Boom - it's landed.

Draggable layout for match UI.
This commit is contained in:
Doublestrike
2012-04-14 08:29:21 +00:00
parent 12a3bf8d5a
commit 7faff76b3f
122 changed files with 4161 additions and 5792 deletions

75
.gitattributes vendored
View File

@@ -10603,6 +10603,7 @@ res/lang/en.properties svneol=native#text/plain
res/lang/howTo/de.properties svneol=native#text/plain
res/lang/howTo/en.properties svneol=native#text/plain
res/lang/lang.properties svneol=native#text/plain
res/layouts/match_default.xml -text
res/licenses/java-yield-license.txt svneol=native#text/plain
res/licenses/log4j-license.txt svneol=native#text/plain
res/licenses/multiline-label-license.txt svneol=native#text/plain
@@ -11538,7 +11539,6 @@ src/main/java/forge/card/trigger/TriggerUntaps.java svneol=native#text/plain
src/main/java/forge/card/trigger/ZCTrigger.java svneol=native#text/plain
src/main/java/forge/card/trigger/package-info.java svneol=native#text/plain
src/main/java/forge/control/ControlBazaarUI.java -text
src/main/java/forge/control/ControlMatchUI.java -text
src/main/java/forge/control/FControl.java -text
src/main/java/forge/control/KeyboardShortcuts.java -text
src/main/java/forge/control/RestartUtil.java -text
@@ -11556,15 +11556,6 @@ src/main/java/forge/control/input/InputPayManaCost.java svneol=native#text/plain
src/main/java/forge/control/input/InputPayManaCostAbility.java svneol=native#text/plain
src/main/java/forge/control/input/InputPayManaCostUtil.java svneol=native#text/plain
src/main/java/forge/control/input/package-info.java svneol=native#text/plain
src/main/java/forge/control/match/ControlDetail.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/ControlMessage.java -text
src/main/java/forge/control/match/ControlPicture.java -text
src/main/java/forge/control/match/ControlTabber.java -text
src/main/java/forge/control/match/ControlWinLose.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/CardCollections.java -text
src/main/java/forge/deck/Deck.java svneol=native#text/plain
@@ -11690,11 +11681,26 @@ src/main/java/forge/gui/download/GuiDownloadQuestImages.java -text
src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java svneol=native#text/plain
src/main/java/forge/gui/download/GuiDownloader.java -text
src/main/java/forge/gui/download/package-info.java -text
src/main/java/forge/gui/framework/DragCell.java -text
src/main/java/forge/gui/framework/DragTab.java -text
src/main/java/forge/gui/framework/EDocID.java -text
src/main/java/forge/gui/framework/ICDoc.java -text
src/main/java/forge/gui/framework/IDocIdList.java -text
src/main/java/forge/gui/framework/ILocalRepaint.java -text
src/main/java/forge/gui/framework/IVDoc.java -text
src/main/java/forge/gui/framework/IVTopLevelUI.java -text
src/main/java/forge/gui/framework/SDisplayUtil.java -text
src/main/java/forge/gui/framework/SIOUtil.java -text
src/main/java/forge/gui/framework/SLayoutConstants.java -text
src/main/java/forge/gui/framework/SOverflowUtil.java -text
src/main/java/forge/gui/framework/SRearrangingUtil.java -text
src/main/java/forge/gui/framework/SResizingUtil.java -text
src/main/java/forge/gui/home/EMenuGroup.java -text
src/main/java/forge/gui/home/EMenuItem.java -text
src/main/java/forge/gui/home/ICSubmenu.java -text
src/main/java/forge/gui/home/IVSubmenu.java -text
src/main/java/forge/gui/home/StartButton.java -text
src/main/java/forge/gui/home/VHomeUI.java -text
src/main/java/forge/gui/home/package-info.java svneol=native#text/plain
src/main/java/forge/gui/home/quest/CSubmenuChallenges.java -text
src/main/java/forge/gui/home/quest/CSubmenuDuels.java -text
@@ -11730,24 +11736,30 @@ src/main/java/forge/gui/home/utilities/VSubmenuDeckEditor.java -text
src/main/java/forge/gui/home/utilities/VSubmenuExit.java -text
src/main/java/forge/gui/home/utilities/VSubmenuUtilities.java -text
src/main/java/forge/gui/home/utilities/package-info.java svneol=native#text/plain
src/main/java/forge/gui/layout/DragCell.java -text
src/main/java/forge/gui/layout/DragTab.java -text
src/main/java/forge/gui/layout/EDocID.java -text
src/main/java/forge/gui/layout/FViewNew.java -text
src/main/java/forge/gui/layout/ICDoc.java -text
src/main/java/forge/gui/layout/IDocIdList.java -text
src/main/java/forge/gui/layout/ILocalRepaint.java -text
src/main/java/forge/gui/layout/IVDoc.java -text
src/main/java/forge/gui/layout/MDragUI.java -text
src/main/java/forge/gui/layout/SIOUtil.java -text
src/main/java/forge/gui/layout/SOverflowUtil.java -text
src/main/java/forge/gui/layout/SRearrangingUtil.java -text
src/main/java/forge/gui/layout/SResizingUtil.java -text
src/main/java/forge/gui/match/CMatchUI.java -text
src/main/java/forge/gui/match/ControlWinLose.java -text
src/main/java/forge/gui/match/QuestWinLoseCardViewer.java -text
src/main/java/forge/gui/match/QuestWinLoseHandler.java -text
src/main/java/forge/gui/match/VMatchUI.java -text
src/main/java/forge/gui/match/ViewWinLose.java -text
src/main/java/forge/gui/match/controllers/CAntes.java -text
src/main/java/forge/gui/match/controllers/CCombat.java -text
src/main/java/forge/gui/match/controllers/CDetail.java -text
src/main/java/forge/gui/match/controllers/CDev.java -text
src/main/java/forge/gui/match/controllers/CDock.java -text
src/main/java/forge/gui/match/controllers/CLog.java -text
src/main/java/forge/gui/match/controllers/CMessage.java -text
src/main/java/forge/gui/match/controllers/CPicture.java -text
src/main/java/forge/gui/match/controllers/CPlayers.java -text
src/main/java/forge/gui/match/controllers/CStack.java -text
src/main/java/forge/gui/match/nonsingleton/CField.java -text
src/main/java/forge/gui/match/nonsingleton/CHand.java -text
src/main/java/forge/gui/match/nonsingleton/VField.java -text
src/main/java/forge/gui/match/nonsingleton/VHand.java -text
src/main/java/forge/gui/match/views/VAntes.java -text
src/main/java/forge/gui/match/views/VCombat.java -text
src/main/java/forge/gui/match/views/VDetail.java -text
src/main/java/forge/gui/match/views/VDev.java -text
src/main/java/forge/gui/match/views/VDock.java -text
src/main/java/forge/gui/match/views/VLog.java -text
src/main/java/forge/gui/match/views/VMessage.java -text
@@ -11769,7 +11781,6 @@ src/main/java/forge/gui/toolbox/FRadioButton.java -text
src/main/java/forge/gui/toolbox/FScrollPane.java -text
src/main/java/forge/gui/toolbox/FSkin.java -text
src/main/java/forge/gui/toolbox/FTextArea.java -text
src/main/java/forge/gui/toolbox/FVerticalTabPanel.java -text
src/main/java/forge/gui/toolbox/package-info.java svneol=native#text/plain
src/main/java/forge/item/BoosterPack.java -text
src/main/java/forge/item/CardDb.java -text
@@ -11862,13 +11873,11 @@ src/main/java/forge/util/closures/Predicate.java -text
src/main/java/forge/util/closures/PredicateString.java -text
src/main/java/forge/util/package-info.java -text
src/main/java/forge/view/ButtonUtil.java svneol=native#text/plain
src/main/java/forge/view/FView.java svneol=native#text/plain
src/main/java/forge/view/FView.java -text
src/main/java/forge/view/Main.java -text
src/main/java/forge/view/SplashFrame.java -text
src/main/java/forge/view/ViewBazaarUI.java -text
src/main/java/forge/view/ViewEditorUI.java -text
src/main/java/forge/view/ViewHomeUI.java -text
src/main/java/forge/view/ViewMatchUI.java -text
src/main/java/forge/view/arcane/CardArea.java svneol=native#text/plain
src/main/java/forge/view/arcane/CardPanel.java svneol=native#text/plain
src/main/java/forge/view/arcane/CardPanelContainer.java svneol=native#text/plain
@@ -11886,18 +11895,6 @@ src/main/java/forge/view/arcane/util/package-info.java svneol=native#text/plain
src/main/java/forge/view/bazaar/ViewItem.java -text
src/main/java/forge/view/bazaar/ViewStall.java svneol=native#text/plain
src/main/java/forge/view/bazaar/package-info.java svneol=native#text/plain
src/main/java/forge/view/match/QuestWinLoseCardViewer.java -text
src/main/java/forge/view/match/QuestWinLoseHandler.java -text
src/main/java/forge/view/match/ViewBattlefield.java -text
src/main/java/forge/view/match/ViewDetail.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/ViewMessage.java -text
src/main/java/forge/view/match/ViewPicture.java -text
src/main/java/forge/view/match/ViewTabber.java -text
src/main/java/forge/view/match/ViewWinLose.java -text
src/main/java/forge/view/match/package-info.java svneol=native#text/plain
src/main/java/forge/view/package-info.java svneol=native#text/plain
src/main/java/net/slightlymagic/braids/BaseProgressMonitor.java svneol=native#text/plain
src/main/java/net/slightlymagic/braids/BraidsProgressMonitor.java svneol=native#text/plain

View File

@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<layout>
<cell x="0.0" y="0.0" w="0.2" h="0.643">
<doc>REPORT_STACK</doc>
<doc>REPORT_COMBAT</doc>
<doc>REPORT_LOG</doc>
<doc>REPORT_PLAYERS</doc>
</cell>
<cell x="0.0" y="0.643" w="0.2" h="0.357">
<doc>REPORT_MESSAGE</doc>
<doc>DEV_MODE</doc>
<doc>CARD_ANTES</doc>
<doc>BUTTON_DOCK</doc>
</cell>
<cell x="0.2" y="0.0" w="0.6" h="0.364">
<doc>FIELD_0</doc>
</cell>
<cell x="0.2" y="0.732" w="0.6" h="0.268">
<doc>HAND_1</doc>
</cell>
<cell x="0.8" y="0.0" w="0.2" h="0.466">
<doc>CARD_DETAIL</doc>
</cell>
<cell x="0.2" y="0.364" w="0.6" h="0.368">
<doc>FIELD_1</doc>
</cell>
<cell x="0.8" y="0.466" w="0.2" h="0.534">
<doc>CARD_PICTURE</doc>
</cell>
</layout>

View File

@@ -55,7 +55,7 @@ import forge.game.zone.PlayerZone;
import forge.game.zone.PlayerZoneComesIntoPlay;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.view.match.ViewWinLose;
import forge.gui.match.ViewWinLose;
/**
* Methods for common actions performed during a game.

View File

@@ -36,6 +36,7 @@ import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.util.MyRandom;
/**
@@ -417,7 +418,7 @@ public final class GameActionUtil {
* @return a boolean.
*/
public static boolean showYesNoDialog(final Card c, String question, final boolean defaultNo) {
Singletons.getControl().getControlMatch().setCard(c);
CMatchUI.SINGLETON_INSTANCE.setCard(c);
final StringBuilder title = new StringBuilder();
title.append(c.getName()).append(" - Ability");
@@ -503,7 +504,7 @@ public final class GameActionUtil {
* @return a boolean.
*/
private static boolean showLandfallDialog(final Card c) {
Singletons.getControl().getControlMatch().setCard(c);
CMatchUI.SINGLETON_INSTANCE.setCard(c);
final String[] choices = { "Yes", "No" };
Object q = null;

View File

@@ -46,6 +46,7 @@ import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.util.MyRandom;
import forge.view.ButtonUtil;
@@ -1428,7 +1429,7 @@ public class AbilityFactoryCounters {
@Override
public void showMessage() {
ButtonUtil.enableOnlyCancel();
Singletons.getControl().getControlMatch().showMessage("Proliferate: Choose permanents and/or players");
CMatchUI.SINGLETON_INSTANCE.showMessage("Proliferate: Choose permanents and/or players");
}
@Override

View File

@@ -28,6 +28,7 @@ import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -145,7 +146,7 @@ class CardFactoryArtifacts {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage("Discard a land card (or select Mox Diamond to sacrifice it)");
CMatchUI.SINGLETON_INSTANCE.showMessage("Discard a land card (or select Mox Diamond to sacrifice it)");
ButtonUtil.enableOnlyCancel();
}
@@ -493,7 +494,7 @@ class CardFactoryArtifacts {
final StringBuilder sb = new StringBuilder();
sb.append(card.getName()).append(" - Exile cards from hand. Currently, ");
sb.append(this.exiled.size()).append(" selected. (Press OK when done.)");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyOK();
}
@@ -528,7 +529,7 @@ class CardFactoryArtifacts {
final StringBuilder sb = new StringBuilder();
sb.append(card.getName()).append(" - Returning cards to top of library.");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
// Then look at the exiled cards and put them on
// top of your library in any order.
@@ -692,7 +693,7 @@ class CardFactoryArtifacts {
if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0) {
this.stop();
}
Singletons.getControl().getControlMatch().showMessage(prompt);
CMatchUI.SINGLETON_INSTANCE.showMessage(prompt);
ButtonUtil.disableAll();
}
@@ -809,7 +810,7 @@ class CardFactoryArtifacts {
public void showMessage() {
final StringBuilder sb = new StringBuilder();
sb.append(cardName).append(" - Select an artifact on the battlefield");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}

View File

@@ -54,6 +54,7 @@ import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.util.MyRandom;
import forge.view.ButtonUtil;
@@ -361,7 +362,7 @@ public class CardFactoryCreatures {
@Override
public void showMessage() {
ButtonUtil.disableAll();
Singletons.getControl().getControlMatch().showMessage("Exile a nonland card from your hand.");
CMatchUI.SINGLETON_INSTANCE.showMessage("Exile a nonland card from your hand.");
}
@Override
@@ -413,9 +414,9 @@ public class CardFactoryCreatures {
@Override
public void showMessage() {
if (index[0] == 0) {
Singletons.getControl().getControlMatch().showMessage("Select target land you control.");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select target land you control.");
} else {
Singletons.getControl().getControlMatch().showMessage("Select target land opponent controls.");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select target land opponent controls.");
}
ButtonUtil.enableOnlyCancel();
@@ -1039,7 +1040,7 @@ public class CardFactoryCreatures {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage(msg);
CMatchUI.SINGLETON_INSTANCE.showMessage(msg);
ButtonUtil.enableOnlyOK();
}
@@ -1476,7 +1477,7 @@ public class CardFactoryCreatures {
final StringBuilder sb = new StringBuilder();
sb.append("Select up to 5 target permanents. Selected (");
sb.append(targetPerms.size()).append(") so far. Click OK when done.");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyOK();
}
@@ -1518,7 +1519,7 @@ public class CardFactoryCreatures {
public void showMessage() {
final StringBuilder sb = new StringBuilder();
sb.append(card.getName()).append(" - Select target player");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}
@@ -1574,7 +1575,7 @@ public class CardFactoryCreatures {
toDisplay += "Currently, (" + toSac.size() + ") selected with a total power of: "
+ getTotalPower();
toDisplay += " Click OK when Done.";
Singletons.getControl().getControlMatch().showMessage(toDisplay);
CMatchUI.SINGLETON_INSTANCE.showMessage(toDisplay);
ButtonUtil.enableAll();
}
@@ -1788,7 +1789,7 @@ public class CardFactoryCreatures {
message += "or artifact ";
}
message += "on the battlefield";
Singletons.getControl().getControlMatch().showMessage(cardName + " - " + message);
CMatchUI.SINGLETON_INSTANCE.showMessage(cardName + " - " + message);
ButtonUtil.enableOnlyCancel();
}

View File

@@ -19,6 +19,7 @@ import forge.game.GameLossReason;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -294,7 +295,7 @@ class CardFactoryEnchantments {
public void showMessage() {
final StringBuilder sb = new StringBuilder();
sb.append(cardName).append(" - Select an artifact on the battlefield");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}

View File

@@ -39,6 +39,7 @@ import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.util.MyRandom;
import forge.view.ButtonUtil;
@@ -206,7 +207,7 @@ class CardFactoryLands {
public void showMessage() {
final StringBuilder sb = new StringBuilder();
sb.append(cardName).append(" - Select an untapped land to sacrifice");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}
@@ -224,7 +225,7 @@ class CardFactoryLands {
paid[0]++;
final StringBuilder sb = new StringBuilder();
sb.append(cardName).append(" - Select an untapped land to sacrifice");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
} else {
this.stop();
}
@@ -295,7 +296,7 @@ class CardFactoryLands {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage(
CMatchUI.SINGLETON_INSTANCE.showMessage(
cardName + " - Select one " + type[0] + " to sacrifice");
ButtonUtil.enableOnlyCancel();
}
@@ -388,7 +389,7 @@ class CardFactoryLands {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage(
CMatchUI.SINGLETON_INSTANCE.showMessage(
"Scorched Ruins - Select an untapped land to sacrifice");
ButtonUtil.enableOnlyCancel();
}
@@ -405,7 +406,7 @@ class CardFactoryLands {
Singletons.getModel().getGameAction().sacrifice(c);
if (paid[0] < 1) {
paid[0]++;
Singletons.getControl().getControlMatch().showMessage(
CMatchUI.SINGLETON_INSTANCE.showMessage(
"Scorched Ruins - Select an untapped land to sacrifice");
} else {
this.stop();
@@ -483,7 +484,7 @@ class CardFactoryLands {
public void showMessage() {
final StringBuilder sb = new StringBuilder();
sb.append(card.getName()).append(" - Reveal a card.");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}
@@ -669,7 +670,7 @@ class CardFactoryLands {
final StringBuilder sb = new StringBuilder();
sb.append(cardName);
sb.append(" - Select one non-Lair land to return to your hand");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}
@@ -738,7 +739,7 @@ class CardFactoryLands {
final StringBuilder sb = new StringBuilder();
sb.append(card).append(" - Select one untapped ");
sb.append(type[0]).append(" to return");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}

View File

@@ -50,6 +50,7 @@ import forge.game.player.PlayerUtil;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -116,9 +117,9 @@ public class CardFactorySorceries {
@Override
public void showMessage() {
if (index[0] == 0) {
Singletons.getControl().getControlMatch().showMessage("Select target land you control.");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select target land you control.");
} else {
Singletons.getControl().getControlMatch().showMessage("Select target land opponent controls.");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select target land opponent controls.");
}
ButtonUtil.enableOnlyCancel();
@@ -608,7 +609,7 @@ public class CardFactorySorceries {
final StringBuilder sb = new StringBuilder();
sb.append("Select target ").append(humanBasic.get(this.count));
sb.append(" land to not sacrifice");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}
}
@@ -1068,7 +1069,7 @@ public class CardFactorySorceries {
final StringBuilder sb = new StringBuilder();
sb.append("Select target creatures and/or players. Currently, ");
sb.append(this.getNumTargets()).append(" targets. Click OK when done.");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
}
private int getNumTargets() {
@@ -1102,11 +1103,11 @@ public class CardFactorySorceries {
@Override
public void selectCard(final Card c, final PlayerZone zone) {
if (!c.canBeTargetedBy(spell)) {
Singletons.getControl().getControlMatch().showMessage("Cannot target this card.");
CMatchUI.SINGLETON_INSTANCE.showMessage("Cannot target this card.");
return; // cannot target
}
if (targets.contains(c)) {
Singletons.getControl().getControlMatch().showMessage("You have already selected this target.");
CMatchUI.SINGLETON_INSTANCE.showMessage("You have already selected this target.");
return; // cannot target the same creature twice.
}
@@ -1119,11 +1120,11 @@ public class CardFactorySorceries {
@Override
public void selectPlayer(final Player player) {
if (!player.canBeTargetedBy(spell)) {
Singletons.getControl().getControlMatch().showMessage("Cannot target this player.");
CMatchUI.SINGLETON_INSTANCE.showMessage("Cannot target this player.");
return; // cannot target
}
if (targetPlayers.contains(player)) {
Singletons.getControl().getControlMatch().showMessage("You have already selected this player.");
CMatchUI.SINGLETON_INSTANCE.showMessage("You have already selected this player.");
return; // cannot target the same player twice.
}
targetPlayers.add(player);
@@ -1606,7 +1607,7 @@ public class CardFactorySorceries {
final StringBuilder sb = new StringBuilder();
sb.append(cardName).append(" - Select a target creature to gain Fear (up to ");
sb.append(this.stop - this.count).append(" more)");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableAll();
}
@@ -1648,7 +1649,7 @@ public class CardFactorySorceries {
public void showMessage() {
final StringBuilder sb = new StringBuilder();
sb.append(cardName).append(" - Select target creature to get -X/-X");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}
@@ -1729,7 +1730,7 @@ public class CardFactorySorceries {
public void showMessage() {
final StringBuilder sb = new StringBuilder();
sb.append(cardName).append(" - Select target player to lose life");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}

View File

@@ -67,6 +67,7 @@ import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.util.MyRandom;
import forge.view.ButtonUtil;
@@ -808,7 +809,7 @@ public class CardFactoryUtil {
if (spell.getTargetCard() != null) {
this.stop();
}
Singletons.getControl().getControlMatch().showMessage("Select target Spell: ");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select target Spell: ");
final Card choice = GuiUtils.chooseOneOrNone("Choose a Spell", choices.toArray());
if (choice != null) {
spell.setTargetCard(choice);
@@ -856,7 +857,7 @@ public class CardFactoryUtil {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage(message);
CMatchUI.SINGLETON_INSTANCE.showMessage(message);
ButtonUtil.disableAll();
}
@@ -1752,7 +1753,7 @@ public class CardFactoryUtil {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage(message);
CMatchUI.SINGLETON_INSTANCE.showMessage(message);
ButtonUtil.enableOnlyCancel();
}
@@ -1764,7 +1765,7 @@ public class CardFactoryUtil {
@Override
public void selectCard(final Card card, final PlayerZone zone) {
if (targeted && !card.canBeTargetedBy(spell)) {
Singletons.getControl().getControlMatch()
CMatchUI.SINGLETON_INSTANCE
.showMessage("Cannot target this card (Shroud? Protection?).");
} else if (choices.contains(card)) {
spell.setTargetCard(card);
@@ -1810,7 +1811,7 @@ public class CardFactoryUtil {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage(message);
CMatchUI.SINGLETON_INSTANCE.showMessage(message);
ButtonUtil.enableOnlyCancel();
}
@@ -1890,7 +1891,7 @@ public class CardFactoryUtil {
* (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) { this.stop();
* }
*
* Singletons.getControl().getControlMatch().showMessage(
* CMatchUI.SINGLETON_INSTANCE.showMessage(
* "Select a card to discard"); ButtonUtil.disableAll(); }
*
* @Override public void selectCard(final Card card, final PlayerZone zone)
@@ -1901,7 +1902,7 @@ public class CardFactoryUtil {
* (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0)) { this.done();
* } else { this.showMessage(); } } }
*
* void done() { Singletons.getControl().getControlMatch().showMessage(
* void done() { CMatchUI.SINGLETON_INSTANCE.showMessage(
* "Returning cards to hand.");
* Singletons.getModel().getGameAction().exile(recall); final CardList grave
* = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); for (int i = 1; i
@@ -1934,7 +1935,7 @@ public class CardFactoryUtil {
public void showMessage() {
final StringBuilder sb = new StringBuilder();
sb.append("Select target wolf to damage for ").append(spell.getSourceCard());
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}
@@ -1976,7 +1977,7 @@ public class CardFactoryUtil {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage("Select target artifact creature");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select target artifact creature");
ButtonUtil.enableOnlyCancel();
}
@@ -3549,7 +3550,7 @@ public class CardFactoryUtil {
public void showMessage() {
final StringBuilder sb = new StringBuilder();
sb.append("Select a ").append(type).append(" to untap");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}
@@ -4699,7 +4700,7 @@ public class CardFactoryUtil {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage("Choose target creature to haunt.");
CMatchUI.SINGLETON_INSTANCE.showMessage("Choose target creature to haunt.");
ButtonUtil.disableAll();
}
@@ -4713,7 +4714,7 @@ public class CardFactoryUtil {
AllZone.getStack().add(haunterDiesWork);
this.stop();
} else {
Singletons.getControl().getControlMatch()
CMatchUI.SINGLETON_INSTANCE
.showMessage("Cannot target this card (Shroud? Protection?).");
}
}

View File

@@ -21,7 +21,6 @@ import forge.AllZone;
import forge.Card;
import forge.CardList;
import forge.CardListUtil;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
import forge.control.input.Input;
@@ -29,6 +28,7 @@ import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -325,7 +325,7 @@ public class CostDiscard extends CostPartWithList {
sb.append(nNeeded - this.nDiscard);
sb.append(" remaining.");
}
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}

View File

@@ -34,6 +34,7 @@ import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -408,7 +409,7 @@ public class CostExile extends CostPartWithList {
this.typeList = sa.getActivatingPlayer().getCardsIn(part.getFrom());
this.typeList = this.typeList.getValidCards(type.split(";"), sa.getActivatingPlayer(),
sa.getSourceCard());
Singletons.getControl().getControlMatch().showMessage(msg.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(msg.toString());
ButtonUtil.enableOnlyCancel();
}

View File

@@ -21,7 +21,6 @@ import com.google.common.base.Strings;
import forge.AllZone;
import forge.Card;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.mana.ManaCost;
import forge.card.spellability.SpellAbility;
@@ -34,6 +33,7 @@ import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -277,7 +277,7 @@ public class CostMana extends CostPart {
ButtonUtil.enableOnlyCancel();
}
Singletons.getControl().getControlMatch().showMessage(
CMatchUI.SINGLETON_INSTANCE.showMessage(
"Pay X Mana Cost for " + sa.getSourceCard().getName() + "\n" + this.xPaid + " Paid so far.");
}
@@ -474,7 +474,7 @@ public class CostMana extends CostPart {
public void showMessage() {
ButtonUtil.enableOnlyCancel();
final String displayMana = this.mana.toString().replace("X", "").trim();
Singletons.getControl().getControlMatch().showMessage("Pay Mana Cost: " + displayMana);
CMatchUI.SINGLETON_INSTANCE.showMessage("Pay Mana Cost: " + displayMana);
final StringBuilder msg = new StringBuilder("Pay Mana Cost: " + displayMana);
if (this.phyLifeToLose > 0) {
@@ -487,7 +487,7 @@ public class CostMana extends CostPart {
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
}
Singletons.getControl().getControlMatch().showMessage(msg.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(msg.toString());
if (this.mana.isPaid()) {
this.done();
}

View File

@@ -20,7 +20,6 @@ package forge.card.cost;
import forge.Card;
import forge.CardList;
import forge.Counters;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.SpellAbility;
@@ -28,6 +27,7 @@ import forge.control.input.Input;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -271,7 +271,7 @@ public class CostPutCounter extends CostPartWithList {
this.typeList = sa.getActivatingPlayer().getCardsIn(ZoneType.Battlefield);
this.typeList = this.typeList.getValidCards(type.split(";"), sa.getActivatingPlayer(),
sa.getSourceCard());
Singletons.getControl().getControlMatch().showMessage(msg.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(msg.toString());
ButtonUtil.enableOnlyCancel();
}

View File

@@ -30,6 +30,7 @@ import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -231,7 +232,7 @@ public class CostReturn extends CostPartWithList {
this.typeList = sa.getActivatingPlayer().getCardsIn(ZoneType.Battlefield);
this.typeList = this.typeList.getValidCards(type.split(";"), sa.getActivatingPlayer(),
sa.getSourceCard());
Singletons.getControl().getControlMatch().showMessage(msg.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(msg.toString());
ButtonUtil.enableOnlyCancel();
}

View File

@@ -20,7 +20,6 @@ package forge.card.cost;
import forge.AllZone;
import forge.Card;
import forge.CardList;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
import forge.control.input.Input;
@@ -29,6 +28,7 @@ import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -256,7 +256,7 @@ public class CostReveal extends CostPartWithList {
sb.append(nNeeded - this.nReveal);
sb.append(" remaining.");
}
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
ButtonUtil.enableOnlyCancel();
}

View File

@@ -30,6 +30,7 @@ import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -273,7 +274,7 @@ public class CostSacrifice extends CostPartWithList {
msg.append("s");
}
Singletons.getControl().getControlMatch().showMessage(msg.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(msg.toString());
ButtonUtil.enableOnlyCancel();
}

View File

@@ -20,7 +20,6 @@ package forge.card.cost;
import forge.Card;
import forge.CardList;
import forge.CardListFilter;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
import forge.control.input.Input;
@@ -28,6 +27,7 @@ import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -242,7 +242,7 @@ public class CostTapType extends CostPartWithList {
}
final int left = nCards - this.nTapped;
Singletons.getControl().getControlMatch()
CMatchUI.SINGLETON_INSTANCE
.showMessage("Select a " + tapType.getDescription() + " to tap (" + left + " left)");
ButtonUtil.enableOnlyCancel();
}

View File

@@ -25,13 +25,13 @@ import forge.AllZone;
import forge.AllZoneUtil;
import forge.Card;
import forge.CardList;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.control.input.Input;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -344,7 +344,7 @@ public class TargetSelection {
sb.append("\n");
sb.append(tgt.getVTSelection());
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
// If reached Minimum targets, enable OK button
if (!tgt.isMinTargetsChosen(sa.getSourceCard(), sa)) {
@@ -376,7 +376,7 @@ public class TargetSelection {
// leave this in temporarily, there some seriously wrong things
// going on here
if (targeted && !card.canBeTargetedBy(sa)) {
Singletons.getControl().getControlMatch().showMessage("Cannot target this card (Shroud? Protection? Restrictions?).");
CMatchUI.SINGLETON_INSTANCE.showMessage("Cannot target this card (Shroud? Protection? Restrictions?).");
} else if (choices.contains(card)) {
tgt.addTarget(card);
this.done();

View File

@@ -31,10 +31,13 @@ import javax.swing.WindowConstants;
import forge.AllZone;
import forge.Singletons;
import forge.control.KeyboardShortcuts.Shortcut;
import forge.gui.home.VHomeUI;
import forge.gui.home.quest.SubmenuQuestUtil;
import forge.gui.match.VMatchUI;
import forge.gui.match.controllers.CDock;
import forge.gui.toolbox.CardFaceSymbols;
import forge.gui.toolbox.FSkin;
import forge.view.ViewHomeUI;
import forge.view.FView;
/**
* <p>
@@ -77,7 +80,7 @@ public enum FControl {
@Override
public void windowClosing(final WindowEvent e) {
Singletons.getView().getFrame().setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
Singletons.getControl().getControlMatch().getDockControl().concede();
CDock.SINGLETON_INSTANCE.concede();
}
};
@@ -94,7 +97,7 @@ public enum FControl {
// Default action on window close
this.waDefault = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
public void windowClosing(final WindowEvent e) {
Singletons.getView().getFrame().setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
};
@@ -112,7 +115,7 @@ public enum FControl {
CardFaceSymbols.loadImages();
this.shortcuts = KeyboardShortcuts.attachKeyboardShortcuts();
this.display = Singletons.getView().getLayeredContentPane();
this.display = FView.SINGLETON_INSTANCE.getLpnDocument();
//Singletons.getView().initialize();
@@ -146,13 +149,14 @@ public enum FControl {
// Fire up new state
switch (i0) {
case HOME_SCREEN:
display.add(ViewHomeUI.SINGLETON_INSTANCE.getPanel(), JLayeredPane.DEFAULT_LAYER);
sizeChildren();
VHomeUI.SINGLETON_INSTANCE.populate();
FView.SINGLETON_INSTANCE.getPnlInsets().setVisible(false);
//sizeChildren();
break;
case MATCH_SCREEN:
display.add(Singletons.getView().getViewMatch(), JLayeredPane.DEFAULT_LAYER);
sizeChildren();
VMatchUI.SINGLETON_INSTANCE.populate();
FView.SINGLETON_INSTANCE.getPnlInsets().setVisible(true);
Singletons.getView().getFrame().addWindowListener(waConcede);
break;
@@ -170,17 +174,6 @@ public enum FControl {
}
}
/** Gets the match controller.
* @return {@link forge.control.match.ControlMatchUI}
*/
public ControlMatchUI getControlMatch() {
if (getState() != FControl.MATCH_SCREEN) {
throw new IllegalArgumentException("FControl$getControlMatch\n"
+ "may only be called while the match UI is showing.");
}
return Singletons.getView().getViewMatch().getControl();
}
/**
* Returns the int reflecting the current state of the top level frame
* (see field definitions and class methods for details).
@@ -198,10 +191,10 @@ public enum FControl {
/** Remove all children from a specified layer. */
private void clearChildren(final int layer0) {
final Component[] children = Singletons.getView()
.getLayeredContentPane().getComponentsInLayer(layer0);
final Component[] children = FView.SINGLETON_INSTANCE.getLpnDocument()
.getComponentsInLayer(layer0);
for (Component c : children) {
for (final Component c : children) {
display.remove(c);
}
}

View File

@@ -16,7 +16,10 @@ import javax.swing.KeyStroke;
import org.apache.commons.lang3.StringUtils;
import forge.Singletons;
import forge.gui.framework.EDocID;
import forge.gui.framework.SDisplayUtil;
import forge.gui.home.settings.VSubmenuPreferences.KeyboardShortcutField;
import forge.gui.match.controllers.CDock;
import forge.properties.ForgePreferences.FPref;
/**
@@ -49,7 +52,7 @@ public class KeyboardShortcuts {
@Override
public void actionPerformed(final ActionEvent e) {
if (Singletons.getControl().getState() != 1) { return; }
Singletons.getControl().getControlMatch().getTabberControl().showPnlStack();
SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
}
};
@@ -58,7 +61,7 @@ public class KeyboardShortcuts {
@Override
public void actionPerformed(final ActionEvent e) {
if (Singletons.getControl().getState() != 1) { return; }
Singletons.getControl().getControlMatch().getTabberControl().showPnlCombat();
SDisplayUtil.showTab(EDocID.REPORT_COMBAT.getDoc());
}
};
@@ -67,7 +70,7 @@ public class KeyboardShortcuts {
@Override
public void actionPerformed(final ActionEvent e) {
if (Singletons.getControl().getState() != 1) { return; }
Singletons.getControl().getControlMatch().getTabberControl().showPnlGameLog();
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
}
};
@@ -76,7 +79,7 @@ public class KeyboardShortcuts {
@Override
public void actionPerformed(final ActionEvent e) {
if (Singletons.getControl().getState() != 1) { return; }
Singletons.getControl().getControlMatch().getTabberControl().showPnlPlayers();
SDisplayUtil.showTab(EDocID.REPORT_PLAYERS.getDoc());
}
};
@@ -85,7 +88,7 @@ public class KeyboardShortcuts {
@Override
public void actionPerformed(final ActionEvent e) {
if (Singletons.getControl().getState() != 1) { return; }
Singletons.getControl().getControlMatch().getTabberControl().showPnlDev();
SDisplayUtil.showTab(EDocID.DEV_MODE.getDoc());
}
};
@@ -94,7 +97,7 @@ public class KeyboardShortcuts {
@Override
public void actionPerformed(final ActionEvent e) {
if (Singletons.getControl().getState() != 1) { return; }
Singletons.getControl().getControlMatch().getDockControl().concede();
CDock.SINGLETON_INSTANCE.concede();
}
};

View File

@@ -22,6 +22,7 @@ import forge.Card;
import forge.Singletons;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.gui.match.CMatchUI;
/**
* <p>
@@ -44,7 +45,7 @@ public abstract class Input implements java.io.Serializable {
* </p>
*/
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage("Blank Input");
CMatchUI.SINGLETON_INSTANCE.showMessage("Blank Input");
}
/**

View File

@@ -20,11 +20,14 @@ package forge.control.input;
import forge.AllZone;
import forge.Card;
import forge.CardList;
import forge.Singletons;
import forge.game.phase.CombatUtil;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.framework.SDisplayUtil;
import forge.gui.match.CMatchUI;
import forge.gui.match.views.VMessage;
import forge.view.ButtonUtil;
import forge.Singletons;
/**
* <p>
@@ -54,7 +57,7 @@ public class InputAttack extends Input {
sb.append("Declare Attackers: Select Creatures to Attack ");
sb.append(o.toString());
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
if (AllZone.getCombat().getRemainingDefenders() == 0) {
// Nothing left to attack, has to attack this defender
@@ -107,7 +110,7 @@ public class InputAttack extends Input {
CombatUtil.showCombat();
}
else {
Singletons.getControl().getControlMatch().getMessageControl().remind();
SDisplayUtil.remind(VMessage.SINGLETON_INSTANCE);
}
} // selectCard()

View File

@@ -25,6 +25,9 @@ import forge.Singletons;
import forge.game.phase.CombatUtil;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.framework.SDisplayUtil;
import forge.gui.match.CMatchUI;
import forge.gui.match.views.VMessage;
import forge.view.ButtonUtil;
/**
@@ -65,14 +68,14 @@ public class InputBlock extends Input {
final StringBuilder sb = new StringBuilder();
sb.append("To Block, click on your Opponents attacker first, then your blocker(s). ");
sb.append("To cancel a block right-click on your blocker");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
} else {
final String attackerName = this.currentAttacker.isFaceDown() ? "Morph" : this.currentAttacker.getName();
final StringBuilder sb = new StringBuilder();
sb.append("Select a creature to block ").append(attackerName).append(" (");
sb.append(this.currentAttacker.getUniqueNumber()).append("). ");
sb.append("To cancel a block right-click on your blocker");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
}
CombatUtil.showCombat();
@@ -102,7 +105,7 @@ public class InputBlock extends Input {
this.allBlocking.add(card);
AllZone.getCombat().addBlocker(this.currentAttacker, card);
} else {
Singletons.getControl().getControlMatch().getMessageControl().remind();
SDisplayUtil.remind(VMessage.SINGLETON_INSTANCE);
}
this.showMessage();
} // selectCard()

View File

@@ -19,11 +19,12 @@ package forge.control.input;
import forge.AllZone;
import forge.Card;
import forge.Singletons;
import forge.game.phase.CombatUtil;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
import forge.Singletons;
/**
* <p>
@@ -63,7 +64,7 @@ public class InputCleanup extends Input {
final StringBuffer sb = new StringBuffer();
sb.append("Cleanup Phase: You can only have a maximum of ").append(max);
sb.append(" cards, you currently have ").append(n).append(" cards in your hand - select a card to discard");
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
}
/** {@inheritDoc} */

View File

@@ -21,11 +21,11 @@ import java.util.LinkedList;
import java.util.Stack;
import forge.MyObservable;
import forge.Singletons;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerAIInput;
import forge.game.player.Player;
import forge.gui.match.CMatchUI;
import forge.model.FModel;
/**
@@ -247,7 +247,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
final boolean skip = this.model.getGameState().getPhaseHandler().doSkipPhase();
this.model.getGameState().getPhaseHandler().setSkipPhase(false);
if ((this.model.getGameState().getStack().size() == 0)
&& !Singletons.getControl().getControlMatch().stopAtPhase(playerTurn, phase) && skip) {
&& !CMatchUI.SINGLETON_INSTANCE.stopAtPhase(playerTurn, phase) && skip) {
this.model.getGameState().getPhaseHandler().passPriority();
return null;
} else {

View File

@@ -35,6 +35,10 @@ import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.framework.SDisplayUtil;
import forge.gui.match.CMatchUI;
import forge.gui.match.VMatchUI;
import forge.gui.match.views.VMessage;
import forge.quest.QuestController;
import forge.quest.bazaar.QuestItemType;
import forge.view.ButtonUtil;
@@ -57,9 +61,9 @@ public class InputMulligan extends Input {
@Override
public final void showMessage() {
ButtonUtil.enableAll();
Singletons.getView().getViewMatch().getBtnOK().setText("No");
Singletons.getView().getViewMatch().getBtnCancel().setText("Yes");
Singletons.getControl().getControlMatch().showMessage("Do you want to Mulligan?");
VMatchUI.SINGLETON_INSTANCE.getBtnOK().setText("No");
VMatchUI.SINGLETON_INSTANCE.getBtnCancel().setText("Yes");
CMatchUI.SINGLETON_INSTANCE.showMessage("Do you want to Mulligan?");
}
/** {@inheritDoc} */
@@ -224,7 +228,7 @@ public class InputMulligan extends Input {
c0.getController().drawCards(hand.size());
}
} else {
Singletons.getControl().getControlMatch().getMessageControl().remind();
SDisplayUtil.remind(VMessage.SINGLETON_INSTANCE);
}
}
}

View File

@@ -24,6 +24,9 @@ import forge.game.phase.PhaseType;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.gui.GuiDisplayUtil;
import forge.gui.framework.SDisplayUtil;
import forge.gui.match.CMatchUI;
import forge.gui.match.views.VMessage;
import forge.view.ButtonUtil;
/**
@@ -64,7 +67,7 @@ public class InputPassPriority extends Input implements java.io.Serializable {
sb.append("\n");
sb.append("Priority: ").append(player);
Singletons.getControl().getControlMatch().showMessage(sb.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
}
/** {@inheritDoc} */
@@ -86,7 +89,7 @@ public class InputPassPriority extends Input implements java.io.Serializable {
Singletons.getModel().getGameState().getPhaseHandler().setPriority(AllZone.getHumanPlayer());
}
else {
Singletons.getControl().getControlMatch().getMessageControl().remind();
SDisplayUtil.remind(VMessage.SINGLETON_INSTANCE);
}
} // selectCard()
}

View File

@@ -27,6 +27,7 @@ import forge.game.phase.PhaseHandler;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
//pays the cost of a card played from the player's hand
@@ -289,7 +290,7 @@ public class InputPayManaCost extends InputMana {
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
}
Singletons.getControl().getControlMatch().showMessage(msg.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(msg.toString());
if (this.manaCost.isPaid() && !new ManaCost(this.originalManaCost).isPaid()) {
this.originalCard.setSunburstValue(this.manaCost.getSunburst());
this.done();

View File

@@ -20,11 +20,13 @@ package forge.control.input;
import forge.AllZone;
import forge.Card;
import forge.Command;
import forge.Singletons;
import forge.card.mana.ManaCost;
import forge.card.spellability.SpellAbility;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.framework.SDisplayUtil;
import forge.gui.match.CMatchUI;
import forge.gui.match.views.VMessage;
import forge.view.ButtonUtil;
//if cost is paid, Command.execute() is called
@@ -156,7 +158,7 @@ public class InputPayManaCostAbility extends InputMana {
this.manaCost = InputPayManaCostUtil.activateManaAbility(this.fakeAbility, card, this.manaCost);
if (card.getManaAbility().isEmpty() || card.isInZone(ZoneType.Hand)) {
Singletons.getControl().getControlMatch().getMessageControl().remind();
SDisplayUtil.remind(VMessage.SINGLETON_INSTANCE);
}
if (this.manaCost.isPaid()) {
@@ -194,7 +196,7 @@ public class InputPayManaCostAbility extends InputMana {
if (this.showOnlyOKButton) {
ButtonUtil.enableOnlyOK();
}
Singletons.getControl().getControlMatch().showMessage(this.message + "Pay Mana Cost: \r\n" + this.manaCost.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(this.message + "Pay Mana Cost: \r\n" + this.manaCost.toString());
}
/* (non-Javadoc)

View File

@@ -1,604 +0,0 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.control.match;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;
import com.google.code.jyield.Generator;
import com.google.code.jyield.YieldUtils;
import forge.AllZone;
import forge.Card;
import forge.CardList;
import forge.Constant;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil;
import forge.control.input.Input;
import forge.control.input.InputAttack;
import forge.control.input.InputBlock;
import forge.control.input.InputMana;
import forge.control.input.InputPayManaCost;
import forge.control.input.InputPayManaCostAbility;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.ForgeAction;
import forge.gui.GuiDisplayUtil;
import forge.gui.GuiUtils;
import forge.gui.toolbox.FLabel;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.properties.NewConstants.Lang.GuiDisplay.ComputerHand;
import forge.properties.NewConstants.Lang.GuiDisplay.ComputerLibrary;
import forge.properties.NewConstants.Lang.GuiDisplay.HumanHand;
import forge.properties.NewConstants.Lang.GuiDisplay.HumanLibrary;
import forge.view.match.ViewField;
/**
* Child controller, applied to single field in battlefield. Manages player view
* functions such as card observers, life total changes, graveyard button click,
* etc.
*
*/
public class ControlField {
private final Player player;
private final ViewField view;
private MouseMotionListener mmlCardOver;
private MouseListener madAvatar, madLibrary, madHand, madExiled,
madGraveyard, madFlashback, madCardClick, madBlack,
madBlue, madGreen, madRed, madWhite, madColorless;
private Observer observerZones, observerDetails, observerPlay;
/**
* Child controller, applied to single field in battlefield. Manages player
* view functions such as card observers, life total changes, graveyard
* button click, etc.
*
* @param p
* &emsp; The Player this field applies to
* @param v
* &emsp; The Swing component for this field
*/
public ControlField(final Player p, final ViewField v) {
this.player = p;
this.view = v;
initMouseAdapters();
initObservers();
addObservers();
addListeners();
}
/**
* Gets the player.
*
* @return Player
*/
public Player getPlayer() {
return this.player;
}
/**
* Gets the view.
*
* @return ViewField
*/
public ViewField getView() {
return this.view;
}
/**
* Adds observers to field components where required: card stats, player
* stats, etc.
*/
public void addObservers() {
this.player.getZone(ZoneType.Hand).addObserver(observerZones);
this.player.addObserver(observerDetails);
this.player.getZone(ZoneType.Battlefield).addObserver(observerPlay);
}
/**
* Listeners for user actions on the battlefield.
*
*/
public void addListeners() {
// Battlefield card clicks
this.view.getTabletop().removeMouseListener(madCardClick);
this.view.getTabletop().addMouseListener(madCardClick);
// Battlefield card mouseover
this.view.getTabletop().removeMouseMotionListener(mmlCardOver);
this.view.getTabletop().addMouseMotionListener(mmlCardOver);
// Player select
this.view.getAvatarArea().removeMouseListener(madAvatar);
this.view.getAvatarArea().addMouseListener(madAvatar);
// Graveyard card list button
((FLabel) this.view.getLblGraveyard()).setHoverable(true);
this.view.getLblGraveyard().removeMouseListener(madGraveyard);
this.view.getLblGraveyard().addMouseListener(madGraveyard);
// Exile card list button
((FLabel) this.view.getLblExile()).setHoverable(true);
this.view.getLblExile().removeMouseListener(madExiled);
this.view.getLblExile().addMouseListener(madExiled);
// Library card list button
this.view.getLblLibrary().removeMouseListener(madLibrary);
this.view.getLblLibrary().addMouseListener(madLibrary);
this.view.getLblHand().removeMouseListener(madHand);
this.view.getLblHand().addMouseListener(madHand);
// Flashback card list button
((FLabel) this.view.getLblFlashback()).setHoverable(true);
this.view.getLblFlashback().removeMouseListener(madFlashback);
this.view.getLblFlashback().addMouseListener(madFlashback);
((FLabel) this.view.getLblBlack()).setHoverable(true);
this.view.getLblBlack().removeMouseListener(madBlack);
this.view.getLblBlack().addMouseListener(madBlack);
((FLabel) this.view.getLblBlue()).setHoverable(true);
this.view.getLblBlue().removeMouseListener(madBlue);
this.view.getLblBlue().addMouseListener(madBlue);
((FLabel) this.view.getLblGreen()).setHoverable(true);
this.view.getLblGreen().removeMouseListener(madGreen);
this.view.getLblGreen().addMouseListener(madGreen);
((FLabel) this.view.getLblRed()).setHoverable(true);
this.view.getLblRed().removeMouseListener(madRed);
this.view.getLblRed().addMouseListener(madRed);
((FLabel) this.view.getLblWhite()).setHoverable(true);
this.view.getLblWhite().removeMouseListener(madWhite);
this.view.getLblWhite().addMouseListener(madWhite);
((FLabel) this.view.getLblColorless()).setHoverable(true);
this.view.getLblColorless().removeMouseListener(madColorless);
this.view.getLblColorless().addMouseListener(madColorless);
}
/**
* Resets all phase buttons to "inactive", so highlight won't be drawn on
* them. "Enabled" state remains the same.
*/
public void resetPhaseButtons() {
this.view.getLblUpkeep().setActive(false);
this.view.getLblDraw().setActive(false);
this.view.getLblMain1().setActive(false);
this.view.getLblBeginCombat().setActive(false);
this.view.getLblDeclareAttackers().setActive(false);
this.view.getLblDeclareBlockers().setActive(false);
this.view.getLblFirstStrike().setActive(false);
this.view.getLblCombatDamage().setActive(false);
this.view.getLblEndCombat().setActive(false);
this.view.getLblMain2().setActive(false);
this.view.getLblEndTurn().setActive(false);
this.view.getLblCleanup().setActive(false);
}
/**
* Receives click and programmatic requests for viewing data stacks in the
* "zones" of a player field: hand, library, etc.
*
*/
private class ZoneAction extends ForgeAction {
private static final long serialVersionUID = -5822976087772388839L;
private final PlayerZone zone;
private final String title;
/**
* Receives click and programmatic requests for viewing data stacks in
* the "zones" of a player field: hand, graveyard, etc. The library
* "zone" is an exception to the rule; it's handled in DeckListAction.
*
* @param zone
* &emsp; PlayerZone obj
* @param property
* &emsp; String obj
*/
public ZoneAction(final PlayerZone zone, final String property) {
super(property);
this.title = ForgeProps.getLocalized(property + "/title");
this.zone = zone;
}
/**
* @param e
* &emsp; ActionEvent obj
*/
@Override
public void actionPerformed(final ActionEvent e) {
Generator<Card> c = YieldUtils.toGenerator(this.getCardsAsIterable());
if (AllZone.getNameChanger().shouldChangeCardName()) {
c = AllZone.getNameChanger().changeCard(c);
}
final Iterable<Card> myIterable = YieldUtils.toIterable(c);
final ArrayList<Card> choices = YieldUtils.toArrayList(myIterable);
final ArrayList<Card> choices2 = new ArrayList<Card>();
if (choices.isEmpty()) {
GuiUtils.chooseOneOrNone(this.title, new String[] { "no cards" });
} else {
for (int i = 0; i < choices.size(); i++) {
final Card crd = choices.get(i);
if (crd.isFaceDown()) {
if (crd.getController().isComputer() || !crd.hasKeyword("You may look at this card.")) {
final Card faceDown = new Card();
faceDown.setName("Face Down");
choices2.add(faceDown);
} else {
final Card faceDown = AllZone.getCardFactory().copyCard(crd);
faceDown.turnFaceUp();
choices2.add(faceDown);
}
} else {
choices2.add(crd);
}
}
final Card choice = (Card) GuiUtils.chooseOneOrNone(this.title, choices2.toArray());
if (choice != null) {
this.doAction(choice);
}
}
}
protected Iterable<Card> getCardsAsIterable() {
return this.zone.getCards();
}
protected void doAction(final Card c) {
}
} // End ZoneAction
private void initObservers() {
// Hand, Graveyard, Library, Flashback, Exile zones, attached to hand.
observerZones = new Observer() {
@Override
public void update(final Observable a, final Object b) {
ControlField.this.view.updateZones(ControlField.this.player);
}
};
// Life total, poison total, and keywords, attached directly to Player.
observerDetails = new Observer() {
@Override
public void update(final Observable a, final Object b) {
ControlField.this.view.updateDetails(ControlField.this.player);
}
};
// Card play area, attached to battlefield zone.
observerPlay = new Observer() {
@Override
public void update(final Observable a, final Object b) {
final PlayerZone pZone = (PlayerZone) a;
GuiDisplayUtil.setupPlayZone(ControlField.this.view.getTabletop(), pZone.getCards(false));
}
};
}
/** Simple method that inits the mouse adapters for listeners,
* here to simplify life in the constructor.
*/
private void initMouseAdapters() {
// Hand listener
madHand = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (!ControlField.this.player.isComputer()) {
new ZoneAction(ControlField.this.player.getZone(ZoneType.Hand), HumanHand.BASE)
.actionPerformed(null);
} else if (Constant.Runtime.DEV_MODE[0]
|| ControlField.this.player.hasKeyword("Play with your hand revealed.")) {
new ZoneAction(ControlField.this.player.getZone(ZoneType.Hand), ComputerHand.BASE)
.actionPerformed(null);
}
}
};
// Flashback listener
madFlashback = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (!ControlField.this.player.isComputer()) {
new ZoneAction(AllZone.getHumanPlayer().getZone(ZoneType.Graveyard),
NewConstants.Lang.GuiDisplay.HUMAN_FLASHBACK) {
private static final long serialVersionUID = 8120331222693706164L;
@Override
protected Iterable<Card> getCardsAsIterable() {
return CardFactoryUtil.getExternalZoneActivationCards(AllZone.getHumanPlayer());
}
@Override
protected void doAction(final Card c) {
Singletons.getModel().getGameAction().playCard(c);
}
} .actionPerformed(null);
} else {
new ZoneAction(ControlField.this.player.getZone(ZoneType.Graveyard),
NewConstants.Lang.GuiDisplay.COMPUTER_FLASHBACK) {
private static final long serialVersionUID = 8120331222693706164L;
@Override
protected Iterable<Card> getCardsAsIterable() {
return CardFactoryUtil.getExternalZoneActivationCards(AllZone.getComputerPlayer());
}
@Override
protected void doAction(final Card c) {
Singletons.getModel().getGameAction().playCard(c);
}
} .actionPerformed(null);
}
}
};
// Library listener
madLibrary = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (!Constant.Runtime.DEV_MODE[0]) { return; }
if (!ControlField.this.player.isComputer()) {
new ZoneAction(ControlField.this.player.getZone(ZoneType.Library), HumanLibrary.BASE)
.actionPerformed(null);
} else {
new ZoneAction(ControlField.this.player.getZone(ZoneType.Library), ComputerLibrary.BASE)
.actionPerformed(null);
}
}
};
// Exiled adapter
madExiled = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) {
new ZoneAction(ControlField.this.player.getZone(ZoneType.Exile),
NewConstants.Lang.GuiDisplay.COMPUTER_EXILED).actionPerformed(null);
} else {
new ZoneAction(ControlField.this.player.getZone(ZoneType.Exile),
NewConstants.Lang.GuiDisplay.HUMAN_EXILED).actionPerformed(null);
}
}
};
// Graveyard adapter
madGraveyard = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) {
new ZoneAction(ControlField.this.player.getZone(ZoneType.Graveyard),
NewConstants.Lang.GuiDisplay.COMPUTER_GRAVEYARD).actionPerformed(null);
} else {
new ZoneAction(ControlField.this.player.getZone(ZoneType.Graveyard),
NewConstants.Lang.GuiDisplay.HUMAN_GRAVEYARD).actionPerformed(null);
}
}
};
// Avatar
madAvatar = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) {
Singletons.getControl().getControlMatch().getMessageControl()
.getInputControl().selectPlayer(AllZone.getComputerPlayer());
} else {
Singletons.getControl().getControlMatch().getMessageControl()
.getInputControl().selectPlayer(AllZone.getHumanPlayer());
}
}
};
// Battlefield card mouse over
mmlCardOver = new MouseMotionAdapter() {
@Override
public void mouseMoved(final MouseEvent me) {
final Card c = ControlField.this.view.getTabletop().getCardFromMouseOverPanel();
if (c != null) {
Singletons.getControl().getControlMatch().setCard(c);
}
}
};
// Battlefield card
madCardClick = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
// original version:
// final Card c = t.getDetailController().getCurrentCard();
// Roujin's bug fix version dated 2-12-2012
final Card c = ControlField.this.view.getTabletop().getCardFromMouseOverPanel();
final Input input = Singletons.getControl().getControlMatch().getMessageControl().getInputControl().getInput();
if (c != null && c.isInZone(ZoneType.Battlefield)) {
if (c.isTapped()
&& ((input instanceof InputPayManaCost) || (input instanceof InputPayManaCostAbility))) {
final forge.view.arcane.CardPanel cardPanel = ControlField.this.view.getTabletop().getCardPanel(
c.getUniqueNumber());
for (final forge.view.arcane.CardPanel cp : cardPanel.getAttachedPanels()) {
if (cp.getCard().isUntapped()) {
break;
}
}
}
final CardList att = AllZone.getCombat().getAttackerList();
if ((c.isTapped() || c.hasSickness() || ((c.hasKeyword("Vigilance")) && att.contains(c)))
&& (input instanceof InputAttack)) {
final forge.view.arcane.CardPanel cardPanel = ControlField.this.view.getTabletop().getCardPanel(
c.getUniqueNumber());
for (final forge.view.arcane.CardPanel cp : cardPanel.getAttachedPanels()) {
if (cp.getCard().isUntapped() && !cp.getCard().hasSickness()) {
break;
}
}
}
if (e.isMetaDown()) {
if (att.contains(c) && (input instanceof InputAttack)
&& !c.hasKeyword("CARDNAME attacks each turn if able.")) {
c.untap();
AllZone.getCombat().removeFromCombat(c);
} else if (input instanceof InputBlock) {
if (c.getController().isHuman()) {
AllZone.getCombat().removeFromCombat(c);
}
((InputBlock) input).removeFromAllBlocking(c);
}
} else {
//Yosei, the Morning Star required cards to be chosen on computer side
//earlier it was enforced that cards must be in player zone
//this can potentially break some other functionality
//(tapping lands works ok but some custom cards may not...)
if (c.getController() != null) {
Singletons.getControl().getControlMatch().getMessageControl()
.getInputControl().selectCard(c,
c.getController().getZone(ZoneType.Battlefield));
} else {
//in weird case card has no controller revert to default behaviour
Singletons.getControl().getControlMatch().getMessageControl()
.getInputControl().selectCard(c,
AllZone.getHumanPlayer().getZone(ZoneType.Battlefield));
}
}
}
}
};
madBlack = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.BLACK);
}
}
}
};
madBlue = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.BLUE);
}
}
}
};
madGreen = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.GREEN);
}
}
}
};
madRed = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.RED);
}
}
}
};
madWhite = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.WHITE);
}
}
}
};
madColorless = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.COLORLESS);
}
}
}
};
} // End initMouseAdapters()
} // End class ControlField

View File

@@ -1,281 +0,0 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.control.match;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JLayeredPane;
import javax.swing.SwingUtilities;
import forge.AllZone;
import forge.Card;
import forge.Singletons;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.view.arcane.CardPanel;
import forge.view.arcane.HandArea;
import forge.view.arcane.util.Animation;
import forge.view.match.ViewHand;
/**
* Child controller - handles operations related to cards in user's hand and
* their Swing components, which are assembled in ViewHand.
*
*/
public class ControlHand {
private final List<Card> cardsInPanel;
private final ViewHand view;
private final MouseListener madCardClick;
private final MouseMotionListener madCardMove;
/** The o1. */
private Observer o1;
/**
* Child controller - handles operations related to cards in user's hand and
* their Swing components, which are assembled in ViewHand.
*
* @param v
* &emsp; The Swing component for user hand
*/
public ControlHand(final ViewHand v) {
this.view = v;
this.cardsInPanel = new ArrayList<Card>();
madCardClick = new MouseAdapter() {
// Card click
@Override
public void mousePressed(final MouseEvent e) {
if (e.getButton() != MouseEvent.BUTTON1) {
return;
}
final Card c = view.getHandArea().getCardFromMouseOverPanel();
if (c != null) {
Singletons.getControl().getControlMatch().getMessageControl().getInputControl().selectCard(c, AllZone.getHumanPlayer().getZone(ZoneType.Hand));
Singletons.getView().getViewMatch().getBtnOK().requestFocusInWindow();
}
}
};
madCardMove = new MouseMotionAdapter() {
// Card mouseover
@Override
public void mouseMoved(final MouseEvent me) {
final Card c = view.getHandArea().getCardFromMouseOverPanel();
if (c != null) {
Singletons.getControl().getControlMatch().setCard(c);
}
}
};
o1 = new Observer() {
@Override
public void update(final Observable a, final Object b) {
final PlayerZone pZone = (PlayerZone) a;
final HandArea p = view.getHandArea();
final Rectangle rctLibraryLabel = Singletons.getControl()
.getControlMatch().getFieldControls().get(1)
.getView().getLblLibrary().getBounds();
final List<Card> c = pZone.getCards();
// Animation starts from the library label.
// This check prevents animation running if label hasn't been realised yet.
if (rctLibraryLabel.isEmpty()) {
return;
}
List<Card> tmp, diff;
tmp = new ArrayList<Card>();
for (final forge.view.arcane.CardPanel cpa : p.getCardPanels()) {
tmp.add(cpa.getGameCard());
}
diff = new ArrayList<Card>(tmp);
diff.removeAll(c);
if (diff.size() == p.getCardPanels().size()) {
p.clear();
} else {
for (final Card card : diff) {
p.removeCardPanel(p.getCardPanel(card.getUniqueNumber()));
}
}
diff = new ArrayList<Card>(c);
diff.removeAll(tmp);
JLayeredPane layeredPane = Singletons.getView().getFrame().getLayeredPane();
int fromZoneX = 0, fromZoneY = 0;
final Point zoneLocation = SwingUtilities.convertPoint(Singletons
.getControl().getControlMatch().getFieldControls()
.get(1).getView().getLblLibrary(),
Math.round(rctLibraryLabel.width / 2.0f), Math.round(rctLibraryLabel.height / 2.0f), layeredPane);
fromZoneX = zoneLocation.x;
fromZoneY = zoneLocation.y;
int startWidth, startX, startY;
startWidth = 10;
startX = fromZoneX - Math.round(startWidth / 2.0f);
startY = fromZoneY - Math.round(Math.round(startWidth * forge.view.arcane.CardPanel.ASPECT_RATIO) / 2.0f);
int endWidth, endX, endY;
forge.view.arcane.CardPanel toPanel = null;
for (final Card card : diff) {
toPanel = p.addCard(card);
endWidth = toPanel.getCardWidth();
final Point toPos = SwingUtilities.convertPoint(view.getHandArea(),
toPanel.getCardLocation(), layeredPane);
endX = toPos.x;
endY = toPos.y;
final forge.view.arcane.CardPanel animationPanel = new forge.view.arcane.CardPanel(card);
if (Singletons.getView().getFrame().isShowing()) {
Animation.moveCard(startX, startY, startWidth, endX, endY, endWidth, animationPanel, toPanel,
layeredPane, 500);
} else {
Animation.moveCard(toPanel);
}
}
}
};
addObservers();
addListeners();
}
/** Adds observers to hand panel. */
public void addObservers() {
AllZone.getHumanPlayer().getZone(ZoneType.Hand).addObserver(o1);
}
/** Adds listeners to hand panel: clicks, mouseover, etc. */
public void addListeners() {
view.getHandArea().removeMouseListener(madCardClick);
view.getHandArea().addMouseListener(madCardClick);
view.getHandArea().removeMouseMotionListener(madCardMove);
view.getHandArea().addMouseMotionListener(madCardMove);
}
/**
* Adds various listeners for cards in hand. Uses CardPanel instance from
* ViewHand.
*
* @param c
* &emsp; CardPanel object
*/
public void addCardPanelListeners(final CardPanel c) {
// Grab top level controller to facilitate interaction between children
final Card cardobj = c.getCard();
// Sidebar pic/detail on card hover
c.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(final MouseEvent e) {
Singletons.getControl().getControlMatch().getDetailControl().showCard(cardobj);
Singletons.getControl().getControlMatch().getPictureControl().showCard(cardobj);
}
});
// Mouse press
c.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (e.getButton() != MouseEvent.BUTTON1) {
return;
}
Singletons.getControl().getControlMatch().getMessageControl().getInputControl()
.selectCard(cardobj, AllZone.getHumanPlayer().getZone(ZoneType.Hand));
}
});
}
/**
* Adds the card.
*
* @param c
* &emsp; Card object
*/
public void addCard(final Card c) {
this.cardsInPanel.add(c);
//this.view.refreshLayout();
}
/**
* Adds the cards.
*
* @param c
* &emsp; List of Card objects
*/
public void addCards(final List<Card> c) {
this.cardsInPanel.addAll(c);
//this.view.refreshLayout();
}
/**
* Gets the cards.
*
* @return List<Card>
*/
public List<Card> getCards() {
return this.cardsInPanel;
}
/**
* Removes the card.
*
* @param c
* &emsp; Card object
*/
public void removeCard(final Card c) {
this.cardsInPanel.remove(c);
//this.view.refreshLayout();
}
/**
* Removes the cards.
*
* @param c
* &emsp; List of Card objects
*/
public void removeCards(final List<Card> c) {
this.cardsInPanel.removeAll(c);
//this.view.refreshLayout();
}
/**
* Reset cards.
*
* @param c
* &emsp; List of Card objects
*/
public void resetCards(final List<Card> c) {
this.cardsInPanel.clear();
this.addCards(c);
}
}

View File

@@ -1,136 +0,0 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.control.match;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import forge.Constant;
import forge.Singletons;
import forge.gui.GuiInput;
import forge.view.match.ViewMessage;
/**
* Child controller - handles operations related to message panel.
*
*/
public class ControlMessage {
private final ViewMessage view;
private final GuiInput inputControl;
private final ActionListener actCancel, actOK;
/**
* Child controller - handles operations related to input panel.
*
* @param v
* &emsp; The Swing component for the input area
*/
public ControlMessage(final ViewMessage v) {
this.view = v;
this.inputControl = new GuiInput();
this.actOK = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent evt) {
ControlMessage.this.btnOKActionPerformed(evt);
if (Singletons.getModel().getGameState().getPhaseHandler().isNeedToNextPhase()) {
// moves to next turn
Singletons.getModel().getGameState().getPhaseHandler().setNeedToNextPhase(false);
Singletons.getModel().getGameState().getPhaseHandler().nextPhase();
}
ControlMessage.this.view.getBtnOK().requestFocusInWindow();
}
};
this.actCancel = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent evt) {
ControlMessage.this.btnCancelActionPerformed(evt);
ControlMessage.this.view.getBtnOK().requestFocusInWindow();
}
};
addListeners();
}
/** Adds listeners to input area. */
public void addListeners() {
this.view.getBtnCancel().removeActionListener(actCancel);
this.view.getBtnCancel().addActionListener(actCancel);
this.view.getBtnOK().removeActionListener(actOK);
this.view.getBtnOK().addActionListener(actOK);
}
/**
* <p>
* btnCancelActionPerformed.
* </p>
* 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) {
this.inputControl.selectButtonCancel();
}
/**
* <p>
* btnOKActionPerformed.
* </p>
* 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) {
this.inputControl.selectButtonOK();
}
/**
* Gets the input control.
*
* @return GuiInput
*/
public GuiInput getInputControl() {
return this.inputControl;
}
/** @param s0 &emsp; {@link java.lang.String} */
public void setMessage(String s0) {
view.getTarMessage().setText(s0);
}
/** Updates count label in input area. */
public void updateGameCount() {
view.getLblGames().setText("<html>Game #"
+ (Singletons.getModel().getMatchState().getGamesPlayedCount() + 1)
+ " of " + Singletons.getModel().getMatchState().getGamesPerMatch()
+ "<br>" + Constant.Runtime.getGameType().toString() + " mode</html>");
}
/** Flashes animation on input panel if play is currently waiting on input. */
public void remind() {
view.remind();
}
}

View File

@@ -1,226 +0,0 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.control.match;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Observable;
import java.util.Observer;
import forge.AllZone;
import forge.MyObservable;
import forge.Singletons;
import forge.gui.GuiDisplayUtil;
import forge.properties.ForgePreferences.FPref;
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 final ViewTabber view;
private final MouseListener madMilling, madUnlimited, madAddAnyCard,
madMana, madSetup, madTutor, madCounter, madTap, madUntap, madLife;
private Observer obsStack, obsLog;
/** */
public static final int STACK_PANEL = 0;
/** */
public static final int COMBAT_PANEL = 1;
/** */
public static final int LOG_PANEL = 2;
/** */
public static final int PLAYERS_PANEL = 3;
/** */
public static final int DEV_PANEL = 4;
/**
* Controls the vertical tabber in sidebar used for viewing gameplay data:
* stack, combat, etc.
*
* @param v
* &emsp; The tabber Swing component
*/
public ControlTabber(final ViewTabber v) {
this.view = v;
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.DEV_MILLING_LOSS)) {
this.view.getLblMilling().setEnabled(true);
} else {
this.view.getLblMilling().setEnabled(false);
}
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.DEV_UNLIMITED_LAND)) {
this.view.getLblUnlimitedLands().setEnabled(true);
} else {
this.view.getLblUnlimitedLands().setEnabled(false);
}
// Observers and listeners
obsStack = new Observer() { @Override
public void update(final Observable a, final Object b) {
ControlTabber.this.view.updateStack(); } };
obsLog = new Observer() { @Override
public void update(final Observable a, final Object b) {
ControlTabber.this.view.updateConsole(); } };
madMilling = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
ControlTabber.this.view.getLblMilling().toggleEnabled(); } };
madUnlimited = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
ControlTabber.this.view.getLblUnlimitedLands().toggleEnabled(); } };
madMana = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeGenerateMana(); } };
madSetup = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devSetupGameState(); } };
madTutor = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeTutor(); } };
madAddAnyCard = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeAddAnyCard(); } };
madCounter = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeAddCounter(); } };
madTap = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeTapPerm(); } };
madUntap = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeUntapPerm(); } };
madLife = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeSetLife(); } };
addListeners();
addObservers();
}
/** Adds observers to tabber. */
public void addObservers() {
AllZone.getStack().addObserver(obsStack);
AllZone.getGameLog().addObserver(obsLog);
}
/** Adds listeners to various components in tabber. */
public void addListeners() {
// Milling enable toggle
this.view.getLblMilling().removeMouseListener(madMilling);
this.view.getLblMilling().addMouseListener(madMilling);
// DevMode: Play unlimited land this turn toggle
this.view.getLblUnlimitedLands().removeMouseListener(madUnlimited);
this.view.getLblUnlimitedLands().addMouseListener(madUnlimited);
// DevMode: Generate mana
this.view.getLblGenerateMana().removeMouseListener(madMana);
this.view.getLblGenerateMana().addMouseListener(madMana);
// DevMode: Battlefield setup
this.view.getLblSetupGame().removeMouseListener(madSetup);
this.view.getLblSetupGame().addMouseListener(madSetup);
// DevMode: Tutor for card
this.view.getLblTutor().removeMouseListener(madTutor);
this.view.getLblTutor().addMouseListener(madTutor);
this.view.getAnyCard().removeMouseListener(madAddAnyCard);
this.view.getAnyCard().addMouseListener(madAddAnyCard);
// DevMode: Add counter to permanent
this.view.getLblCounterPermanent().removeMouseListener(madCounter);
this.view.getLblCounterPermanent().addMouseListener(madCounter);
// DevMode: Tap permanent
this.view.getLblTapPermanent().removeMouseListener(madTap);
this.view.getLblTapPermanent().addMouseListener(madTap);
// DevMode: Untap permanent
this.view.getLblUntapPermanent().removeMouseListener(madUntap);
this.view.getLblUntapPermanent().addMouseListener(madUntap);
// DevMode: Set life
this.view.getLblSetLife().removeMouseListener(madLife);
this.view.getLblSetLife().addMouseListener(madLife);
}
/**
* Gets the view.
*
* @return ViewTabber
*/
public ViewTabber getView() {
return this.view;
}
/**
* Programatically forces card layout of sidebar tabber to show "Dev" panel.
*/
public void showPnlDev() {
this.view.getVtpTabber().showTab(DEV_PANEL);
}
/**
* Programatically forces card layout of sidebar tabber to show "Players"
* panel.
*/
public void showPnlPlayers() {
this.view.getVtpTabber().showTab(PLAYERS_PANEL);
}
/**
* Programatically forces card layout of sidebar tabber to show "Log"
* panel.
*/
public void showPnlGameLog() {
this.view.getVtpTabber().showTab(LOG_PANEL);
}
/**
* Programatically forces card layout of sidebar tabber to show "Combat"
* panel.
*/
public void showPnlCombat() {
this.view.getVtpTabber().showTab(COMBAT_PANEL);
}
/**
* Programatically forces card layout of sidebar tabber to show "Stack"
* panel.
*/
public void showPnlStack() {
this.view.getVtpTabber().showTab(STACK_PANEL);
}
}

View File

@@ -1,3 +0,0 @@
/** Child controllers used in match UI. */
package forge.control.match;

View File

@@ -20,15 +20,20 @@ import forge.card.trigger.TriggerType;
import forge.control.FControl;
import forge.control.input.InputMulligan;
import forge.deck.Deck;
import forge.game.phase.PhaseHandler;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.gui.match.VMatchUI;
import forge.gui.match.controllers.CMessage;
import forge.gui.match.nonsingleton.VField;
import forge.gui.match.views.VAntes;
import forge.gui.toolbox.FLabel;
import forge.item.CardPrinted;
import forge.properties.ForgePreferences.FPref;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.Lang.GameAction.GameActionText;
import forge.util.MyRandom;
import forge.view.match.ViewField;
/**
* Methods for all things related to starting a new game.
@@ -40,24 +45,24 @@ public class GameNew {
* immediately, and life totals to be adjusted, for computer and human.
*
* @param humanDeck
* &emsp; {@link forge.deck.Deck} object.
* &emsp; {@link forge.deck.Deck} object.
* @param computerDeck
* &emsp; {@link forge.deck.Deck} object.
* &emsp; {@link forge.deck.Deck} object.
* @param human
* &emsp; {@link forge.CardList} object.
* &emsp; {@link forge.CardList} object.
* @param computer
* &emsp; {@link forge.CardList} object.
* &emsp; {@link forge.CardList} object.
* @param humanLife
* &emsp; int.
* &emsp; int.
* @param computerLife
* &emsp; int.
* &emsp; int.
* @param iconEnemy
* &emsp; String.
* &emsp; {@link java.lang.String}
*/
public static void newGame(final Deck humanDeck, final Deck computerDeck, final CardList human,
final CardList computer, final int humanLife, final int computerLife, String iconEnemy) {
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
Singletons.getControl().getControlMatch().initMatch(iconEnemy);
CMatchUI.SINGLETON_INSTANCE.initMatch(iconEnemy);
GameNew.newGameCleanup();
GameNew.newMatchCleanup();
@@ -89,7 +94,7 @@ public class GameNew {
*/
public static void newGame(final Deck humanDeck, final Deck computerDeck) {
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
Singletons.getControl().getControlMatch().initMatch(null);
CMatchUI.SINGLETON_INSTANCE.initMatch(null);
GameNew.newGameCleanup();
GameNew.newMatchCleanup();
@@ -111,7 +116,7 @@ public class GameNew {
forge.card.trigger.Trigger.resetIDs();
AllZone.getTriggerHandler().clearTriggerSettings();
AllZone.getTriggerHandler().clearDelayedTrigger();
Singletons.getControl().getControlMatch().getMessageControl().updateGameCount();
CMessage.SINGLETON_INSTANCE.updateGameCount();
// friendliness
Card.resetUniqueNumber();
@@ -270,6 +275,7 @@ public class GameNew {
throw new RuntimeException(p + " library is empty.");
}
AllZone.getGameLog().add("Ante", p + " anted " + ante, 0);
VAntes.SINGLETON_INSTANCE.setAnteCard(p, ante);
Singletons.getModel().getGameAction().moveTo(ZoneType.Ante, ante);
msg.append(p.getName()).append(" ante: ").append(ante).append(nl);
}
@@ -281,10 +287,10 @@ public class GameNew {
AllZone.getComputerPlayer().drawCard();
}
Singletons.getControl().getControlMatch().setCard(AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand).get(0));
CMatchUI.SINGLETON_INSTANCE.setCard(AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand).get(0));
AllZone.getInputControl().setInput(new InputMulligan());
// PhaseHandler.setGameBegins(1); // is this needed? It's already in InputMulligan...
PhaseHandler.setGameBegins(1); // is this needed? It's already in InputMulligan...
AllZone.getGameLog().add("Turn",
"Turn " + Singletons.getModel().getGameState().getPhaseHandler().getTurn()
@@ -323,26 +329,28 @@ public class GameNew {
// Update mouse events in case of dev mode toggle
if (Constant.Runtime.DEV_MODE[0]) {
Singletons.getView().getViewMatch()
.getViewTabber().getVtpTabber().getAllVTabs().get(4).setVisible(true);
final List<ViewField> allFields = Singletons.getView().getViewMatch().getFieldViews();
// TODO restore this functionality!!!
//VMatchUI.SINGLETON_INSTANCE.getViewDevMode().getDocument().setVisible(true);
final List<VField> allFields = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
for (final ViewField field : allFields) {
for (final VField field : allFields) {
((FLabel) field.getLblHand()).setHoverable(true);
((FLabel) field.getLblLibrary()).setHoverable(true);
}
}
else {
Singletons.getView().getViewMatch()
.getViewTabber().getVtpTabber().getAllVTabs().get(4).setVisible(false);
final List<ViewField> allFields = Singletons.getView().getViewMatch().getFieldViews();
// TODO restore this functionality!!!
//VMatchUI.SINGLETON_INSTANCE.getViewDevMode().getDocument().setVisible(false);
final List<VField> allFields = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
for (final ViewField field : allFields) {
for (final VField field : allFields) {
((FLabel) field.getLblHand()).setHoverable(false);
((FLabel) field.getLblLibrary()).setHoverable(false);
}
}
VAntes.SINGLETON_INSTANCE.setAnteCard(AllZone.getComputerPlayer(), null);
VAntes.SINGLETON_INSTANCE.setAnteCard(AllZone.getHumanPlayer(), null);
AllZone.getInputControl().resetInput();
Singletons.getModel().getMatchState().reset();
Singletons.getModel().loadPrefs();

View File

@@ -39,6 +39,7 @@ import forge.Singletons;
import forge.card.trigger.TriggerType;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
/**
* <p>
@@ -729,7 +730,7 @@ public class Combat {
this.addDefendingDamage(damageDealt, attacker);
} else {
if (attacker.hasKeyword("Trample") || (block.size() > 1)) {
Singletons.getControl().getControlMatch().assignDamage(attacker, block, damageDealt);
CMatchUI.SINGLETON_INSTANCE.assignDamage(attacker, block, damageDealt);
} else {
block.get(0).addAssignedDamage(damageDealt, attacking.get(i));
}
@@ -782,7 +783,7 @@ public class Combat {
this.addDefendingDamage(damageDealt, attacker);
} else {
if (attacker.hasKeyword("Trample") || (block.size() > 1)) {
Singletons.getControl().getControlMatch().assignDamage(attacker, block, damageDealt);
CMatchUI.SINGLETON_INSTANCE.assignDamage(attacker, block, damageDealt);
} else {
block.get(0).addAssignedDamage(damageDealt, attacking.get(i));
}

View File

@@ -52,6 +52,9 @@ import forge.game.player.PlayerUtil;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.framework.EDocID;
import forge.gui.framework.SDisplayUtil;
import forge.gui.match.views.VCombat;
/**
* <p>
@@ -2431,8 +2434,6 @@ public class CombatUtil {
* </p>
*/
public static void showCombat() {
Singletons.getControl().getControlMatch().showCombat("");
Card[] defend = null;
final StringBuilder display = new StringBuilder();
@@ -2471,8 +2472,9 @@ public class CombatUtil {
}
} // loop through attackers
}
Singletons.getControl().getControlMatch().showCombat(display.toString().trim());
SDisplayUtil.showTab(EDocID.REPORT_COMBAT.getDoc());
VCombat.SINGLETON_INSTANCE.updateCombat(display.toString().trim());
} // showBlockers()
/**

View File

@@ -34,6 +34,8 @@ import forge.Singletons;
import forge.card.trigger.TriggerType;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.framework.EDocID;
import forge.gui.framework.SDisplayUtil;
import forge.properties.ForgePreferences.FPref;
/**
@@ -321,7 +323,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
switch(phase) {
case UNTAP:
Singletons.getControl().getControlMatch().showStack();
SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
PhaseUtil.handleUntap();
break;
@@ -406,12 +408,12 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
AllZone.getEndOfCombat().executeUntil();
AllZone.getEndOfCombat().executeAt();
CombatUtil.showCombat();
Singletons.getControl().getControlMatch().showStack();
SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
break;
case MAIN2:
CombatUtil.showCombat();
Singletons.getControl().getControlMatch().showStack();
SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
break;
case END_OF_TURN:
@@ -526,7 +528,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
}
if (this.getPhase() == PhaseType.COMBAT_END) {
Singletons.getControl().getControlMatch().showStack();
SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
AllZone.getCombat().reset();
this.resetAttackedThisCombat(this.getPlayerTurn());
this.bCombat = false;

View File

@@ -26,11 +26,10 @@ import forge.CardList;
import forge.CardListFilter;
import forge.Singletons;
import forge.card.trigger.TriggerType;
import forge.control.ControlMatchUI;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.view.match.ViewField.PhaseLabel;
import forge.gui.match.CMatchUI;
import forge.gui.match.nonsingleton.VField.PhaseLabel;
/**
* <p>
@@ -386,13 +385,12 @@ public class PhaseUtil {
public static void visuallyActivatePhase(final PhaseType s) {
PhaseLabel lbl = null;
final Player p = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
final ControlMatchUI t = Singletons.getControl().getControlMatch();
final CMatchUI t = CMatchUI.SINGLETON_INSTANCE;
// Index of field; computer is 0, human is 1
int i = p.isComputer() ? 0 : 1;
switch(s) {
case UPKEEP:
lbl = t.getFieldControls().get(i).getView().getLblUpkeep();
break;
@@ -434,7 +432,6 @@ public class PhaseUtil {
}
t.resetAllPhaseButtons();
Singletons.getView().getViewMatch().repaint();
lbl.setActive(true);
}
}

View File

@@ -33,6 +33,7 @@ import forge.control.input.Input;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -208,7 +209,7 @@ public class Untap extends Phase implements java.io.Serializable {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage("Select one tapped land to untap");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select one tapped land to untap");
ButtonUtil.enableOnlyCancel();
}
@@ -256,7 +257,7 @@ public class Untap extends Phase implements java.io.Serializable {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage("Select one tapped artifact to untap");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select one tapped artifact to untap");
ButtonUtil.enableOnlyCancel();
}
@@ -305,7 +306,7 @@ public class Untap extends Phase implements java.io.Serializable {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage("Select one creature to untap");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select one creature to untap");
ButtonUtil.enableOnlyCancel();
}

View File

@@ -44,6 +44,7 @@ import forge.game.player.PlayerUtil;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -495,9 +496,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override
public void showMessage() {
Singletons
.getControl()
.getControlMatch()
CMatchUI.SINGLETON_INSTANCE
.showMessage(
abyss.getName() + " - Select one nonartifact creature to destroy");
ButtonUtil.disableAll();
@@ -566,9 +565,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override
public void showMessage() {
Singletons
.getControl()
.getControlMatch()
CMatchUI.SINGLETON_INSTANCE
.showMessage(
"Yawgmoth Demon - Select one artifact to sacrifice or be dealt 2 damage");
ButtonUtil.enableOnlyCancel();
@@ -2285,7 +2282,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch()
CMatchUI.SINGLETON_INSTANCE
.showMessage(c.getName() + " - Select target creature.");
ButtonUtil.enableOnlyCancel();
}
@@ -2359,9 +2356,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
this.stop();
return;
}
Singletons
.getControl()
.getControlMatch()
CMatchUI.SINGLETON_INSTANCE
.showMessage(
source.getName()
+ " - Select "

View File

@@ -26,6 +26,7 @@ import forge.card.spellability.SpellAbility;
import forge.control.input.Input;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
/**
* <p>
@@ -250,7 +251,7 @@ public class HumanPlayer extends Player {
protected final void clashMoveToTopOrBottom(final Card c) {
String choice = "";
final String[] choices = { "top", "bottom" };
Singletons.getControl().getControlMatch().setCard(c);
CMatchUI.SINGLETON_INSTANCE.setCard(c);
choice = GuiUtils.chooseOne(c.getName() + " - Top or bottom of Library", choices);
if (choice.equals("bottom")) {

View File

@@ -51,6 +51,7 @@ import forge.game.zone.PlayerZone;
import forge.game.zone.PlayerZoneComesIntoPlay;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
import forge.gui.match.VMatchUI;
import forge.util.MyRandom;
/**
@@ -1854,7 +1855,7 @@ public abstract class Player extends GameEntity {
* @return a boolean.
*/
public final boolean canPlayLand() {
if (Singletons.getView().getViewMatch().getViewTabber().getLblUnlimitedLands().getEnabled() && this.isHuman()
if (VMatchUI.SINGLETON_INSTANCE.getViewDevMode().getLblUnlimitedLands().getEnabled() && this.isHuman()
&& Constant.Runtime.DEV_MODE[0]) {
return PhaseHandler.canCastSorcery(this);
}

View File

@@ -26,6 +26,7 @@ import forge.card.spellability.SpellAbility;
import forge.control.input.Input;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -91,7 +92,7 @@ public final class PlayerUtil {
if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0) {
this.stop();
}
Singletons.getControl().getControlMatch().showMessage(
CMatchUI.SINGLETON_INSTANCE.showMessage(
"Select " + (nCards - this.n) + " cards to discard, unless you discard a " + uType + ".");
ButtonUtil.disableAll();
}
@@ -151,7 +152,7 @@ public final class PlayerUtil {
this.stop();
}
Singletons.getControl().getControlMatch().showMessage("Select a card to discard");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select a card to discard");
ButtonUtil.disableAll();
}
@@ -190,7 +191,7 @@ public final class PlayerUtil {
this.stop();
}
Singletons.getControl().getControlMatch().showMessage("Chains of Mephistopheles:\n" + "Select a card to discard");
CMatchUI.SINGLETON_INSTANCE.showMessage("Chains of Mephistopheles:\n" + "Select a card to discard");
ButtonUtil.disableAll();
}
@@ -288,7 +289,7 @@ public final class PlayerUtil {
return;
}
Singletons.getControl().getControlMatch().showMessage(message + " (" + (nCards - this.n) + " left)");
CMatchUI.SINGLETON_INSTANCE.showMessage(message + " (" + (nCards - this.n) + " left)");
ButtonUtil.disableAll();
}
@@ -331,7 +332,7 @@ public final class PlayerUtil {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage("Select a card to put on the " + topOrBottom + " of your library.");
CMatchUI.SINGLETON_INSTANCE.showMessage("Select a card to put on the " + topOrBottom + " of your library.");
ButtonUtil.disableAll();
if ((this.n == num) || (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0)) {

View File

@@ -57,6 +57,7 @@ import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.gui.GuiDisplayUtil;
import forge.gui.GuiUtils;
import forge.gui.match.CMatchUI;
import forge.view.ButtonUtil;
/**
@@ -761,7 +762,7 @@ public class MagicStack extends MyObservable {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage("Mana Vortex - select a land to sacrifice");
CMatchUI.SINGLETON_INSTANCE.showMessage("Mana Vortex - select a land to sacrifice");
ButtonUtil.enableOnlyCancel();
}
@@ -953,7 +954,7 @@ public class MagicStack extends MyObservable {
@Override
public void showMessage() {
Singletons.getControl().getControlMatch().showMessage("Choose target creature to haunt.");
CMatchUI.SINGLETON_INSTANCE.showMessage("Choose target creature to haunt.");
ButtonUtil.disableAll();
}
@@ -967,7 +968,7 @@ public class MagicStack extends MyObservable {
MagicStack.this.add(haunterDiesWork);
this.stop();
} else {
Singletons.getControl().getControlMatch().showMessage("Cannot target this card (Shroud? Protection?).");
CMatchUI.SINGLETON_INSTANCE.showMessage("Cannot target this card (Shroud? Protection?).");
}
}
};

View File

@@ -327,7 +327,7 @@ public final class GuiDisplayUtil {
public static void updateGUI() {
AllZone.getComputerPlayer().getZone(ZoneType.Battlefield).updateObservers();
AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers();
//AllZone.getHumanPlayer().getZone(Zone.Hand).updateObservers();
//AllZone.getHumanPlayer().getZone(ZoneType.Hand).updateObservers();
AllZone.getComputerPlayer().updateObservers();
AllZone.getHumanPlayer().updateObservers();
}

View File

@@ -133,11 +133,7 @@ public class GuiInput extends MyObservable implements Observer {
return this.getInput().toString();
}
/**
* Gets the input.
*
* @return the input
*/
/** @return {@link forge.gui.GuiInput.Input} */
public Input getInput() {
return this.input;
}

View File

@@ -32,8 +32,8 @@ import javax.swing.SwingConstants;
import forge.AllZone;
import forge.Card;
import forge.CardList;
import forge.Singletons;
import forge.error.ErrorViewer;
import forge.gui.match.CMatchUI;
/**
* <p>Constructor for Gui_MultipleBlockers4.</p>
@@ -241,7 +241,7 @@ public class GuiMultipleBlockers extends JFrame {
final CardContainer cardPanel = (CardContainer) o;
final Card c = cardPanel.getCard();
Singletons.getControl().getControlMatch().setCard(c);
CMatchUI.SINGLETON_INSTANCE.setCard(c);
}
}
}

View File

@@ -39,7 +39,7 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import forge.Card;
import forge.Singletons;
import forge.gui.match.CMatchUI;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
@@ -343,7 +343,7 @@ public final class GuiUtils {
@Override
public void valueChanged(final ListSelectionEvent ev) {
if (list.getSelectedValue() instanceof Card) {
Singletons.getControl().getControlMatch().setCard((Card) list.getSelectedValue());
CMatchUI.SINGLETON_INSTANCE.setCard((Card) list.getSelectedValue());
}
}
});

View File

@@ -1,6 +1,5 @@
package forge.gui.layout;
package forge.gui.framework;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
@@ -17,6 +16,7 @@ import javax.swing.JPanel;
import javax.swing.SwingConstants;
import net.miginfocom.swing.MigLayout;
import forge.gui.toolbox.FPanel;
import forge.gui.toolbox.FSkin;
/**
@@ -26,7 +26,7 @@ import forge.gui.toolbox.FSkin;
* for resizing.
*/
@SuppressWarnings("serial")
final class DragCell extends JPanel implements ILocalRepaint {
public final class DragCell extends JPanel implements ILocalRepaint {
// Layout creation worker vars
private double roughX = 0;
private double roughY = 0;
@@ -38,9 +38,8 @@ final class DragCell extends JPanel implements ILocalRepaint {
private int smoothH = 0;
// Core layout stuff
private final CardLayout cards = new CardLayout();
private final JPanel pnlHead = new JPanel(new MigLayout("insets 0, gap 0, hidemode 3"));
private final JPanel pnlBody = new JPanel(cards);
private final JPanel pnlBody = new FPanel();
private final JPanel pnlBorderRight = new JPanel();
private final JPanel pnlBorderBottom = new JPanel();
private final int tabPaddingPx = 2;
@@ -58,18 +57,19 @@ final class DragCell extends JPanel implements ILocalRepaint {
public DragCell() {
super(new MigLayout("insets 0, gap 0, wrap 2"));
this.add(pnlHead, "w 100% - " + FViewNew.BORDER_T + "px!, "
+ "h " + FViewNew.HEAD_H + "px!");
this.add(pnlBorderRight, "w " + FViewNew.BORDER_T + "px!, "
+ "h 100% - " + FViewNew.BORDER_T + "px!, span 1 2");
this.add(pnlBody, "w 100% - " + FViewNew.BORDER_T + "px!, "
+ "h 100% - " + (FViewNew.HEAD_H + FViewNew.BORDER_T) + "px!");
this.add(pnlBorderBottom, "w 100% - " + FViewNew.BORDER_T + "px!, "
+ "h " + FViewNew.BORDER_T + "px!");
this.add(pnlHead, "w 100% - " + SLayoutConstants.BORDER_T + "px!, "
+ "h " + SLayoutConstants.HEAD_H + "px!");
this.add(pnlBorderRight, "w " + SLayoutConstants.BORDER_T + "px!, "
+ "h 100% - " + SLayoutConstants.BORDER_T + "px!, span 1 2");
this.add(pnlBody, "w 100% - " + SLayoutConstants.BORDER_T + "px!, "
+ "h 100% - " + (SLayoutConstants.HEAD_H + SLayoutConstants.BORDER_T) + "px!");
this.add(pnlBorderBottom, "w 100% - " + SLayoutConstants.BORDER_T + "px!, "
+ "h " + SLayoutConstants.BORDER_T + "px!");
this.setOpaque(false);
pnlHead.setOpaque(false);
this.setBackground(Color.black);
pnlHead.setBackground(Color.DARK_GRAY);
pnlBody.setBackground(Color.LIGHT_GRAY);
lblOverflow.setForeground(Color.white);
lblOverflow.setHorizontalAlignment(SwingConstants.CENTER);
@@ -117,7 +117,7 @@ final class DragCell extends JPanel implements ILocalRepaint {
/**
* Returns a defensive copy list of all documents in this cell.
* @return {@link java.util.List}<{@link forge.gui.layout.IVDoc}>
* @return {@link java.util.List}<{@link forge.gui.framework.IVDoc}>
*/
public List<IVDoc> getDocs() {
final List<IVDoc> clone = new ArrayList<IVDoc>();
@@ -237,11 +237,11 @@ final class DragCell extends JPanel implements ILocalRepaint {
this.smoothH = h0;
}
/** Adds a document to the layout and tabs.
* @param doc0 &emsp; {@link forge.gui.layout.IVDoc} */
/** Adds a document to the tabs.
* @param doc0 &emsp; {@link forge.gui.framework.IVDoc} */
public void addDoc(final IVDoc doc0) {
pnlBody.add(doc0.getDocumentID().toString(), doc0.getDocument());
allDocs.add(doc0);
doc0.setParentCell(this);
pnlHead.add(doc0.getTabLabel(), "h 100%!, gap " + tabPaddingPx + "px " + tabPaddingPx + "px 0 0", allDocs.size() - 1);
// Ensure that a tab is selected
@@ -249,44 +249,52 @@ final class DragCell extends JPanel implements ILocalRepaint {
}
/** Removes a document from the layout and tabs.
* @param doc0 &emsp; {@link forge.gui.layout.IVDoc} */
* @param doc0 &emsp; {@link forge.gui.framework.IVDoc} */
public void removeDoc(final IVDoc doc0) {
pnlBody.remove(doc0.getDocument());
allDocs.remove(doc0);
pnlHead.remove(doc0.getTabLabel());
}
/** Deselects previous selection, if exists, and then
* selects a tab in the title bar. <br><br><b>null</b> will reset
/** - Deselects previous selection, if there is one<br>
* - Decrements the priorities of all other tabs<br>
* - Sets selected as priority 1<br>
*
* <br><b>null</b> will reset
* (deselect all tabs, and then select the first in the group).
*
* <br><br>Unless there are no tab docs in this cell, there
* will always be a selection.
*
* @param doc0 &emsp; {@link forge.gui.layout.IVDoc} tab document.
* @param doc0 &emsp; {@link forge.gui.framework.IVDoc} tab document.
*/
public void setSelected(final IVDoc doc0) {
docSelected = null;
pnlBody.removeAll();
// Priorities are used to "remember" tab selection history.
for (final IVDoc t : allDocs) {
if (t.equals(doc0)) {
for (final IVDoc doc : allDocs) {
if (doc.equals(doc0)) {
docSelected = doc0;
t.getTabLabel().priorityOne();
docSelected.getTabLabel().setSelected(true);
cards.show(pnlBody, docSelected.getDocumentID().toString());
doc.getTabLabel().priorityOne();
doc.getTabLabel().setSelected(true);
doc.populate();
doc.getControl().update();
}
else {
t.getTabLabel().setSelected(false);
t.getTabLabel().priorityDecrease();
doc.getTabLabel().setSelected(false);
doc.getTabLabel().priorityDecrease();
}
}
pnlBody.revalidate();
pnlBody.repaint();
// Reached the end without a selection? Select the first in the group.
if (docSelected == null && allDocs.size() > 0) { setSelected(allDocs.get(0)); }
}
/** Returns currently selected document in this cell.
* @return {@link forge.gui.layout.IVDoc} */
* @return {@link forge.gui.framework.IVDoc} */
public IVDoc getSelected() {
return docSelected;
}

View File

@@ -1,12 +1,13 @@
package forge.gui.layout;
package forge.gui.framework;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JLabel;
import javax.swing.border.EmptyBorder;
import forge.gui.toolbox.FSkin;
/**
* The tab label object in drag layout.
* No modification should be necessary to this object.
@@ -68,15 +69,15 @@ public final class DragTab extends JLabel implements ILocalRepaint {
@Override
public void paintComponent(final Graphics g) {
if (!selected) {
g.setColor(Color.white);
g.setColor(FSkin.getColor(FSkin.Colors.CLR_BORDERS));
g.fillRoundRect(0, 0, getWidth() - 1, getHeight() * 2, 6, 6);
g.setColor(Color.LIGHT_GRAY);
g.setColor(FSkin.getColor(FSkin.Colors.CLR_INACTIVE));
g.drawRoundRect(0, 0, getWidth() - 1, getHeight() * 2, 6, 6);
}
else {
g.setColor(Color.orange);
g.setColor(FSkin.getColor(FSkin.Colors.CLR_ACTIVE));
g.fillRoundRect(0, 0, getWidth() - 1, getHeight() * 2, 6, 6);
g.setColor(Color.red);
g.setColor(FSkin.getColor(FSkin.Colors.CLR_BORDERS));
g.drawRoundRect(0, 0, getWidth() - 1, getHeight() * 2, 6, 6);
}

View File

@@ -1,13 +1,12 @@
/**
*
*/
package forge.gui.layout;
package forge.gui.framework;
import forge.gui.match.nonsingleton.VField;
import forge.gui.match.nonsingleton.VHand;
import forge.gui.match.views.VAntes;
import forge.gui.match.views.VCombat;
import forge.gui.match.views.VDetail;
import forge.gui.match.views.VDev;
import forge.gui.match.views.VDock;
import forge.gui.match.views.VLog;
import forge.gui.match.views.VMessage;
@@ -15,10 +14,8 @@ import forge.gui.match.views.VPicture;
import forge.gui.match.views.VPlayers;
import forge.gui.match.views.VStack;
/**
* These are the identifiers for tabs found in the Drag3 layout.
* These are the identifiers for tabs found in the drag layout.
* These IDs are used in the save XML and card layouts.
*
* <br><br><i>(E at beginning of class name denotes an enum.)</i>
@@ -34,17 +31,17 @@ public enum EDocID { /** */
REPORT_LOG (VLog.SINGLETON_INSTANCE), /** */
REPORT_PLAYERS (VPlayers.SINGLETON_INSTANCE), /** */
// Current user's panels
YOUR_HAND (VHand.SINGLETON_INSTANCE), /** */
YOUR_BATTLEFIELD (VField.SINGLETON_INSTANCE), /** */
YOUR_DOCK (VDock.SINGLETON_INSTANCE), /** */
DEV_MODE (VDev.SINGLETON_INSTANCE), /** */
BUTTON_DOCK (VDock.SINGLETON_INSTANCE), /** */
// Non-user battlefields (AI or teammate), use setDoc to activate.
BATTLEFIELD_1 (null), /** */
BATTLEFIELD_2 (null), /** */
BATTLEFIELD_3 (null), /** */
// Non-user battlefields (AI or teammate), use setDoc to register.
FIELD_0 (null), /** */
FIELD_1 (null), /** */
FIELD_2 (null), /** */
FIELD_3 (null), /** */
// Non-user hands (AI or teammate), use setDoc to activate.
// Non-user hands (AI or teammate), use setDoc to register.
HAND_0 (null), /** */
HAND_1 (null), /** */
HAND_2 (null), /** */
HAND_3 (null); /** */
@@ -52,23 +49,19 @@ public enum EDocID { /** */
// End enum declarations, start enum methods.
private IVDoc vDoc;
/** @param doc0 &emsp; {@link forge.gui.layout.IVDoc} */
/** @param doc0 &emsp; {@link forge.gui.framework.IVDoc} */
EDocID(final IVDoc doc0) {
this.vDoc = doc0;
}
/** @return {@link forge.gui.layout.IVDoc} */
public IVDoc getDoc() {
return vDoc;
/** @param doc0 &emsp; {@link forge.gui.framework.IVDoc} */
public void setDoc(final IVDoc doc0) {
this.vDoc = doc0;
}
/**
* Register non-singleton tab instances using this method.
*
* @param id0 &emsp; {@link forge.gui.layout.EDocID}
* @param doc0 &emsp; {@link forge.gui.layout.IVDoc}
*/
public void setDoc(EDocID id0, IVDoc doc0) {
id0.vDoc = doc0;
/** @return {@link forge.gui.framework.IVDoc} */
public IVDoc getDoc() {
if (vDoc == null) { throw new NullPointerException("No document found!"); }
return vDoc;
}
}

View File

@@ -1,10 +1,10 @@
package forge.gui.layout;
package forge.gui.framework;
import forge.Command;
/**
* Dictates methods required for any controller
* of an {@link forge.gui.layout.IVDoc}.
* of an {@link forge.gui.framework.IVDoc}.
*
* <br><br><i>(I at beginning of class name denotes an interface.)</i>
* <br><i>(C at beginning of class name denotes a controller class.)</i>
@@ -14,14 +14,17 @@ public interface ICDoc {
* Fires when this controller's view tab is selected.
* Since this method is fired when all tabs are first
* initialized, be wary of NPEs created by referring to
* non-existing components.
* non-existent components.
*
* @return {@link forge.Command} */
Command getCommandOnSelect();
/**
* Call this method after the view singleton has been fully realized
* for the first time. This method should ideally only be called once.
* for the first time. It should execute operations which should only
* be done once, but require non-null view components.<br><br>
*
* This method should only be called once, in FView, after singletons are populated.
*/
void initialize();

View File

@@ -1,7 +1,7 @@
/**
*
*/
package forge.gui.layout;
package forge.gui.framework;
/**
* This interface provides a unifying type to all enums

View File

@@ -1,4 +1,4 @@
package forge.gui.layout;
package forge.gui.framework;
/**
* This interface requires a repaintThis() method, which

View File

@@ -0,0 +1,62 @@
package forge.gui.framework;
/**
* This interface provides a unifying type to any component
* (usually JPanels or JScrollPanes) which could be used as
* a tab. A single one of these components is referred to as
* a "document" throughout the codebase. The tabs and their
* documents are contained in "cells" for resizing and dragging.
*
* <br><br><i>(I at beginning of class name denotes an interface.)</i>
* <br><i>(V at beginning of class name denotes a view class.)</i>
*/
public interface IVDoc {
/**
* Returns the ID used to identify this tab in save XML and card layouts.
*
* @return {@link forge.gui.framework.EDocID}
*/
EDocID getDocumentID();
/**
* Returns tab label object used in title bars.
*
* @return {@link forge.gui.framework.DragTab}
*/
DragTab getTabLabel();
/** Retrieves control object associated with this document.
* @return {@link forge.gui.home.ICSubmenu}
*/
ICDoc getControl();
/** Sets the current parent cell of this view,
* allowing access to its body and head sections.
*
* @param cell0 &emsp; {@link forge.gui.framework.DragCell}
*/
void setParentCell(DragCell cell0);
/**
* Gets parent cell for this view.
*
* @return {@link forge.gui.framework.DragCell}
*/
DragCell getParentCell();
/**
* Targets the drag cell body (use <code>parentCell.getBody()</code>).
* Populates panel components, independent of constructor.
* Expected to provide a completely fresh layout to the body panel.
* <br><br>
* Styling and adding of lower-level components for this view
* should happen once, in constructor. This method is
* only for removing / adding top-level components.
* <br><br>
* The body panel will be empty when this method is called.
* However, its layout may need to be redefined as required.
*/
void populate();
}

View File

@@ -0,0 +1,23 @@
package forge.gui.framework;
/**
* This interface provides a unifying type for all top-level
* UI components.
*
* <br><br><i>(I at beginning of class name denotes an interface.)</i>
* <br><i>(V at beginning of class name denotes a view class.)</i>
*
*/
public interface IVTopLevelUI {
/** Called during the preload sequence, this method caches
* all of the children singletons and instances. */
void instantiate();
/**
* Removes all children and (re)populates top level content,
* independent of constructor. Expected to provide
* a completely fresh layout on the component.
*
*/
void populate();
}

View File

@@ -0,0 +1,87 @@
package forge.gui.framework;
import java.awt.Color;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
/**
* Experimental static factory for generic operations carried out
* onto specific members of the framework. Doublestrike 11-04-12
*
* <br><br><i>(S at beginning of class name denotes a static factory.)</i>
*/
public class SDisplayUtil {
private static boolean remindIsRunning = false;
private static int counter = 0;
private static int[] newA = null, newR = null, newG = null, newB = null;
private static Timer timer1 = null;
/** Flashes animation on input panel if play is currently waiting on input.
*
* @param tab0 &emsp; {@link java.gui.framework.IVDoc}
*/
public static void remind(final IVDoc tab0) {
showTab(tab0);
final JPanel pnl = tab0.getParentCell().getBody();
// To adjust, only touch these two values.
final int steps = 5; // Number of delays
final int delay = 80; // Milliseconds between steps
if (remindIsRunning) { return; }
if (pnl.equals(null)) { return; }
remindIsRunning = true;
final int oldR = pnl.getBackground().getRed();
final int oldG = pnl.getBackground().getGreen();
final int oldB = pnl.getBackground().getBlue();
final int oldA = pnl.getBackground().getAlpha();
counter = 0;
newR = new int[steps];
newG = new int[steps];
newB = new int[steps];
newA = new int[steps];
for (int i = 0; i < steps; i++) {
newR[i] = (int) ((255 - oldR) / steps * i);
newG[i] = (int) (oldG / steps * i);
newB[i] = (int) (oldB / steps * i);
newA[i] = (int) ((255 - oldA) / steps * i);
}
final TimerTask tt = new TimerTask() {
@Override
public void run() {
counter++;
if (counter != (steps - 1)) {
SwingUtilities.invokeLater(new Runnable() { @Override
public void run() {
pnl.setBackground(new Color(newR[counter], oldG, oldB, newA[counter]));
}
});
}
else {
SwingUtilities.invokeLater(new Runnable() { @Override
public void run() { pnl.setBackground(new Color(oldR, oldG, oldB, oldA)); } });
remindIsRunning = false;
timer1.cancel();
newR = null;
newG = null;
newB = null;
newA = null;
}
}
};
timer1 = new Timer();
timer1.scheduleAtFixedRate(tt, 0, delay);
}
/** @param tab0 &emsp; {@link java.gui.framework.IVDoc} */
public static void showTab(final IVDoc tab0) {
tab0.getParentCell().setSelected(tab0);
}
}

View File

@@ -0,0 +1,173 @@
package forge.gui.framework;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Iterator;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import forge.view.FView;
/** Package-private class for handling layout saving and loading. */
public final class SIOUtil {
/** Each cell must save these elements of its display. */
private enum Property {
x,
y,
w,
h,
doc
};
private static final String FILE_DEFAULT = "res/layouts/match_default.xml";
private static final String FILE_PREFERRED = "res/layouts/match_preferred.xml";
private static final XMLEventFactory EF = XMLEventFactory.newInstance();
private static final XMLEvent NEWLINE = EF.createDTD("\n");
private static final XMLEvent TAB = EF.createDTD("\t");
/** Publicly-accessible save method, to neatly handle exception handling. */
public static void saveLayout() {
if (SwingUtilities.isEventDispatchThread()) {
throw new IllegalThreadStateException("This operation should be independent of the EDT.");
}
try { save(); }
catch (final Exception e) { e.printStackTrace(); }
}
/** Publicly-accessible load method, to neatly handle exception handling. */
public static void loadLayout() {
if (SwingUtilities.isEventDispatchThread()) {
throw new IllegalThreadStateException("This operation should be independent of the EDT.");
}
try { load(); }
catch (final Exception e) { e.printStackTrace(); }
}
private static void save() throws Exception {
final XMLOutputFactory out = XMLOutputFactory.newInstance();
final XMLEventWriter writer = out.createXMLEventWriter(new FileOutputStream(FILE_PREFERRED));
final List<DragCell> cells = FView.SINGLETON_INSTANCE.getDragCells();
final JPanel pnl = FView.SINGLETON_INSTANCE.getPnlContent();
double x0, y0, w0, h0;
writer.add(EF.createStartDocument());
writer.add(NEWLINE);
writer.add(EF.createStartElement("", "", "layout"));
writer.add(NEWLINE);
for (final DragCell cell : cells) {
x0 = ((double) Math.round(((double) cell.getX() / (double) pnl.getWidth()) * 1000)) / 1000;
y0 = ((double) Math.round(((double) cell.getY() / (double) pnl.getHeight()) * 1000)) / 1000;
w0 = ((double) Math.round(((double) cell.getW() / (double) pnl.getWidth()) * 1000)) / 1000;
h0 = ((double) Math.round(((double) cell.getH() / (double) pnl.getHeight()) * 1000)) / 1000;
//cell.setRoughBounds(x, y, w, h);
writer.add(TAB);
writer.add(EF.createStartElement("", "", "cell"));
writer.add(EF.createAttribute(Property.x.toString(), String.valueOf(x0)));
writer.add(EF.createAttribute(Property.y.toString(), String.valueOf(y0)));
writer.add(EF.createAttribute(Property.w.toString(), String.valueOf(w0)));
writer.add(EF.createAttribute(Property.h.toString(), String.valueOf(h0)));
writer.add(NEWLINE);
for (final IVDoc vDoc : cell.getDocs()) {
createNode(writer, Property.doc, vDoc.getDocumentID().toString());
}
writer.add(TAB);
writer.add(EF.createEndElement("", "", "cell"));
writer.add(NEWLINE);
}
writer.add(EF.createEndDocument());
writer.flush();
writer.close();
}
private static void load() throws Exception {
final FView view = FView.SINGLETON_INSTANCE;
final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
final XMLEventReader reader;
if (new File(FILE_PREFERRED).exists()) {
reader = inputFactory.createXMLEventReader(new FileInputStream(FILE_PREFERRED));
}
else {
reader = inputFactory.createXMLEventReader(new FileInputStream(FILE_DEFAULT));
}
view.removeAllDragCells();
XMLEvent event;
StartElement element;
Iterator<?> attributes;
Attribute attribute;
DragCell cell = null;
double x0 = 0, y0 = 0, w0 = 0, h0 = 0;
while (reader.hasNext()) {
event = reader.nextEvent();
if (event.isStartElement()) {
//&& event.asStartElement().getName().getLocalPart().equals("cell")) {
element = event.asStartElement();
if (element.getName().getLocalPart().equals("cell")) {
attributes = element.getAttributes();
while (attributes.hasNext()) {
attribute = (Attribute) attributes.next();
if (attribute.getName().toString().equals(Property.x.toString())) {
x0 = Double.valueOf(attribute.getValue());
}
else if (attribute.getName().toString().equals(Property.y.toString())) {
y0 = Double.valueOf(attribute.getValue());
}
else if (attribute.getName().toString().equals(Property.w.toString())) {
w0 = Double.valueOf(attribute.getValue());
}
else if (attribute.getName().toString().equals(Property.h.toString())) {
h0 = Double.valueOf(attribute.getValue());
}
}
cell = new DragCell();
cell.setRoughBounds(x0, y0, w0, h0);
FView.SINGLETON_INSTANCE.addDragCell(cell);
}
else if (element.getName().getLocalPart().equals("doc")) {
event = reader.nextEvent();
cell.addDoc(EDocID.valueOf(event.asCharacters().getData()).getDoc());
}
}
}
// Rough bounds are all in place; resize the window.
SResizingUtil.resizeWindow();
}
private static void createNode(final XMLEventWriter writer0, final Property name0,
final String val0) throws XMLStreamException {
writer0.add(TAB);
writer0.add(TAB);
writer0.add(EF.createStartElement("", "", name0.toString()));
writer0.add(EF.createCharacters(val0));
writer0.add(EF.createEndElement("", "", name0.toString()));
writer0.add(NEWLINE);
}
}

View File

@@ -0,0 +1,14 @@
package forge.gui.framework;
/**
* Holds static constants used throughout layout.
*
* <br><br><i>(S at beginning of class name denotes a static factory.)</i>
*/
public class SLayoutConstants {
/** Height of head area in drag panel. */
public static final int HEAD_H = 20;
/** Thickness of resize border in drag panel. */
public static final int BORDER_T = 5;
}

View File

@@ -1,4 +1,4 @@
package forge.gui.layout;
package forge.gui.framework;
import java.awt.Color;
import java.awt.Dimension;
@@ -9,19 +9,21 @@ import java.awt.event.MouseListener;
import javax.swing.JLabel;
import javax.swing.JPanel;
import forge.view.FView;
/**
* Package-private utilities for generic overflow behavior
* in title bar for any cell in layout.
*
* <br><br><i>(S at beginning of class name denotes a static factory.)</i>
*/
final class SOverflowUtil {
public final class SOverflowUtil {
private static final MouseListener MAD_OVERFLOW_SELECT = new MouseAdapter() {
@Override
public void mouseReleased(final MouseEvent e) {
final JLabel src = ((JLabel) e.getSource());
final DragCell pnlParent = ((DragCell) src.getParent().getParent());
final JPanel pnlOverflow = FViewNew.SINGLETON_INSTANCE.getPnlTabOverflow();
final JPanel pnlOverflow = FView.SINGLETON_INSTANCE.getPnlTabOverflow();
final String constraints = "w 150px!, h 20px!, gap 5px 5px 2px 2px";
final int w = 160;
int h = 0;
@@ -36,11 +38,11 @@ final class SOverflowUtil {
pnlOverflow.revalidate();
pnlOverflow.setVisible(true);
int x = src.getParent().getParent().getX() + src.getX() + FViewNew.BORDER_T;
final int y = src.getParent().getParent().getY() + src.getY() + FViewNew.BORDER_T + src.getHeight() + 3;
int x = src.getParent().getParent().getX() + src.getX() + SLayoutConstants.BORDER_T;
final int y = src.getParent().getParent().getY() + src.getY() + SLayoutConstants.BORDER_T + src.getHeight() + 3;
// If overflow will appear offscreen, offset.
if (x + w > FViewNew.SINGLETON_INSTANCE.getPnlContent().getWidth()) {
if (x + w > FView.SINGLETON_INSTANCE.getPnlContent().getWidth()) {
x += src.getWidth() - w;
}
@@ -64,7 +66,7 @@ final class SOverflowUtil {
private static final MouseListener MAD_HIDE_OVERFLOW = new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
final JPanel pnl = FViewNew.SINGLETON_INSTANCE.getPnlTabOverflow();
final JPanel pnl = FView.SINGLETON_INSTANCE.getPnlTabOverflow();
if (pnl != null) {
pnl.setVisible(pnl.isVisible() ? false : true);
}
@@ -103,7 +105,7 @@ final class SOverflowUtil {
@Override
public void mousePressed(final MouseEvent e) {
FViewNew.SINGLETON_INSTANCE.getPnlTabOverflow().setVisible(false);
FView.SINGLETON_INSTANCE.getPnlTabOverflow().setVisible(false);
parent0.setSelected(tab0);
parent0.refresh();
}

View File

@@ -1,4 +1,4 @@
package forge.gui.layout;
package forge.gui.framework;
import java.awt.Container;
import java.awt.Cursor;
@@ -16,14 +16,15 @@ import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import forge.gui.toolbox.FSkin;
import forge.view.FView;
/**
* Package-private utilities for rearranging drag behavior using
* the draggable panels registered in FViewNew.
* the draggable panels registered in FView.
*
* <br><br><i>(S at beginning of class name denotes a static factory.)</i>
*/
final class SRearrangingUtil {
public final class SRearrangingUtil {
private enum Dropzone {
BODY,
@@ -42,8 +43,8 @@ final class SRearrangingUtil {
private static int tempW;
private static int tempH;
private static JPanel pnlPreview = FViewNew.SINGLETON_INSTANCE.getPnlPreview();
private static JLayeredPane pnlDocument = FViewNew.SINGLETON_INSTANCE.getLpnDocument();
private static JPanel pnlPreview = FView.SINGLETON_INSTANCE.getPnlPreview();
private static JLayeredPane pnlDocument = FView.SINGLETON_INSTANCE.getLpnDocument();
private static DragCell cellTarget = null;
private static DragCell cellSrc = null;
private static DragCell cellNew = null;
@@ -134,7 +135,7 @@ final class SRearrangingUtil {
evtY = (int) e.getLocationOnScreen().getY();
// Find out over which panel the event occurred.
for (final DragCell t : FViewNew.SINGLETON_INSTANCE.getDragCells()) {
for (final DragCell t : FView.SINGLETON_INSTANCE.getDragCells()) {
tempX = t.getAbsX();
tempY = t.getAbsY();
tempW = t.getW();
@@ -154,10 +155,10 @@ final class SRearrangingUtil {
dropzone = Dropzone.LEFT;
pnlDocument.setCursor(CUR_L);
pnlPreview.setBounds(
cellTarget.getX() + FViewNew.BORDER_T,
cellTarget.getY() + FViewNew.BORDER_T,
(int) ((tempW - FViewNew.BORDER_T) / 2),
tempH - FViewNew.BORDER_T
cellTarget.getX() + SLayoutConstants.BORDER_T,
cellTarget.getY() + SLayoutConstants.BORDER_T,
(int) ((tempW - SLayoutConstants.BORDER_T) / 2),
tempH - SLayoutConstants.BORDER_T
);
}
@@ -169,20 +170,20 @@ final class SRearrangingUtil {
pnlPreview.setBounds(
cellTarget.getX() + cellTarget.getW() - tempW,
cellTarget.getY() + FViewNew.BORDER_T,
cellTarget.getY() + SLayoutConstants.BORDER_T,
tempW,
tempH - FViewNew.BORDER_T
tempH - SLayoutConstants.BORDER_T
);
}
else if (evtY < (tempY + nestingMargin + FViewNew.HEAD_H) && evtY > tempY + FViewNew.HEAD_H
else if (evtY < (tempY + nestingMargin + SLayoutConstants.HEAD_H) && evtY > tempY + SLayoutConstants.HEAD_H
&& (cellTarget.getH() / 2) > SResizingUtil.H_MIN) {
dropzone = Dropzone.TOP;
pnlDocument.setCursor(CUR_T);
pnlPreview.setBounds(
cellTarget.getX() + FViewNew.BORDER_T,
cellTarget.getY() + FViewNew.BORDER_T,
tempW - FViewNew.BORDER_T,
cellTarget.getX() + SLayoutConstants.BORDER_T,
cellTarget.getY() + SLayoutConstants.BORDER_T,
tempW - SLayoutConstants.BORDER_T,
(int) (tempH / 2)
);
}
@@ -193,9 +194,9 @@ final class SRearrangingUtil {
tempH = (int) Math.round(cellTarget.getH() / 2);
pnlPreview.setBounds(
cellTarget.getX() + FViewNew.BORDER_T,
cellTarget.getX() + SLayoutConstants.BORDER_T,
cellTarget.getY() + cellTarget.getH() - tempH,
tempW - FViewNew.BORDER_T,
tempW - SLayoutConstants.BORDER_T,
tempH
);
}
@@ -209,10 +210,10 @@ final class SRearrangingUtil {
pnlDocument.setCursor(CUR_TAB);
pnlPreview.setBounds(
cellTarget.getX() + FViewNew.BORDER_T,
cellTarget.getY() + FViewNew.BORDER_T,
tempW - FViewNew.BORDER_T,
tempH - FViewNew.BORDER_T
cellTarget.getX() + SLayoutConstants.BORDER_T,
cellTarget.getY() + SLayoutConstants.BORDER_T,
tempW - SLayoutConstants.BORDER_T,
tempH - SLayoutConstants.BORDER_T
);
}
}
@@ -247,7 +248,7 @@ final class SRearrangingUtil {
cellTarget.setBounds(
tempX + cellNew.getW(), tempY,
tempW - cellNew.getW(), tempH);
FViewNew.SINGLETON_INSTANCE.addDragCell(cellNew);
FView.SINGLETON_INSTANCE.addDragCell(cellNew);
break;
case RIGHT:
cellTarget.setBounds(
@@ -256,7 +257,7 @@ final class SRearrangingUtil {
cellNew.setBounds(
cellTarget.getX() + cellTarget.getW(), tempY ,
tempW - cellTarget.getW(), tempH);
FViewNew.SINGLETON_INSTANCE.addDragCell(cellNew);
FView.SINGLETON_INSTANCE.addDragCell(cellNew);
break;
case TOP:
cellNew.setBounds(
@@ -265,7 +266,7 @@ final class SRearrangingUtil {
cellTarget.setBounds(
tempX, tempY + cellNew.getH(),
tempW, tempH - cellNew.getH());
FViewNew.SINGLETON_INSTANCE.addDragCell(cellNew);
FView.SINGLETON_INSTANCE.addDragCell(cellNew);
break;
case BOTTOM:
cellTarget.setBounds(
@@ -275,7 +276,7 @@ final class SRearrangingUtil {
cellNew.setBounds(
tempX, cellTarget.getY() + cellTarget.getH(),
tempW, tempH - cellTarget.getH());
FViewNew.SINGLETON_INSTANCE.addDragCell(cellNew);
FView.SINGLETON_INSTANCE.addDragCell(cellNew);
break;
case BODY:
cellNew = cellTarget;
@@ -292,7 +293,7 @@ final class SRearrangingUtil {
// Remove old cell if necessary
if (cellSrc.getDocs().size() == 0) {
fillGap();
FViewNew.SINGLETON_INSTANCE.removeDragCell(cellSrc);
FView.SINGLETON_INSTANCE.removeDragCell(cellSrc);
}
cellSrc.setSelected(srcSelectedDoc);
@@ -301,7 +302,10 @@ final class SRearrangingUtil {
cellNew.validate();
cellNew.refresh();
updateBorders();
SIOUtil.saveLayout();
final Thread t = new Thread() { @Override
public void run() { SIOUtil.saveLayout(); } };
t.start();
}
/** The gap created by displaced panels must be filled.
@@ -324,7 +328,7 @@ final class SRearrangingUtil {
foundT = false;
foundB = false;
// Look for matching panels to left of source, expand them to the right.
for (final DragCell cell : FViewNew.SINGLETON_INSTANCE.getDragCells()) {
for (final DragCell cell : FView.SINGLETON_INSTANCE.getDragCells()) {
if (cell.getAbsX2() != srcX) { continue; }
if (cell.getAbsY() == srcY) {
@@ -349,7 +353,7 @@ final class SRearrangingUtil {
foundT = false;
foundB = false;
// Look for matching panels to right of source, expand them to the left.
for (final DragCell cell : FViewNew.SINGLETON_INSTANCE.getDragCells()) {
for (final DragCell cell : FView.SINGLETON_INSTANCE.getDragCells()) {
if (cell.getAbsX() != srcX2) { continue; }
if (cell.getAbsY() == srcY) {
@@ -374,7 +378,7 @@ final class SRearrangingUtil {
foundL = false;
foundR = false;
// Look for matching panels below source, expand them upwards.
for (final DragCell cell : FViewNew.SINGLETON_INSTANCE.getDragCells()) {
for (final DragCell cell : FView.SINGLETON_INSTANCE.getDragCells()) {
if (cell.getAbsY() != srcY2) { continue; }
if (cell.getAbsX() == srcX) {
@@ -399,7 +403,7 @@ final class SRearrangingUtil {
foundL = false;
foundR = false;
// Look for matching panels above source, expand them downwards.
for (final DragCell cell : FViewNew.SINGLETON_INSTANCE.getDragCells()) {
for (final DragCell cell : FView.SINGLETON_INSTANCE.getDragCells()) {
if (cell.getAbsY2() != srcY) { continue; }
if (cell.getAbsX() == srcX) {
@@ -426,8 +430,8 @@ final class SRearrangingUtil {
/** Hides outer borders for components on edges,
* preventing illegal resizing (and misleading cursor). */
public static void updateBorders() {
final List<DragCell> cells = FViewNew.SINGLETON_INSTANCE.getDragCells();
final JPanel pnlContent = FViewNew.SINGLETON_INSTANCE.getPnlContent();
final List<DragCell> cells = FView.SINGLETON_INSTANCE.getDragCells();
final JPanel pnlContent = FView.SINGLETON_INSTANCE.getPnlContent();
for (final DragCell t : cells) {
if (t.getAbsX2() == (pnlContent.getLocationOnScreen().getX() + pnlContent.getWidth())) {

View File

@@ -1,4 +1,4 @@
package forge.gui.layout;
package forge.gui.framework;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
@@ -13,15 +13,16 @@ import java.util.Iterator;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
import forge.view.FView;
/**
* Package-private utilities for resizing drag behavior using
* the draggable panels registered in FViewNew.
* the draggable panels registered in FView.
*
* <br><br><i>(S at beginning of class name denotes a static factory.)</i>
*/
final class SResizingUtil {
public final class SResizingUtil {
private static final List<DragCell> LEFT_PANELS = new ArrayList<DragCell>();
private static final List<DragCell> RIGHT_PANELS = new ArrayList<DragCell>();
private static final List<DragCell> TOP_PANELS = new ArrayList<DragCell>();
@@ -45,7 +46,7 @@ final class SResizingUtil {
@Override
public void mouseReleased(final MouseEvent e) {
SResizingUtil.endResizeX();
SResizingUtil.endResize();
}
};
@@ -57,7 +58,7 @@ final class SResizingUtil {
@Override
public void mouseReleased(final MouseEvent e) {
SResizingUtil.endResizeY();
SResizingUtil.endResize();
}
};
@@ -85,11 +86,11 @@ final class SResizingUtil {
/** */
public static void resizeWindow() {
final List<DragCell> cells = FViewNew.SINGLETON_INSTANCE.getDragCells();
final JPanel pnlContent = FViewNew.SINGLETON_INSTANCE.getPnlContent();
final JPanel pnlInsets = FViewNew.SINGLETON_INSTANCE.getPnlInsets();
final List<DragCell> cells = FView.SINGLETON_INSTANCE.getDragCells();
final JPanel pnlContent = FView.SINGLETON_INSTANCE.getPnlContent();
final JPanel pnlInsets = FView.SINGLETON_INSTANCE.getPnlInsets();
pnlInsets.setBounds(FViewNew.SINGLETON_INSTANCE.getFrame().getContentPane().getBounds());
pnlInsets.setBounds(FView.SINGLETON_INSTANCE.getFrame().getContentPane().getBounds());
pnlInsets.validate();
final int w = pnlContent.getWidth();
@@ -218,7 +219,7 @@ final class SResizingUtil {
// Add all panels who share a left or right edge with the
// same coordinate as the right edge of the source panel.
for (final DragCell t : FViewNew.SINGLETON_INSTANCE.getDragCells()) {
for (final DragCell t : FView.SINGLETON_INSTANCE.getDragCells()) {
tempX = t.getAbsX();
tempX2 = t.getAbsX2();
@@ -283,7 +284,7 @@ final class SResizingUtil {
// Add all panels who share a top or bottom edge with the
// same coordinate as the bottom edge of the source panel.
for (final DragCell t : FViewNew.SINGLETON_INSTANCE.getDragCells()) {
for (final DragCell t : FView.SINGLETON_INSTANCE.getDragCells()) {
tempY = t.getAbsY();
tempY2 = t.getAbsY2();
@@ -329,27 +330,10 @@ final class SResizingUtil {
}
/** */
public static void endResizeX() {
final SwingWorker<Object, Void> w = new SwingWorker<Object, Void>() {
@Override
public Object doInBackground() {
SIOUtil.saveLayout();
return null;
}
};
w.execute();
}
/** */
public static void endResizeY() {
final SwingWorker<Object, Void> w = new SwingWorker<Object, Void>() {
@Override
public Object doInBackground() {
SIOUtil.saveLayout();
return null;
}
};
w.execute();
public static void endResize() {
final Thread t = new Thread() { @Override
public void run() { SIOUtil.saveLayout(); } };
t.start();
}
/** @return {@link java.awt.event.MouseListener} */

View File

@@ -4,6 +4,8 @@ package forge.gui.home;
* Submenus each belong to a menu group, which
* is used for several functions, such as expanding
* and collapsing in the menu.
*
* <br><br><i>(E at beginning of class name denotes an enum.)</i>
*/
public enum EMenuGroup { /** */
SANCTIONED ("Sanctioned Game Formats"), /** */

View File

@@ -1,7 +1,9 @@
package forge.gui.home;
/**
* TODO: Write javadoc for this type.
* These are the identifiers for topics found in home screen submenus.
*
* <br><br><i>(E at beginning of class name denotes an enum.)</i>
*
*/
public enum EMenuItem { /** */

View File

@@ -2,12 +2,16 @@ package forge.gui.home;
import forge.Command;
/** Dictates methods required for a submenu controller. */
/**
* Dictates methods required for a submenu controller.
*
* <br><br><i>(I at beginning of class name denotes an interface.)</i>
* <br><i>(C at beginning of class name denotes a controller class.)</i>
*/
public interface ICSubmenu {
/** Fires when a menu is selected. Avoid any reference
* referring to ViewHomeUI in this method, because
* it is triggered when ViewHomeUI is initialized, which
* referring to VHomeUI in this method, because
* it is triggered when VHomeUI is initialized, which
* will create an NPE.
*
* @return {@link forge.Command} */

View File

@@ -2,7 +2,12 @@ package forge.gui.home;
import javax.swing.JPanel;
/** Dictates methods required for a submenu view. */
/**
* Dictates methods required for a submenu view.
*
* <br><br><i>(I at beginning of class name denotes an interface.)</i>
* <br><i>(V at beginning of class name denotes a view class.)</i>
*/
public interface IVSubmenu {
/** Allows static factory creation by decoupling UI components.
* @return {@link javax.swing.JPanel} */

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.view;
package forge.gui.home;
import java.awt.CardLayout;
import java.awt.Component;
@@ -32,6 +32,7 @@ import java.util.TreeMap;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
@@ -43,9 +44,7 @@ import net.miginfocom.swing.MigLayout;
import forge.AllZone;
import forge.Command;
import forge.Singletons;
import forge.gui.home.EMenuGroup;
import forge.gui.home.EMenuItem;
import forge.gui.home.IVSubmenu;
import forge.gui.framework.IVTopLevelUI;
import forge.gui.home.quest.VSubmenuChallenges;
import forge.gui.home.quest.VSubmenuDuels;
import forge.gui.home.quest.VSubmenuQuestData;
@@ -69,6 +68,7 @@ import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.quest.data.QuestPreferences.QPref;
import forge.quest.io.QuestDataIO;
import forge.view.FView;
/** Singleton instance of home screen UI.
* Use "getPanel()" to work with the main container.
@@ -79,9 +79,11 @@ import forge.quest.io.QuestDataIO;
* - Build a view implementing IVSubmenu<br>
* - Build a controller impelementing ICSubmenu<br>
* - Add its singleton instance to the map storing the views for the card layout.
*
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
*/
public enum ViewHomeUI {
public enum VHomeUI implements IVTopLevelUI {
/** */
SINGLETON_INSTANCE;
@@ -90,6 +92,9 @@ public enum ViewHomeUI {
private final FPanel pnlLeft = new FPanel();
private final FPanel pnlRight = new FPanel(cards);
private final JPanel pnlMenu = new JPanel();
private final FScrollPane scrMenu = new FScrollPane(pnlMenu,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
private final int insets = 10;
private final int leftWidthPx = 250;
@@ -97,20 +102,15 @@ public enum ViewHomeUI {
private final Map<EMenuItem, FLabel> allSubmenuLabels = new HashMap<EMenuItem, FLabel>();
private FLabel lblPreviousSelected;
/** Mostly, assembles child singletons for the home screen UI. */
public void initialize() {
// There's d a better home for this (model?)
@Override
public void instantiate() {
// There'd a better home for this (model?)
final File dirQuests = ForgeProps.getFile(NewConstants.Quest.DATA_DIR);
final String questname = Singletons.getModel().getQuestPreferences().getPreference(QPref.CURRENT_QUEST);
final File data = new File(dirQuests.getPath(), questname);
if (data.exists()) {
AllZone.getQuest().load(QuestDataIO.loadData(data));
} //////////////////////////////
if (data.exists()) { AllZone.getQuest().load(QuestDataIO.loadData(data)); }
// Add new menu items here (order doesn't matter).
allSubmenus.clear();
allSubmenus.add(VSubmenuConstructed.SINGLETON_INSTANCE);
allSubmenus.add(VSubmenuDraft.SINGLETON_INSTANCE);
allSubmenus.add(VSubmenuSealed.SINGLETON_INSTANCE);
@@ -133,13 +133,12 @@ public enum ViewHomeUI {
pnlParent.setBorderToggle(false);
pnlParent.setBackgroundTexture(FSkin.getIcon(FSkin.Backgrounds.BG_TEXTURE));
pnlParent.setLayout(null);
pnlParent.add(pnlLeft);
pnlParent.add(pnlRight);
pnlParent.add(pnlRight);
// Left pane holds scroller with menu panel.
final FScrollPane scrMenu = new FScrollPane(pnlMenu,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
pnlMenu.setLayout(new MigLayout("insets 0, gap 0, wrap, hidemode 3"));
pnlMenu.setOpaque(false);
scrMenu.setBorder(null);
pnlLeft.setLayout(new MigLayout("insets 0, gap 0, align center, wrap"));
@@ -148,8 +147,43 @@ public enum ViewHomeUI {
pnlLeft.add(scrMenu, "pushy, growy, w 98%!, gap 1% 0 1% 0");
populateMenu();
final Map<EMenuGroup, JLabel> allGroupLabels = new HashMap<EMenuGroup, JLabel>();
final String strTitleConstraints = "w 90%!, gap 5% 0 5px 10px";
final String strGroupConstraints = "w 85%!, gap 10% 0 0 0";
final String strItemConstraints = "w 100%!, h 26px!, gap 0 0 1px 1px";
// For each group: init its panel
final SortedMap<EMenuGroup, JPanel> allGroupPanels = new TreeMap<EMenuGroup, JPanel>();
for (final EMenuGroup e : EMenuGroup.values()) {
allGroupPanels.put(e, new JPanel());
allGroupPanels.get(e).setOpaque(false);
allGroupPanels.get(e).setVisible(false);
allGroupPanels.get(e).setLayout(new MigLayout("insets 0, gap 0, wrap"));
allGroupPanels.get(e).setName(e.toString());
}
// For each item: Add to its group, and add to the card layout in right panel.
for (final IVSubmenu item : allSubmenus) {
allSubmenuLabels.put(EMenuItem.valueOf(item.getItemEnum()), makeItemLabel(item));
pnlRight.add(item.getItemEnum(), item.getPanel());
allGroupPanels.get(item.getGroupEnum()).add(
allSubmenuLabels.get(EMenuItem.valueOf(item.getItemEnum())), strItemConstraints);
item.getControl().initialize();
}
// For each group: add its title, then its panel, then "click" if necessary.
for (final EMenuGroup e : allGroupPanels.keySet()) {
allGroupLabels.put(e, makeTitleLabel(e));
pnlMenu.add(allGroupLabels.get(e), strTitleConstraints);
pnlMenu.add(allGroupPanels.get(e), strGroupConstraints);
// Expand groups expanded from previous session
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.valueOf("SUBMENU_" + e.toString()))) {
groupClick(e, allGroupLabels.get(e));
}
}
// Select previous
EMenuItem selected = null;
try {
@@ -164,6 +198,7 @@ public enum ViewHomeUI {
itemClick(EMenuItem.CONSTRUCTED);
}
// TODO this shouldn't be here; should perhaps be an interface method in controller.
pnlParent.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(final ComponentEvent e) {
@@ -181,51 +216,9 @@ public enum ViewHomeUI {
});
}
/** Generates expand/collapse menu using cards in layout, and EMenuGroup enum.
* No further hardcoding should be required in this method. */
private void populateMenu() {
final SortedMap<EMenuGroup, JPanel> allGroupPanels = new TreeMap<EMenuGroup, JPanel>();
final Map<EMenuGroup, JLabel> allGroupLabels = new HashMap<EMenuGroup, JLabel>();
final ForgePreferences prefs = Singletons.getModel().getPreferences();
final String strTitleConstraints = "w 90%!, gap 5% 0 5px 10px";
final String strGroupConstraints = "w 85%!, gap 10% 0 0 0";
final String strItemConstraints = "w 100%!, h 26px!, gap 0 0 1px 1px";
pnlMenu.removeAll();
pnlMenu.setLayout(new MigLayout("insets 0, gap 0, wrap, hidemode 3"));
pnlMenu.setOpaque(false);
// For each group: init its panel
for (final EMenuGroup e : EMenuGroup.values()) {
allGroupPanels.put(e, new JPanel());
allGroupPanels.get(e).setOpaque(false);
allGroupPanels.get(e).setVisible(false);
allGroupPanels.get(e).setLayout(new MigLayout("insets 0, gap 0, wrap"));
allGroupPanels.get(e).setName(e.toString());
}
// For each item: Add to its group, and add to the card layout in right panel.
allSubmenuLabels.clear();
for (final IVSubmenu item : allSubmenus) {
allSubmenuLabels.put(EMenuItem.valueOf(item.getItemEnum()), makeItemLabel(item));
pnlRight.add(item.getItemEnum(), item.getPanel());
allGroupPanels.get(item.getGroupEnum()).add(
allSubmenuLabels.get(EMenuItem.valueOf(item.getItemEnum())), strItemConstraints);
item.getControl().initialize();
}
// For each group: add its title, then its panel, then "click" if necessary.
for (final EMenuGroup e : allGroupPanels.keySet()) {
allGroupLabels.put(e, makeTitleLabel(e));
pnlMenu.add(allGroupLabels.get(e), strTitleConstraints);
pnlMenu.add(allGroupPanels.get(e), strGroupConstraints);
// Expand groups expanded from previous session
if (prefs.getPrefBoolean(FPref.valueOf("SUBMENU_" + e.toString()))) {
groupClick(e, allGroupLabels.get(e));
}
}
@Override
public void populate() {
FView.SINGLETON_INSTANCE.getLpnDocument().add(pnlParent, JLayeredPane.DEFAULT_LAYER);
}
private void groupClick(final EMenuGroup e0, final JLabel lbl0) {

View File

@@ -12,13 +12,13 @@ import forge.AllZone;
import forge.Command;
import forge.gui.home.EMenuItem;
import forge.gui.home.ICSubmenu;
import forge.gui.home.VHomeUI;
import forge.gui.home.quest.SubmenuQuestUtil.SelectablePanel;
import forge.gui.toolbox.FLabel;
import forge.quest.QuestController;
import forge.quest.QuestEventChallenge;
import forge.quest.bazaar.QuestItemType;
import forge.quest.bazaar.QuestPetController;
import forge.view.ViewHomeUI;
/**
* TODO: Write javadoc for this type.
@@ -39,7 +39,7 @@ public enum CSubmenuChallenges implements ICSubmenu {
@Override
public void execute() {
if (qc.getAchievements() == null) {
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
VHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
}
}
};
@@ -80,7 +80,7 @@ public enum CSubmenuChallenges implements ICSubmenu {
view.getBtnCurrentDeck().setCommand(
new Command() { @Override
public void execute() {
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DECKS);
VHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DECKS);
}
});

View File

@@ -8,11 +8,11 @@ import forge.AllZone;
import forge.Command;
import forge.gui.home.EMenuItem;
import forge.gui.home.ICSubmenu;
import forge.gui.home.VHomeUI;
import forge.gui.home.quest.SubmenuQuestUtil.SelectablePanel;
import forge.quest.QuestController;
import forge.quest.QuestEventDuel;
import forge.quest.bazaar.QuestPetController;
import forge.view.ViewHomeUI;
/**
* TODO: Write javadoc for this type.
@@ -32,7 +32,7 @@ public enum CSubmenuDuels implements ICSubmenu {
return new Command() {
public void execute() {
if (qc.getAchievements() == null) {
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
VHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
}
}
};
@@ -63,7 +63,7 @@ public enum CSubmenuDuels implements ICSubmenu {
view.getBtnCurrentDeck().setCommand(
new Command() { @Override
public void execute() {
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DECKS);
VHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DECKS);
}
});

View File

@@ -10,9 +10,9 @@ import forge.gui.OverlayUtils;
import forge.gui.deckeditor.DeckEditorQuest;
import forge.gui.home.EMenuItem;
import forge.gui.home.ICSubmenu;
import forge.gui.home.VHomeUI;
import forge.quest.QuestController;
import forge.quest.data.QuestPreferences.QPref;
import forge.view.ViewHomeUI;
/**
* TODO: Write javadoc for this type.
@@ -57,7 +57,7 @@ public enum CSubmenuQuestDecks implements ICSubmenu {
@Override
public void execute() {
if (qc.getAchievements() == null) {
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
VHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
}
}
};

View File

@@ -1,181 +0,0 @@
package forge.gui.layout;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import net.miginfocom.swing.MigLayout;
import forge.Singletons;
/** */
public enum FViewNew {
/** */
SINGLETON_INSTANCE;
// Layout vars
private final JFrame frmDocument = new JFrame();
private final JPanel pnlContent = new JPanel();
private final JPanel pnlInsets = new JPanel(new BorderLayout());
private final JPanel pnlPreview = new PreviewPanel();
private final JPanel pnlTabOverflow = new JPanel(new MigLayout("insets 0, gap 0, wrap"));
private final JLayeredPane lpnDocument = new JLayeredPane();
private static final List<DragCell> CELLS = new ArrayList<DragCell>();
/** Height of head area in drag panel. */
public static final int HEAD_H = 20;
/** Thickness of resize border in drag panel. */
public static final int BORDER_T = 5;
private FViewNew() {
frmDocument.setMinimumSize(new Dimension(800, 600));
frmDocument.setLocationRelativeTo(null);
frmDocument.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmDocument.setContentPane(lpnDocument);
frmDocument.setTitle("Forge: " + Singletons.getModel().getBuildInfo().getVersion());
pnlInsets.add(pnlContent, BorderLayout.CENTER);
pnlInsets.setBackground(Color.black);
pnlInsets.setBorder(new EmptyBorder(
FViewNew.BORDER_T, FViewNew.BORDER_T, 0, 0));
pnlContent.setBackground(Color.black);
pnlContent.setLayout(null);
lpnDocument.addMouseListener(SOverflowUtil.getHideOverflowListener());
lpnDocument.addComponentListener(SResizingUtil.getWindowResizeListener());
lpnDocument.add(pnlInsets, (Integer) 0);
lpnDocument.add(pnlPreview, (Integer) 1);
lpnDocument.add(pnlTabOverflow, (Integer) 2);
frmDocument.setVisible(true);
pnlInsets.setBounds(lpnDocument.getBounds());
}
/** */
public void populate() {
DragCell cell0 = new DragCell();
DragCell cell1 = new DragCell();
DragCell cell2 = new DragCell();
DragCell cell3 = new DragCell();
DragCell cell4 = new DragCell();
DragCell cell5 = new DragCell();
cell0.addDoc(EDocID.REPORT_STACK.getDoc());
cell0.addDoc(EDocID.REPORT_COMBAT.getDoc());
cell0.addDoc(EDocID.REPORT_LOG.getDoc());
cell0.addDoc(EDocID.REPORT_PLAYERS.getDoc());
cell1.addDoc(EDocID.REPORT_MESSAGE.getDoc());
cell2.addDoc(EDocID.YOUR_BATTLEFIELD.getDoc());
cell3.addDoc(EDocID.YOUR_HAND.getDoc());
cell4.addDoc(EDocID.YOUR_DOCK.getDoc());
cell5.addDoc(EDocID.CARD_DETAIL.getDoc());
cell5.addDoc(EDocID.CARD_PICTURE.getDoc());
cell5.addDoc(EDocID.CARD_ANTES.getDoc());
addDragCell(cell0);
addDragCell(cell1);
addDragCell(cell2);
addDragCell(cell3);
addDragCell(cell4);
addDragCell(cell5);
cell0.setRoughBounds(0, 0, 0.2, 0.7);
cell1.setRoughBounds(0, 0.7, 0.2, 0.3);
cell2.setRoughBounds(0.2, 0, 0.6, 0.5);
cell3.setRoughBounds(0.2, 0.5, 0.6, 0.5);
cell4.setRoughBounds(0.8, 0, 0.2, 0.25);
cell5.setRoughBounds(0.8, 0.25, 0.2, 0.75);
// TODO save a default layout, and then remove these lines and load it every time.
//SIOUtil.saveLayout();
//SIOUtil.loadLayout();
}
/** @return {@link javax.swing.JFrame} */
public JFrame getFrame() {
return frmDocument;
}
/** @return {@link javax.swing.JLayeredPane} */
public JLayeredPane getLpnDocument() {
return lpnDocument;
}
/** @return {@link javax.swing.JPanel} */
public JPanel getPnlInsets() {
return pnlInsets;
}
/** @return {@link javax.swing.JPanel} */
public JPanel getPnlContent() {
return pnlContent;
}
/** @return {@link javax.swing.JPanel} */
public JPanel getPnlPreview() {
return pnlPreview;
}
/** @return {@link javax.swing.JPanel} */
public JPanel getPnlTabOverflow() {
return pnlTabOverflow;
}
/** @return {@link java.util.List}<{@link forge.gui.layout.DragCell}> */
public List<DragCell> getDragCells() {
final List<DragCell> clone = new ArrayList<DragCell>();
clone.addAll(CELLS);
return clone;
}
/** @param pnl0 &emsp; {@link forge.gui.layout.DragCell} */
public void addDragCell(final DragCell pnl0) {
CELLS.add(pnl0);
pnlContent.add(pnl0);
}
/** @param pnl0 &emsp; {@link forge.gui.layout.DragCell} */
public void removeDragCell(final DragCell pnl0) {
CELLS.remove(pnl0);
pnlContent.remove(pnl0);
}
/** */
public void removeAllDragCells() {
CELLS.clear();
pnlContent.removeAll();
}
/** PreviewPanel shows where a dragged component could
* come to rest when the mouse is released.<br>
* This class is an unfortunate necessity to overcome
* translucency issues for preview panel. */
@SuppressWarnings("serial")
class PreviewPanel extends JPanel {
/** PreviewPanel shows where a dragged component could
* come to rest when the mouse is released. */
public PreviewPanel() {
super();
setOpaque(false);
setVisible(false);
setBorder(new LineBorder(Color.DARK_GRAY, 2));
}
@Override
public void paintComponent(final Graphics g) {
super.paintComponent(g);
g.setColor(new Color(0, 0, 0, 50));
g.fillRect(0, 0, getWidth(), getHeight());
}
}
}

View File

@@ -1,49 +0,0 @@
package forge.gui.layout;
import java.awt.Component;
/**
* This interface provides a unifying type to any component
* (usually JPanels or JScrollPanes) which could be used as
* a tab. A single one of these components is referred to as
* a "document" throughout the codebase. The tabs and their
* documents are contained in "cells" for resizing and dragging.
*
* <br><br><i>(I at beginning of class name denotes an interface.)</i>
* <br><i>(V at beginning of class name denotes a view class.)</i>
*/
public interface IVDoc {
/**
* Returns the ID used to identify this tab in save XML and card layouts.
*
* @return {@link forge.gui.layout.EDocID}
*/
EDocID getDocumentID();
/**
* Returns top-level component containing all of the content in this tab.
* This is used to attach the component to the card layout of its parent.
*
* @return {@link java.awt.Component}
*/
Component getDocument();
/**
* Returns tab label object used in title bars.
*
* @return {@link forge.gui.layout.DragTab}
*/
DragTab getTabLabel();
/** Retrieves control object associated with this document.
* @return {@link forge.gui.home.ICSubmenu}
*/
ICDoc getControl();
/**
* Removes all children and (re)populates panel components,
* independent of constructor. Expected to provide
* a completely fresh layout on the component.
*/
void populate();
}

View File

@@ -1,13 +0,0 @@
package forge.gui.layout;
/**
* <br><br><i>(M at beginning of class name denotes a class
* containing the <b>main</b> method).</i>
*/
final class MDragUI {
/** @param args &emsp; {@link java.lang.String}[] */
public static void main(String[] args) {
FViewNew.SINGLETON_INSTANCE.populate();
}
}

View File

@@ -1,114 +0,0 @@
package forge.gui.layout;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.List;
import javax.swing.SwingUtilities;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
/** Package-private class for handling layout saving and loading. */
final class SIOUtil {
/** Each cell must save these elements of its display. */
private enum Element {
x,
y,
w,
h,
doc
};
private static final String FILE = "layout_default.xml";
private static final XMLEventFactory EF = XMLEventFactory.newInstance();
private static final XMLEvent NEWLINE = EF.createDTD("\n");
private static final XMLEvent TAB = EF.createDTD("\t");
/** Publicly-accessible save method, to neatly handle exception handling. */
public static void saveLayout() {
if (SwingUtilities.isEventDispatchThread()) {
throw new IllegalThreadStateException("This operation should be independent of the EDT.");
}
// try { save(); }
// catch (final Exception e) { e.printStackTrace(); }
}
/** Publicly-accessible load method, to neatly handle exception handling. */
public static void loadLayout() {
if (SwingUtilities.isEventDispatchThread()) {
throw new IllegalThreadStateException("This operation should be independent of the EDT.");
}
// try { load(); }
// catch (final Exception e) { e.printStackTrace(); }
// TODO save layout after resize / rearrange
// TODO layout save
int todo = 5;
}
private static void save() throws Exception {
final XMLOutputFactory out = XMLOutputFactory.newInstance();
final XMLEventWriter writer = out.createXMLEventWriter(new FileOutputStream(FILE));
final List<DragCell> cells = FViewNew.SINGLETON_INSTANCE.getDragCells();
writer.add(EF.createStartDocument());
writer.add(EF.createStartElement("", "", "layout"));
for (final DragCell cell : cells) {
writer.add(EF.createStartElement("", "", "cell"));
createNode(writer, Element.x, String.valueOf(cell.getRoughX()));
createNode(writer, Element.y, String.valueOf(cell.getRoughY()));
createNode(writer, Element.w, String.valueOf(cell.getRoughW()));
createNode(writer, Element.h, String.valueOf(cell.getRoughH()));
for (final IVDoc vDoc : cell.getDocs()) {
createNode(writer, Element.doc, vDoc.getDocumentID().toString());
}
writer.add(EF.createEndElement("", "", "cell"));
}
writer.add(EF.createEndDocument());
writer.flush();
writer.close();
}
private static void load() throws Exception {
final FViewNew view = FViewNew.SINGLETON_INSTANCE;
final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
final XMLEventReader reader = inputFactory.createXMLEventReader(new FileInputStream(FILE));
view.removeAllDragCells();
/*while (reader.hasNext()) {
XMLEvent event = reader.nextEvent();
if (event.isStartElement()) {
/*StartElement startElement = event.asStartElement();
if (startElement.getName().getLocalPart() == (ITEM)) {
}*
//System.err.println(event.isStartElement());
}
}*/
}
private static void createNode(final XMLEventWriter writer0, final Element name0,
final String val0) throws XMLStreamException {
writer0.add(TAB);
writer0.add(EF.createStartElement("", "", name0.toString()));
writer0.add(EF.createCharacters(val0));
writer0.add(EF.createEndElement("", "", name0.toString()));
writer0.add(NEWLINE);
}
}

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.control;
package forge.gui.match;
import java.awt.Image;
import java.io.File;
@@ -29,57 +29,36 @@ import forge.Card;
import forge.CardList;
import forge.Constant;
import forge.Singletons;
import forge.control.match.ControlDetail;
import forge.control.match.ControlDock;
import forge.control.match.ControlField;
import forge.control.match.ControlHand;
import forge.control.match.ControlMessage;
import forge.control.match.ControlPicture;
import forge.control.match.ControlTabber;
import forge.game.GameType;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.CardContainer;
import forge.gui.GuiMultipleBlockers;
import forge.gui.framework.EDocID;
import forge.gui.framework.SDisplayUtil;
import forge.gui.match.controllers.CDetail;
import forge.gui.match.controllers.CMessage;
import forge.gui.match.controllers.CPicture;
import forge.gui.match.nonsingleton.CField;
import forge.gui.match.nonsingleton.VField;
import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FSkin;
import forge.properties.ForgePreferences.FPref;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.view.ViewMatchUI;
import forge.view.match.ViewField;
/**
* <p>
* ControlMatchUI
* </p>
* Top-level controller for matches.
* Constructs instance of match UI controller, used as a single point of
* top-level control for child UIs. Tasks targeting the view of individual
* components are found in a separate controller for that component and
* should not be included here.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*/
public class ControlMatchUI implements CardContainer {
private final ViewMatchUI view;
/**
* <p>
* ControlMatchUI
* </p>
* 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
* &emsp; A ViewMatchUI object
*/
public ControlMatchUI(final ViewMatchUI v) {
this.view = v;
}
public enum CMatchUI implements CardContainer {
/** */
SINGLETON_INSTANCE;
/**
* Fires up controllers for each component of UI.
@@ -88,12 +67,11 @@ public class ControlMatchUI implements CardContainer {
*
*/
public void initMatch(final String strAvatarIcon) {
ControlMatchUI.this.showCombat("");
ControlMatchUI.this.showStack();
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
// Update avatars
final String[] indices = Singletons.getModel().getPreferences().getPref(FPref.UI_AVATARS).split(",");
final Object[] views = Singletons.getView().getViewMatch().getFieldViews().toArray();
final Object[] views = VMatchUI.SINGLETON_INSTANCE.getFieldViews().toArray();
for (int i = 0; i < views.length; i++) {
final Image img;
// Update AI quest icon
@@ -115,8 +93,8 @@ public class ControlMatchUI implements CardContainer {
img = FSkin.getAvatars().get(Integer.parseInt(indices[i]));
}
((ViewField) views[i]).getLblAvatar().setIcon(new ImageIcon(img));
((FLabel) ((ViewField) views[i]).getLblAvatar()).getResizeTimer().start();
((VField) views[i]).getLblAvatar().setIcon(new ImageIcon(img));
((FLabel) ((VField) views[i]).getLblAvatar()).getResizeTimer().start();
}
// Update observers
@@ -126,11 +104,11 @@ public class ControlMatchUI implements CardContainer {
AllZone.getComputerPlayer().updateObservers();
AllZone.getComputerPlayer().getZone(ZoneType.Hand).updateObservers();
AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers();
AllZone.getComputerPlayer().getZone(ZoneType.Battlefield).updateObservers();
AllZone.getStack().updateObservers();
AllZone.getInputControl().updateObservers();
ControlMatchUI.this.getTabberControl().updateObservers();
AllZone.getGameLog().updateObservers();
}
/**
@@ -140,91 +118,27 @@ public class ControlMatchUI implements CardContainer {
// This method is in the top-level controller because it affects ALL fields
// (not just one).
public void resetAllPhaseButtons() {
for (final ControlField c : ControlMatchUI.this.getFieldControls()) {
for (final CField c : CMatchUI.this.getFieldControls()) {
c.resetPhaseButtons();
}
}
/** @param s0 &emsp; {@link java.lang.String} */
public void showMessage(final String s0) {
getMessageControl().setMessage(s0);
}
/** */
public void showStack() {
ControlMatchUI.this.getTabberControl().showPnlStack();
}
/** @param s0 &emsp; {@link java.lang.String} */
public void showCombat(final String s0) {
ControlMatchUI.this.getTabberControl().getView().updateCombat(s0);
}
/**
* Gets the detail controller.
*
* @return ControlDetail
*/
public ControlDetail getDetailControl() {
return view.getViewDetail().getControl();
}
/**
* Gets the picture controller.
*
* @return ControlPicture
*/
public ControlPicture getPictureControl() {
return view.getViewPicture().getControl();
}
/**
* Gets the tabber controller.
*
* @return ControlTabber
*/
public ControlTabber getTabberControl() {
return view.getViewTabber().getControl();
}
/**
* Gets the input controller.
*
* @return ControlMessage
*/
public ControlMessage getMessageControl() {
return view.getViewMessage().getControl();
}
/**
* Gets the hand controller.
*
* @return ControlHand
*/
public ControlHand getHandControl() {
return view.getViewHand().getControl();
}
/**
* Gets the dock controller.
*
* @return ControlDock
*/
public ControlDock getDockControl() {
return view.getDockView().getControl();
CMessage.SINGLETON_INSTANCE.setMessage(s0);
}
/**
* Gets the field controllers.
*
* @return List<ControlField>
* @return List<CField>
*/
public List<ControlField> getFieldControls() {
final List<ViewField> fields = view.getViewBattlefield().getFields();
final List<ControlField> controllers = new ArrayList<ControlField>();
public List<CField> getFieldControls() {
final List<VField> fields = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
final List<CField> controllers = new ArrayList<CField>();
for (final ViewField f : fields) {
controllers.add(f.getControl());
for (final VField f : fields) {
controllers.add((CField) f.getControl());
}
return controllers;
@@ -255,11 +169,11 @@ public class ControlMatchUI implements CardContainer {
* @return boolean
*/
public final boolean stopAtPhase(final Player turn, final PhaseType phase) {
final List<ControlField> fieldControllers = ControlMatchUI.this.getFieldControls();
final List<CField> fieldControllers = CMatchUI.this.getFieldControls();
// AI field is at index [0]
int index = turn.isComputer() ? 0 : 1;
ViewField vf = fieldControllers.get(index).getView();
VField vf = fieldControllers.get(index).getView();
switch (phase) {
case UPKEEP: return vf.getLblUpkeep().getEnabled();
@@ -273,6 +187,7 @@ public class ControlMatchUI implements CardContainer {
case COMBAT_END: return vf.getLblEndCombat().getEnabled();
case MAIN2: return vf.getLblMain2().getEnabled();
case END_OF_TURN: return vf.getLblEndTurn().getEnabled();
default:
}
return true;
@@ -280,12 +195,12 @@ public class ControlMatchUI implements CardContainer {
@Override
public void setCard(final Card c) {
Singletons.getControl().getControlMatch().getDetailControl().showCard(c);
Singletons.getControl().getControlMatch().getPictureControl().showCard(c);
CDetail.SINGLETON_INSTANCE.showCard(c);
CPicture.SINGLETON_INSTANCE.showCard(c);
}
@Override
public Card getCard() {
return Singletons.getControl().getControlMatch().getDetailControl().getCurrentCard();
return CDetail.SINGLETON_INSTANCE.getCurrentCard();
}
}

View File

@@ -1,4 +1,4 @@
package forge.control.match;
package forge.gui.match;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -19,7 +19,6 @@ import forge.gui.OverlayUtils;
import forge.item.CardDb;
import forge.item.CardPrinted;
import forge.properties.ForgePreferences.FPref;
import forge.view.match.ViewWinLose;
/**
* Default controller for a ViewWinLose object. This class can

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.view.match;
package forge.gui.match;
import java.util.Collections;
import java.util.List;

View File

@@ -14,14 +14,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.view.match;
package forge.gui.match;
import forge.AllZone;
import forge.CardList;
import forge.Constant;
import forge.Singletons;
import forge.control.FControl;
import forge.control.match.ControlWinLose;
import forge.game.GameEndReason;
import forge.game.GameFormat;
@@ -49,6 +48,7 @@ import forge.quest.bazaar.QuestItemType;
import forge.quest.data.QuestAssets;
import forge.quest.data.QuestPreferences.QPref;
import forge.util.MyRandom;
import java.awt.Color;
import java.awt.Dimension;
import java.util.ArrayList;

View File

@@ -0,0 +1,168 @@
package forge.gui.match;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import forge.AllZone;
import forge.gui.framework.DragCell;
import forge.gui.framework.EDocID;
import forge.gui.framework.IVDoc;
import forge.gui.framework.IVTopLevelUI;
import forge.gui.framework.SIOUtil;
import forge.gui.framework.SResizingUtil;
import forge.gui.match.nonsingleton.VField;
import forge.gui.match.nonsingleton.VHand;
import forge.gui.match.views.VDetail;
import forge.gui.match.views.VDev;
import forge.gui.match.views.VMessage;
import forge.gui.match.views.VPicture;
import forge.view.FView;
/**
* Top level view class for match UI drag layout.<br>
* Has access methods for all draggable documents.<br>
* Uses singleton pattern.<br>
*
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
*/
public enum VMatchUI implements IVTopLevelUI {
/** */
SINGLETON_INSTANCE;
// Instantiate non-singleton tab instances
private final IVDoc field0 = new VField(EDocID.FIELD_0, AllZone.getComputerPlayer());
private final IVDoc field1 = new VField(EDocID.FIELD_1, AllZone.getHumanPlayer());
private final IVDoc field2 = new VField(EDocID.FIELD_2, AllZone.getComputerPlayer());
private final IVDoc field3 = new VField(EDocID.FIELD_3, AllZone.getComputerPlayer());
private final IVDoc hand0 = new VHand(EDocID.HAND_0, AllZone.getComputerPlayer());
private final IVDoc hand1 = new VHand(EDocID.HAND_1, AllZone.getHumanPlayer());
private final IVDoc hand2 = new VHand(EDocID.HAND_2, AllZone.getComputerPlayer());
private final IVDoc hand3 = new VHand(EDocID.HAND_3, AllZone.getComputerPlayer());
// Instantiate singleton tab instances
private final IVDoc stack = EDocID.REPORT_STACK.getDoc();
private final IVDoc combat = EDocID.REPORT_COMBAT.getDoc();
private final IVDoc log = EDocID.REPORT_LOG.getDoc();
private final IVDoc players = EDocID.REPORT_PLAYERS.getDoc();
private final IVDoc message = EDocID.REPORT_MESSAGE.getDoc();
private final IVDoc dock = EDocID.BUTTON_DOCK.getDoc();
private final IVDoc detail = EDocID.CARD_DETAIL.getDoc();
private final IVDoc picture = EDocID.CARD_PICTURE.getDoc();
private final IVDoc antes = EDocID.CARD_ANTES.getDoc();
private final IVDoc devmode = EDocID.DEV_MODE.getDoc();
// Other instantiations
private final CMatchUI control = null;
private boolean isPopulated = false;
/** */
public void instantiate() {
}
/** */
public void populate() {
if (isPopulated) { return; }
else { isPopulated = true; }
SIOUtil.loadLayout();
}
/** */
public void defaultLayout() {
final DragCell cell0 = new DragCell();
final DragCell cell1 = new DragCell();
final DragCell cell2 = new DragCell();
final DragCell cell3 = new DragCell();
final DragCell cell4 = new DragCell();
final DragCell cell5 = new DragCell();
final DragCell cell6 = new DragCell();
cell0.addDoc(stack);
cell0.addDoc(combat);
cell0.addDoc(log);
cell0.addDoc(players);
cell1.addDoc(message);
cell1.addDoc(devmode);
cell2.addDoc(field0);
cell6.addDoc(field1);
if (AllZone.getPlayersInGame().size() > 2) { cell2.addDoc(field2); }
if (AllZone.getPlayersInGame().size() > 3) { cell2.addDoc(field3); }
if (AllZone.getPlayersInGame().size() > 1000) { cell3.addDoc(hand0); }
cell3.addDoc(hand1);
if (AllZone.getPlayersInGame().size() > 2) { cell2.addDoc(hand2); }
if (AllZone.getPlayersInGame().size() > 3) { cell2.addDoc(hand3); }
cell4.addDoc(dock);
cell5.addDoc(detail);
cell5.addDoc(picture);
cell5.addDoc(antes);
FView.SINGLETON_INSTANCE.addDragCell(cell0);
FView.SINGLETON_INSTANCE.addDragCell(cell1);
FView.SINGLETON_INSTANCE.addDragCell(cell2);
FView.SINGLETON_INSTANCE.addDragCell(cell3);
FView.SINGLETON_INSTANCE.addDragCell(cell4);
FView.SINGLETON_INSTANCE.addDragCell(cell5);
FView.SINGLETON_INSTANCE.addDragCell(cell6);
cell0.setRoughBounds(0, 0, 0.2, 0.7);
cell1.setRoughBounds(0, 0.7, 0.2, 0.3);
cell2.setRoughBounds(0.2, 0, 0.6, 0.33);
cell3.setRoughBounds(0.2, 0.66, 0.6, 0.34);
cell4.setRoughBounds(0.8, 0, 0.2, 0.25);
cell5.setRoughBounds(0.8, 0.25, 0.2, 0.75);
cell6.setRoughBounds(0.2, 0.33, 0.6, 0.33);
SResizingUtil.resizeWindow();
}
//========== Retrieval methods
/** @return {@link forge.gui.match.CMatchUI} */
public CMatchUI getControl() {
return this.control;
}
/** @return {@link forge.gui.match.views.VDetail} */
public VDetail getViewDetail() {
return ((VDetail) this.detail);
}
/** @return {@link forge.gui.match.views.VPicture} */
public VPicture getViewPicture() {
return ((VPicture) this.picture);
}
/** @return {@link forge.gui.match.views.VDev} */
public VDev getViewDevMode() {
return ((VDev) this.devmode);
}
/** @return {@link java.util.List}<{@link forge.gui.match.nonsigleton.VField}> */
public List<VField> getFieldViews() {
final List<VField> lst = new ArrayList<VField>();
lst.add((VField) field0);
lst.add((VField) field1);
//lst.add((VField) field2);
//lst.add((VField) field3);
return lst;
}
/** @return {@link javax.swing.JButton} */
public JButton getBtnCancel() {
return ((VMessage) this.message).getBtnCancel();
}
/** @return {@link javax.swing.JButton} */
public JButton getBtnOK() {
return ((VMessage) this.message).getBtnOK();
}
}

View File

@@ -1,4 +1,4 @@
package forge.view.match;
package forge.gui.match;
import java.awt.Color;
import java.awt.Font;
@@ -13,7 +13,6 @@ import net.miginfocom.swing.MigLayout;
import forge.AllZone;
import forge.Constant;
import forge.Singletons;
import forge.control.match.ControlWinLose;
import forge.game.GameType;
import forge.game.phase.PhaseHandler;
import forge.game.player.Player;

View File

@@ -0,0 +1,38 @@
package forge.gui.match.controllers;
import forge.Command;
import forge.gui.framework.ICDoc;
/**
* Controls the ante panel in the match UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*
*/
public enum CAntes implements ICDoc {
/** */
SINGLETON_INSTANCE;
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
}
}

View File

@@ -0,0 +1,40 @@
package forge.gui.match.controllers;
import forge.Command;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VCombat;
/**
* Controls the combat panel in the match UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*
*/
public enum CCombat implements ICDoc {
/** */
SINGLETON_INSTANCE;
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
VCombat.SINGLETON_INSTANCE.updateCombat("");
}
}

View File

@@ -15,28 +15,24 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.control.match;
package forge.gui.match.controllers;
import forge.Card;
import forge.view.match.ViewDetail;
import forge.Command;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VDetail;
/**
*
* Controls the card detail area in the match UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*/
public class ControlDetail {
private final ViewDetail view;
private Card currentCard = null;
public enum CDetail implements ICDoc {
/** */
SINGLETON_INSTANCE;
/**
* Controls the card detail area in the match UI.
*
* @param v &emsp; The CardViewer Swing component.
*/
public ControlDetail(final ViewDetail v) {
this.view = v;
}
private Card currentCard = null;
/**
* Shows card details and/or picture in sidebar cardview tabber.
@@ -45,7 +41,7 @@ public class ControlDetail {
*/
public void showCard(final Card c) {
this.currentCard = c;
this.view.getPnlDetail().setCard(c);
VDetail.SINGLETON_INSTANCE.getPnlDetail().setCard(c);
}
/**
@@ -56,4 +52,26 @@ public class ControlDetail {
public Card getCurrentCard() {
return this.currentCard;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
}
}

View File

@@ -0,0 +1,110 @@
package forge.gui.match.controllers;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import forge.Command;
import forge.Singletons;
import forge.gui.GuiDisplayUtil;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VDev;
import forge.properties.ForgePreferences.FPref;
/**
* Controls the combat panel in the match UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*
*/
public enum CDev implements ICDoc {
/** */
SINGLETON_INSTANCE;
//========= Start mouse listener inits
private final MouseListener madMilling = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
VDev.SINGLETON_INSTANCE.getLblMilling().toggleEnabled(); } };
private final MouseListener madUnlimited = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().toggleEnabled(); } };
private final MouseListener madMana = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeGenerateMana(); } };
private final MouseListener madSetup = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devSetupGameState(); } };
private final MouseListener madTutor = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeTutor(); } };
private final MouseListener madAddAnyCard = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeAddAnyCard(); } };
private final MouseListener madCounter = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeAddCounter(); } };
private final MouseListener madTap = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeTapPerm(); } };
private final MouseListener madUntap = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeUntapPerm(); } };
private final MouseListener madLife = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeSetLife(); } };
//========== End mouse listener inits
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
VDev.SINGLETON_INSTANCE.getLblMilling().addMouseListener(madMilling);
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().addMouseListener(madUnlimited);
VDev.SINGLETON_INSTANCE.getLblGenerateMana().addMouseListener(madMana);
VDev.SINGLETON_INSTANCE.getLblSetupGame().addMouseListener(madSetup);
VDev.SINGLETON_INSTANCE.getLblTutor().addMouseListener(madTutor);
VDev.SINGLETON_INSTANCE.getAnyCard().addMouseListener(madAddAnyCard);
VDev.SINGLETON_INSTANCE.getLblCounterPermanent().addMouseListener(madCounter);
VDev.SINGLETON_INSTANCE.getLblTapPermanent().addMouseListener(madTap);
VDev.SINGLETON_INSTANCE.getLblUntapPermanent().addMouseListener(madUntap);
VDev.SINGLETON_INSTANCE.getLblSetLife().addMouseListener(madLife);
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.DEV_MILLING_LOSS)) {
VDev.SINGLETON_INSTANCE.getLblMilling().setEnabled(true);
} else {
VDev.SINGLETON_INSTANCE.getLblMilling().setEnabled(false);
}
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.DEV_UNLIMITED_LAND)) {
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setEnabled(true);
} else {
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setEnabled(false);
}
}
}

View File

@@ -15,11 +15,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.control.match;
package forge.gui.match.controllers;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -28,30 +30,25 @@ import java.util.Map.Entry;
import javax.swing.JOptionPane;
import forge.AllZone;
import forge.Command;
import forge.Constant;
import forge.Singletons;
import forge.deck.Deck;
import forge.gui.ForgeAction;
import forge.gui.OverlayUtils;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VDock;
import forge.item.CardPrinted;
import forge.properties.NewConstants;
import forge.view.match.ViewDock;
/**
* Child controller, handles dock button operations.
* Controls the dock panel in the match UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*/
public class ControlDock {
private final ViewDock view;
/**
* Child controller, handles dock button operations.
*
* @param v
* &emsp; ViewDock obj
*/
public ControlDock(final ViewDock v) {
this.view = v;
}
public enum CDock implements ICDoc {
/** */
SINGLETON_INSTANCE;
/** Concede game, bring up WinLose UI. */
public void concede() {
@@ -59,22 +56,14 @@ public class ControlDock {
Singletons.getModel().getGameAction().checkStateEffects();
}
/**
* Gets the view.
*
* @return ViewDock
*/
public ViewDock getView() {
return this.view;
}
/**
* End turn.
*/
public void endTurn() {
// Big thanks to you, Gameplay Guru, since I was too lazy to figure this
// out before release. Doublestrike 24-11-11
System.err.println("forge.control.match > ControlDock > endTurn()");
//
System.err.println("forge.control.match > CDock > endTurn()");
System.out.println("Should skip to the end of turn, or entire turn.");
System.err.println("If some gameplay guru could implement this, that would be great...");
}
@@ -160,4 +149,45 @@ public class ControlDock {
}
}
} // End DeckListAction
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
VDock.SINGLETON_INSTANCE.getBtnConcede()
.addMouseListener(new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
concede(); } });
VDock.SINGLETON_INSTANCE.getBtnSettings()
.addMouseListener(new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
OverlayUtils.showOverlay(); } });
VDock.SINGLETON_INSTANCE.getBtnEndTurn()
.addMouseListener(new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
endTurn(); } });
VDock.SINGLETON_INSTANCE.getBtnViewDeckList()
.addMouseListener(new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
viewDeckList(); } });
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
}
}

View File

@@ -0,0 +1,53 @@
package forge.gui.match.controllers;
import java.util.Observable;
import java.util.Observer;
import forge.AllZone;
import forge.Command;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VLog;
/**
* Controls the combat panel in the match UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*
*/
public enum CLog implements ICDoc, Observer {
/** */
SINGLETON_INSTANCE;
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
AllZone.getGameLog().addObserver(this);
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
VLog.SINGLETON_INSTANCE.updateConsole();
}
/* (non-Javadoc)
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
*/
@Override
public void update(Observable arg0, Object arg1) {
update();
}
}

View File

@@ -0,0 +1,114 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.gui.match.controllers;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import forge.Command;
import forge.Constant;
import forge.Singletons;
import forge.gui.GuiInput;
import forge.gui.framework.ICDoc;
import forge.gui.framework.SDisplayUtil;
import forge.gui.match.views.VMessage;
/**
* Controls the message panel in the match UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*/
public enum CMessage implements ICDoc {
/** */
SINGLETON_INSTANCE;
private final GuiInput inputControl = new GuiInput();
private final ActionListener actCancel = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent evt) {
inputControl.selectButtonCancel();
VMessage.SINGLETON_INSTANCE.getBtnOK().requestFocusInWindow();
}
};
private final ActionListener actOK = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent evt) {
inputControl.selectButtonOK();
if (Singletons.getModel().getGameState().getPhaseHandler().isNeedToNextPhase()) {
// moves to next turn
Singletons.getModel().getGameState().getPhaseHandler().setNeedToNextPhase(false);
Singletons.getModel().getGameState().getPhaseHandler().nextPhase();
}
VMessage.SINGLETON_INSTANCE.getBtnOK().requestFocusInWindow();
}
};
@Override
public void initialize() {
VMessage.SINGLETON_INSTANCE.getBtnCancel().removeActionListener(actCancel);
VMessage.SINGLETON_INSTANCE.getBtnCancel().addActionListener(actCancel);
VMessage.SINGLETON_INSTANCE.getBtnOK().removeActionListener(actOK);
VMessage.SINGLETON_INSTANCE.getBtnOK().addActionListener(actOK);
}
/**
* Gets the input control.
*
* @return GuiInput
*/
public GuiInput getInputControl() {
return this.inputControl;
}
/** @param s0 &emsp; {@link java.lang.String} */
public void setMessage(String s0) {
VMessage.SINGLETON_INSTANCE.getTarMessage().setText(s0);
}
/** Updates count label in input area. */
public void updateGameCount() {
VMessage.SINGLETON_INSTANCE.getLblGames().setText("<html>Game #"
+ (Singletons.getModel().getMatchState().getGamesPlayedCount() + 1)
+ " of " + Singletons.getModel().getMatchState().getGamesPerMatch()
+ "<br>" + Constant.Runtime.getGameType().toString() + " mode</html>");
}
/** Flashes animation on input panel if play is currently waiting on input. */
public void remind() {
SDisplayUtil.remind(VMessage.SINGLETON_INSTANCE);
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
}
}

View File

@@ -15,36 +15,23 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.control.match;
package forge.gui.match.controllers;
import forge.Card;
import forge.view.match.ViewPicture;
import forge.Command;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VPicture;
/**
* Controls the card picture panel in the match UI.
*
* Controls the vertical tabber in sidebar used for viewing card details and
* picture.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*/
public class ControlPicture {
private final ViewPicture view;
public enum CPicture implements ICDoc {
/** */
SINGLETON_INSTANCE;
private Card currentCard = null;
/**
* Controls the vertical tabber in sidebar used for viewing card details and
* picture.
*
* @param v
* &emsp; The CardViewer Swing component.
*/
public ControlPicture(final ViewPicture v) {
this.view = v;
}
/** @return ViewPicture */
public ViewPicture getView() {
return view;
}
/**
* Shows card details and/or picture in sidebar cardview tabber.
*
@@ -53,7 +40,7 @@ public class ControlPicture {
*/
public void showCard(final Card c) {
this.currentCard = c;
this.view.getPnlPicture().setCard(c);
VPicture.SINGLETON_INSTANCE.getPnlPicture().setCard(c);
}
/**
@@ -64,4 +51,26 @@ public class ControlPicture {
public Card getCurrentCard() {
return this.currentCard;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
}
}

View File

@@ -0,0 +1,42 @@
package forge.gui.match.controllers;
import forge.AllZone;
import forge.Command;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VPlayers;
/**
* Controls the combat panel in the match UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*
*/
public enum CPlayers implements ICDoc {
/** */
SINGLETON_INSTANCE;
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
VPlayers.SINGLETON_INSTANCE.updatePlayerLabels(AllZone.getComputerPlayer());
VPlayers.SINGLETON_INSTANCE.updatePlayerLabels(AllZone.getHumanPlayer());
}
}

View File

@@ -0,0 +1,52 @@
package forge.gui.match.controllers;
import java.util.Observable;
import java.util.Observer;
import forge.AllZone;
import forge.Command;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VStack;
/**
* Controls the combat panel in the match UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*
*/
public enum CStack implements ICDoc, Observer {
/** */
SINGLETON_INSTANCE;
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
AllZone.getStack().addObserver(this);
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
VStack.SINGLETON_INSTANCE.updateStack();
}
/* (non-Javadoc)
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
*/
@Override
public void update(Observable arg0, Object arg1) {
update();
}
}

View File

@@ -0,0 +1,579 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.gui.match.nonsingleton;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;
import com.google.code.jyield.Generator;
import com.google.code.jyield.YieldUtils;
import forge.AllZone;
import forge.Card;
import forge.CardList;
import forge.Command;
import forge.Constant;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil;
import forge.control.input.Input;
import forge.control.input.InputAttack;
import forge.control.input.InputBlock;
import forge.control.input.InputMana;
import forge.control.input.InputPayManaCost;
import forge.control.input.InputPayManaCostAbility;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.ForgeAction;
import forge.gui.GuiDisplayUtil;
import forge.gui.GuiUtils;
import forge.gui.framework.ICDoc;
import forge.gui.match.CMatchUI;
import forge.gui.match.controllers.CMessage;
import forge.gui.toolbox.FLabel;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.properties.NewConstants.Lang.GuiDisplay.ComputerHand;
import forge.properties.NewConstants.Lang.GuiDisplay.ComputerLibrary;
import forge.properties.NewConstants.Lang.GuiDisplay.HumanHand;
import forge.properties.NewConstants.Lang.GuiDisplay.HumanLibrary;
/**
* Controls Swing components of a player's field instance.
*/
public class CField implements ICDoc {
private final Player player;
private final VField view;
private boolean initializedAlready = false;
private MouseMotionListener mmlCardOver = new MouseMotionAdapter() { @Override
public void mouseMoved(final MouseEvent e) {
cardoverAction(); } };
private final MouseListener madHand = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
handAction(); } };
private final MouseListener madAvatar = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
avatarAction(); } };
private final MouseListener madExiled = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
exiledAction(); } };
private final MouseListener madLibrary = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
libraryAction(); } };
private final MouseListener madGraveyard = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
graveyardAction(); } };
private final MouseListener madFlashback = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
flashbackAction(); } };
private final MouseListener madCardClick = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
cardclickAction(e); } };
private final MouseListener madBlack = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
blackAction(); } };
private final MouseListener madBlue = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
blueAction(); } };
private final MouseListener madGreen = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
greenAction(); } };
private final MouseListener madRed = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
redAction(); } };
private final MouseListener madWhite = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
whiteAction(); } };
private final MouseListener madColorless = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
colorlessAction(); } };
// Hand, Graveyard, Library, Flashback, Exile zones, attached to hand.
private final Observer observerZones = new Observer() {
@Override
public void update(final Observable a, final Object b) {
CField.this.view.updateZones(CField.this.player);
}
};
// Life total, poison total, and keywords, attached directly to Player.
private final Observer observerDetails = new Observer() {
@Override
public void update(final Observable a, final Object b) {
CField.this.view.updateDetails(CField.this.player);
}
};
// Card play area, attached to battlefield zone.
private final Observer observerPlay = new Observer() {
@Override
public void update(final Observable a, final Object b) {
final PlayerZone pZone = (PlayerZone) a;
GuiDisplayUtil.setupPlayZone(CField.this.view.getTabletop(), pZone.getCards(false));
}
};
/**
* Controls Swing components of a player's field instance.
*
* @param p0 &emsp; {@link forge.game.player.Player}
* @param v0 &emsp; {@link forge.gui.match.nonsingleton.VField}
*/
public CField(final Player p0, final VField v0) {
this.player = p0;
this.view = v0;
}
@Override
public void initialize() {
if (initializedAlready) { return; }
else { initializedAlready = true; }
// Observers
CField.this.player.getZone(ZoneType.Hand).addObserver(observerZones);
CField.this.player.getZone(ZoneType.Battlefield).addObserver(observerPlay);
CField.this.player.addObserver(observerDetails);
// Listeners
// Battlefield card clicks
this.view.getTabletop().addMouseListener(madCardClick);
// Battlefield card mouseover
this.view.getTabletop().addMouseMotionListener(mmlCardOver);
// Player select
this.view.getAvatarArea().addMouseListener(madAvatar);
// Detail label listeners
((FLabel) this.view.getLblGraveyard()).setHoverable(true);
this.view.getLblGraveyard().addMouseListener(madGraveyard);
((FLabel) this.view.getLblExile()).setHoverable(true);
this.view.getLblExile().addMouseListener(madExiled);
this.view.getLblLibrary().addMouseListener(madLibrary);
this.view.getLblHand().addMouseListener(madHand);
((FLabel) this.view.getLblFlashback()).setHoverable(true);
this.view.getLblFlashback().addMouseListener(madFlashback);
((FLabel) this.view.getLblBlack()).setHoverable(true);
this.view.getLblBlack().addMouseListener(madBlack);
((FLabel) this.view.getLblBlue()).setHoverable(true);
this.view.getLblBlue().addMouseListener(madBlue);
((FLabel) this.view.getLblGreen()).setHoverable(true);
this.view.getLblGreen().addMouseListener(madGreen);
((FLabel) this.view.getLblRed()).setHoverable(true);
this.view.getLblRed().removeMouseListener(madRed);
this.view.getLblRed().addMouseListener(madRed);
((FLabel) this.view.getLblWhite()).setHoverable(true);
this.view.getLblWhite().removeMouseListener(madWhite);
this.view.getLblWhite().addMouseListener(madWhite);
((FLabel) this.view.getLblColorless()).setHoverable(true);
this.view.getLblColorless().addMouseListener(madColorless);
}
@Override
public void update() {
}
/** @return {@link forge.game.player.Player} */
public Player getPlayer() {
return this.player;
}
/** @return {@link forge.gui.nonsingleton.VField} */
public VField getView() {
return this.view;
}
/**
* Resets all phase buttons to "inactive", so highlight won't be drawn on
* them. "Enabled" state remains the same.
*/
public void resetPhaseButtons() {
this.view.getLblUpkeep().setActive(false);
this.view.getLblDraw().setActive(false);
this.view.getLblMain1().setActive(false);
this.view.getLblBeginCombat().setActive(false);
this.view.getLblDeclareAttackers().setActive(false);
this.view.getLblDeclareBlockers().setActive(false);
this.view.getLblFirstStrike().setActive(false);
this.view.getLblCombatDamage().setActive(false);
this.view.getLblEndCombat().setActive(false);
this.view.getLblMain2().setActive(false);
this.view.getLblEndTurn().setActive(false);
this.view.getLblCleanup().setActive(false);
}
/**
* Receives click and programmatic requests for viewing data stacks in the
* "zones" of a player field: hand, library, etc.
*
*/
private class ZoneAction extends ForgeAction {
private static final long serialVersionUID = -5822976087772388839L;
private final PlayerZone zone;
private final String title;
/**
* Receives click and programmatic requests for viewing data stacks in
* the "zones" of a player field: hand, graveyard, etc. The library
* "zone" is an exception to the rule; it's handled in DeckListAction.
*
* @param zone
* &emsp; PlayerZone obj
* @param property
* &emsp; String obj
*/
public ZoneAction(final PlayerZone zone, final String property) {
super(property);
this.title = ForgeProps.getLocalized(property + "/title");
this.zone = zone;
}
/**
* @param e
* &emsp; ActionEvent obj
*/
@Override
public void actionPerformed(final ActionEvent e) {
Generator<Card> c = YieldUtils.toGenerator(this.getCardsAsIterable());
if (AllZone.getNameChanger().shouldChangeCardName()) {
c = AllZone.getNameChanger().changeCard(c);
}
final Iterable<Card> myIterable = YieldUtils.toIterable(c);
final ArrayList<Card> choices = YieldUtils.toArrayList(myIterable);
final ArrayList<Card> choices2 = new ArrayList<Card>();
if (choices.isEmpty()) {
GuiUtils.chooseOneOrNone(this.title, new String[] { "no cards" });
} else {
for (int i = 0; i < choices.size(); i++) {
final Card crd = choices.get(i);
if (crd.isFaceDown()) {
if (crd.getController().isComputer() || !crd.hasKeyword("You may look at this card.")) {
final Card faceDown = new Card();
faceDown.setName("Face Down");
choices2.add(faceDown);
} else {
final Card faceDown = AllZone.getCardFactory().copyCard(crd);
faceDown.turnFaceUp();
choices2.add(faceDown);
}
} else {
choices2.add(crd);
}
}
final Card choice = (Card) GuiUtils.chooseOneOrNone(this.title, choices2.toArray());
if (choice != null) {
this.doAction(choice);
}
}
}
protected Iterable<Card> getCardsAsIterable() {
return this.zone.getCards();
}
protected void doAction(final Card c) {
}
} // End ZoneAction
/** */
private void handAction() {
if (!CField.this.player.isComputer()) {
new ZoneAction(CField.this.player.getZone(ZoneType.Hand), HumanHand.BASE)
.actionPerformed(null);
} else if (Constant.Runtime.DEV_MODE[0]
|| CField.this.player.hasKeyword("Play with your hand revealed.")) {
new ZoneAction(CField.this.player.getZone(ZoneType.Hand), ComputerHand.BASE)
.actionPerformed(null);
}
}
/** */
private void flashbackAction() {
if (!CField.this.player.isComputer()) {
new ZoneAction(AllZone.getHumanPlayer().getZone(ZoneType.Graveyard),
NewConstants.Lang.GuiDisplay.HUMAN_FLASHBACK) {
private static final long serialVersionUID = 8120331222693706164L;
@Override
protected Iterable<Card> getCardsAsIterable() {
return CardFactoryUtil.getExternalZoneActivationCards(AllZone.getHumanPlayer());
}
@Override
protected void doAction(final Card c) {
Singletons.getModel().getGameAction().playCard(c);
}
} .actionPerformed(null);
}
else {
new ZoneAction(CField.this.player.getZone(ZoneType.Graveyard),
NewConstants.Lang.GuiDisplay.COMPUTER_FLASHBACK) {
private static final long serialVersionUID = 8120331222693706164L;
@Override
protected Iterable<Card> getCardsAsIterable() {
return CardFactoryUtil.getExternalZoneActivationCards(AllZone.getComputerPlayer());
}
@Override
protected void doAction(final Card c) {
Singletons.getModel().getGameAction().playCard(c);
}
} .actionPerformed(null);
}
}
/** */
private void libraryAction() {
if (!Constant.Runtime.DEV_MODE[0]) { return; }
if (!CField.this.player.isComputer()) {
new ZoneAction(CField.this.player.getZone(ZoneType.Library), HumanLibrary.BASE)
.actionPerformed(null);
} else {
new ZoneAction(CField.this.player.getZone(ZoneType.Library), ComputerLibrary.BASE)
.actionPerformed(null);
}
}
/** */
private void exiledAction() {
if (CField.this.player.isComputer()) {
new ZoneAction(CField.this.player.getZone(ZoneType.Exile),
NewConstants.Lang.GuiDisplay.COMPUTER_EXILED).actionPerformed(null);
} else {
new ZoneAction(CField.this.player.getZone(ZoneType.Exile),
NewConstants.Lang.GuiDisplay.HUMAN_EXILED).actionPerformed(null);
}
}
private void graveyardAction() {
if (CField.this.player.isComputer()) {
new ZoneAction(CField.this.player.getZone(ZoneType.Graveyard),
NewConstants.Lang.GuiDisplay.COMPUTER_GRAVEYARD).actionPerformed(null);
} else {
new ZoneAction(CField.this.player.getZone(ZoneType.Graveyard),
NewConstants.Lang.GuiDisplay.HUMAN_GRAVEYARD).actionPerformed(null);
}
}
private void avatarAction() {
if (CField.this.player.isComputer()) {
CMessage.SINGLETON_INSTANCE
.getInputControl().selectPlayer(AllZone.getComputerPlayer());
} else {
CMessage.SINGLETON_INSTANCE
.getInputControl().selectPlayer(AllZone.getHumanPlayer());
}
}
/** */
private void cardoverAction() {
final Card c = CField.this.view.getTabletop().getCardFromMouseOverPanel();
if (c != null) {
CMatchUI.SINGLETON_INSTANCE.setCard(c);
}
}
/** */
private void cardclickAction(final MouseEvent e) {
// original version:
// final Card c = t.getDetailController().getCurrentCard();
// Roujin's bug fix version dated 2-12-2012
final Card c = CField.this.view.getTabletop().getCardFromMouseOverPanel();
final Input input = CMessage.SINGLETON_INSTANCE.getInputControl().getInput();
if (c != null && c.isInZone(ZoneType.Battlefield)) {
if (c.isTapped()
&& ((input instanceof InputPayManaCost) || (input instanceof InputPayManaCostAbility))) {
final forge.view.arcane.CardPanel cardPanel = CField.this.view.getTabletop().getCardPanel(
c.getUniqueNumber());
for (final forge.view.arcane.CardPanel cp : cardPanel.getAttachedPanels()) {
if (cp.getCard().isUntapped()) {
break;
}
}
}
final CardList att = AllZone.getCombat().getAttackerList();
if ((c.isTapped() || c.hasSickness() || ((c.hasKeyword("Vigilance")) && att.contains(c)))
&& (input instanceof InputAttack)) {
final forge.view.arcane.CardPanel cardPanel = CField.this.view.getTabletop().getCardPanel(
c.getUniqueNumber());
for (final forge.view.arcane.CardPanel cp : cardPanel.getAttachedPanels()) {
if (cp.getCard().isUntapped() && !cp.getCard().hasSickness()) {
break;
}
}
}
if (e.isMetaDown()) {
if (att.contains(c) && (input instanceof InputAttack)
&& !c.hasKeyword("CARDNAME attacks each turn if able.")) {
c.untap();
AllZone.getCombat().removeFromCombat(c);
} else if (input instanceof InputBlock) {
if (c.getController().isHuman()) {
AllZone.getCombat().removeFromCombat(c);
}
((InputBlock) input).removeFromAllBlocking(c);
}
} else {
//Yosei, the Morning Star required cards to be chosen on computer side
//earlier it was enforced that cards must be in player zone
//this can potentially break some other functionality
//(tapping lands works ok but some custom cards may not...)
if (c.getController() != null) {
input.selectCard(c, c.getController().getZone(ZoneType.Battlefield));
} else {
//in weird case card has no controller revert to default behaviour
input.selectCard(c, AllZone.getHumanPlayer().getZone(ZoneType.Battlefield));
}
}
}
}
/** */
private void blackAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.BLACK);
}
}
}
/** */
private void blueAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.BLUE);
}
}
}
/** */
private void greenAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.GREEN);
}
}
}
/** */
private void redAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.RED);
}
}
}
/** */
private void whiteAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.WHITE);
}
}
}
/** */
private void colorlessAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.COLORLESS);
}
}
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
} // End class CField

View File

@@ -0,0 +1,288 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.gui.match.nonsingleton;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JLayeredPane;
import javax.swing.SwingUtilities;
import forge.AllZone;
import forge.Card;
import forge.Command;
import forge.Singletons;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.framework.ICDoc;
import forge.gui.match.CMatchUI;
import forge.gui.match.VMatchUI;
import forge.gui.match.controllers.CMessage;
import forge.view.arcane.CardPanel;
import forge.view.arcane.HandArea;
import forge.view.arcane.util.Animation;
/**
* Controls Swing components of a player's hand instance.
*
*/
public class CHand implements ICDoc {
private final Player player;
private final VHand view;
private boolean initializedAlready = false;
private final List<Card> cardsInPanel = new ArrayList<Card>();;
private final MouseListener madCardClick = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
cardclickAction(e); } };
private final MouseMotionListener madCardMove = new MouseMotionAdapter() { @Override
public void mouseMoved(final MouseEvent me) {
cardmoveAction(); } };
private final Observer o1 = new Observer() { @Override
public void update(final Observable a, final Object b) {
observerAction(a); } };
/**
* Controls Swing components of a player's hand instance.
*
* @param p0 &emsp; {@link forge.game.player.Player}
* @param v0 &emsp; {@link forge.gui.match.nonsingleton.VHand}
*/
public CHand(final Player p0, final VHand v0) {
this.player = p0;
this.view = v0;
}
@Override
public void initialize() {
if (initializedAlready) { return; }
else { initializedAlready = true; }
player.getZone(ZoneType.Hand).addObserver(o1);
view.getHandArea().addMouseListener(madCardClick);
view.getHandArea().addMouseMotionListener(madCardMove);
}
/**
* Adds various listeners for cards in hand. Uses CardPanel instance from
* ViewHand.
*
* @param c
* &emsp; CardPanel object
*/
public void addCardPanelListeners(final CardPanel c) {
// Grab top level controller to facilitate interaction between children
final Card cardobj = c.getCard();
// Sidebar pic/detail on card hover
c.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(final MouseEvent e) {
CMatchUI.SINGLETON_INSTANCE.setCard(cardobj);
}
});
// Mouse press
c.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (e.getButton() != MouseEvent.BUTTON1) { return; }
CMessage.SINGLETON_INSTANCE.getInputControl()
.selectCard(cardobj, AllZone.getHumanPlayer().getZone(ZoneType.Hand));
}
});
}
/**
* Adds the card.
*
* @param c
* &emsp; Card object
*/
public void addCard(final Card c) {
this.cardsInPanel.add(c);
//this.view.refreshLayout();
}
/**
* Adds the cards.
*
* @param c
* &emsp; List of Card objects
*/
public void addCards(final List<Card> c) {
this.cardsInPanel.addAll(c);
//this.view.refreshLayout();
}
/**
* Gets the cards.
*
* @return List<Card>
*/
public List<Card> getCards() {
return this.cardsInPanel;
}
/**
* Removes the card.
*
* @param c
* &emsp; Card object
*/
public void removeCard(final Card c) {
this.cardsInPanel.remove(c);
//this.view.refreshLayout();
}
/**
* Removes the cards.
*
* @param c
* &emsp; List of Card objects
*/
public void removeCards(final List<Card> c) {
this.cardsInPanel.removeAll(c);
//this.view.refreshLayout();
}
/**
* Reset cards.
*
* @param c
* &emsp; List of Card objects
*/
public void resetCards(final List<Card> c) {
this.cardsInPanel.clear();
this.addCards(c);
}
private void cardmoveAction() {
final Card c = view.getHandArea().getCardFromMouseOverPanel();
if (c != null) {
CMatchUI.SINGLETON_INSTANCE.setCard(c);
}
}
private void cardclickAction(final MouseEvent e) {
if (e.getButton() != MouseEvent.BUTTON1) {
return;
}
final Card c = view.getHandArea().getCardFromMouseOverPanel();
if (c != null) {
CMessage.SINGLETON_INSTANCE.getInputControl().selectCard(c, AllZone.getHumanPlayer().getZone(ZoneType.Hand));
VMatchUI.SINGLETON_INSTANCE.getBtnOK().requestFocusInWindow();
}
}
private void observerAction(final Observable a) {
final PlayerZone pZone = (PlayerZone) a;
final HandArea p = view.getHandArea();
final Rectangle rctLibraryLabel = CMatchUI.SINGLETON_INSTANCE
.getFieldControls().get(1)
.getView().getLblLibrary().getBounds();
final List<Card> c = pZone.getCards();
// Animation starts from the library label and runs to the hand panel.
// This check prevents animation running if label hasn't been realized yet.
if (rctLibraryLabel.isEmpty() || p.getWidth() <= 0) {
return;
}
List<Card> tmp, diff;
tmp = new ArrayList<Card>();
for (final forge.view.arcane.CardPanel cpa : p.getCardPanels()) {
tmp.add(cpa.getGameCard());
}
diff = new ArrayList<Card>(tmp);
diff.removeAll(c);
if (diff.size() == p.getCardPanels().size()) {
p.clear();
} else {
for (final Card card : diff) {
p.removeCardPanel(p.getCardPanel(card.getUniqueNumber()));
}
}
diff = new ArrayList<Card>(c);
diff.removeAll(tmp);
JLayeredPane layeredPane = Singletons.getView().getFrame().getLayeredPane();
int fromZoneX = 0, fromZoneY = 0;
final Point zoneLocation = SwingUtilities.convertPoint(CMatchUI.SINGLETON_INSTANCE
.getFieldControls()
.get(1).getView().getLblLibrary(),
Math.round(rctLibraryLabel.width / 2.0f), Math.round(rctLibraryLabel.height / 2.0f), layeredPane);
fromZoneX = zoneLocation.x;
fromZoneY = zoneLocation.y;
int startWidth, startX, startY;
startWidth = 10;
startX = fromZoneX - Math.round(startWidth / 2.0f);
startY = fromZoneY - Math.round(Math.round(startWidth * forge.view.arcane.CardPanel.ASPECT_RATIO) / 2.0f);
int endWidth, endX, endY;
forge.view.arcane.CardPanel toPanel = null;
for (final Card card : diff) {
toPanel = p.addCard(card);
endWidth = toPanel.getCardWidth();
final Point toPos = SwingUtilities.convertPoint(view.getHandArea(),
toPanel.getCardLocation(), layeredPane);
endX = toPos.x;
endY = toPos.y;
final forge.view.arcane.CardPanel animationPanel = new forge.view.arcane.CardPanel(card);
if (Singletons.getView().getFrame().isShowing()) {
Animation.moveCard(startX, startY, startWidth, endX, endY, endWidth, animationPanel, toPanel,
layeredPane, 500);
} else {
Animation.moveCard(toPanel);
}
}
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@Override
public Command getCommandOnSelect() {
return null;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
}
}

View File

@@ -18,7 +18,6 @@
package forge.gui.match.nonsingleton;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
@@ -30,15 +29,21 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.border.MatteBorder;
import net.miginfocom.swing.MigLayout;
import forge.gui.layout.DragTab;
import forge.gui.layout.EDocID;
import forge.gui.layout.ICDoc;
import forge.gui.layout.IVDoc;
import forge.AllZone;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.mana.ManaPool;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab;
import forge.gui.framework.EDocID;
import forge.gui.framework.ICDoc;
import forge.gui.framework.IVDoc;
import forge.gui.match.controllers.CPlayers;
import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FSkin;
import forge.gui.toolbox.FSkin.SkinProp;
@@ -49,18 +54,30 @@ import forge.view.arcane.PlayArea;
*
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
*/
public enum VField implements IVDoc {
/** */
SINGLETON_INSTANCE;
public class VField implements IVDoc {
// Fields used with interface IVDoc
private final CField control;
private DragCell parentCell;
private final EDocID docID;
private final DragTab tab = new DragTab("Field");
private final JPanel pnl = new JPanel();
private final DragTab tab = new DragTab("Your Battlefield");
// Other fields
private Player player = null;
// Top-level containers
private final JScrollPane scroller = new JScrollPane();
private final PlayArea tabletop = new PlayArea(scroller, true);
private final PlayArea tabletop;
private final JPanel avatarArea = new JPanel();
private final JPanel phaseArea = new JPanel();
private final JPanel pnlDetails = new JPanel();
private final Border inactiveBorder = new LineBorder(new Color(0, 0, 0, 0), 1);
private final Border hoverBorder = new LineBorder(FSkin.getColor(FSkin.Colors.CLR_BORDERS), 1);
// Avatar area
private final JLabel lblAvatar = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.iconScaleFactor(1.0f).build();
private final JLabel lblLife = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.fontStyle(Font.BOLD).build();
// Info labels
private FLabel lblHand = getBuiltFLabel(FSkin.ZoneImages.ICO_HAND, "99", "Cards in hand");
private FLabel lblGraveyard = getBuiltFLabel(FSkin.ZoneImages.ICO_GRAVEYARD, "99", "Cards in graveyard");
private FLabel lblLibrary = getBuiltFLabel(FSkin.ZoneImages.ICO_LIBRARY, "99", "Cards in library");
@@ -74,6 +91,7 @@ public enum VField implements IVDoc {
private FLabel lblWhite = getBuiltFLabel(FSkin.ManaImages.IMG_WHITE, "99", "White mana");
private FLabel lblColorless = getBuiltFLabel(FSkin.ManaImages.IMG_COLORLESS, "99", "Colorless mana");
// Phase labels
private PhaseLabel lblUpkeep = new PhaseLabel("UP");
private PhaseLabel lblDraw = new PhaseLabel("DR");
private PhaseLabel lblMain1 = new PhaseLabel("M1");
@@ -87,44 +105,55 @@ public enum VField implements IVDoc {
private PhaseLabel lblEndTurn = new PhaseLabel("ET");
private PhaseLabel lblCleanup = new PhaseLabel("CL");
private final JPanel avatarArea = new JPanel();
private final JPanel phaseArea = new JPanel();
private final JPanel pnlDetails = new JPanel();
private final JLabel lblAvatar = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.iconScaleFactor(1.0f).build();
private final JLabel lblLife = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.fontStyle(Font.BOLD).build();
private final Color clrHover
= FSkin.getColor(FSkin.Colors.CLR_HOVER);
private final Color clrPhaseActiveEnabled
= FSkin.getColor(FSkin.Colors.CLR_PHASE_ACTIVE_ENABLED);
private final Color clrPhaseActiveDisabled
= FSkin.getColor(FSkin.Colors.CLR_PHASE_ACTIVE_DISABLED);
private final Color clrPhaseInactiveEnabled
= FSkin.getColor(FSkin.Colors.CLR_PHASE_INACTIVE_ENABLED);
private final Color clrPhaseInactiveDisabled
= FSkin.getColor(FSkin.Colors.CLR_PHASE_INACTIVE_DISABLED);
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#populate()
//========= Constructor
/**
* Assembles Swing components of a player field instance.
*
* @param player0 &emsp; {@link forge.game.player.Player}
* @param id0 &emsp; {@link forge.gui.framework.EDocID}
*/
@Override
public void populate() {
// Avatar and life
public VField(final EDocID id0, final Player player0) {
this.docID = id0;
id0.setDoc(this);
this.player = player0;
if (player0 != null) { tab.setText(player0.getName() + " Field"); }
else { tab.setText("NO PLAYER FOR " + docID.toString()); }
// TODO player is hard-coded into tabletop...should be dynamic
// (haven't looked into it too deeply). Doublestrike 12-04-12
tabletop = new PlayArea(scroller,
player.equals(AllZone.getComputerPlayer()) ? true : false);
control = new CField(player, this);
avatarArea.setOpaque(false);
avatarArea.setBackground(FSkin.getColor(FSkin.Colors.CLR_HOVER));
avatarArea.setLayout(new MigLayout("insets 0, gap 0"));
avatarArea.add(lblAvatar, "w 100%!, h 70%!, wrap, gaptop 4%");
avatarArea.add(lblLife, "w 100%!, h 30%!, gaptop 4%");
// Phases
// Player area hover effect
avatarArea.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(final MouseEvent e) {
avatarArea.setOpaque(true);
avatarArea.setBorder(new LineBorder(FSkin.getColor(FSkin.Colors.CLR_BORDERS), 1));
}
@Override
public void mouseExited(final MouseEvent e) {
avatarArea.setOpaque(false);
avatarArea.setBorder(new LineBorder(new Color(0, 0, 0, 0), 1));
}
});
phaseArea.setOpaque(false);
phaseArea.setLayout(new MigLayout("insets 0 0 1% 0, gap 0, wrap"));
populatePhase();
// Play area
tabletop.setBorder(new MatteBorder(0, 1, 0, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS)));
tabletop.setBorder(new MatteBorder(0, 1, 0, 0,
FSkin.getColor(FSkin.Colors.CLR_BORDERS)));
tabletop.setOpaque(false);
scroller.setViewportView(this.tabletop);
@@ -132,56 +161,37 @@ public enum VField implements IVDoc {
scroller.getViewport().setOpaque(false);
scroller.setBorder(null);
// Pool info
pnlDetails.setOpaque(false);
pnlDetails.setLayout(new MigLayout("insets 0, gap 0, wrap"));
populateDetails();
}
// Final layout
pnl.removeAll();
//========= Overridden methods
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#populate()
*/
@Override
public void populate() {
final JPanel pnl = parentCell.getBody();
pnl.setLayout(new MigLayout("insets 0, gap 0"));
pnl.add(avatarArea, "w 10%!, h 30%!");
pnl.add(phaseArea, "w 5%!, h 100%!, span 1 2");
pnl.add(scroller, "w 85%!, h 100%!, span 1 2, wrap");
pnl.add(pnlDetails, "w 10%!, h 69%!, gapleft 1px");
// TODO Player hover effect
/*
avatarArea.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(final MouseEvent e) {
VField.this.avatarArea.setOpaque(true);
VField.this.avatarArea.setBorder(VField.this.hoverBorder);
}
@Override
public void mouseExited(final MouseEvent e) {
VField.this.avatarArea.setOpaque(false);
VField.this.avatarArea.setBorder(VField.this.inactiveBorder);
}
});
*/
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getDocumentID()
* @see forge.gui.framework.IVDoc#getDocumentID()
*/
@Override
public EDocID getDocumentID() {
return EDocID.YOUR_BATTLEFIELD;
return docID;
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getDocument()
*/
@Override
public Component getDocument() {
return pnl;
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getTabLabel()
* @see forge.gui.framework.IVDoc#getTabLabel()
*/
@Override
public DragTab getTabLabel() {
@@ -189,13 +199,31 @@ public enum VField implements IVDoc {
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getControl()
* @see forge.gui.framework.IVDoc#getControl()
*/
@Override
public ICDoc getControl() {
return null;
return control;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#setParentCell()
*/
@Override
public void setParentCell(final DragCell cell0) {
this.parentCell = cell0;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getParentCell()
*/
@Override
public DragCell getParentCell() {
return this.parentCell;
}
//========= Populate helper methods
/** Adds phase indicator labels to phase area JPanel container. */
private void populatePhase() {
// Constraints string, set once
@@ -284,32 +312,39 @@ public enum VField implements IVDoc {
pnlDetails.add(row6, constraintsRow);
}
private FLabel getBuiltFLabel(SkinProp p0, String s0, String s1) {
return new FLabel.Builder().icon(new ImageIcon(FSkin.getImage(p0)))
.opaque(false).fontScaleAuto(false).fontSize(14)
.fontStyle(Font.BOLD).iconAlpha(0.6f).iconInBackground(true)
.text(s0).tooltip(s1).fontAlign(SwingConstants.RIGHT).build();
}
// ========== Observer update methods
/**
* Handles observer update of player Zones - hand, graveyard, etc.
*
* @p aram p0
* &emsp; Player obj
*
* @param p0 &emsp; {@link forge.game.player.Player}
*/
public void updateZones(final Player p0) {
this.getLblHand().setText("" + p0.getZone(Zone.Hand).size());
this.getLblGraveyard().setText("" + p0.getZone(Zone.Graveyard).size());
this.getLblLibrary().setText("" + p0.getZone(Zone.Library).size());
this.getLblHand().setText("" + p0.getZone(ZoneType.Hand).size());
this.getLblGraveyard().setText("" + p0.getZone(ZoneType.Graveyard).size());
this.getLblLibrary().setText("" + p0.getZone(ZoneType.Library).size());
this.getLblFlashback().setText("" + CardFactoryUtil.getExternalZoneActivationCards(p0).size());
this.getLblExile().setText("" + p0.getZone(Zone.Exile).size());
this.getLblExile().setText("" + p0.getZone(ZoneType.Exile).size());
}
/**
* Handles observer update of non-Zone details - life, poison, etc. Also
* updates "players" panel in tabber for this player.
*
* @p aram p0
* &emsp; Player obj
*
* @param p0 &emsp; {@link forge.game.player.Player}
*/
public void updateDetails(final Player p0) {
// "Players" panel update
Singletons.getControl().getControlMatch()
.getTabberControl().getView().updatePlayerLabels(p0);
CPlayers.SINGLETON_INSTANCE.update();
// Mana pool update
updateManaPool(p0);
// Poison/life
this.getLblLife().setText("" + p0.getLife());
@@ -328,28 +363,32 @@ public enum VField implements IVDoc {
else {
this.getLblPoison().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
}
//mana pool
updateManaPool(p0);
}
/**
* Handles observer update of the mana pool.
*
* @p aram p0
* &emsp; Player obj
*
* @param p0 &emsp; {@link forge.game.player.Player}
*/
public void updateManaPool(final Player p0) {
ManaPool m = p0.getManaPool();
getLblBlack().setText("" + m.getAmountOfColor(forge.Constant.Color.BLACK));
getLblBlue().setText("" + m.getAmountOfColor(forge.Constant.Color.BLUE));
getLblGreen().setText("" + m.getAmountOfColor(forge.Constant.Color.GREEN));
getLblRed().setText("" + m.getAmountOfColor(forge.Constant.Color.RED));
getLblWhite().setText("" + m.getAmountOfColor(forge.Constant.Color.WHITE));
getLblColorless().setText("" + m.getAmountOfColor(forge.Constant.Color.COLORLESS));
this.lblBlack.setText("" + m.getAmountOfColor(forge.Constant.Color.BLACK));
this.lblBlue.setText("" + m.getAmountOfColor(forge.Constant.Color.BLUE));
this.lblGreen.setText("" + m.getAmountOfColor(forge.Constant.Color.GREEN));
this.lblRed.setText("" + m.getAmountOfColor(forge.Constant.Color.RED));
this.lblWhite.setText("" + m.getAmountOfColor(forge.Constant.Color.WHITE));
this.lblColorless.setText("" + m.getAmountOfColor(forge.Constant.Color.COLORLESS));
}
//========= Retrieval methods
/**
* Gets the player currently associated with this field.
* @return {@link forge.game.player.Player}
*/
public Player getPlayer() {
return this.player;
}
// ========= Retrieval methods
/**
* Gets the tabletop.
*
@@ -499,19 +538,14 @@ public enum VField implements IVDoc {
return this.lblCleanup;
}
// ========== Custom class handling
private FLabel getBuiltFLabel(SkinProp p0, String s0, String s1) {
return new FLabel.Builder().icon(new ImageIcon(FSkin.getImage(p0)))
.opaque(false).fontScaleFactor(0.5).iconAlpha(0.6f).iconInBackground(true)
.text(s0).tooltip(s1).fontAlign(SwingConstants.RIGHT).build();
}
//========== Custom class handling
/**
* Shows phase labels, handles repainting and on/off states. A PhaseLabel
* has "skip" and "active" states, meaning "this phase is (not) skipped" and
* "this is the current phase".
*/
@SuppressWarnings("serial")
public class PhaseLabel extends JLabel {
private boolean enabled = true;
private boolean active = false;
@@ -613,15 +647,15 @@ public enum VField implements IVDoc {
// Set color according to skip or active or hover state of label
if (this.hover) {
c = clrHover;
c = FSkin.getColor(FSkin.Colors.CLR_HOVER);
} else if (this.active && this.enabled) {
c = clrPhaseActiveEnabled;
c = FSkin.getColor(FSkin.Colors.CLR_PHASE_ACTIVE_ENABLED);
} else if (!this.active && this.enabled) {
c = clrPhaseInactiveEnabled;
c = FSkin.getColor(FSkin.Colors.CLR_PHASE_INACTIVE_ENABLED);
} else if (this.active && !this.enabled) {
c = clrPhaseActiveDisabled;
c = FSkin.getColor(FSkin.Colors.CLR_PHASE_ACTIVE_DISABLED);
} else {
c = clrPhaseInactiveDisabled;
c = FSkin.getColor(FSkin.Colors.CLR_PHASE_INACTIVE_DISABLED);
}
// Center vertically and horizontally. Show border if active.

View File

@@ -17,16 +17,16 @@
*/
package forge.gui.match.nonsingleton;
import java.awt.Component;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import net.miginfocom.swing.MigLayout;
import forge.gui.layout.DragTab;
import forge.gui.layout.EDocID;
import forge.gui.layout.ICDoc;
import forge.gui.layout.IVDoc;
import forge.game.player.Player;
import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab;
import forge.gui.framework.EDocID;
import forge.gui.framework.ICDoc;
import forge.gui.framework.IVDoc;
import forge.view.arcane.HandArea;
/**
@@ -34,56 +34,98 @@ import forge.view.arcane.HandArea;
*
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
*/
public enum VHand implements IVDoc {
/** */
SINGLETON_INSTANCE;
private final JPanel pnl = new JPanel();
public class VHand implements IVDoc {
// Fields used with interface IVDoc
private final CHand control;
private DragCell parentCell;
private final EDocID docID;
private final DragTab tab = new DragTab("Your Hand");
// Other fields
private Player player = null;
// Top-level containers
private final JScrollPane scroller = new JScrollPane();
private final HandArea hand = new HandArea(scroller);
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#populate()
//========= Constructor
/**
* Assembles Swing components of a player hand instance.
*
* @param id0 &emsp; {@link forge.gui.framework.EDocID}
* @param player0 &emsp; {@link forge.game.player.Player}
*/
@Override
public void populate() {
public VHand(final EDocID id0, final Player player0) {
docID = id0;
id0.setDoc(this);
tab.setText(player0.getName() + " Hand");
player = player0;
scroller.setBorder(null);
scroller.setViewportView(VHand.this.hand);
scroller.setOpaque(false);
scroller.getViewport().setOpaque(false);
scroller.setBorder(null);
hand.setOpaque(false);
pnl.removeAll();
control = new CHand(player, this);
}
//========= Overridden methods
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#populate()
*/
@Override
public void populate() {
final JPanel pnl = parentCell.getBody();
pnl.setLayout(new MigLayout("insets 0, gap 0"));
pnl.add(scroller, "w 100%, h 100%!");
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getDocumentID()
* @see forge.gui.framework.IVDoc#getDocumentID()
*/
@Override
public EDocID getDocumentID() {
return EDocID.YOUR_HAND;
return docID;
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getDocument()
* @see forge.gui.framework.IVDoc#setParentCell()
*/
@Override
public Component getDocument() {
return pnl;
public void setParentCell(final DragCell cell0) {
this.parentCell = cell0;
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getTabLabel()
* @see forge.gui.framework.IVDoc#getParentCell()
*/
@Override
public DragCell getParentCell() {
return this.parentCell;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getTabLabel()
*/
@Override
public DragTab getTabLabel() {
return tab;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getControl()
*/
@Override
public ICDoc getControl() {
return control;
}
//========= Retrieval methods
/**
* Gets the hand area.
*
@@ -93,11 +135,20 @@ public enum VHand implements IVDoc {
return VHand.this.hand;
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getControl()
/**
* Gets the player currently associated with this hand.
* @return {@link forge.game.player.Player}
*/
@Override
public ICDoc getControl() {
return null;
public Player getPlayer() {
return this.player;
}
/**
* Sets the player currently associated with this field.
* @param player0 &emsp; {@link forge.game.player.Player}
*/
public void setPlayer(final Player player0) {
this.player = player0;
if (player0 != null) { tab.setText(player0.getName() + " Field"); }
}
}

View File

@@ -17,15 +17,17 @@
*/
package forge.gui.match.views;
import java.awt.Component;
import javax.swing.JPanel;
import forge.gui.layout.DragTab;
import forge.gui.layout.EDocID;
import forge.gui.layout.ICDoc;
import forge.gui.layout.IVDoc;
import forge.gui.toolbox.FSkin;
import net.miginfocom.swing.MigLayout;
import forge.AllZone;
import forge.Card;
import forge.game.player.Player;
import forge.gui.CardPicturePanel;
import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab;
import forge.gui.framework.EDocID;
import forge.gui.framework.ICDoc;
import forge.gui.framework.IVDoc;
import forge.gui.match.controllers.CAntes;
/**
* Assembles Swing components of card ante area.
@@ -36,36 +38,56 @@ public enum VAntes implements IVDoc {
/** */
SINGLETON_INSTANCE;
private final JPanel pnl = new JPanel();
// Fields used with interface IVDoc
private DragCell parentCell;
private final DragTab tab = new DragTab("Ante");
private CardPicturePanel humanAnte = new CardPicturePanel(null);
private CardPicturePanel computerAnte = new CardPicturePanel(null);
//========== Constructor
private VAntes() {
humanAnte.setOpaque(false);
computerAnte.setOpaque(false);
}
//========== Overridden methods
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#populate()
* @see forge.gui.framework.IVDoc#populate()
*/
@Override
public void populate() {
pnl.removeAll();
pnl.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME));
parentCell.getBody().setLayout(new MigLayout("insets 1%, gap 1%"));
parentCell.getBody().add(humanAnte, "w 47%!, h 100%!");
parentCell.getBody().add(computerAnte, "w 47%!, h 100%!");
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getDocumentID()
* @see forge.gui.framework.IVDoc#setParentCell()
*/
@Override
public void setParentCell(final DragCell cell0) {
this.parentCell = cell0;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getParentCell()
*/
@Override
public DragCell getParentCell() {
return this.parentCell;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getDocumentID()
*/
@Override
public EDocID getDocumentID() {
return EDocID.REPORT_STACK;
return EDocID.CARD_ANTES;
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getDocument()
*/
@Override
public Component getDocument() {
return pnl;
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getTabLabel()
* @see forge.gui.framework.IVDoc#getTabLabel()
*/
@Override
public DragTab getTabLabel() {
@@ -73,10 +95,26 @@ public enum VAntes implements IVDoc {
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getControl()
* @see forge.gui.framework.IVDoc#getControl()
*/
@Override
public ICDoc getControl() {
return null;
return CAntes.SINGLETON_INSTANCE;
}
//========== Setters / getters
/**
* @param p0 &emsp; {@link forge.game.player.Player}
* @param c0 &emsp; {@link forge.Card}
*/
public void setAnteCard(final Player p0, final Card c0) {
if (p0.equals(AllZone.getComputerPlayer())) {
computerAnte.setCard(c0);
computerAnte.revalidate();
}
else if (p0.equals(AllZone.getHumanPlayer())) {
humanAnte.setCard(c0);
humanAnte.revalidate();
}
}
}

View File

@@ -17,14 +17,18 @@
*/
package forge.gui.match.views;
import java.awt.Component;
import javax.swing.JTextArea;
import javax.swing.border.Border;
import javax.swing.border.MatteBorder;
import javax.swing.JPanel;
import forge.gui.layout.DragTab;
import forge.gui.layout.EDocID;
import forge.gui.layout.ICDoc;
import forge.gui.layout.IVDoc;
import net.miginfocom.swing.MigLayout;
import forge.AllZone;
import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab;
import forge.gui.framework.EDocID;
import forge.gui.framework.ICDoc;
import forge.gui.framework.IVDoc;
import forge.gui.match.controllers.CCombat;
import forge.gui.toolbox.FSkin;
/**
@@ -36,36 +40,46 @@ public enum VCombat implements IVDoc {
/** */
SINGLETON_INSTANCE;
private final JPanel pnl = new JPanel();
private final DragTab tab = new DragTab("Combat Report");
// Fields used with interface IVDoc
private DragCell parentCell;
private final DragTab tab = new DragTab("Combat");
//========== Overridden methods
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#populate()
* @see forge.gui.framework.IVDoc#populate()
*/
@Override
public void populate() {
pnl.removeAll();
pnl.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME));
// (Panel uses observers to update, no permanent components here.)
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getDocumentID()
* @see forge.gui.framework.IVDoc#setParentCell()
*/
@Override
public void setParentCell(final DragCell cell0) {
this.parentCell = cell0;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getParentCell()
*/
@Override
public DragCell getParentCell() {
return this.parentCell;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getDocumentID()
*/
@Override
public EDocID getDocumentID() {
return EDocID.REPORT_STACK;
return EDocID.REPORT_COMBAT;
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getDocument()
*/
@Override
public Component getDocument() {
return pnl;
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getTabLabel()
* @see forge.gui.framework.IVDoc#getTabLabel()
*/
@Override
public DragTab getTabLabel() {
@@ -73,10 +87,33 @@ public enum VCombat implements IVDoc {
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getControl()
* @see forge.gui.framework.IVDoc#getControl()
*/
@Override
public ICDoc getControl() {
return null;
return CCombat.SINGLETON_INSTANCE;
}
//========= Observer update methods
/** @param s0 &emsp; {@link java.lang.String} */
public void updateCombat(final String s0) {
// No need to update this unless it's showing
if (!parentCell.getSelected().equals(this)) { return; }
parentCell.getBody().removeAll();
parentCell.getBody().setLayout(new MigLayout("insets 0, gap 0, wrap"));
final Border border = new MatteBorder(0, 0, 0, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS));
tab.setText("Combat : " + AllZone.getCombat().getAttackers().size());
final JTextArea tar = new JTextArea(s0);
tar.setOpaque(false);
tar.setBorder(border);
tar.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
tar.setFocusable(false);
tar.setLineWrap(true);
parentCell.getBody().add(tar, "w 95%!, gapleft 3%, gaptop 1%, h 95%");
}
}

View File

@@ -17,17 +17,14 @@
*/
package forge.gui.match.views;
import java.awt.Component;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
import forge.gui.CardDetailPanel;
import forge.gui.layout.DragTab;
import forge.gui.layout.EDocID;
import forge.gui.layout.ICDoc;
import forge.gui.layout.IVDoc;
import forge.gui.toolbox.FSkin;
import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab;
import forge.gui.framework.EDocID;
import forge.gui.framework.ICDoc;
import forge.gui.framework.IVDoc;
import forge.gui.match.controllers.CDetail;
/**
* Assembles Swing components of card detail area.
@@ -38,32 +35,41 @@ public enum VDetail implements IVDoc {
/** */
SINGLETON_INSTANCE;
private final JPanel pnl = new JPanel();
// Fields used with interface IVDoc
private DragCell parentCell;
private final DragTab tab = new DragTab("Card Detail");
// Top-level containers
private final CardDetailPanel pnlDetail = new CardDetailPanel(null);
//========= Overridden methods
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#populate()
* @see forge.gui.framework.IVDoc#populate()
*/
@Override
public void populate() {
pnlDetail.setOpaque(false);
pnl.removeAll();
pnl.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME));
pnl.setLayout(new MigLayout("insets 0, gap 0"));
pnl.add(pnlDetail, "w 100%!, h 100%!");
}
/** @return {@link forge.gui.CardDetailPanel} */
public CardDetailPanel getPnlDetail() {
return pnlDetail;
parentCell.getBody().setLayout(new MigLayout("insets 0, gap 0"));
parentCell.getBody().add(pnlDetail, "w 100%!, h 100%!");
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getDocumentID()
* @see forge.gui.framework.IVDoc#setParentCell()
*/
@Override
public void setParentCell(final DragCell cell0) {
this.parentCell = cell0;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getParentCell()
*/
@Override
public DragCell getParentCell() {
return this.parentCell;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getDocumentID()
*/
@Override
public EDocID getDocumentID() {
@@ -71,15 +77,7 @@ public enum VDetail implements IVDoc {
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getDocument()
*/
@Override
public Component getDocument() {
return pnl;
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getTabLabel()
* @see forge.gui.framework.IVDoc#getTabLabel()
*/
@Override
public DragTab getTabLabel() {
@@ -87,10 +85,17 @@ public enum VDetail implements IVDoc {
}
/* (non-Javadoc)
* @see forge.gui.layout.IVDoc#getControl()
* @see forge.gui.framework.IVDoc#getControl()
*/
@Override
public ICDoc getControl() {
return null;
return CDetail.SINGLETON_INSTANCE;
}
//========= Retrieval methods
/** @return {@link forge.gui.CardDetailPanel} */
public CardDetailPanel getPnlDetail() {
return pnlDetail;
}
}

Some files were not shown because too many files have changed in this diff Show More