mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Code cleanup
This commit is contained in:
@@ -244,8 +244,12 @@ public enum FControl implements KeyEventDispatcher {
|
|||||||
setGlobalKeyboardHandler();
|
setGlobalKeyboardHandler();
|
||||||
|
|
||||||
FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Opening main window...");
|
FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Opening main window...");
|
||||||
SwingUtilities.invokeLater(new Runnable() { @Override
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() { Singletons.getView().initialize(); } });
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Singletons.getView().initialize();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setGlobalKeyboardHandler() {
|
private void setGlobalKeyboardHandler() {
|
||||||
@@ -329,8 +333,7 @@ public enum FControl implements KeyEventDispatcher {
|
|||||||
|
|
||||||
/** Remove all children from a specified layer. */
|
/** Remove all children from a specified layer. */
|
||||||
private void clearChildren(final int layer0) {
|
private void clearChildren(final int layer0) {
|
||||||
final Component[] children = FView.SINGLETON_INSTANCE.getLpnDocument()
|
final Component[] children = FView.SINGLETON_INSTANCE.getLpnDocument().getComponentsInLayer(layer0);
|
||||||
.getComponentsInLayer(layer0);
|
|
||||||
|
|
||||||
for (final Component c : children) {
|
for (final Component c : children) {
|
||||||
display.remove(c);
|
display.remove(c);
|
||||||
@@ -353,13 +356,16 @@ public enum FControl implements KeyEventDispatcher {
|
|||||||
public Player getCurrentPlayer() {
|
public Player getCurrentPlayer() {
|
||||||
// try current priority
|
// try current priority
|
||||||
Player currentPriority = game.getPhaseHandler().getPriorityPlayer();
|
Player currentPriority = game.getPhaseHandler().getPriorityPlayer();
|
||||||
if( null != currentPriority && currentPriority.getLobbyPlayer() == FServer.instance.getLobby().getGuiPlayer() )
|
if (null != currentPriority && currentPriority.getLobbyPlayer() == FServer.instance.getLobby().getGuiPlayer()) {
|
||||||
return currentPriority;
|
return currentPriority;
|
||||||
|
}
|
||||||
|
|
||||||
// otherwise find just any player, belonging to this lobbyplayer
|
// otherwise find just any player, belonging to this lobbyplayer
|
||||||
for(Player p : game.getPlayers())
|
for (Player p : game.getPlayers()) {
|
||||||
if(p.getLobbyPlayer() == FServer.instance.getLobby().getGuiPlayer() )
|
if (p.getLobbyPlayer() == FServer.instance.getLobby().getGuiPlayer()) {
|
||||||
return p;
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -386,22 +392,26 @@ public enum FControl implements KeyEventDispatcher {
|
|||||||
public final void stopGame() {
|
public final void stopGame() {
|
||||||
List<Player> pp = new ArrayList<Player>();
|
List<Player> pp = new ArrayList<Player>();
|
||||||
for (Player p : game.getPlayers()) {
|
for (Player p : game.getPlayers()) {
|
||||||
if ( p.getOriginalLobbyPlayer() == FServer.instance.getLobby().getGuiPlayer() )
|
if (p.getOriginalLobbyPlayer() == FServer.instance.getLobby().getGuiPlayer()) {
|
||||||
pp.add(p);
|
pp.add(p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
boolean hasHuman = !pp.isEmpty();
|
boolean hasHuman = !pp.isEmpty();
|
||||||
|
|
||||||
if ( pp.isEmpty() )
|
if (pp.isEmpty()) {
|
||||||
pp.addAll(game.getPlayers()); // no human? then all players surrender!
|
pp.addAll(game.getPlayers()); // no human? then all players surrender!
|
||||||
|
}
|
||||||
|
|
||||||
for(Player p: pp)
|
for (Player p: pp) {
|
||||||
p.concede();
|
p.concede();
|
||||||
|
}
|
||||||
|
|
||||||
Player priorityPlayer = game.getPhaseHandler().getPriorityPlayer();
|
Player priorityPlayer = game.getPhaseHandler().getPriorityPlayer();
|
||||||
boolean humanHasPriority = priorityPlayer == null || priorityPlayer.getLobbyPlayer() == FServer.instance.getLobby().getGuiPlayer();
|
boolean humanHasPriority = priorityPlayer == null || priorityPlayer.getLobbyPlayer() == FServer.instance.getLobby().getGuiPlayer();
|
||||||
|
|
||||||
if ( hasHuman && humanHasPriority )
|
if (hasHuman && humanHasPriority) {
|
||||||
game.getAction().checkGameOverCondition();
|
game.getAction().checkGameOverCondition();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
game.isGameOver(); // this is synchronized method - it's used to make Game-0 thread see changes made here
|
game.isGameOver(); // this is synchronized method - it's used to make Game-0 thread see changes made here
|
||||||
inputQueue.onGameOver(false); // release any waiting input, effectively passing priority
|
inputQueue.onGameOver(false); // release any waiting input, effectively passing priority
|
||||||
@@ -458,7 +468,6 @@ public enum FControl implements KeyEventDispatcher {
|
|||||||
CStack.SINGLETON_INSTANCE.setModel(game.getStack(), humanLobbyPlayer);
|
CStack.SINGLETON_INSTANCE.setModel(game.getStack(), humanLobbyPlayer);
|
||||||
CLog.SINGLETON_INSTANCE.setModel(game.getGameLog());
|
CLog.SINGLETON_INSTANCE.setModel(game.getGameLog());
|
||||||
|
|
||||||
|
|
||||||
Singletons.getModel().getPreferences().actuateMatchPreferences();
|
Singletons.getModel().getPreferences().actuateMatchPreferences();
|
||||||
|
|
||||||
setCurrentScreen(FScreen.MATCH_SCREEN);
|
setCurrentScreen(FScreen.MATCH_SCREEN);
|
||||||
@@ -542,6 +551,5 @@ public enum FControl implements KeyEventDispatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user