mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08: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 org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
@@ -150,26 +149,20 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
playerPanels.get(0).initialize(FPref.CONSTRUCTED_P1_DECK_STATE, DeckType.PRECONSTRUCTED_DECK);
|
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
|
FThreads.invokeInEdtLater(new Runnable() {
|
||||||
playerPanels.get(1).initialize(FPref.CONSTRUCTED_P2_DECK_STATE, DeckType.COLOR_DECK);
|
@Override
|
||||||
/*playerPanels.get(2).initialize(FPref.CONSTRUCTED_P3_DECK_STATE, DeckType.COLOR_DECK);
|
public void run() {
|
||||||
playerPanels.get(3).initialize(FPref.CONSTRUCTED_P4_DECK_STATE, DeckType.COLOR_DECK);
|
btnStart.setEnabled(lobby instanceof LocalLobby);
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -539,4 +532,8 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
|||||||
public List<PlayerPanel> getPlayerPanels() {
|
public List<PlayerPanel> getPlayerPanels() {
|
||||||
return playerPanels;
|
return playerPanels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FScrollPane getPlayersScroll() {
|
||||||
|
return playersScroll;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,24 +82,11 @@ public class PlayerPanel extends FContainer {
|
|||||||
allowNetworking = allowNetworking0;
|
allowNetworking = allowNetworking0;
|
||||||
index = index0;
|
index = index0;
|
||||||
populateTeamsComboBoxes();
|
populateTeamsComboBoxes();
|
||||||
if (slot == null) {
|
setTeam(slot.getTeam());
|
||||||
setTeam(index);
|
setIsArchenemy(slot.isArchenemy());
|
||||||
if (index > 0) {
|
setType(slot.getType());
|
||||||
setType(LobbySlotType.AI);
|
setPlayerName(slot.getName());
|
||||||
}
|
setAvatarIndex(slot.getAvatarIndex());
|
||||||
else {
|
|
||||||
setIsArchenemy(true);
|
|
||||||
}
|
|
||||||
setPlayerName("");
|
|
||||||
setAvatarIndex(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
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
|
btnDeck.setEnabled(false); //disable deck button until done loading decks
|
||||||
|
|
||||||
@@ -299,9 +286,6 @@ public class PlayerPanel extends FContainer {
|
|||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
boolean wasAi = isAi();
|
boolean wasAi = isAi();
|
||||||
boolean isAi = humanAiSwitch.isToggled();
|
boolean isAi = humanAiSwitch.isToggled();
|
||||||
if (wasAi != isAi) {
|
|
||||||
onIsAiChanged(isAi);
|
|
||||||
}
|
|
||||||
if (isAi) {
|
if (isAi) {
|
||||||
type = LobbySlotType.AI;
|
type = LobbySlotType.AI;
|
||||||
}
|
}
|
||||||
@@ -312,6 +296,18 @@ public class PlayerPanel extends FContainer {
|
|||||||
else {
|
else {
|
||||||
type = LobbySlotType.LOCAL;
|
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);
|
txtPlayerName.setEnabled(mayEdit);
|
||||||
nameRandomiser.setEnabled(mayEdit);
|
nameRandomiser.setEnabled(mayEdit);
|
||||||
updateVariantControlsVisibility();
|
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) {
|
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
|
//Temporary lobby instance to use for OnlineLobby before connecting to a server
|
||||||
public final class OfflineLobby extends GameLobby {
|
public final class OfflineLobby extends GameLobby {
|
||||||
public OfflineLobby() {
|
public OfflineLobby() {
|
||||||
super(false);
|
super(true);
|
||||||
|
|
||||||
final String humanName = localName();
|
final String humanName = localName();
|
||||||
final int[] avatarIndices = localAvatarIndices();
|
final int[] avatarIndices = localAvatarIndices();
|
||||||
|
|||||||
@@ -42,24 +42,29 @@ public final class ServerGameLobby extends GameLobby {
|
|||||||
updateView(false);
|
updateView(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean hasControl() {
|
@Override
|
||||||
|
public boolean hasControl() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean mayEdit(final int index) {
|
@Override
|
||||||
|
public boolean mayEdit(final int index) {
|
||||||
final LobbySlotType type = getSlot(index).getType();
|
final LobbySlotType type = getSlot(index).getType();
|
||||||
return type != LobbySlotType.REMOTE && type != LobbySlotType.OPEN;
|
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;
|
return getSlot(index).getType() != LobbySlotType.REMOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean mayRemove(final int index) {
|
@Override
|
||||||
|
public boolean mayRemove(final int index) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected IGuiGame getGui(final int index) {
|
@Override
|
||||||
|
protected IGuiGame getGui(final int index) {
|
||||||
return FServerManager.getInstance().getGui(index);
|
return FServerManager.getInstance().getGui(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user