- Added Stop at Phases to Display3.

- Added Phase Stops preferences to ForgePreferences
This commit is contained in:
jendave
2011-08-06 12:29:21 +00:00
parent 6f9ca45d29
commit f0538ab500
6 changed files with 131 additions and 16 deletions

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -893,4 +893,12 @@ public class GuiDisplay2 extends javax.swing.JFrame implements CardContainer, Di
return true;
}
public boolean loadPhases(){
return false;
}
public boolean savePhases(){
return false;
}
}

View File

@@ -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();
}
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;
}
return true;
}
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();

View File

@@ -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])
@@ -1042,6 +1040,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);
// Phases

View File

@@ -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<SavePreferencesListener> saveListeners = new ArrayList<SavePreferencesListener>();
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");