diff --git a/src/forge/Display.java b/src/forge/Display.java index 9ebdddc49a6..1088a5218a4 100644 --- a/src/forge/Display.java +++ b/src/forge/Display.java @@ -31,4 +31,8 @@ public interface Display { //public void addAssignDamage(Card attacker, int damage); public boolean stopAtPhase(Player turn, String phase); + + public boolean loadPhases(); + + public boolean savePhases(); } diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index 630db6777da..1ff5e5fc3e1 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -486,6 +486,7 @@ public class GameAction { if(!frame.isDisplayable()) return; if(checkEndGameSate()) { + AllZone.Display.savePhases(); frame.dispose(); if (!Constant.Quest.fantasyQuest[0]) new Gui_WinLose(); @@ -2341,6 +2342,7 @@ public class GameAction { AllZone.Stack.reset(); AllZone.Combat.reset(); AllZone.Display.showCombat(""); + AllZone.Display.loadPhases(); AllZone.Human_Graveyard.reset(); AllZone.Human_Hand.reset(); diff --git a/src/forge/GuiDisplay2.java b/src/forge/GuiDisplay2.java index 96b6b51e6a1..06814a93935 100644 --- a/src/forge/GuiDisplay2.java +++ b/src/forge/GuiDisplay2.java @@ -892,5 +892,13 @@ public class GuiDisplay2 extends javax.swing.JFrame implements CardContainer, Di // is display2 even used? return true; } + + public boolean loadPhases(){ + + return false; + } + public boolean savePhases(){ + return false; + } } diff --git a/src/forge/GuiDisplay3.java b/src/forge/GuiDisplay3.java index 6e089ff57c9..02dd365a7ed 100644 --- a/src/forge/GuiDisplay3.java +++ b/src/forge/GuiDisplay3.java @@ -69,6 +69,7 @@ import forge.gui.ListChooser; import forge.gui.game.CardDetailPanel; import forge.gui.game.CardPanel; import forge.gui.game.CardPicturePanel; +import forge.properties.ForgePreferences; import forge.properties.ForgeProps; import forge.properties.NewConstants; @@ -78,10 +79,6 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo private GuiInput inputControl; - //Font statFont = new Font("MS Sans Serif", Font.PLAIN, 12); - //Font lifeFont = new Font("MS Sans Serif", Font.PLAIN, 40); - //Font checkboxFont = new Font("MS Sans Serif", Font.PLAIN, 9); - Font statFont = new Font("Dialog", Font.PLAIN, 12); Font lifeFont = new Font("Dialog", Font.PLAIN, 40); Font checkboxFont = new Font("Dialog", Font.PLAIN, 9); @@ -171,7 +168,7 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo private void addMenu() { Object[] obj = { HUMAN_GRAVEYARD_ACTION, HUMAN_REMOVED_ACTION, HUMAN_FLASHBACK_ACTION, COMPUTER_GRAVEYARD_ACTION, - COMPUTER_REMOVED_ACTION, new JSeparator(), GuiDisplay3.eotCheckboxForMenu, + COMPUTER_REMOVED_ACTION, new JSeparator(), GuiDisplay3.playsoundCheckboxForMenu, new JSeparator(), ErrorViewer.ALL_THREADS_ACTION, CONCEDE_ACTION}; @@ -183,8 +180,22 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo else throw new AssertionError(); } + JMenu gamePhases = new JMenu(ForgeProps.getLocalized(MENU_BAR.PHASE.TITLE)); + + JMenuItem aiLabel = new JMenuItem("Computer"); + JMenuItem humanLabel = new JMenuItem("Human"); + + Component[] objPhases = { aiLabel, GuiDisplay3.cbAIUpkeep , GuiDisplay3.cbAIDraw , GuiDisplay3.cbAIEndOfTurn, new JSeparator(), + humanLabel, GuiDisplay3.cbHumanUpkeep, GuiDisplay3.cbHumanDraw, GuiDisplay3.cbHumanEndOfTurn }; + + for(Component cmp:objPhases) { + gamePhases.add(cmp); + } + + JMenuBar menuBar = new JMenuBar(); menuBar.add(gameMenu); + menuBar.add(gamePhases); menuBar.add(new MenuItem_HowToPlay()); this.setJMenuBar(menuBar); }//addMenu() @@ -1005,6 +1016,7 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo * Exit the Application */ private void concede() { + savePhases(); dispose(); Constant.Runtime.WinLose.addLose(); if (!Constant.Quest.fantasyQuest[0]) @@ -1023,19 +1035,62 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo } } - public boolean stopAtPhase(Player turn, String phase) { - // fill this in + public boolean stopAtPhase(Player turn, String phase) { if (turn.isComputer()){ if (phase.equals(Constant.Phase.End_Of_Turn)) - return eotCheckboxForMenu.isSelected(); + return cbAIEndOfTurn.isSelected(); + else if (phase.equals(Constant.Phase.Upkeep)) + return cbAIUpkeep.isSelected(); + else if (phase.equals(Constant.Phase.Draw)) + return cbAIDraw.isSelected(); } - - return true; - } + else{ + if (phase.equals(Constant.Phase.End_Of_Turn)) + return cbHumanEndOfTurn.isSelected(); + else if (phase.equals(Constant.Phase.Upkeep)) + return cbHumanUpkeep.isSelected(); + else if (phase.equals(Constant.Phase.Draw)) + return cbHumanDraw.isSelected(); + } + return false; + } + + public boolean loadPhases(){ + ForgePreferences fp = Gui_NewGame.preferences; + + cbAIUpkeep.setSelected(fp.bAIUpkeep); + cbAIDraw.setSelected(fp.bAIDraw); + cbAIEndOfTurn.setSelected(fp.bAIEOT); + cbHumanUpkeep.setSelected(fp.bHumanUpkeep); + cbHumanDraw.setSelected(fp.bHumanDraw); + cbHumanEndOfTurn.setSelected(fp.bHumanEOT); + + return true; + } + + public boolean savePhases(){ + ForgePreferences fp = Gui_NewGame.preferences; + + fp.bAIUpkeep = cbAIUpkeep.isSelected(); + fp.bAIDraw = cbAIDraw.isSelected(); + fp.bAIEOT = cbAIEndOfTurn.isSelected(); + fp.bHumanUpkeep = cbHumanUpkeep.isSelected(); + fp.bHumanDraw = cbHumanDraw.isSelected(); + fp.bHumanEOT = cbHumanEndOfTurn.isSelected(); + + return true; + } - public static JCheckBoxMenuItem eotCheckboxForMenu = new JCheckBoxMenuItem("Stop at End of Turn", true); public static JCheckBoxMenuItem playsoundCheckboxForMenu = new JCheckBoxMenuItem("Play Sound", false); + // Phases + public static JCheckBoxMenuItem cbAIUpkeep = new JCheckBoxMenuItem("Upkeep", true); + public static JCheckBoxMenuItem cbAIDraw = new JCheckBoxMenuItem("Draw", true); + public static JCheckBoxMenuItem cbAIEndOfTurn = new JCheckBoxMenuItem("End of Turn", true); + public static JCheckBoxMenuItem cbHumanUpkeep = new JCheckBoxMenuItem("Upkeep", true); + public static JCheckBoxMenuItem cbHumanDraw = new JCheckBoxMenuItem("Draw", true); + public static JCheckBoxMenuItem cbHumanEndOfTurn = new JCheckBoxMenuItem("End of Turn", true); + JXMultiSplitPane pane = new JXMultiSplitPane(); JButton cancelButton = new JButton(); JButton okButton = new JButton(); diff --git a/src/forge/GuiDisplay4.java b/src/forge/GuiDisplay4.java index 2c9ffd680a2..8e4f6102007 100644 --- a/src/forge/GuiDisplay4.java +++ b/src/forge/GuiDisplay4.java @@ -76,6 +76,7 @@ import forge.gui.ForgeAction; import forge.gui.ListChooser; import forge.gui.game.CardDetailPanel; import forge.gui.game.CardPanel; +import forge.properties.ForgePreferences; import forge.properties.ForgeProps; import forge.properties.NewConstants; @@ -85,10 +86,6 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo private GuiInput inputControl; - //Font statFont = new Font("MS Sans Serif", Font.PLAIN, 12); - //Font lifeFont = new Font("MS Sans Serif", Font.PLAIN, 40); - //Font checkboxFont = new Font("MS Sans Serif", Font.PLAIN, 9); - Font statFont = new Font("Dialog", Font.PLAIN, 12); Font lifeFont = new Font("Dialog", Font.PLAIN, 40); Font checkboxFont = new Font("Dialog", Font.PLAIN, 9); @@ -1004,6 +1001,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo * Exit the Application */ private void concede() { + savePhases(); dispose(); Constant.Runtime.WinLose.addLose(); if (!Constant.Quest.fantasyQuest[0]) @@ -1041,6 +1039,32 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } return false; } + + public boolean loadPhases(){ + ForgePreferences fp = Gui_NewGame.preferences; + + cbAIUpkeep.setSelected(fp.bAIUpkeep); + cbAIDraw.setSelected(fp.bAIDraw); + cbAIEndOfTurn.setSelected(fp.bAIEOT); + cbHumanUpkeep.setSelected(fp.bHumanUpkeep); + cbHumanDraw.setSelected(fp.bHumanDraw); + cbHumanEndOfTurn.setSelected(fp.bHumanEOT); + + return true; + } + + public boolean savePhases(){ + ForgePreferences fp = Gui_NewGame.preferences; + + fp.bAIUpkeep = cbAIUpkeep.isSelected(); + fp.bAIDraw = cbAIDraw.isSelected(); + fp.bAIEOT = cbAIEndOfTurn.isSelected(); + fp.bHumanUpkeep = cbHumanUpkeep.isSelected(); + fp.bHumanDraw = cbHumanDraw.isSelected(); + fp.bHumanEOT = cbHumanEndOfTurn.isSelected(); + + return true; + } public static JCheckBoxMenuItem playsoundCheckboxForMenu = new JCheckBoxMenuItem("Play Sound", false); diff --git a/src/forge/properties/ForgePreferences.java b/src/forge/properties/ForgePreferences.java index 3e082834dc9..ea428be0fa1 100644 --- a/src/forge/properties/ForgePreferences.java +++ b/src/forge/properties/ForgePreferences.java @@ -22,6 +22,13 @@ public class ForgePreferences extends Preferences { public CardSizeType cardSize; public boolean cardOverlay; public boolean scaleLargerThanOriginal; + // Phases + public boolean bAIUpkeep; + public boolean bAIDraw; + public boolean bAIEOT; + public boolean bHumanUpkeep; + public boolean bHumanDraw; + public boolean bHumanEOT; private List saveListeners = new ArrayList(); private final String fileName; @@ -55,6 +62,14 @@ public class ForgePreferences extends Preferences { stackOffset = StackOffsetType.valueOf(get("stack.offset", "tiny")); maxStackSize = getInt("stack.max.size", 3); scaleLargerThanOriginal = getBoolean("card.scale.larger.than.original", true); + + // Stop at Phases + bAIUpkeep = getBoolean("phase.ai.upkeep", true); + bAIDraw = getBoolean("phase.ai.draw", true); + bAIEOT = getBoolean("phase.ai.eot", true); + bHumanUpkeep = getBoolean("phase.human.upkeep", true); + bHumanDraw = getBoolean("phase.human.draw", true); + bHumanEOT = getBoolean("phase.human.eot", true); } public void save () throws Exception{ @@ -75,6 +90,13 @@ public class ForgePreferences extends Preferences { for (SavePreferencesListener listeners : saveListeners) listeners.savePreferences(); + set("phase.ai.upkeep", bAIUpkeep); + set("phase.ai.draw", bAIDraw); + set("phase.ai.eot", bAIEOT); + set("phase.human.upkeep", bHumanUpkeep); + set("phase.human.draw", bHumanDraw); + set("phase.human.eot", bHumanEOT); + try { FileOutputStream stream = new FileOutputStream(fileName); store(stream, "Forge");