diff --git a/.gitattributes b/.gitattributes
index 7f9009ef7fe..a8bdee7987c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -9805,6 +9805,7 @@ res/images/deckeditor/filter_sorcery_n.png -text svneol=unset#image/png
res/images/deckeditor/filter_sorcery_y.png -text svneol=unset#image/png
res/images/deckeditor/filter_white_n.png -text svneol=unset#image/png
res/images/deckeditor/filter_white_y.png -text svneol=unset#image/png
+res/images/skins/default/bg_match.jpg -text
res/images/skins/default/bg_splash.jpg -text
res/images/skins/default/btnLdown.png -text
res/images/skins/default/btnLover.png -text
@@ -9818,9 +9819,9 @@ res/images/skins/default/btnRup.png -text
res/images/skins/default/font1.ttf -text
res/images/skins/default/font2.ttf -text
res/images/skins/default/palette.png -text
+res/images/skins/default/sprite.png -text
res/images/skins/default/texture1.jpg -text
-res/images/skins/default/texture2.jpg -text
-res/images/skins/default/texture3.jpg -text
+res/images/skins/rebel/bg_match.jpg -text
res/images/skins/rebel/bg_splash.jpg -text
res/images/skins/rebel/btnLdown.png -text
res/images/skins/rebel/btnLover.png -text
@@ -9834,9 +9835,8 @@ res/images/skins/rebel/btnRup.png -text
res/images/skins/rebel/font1.ttf -text
res/images/skins/rebel/font2.ttf -text
res/images/skins/rebel/palette.png -text
+res/images/skins/rebel/sprite.png -text
res/images/skins/rebel/texture1.jpg -text
-res/images/skins/rebel/texture2.jpg -text
-res/images/skins/rebel/texture3.jpg -text
res/images/symbols-13/0.png -text svneol=unset#image/png
res/images/symbols-13/1.png -text svneol=unset#image/png
res/images/symbols-13/10.png -text svneol=unset#image/png
@@ -9891,6 +9891,12 @@ res/images/symbols-13/counters2.png -text
res/images/symbols-13/counters3.png -text
res/images/symbols-13/countersMulti.png -text
res/images/symbols-13/defend.png -text svneol=unset#image/png
+res/images/symbols-13/detail_exile.png -text
+res/images/symbols-13/detail_flashback.png -text
+res/images/symbols-13/detail_grave.png -text
+res/images/symbols-13/detail_hand.png -text
+res/images/symbols-13/detail_library.png -text
+res/images/symbols-13/detail_poison.png -text
res/images/symbols-13/foil01.png -text svneol=unset#image/png
res/images/symbols-13/foil02.png -text svneol=unset#image/png
res/images/symbols-13/foil03.png -text svneol=unset#image/png
@@ -10692,6 +10698,18 @@ src/main/java/forge/card/trigger/TriggerTurnFaceUp.java svneol=native#text/plain
src/main/java/forge/card/trigger/TriggerUnequip.java svneol=native#text/plain
src/main/java/forge/card/trigger/TriggerUntaps.java svneol=native#text/plain
src/main/java/forge/card/trigger/package-info.java svneol=native#text/plain
+src/main/java/forge/control/ControlAllUI.java -text
+src/main/java/forge/control/ControlEditorUI.java -text
+src/main/java/forge/control/ControlHomeUI.java -text
+src/main/java/forge/control/ControlMatchUI.java -text
+src/main/java/forge/control/match/ControlCardviewer.java -text
+src/main/java/forge/control/match/ControlDock.java -text
+src/main/java/forge/control/match/ControlField.java -text
+src/main/java/forge/control/match/ControlHand.java -text
+src/main/java/forge/control/match/ControlInput.java -text
+src/main/java/forge/control/match/ControlTabber.java -text
+src/main/java/forge/control/match/package-info.java -text
+src/main/java/forge/control/package-info.java -text
src/main/java/forge/deck/Deck.java svneol=native#text/plain
src/main/java/forge/deck/DeckGeneration.java -text
src/main/java/forge/deck/DeckManager.java svneol=native#text/plain
@@ -10848,6 +10866,18 @@ src/main/java/forge/quest/gui/main/package-info.java svneol=native#text/plain
src/main/java/forge/quest/gui/package-info.java svneol=native#text/plain
src/main/java/forge/quest/package-info.java svneol=native#text/plain
src/main/java/forge/view/FView.java svneol=native#text/plain
+src/main/java/forge/view/GuiTopLevel.java -text
+src/main/java/forge/view/home/HomeTopLevel.java -text
+src/main/java/forge/view/match/ViewAreaBattlefield.java -text
+src/main/java/forge/view/match/ViewAreaSidebar.java -text
+src/main/java/forge/view/match/ViewAreaUser.java -text
+src/main/java/forge/view/match/ViewCardviewer.java -text
+src/main/java/forge/view/match/ViewDock.java -text
+src/main/java/forge/view/match/ViewField.java -text
+src/main/java/forge/view/match/ViewHand.java -text
+src/main/java/forge/view/match/ViewInput.java -text
+src/main/java/forge/view/match/ViewTabber.java -text
+src/main/java/forge/view/match/ViewTopLevel.java -text
src/main/java/forge/view/package-info.java svneol=native#text/plain
src/main/java/forge/view/swing/ApplicationView.java svneol=native#text/plain
src/main/java/forge/view/swing/GuiHomeScreen.java svneol=native#text/plain
@@ -10859,6 +10889,10 @@ src/main/java/forge/view/swing/SplashProgressModel.java -text
src/main/java/forge/view/swing/WinLoseFrame.java -text
src/main/java/forge/view/swing/WinLoseModeHandler.java -text
src/main/java/forge/view/swing/package-info.java svneol=native#text/plain
+src/main/java/forge/view/toolbox/CardDetailPanel.java -text
+src/main/java/forge/view/toolbox/CardViewer.java -text
+src/main/java/forge/view/toolbox/FOverlay.java -text
+src/main/java/forge/view/toolbox/FVerticalTabPanel.java -text
src/main/java/net/slightlymagic/braids/LICENSE.txt svneol=native#text/plain
src/main/java/net/slightlymagic/braids/util/ClumsyRunnable.java svneol=native#text/plain
src/main/java/net/slightlymagic/braids/util/ImmutableIterableFrom.java svneol=native#text/plain
diff --git a/.gitignore b/.gitignore
index a9ec3ba43b7..144d82156da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,8 +17,22 @@ res/quest/questData.dat
res/quest/questData.dat.xml
res/reprintSetInfo.log
res/setInfoScript.log
+src/main/java/forge/control
+src/main/java/forge/gui/control
+src/main/java/forge/gui/ds
+src/main/java/forge/gui/editor
+src/main/java/forge/gui/home
src/main/java/forge/gui/match
+src/main/java/forge/gui/matchOLD
src/main/java/forge/gui/toolbox
src/main/java/forge/gui/unfinished
+src/main/java/forge/interfaces
+src/main/java/forge/view/components
+src/main/java/forge/view/controllers
+src/main/java/forge/view/editor
+src/main/java/forge/view/home
+src/main/java/forge/view/interfaces
+src/main/java/forge/view/match
+src/main/java/forge/view/toolbox
/target
/test-output
diff --git a/res/images/skins/default/bg_match.jpg b/res/images/skins/default/bg_match.jpg
new file mode 100644
index 00000000000..51a480836b8
Binary files /dev/null and b/res/images/skins/default/bg_match.jpg differ
diff --git a/res/images/skins/default/sprite.png b/res/images/skins/default/sprite.png
new file mode 100644
index 00000000000..0492e8ce5cf
Binary files /dev/null and b/res/images/skins/default/sprite.png differ
diff --git a/res/images/skins/default/texture2.jpg b/res/images/skins/default/texture2.jpg
deleted file mode 100644
index 6fc0e6f890f..00000000000
Binary files a/res/images/skins/default/texture2.jpg and /dev/null differ
diff --git a/res/images/skins/default/texture3.jpg b/res/images/skins/default/texture3.jpg
deleted file mode 100644
index 023287f74d9..00000000000
Binary files a/res/images/skins/default/texture3.jpg and /dev/null differ
diff --git a/res/images/skins/rebel/bg_match.jpg b/res/images/skins/rebel/bg_match.jpg
new file mode 100644
index 00000000000..f84722e6b0b
Binary files /dev/null and b/res/images/skins/rebel/bg_match.jpg differ
diff --git a/res/images/skins/rebel/sprite.png b/res/images/skins/rebel/sprite.png
new file mode 100644
index 00000000000..6b8f9a8567a
Binary files /dev/null and b/res/images/skins/rebel/sprite.png differ
diff --git a/res/images/skins/rebel/texture2.jpg b/res/images/skins/rebel/texture2.jpg
deleted file mode 100644
index 75a621f202d..00000000000
Binary files a/res/images/skins/rebel/texture2.jpg and /dev/null differ
diff --git a/res/images/skins/rebel/texture3.jpg b/res/images/skins/rebel/texture3.jpg
deleted file mode 100644
index c01bfb91604..00000000000
Binary files a/res/images/skins/rebel/texture3.jpg and /dev/null differ
diff --git a/res/images/symbols-13/detail_exile.png b/res/images/symbols-13/detail_exile.png
new file mode 100644
index 00000000000..4fc20ba1d23
Binary files /dev/null and b/res/images/symbols-13/detail_exile.png differ
diff --git a/res/images/symbols-13/detail_flashback.png b/res/images/symbols-13/detail_flashback.png
new file mode 100644
index 00000000000..a71a1b4473e
Binary files /dev/null and b/res/images/symbols-13/detail_flashback.png differ
diff --git a/res/images/symbols-13/detail_grave.png b/res/images/symbols-13/detail_grave.png
new file mode 100644
index 00000000000..1b04cf022bd
Binary files /dev/null and b/res/images/symbols-13/detail_grave.png differ
diff --git a/res/images/symbols-13/detail_hand.png b/res/images/symbols-13/detail_hand.png
new file mode 100644
index 00000000000..0b1487be445
Binary files /dev/null and b/res/images/symbols-13/detail_hand.png differ
diff --git a/res/images/symbols-13/detail_library.png b/res/images/symbols-13/detail_library.png
new file mode 100644
index 00000000000..91d5698ea14
Binary files /dev/null and b/res/images/symbols-13/detail_library.png differ
diff --git a/res/images/symbols-13/detail_poison.png b/res/images/symbols-13/detail_poison.png
new file mode 100644
index 00000000000..de6721ad7ad
Binary files /dev/null and b/res/images/symbols-13/detail_poison.png differ
diff --git a/res/lang/de.properties b/res/lang/de.properties
index ea2122654f3..acf48eb9f94 100644
--- a/res/lang/de.properties
+++ b/res/lang/de.properties
@@ -134,7 +134,7 @@ NewGame/booster_text=Booster Draft (Schwierig) - W
NewGame/yourdeck=Dein Deck
NewGame/opponent=Gegner
NewGame/deckeditor=Deck Editor
-NewGame/newgui=New Gui
+NewGame/oldgui=Old Gui
NewGame/ailand=Stack AI Land
NewGame/devmode=Developer Mode
NewGame/questmode=Quest Mode
@@ -142,7 +142,7 @@ NewGame/startgame=Spiel starten
NewGame/savesealed_msg=Please name this sealed deck
NewGame/savesealed_ttl=Save Sealed Deck
-WinLose/won=Siege:
+WinLose/won=Siege:
WinLose/lost=, Niederlagen:
WinLose/win=Gewonnen
WinLose/lose=Verloren
diff --git a/res/lang/en.properties b/res/lang/en.properties
index 725391cda54..6e9a15ce40f 100644
--- a/res/lang/en.properties
+++ b/res/lang/en.properties
@@ -172,7 +172,7 @@ NewGame/booster_text=Booster Draft (Hard) - Pick cards 1 at a time to create you
NewGame/yourdeck=Your Deck
NewGame/opponent=Opponent
NewGame/deckeditor=Deck Editor
-NewGame/newgui=New Gui
+NewGame/oldgui=Old Gui
NewGame/ailand=Stack AI Land
NewGame/devmode=Developer Mode
NewGame/questmode=Quest Mode
diff --git a/src/main/java/forge/AllZone.java b/src/main/java/forge/AllZone.java
index 43d324f1316..01cdff41e51 100644
--- a/src/main/java/forge/AllZone.java
+++ b/src/main/java/forge/AllZone.java
@@ -11,6 +11,7 @@ import forge.card.trigger.TriggerHandler;
import forge.deck.DeckManager;
import forge.game.GameSummary;
import forge.gui.input.InputControl;
+import forge.view.toolbox.FOverlay;
import forge.gui.skin.FSkin;
import forge.model.FGameState;
import forge.properties.ForgeProps;
@@ -78,6 +79,9 @@ public final class AllZone {
/** Global display. */
private static Display display;
+ /** Global overlay. */
+ private static FOverlay overlay;
+
/** Constant DECK_MGR. */
private static DeckManager deckManager;
@@ -629,4 +633,18 @@ public final class AllZone {
public static void setSkin(final FSkin fs) {
skin = fs;
}
+
+ /**
+ * @return overlay
+ */
+ public static FOverlay getOverlay() {
+ return overlay;
+ }
+
+ /**
+ * @param overlay0 Overlay panel
+ */
+ public static void setOverlay(FOverlay overlay0) {
+ overlay = overlay0;
+ }
} // AllZone
diff --git a/src/main/java/forge/Constant.java b/src/main/java/forge/Constant.java
index 2168f96ee66..d5c829c72dc 100644
--- a/src/main/java/forge/Constant.java
+++ b/src/main/java/forge/Constant.java
@@ -40,10 +40,17 @@ public final class Constant {
public static final boolean[] MILL = new boolean[1];
/** The Constant DevMode. */
- public static final boolean[] DEV_MODE = new boolean[1]; // one for
- // normal mode
- // one for quest
- // mode
+ // one for normal mode, one for quest mode
+ public static final boolean[] DEV_MODE = new boolean[1];
+
+ /** The Constant HANDVIEW. */
+ public static final boolean[] HANDVIEW = new boolean[1];
+
+ /** The Constant LIBRARYVIEW. */
+ public static final boolean[] LIBRARYVIEW = new boolean[1];
+
+ /** The Constant OLDGUI. */
+ public static final boolean[] OLDGUI = new boolean[1];
/** The Constant NetConn. */
public static final boolean[] NET_CONN = new boolean[1];
diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java
index ba15dbe7eb0..cc21b310079 100644
--- a/src/main/java/forge/GameAction.java
+++ b/src/main/java/forge/GameAction.java
@@ -42,6 +42,7 @@ import forge.properties.ForgeProps;
import forge.properties.NewConstants.Lang.GameAction.GameActionText;
import forge.quest.gui.QuestWinLoseHandler;
import forge.quest.gui.main.QuestEvent;
+import forge.view.match.ViewTopLevel;
import forge.view.swing.WinLoseFrame;
/**
@@ -776,14 +777,22 @@ public class GameAction {
final boolean refreeze = AllZone.getStack().isFrozen();
AllZone.getStack().setFrozen(true);
- final JFrame frame = (JFrame) AllZone.getDisplay();
- if (!frame.isDisplayable()) {
- return;
+ if (Constant.Runtime.OLDGUI[0]) {
+ final JFrame frame = (JFrame) AllZone.getDisplay();
+ if (!frame.isDisplayable()) {
+ return;
+ }
+ }
+ else {
+ final ViewTopLevel frame = (ViewTopLevel) AllZone.getDisplay();
+ if (!frame.isDisplayable()) {
+ return;
+ }
}
if (this.canShowWinLose && this.checkEndGameSate()) {
AllZone.getDisplay().savePrefs();
- frame.setEnabled(false);
+ //frame.setEnabled(false);
// frame.dispose();
// Gui_WinLose gwl = new Gui_WinLose(AllZone.getMatchState(),
diff --git a/src/main/java/forge/Phase.java b/src/main/java/forge/Phase.java
index e423f2e5ace..44cdd8c1687 100644
--- a/src/main/java/forge/Phase.java
+++ b/src/main/java/forge/Phase.java
@@ -516,6 +516,9 @@ public class Phase extends MyObservable implements java.io.Serializable {
this.turn++;
}
+ // Visual indicators
+ PhaseUtil.visuallyActivatePhase(this.getPhase());
+
// When consecutively skipping phases (like in combat) this section
// pushes through that block
this.updateObservers();
diff --git a/src/main/java/forge/PhaseUtil.java b/src/main/java/forge/PhaseUtil.java
index 1bfa4db521d..fefc0adb898 100644
--- a/src/main/java/forge/PhaseUtil.java
+++ b/src/main/java/forge/PhaseUtil.java
@@ -6,6 +6,8 @@ import java.util.HashMap;
import forge.Constant.Zone;
import forge.card.cardfactory.CardFactoryUtil;
import forge.gui.input.Input;
+import forge.view.match.ViewField.PhaseLabel;
+import forge.view.match.ViewTopLevel;
/**
*
@@ -423,6 +425,7 @@ public class PhaseUtil { */ public static void handleUpkeep() { Player turn = AllZone.getPhase().getPlayerTurn(); + if (skipUpkeep()) { // Slowtrips all say "on the next turn's upkeep" if there is no // upkeep next turn, the trigger will never occur. @@ -623,4 +626,46 @@ public class PhaseUtil { || phase.equals(Constant.Phase.DRAW) || phase.equals(Constant.Phase.MAIN1) || phase.equals(Constant.Phase.COMBAT_BEGIN); } + + /** + * Retrieves and visually activates phase label for appropriate + * phase and player. + * + * @param s Phase state + */ + public static void visuallyActivatePhase(String s) { + PhaseLabel lbl = null; + Player p = AllZone.getPhase().getPlayerTurn(); + ViewTopLevel t = (ViewTopLevel) AllZone.getDisplay(); + + int i; // Index of field; computer is 0, human is 1 + if (p.isComputer()) { + i = 0; + } + else { + i = 1; + } + + if (s.equals(Constant.Phase.UPKEEP)) { + lbl = t.getFieldControllers().get(i).getView().getLblUpkeep(); + } + else if (s.equals(Constant.Phase.DRAW)) { + lbl = t.getFieldControllers().get(i).getView().getLblDraw(); + } + else if (s.equals(Constant.Phase.COMBAT_BEGIN)) { + lbl = t.getFieldControllers().get(i).getView().getLblBeginCombat(); + } + else if (s.equals(Constant.Phase.COMBAT_END)) { + lbl = t.getFieldControllers().get(i).getView().getLblEndCombat(); + } + else if (s.equals(Constant.Phase.END_OF_TURN)) { + lbl = t.getFieldControllers().get(i).getView().getLblEndTurn(); + } + else { + return; + } + + t.getController().resetAllPhaseButtons(); + lbl.setActive(true); + } } diff --git a/src/main/java/forge/control/ControlAllUI.java b/src/main/java/forge/control/ControlAllUI.java new file mode 100644 index 00000000000..17ad7e7763a --- /dev/null +++ b/src/main/java/forge/control/ControlAllUI.java @@ -0,0 +1,98 @@ +package forge.control; + +import java.awt.Component; + +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; + +import javax.swing.JLayeredPane; + +import forge.view.GuiTopLevel; +import forge.view.editor.EditorTopLevel; +import forge.view.home.HomeTopLevel; +import forge.view.match.ViewTopLevel; + +/** + *
ControlAllUI.
+ * Controls all Forge UI functionality inside one JFrame. + * This class switches between various display states in that JFrame. + * Controllers are instantiated separately by each state's top level view class. + */ +public class ControlAllUI { + private JLayeredPane display; + private GuiTopLevel view; + private HomeTopLevel home = null; + private ViewTopLevel match = null; + private EditorTopLevel editor = null; + + /** + *ControlAllUI.
+ * Controls all Forge UI functionality inside one JFrame. + * This class switches between various display states in that JFrame. + * Controllers are instantiated separately by each state's top level view class. + * + */ + public ControlAllUI() { + view = new GuiTopLevel(); + + view.addComponentListener(new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + Component[] children; + children = display.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER); + children[0].setSize(display.getSize()); + + children = display.getComponentsInLayer(JLayeredPane.MODAL_LAYER); + children[0].setSize(display.getSize()); + } + }); + + display = (JLayeredPane) view.getContentPane(); + + changeState(1); + } + + /** + *changeState.
+ * Switches between display states in top level JFrame. + * + * @param i State index: 0 for home, 1 for match, etc. + */ + public void changeState(int i) { + home = null; + match = null; + editor = null; + + display.removeAll(); + view.addOverlay(); + + // Fire up new state + switch (i) { + case 0: // Home screen + home = new HomeTopLevel(); + display.add(home); + break; + + case 1: // Match screen + match = new ViewTopLevel(); + display.add(match, JLayeredPane.DEFAULT_LAYER); + break; + + case 2: // Deck editor screen + editor = new EditorTopLevel(); + display.add(editor); + break; + + default: break; + } + } + + /** @return ViewTopLevel */ + public ViewTopLevel getMatchView() { + return match; + } + + /** @return ControlMatchUI */ + public ControlMatchUI getMatchController() { + return match.getController(); + } +} diff --git a/src/main/java/forge/control/ControlEditorUI.java b/src/main/java/forge/control/ControlEditorUI.java new file mode 100644 index 00000000000..536dac28967 --- /dev/null +++ b/src/main/java/forge/control/ControlEditorUI.java @@ -0,0 +1,19 @@ +package forge.control; + +import javax.swing.JPanel; + +/** + *ControlEditorUI
+ * Top-level controller for deck editor. + * + */ +@SuppressWarnings("serial") +public class ControlEditorUI extends JPanel { + /** + *ControlEditorUI
+ * Top-level controller for deck editor. + * + */ + public ControlEditorUI() { + } +} diff --git a/src/main/java/forge/control/ControlHomeUI.java b/src/main/java/forge/control/ControlHomeUI.java new file mode 100644 index 00000000000..2c667320168 --- /dev/null +++ b/src/main/java/forge/control/ControlHomeUI.java @@ -0,0 +1,9 @@ +package forge.control; + +/** + * TODO: Write javadoc for this type. + * + */ +public class ControlHomeUI { + +} diff --git a/src/main/java/forge/control/ControlMatchUI.java b/src/main/java/forge/control/ControlMatchUI.java new file mode 100644 index 00000000000..a0524174671 --- /dev/null +++ b/src/main/java/forge/control/ControlMatchUI.java @@ -0,0 +1,240 @@ +package forge.control; + +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.InputMap; +import javax.swing.JComponent; + +import forge.AllZone; +import forge.Singletons; +import forge.Constant.Zone; +import forge.control.match.ControlField; +import javax.swing.KeyStroke; + +import org.apache.commons.lang3.StringUtils; + +import forge.properties.ForgePreferences; +import forge.view.match.ViewTopLevel; + +/** + *ControlMatchUI
+ * Top-level controller for matches. Implements Display. + * + */ +public class ControlMatchUI { + private ViewTopLevel view; + + /** + *ControlMatchUI
+ * Constructs instance of match UI controller, used as a single + * point of top-level control for child UIs - in other words, this class + * controls the controllers. Tasks targeting the view of individual + * components are found in a separate controller for that component + * and should not be included here. + * + * This constructor is called after child components have been instantiated. + * When children are instantiated, they also instantiate their controller. + * So, this class must be called after everything is already in place. + * + * @param v A ViewTopLevel object + */ + public ControlMatchUI(ViewTopLevel v) { + view = v; + } + + /** + * Fires up controllers for each component of UI. + * + */ + public void initMatch() { + // All child components have been assembled; observers and listeners can + // be added safely. + view.getAreaSidebar().getTabber().getController().addObservers(); + view.getAreaSidebar().getTabber().getController().addListeners(); + + view.getAreaUser().getPnlInput().getController().addListeners(); + + view.getAreaUser().getPnlHand().getController().addObservers(); + view.getAreaUser().getPnlHand().getController().addListeners(); + + // Update all observers with values for start of match. + ListbtnCancelActionPerformed.
+ * Triggers current cancel action from whichever input controller is being used. + * + * @param evt a {@link java.awt.event.ActionEvent} object. + */ + private void btnCancelActionPerformed(final ActionEvent evt) { + inputControl.selectButtonCancel(); + } + + /** + *btnOKActionPerformed.
+ * Triggers current OK action from whichever input controller is being used. + * + * @param evt a {@link java.awt.event.ActionEvent} object. + */ + private void btnOKActionPerformed(final ActionEvent evt) { + inputControl.selectButtonOK(); + } + + /** @return GuiInput */ + public GuiInput getInputControl() { + return inputControl; + } +} diff --git a/src/main/java/forge/control/match/ControlTabber.java b/src/main/java/forge/control/match/ControlTabber.java new file mode 100644 index 00000000000..5246a94aec9 --- /dev/null +++ b/src/main/java/forge/control/match/ControlTabber.java @@ -0,0 +1,198 @@ +package forge.control.match; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Observable; +import java.util.Observer; + +import forge.AllZone; +import forge.GuiDisplayUtil; +import forge.MyObservable; +import forge.Singletons; +import forge.view.match.ViewTabber; + +/** + * Controls the vertical tabber in sidebar used for + * viewing gameplay data: stack, combat, etc. + * + */ +public class ControlTabber extends MyObservable { + private ViewTabber view; + + /** + * Controls the vertical tabber in sidebar used for + * viewing gameplay data: stack, combat, etc. + * + * @param v The tabber Swing component + */ + public ControlTabber(ViewTabber v) { + view = v; + if (Singletons.getModel().getPreferences().isMillingLossCondition()) { + view.getLblMilling().setEnabled(true); + } + else { + view.getLblMilling().setEnabled(false); + } + + if (Singletons.getModel().getPreferences().getHandView()) { + view.getLblHandView().setEnabled(true); + } + else { + view.getLblHandView().setEnabled(false); + } + + if (Singletons.getModel().getPreferences().getLibraryView()) { + view.getLblLibraryView().setEnabled(true); + } + else { + view.getLblLibraryView().setEnabled(false); + } + } + + /** Adds observers to tabber. */ + public void addObservers() { + // Stack + Observer o1 = new Observer() { + public void update(final Observable a, final Object b) { + view.updateStack(); + } + }; + + AllZone.getStack().addObserver(o1); + } + + /** Adds listeners to various components in tabber. */ + public void addListeners() { + // Milling enable toggle + view.getLblMilling().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + view.getLblMilling().toggleEnabled(); + } + }); + + // View any hand toggle + view.getLblHandView().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + view.getLblHandView().toggleEnabled(); + } + }); + + // DevMode: View any library toggle + view.getLblLibraryView().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + view.getLblLibraryView().toggleEnabled(); + } + }); + + // DevMode: Play unlimited land this turn toggle + view.getLblUnlimitedLands().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + GuiDisplayUtil.devModeUnlimitedLand(); + + // TODO: Enable toggle for this (e.g. Unlimited land each turn: enabled) + // Also must change enabled/disabled text in ViewTabber to reflect this. + //view.getLblUnlimitedLands().toggleEnabled(); + } + }); + + // DevMode: Generate mana + view.getLblGenerateMana().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + GuiDisplayUtil.devModeGenerateMana(); + } + }); + + // DevMode: Battlefield setup + view.getLblSetupGame().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + GuiDisplayUtil.devSetupGameState(); + } + }); + + // DevMode: Tutor for card + view.getLblTutor().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + GuiDisplayUtil.devModeTutor(); + } + }); + + // DevMode: Add counter to permanent + view.getLblCounterPermanent().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + GuiDisplayUtil.devModeAddCounter(); + } + }); + + // DevMode: Tap permanent + view.getLblTapPermanent().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + GuiDisplayUtil.devModeTapPerm(); + } + }); + + // DevMode: Untap permanent + view.getLblUntapPermanent().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + GuiDisplayUtil.devModeUntapPerm(); + } + }); + + // DevMode: Set human life + view.getLblHumanLife().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + GuiDisplayUtil.devModeSetLife(); + } + }); + } + + /** @return ViewTabber */ + public ViewTabber getView() { + return view; + } + + /** + * Programatically forces card layout of sidebar tabber to show "Dev" panel. + */ + public void showPnlDev() { + view.getVtpTabber().showTab(4); + } + + /** + * Programatically forces card layout of sidebar tabber to show "Players" panel. + */ + public void showPnlPlayers() { + view.getVtpTabber().showTab(3); + } + + /** + * Programatically forces card layout of sidebar tabber to show "Console" panel. + */ + public void showPnlConsole() { + view.getVtpTabber().showTab(2); + } + + /** + * Programatically forces card layout of sidebar tabber to show "Combat" panel. + */ + public void showPnlCombat() { + view.getVtpTabber().showTab(1); + } + + /** + * Programatically forces card layout of sidebar tabber to show "Stack" panel. + */ + public void showPnlStack() { + view.getVtpTabber().showTab(0); + } +} diff --git a/src/main/java/forge/control/match/package-info.java b/src/main/java/forge/control/match/package-info.java new file mode 100644 index 00000000000..ba6acc3b070 --- /dev/null +++ b/src/main/java/forge/control/match/package-info.java @@ -0,0 +1,3 @@ +/** Child controllers used in match UI. */ +package forge.control.match; + diff --git a/src/main/java/forge/control/package-info.java b/src/main/java/forge/control/package-info.java new file mode 100644 index 00000000000..8276b98567c --- /dev/null +++ b/src/main/java/forge/control/package-info.java @@ -0,0 +1,3 @@ +/** Controller (as in model-view-controller) for Forge. */ +package forge.control; + diff --git a/src/main/java/forge/gui/skin/FButton.java b/src/main/java/forge/gui/skin/FButton.java index 7287cf1014d..00c04bf4340 100644 --- a/src/main/java/forge/gui/skin/FButton.java +++ b/src/main/java/forge/gui/skin/FButton.java @@ -31,7 +31,14 @@ public class FButton extends JButton { private final AlphaComposite disabledComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f); /** - * Instantiates a new f button. + * Instantiates a new FButton. + */ + public FButton() { + this(""); + } + + /** + * Instantiates a new FButton. * * @param msg * the msg diff --git a/src/main/java/forge/gui/skin/FPanel.java b/src/main/java/forge/gui/skin/FPanel.java index 076270fdfea..9fa4f7d4a0d 100644 --- a/src/main/java/forge/gui/skin/FPanel.java +++ b/src/main/java/forge/gui/skin/FPanel.java @@ -2,6 +2,7 @@ package forge.gui.skin; import java.awt.Dimension; import java.awt.Graphics; +import java.awt.Image; import java.awt.LayoutManager; import javax.swing.ImageIcon; @@ -11,14 +12,15 @@ import javax.swing.JPanel; ** FPanel. *
- * The core JPanel used throughout the Forge project. Allows tiled images and - * ... + * The core JPanel used throughout the Forge project. Allows tiled texture images + * and single background images, using setBGTexture() and setBGImage() respectively. * */ @SuppressWarnings("serial") public class FPanel extends JPanel { - private ImageIcon bgImg = null; - private int w, h, iw, ih, x, y = 0; + private Image bgTexture, bgImg = null; + // Panel Width, panel Height, Image Width, Image Height, Image Aspect Ratio + private double w, h, iw, ih, iar, x, y = 0; /** * Instantiates a new f panel. @@ -45,40 +47,84 @@ public class FPanel extends JPanel { */ @Override protected void paintComponent(final Graphics g) { - // System.out.print("\nRepainting. "); - if (this.bgImg != null) { - this.w = this.getWidth(); - this.h = this.getHeight(); - this.iw = this.bgImg.getIconWidth(); - this.ih = this.bgImg.getIconHeight(); + w = this.getWidth(); + h = this.getHeight(); - while (this.x < this.w) { - while (this.y < this.h) { - g.drawImage(this.bgImg.getImage(), this.x, this.y, null); - this.y += this.ih; + // Draw background texture + if (bgTexture != null) { + iw = bgTexture.getWidth(null); + ih = bgTexture.getHeight(null); + x = 0; + y = 0; + + while (x < w) { + while (y < h) { + g.drawImage(bgTexture, (int) x, (int) y, null); + y += ih; } - this.x += this.iw; - this.y = 0; + x += iw; + y = 0; + } + x = 0; + } + + // Draw background image + if (bgImg != null) { + iw = bgImg.getWidth(null); // Image Width + ih = bgImg.getHeight(null); // Image Height + iar = iw / ih; // Image Aspect Ratio + + // Image is smaller than panel: + if (w > iw && h > ih) { + g.drawImage(bgImg, (int) (w - iw) / 2, (int) (h - ih) / 2, (int) iw, (int) ih, null); + } + // Image is larger than panel, and tall: + else if (iar < 1) { + g.drawImage(bgImg, + (int) ((w - h * iar) / 2), 0, + (int) ((w + h * iar) / 2), (int) h, + 0, 0, (int) iw, (int) ih, null); + } + // Image is larger than panel, and wide: + else if (iar > 1) { + g.drawImage(bgImg, + 0, (int) ((h - w / iar) / 2), + (int) w, (int) ((h + w / iar) / 2), + 0, 0, (int) iw, (int) ih, null); } - this.x = 0; } super.paintComponent(g); } /** - * Sets the bG img. - * - * @param icon - * the new bG img + * An FPanel can have a tiled texture and an image. The texture will be drawn + * first. If a background image has been set, it will be drawn on top of the + * texture, centered and scaled proportional to its aspect ratio. + * + * @param i0 ImageIcon */ - public void setBGImg(final ImageIcon icon) { - this.bgImg = icon; + public void setBGImg(final ImageIcon i0) { + this.bgImg = i0.getImage(); if (this.bgImg != null) { this.setOpaque(false); } } + /** + * An FPanel can have a tiled texture and an image. The texture will be drawn + * first. If a background image has been set, it will be drawn on top of the + * texture, centered and scaled proportional to its aspect ratio. + * + * @param i0 ImageIcon + */ + public void setBGTexture(final ImageIcon i0) { + this.bgTexture = i0.getImage(); + if (this.bgTexture != null) { + this.setOpaque(false); + } + } + /** * Sets the preferred size. * diff --git a/src/main/java/forge/gui/skin/FRoundedPanel.java b/src/main/java/forge/gui/skin/FRoundedPanel.java index 0a2d3fe9ebf..29c1a85d61c 100644 --- a/src/main/java/forge/gui/skin/FRoundedPanel.java +++ b/src/main/java/forge/gui/skin/FRoundedPanel.java @@ -22,6 +22,7 @@ import forge.AllZone; */ @SuppressWarnings("serial") public class FRoundedPanel extends JPanel { + private boolean[] borders = { true, true, true, true }; private boolean[] corners = { true, true, true, true }; // NW, SW, SE, NE private Color shadowColor = new Color(150, 150, 150, 150); private Color borderColor = AllZone.getSkin().getClrBorders(); @@ -146,39 +147,56 @@ public class FRoundedPanel extends JPanel { // Mid, left, right rectangles: border g2d.setColor(this.borderColor); - g2d.drawLine(r, 0, w - r - so, 0); - g2d.drawLine(r, h - so - 1, w - r - so, h - so - 1); - g2d.drawLine(0, r, 0, h - r - so); - g2d.drawLine(w - so - 1, r, w - so - 1, h - r - so); + + if (this.borders[0]) { g2d.drawLine(r, 0, w - r - so, 0); } + if (this.borders[1]) { g2d.drawLine(0, r, 0, h - r - so); } + if (this.borders[2]) { g2d.drawLine(r, h - so - 1, w - r - so, h - so - 1); } + if (this.borders[3]) { g2d.drawLine(w - so - 1, r, w - so - 1, h - r - so); } // Corners: border // NW if (this.corners[0]) { g2d.drawArc(0, 0, 2 * r, 2 * r, 90, 90); } else { - g2d.drawLine(0, 0, r, 0); - g2d.drawLine(0, 0, 0, r); + if (this.borders[0]) { + g2d.drawLine(0, 0, r, 0); + } + if (this.borders[1]) { + g2d.drawLine(0, 0, 0, r); + } } // SW if (this.corners[1]) { g2d.drawArc(0, h - (2 * r) - so, 2 * r, (2 * r) - 1, 180, 90); } else { - g2d.drawLine(0, h - so - 1, 0, h - r - so - 1); - g2d.drawLine(0, h - so - 1, r, h - so - 1); + if (this.borders[1]) { + g2d.drawLine(0, h - so - 1, 0, h - r - so - 1); + } + if (this.borders[2]) { + g2d.drawLine(0, h - so - 1, r, h - so - 1); + } } // SE if (this.corners[2]) { g2d.drawArc(w - (2 * r) - so, h - (2 * r) - so, (2 * r) - 1, (2 * r) - 1, 270, 90); } else { - g2d.drawLine(w - so - 1, h - so - 1, w - so - 1, h - r - so); - g2d.drawLine(w - so - 1, h - so - 1, w - r - so, h - so - 1); + if (this.borders[2]) { + g2d.drawLine(w - so - 1, h - so - 1, w - r - so, h - so - 1); + } + if (this.borders[3]) { + g2d.drawLine(w - so - 1, h - so - 1, w - so - 1, h - r - so); + } } // NE if (this.corners[3]) { g2d.drawArc(w - (2 * r) - so, 0, (2 * r) - 1, (2 * r) - 1, 0, 90); } else { - g2d.drawLine(w - so - 1, 0, w - so - r, 0); - g2d.drawLine(w - so - 1, 0, w - so - 1, r); + if (this.borders[0]) { + g2d.drawLine(w - so - 1, 0, w - so - r, 0); + } + if (this.borders[3]) { + g2d.drawLine(w - so - 1, 0, w - so - 1, r); + } } } @@ -230,15 +248,14 @@ public class FRoundedPanel extends JPanel { * * Sets radius of each corner on rounded panel. * - * @param r - * the new corner radius + * @param r0 int */ - public void setCornerRadius(int r) { - if (r < 0) { - r = 0; + public void setCornerRadius(int r0) { + if (r0 < 0) { + r0 = 0; } - this.cornerRadius = r; + this.cornerRadius = r0; } /** @@ -248,8 +265,7 @@ public class FRoundedPanel extends JPanel { * Sets if corners should be rounded or not in the following order: NW, SW, * SE, NE * - * @param vals - * the new corners + * @param vals boolean[4] */ public void setCorners(final boolean[] vals) { if (vals.length != 4) { @@ -259,6 +275,23 @@ public class FRoundedPanel extends JPanel { this.corners = vals; } + /** + *+ * setBorders. + *
+ * Sets if borders should be displayed or not following order: N, W, S, E. + * Only works for square corners, rounded corners will be shown with borders. + * + * @param vals boolean[4] + */ + public void setBorders(final boolean[] vals) { + if (vals.length != 4) { + throw new IllegalArgumentException("FRoundedPanel > setBorders requires an array of booleans of length 4."); + } + + this.borders = vals; + } + /** * Sets the show shadow. * diff --git a/src/main/java/forge/gui/skin/FSkin.java b/src/main/java/forge/gui/skin/FSkin.java index f28c74b7a28..530adfd9cf4 100644 --- a/src/main/java/forge/gui/skin/FSkin.java +++ b/src/main/java/forge/gui/skin/FSkin.java @@ -28,6 +28,9 @@ public class FSkin { /** Primary texture used in skin. */ private ImageIcon texture1 = null; + /** Primary background image used during match play. */ + private ImageIcon matchBG = null; + /** Left side of button, up state. */ private ImageIcon btnLup = null; @@ -58,6 +61,17 @@ public class FSkin { /** Splash screen image. */ private ImageIcon splash = null; + /** Splash screen image. */ + private ImageIcon icoEnabled = null; + private ImageIcon icoDisabled = null; + private ImageIcon icoTap = null; + private ImageIcon icoUntap = null; + private ImageIcon icoPlus = null; + private ImageIcon icoShortcuts = null; + private ImageIcon icoSettings = null; + private ImageIcon icoConcede = null; + private ImageIcon icoEndTurn = null; + /** Base color used in skin. */ private Color clrTheme = Color.red; @@ -95,7 +109,7 @@ public class FSkin { private String name = "default"; // ===== Private fields - private final String paletteFile = "palette.png"; + private final String spriteFile = "sprite.png"; private final String font1file = "font1.ttf"; private final String font2file = "font2.ttf"; private final String texture1file = "texture1.jpg"; @@ -109,11 +123,11 @@ public class FSkin { private final String btnMdownfile = "btnMdown.png"; private final String btnRdownfile = "btnRdown.png"; private final String splashfile = "bg_splash.jpg"; + private final String matchfile = "bg_match.jpg"; private ImageIcon tempImg; private Font tempFont; - private String skin; - private final String notfound = "FSkin.java: \"" + this.skin + "\" skin can't find "; + private final String notfound = "FSkin.java: Can't find "; /** * FSkin constructor. No arguments, will generate default skin settings, @@ -153,6 +167,7 @@ public class FSkin { // Images this.setTexture1(this.retrieveImage(dirName + this.texture1file)); + this.setMatchBG(this.retrieveImage(dirName + this.matchfile)); this.setBtnLup(this.retrieveImage(dirName + this.btnLupfile)); this.setBtnMup(this.retrieveImage(dirName + this.btnMupfile)); this.setBtnRup(this.retrieveImage(dirName + this.btnRupfile)); @@ -162,26 +177,35 @@ public class FSkin { this.setBtnLdown(this.retrieveImage(dirName + this.btnLdownfile)); this.setBtnMdown(this.retrieveImage(dirName + this.btnMdownfile)); this.setBtnRdown(this.retrieveImage(dirName + this.btnRdownfile)); - this.setSplash(this.retrieveImage(dirName + this.splashfile)); + this.setSplashBG(this.retrieveImage(dirName + this.splashfile)); // Color palette - final File file = new File(dirName + this.paletteFile); + final File file = new File(dirName + this.spriteFile); BufferedImage image; try { image = ImageIO.read(file); - this.setClrTheme(this.getColorFromPixel(image.getRGB(60, 10))); - this.setClrBorders(this.getColorFromPixel(image.getRGB(60, 30))); - this.setClrZebra(this.getColorFromPixel(image.getRGB(60, 50))); - this.setClrHover(this.getColorFromPixel(image.getRGB(60, 70))); - this.setClrActive(this.getColorFromPixel(image.getRGB(60, 90))); - this.setClrInactive(this.getColorFromPixel(image.getRGB(60, 110))); - this.setClrText(this.getColorFromPixel(image.getRGB(60, 130))); - this.setClrProgress1(this.getColorFromPixel(image.getRGB(55, 145))); - this.setClrProgress2(this.getColorFromPixel(image.getRGB(65, 145))); - this.setClrProgress3(this.getColorFromPixel(image.getRGB(55, 155))); - this.setClrProgress4(this.getColorFromPixel(image.getRGB(65, 155))); + this.setClrTheme(this.getColorFromPixel(image.getRGB(70, 10))); + this.setClrBorders(this.getColorFromPixel(image.getRGB(70, 30))); + this.setClrZebra(this.getColorFromPixel(image.getRGB(70, 50))); + this.setClrHover(this.getColorFromPixel(image.getRGB(70, 70))); + this.setClrActive(this.getColorFromPixel(image.getRGB(70, 90))); + this.setClrInactive(this.getColorFromPixel(image.getRGB(70, 110))); + this.setClrText(this.getColorFromPixel(image.getRGB(70, 130))); + this.setClrProgress1(this.getColorFromPixel(image.getRGB(65, 145))); + this.setClrProgress2(this.getColorFromPixel(image.getRGB(75, 145))); + this.setClrProgress3(this.getColorFromPixel(image.getRGB(65, 155))); + this.setClrProgress4(this.getColorFromPixel(image.getRGB(75, 155))); + this.setIconEnabled(image.getSubimage(80, 0, 40, 40)); + this.setIconDisabled(image.getSubimage(120, 0, 40, 40)); + this.setIconTap(image.getSubimage(80, 40, 40, 40)); + this.setIconUntap(image.getSubimage(120, 40, 40, 40)); + this.setIconPlus(image.getSubimage(80, 80, 40, 40)); + this.setIconShortcuts(image.getSubimage(160, 0, 80, 80)); + this.setIconEndTurn(image.getSubimage(160, 80, 80, 80)); + this.setIconSettings(image.getSubimage(80, 0, 80, 80)); + this.setIconConcede(image.getSubimage(80, 80, 80, 80)); } catch (final IOException e) { - System.err.println(this.notfound + this.paletteFile); + System.err.println(this.notfound + this.spriteFile); } } @@ -273,7 +297,7 @@ public class FSkin { * Splash screen image. * @return {@link javax.swing.ImageIcon} splash */ - public ImageIcon getSplash() { + public ImageIcon getSplashBG() { return splash; } @@ -281,7 +305,7 @@ public class FSkin { * Splash screen image. * @param splash0 an image icon */ - public void setSplash(ImageIcon splash0) { + public void setSplashBG(ImageIcon splash0) { this.splash = splash0; } @@ -333,6 +357,22 @@ public class FSkin { this.texture1 = texture10; } + /** + * Primary background image used during match play. + * @return ImageIcon + */ + public ImageIcon getMatchBG() { + return matchBG; + } + + /** + * Primary background image used during match play. + * @param img0 an image icon + */ + public void setMatchBG(ImageIcon img0) { + this.matchBG = img0; + } + /** * Color of zebra striping in grid displays. * @return {@link java.awt.Color} clrZebra @@ -626,4 +666,94 @@ public class FSkin { public String getName() { return name; } + + /** @param bi0 BufferedImage */ + public void setIconEnabled(BufferedImage bi0) { + this.icoEnabled = new ImageIcon(bi0); + } + + /** @return ImageIcon */ + public ImageIcon getIconEnabled() { + return icoEnabled; + } + + /** @param bi0 BufferedImage */ + public void setIconDisabled(BufferedImage bi0) { + this.icoDisabled = new ImageIcon(bi0); + } + + /** @return ImageIcon */ + public ImageIcon getIconDisabled() { + return icoDisabled; + } + + /** @param bi0 BufferedImage */ + public void setIconTap(BufferedImage bi0) { + this.icoTap = new ImageIcon(bi0); + } + + /** @return ImageIcon */ + public ImageIcon getIconTap() { + return icoTap; + } + + /** @param bi0 BufferedImage */ + public void setIconUntap(BufferedImage bi0) { + this.icoUntap = new ImageIcon(bi0); + } + + /** @return ImageIcon */ + public ImageIcon getIconUntap() { + return icoUntap; + } + + /** @param bi0 BufferedImage */ + public void setIconPlus(BufferedImage bi0) { + this.icoPlus = new ImageIcon(bi0); + } + + /** @return ImageIcon */ + public ImageIcon getIconPlus() { + return icoPlus; + } + + /** @param bi0 BufferedImage */ + public void setIconShortcuts(BufferedImage bi0) { + this.icoShortcuts = new ImageIcon(bi0); + } + + /** @return ImageIcon */ + public ImageIcon getIconShortcuts() { + return icoShortcuts; + } + + /** @param bi0 BufferedImage */ + public void setIconSettings(BufferedImage bi0) { + this.icoSettings = new ImageIcon(bi0); + } + + /** @return ImageIcon */ + public ImageIcon getIconSettings() { + return icoSettings; + } + + /** @param bi0 BufferedImage */ + public void setIconConcede(BufferedImage bi0) { + this.icoConcede = new ImageIcon(bi0); + } + + /** @return ImageIcon */ + public ImageIcon getIconConcede() { + return icoConcede; + } + + /** @param bi0 BufferedImage */ + public void setIconEndTurn(BufferedImage bi0) { + this.icoEndTurn = new ImageIcon(bi0); + } + + /** @return ImageIcon */ + public ImageIcon getIconEndTurn() { + return icoEndTurn; + } } diff --git a/src/main/java/forge/model/FGameState.java b/src/main/java/forge/model/FGameState.java index 31014097701..64901aa1f4d 100644 --- a/src/main/java/forge/model/FGameState.java +++ b/src/main/java/forge/model/FGameState.java @@ -172,6 +172,7 @@ public class FGameState { * the phase to set */ protected final void setPhase(final Phase phase0) { + System.out.println("asdf:"+phase0); this.phase = phase0; } diff --git a/src/main/java/forge/properties/ForgePreferences.java b/src/main/java/forge/properties/ForgePreferences.java index b2a86719f24..5fc92012d22 100644 --- a/src/main/java/forge/properties/ForgePreferences.java +++ b/src/main/java/forge/properties/ForgePreferences.java @@ -18,8 +18,8 @@ import java.util.List; */ public class ForgePreferences extends Preferences { - /** The new gui. */ - private final boolean newGui; + /** Old gui checkbox toggle. */ + private boolean oldGui; /** The stack ai land. */ private boolean stackAiLand; @@ -27,7 +27,13 @@ public class ForgePreferences extends Preferences { /** The milling loss condition. */ private boolean millingLossCondition; - /** The developer mode. */ + /** Hand view toggle. */ + private boolean handView; + + /** Library view toggle. */ + private boolean libraryView; + + /** Developer mode. */ private boolean developerMode; /** The upload draft ai. */ @@ -106,6 +112,17 @@ public class ForgePreferences extends Preferences { /** The b human end combat. */ private boolean bHumanEndCombat; + // Keyboard shortcuts + private String showStackShortcut; + private String showCombatShortcut; + private String showConsoleShortcut; + private String showPlayersShortcut; + private String showDevShortcut; + private String concedeShortcut; + private String showPictureShortcut; + private String showDetailShortcut; + + // private final ListConstructor for CardPanel.
+ * + * @param c Card object. + */ + public CardPanel(Card c) { + super(); + this.card = c; + this.img = ImageCache.getImage(card); + + setToolTipText("" + c.getName() + "loadPrefs.
+ * Required by Display interface. + * Due to be deprecated: will be handled by ControlMatchUI. + * + * + * @return boolean. + */ + public final boolean loadPrefs() { + ForgePreferences fp = Singletons.getModel().getPreferences(); + ListsavePrefs.
+ * Required by Display interface. + * Due to be deprecated: will be handled by ControlMatchUI. + * Also, this functionality is already performed elsewhere in the code base. + * Furthermore, there's a strong possibility this will need bo be broken + * down and can't be in one place - e.g. keyboard shortcuts are + * saved after they're edited. + * + * @return a boolean. + */ + public final boolean savePrefs() { + ForgePreferences fp = Singletons.getModel().getPreferences(); + ListstopAtPhase.
+ * Required by Display interface. + * Due to be deprecated: should be handled by control class. + * + * @param turn Player object...more info needed + * @param phase A string...more info needed + * @return a boolean. + */ + public final boolean stopAtPhase(final Player turn, final String phase) { + ListnewGuiCheckBox. */
- // private static JCheckBox newGuiCheckBox = new JCheckBox("", true);
+ /** Constant oldGuiCheckBox. */
+ private static JCheckBox oldGuiCheckBox = new JCheckBox("", false);
/** Constant smoothLandCheckBox. */
private static JCheckBox smoothLandCheckBox = new JCheckBox("", false);
/** Constant devModeCheckBox. */
@@ -556,7 +557,7 @@ public class OldGuiNewGame extends JFrame {
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SETTINGS));
this.jPanel3.setLayout(new MigLayout("align center"));
- // newGuiCheckBox.setText(ForgeProps.getLocalized(NEW_GAME_TEXT.NEW_GUI));
+ oldGuiCheckBox.setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.OLD_GUI));
OldGuiNewGame.getSmoothLandCheckBox().setText(
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.AI_LAND));
@@ -639,7 +640,7 @@ public class OldGuiNewGame extends JFrame {
this.getContentPane().add(this.jPanel3, "span 2, grow");
- // jPanel3.add(newGuiCheckBox, "wrap");
+ jPanel3.add(oldGuiCheckBox, "wrap");
this.jPanel3.add(OldGuiNewGame.getSmoothLandCheckBox(), "wrap");
this.jPanel3.add(OldGuiNewGame.getDevModeCheckBox(), "wrap");
this.jPanel3.add(OldGuiNewGame.getUpldDrftCheckBox(), "wrap");
@@ -865,15 +866,19 @@ public class OldGuiNewGame extends JFrame {
}
} // else
- // DO NOT CHANGE THIS ORDER, GuiDisplay needs to be created before cards
- // are added
- // Constant.Runtime.DevMode[0] = devModeCheckBox.isSelected();
+ Constant.Runtime.OLDGUI[0] = oldGuiCheckBox.isSelected();
- // if (newGuiCheckBox.isSelected())
- AllZone.setDisplay(new GuiDisplay());
- // else AllZone.setDisplay(new GuiDisplay3());
+ if (Constant.Runtime.OLDGUI[0]) {
+ AllZone.setDisplay(new GuiDisplay());
+ }
+ else {
+ ControlAllUI ui = new ControlAllUI();
+ AllZone.setDisplay(ui.getMatchView());
+ ui.getMatchController().initMatch();
+ }
Constant.Runtime.SMOOTH[0] = OldGuiNewGame.getSmoothLandCheckBox().isSelected();
+ //Constant.Runtime.DEV_MODE[0] = OldGuiNewGame.devModeCheckBox.isSelected();
AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
AllZone.getDisplay().setVisible(true);
@@ -1714,7 +1719,7 @@ public class OldGuiNewGame extends JFrame {
final ForgePreferences preferences = Singletons.getModel().getPreferences();
preferences.setLaf(UIManager.getLookAndFeel().getClass().getName());
preferences.setLafFonts(OldGuiNewGame.getUseLAFFonts().isSelected());
- // preferences.newGui = newGuiCheckBox.isSelected();
+ preferences.setOldGui(oldGuiCheckBox.isSelected());
preferences.setStackAiLand(OldGuiNewGame.getSmoothLandCheckBox().isSelected());
preferences.setMillingLossCondition(Constant.Runtime.MILL[0]);
preferences.setDeveloperMode(Constant.Runtime.DEV_MODE[0]);
@@ -2000,4 +2005,8 @@ public class OldGuiNewGame extends JFrame {
// name.
}
+ /** @return JCheckBox */
+ public static JCheckBox getOldGuiCheckBox() {
+ return OldGuiNewGame.oldGuiCheckBox;
+ }
}
diff --git a/src/main/java/forge/view/swing/SplashFrame.java b/src/main/java/forge/view/swing/SplashFrame.java
index ffb0f97f6b6..3c88feb4fc5 100644
--- a/src/main/java/forge/view/swing/SplashFrame.java
+++ b/src/main/java/forge/view/swing/SplashFrame.java
@@ -69,7 +69,7 @@ public class SplashFrame extends JFrame {
this.setUndecorated(true);
// Set preferred JFrame properties.
- final ImageIcon bgIcon = skin.getSplash();
+ final ImageIcon bgIcon = skin.getSplashBG();
final int splashWidthPx = bgIcon.getIconWidth();
final int splashHeightPx = bgIcon.getIconHeight();
diff --git a/src/main/java/forge/view/swing/WinLoseFrame.java b/src/main/java/forge/view/swing/WinLoseFrame.java
index 9759aea282e..d3b622b3519 100644
--- a/src/main/java/forge/view/swing/WinLoseFrame.java
+++ b/src/main/java/forge/view/swing/WinLoseFrame.java
@@ -17,6 +17,7 @@ import javax.swing.border.AbstractBorder;
import net.miginfocom.swing.MigLayout;
import forge.AllZone;
+import forge.Constant;
import forge.Phase;
import forge.Player;
import forge.gui.skin.FButton;
@@ -24,6 +25,7 @@ import forge.gui.skin.FPanel;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.Lang.WinLoseFrame.WinLoseText;
import forge.quest.data.QuestMatchState;
+import forge.view.match.ViewTopLevel;
/**
*
@@ -88,7 +90,7 @@ public class WinLoseFrame extends JFrame {
// Place all content in FPanel
final FPanel contentPanel = new FPanel(new MigLayout("wrap, fill, insets 20 0 10 10"));
- contentPanel.setBGImg(AllZone.getSkin().getTexture1());
+ contentPanel.setBGTexture(AllZone.getSkin().getTexture1());
contentPanel.setBorder(new WinLoseBorder());
this.getContentPane().add(contentPanel);
@@ -271,8 +273,17 @@ public class WinLoseFrame extends JFrame {
* @return {@link javax.swing.JFrame} display frame
*/
final JFrame closeWinLoseFrame() {
+ JFrame frame;
+
// Issue 147 - keep battlefield up following win/loss
- final JFrame frame = (JFrame) AllZone.getDisplay();
+ if (Constant.Runtime.OLDGUI[0]) {
+ frame = (JFrame) AllZone.getDisplay();
+ }
+ else {
+ ViewTopLevel temp = (ViewTopLevel) AllZone.getDisplay();
+ frame = (JFrame) temp.getParent().getParent().getParent().getParent();
+ }
+
frame.dispose();
frame.setEnabled(true);
this.dispose();
diff --git a/src/main/java/forge/view/toolbox/CardDetailPanel.java b/src/main/java/forge/view/toolbox/CardDetailPanel.java
new file mode 100644
index 00000000000..83cf97fb67e
--- /dev/null
+++ b/src/main/java/forge/view/toolbox/CardDetailPanel.java
@@ -0,0 +1,382 @@
+package forge.view.toolbox;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.util.Iterator;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.ScrollPaneConstants;
+import javax.swing.SwingConstants;
+
+import net.miginfocom.swing.MigLayout;
+import forge.AllZone;
+import forge.Card;
+import forge.CardContainer;
+import forge.Constant.Zone;
+import forge.Counters;
+import forge.GameEntity;
+import forge.GuiDisplayUtil;
+import forge.gui.skin.FSkin;
+
+/** Shows details of card if moused over. */
+@SuppressWarnings("serial")
+public class CardDetailPanel extends JPanel implements CardContainer {
+ private Card card = null;
+ private JLabel lblCardName, lblCardCost, lblCardType,
+ lblCardID, lblCardPT, lblCardSet, lblCardDmg1, lblCardDmg2;
+ private JTextArea tarInfo;
+ private static final Color PURPLE = new Color(14381203);
+
+ private FSkin skin;
+ private Font f;
+ private Color foreground;
+ private Color zebra;
+
+ /** */
+ public CardDetailPanel() {
+ super();
+ setLayout(new MigLayout("wrap, insets 0, gap 0"));
+
+ // Styles used in DetailLabel class
+ skin = AllZone.getSkin();
+ f = skin.getFont1().deriveFont(Font.PLAIN, 11);
+ foreground = skin.getClrText();
+ zebra = skin.getClrZebra();
+
+ // DetailLabel instances (true = zebra stripe)
+ lblCardName = new DetailLabel();
+ lblCardCost = new DetailLabel();
+ lblCardType = new DetailLabel();
+ lblCardPT = new DetailLabel();
+ lblCardDmg1 = new DetailLabel();
+ lblCardDmg2 = new DetailLabel();
+ lblCardID = new DetailLabel();
+ lblCardSet = new DetailLabel();
+
+ // Info text area
+ tarInfo = new JTextArea();
+ tarInfo.setFont(f);
+ tarInfo.setLineWrap(true);
+ tarInfo.setWrapStyleWord(true);
+ tarInfo.setFocusable(false);
+
+ add(lblCardName, "w 100%!");
+ add(lblCardCost, "w 100%!");
+ add(lblCardType, "w 100%!");
+ add(lblCardPT, "w 100%!");
+ add(lblCardDmg1, "w 100%!");
+ add(lblCardDmg2, "w 100%!");
+ add(lblCardID, "w 100%!");
+ add(lblCardSet, "w 100%!");
+ add(new JScrollPane(tarInfo,
+ ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), "w 100%!, h 45%!, south");
+ setCard(card);
+ }
+
+ /**
+ * A fairly long method testing conditions determining which details to show.
+ *
+ * @param c Card obj
+ */
+ public void setCard(Card c) {
+ lblCardName.setText(" ");
+ lblCardCost.setText(" ");
+ lblCardType.setText(" ");
+ lblCardPT.setText(" ");
+ lblCardDmg1.setText(" ");
+ lblCardDmg2.setText(" ");
+ lblCardID.setText(" ");
+ lblCardSet.setText(" ");
+ lblCardSet.setOpaque(true);
+ lblCardSet.setBorder(null);
+ tarInfo.setText(" ");
+
+ this.card = c;
+ if (card == null) {
+ return;
+ }
+
+ boolean faceDown = card.isFaceDown() && card.getController() != AllZone.getHumanPlayer();
+
+ if (!faceDown) {
+ lblCardName.setText(card.getName());
+ if (!card.getManaCost().equals("") && !card.isLand()) {
+ lblCardCost.setText(card.getManaCost());
+ }
+ }
+ else {
+ lblCardName.setText("Morph");
+ }
+
+ if (!faceDown) {
+ lblCardType.setText(GuiDisplayUtil.formatCardType(card));
+ }
+ else {
+ lblCardType.setText("Creature");
+ }
+
+ if (card.isCreature()) {
+ lblCardPT.setText(card.getNetAttack() + " / " + card.getNetDefense());
+ lblCardDmg1.setText("Damage: " + card.getDamage());
+ lblCardDmg2.setText("Assigned Damage: " + card.getTotalAssignedDamage());
+ }
+ if (card.isPlaneswalker()) {
+ lblCardDmg2.setText("Assigned Damage: " + card.getTotalAssignedDamage());
+ }
+
+ lblCardID.setText("Card ID " + card.getUniqueNumber());
+
+ // Rarity and set of a face down card should not be visible to the opponent
+ if (!card.isFaceDown() || card.getController().isHuman()) {
+ String s = card.getCurSetCode();
+ if (s.equals("")) {
+ lblCardSet.setText("---");
+ }
+ else {
+ lblCardSet.setText(s);
+ }
+ }
+
+ String csr = card.getCurSetRarity();
+ if (csr.equals("Common") || csr.equals("Land")) {
+ lblCardSet.setBackground(Color.BLACK);
+ lblCardSet.setForeground(Color.WHITE);
+ //lblCardSet.setBorder(BorderFactory.createLineBorder(Color.WHITE));
+ } else if (csr.equals("Uncommon")) {
+ lblCardSet.setBackground(Color.LIGHT_GRAY);
+ lblCardSet.setForeground(Color.BLACK);
+ //lblCardSet.setBorder(BorderFactory.createLineBorder(Color.BLACK));
+ } else if (csr.equals("Rare")) {
+ lblCardSet.setBackground(Color.YELLOW);
+ lblCardSet.setForeground(Color.BLACK);
+ //lblCardSet.setBorder(BorderFactory.createLineBorder(Color.BLACK));
+ } else if (csr.equals("Mythic")) {
+ lblCardSet.setBackground(Color.RED);
+ lblCardSet.setForeground(Color.BLACK);
+ //lblCardSet.setBorder(BorderFactory.createLineBorder(Color.BLACK));
+ } else if (csr.equals("Special")) {
+ // "Timeshifted" or other Special Rarity Cards
+ lblCardSet.setBackground(PURPLE);
+ lblCardSet.setForeground(Color.BLACK);
+ //lblCardSet.setBorder(BorderFactory.createLineBorder(Color.BLACK));
+ }
+
+ // Fill the card text
+ StringBuilder str = new StringBuilder();
+
+ // Token
+ if (card.isToken()) { str.append("Token"); }
+
+ if (!faceDown) {
+ if (str.length() != 0) { str.append("\n"); }
+ String text = card.getText();
+
+ //LEVEL [0-9]+-[0-9]+
+ //LEVEL [0-9]+\+
+ String regex = "LEVEL [0-9]+-[0-9]+ ";
+ text = text.replaceAll(regex, "$0\r\n");
+
+ regex = "LEVEL [0-9]+\\+ ";
+ text = text.replaceAll(regex, "\r\n$0\r\n");
+
+ // Displays keywords that have dots in them a little better:
+ regex = "\\., ";
+ text = text.replaceAll(regex, ".\r\n");
+
+ str.append(text);
+ }
+
+ // Phasing
+ if (card.isPhasedOut()) {
+ if (str.length() != 0) { str.append("\n"); }
+ str.append("Phased Out");
+ }
+
+ // Counter text
+ Counters[] counters = Counters.values();
+ for (Counters counter : counters) {
+ if (card.getCounters(counter) != 0) {
+ if (str.length() != 0) { str.append("\n"); }
+ str.append(counter.getName() + " counters: ");
+ str.append(card.getCounters(counter));
+ }
+ }
+
+ // Regeneration Shields
+ int regenShields = card.getShield();
+ if (regenShields > 0) {
+ if (str.length() != 0) { str.append("\n"); }
+ str.append("Regeneration Shield(s): ").append(regenShields);
+ }
+
+ // Damage Prevention
+ int preventNextDamage = card.getPreventNextDamage();
+ if (preventNextDamage > 0) {
+ str.append("\n");
+ str.append("Prevent the next ").append(preventNextDamage).append(" damage that would be dealt to ");
+ str.append(card.getName()).append(" it this turn.");
+ }
+
+ // Top revealed
+ if (card.hasKeyword("Play with the top card of your library revealed.") && card.getController() != null
+ && !card.getController().getZone(Zone.Library).isEmpty()) {
+ str.append("\r\nTop card: ");
+ str.append(card.getController().getCardsIn(Zone.Library, 1));
+ }
+
+ // Chosen type
+ if (card.getChosenType() != "") {
+ if (str.length() != 0) { str.append("\n"); }
+ str.append("(chosen type: ");
+ str.append(card.getChosenType());
+ str.append(")");
+ }
+
+ // Chosen color
+ if (!card.getChosenColor().isEmpty()) {
+ if (str.length() != 0) { str.append("\n"); }
+ str.append("(chosen colors: ");
+ str.append(card.getChosenColor());
+ str.append(")");
+ }
+
+ // Named card
+ if (card.getNamedCard() != "") {
+ if (str.length() != 0) { str.append("\n"); }
+ str.append("(named card: ");
+ str.append(card.getNamedCard());
+ str.append(")");
+ }
+
+ // Equipping
+ if (card.getEquipping().size() > 0) {
+ if (str.length() != 0) { str.append("\n"); }
+ str.append("=Equipping ");
+ str.append(card.getEquipping().get(0));
+ str.append("=");
+ }
+
+ // Equipped by
+ if (card.getEquippedBy().size() > 0) {
+ if (str.length() != 0) { str.append("\n"); }
+ str.append("=Equipped by ");
+ for (Iterator