mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Allow toggling between Open and AI
This commit is contained in:
@@ -4,7 +4,6 @@ import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
@@ -150,26 +149,20 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
||||
@Override
|
||||
public void run() {
|
||||
playerPanels.get(0).initialize(FPref.CONSTRUCTED_P1_DECK_STATE, DeckType.PRECONSTRUCTED_DECK);
|
||||
playerPanels.get(1).initialize(FPref.CONSTRUCTED_P2_DECK_STATE, DeckType.COLOR_DECK);
|
||||
/*playerPanels.get(2).initialize(FPref.CONSTRUCTED_P3_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(3).initialize(FPref.CONSTRUCTED_P4_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(4).initialize(FPref.CONSTRUCTED_P5_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(5).initialize(FPref.CONSTRUCTED_P6_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(6).initialize(FPref.CONSTRUCTED_P7_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(7).initialize(FPref.CONSTRUCTED_P8_DECK_STATE, DeckType.COLOR_DECK);*/ //TODO: Support multiplayer and improve performance of loading this screen by using background thread
|
||||
|
||||
if (lobby instanceof LocalLobby) { //only initialize other decks for Constructed screen
|
||||
playerPanels.get(1).initialize(FPref.CONSTRUCTED_P2_DECK_STATE, DeckType.COLOR_DECK);
|
||||
/*playerPanels.get(2).initialize(FPref.CONSTRUCTED_P3_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(3).initialize(FPref.CONSTRUCTED_P4_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(4).initialize(FPref.CONSTRUCTED_P5_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(5).initialize(FPref.CONSTRUCTED_P6_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(6).initialize(FPref.CONSTRUCTED_P7_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(7).initialize(FPref.CONSTRUCTED_P8_DECK_STATE, DeckType.COLOR_DECK);*/ //TODO: Support multiplayer and improve performance of loading this screen by using background thread
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
btnStart.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
Gdx.graphics.requestRendering();
|
||||
}
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
btnStart.setEnabled(lobby instanceof LocalLobby);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -539,4 +532,8 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
||||
public List<PlayerPanel> getPlayerPanels() {
|
||||
return playerPanels;
|
||||
}
|
||||
|
||||
public FScrollPane getPlayersScroll() {
|
||||
return playersScroll;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,27 +82,14 @@ public class PlayerPanel extends FContainer {
|
||||
allowNetworking = allowNetworking0;
|
||||
index = index0;
|
||||
populateTeamsComboBoxes();
|
||||
if (slot == null) {
|
||||
setTeam(index);
|
||||
if (index > 0) {
|
||||
setType(LobbySlotType.AI);
|
||||
}
|
||||
else {
|
||||
setIsArchenemy(true);
|
||||
}
|
||||
setPlayerName("");
|
||||
setAvatarIndex(0);
|
||||
}
|
||||
else {
|
||||
setTeam(slot.getTeam());
|
||||
setIsArchenemy(slot.isArchenemy());
|
||||
setType(slot.getType());
|
||||
setPlayerName(slot.getName());
|
||||
setAvatarIndex(slot.getAvatarIndex());
|
||||
}
|
||||
setTeam(slot.getTeam());
|
||||
setIsArchenemy(slot.isArchenemy());
|
||||
setType(slot.getType());
|
||||
setPlayerName(slot.getName());
|
||||
setAvatarIndex(slot.getAvatarIndex());
|
||||
|
||||
btnDeck.setEnabled(false); //disable deck button until done loading decks
|
||||
|
||||
|
||||
boolean isAi = isAi();
|
||||
deckChooser = new FDeckChooser(GameType.Constructed, isAi, new FEventHandler() {
|
||||
@Override
|
||||
@@ -299,9 +286,6 @@ public class PlayerPanel extends FContainer {
|
||||
public void handleEvent(FEvent e) {
|
||||
boolean wasAi = isAi();
|
||||
boolean isAi = humanAiSwitch.isToggled();
|
||||
if (wasAi != isAi) {
|
||||
onIsAiChanged(isAi);
|
||||
}
|
||||
if (isAi) {
|
||||
type = LobbySlotType.AI;
|
||||
}
|
||||
@@ -312,6 +296,18 @@ public class PlayerPanel extends FContainer {
|
||||
else {
|
||||
type = LobbySlotType.LOCAL;
|
||||
}
|
||||
|
||||
if (wasAi != isAi) {
|
||||
onIsAiChanged(isAi);
|
||||
}
|
||||
|
||||
LobbySlot slot = screen.getLobby().getSlot(index);
|
||||
slot.setType(type);
|
||||
|
||||
//update may edit in-case it changed as a result of the AI change
|
||||
setMayEdit(screen.getLobby().mayEdit(index));
|
||||
setAvatarIndex(slot.getAvatarIndex());
|
||||
setPlayerName(slot.getName());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -615,6 +611,11 @@ public class PlayerPanel extends FContainer {
|
||||
txtPlayerName.setEnabled(mayEdit);
|
||||
nameRandomiser.setEnabled(mayEdit);
|
||||
updateVariantControlsVisibility();
|
||||
|
||||
//if panel has height already, ensure height updated to account for button visibility changes
|
||||
if (getHeight() > 0) {
|
||||
screen.getPlayersScroll().revalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMayControl(boolean mayControl0) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import forge.match.LobbySlotType;
|
||||
//Temporary lobby instance to use for OnlineLobby before connecting to a server
|
||||
public final class OfflineLobby extends GameLobby {
|
||||
public OfflineLobby() {
|
||||
super(false);
|
||||
super(true);
|
||||
|
||||
final String humanName = localName();
|
||||
final int[] avatarIndices = localAvatarIndices();
|
||||
|
||||
@@ -42,24 +42,29 @@ public final class ServerGameLobby extends GameLobby {
|
||||
updateView(false);
|
||||
}
|
||||
|
||||
@Override public boolean hasControl() {
|
||||
@Override
|
||||
public boolean hasControl() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean mayEdit(final int index) {
|
||||
@Override
|
||||
public boolean mayEdit(final int index) {
|
||||
final LobbySlotType type = getSlot(index).getType();
|
||||
return type != LobbySlotType.REMOTE && type != LobbySlotType.OPEN;
|
||||
}
|
||||
|
||||
@Override public boolean mayControl(final int index) {
|
||||
@Override
|
||||
public boolean mayControl(final int index) {
|
||||
return getSlot(index).getType() != LobbySlotType.REMOTE;
|
||||
}
|
||||
|
||||
@Override public boolean mayRemove(final int index) {
|
||||
@Override
|
||||
public boolean mayRemove(final int index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override protected IGuiGame getGui(final int index) {
|
||||
@Override
|
||||
protected IGuiGame getGui(final int index) {
|
||||
return FServerManager.getInstance().getGui(index);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user