mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 17:58:01 +00:00
First attempt at converting the Android code for the GUI refactoring (untested).
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1122,6 +1122,7 @@ forge-gui-mobile/libs/gdx.jar -text
|
||||
forge-gui-mobile/pom.xml -text
|
||||
forge-gui-mobile/src/forge/Forge.java -text
|
||||
forge-gui-mobile/src/forge/Graphics.java -text
|
||||
forge-gui-mobile/src/forge/GuiBase.java -text
|
||||
forge-gui-mobile/src/forge/GuiMobile.java -text
|
||||
forge-gui-mobile/src/forge/animation/AbilityEffect.java -text
|
||||
forge-gui-mobile/src/forge/animation/ForgeAnimation.java -text
|
||||
@@ -1280,6 +1281,7 @@ forge-gui-mobile/src/forge/toolbox/ListChooser.java -text
|
||||
forge-gui-mobile/src/forge/util/LayoutHelper.java -text
|
||||
forge-gui-mobile/src/forge/util/PhysicsObject.java -text
|
||||
forge-gui-mobile/src/forge/util/Utils.java -text
|
||||
forge-gui-mobile/src/forge/util/WaitCallback.java -text
|
||||
forge-gui-mobile/src/forge/util/WaitRunnable.java -text
|
||||
forge-gui/.classpath -text
|
||||
forge-gui/.project -text
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<packaging.type>jar</packaging.type>
|
||||
<build.min.memory>-Xms128m</build.min.memory>
|
||||
<build.max.memory>-Xmx2048m</build.max.memory>
|
||||
<alpha-version>1.5.26.004</alpha-version>
|
||||
<alpha-version>1.5.26.005</alpha-version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
|
||||
@@ -37,7 +37,7 @@ import forge.util.FileUtil;
|
||||
import forge.util.Utils;
|
||||
|
||||
public class Forge implements ApplicationListener {
|
||||
public static final String CURRENT_VERSION = "1.5.26.004";
|
||||
public static final String CURRENT_VERSION = "1.5.26.005";
|
||||
|
||||
private static final ApplicationListener app = new Forge();
|
||||
private static Clipboard clipboard;
|
||||
@@ -49,14 +49,15 @@ public class Forge implements ApplicationListener {
|
||||
private static SplashScreen splashScreen;
|
||||
private static KeyInputAdapter keyInputAdapter;
|
||||
private static boolean exited;
|
||||
private static final SoundSystem soundSystem = new SoundSystem();
|
||||
private static final SoundSystem soundSystem = new SoundSystem(GuiBase.getInterface());
|
||||
private static final Stack<FScreen> screens = new Stack<FScreen>();
|
||||
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0) {
|
||||
if (GuiBase.getInterface() == null) {
|
||||
ForgeConstants.init(assetDir0);
|
||||
clipboard = clipboard0;
|
||||
deviceAdapter = deviceAdapter0;
|
||||
GuiBase.setInterface(new GuiMobile(assetDir0));
|
||||
GuiBase.setInterface(new GuiMobile());
|
||||
}
|
||||
return app;
|
||||
}
|
||||
@@ -67,7 +68,7 @@ public class Forge implements ApplicationListener {
|
||||
@Override
|
||||
public void create() {
|
||||
//install our error handler
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
ExceptionHandler.registerErrorHandling(GuiBase.getInterface());
|
||||
|
||||
graphics = new Graphics();
|
||||
splashScreen = new SplashScreen();
|
||||
@@ -90,7 +91,7 @@ public class Forge implements ApplicationListener {
|
||||
AssetsDownloader.checkForUpdates(splashScreen);
|
||||
if (exited) { return; } //don't continue if user chose to exit or couldn't download required assets
|
||||
|
||||
FModel.initialize(splashScreen.getProgressBar());
|
||||
FModel.initialize(GuiBase.getInterface(), splashScreen.getProgressBar());
|
||||
|
||||
splashScreen.getProgressBar().setDescription("Loading fonts...");
|
||||
FSkinFont.preloadAll();
|
||||
@@ -211,7 +212,7 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
graphics.end();
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +246,7 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
graphics.end();
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +264,7 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
graphics.end();
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +434,7 @@ public class Forge implements ApplicationListener {
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -449,7 +450,7 @@ public class Forge implements ApplicationListener {
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -465,7 +466,7 @@ public class Forge implements ApplicationListener {
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -481,7 +482,7 @@ public class Forge implements ApplicationListener {
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -497,7 +498,7 @@ public class Forge implements ApplicationListener {
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -513,7 +514,7 @@ public class Forge implements ApplicationListener {
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -529,7 +530,7 @@ public class Forge implements ApplicationListener {
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -545,7 +546,7 @@ public class Forge implements ApplicationListener {
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
14
forge-gui-mobile/src/forge/GuiBase.java
Normal file
14
forge-gui-mobile/src/forge/GuiBase.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package forge;
|
||||
|
||||
import forge.interfaces.IGuiBase;
|
||||
|
||||
public class GuiBase {
|
||||
private static IGuiBase guiInterface;
|
||||
|
||||
public static IGuiBase getInterface() {
|
||||
return guiInterface;
|
||||
}
|
||||
public static void setInterface(IGuiBase i0) {
|
||||
guiInterface = i0;
|
||||
}
|
||||
}
|
||||
@@ -25,19 +25,11 @@ import forge.deck.FDeckViewer;
|
||||
import forge.deck.FSideboardDialog;
|
||||
import forge.error.BugReportDialog;
|
||||
import forge.events.UiEvent;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameType;
|
||||
import forge.game.Match;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.event.GameEventTurnBegan;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.IHasIcon;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.interfaces.IButton;
|
||||
import forge.interfaces.IGuiBase;
|
||||
@@ -61,13 +53,15 @@ import forge.util.ThreadUtil;
|
||||
import forge.util.WaitCallback;
|
||||
import forge.util.WaitRunnable;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.SpellAbilityView;
|
||||
|
||||
public class GuiMobile implements IGuiBase {
|
||||
|
||||
private final String assetsDir;
|
||||
|
||||
public GuiMobile(String assetsDir0) {
|
||||
assetsDir = assetsDir0;
|
||||
public GuiMobile() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,16 +99,6 @@ public class GuiMobile implements IGuiBase {
|
||||
return !ThreadUtil.isGameThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssetsDir() {
|
||||
return assetsDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayShowCard(Card card) {
|
||||
return FControl.mayShowCard(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkinImage getSkinIcon(FSkinProp skinProp) {
|
||||
if (skinProp == null) { return null; }
|
||||
@@ -137,7 +121,7 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int showCardOptionDialog(final Card card, final String message, final String title, final FSkinProp icon, final String[] options, final int defaultOption) {
|
||||
public int showCardOptionDialog(final CardView card, final String message, final String title, final FSkinProp icon, final String[] options, final int defaultOption) {
|
||||
return new WaitCallback<Integer>() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -168,7 +152,7 @@ public class GuiMobile implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public <T> List<T> order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
final List<T> sourceChoices, final List<T> destChoices, final Card referenceCard, final boolean sideboardingMode) {
|
||||
final List<T> sourceChoices, final List<T> destChoices, final CardView referenceCard, final boolean sideboardingMode) {
|
||||
return new WaitCallback<List<T>>() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -230,9 +214,8 @@ public class GuiMobile implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public void updatePhase() {
|
||||
PhaseHandler pH = FControl.getGame().getPhaseHandler();
|
||||
Player p = pH.getPlayerTurn();
|
||||
PhaseType ph = pH.getPhase();
|
||||
final PlayerView p = FControl.getGameView().getPlayerTurn();
|
||||
final PhaseType ph = FControl.getGameView().getPhase();
|
||||
|
||||
PhaseLabel lbl = FControl.getPlayerPanel(p).getPhaseIndicator().getLabel(ph);
|
||||
|
||||
@@ -243,7 +226,7 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTurn(final GameEventTurnBegan event, final Game game) {
|
||||
public void updateTurn(final PlayerView player) {
|
||||
//VField nextField = FControl.getFieldViewFor(event.turnOwner);
|
||||
//SDisplayUtil.showTab(nextField);
|
||||
}
|
||||
@@ -263,7 +246,7 @@ public class GuiMobile implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public void finishGame() {
|
||||
new ViewWinLose(FControl.getGame()).setVisible(true);
|
||||
new ViewWinLose(FControl.getGameView()).setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -277,19 +260,19 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPanelSelection(Card c) {
|
||||
public void setPanelSelection(final CardView c) {
|
||||
//GuiUtils.setPanelSelection(c); //TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility getAbilityToPlay(List<SpellAbility> abilities, ITriggerEvent triggerEvent) {
|
||||
public SpellAbilityView getAbilityToPlay(List<SpellAbilityView> abilities, ITriggerEvent triggerEvent) {
|
||||
if (abilities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (abilities.size() == 1) {
|
||||
return abilities.get(0);
|
||||
}
|
||||
return SGuiChoose.oneOrNone("Choose ability to play", abilities);
|
||||
return SGuiChoose.oneOrNone(this, "Choose ability to play", abilities);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -311,22 +294,22 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCard(Card card) {
|
||||
public void setCard(final CardView card) {
|
||||
//doesn't need to do anything
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCombat(Combat combat) {
|
||||
public void showCombat(final CombatView combat) {
|
||||
FControl.showCombat(combat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsedToPay(Card card, boolean b) {
|
||||
public void setUsedToPay(final CardView card, final boolean b) {
|
||||
FControl.setUsedToPay(card, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHighlighted(Player player, boolean b) {
|
||||
public void setHighlighted(final PlayerView player, boolean b) {
|
||||
FControl.setHighlighted(player, b);
|
||||
}
|
||||
|
||||
@@ -336,7 +319,7 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopAtPhase(Player playerTurn, PhaseType phase) {
|
||||
public boolean stopAtPhase(final PlayerView playerTurn, final PhaseType phase) {
|
||||
return FControl.stopAtPhase(playerTurn, phase);
|
||||
}
|
||||
|
||||
@@ -346,12 +329,7 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Game getGame() {
|
||||
return FControl.getGame();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object showManaPool(Player player) {
|
||||
public Object showManaPool(final PlayerView player) {
|
||||
VPlayerPanel playerPanel = FControl.getPlayerPanel(player);
|
||||
InfoTab oldSelectedTab = playerPanel.getSelectedTab();
|
||||
playerPanel.setSelectedTab(playerPanel.getManaPoolTab());
|
||||
@@ -359,7 +337,7 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideManaPool(Player player, Object zoneToRestore) {
|
||||
public void hideManaPool(final PlayerView player, final Object zoneToRestore) {
|
||||
VPlayerPanel playerPanel = FControl.getPlayerPanel(player);
|
||||
if (zoneToRestore == playerPanel.getManaPoolTab()) {
|
||||
return; //if mana pool was selected previously, we don't need to switch back to anything
|
||||
@@ -371,9 +349,9 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openZones(List<ZoneType> zones, Map<Player, Object> players) {
|
||||
public boolean openZones(Collection<ZoneType> zones, Map<PlayerView, Object> players) {
|
||||
if (zones.size() == 1) {
|
||||
ZoneType zoneType = zones.get(0);
|
||||
ZoneType zoneType = zones.iterator().next();
|
||||
switch (zoneType) {
|
||||
case Battlefield:
|
||||
case Command:
|
||||
@@ -382,7 +360,7 @@ public class GuiMobile implements IGuiBase {
|
||||
default:
|
||||
//open zone tab for given zone if needed
|
||||
boolean result = true;
|
||||
for (Player player : players.keySet()) {
|
||||
for (PlayerView player : players.keySet()) {
|
||||
VPlayerPanel playerPanel = FControl.getPlayerPanel(player);
|
||||
players.put(player, playerPanel.getSelectedTab()); //backup selected tab before changing it
|
||||
InfoTab zoneTab = playerPanel.getZoneTab(zoneType);
|
||||
@@ -400,35 +378,35 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreOldZones(Map<Player, Object> playersToRestoreZonesFor) {
|
||||
for (Entry<Player, Object> player : playersToRestoreZonesFor.entrySet()) {
|
||||
public void restoreOldZones(Map<PlayerView, Object> playersToRestoreZonesFor) {
|
||||
for (Entry<PlayerView, Object> player : playersToRestoreZonesFor.entrySet()) {
|
||||
VPlayerPanel playerPanel = FControl.getPlayerPanel(player.getKey());
|
||||
playerPanel.setSelectedTab((InfoTab)player.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateZones(List<Pair<Player, ZoneType>> zonesToUpdate) {
|
||||
public void updateZones(List<Pair<PlayerView, ZoneType>> zonesToUpdate) {
|
||||
FControl.updateZones(zonesToUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCards(Set<Card> cardsToUpdate) {
|
||||
public void updateCards(Set<CardView> cardsToUpdate) {
|
||||
FControl.updateCards(cardsToUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshCardDetails(Collection<Card> cards) {
|
||||
public void refreshCardDetails(Iterable<CardView> cards) {
|
||||
FControl.refreshCardDetails(cards);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateManaPool(List<Player> manaPoolUpdate) {
|
||||
public void updateManaPool(List<PlayerView> manaPoolUpdate) {
|
||||
FControl.updateManaPool(manaPoolUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLives(List<Player> livesUpdate) {
|
||||
public void updateLives(List<PlayerView> livesUpdate) {
|
||||
FControl.updateLives(livesUpdate);
|
||||
}
|
||||
|
||||
@@ -438,8 +416,8 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Card, Integer> getDamageToAssign(Card attacker, List<Card> blockers,
|
||||
int damageDealt, GameEntity defender, boolean overrideOrder) {
|
||||
public Map<CardView, Integer> getDamageToAssign(CardView attacker, List<CardView> blockers,
|
||||
int damageDealt, GameEntityView defender, boolean overrideOrder) {
|
||||
return FControl.getDamageToAssign(attacker, blockers,
|
||||
damageDealt, defender, overrideOrder);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.GuiBase;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.screens.SplashScreen;
|
||||
import forge.toolbox.FProgressBar;
|
||||
@@ -51,7 +52,7 @@ public class AssetsDownloader {
|
||||
if (!Forge.getDeviceAdapter().isConnectedToWifi()) {
|
||||
message += " If so, you may want to connect to wifi first. The download is around 6.5MB.";
|
||||
}
|
||||
if (SOptionPane.showConfirmDialog(message, "New Version Available", "Update Now", "Update Later")) {
|
||||
if (SOptionPane.showConfirmDialog(GuiBase.getInterface(), message, "New Version Available", "Update Now", "Update Later")) {
|
||||
String apkFile = downloadFile("update", "forge-android-" + version + "-signed-aligned.apk",
|
||||
"http://cardforge.org/android/releases/forge/forge-gui-android/" + version + "/",
|
||||
Forge.getDeviceAdapter().getDownloadsDir(), splashScreen.getProgressBar());
|
||||
@@ -60,7 +61,7 @@ public class AssetsDownloader {
|
||||
Forge.exit(true);
|
||||
return;
|
||||
}
|
||||
SOptionPane.showMessageDialog("Could not download update. " +
|
||||
SOptionPane.showMessageDialog(GuiBase.getInterface(), "Could not download update. " +
|
||||
"Press OK to proceed without update.", "Update Failed");
|
||||
}
|
||||
}
|
||||
@@ -98,7 +99,7 @@ public class AssetsDownloader {
|
||||
else {
|
||||
message += "You cannot start the app since you haven't previously downloaded these files.";
|
||||
}
|
||||
SOptionPane.showMessageDialog(message, "No Internet Connection");
|
||||
SOptionPane.showMessageDialog(GuiBase.getInterface(), message, "No Internet Connection");
|
||||
if (!canIgnoreDownload) {
|
||||
Forge.exit(true); //exit if can't ignore download
|
||||
}
|
||||
@@ -124,7 +125,7 @@ public class AssetsDownloader {
|
||||
message += "This download is mandatory to start the app since you haven't previously downloaded these files.";
|
||||
options = new String[] { "Download", "Exit" };
|
||||
}
|
||||
switch (SOptionPane.showOptionDialog(message, "Download Resource Files?",
|
||||
switch (SOptionPane.showOptionDialog(GuiBase.getInterface(), message, "Download Resource Files?",
|
||||
null, options)) {
|
||||
case 1:
|
||||
if (!canIgnoreDownload) {
|
||||
@@ -141,7 +142,7 @@ public class AssetsDownloader {
|
||||
FSkinFont.deleteCachedFiles(); //delete cached font files in case any skin's .ttf file changed
|
||||
|
||||
//reload light version of skin after assets updated
|
||||
FThreads.invokeInEdtAndWait(new Runnable() {
|
||||
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FSkinFont.updateAll(); //update all fonts used by splash screen
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.badlogic.gdx.math.Matrix4;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Graphics;
|
||||
import forge.GuiBase;
|
||||
|
||||
//Special graphics object for rendering to a texture
|
||||
public abstract class FBufferedImage extends FImageComplex {
|
||||
@@ -72,7 +73,7 @@ public abstract class FBufferedImage extends FImageComplex {
|
||||
final FrameBuffer fb = frameBuffer;
|
||||
if (fb != null) {
|
||||
frameBuffer = null;
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fb.dispose(); //must be disposed on EDT thread
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinImage.SourceFile;
|
||||
import forge.card.CardFaceSymbols;
|
||||
import forge.card.CardImageRenderer;
|
||||
@@ -51,7 +52,7 @@ public class FSkin {
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadLight(skinName, null);
|
||||
@@ -63,7 +64,7 @@ public class FSkin {
|
||||
FSkinFont.deleteCachedFiles(); //delete cached font files so font can be update for new skin
|
||||
FSkinFont.updateAll();
|
||||
CardImageRenderer.forceStaticFieldUpdate();
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loader.hide();
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.badlogic.gdx.graphics.glutils.PixmapTextureData;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.Utils;
|
||||
@@ -163,7 +164,7 @@ public class FSkinFont {
|
||||
FileHandle fontFile = Gdx.files.absolute(ForgeConstants.FONTS_DIR + fontName + ".fnt");
|
||||
if (fontFile != null && fontFile.exists()) {
|
||||
final BitmapFontData data = new BitmapFontData(fontFile, false);
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() { //font must be initialized on UI thread
|
||||
font = new BitmapFont(data, (TextureRegion)null, true);
|
||||
@@ -202,7 +203,7 @@ public class FSkinFont {
|
||||
final Array<PixmapPacker.Page> pages = packer.getPages();
|
||||
|
||||
//finish generating font on UI thread
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TextureRegion[] textureRegions = new TextureRegion[pages.size];
|
||||
|
||||
@@ -24,12 +24,11 @@ import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
||||
import forge.ImageKeys;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.IHasIcon;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.PaperCard;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.view.CardView;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -80,14 +79,8 @@ public class ImageCache {
|
||||
missingIconKeys.clear();
|
||||
}
|
||||
|
||||
public static Texture getImage(Card card) {
|
||||
final String key;
|
||||
if (!FControl.mayShowCard(card) || card.isFaceDown()) {
|
||||
key = ImageKeys.TOKEN_PREFIX + ImageKeys.MORPH_IMAGE;
|
||||
}
|
||||
else {
|
||||
key = card.getImageKey();
|
||||
}
|
||||
public static Texture getImage(CardView card) {
|
||||
final String key = card.getOriginal().getImageKey();
|
||||
return getImage(key, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package forge.card;
|
||||
|
||||
import forge.Graphics;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
@@ -178,7 +179,7 @@ public class CardFaceSymbols {
|
||||
String symbol = tok.nextToken();
|
||||
FSkinImage image = MANA_IMAGES.get(symbol);
|
||||
if (image == null) {
|
||||
BugReporter.reportBug("Symbol not recognized \"" + symbol + "\" in string: " + s);
|
||||
BugReporter.reportBug(GuiBase.getInterface(), "Symbol not recognized \"" + symbol + "\" in string: " + s);
|
||||
continue;
|
||||
}
|
||||
g.drawImage(image, x, y, w, h);
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
|
||||
import forge.Graphics;
|
||||
import forge.assets.FBufferedImage;
|
||||
import forge.assets.FSkinColor;
|
||||
@@ -16,8 +17,9 @@ import forge.assets.FSkinTexture;
|
||||
import forge.assets.TextRenderer;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.card.Card;
|
||||
import forge.screens.FScreen;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
public class CardImageRenderer {
|
||||
private static final float BASE_IMAGE_WIDTH = 360;
|
||||
@@ -54,9 +56,9 @@ public class CardImageRenderer {
|
||||
prevImageHeight = h;
|
||||
}
|
||||
|
||||
public static void drawCardImage(Graphics g, Card card, float x, float y, float w, float h) {
|
||||
card = card.getCardForUi();
|
||||
public static void drawCardImage(Graphics g, CardView card, float x, float y, float w, float h) {
|
||||
updateStaticFields(w, h);
|
||||
final CardStateView state = card.getOriginal();
|
||||
|
||||
float blackBorderThickness = w * CardRenderer.BLACK_BORDER_THICKNESS_RATIO;
|
||||
g.fillRect(Color.BLACK, x, y, w, h);
|
||||
@@ -66,7 +68,7 @@ public class CardImageRenderer {
|
||||
h -= 2 * blackBorderThickness;
|
||||
|
||||
//determine colors for borders
|
||||
List<DetailColors> borderColors = CardDetailUtil.getBorderColors(card, true, true);
|
||||
final List<DetailColors> borderColors = CardDetailUtil.getBorderColors(card.getOriginal());
|
||||
DetailColors borderColor = borderColors.get(0);
|
||||
Color color1 = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b);
|
||||
Color color2 = null;
|
||||
@@ -99,7 +101,7 @@ public class CardImageRenderer {
|
||||
float typeBoxHeight = 2 * TYPE_FONT.getCapHeight();
|
||||
float ptBoxHeight = 0;
|
||||
float textBoxHeight = h - headerHeight - artHeight - typeBoxHeight - outerBorderThickness - artInset;
|
||||
if (card.isCreature() || card.isPlaneswalker()) {
|
||||
if (state.isCreature() || state.isPlaneswalker()) {
|
||||
//if P/T box needed, make room for it
|
||||
ptBoxHeight = 2 * PT_FONT.getCapHeight();
|
||||
textBoxHeight -= ptBoxHeight;
|
||||
@@ -143,7 +145,7 @@ public class CardImageRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawHeader(Graphics g, Card card, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
private static void drawHeader(Graphics g, CardView card, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
if (color2 == null) {
|
||||
g.fillRect(color1, x, y, w, h);
|
||||
}
|
||||
@@ -154,13 +156,14 @@ public class CardImageRenderer {
|
||||
|
||||
float padding = h / 8;
|
||||
|
||||
final CardStateView state = card.getOriginal();
|
||||
//draw mana cost for card
|
||||
float manaCostWidth = 0;
|
||||
ManaCost mainManaCost = card.getManaCost();
|
||||
if (card.isSplitCard() && card.getCurState() == CardCharacteristicName.Original) {
|
||||
ManaCost mainManaCost = state.getManaCost();
|
||||
if (card.isSplitCard() && card.hasAltState()) {
|
||||
//handle rendering both parts of split card
|
||||
mainManaCost = card.getRules().getMainPart().getManaCost();
|
||||
ManaCost otherManaCost = card.getRules().getOtherPart().getManaCost();
|
||||
mainManaCost = state.getManaCost();
|
||||
ManaCost otherManaCost = card.getAlternate().getManaCost();
|
||||
manaCostWidth = CardFaceSymbols.getWidth(otherManaCost, MANA_SYMBOL_SIZE) + HEADER_PADDING;
|
||||
CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE);
|
||||
//draw "//" between two parts of mana cost
|
||||
@@ -173,7 +176,7 @@ public class CardImageRenderer {
|
||||
//draw name for card
|
||||
x += padding;
|
||||
w -= 2 * padding;
|
||||
g.drawText(card.getName(), NAME_FONT, Color.BLACK, x, y, w - manaCostWidth - padding, h, false, HAlignment.LEFT, true);
|
||||
g.drawText(state.getName(), NAME_FONT, Color.BLACK, x, y, w - manaCostWidth - padding, h, false, HAlignment.LEFT, true);
|
||||
}
|
||||
|
||||
public static final FBufferedImage forgeArt;
|
||||
@@ -197,7 +200,7 @@ public class CardImageRenderer {
|
||||
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
|
||||
}
|
||||
|
||||
private static void drawTypeLine(Graphics g, Card card, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
private static void drawTypeLine(Graphics g, CardView card, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
if (color2 == null) {
|
||||
g.fillRect(color1, x, y, w, h);
|
||||
}
|
||||
@@ -216,13 +219,13 @@ public class CardImageRenderer {
|
||||
|
||||
//draw type
|
||||
x += padding;
|
||||
g.drawText(CardDetailUtil.formatCardType(card), TYPE_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true);
|
||||
g.drawText(CardDetailUtil.formatCardType(card.getOriginal()), TYPE_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true);
|
||||
}
|
||||
|
||||
//use text g to handle mana symbols and reminder text
|
||||
private static final TextRenderer cardTextRenderer = new TextRenderer(true);
|
||||
|
||||
private static void drawTextBox(Graphics g, Card card, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
private static void drawTextBox(Graphics g, CardView card, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
if (color2 == null) {
|
||||
g.fillRect(color1, x, y, w, h);
|
||||
}
|
||||
@@ -231,10 +234,11 @@ public class CardImageRenderer {
|
||||
}
|
||||
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
|
||||
|
||||
if (card.isBasicLand()) {
|
||||
final CardStateView state = card.getOriginal();
|
||||
if (state.isBasicLand()) {
|
||||
//draw icons for basic lands
|
||||
FSkinImage image;
|
||||
switch (card.getName()) {
|
||||
switch (state.getName()) {
|
||||
case "Plains":
|
||||
image = FSkinImage.MANA_W;
|
||||
break;
|
||||
@@ -255,11 +259,9 @@ public class CardImageRenderer {
|
||||
g.drawImage(image, x + (w - iconSize) / 2, y + (h - iconSize) / 2, iconSize, iconSize);
|
||||
}
|
||||
else {
|
||||
String text = card.getOracleText();
|
||||
final String text = card.getOriginal().getText();
|
||||
if (StringUtils.isEmpty(text)) { return; }
|
||||
|
||||
text = text.replace("\\n", "\n"); //replace new line placeholders with actual new line characters
|
||||
|
||||
float padding = TEXT_FONT.getCapHeight() * 0.75f;
|
||||
x += padding;
|
||||
y += padding;
|
||||
@@ -269,15 +271,16 @@ public class CardImageRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawPtBox(Graphics g, Card card, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
private static void drawPtBox(Graphics g, CardView card, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
final CardStateView state = card.getOriginal();
|
||||
List<String> pieces = new ArrayList<String>();
|
||||
if (card.isCreature()) {
|
||||
pieces.add(String.valueOf(card.getBaseAttack()));
|
||||
if (state.isCreature()) {
|
||||
pieces.add(String.valueOf(state.getPower()));
|
||||
pieces.add("/");
|
||||
pieces.add(String.valueOf(card.getBaseDefense()));
|
||||
pieces.add(String.valueOf(state.getToughness()));
|
||||
}
|
||||
else if (card.isPlaneswalker()) {
|
||||
pieces.add(String.valueOf(card.getBaseLoyalty()));
|
||||
else if (state.isPlaneswalker()) {
|
||||
pieces.add(String.valueOf(state.getLoyalty()));
|
||||
}
|
||||
else { return; }
|
||||
|
||||
|
||||
@@ -23,18 +23,20 @@ import forge.assets.ImageCache;
|
||||
import forge.assets.TextRenderer;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.screens.match.FControl.CardDetails;
|
||||
import forge.toolbox.FCardPanel;
|
||||
import forge.toolbox.FDialog;
|
||||
import forge.toolbox.FList;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
public class CardRenderer {
|
||||
private static final FSkinFont NAME_FONT = FSkinFont.get(16);
|
||||
@@ -72,16 +74,13 @@ public class CardRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean drawZoom(Graphics g, Card card, float width, float height) {
|
||||
public static boolean drawZoom(Graphics g, CardView card, float width, float height) {
|
||||
float x = FDialog.INSETS;
|
||||
float y = FDialog.INSETS;
|
||||
float w = width - 2 * x;
|
||||
float h = height - 2 * y;
|
||||
|
||||
final Texture image;
|
||||
boolean canShow = FControl.mayShowCard(card) || FDialog.isDialogOpen(); //support showing if card revealed in dialog
|
||||
if (canShow) {
|
||||
image = ImageCache.getImage(card.getImageKey(), true);
|
||||
final Texture image = ImageCache.getImage(card.getOriginal().getImageKey(), true);
|
||||
if (image == ImageCache.defaultImage) { //support drawing card image manually if card image not found
|
||||
float ratio = h / w;
|
||||
if (ratio > FCardPanel.ASPECT_RATIO) {
|
||||
@@ -98,10 +97,7 @@ public class CardRenderer {
|
||||
drawFoilEffect(g, card, x, y, w, h);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else { //only show card back if can't show card
|
||||
image = ImageCache.getImage(ImageKeys.TOKEN_PREFIX + ImageKeys.MORPH_IMAGE, true);
|
||||
}
|
||||
|
||||
if (image == null || image == ImageCache.defaultImage) { return false; } //don't support drawing zoom for null or default textures
|
||||
|
||||
float imageWidth = image.getWidth();
|
||||
@@ -134,15 +130,11 @@ public class CardRenderer {
|
||||
x = (width - imageWidth) / 2;
|
||||
y = (height - imageHeight) / 2;
|
||||
g.drawImage(image, x, y, imageWidth, imageHeight);
|
||||
if (canShow) {
|
||||
drawFoilEffect(g, card, x, y, w, h);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void drawDetails(Graphics g, Card card, float width, float height) {
|
||||
card = card.getCardForUi();
|
||||
|
||||
public static void drawDetails(Graphics g, CardView card, float width, float height) {
|
||||
float x = FDialog.INSETS;
|
||||
float y = FDialog.INSETS;
|
||||
float w = width - 2 * x;
|
||||
@@ -160,8 +152,6 @@ public class CardRenderer {
|
||||
x += (oldWidth - w) / 2;
|
||||
}
|
||||
|
||||
boolean canShow = FControl.mayShowCard(card) || FDialog.isDialogOpen(); //support showing if card revealed in dialog
|
||||
|
||||
float blackBorderThickness = w * BLACK_BORDER_THICKNESS_RATIO;
|
||||
g.fillRect(Color.BLACK, x, y, w, h);
|
||||
x += blackBorderThickness;
|
||||
@@ -170,7 +160,7 @@ public class CardRenderer {
|
||||
h -= 2 * blackBorderThickness;
|
||||
|
||||
//determine colors for borders
|
||||
List<DetailColors> borderColors = CardDetailUtil.getBorderColors(card, canShow, true);
|
||||
List<DetailColors> borderColors = CardDetailUtil.getBorderColors(card.getOriginal());
|
||||
DetailColors borderColor = borderColors.get(0);
|
||||
Color color1 = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b);
|
||||
Color color2 = null;
|
||||
@@ -196,7 +186,7 @@ public class CardRenderer {
|
||||
//draw name/type box
|
||||
Color nameBoxColor1 = FSkinColor.tintColor(Color.WHITE, color1, NAME_BOX_TINT);
|
||||
Color nameBoxColor2 = color2 == null ? null : FSkinColor.tintColor(Color.WHITE, color2, NAME_BOX_TINT);
|
||||
drawCardNameBox(g, card, canShow, nameBoxColor1, nameBoxColor2, x, y, w, cardNameBoxHeight);
|
||||
drawCardNameBox(g, card, nameBoxColor1, nameBoxColor2, x, y, w, cardNameBoxHeight);
|
||||
|
||||
float innerBorderThickness = outerBorderThickness / 2;
|
||||
float ptBoxHeight = 2 * PT_FONT.getCapHeight();
|
||||
@@ -205,15 +195,13 @@ public class CardRenderer {
|
||||
y += cardNameBoxHeight + innerBorderThickness;
|
||||
Color textBoxColor1 = FSkinColor.tintColor(Color.WHITE, color1, TEXT_BOX_TINT);
|
||||
Color textBoxColor2 = color2 == null ? null : FSkinColor.tintColor(Color.WHITE, color2, TEXT_BOX_TINT);
|
||||
drawCardTextBox(g, card, canShow, textBoxColor1, textBoxColor2, x, y, w, textBoxHeight);
|
||||
drawCardTextBox(g, card, textBoxColor1, textBoxColor2, x, y, w, textBoxHeight);
|
||||
|
||||
if (canShow) {
|
||||
y += textBoxHeight + innerBorderThickness;
|
||||
Color ptColor1 = FSkinColor.tintColor(Color.WHITE, color1, PT_BOX_TINT);
|
||||
Color ptColor2 = color2 == null ? null : FSkinColor.tintColor(Color.WHITE, color2, PT_BOX_TINT);
|
||||
drawCardIdAndPtBox(g, card, idForeColor, ptColor1, ptColor2, x, y, w, ptBoxHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getCardListItemHeight(boolean compactMode) {
|
||||
if (compactMode) {
|
||||
@@ -229,8 +217,8 @@ public class CardRenderer {
|
||||
public static FImageComplex getCardArt(IPaperCard pc) {
|
||||
return getCardArt(ImageKeys.getImageKey(pc, false), pc.getRules().getSplitType() == CardSplitType.Split);
|
||||
}
|
||||
public static FImageComplex getCardArt(Card card) {
|
||||
return getCardArt(card.getImageKey(), card.isSplitCard());
|
||||
public static FImageComplex getCardArt(CardView card) {
|
||||
return getCardArt(card.getOriginal().getImageKey(), card.isSplitCard());
|
||||
}
|
||||
public static FImageComplex getCardArt(String imageKey, boolean isSplitCard) {
|
||||
FImageComplex cardArt = cardArtCache.get(imageKey);
|
||||
@@ -274,16 +262,14 @@ public class CardRenderer {
|
||||
return cardArt;
|
||||
}
|
||||
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, Card card, int count, String suffix, float x, float y, float w, float h, boolean compactMode) {
|
||||
card = card.getCardForUi();
|
||||
CardRules cardRules = card.getRules();
|
||||
if (cardRules != null) {
|
||||
drawCardListItem(g, font, foreColor, getCardArt(card), cardRules, card.getCurSetCode(),
|
||||
card.getRarity(), card.getNetAttack(), card.getNetDefense(),
|
||||
card.getCurrentLoyalty(), count, suffix, x, y, w, h, compactMode);
|
||||
}
|
||||
else { //if fake card, just draw card name centered
|
||||
String name = card.getName();
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, CardView card, int count, String suffix, float x, float y, float w, float h, boolean compactMode) {
|
||||
final CardStateView state = card.getOriginal();
|
||||
if (card.isUiDisplayable()) {
|
||||
drawCardListItem(g, font, foreColor, getCardArt(card), card, card.getSetCode(),
|
||||
card.getRarity(), state.getPower(), state.getToughness(),
|
||||
state.getLoyalty(), count, suffix, x, y, w, h, compactMode);
|
||||
} else { //if fake card, just draw card name centered
|
||||
String name = state.getName();
|
||||
if (count > 0) { //preface name with count if applicable
|
||||
name = count + " " + name;
|
||||
}
|
||||
@@ -294,11 +280,12 @@ public class CardRenderer {
|
||||
}
|
||||
}
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, IPaperCard pc, int count, String suffix, float x, float y, float w, float h, boolean compactMode) {
|
||||
CardRules cardRules = pc.getRules();
|
||||
if (cardRules != null) {
|
||||
drawCardListItem(g, font, foreColor, getCardArt(pc), cardRules, pc.getEdition(),
|
||||
pc.getRarity(), cardRules.getIntPower(), cardRules.getIntToughness(),
|
||||
cardRules.getInitialLoyalty(), count, suffix, x, y, w, h, compactMode);
|
||||
final CardView card = ViewUtil.getCardForUi(pc);
|
||||
if (card.isUiDisplayable()) {
|
||||
final CardStateView state = card.getOriginal();
|
||||
drawCardListItem(g, font, foreColor, getCardArt(pc), card, pc.getEdition(),
|
||||
pc.getRarity(), state.getPower(), state.getToughness(),
|
||||
state.getLoyalty(), count, suffix, x, y, w, h, compactMode);
|
||||
}
|
||||
else { //if fake card, just draw card name centered
|
||||
String name = pc.getName();
|
||||
@@ -311,13 +298,13 @@ public class CardRenderer {
|
||||
g.drawText(name, font, foreColor, x, y, w, h, false, HAlignment.CENTER, true);
|
||||
}
|
||||
}
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, FImageComplex cardArt, CardRules cardRules, String set, CardRarity rarity, int power, int toughness, int loyalty, int count, String suffix, float x, float y, float w, float h, boolean compactMode) {
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, FImageComplex cardArt, CardView card, String set, CardRarity rarity, int power, int toughness, int loyalty, int count, String suffix, float x, float y, float w, float h, boolean compactMode) {
|
||||
float cardArtHeight = h + 2 * FList.PADDING;
|
||||
float cardArtWidth = cardArtHeight * CARD_ART_RATIO;
|
||||
if (cardArt != null) {
|
||||
float artX = x - FList.PADDING;
|
||||
float artY = y - FList.PADDING;
|
||||
if (cardRules.getSplitType() == CardSplitType.Split) {
|
||||
if (card.isSplitCard()) {
|
||||
//draw split art with proper orientation
|
||||
float srcY = cardArt.getHeight() * 13f / 354f;
|
||||
float srcHeight = cardArt.getHeight() * 150f / 354f;
|
||||
@@ -334,10 +321,10 @@ public class CardRenderer {
|
||||
|
||||
//render card name and mana cost on first line
|
||||
float manaCostWidth = 0;
|
||||
ManaCost mainManaCost = cardRules.getMainPart().getManaCost();
|
||||
if (cardRules.getSplitType() == CardSplitType.Split) {
|
||||
ManaCost mainManaCost = card.getOriginal().getManaCost();
|
||||
if (card.isSplitCard()) {
|
||||
//handle rendering both parts of split card
|
||||
ManaCost otherManaCost = cardRules.getOtherPart().getManaCost();
|
||||
ManaCost otherManaCost = card.getAlternate().getManaCost();
|
||||
manaCostWidth = CardFaceSymbols.getWidth(otherManaCost, MANA_SYMBOL_SIZE) + MANA_COST_PADDING;
|
||||
CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth + MANA_COST_PADDING, y, MANA_SYMBOL_SIZE);
|
||||
//draw "//" between two parts of mana cost
|
||||
@@ -348,7 +335,7 @@ public class CardRenderer {
|
||||
CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y, MANA_SYMBOL_SIZE);
|
||||
|
||||
x += cardArtWidth;
|
||||
String name = cardRules.getName();
|
||||
String name = card.getOriginal().getName();
|
||||
if (count > 0) { //preface name with count if applicable
|
||||
name = count + " " + name;
|
||||
}
|
||||
@@ -372,17 +359,17 @@ public class CardRenderer {
|
||||
availableTypeWidth -= setWidth;
|
||||
drawSetLabel(g, typeFont, set, rarity, x + availableTypeWidth + SET_BOX_MARGIN, y - SET_BOX_MARGIN, setWidth, lineHeight + 2 * SET_BOX_MARGIN);
|
||||
}
|
||||
String type = cardRules.getType().toString();
|
||||
if (cardRules.getType().isCreature()) { //include P/T or Loyalty at end of type
|
||||
String type = CardDetailUtil.formatCardId(card.getOriginal());
|
||||
if (card.getOriginal().isCreature()) { //include P/T or Loyalty at end of type
|
||||
type += " (" + power + " / " + toughness + ")";
|
||||
}
|
||||
else if (cardRules.getType().isPlaneswalker()) {
|
||||
else if (card.getOriginal().isPlaneswalker()) {
|
||||
type += " (" + loyalty + ")";
|
||||
}
|
||||
g.drawText(type, typeFont, foreColor, x, y, availableTypeWidth, lineHeight, false, HAlignment.LEFT, true);
|
||||
}
|
||||
|
||||
public static boolean cardListItemTap(Card card, float x, float y, int count, boolean compactMode) {
|
||||
public static boolean cardListItemTap(CardView card, float x, float y, int count, boolean compactMode) {
|
||||
if (x <= getCardListItemHeight(compactMode) * CARD_ART_RATIO) {
|
||||
CardZoom.show(card);
|
||||
return true;
|
||||
@@ -393,13 +380,13 @@ public class CardRenderer {
|
||||
float cardArtHeight = getCardListItemHeight(compactMode);
|
||||
float cardArtWidth = cardArtHeight * CARD_ART_RATIO;
|
||||
if (x <= cardArtWidth && y <= cardArtHeight) {
|
||||
CardZoom.show(Card.getCardForUi(pc));
|
||||
CardZoom.show(ViewUtil.getCardForUi(pc));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void drawCardNameBox(Graphics g, Card card, boolean canShow, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
private static void drawCardNameBox(Graphics g, CardView card, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
if (color2 == null) {
|
||||
g.fillRect(color1, x, y, w, h);
|
||||
}
|
||||
@@ -409,18 +396,18 @@ public class CardRenderer {
|
||||
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
|
||||
|
||||
float padding = h / 8;
|
||||
final CardStateView state = card.getOriginal();
|
||||
|
||||
//make sure name/mana cost row height is tall enough for both
|
||||
h = Math.max(MANA_SYMBOL_SIZE + 2 * MANA_COST_PADDING, 2 * NAME_FONT.getCapHeight());
|
||||
|
||||
//draw mana cost for card
|
||||
float manaCostWidth = 0;
|
||||
if (canShow) {
|
||||
ManaCost mainManaCost = card.getManaCost();
|
||||
if (card.isSplitCard() && card.getCurState() == CardCharacteristicName.Original) {
|
||||
ManaCost mainManaCost = state.getManaCost();
|
||||
if (card.isSplitCard() && card.hasAltState()) {
|
||||
//handle rendering both parts of split card
|
||||
mainManaCost = card.getRules().getMainPart().getManaCost();
|
||||
ManaCost otherManaCost = card.getRules().getOtherPart().getManaCost();
|
||||
mainManaCost = state.getManaCost();
|
||||
ManaCost otherManaCost = card.getAlternate().getManaCost();
|
||||
manaCostWidth = CardFaceSymbols.getWidth(otherManaCost, MANA_SYMBOL_SIZE) + MANA_COST_PADDING;
|
||||
CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE);
|
||||
//draw "//" between two parts of mana cost
|
||||
@@ -429,27 +416,24 @@ public class CardRenderer {
|
||||
}
|
||||
manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE) + MANA_COST_PADDING;
|
||||
CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE);
|
||||
}
|
||||
|
||||
//draw name for card
|
||||
x += padding;
|
||||
w -= 2 * padding;
|
||||
g.drawText(!canShow || card.isFaceDown() ? "???" : card.getName(), NAME_FONT, Color.BLACK, x, y, w - manaCostWidth - padding, h, false, HAlignment.LEFT, true);
|
||||
g.drawText(state.getName(), NAME_FONT, Color.BLACK, x, y, w - manaCostWidth - padding, h, false, HAlignment.LEFT, true);
|
||||
|
||||
//draw type and set label for card
|
||||
if (canShow) {
|
||||
y += h;
|
||||
h = 2 * TYPE_FONT.getCapHeight();
|
||||
|
||||
String set = card.getCurSetCode();
|
||||
String set = card.getSetCode();
|
||||
if (!StringUtils.isEmpty(set)) {
|
||||
float setWidth = getSetWidth(SET_FONT, set);
|
||||
drawSetLabel(g, SET_FONT, set, card.getRarity(), x + w + padding - setWidth - SET_BOX_MARGIN, y + SET_BOX_MARGIN, setWidth, h - SET_BOX_MARGIN);
|
||||
w -= setWidth; //reduce available width for type
|
||||
}
|
||||
|
||||
g.drawText(CardDetailUtil.formatCardType(card), TYPE_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true);
|
||||
}
|
||||
g.drawText(CardDetailUtil.formatCardType(state), TYPE_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true);
|
||||
}
|
||||
|
||||
public static float getSetWidth(FSkinFont font, String set) {
|
||||
@@ -466,7 +450,7 @@ public class CardRenderer {
|
||||
//use text renderer to handle mana symbols and reminder text
|
||||
private static final TextRenderer cardTextRenderer = new TextRenderer(true);
|
||||
|
||||
private static void drawCardTextBox(Graphics g, Card card, boolean canShow, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
private static void drawCardTextBox(Graphics g, CardView card, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
if (color2 == null) {
|
||||
g.fillRect(color1, x, y, w, h);
|
||||
}
|
||||
@@ -481,14 +465,16 @@ public class CardRenderer {
|
||||
y += padY;
|
||||
w -= 2 * padX;
|
||||
h -= 2 * padY;
|
||||
cardTextRenderer.drawText(g, CardDetailUtil.composeCardText(card, canShow), TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, HAlignment.LEFT, false);
|
||||
cardTextRenderer.drawText(g, CardDetailUtil.composeCardText(card.getOriginal()), TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, HAlignment.LEFT, false);
|
||||
}
|
||||
|
||||
private static void drawCardIdAndPtBox(Graphics g, Card card, Color idForeColor, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
String idText = CardDetailUtil.formatCardId(card);
|
||||
private static void drawCardIdAndPtBox(Graphics g, CardView card, Color idForeColor, Color color1, Color color2, float x, float y, float w, float h) {
|
||||
final CardStateView state = card.getOriginal();
|
||||
|
||||
String idText = CardDetailUtil.formatCardId(state);
|
||||
g.drawText(idText, ID_FONT, idForeColor, x, y + ID_FONT.getCapHeight() / 2, w, h, false, HAlignment.LEFT, false);
|
||||
|
||||
String ptText = CardDetailUtil.formatPowerToughness(card);
|
||||
String ptText = CardDetailUtil.formatPowerToughness(state);
|
||||
if (StringUtils.isEmpty(ptText)) { return; }
|
||||
|
||||
float padding = PT_FONT.getCapHeight() / 2;
|
||||
@@ -511,14 +497,14 @@ public class CardRenderer {
|
||||
Texture image = ImageCache.getImage(pc);
|
||||
if (image != null) {
|
||||
if (image == ImageCache.defaultImage) {
|
||||
CardImageRenderer.drawCardImage(g, Card.getCardForUi(pc), x, y, w, h);
|
||||
CardImageRenderer.drawCardImage(g, ViewUtil.getCardForUi(pc), x, y, w, h);
|
||||
}
|
||||
else {
|
||||
g.drawImage(image, x, y, w, h);
|
||||
}
|
||||
if (pc.isFoil()) { //draw foil effect if needed
|
||||
Card card = Card.getCardForUi(pc);
|
||||
if (card.getFoil() == 0) { //if foil finish not yet established, assign a random one
|
||||
final CardView card = ViewUtil.getCardForUi(pc);
|
||||
if (card.getFoilIndex() == 0) { //if foil finish not yet established, assign a random one
|
||||
card.setRandomFoil();
|
||||
}
|
||||
drawFoilEffect(g, card, x, y, w, h);
|
||||
@@ -528,29 +514,24 @@ public class CardRenderer {
|
||||
g.fillRect(Color.BLACK, x, y, w, h);
|
||||
}
|
||||
}
|
||||
public static void drawCard(Graphics g, Card card, boolean canShow, float x, float y, float w, float h) {
|
||||
public static void drawCard(Graphics g, CardView card, float x, float y, float w, float h) {
|
||||
Texture image = ImageCache.getImage(card);
|
||||
if (image != null) {
|
||||
if (image == ImageCache.defaultImage && canShow) {
|
||||
if (image == ImageCache.defaultImage) {
|
||||
CardImageRenderer.drawCardImage(g, card, x, y, w, h);
|
||||
}
|
||||
else {
|
||||
g.drawImage(image, x, y, w, h);
|
||||
}
|
||||
if (canShow) {
|
||||
drawFoilEffect(g, card, x, y, w, h);
|
||||
}
|
||||
}
|
||||
else { //draw cards without textures as just a black rectangle
|
||||
g.fillRect(Color.BLACK, x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawCardWithOverlays(Graphics g, Card card, float x, float y, float w, float h) {
|
||||
card = card.getCardForUi();
|
||||
|
||||
boolean canShow = FControl.mayShowCard(card);
|
||||
drawCard(g, card, canShow, x, y, w, h);
|
||||
public static void drawCardWithOverlays(Graphics g, CardView card, float x, float y, float w, float h) {
|
||||
drawCard(g, card, x, y, w, h);
|
||||
|
||||
float padding = w * 0.021f; //adjust for card border
|
||||
x += padding;
|
||||
@@ -558,25 +539,25 @@ public class CardRenderer {
|
||||
w -= 2 * padding;
|
||||
h -= 2 * padding;
|
||||
|
||||
CardDetails details = FControl.getCardDetails(card);
|
||||
DetailColors borderColor = CardDetailUtil.getBorderColor(details.colors, details.isLand, canShow);
|
||||
CardStateView details = FControl.getCardDetails(card);
|
||||
DetailColors borderColor = CardDetailUtil.getBorderColor(details);
|
||||
Color color = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b);
|
||||
color = FSkinColor.tintColor(Color.WHITE, color, CardRenderer.PT_BOX_TINT);
|
||||
|
||||
//draw name and mana cost overlays if card is small or default card image being used
|
||||
if (h <= NAME_COST_THRESHOLD) {
|
||||
if (showCardNameOverlay(card)) {
|
||||
g.drawOutlinedText(card.getName(), FSkinFont.forHeight(h * 0.18f), Color.WHITE, Color.BLACK, x + padding, y + padding, w - 2 * padding, h * 0.4f, true, HAlignment.LEFT, false);
|
||||
g.drawOutlinedText(details.getName(), FSkinFont.forHeight(h * 0.18f), Color.WHITE, Color.BLACK, x + padding, y + padding, w - 2 * padding, h * 0.4f, true, HAlignment.LEFT, false);
|
||||
}
|
||||
if (showCardManaCostOverlay(card)) {
|
||||
float manaSymbolSize = w / 4;
|
||||
if (card.isSplitCard() && card.getCurState() == CardCharacteristicName.Original) {
|
||||
if (card.isSplitCard() && card.hasAltState()) {
|
||||
float dy = manaSymbolSize / 2 + Utils.scaleY(5);
|
||||
drawManaCost(g, card.getRules().getMainPart().getManaCost(), x, y + dy, w, h, manaSymbolSize);
|
||||
drawManaCost(g, card.getRules().getOtherPart().getManaCost(), x, y - dy, w, h, manaSymbolSize);
|
||||
drawManaCost(g, card.getOriginal().getManaCost(), x, y + dy, w, h, manaSymbolSize);
|
||||
drawManaCost(g, card.getAlternate().getManaCost(), x, y - dy, w, h, manaSymbolSize);
|
||||
}
|
||||
else {
|
||||
drawManaCost(g, card.getManaCost(), x, y, w, h, manaSymbolSize);
|
||||
drawManaCost(g, card.getOriginal().getManaCost(), x, y, w, h, manaSymbolSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -584,7 +565,7 @@ public class CardRenderer {
|
||||
if (showCardIdOverlay(card)) {
|
||||
FSkinFont idFont = FSkinFont.forHeight(h * 0.12f);
|
||||
float idHeight = idFont.getCapHeight();
|
||||
g.drawOutlinedText(String.valueOf(card.getUniqueNumber()), idFont, Color.WHITE, Color.BLACK, x + padding, y + h - idHeight - padding, w, h, false, HAlignment.LEFT, false);
|
||||
g.drawOutlinedText(String.valueOf(card.getId()), idFont, Color.WHITE, Color.BLACK, x + padding, y + h - idHeight - padding, w, h, false, HAlignment.LEFT, false);
|
||||
}
|
||||
|
||||
int number = 0;
|
||||
@@ -616,12 +597,9 @@ public class CardRenderer {
|
||||
final float stateXSymbols = (x + (w / 2)) - otherSymbolsSize / 2;
|
||||
final float ySymbols = (y + h) - (h / 8) - otherSymbolsSize / 2;
|
||||
|
||||
Game game = card.getGame();
|
||||
if (game == null) {
|
||||
game = FControl.getGame();
|
||||
}
|
||||
final IGameView game = FControl.getGameView();
|
||||
if (game != null) {
|
||||
Combat combat = game.getCombat();
|
||||
final CombatView combat = game.getCombat();
|
||||
if (combat != null) {
|
||||
if (combat.isAttacking(card)) {
|
||||
CardFaceSymbols.drawSymbol("attack", g, combatXSymbols, ySymbols, otherSymbolsSize, otherSymbolsSize);
|
||||
@@ -632,7 +610,7 @@ public class CardRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
if (details.isCreature && card.hasSickness() && card.isInPlay()) {
|
||||
if (details.isCreature() && card.isSick() && card.getZone() == ZoneType.Battlefield) {
|
||||
CardFaceSymbols.drawSymbol("summonsick", g, stateXSymbols, ySymbols, otherSymbolsSize, otherSymbolsSize);
|
||||
}
|
||||
|
||||
@@ -650,21 +628,21 @@ public class CardRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawPtBox(Graphics g, Card card, CardDetails details, Color color, float x, float y, float w, float h) {
|
||||
private static void drawPtBox(Graphics g, CardView card, CardStateView details, Color color, float x, float y, float w, float h) {
|
||||
//use array of strings to render separately with a tiny amount of space in between
|
||||
//instead of using actual spaces which are too wide
|
||||
List<String> pieces = new ArrayList<String>();
|
||||
if (details.isCreature) {
|
||||
pieces.add(String.valueOf(details.power));
|
||||
if (details.isCreature()) {
|
||||
pieces.add(String.valueOf(details.getPower()));
|
||||
pieces.add("/");
|
||||
pieces.add(String.valueOf(details.toughness));
|
||||
pieces.add(String.valueOf(details.getToughness()));
|
||||
}
|
||||
if (details.isPlaneswalker) {
|
||||
if (details.isPlaneswalker()) {
|
||||
if (pieces.isEmpty()) {
|
||||
pieces.add(String.valueOf(details.loyalty));
|
||||
pieces.add(String.valueOf(details.getLoyalty()));
|
||||
}
|
||||
else {
|
||||
pieces.add("(" + details.loyalty + ")");
|
||||
pieces.add("(" + details.getLoyalty() + ")");
|
||||
}
|
||||
}
|
||||
if (pieces.isEmpty()) { return; }
|
||||
@@ -705,9 +683,9 @@ public class CardRenderer {
|
||||
CardFaceSymbols.drawManaCost(g, cost, x + (w - manaCostWidth) / 2, y + (h - manaSymbolSize) / 2, manaSymbolSize);
|
||||
}
|
||||
|
||||
public static void drawFoilEffect(Graphics g, Card card, float x, float y, float w, float h) {
|
||||
public static void drawFoilEffect(Graphics g, CardView card, float x, float y, float w, float h) {
|
||||
if (isPreferenceEnabled(FPref.UI_OVERLAY_FOIL_EFFECT)) {
|
||||
int foil = card.getFoil();
|
||||
int foil = card.getFoilIndex();
|
||||
if (foil > 0) {
|
||||
CardFaceSymbols.drawOther(g, String.format("foil%02d", foil), x, y, w, h);
|
||||
}
|
||||
@@ -718,25 +696,25 @@ public class CardRenderer {
|
||||
return FModel.getPreferences().getPrefBoolean(preferenceName);
|
||||
}
|
||||
|
||||
private static boolean isShowingOverlays(Card card) {
|
||||
return isPreferenceEnabled(FPref.UI_SHOW_CARD_OVERLAYS) && card != null && FControl.mayShowCard(card);
|
||||
private static boolean isShowingOverlays(CardView card) {
|
||||
return isPreferenceEnabled(FPref.UI_SHOW_CARD_OVERLAYS) && card != null;
|
||||
}
|
||||
|
||||
private static boolean showCardNameOverlay(Card card) {
|
||||
private static boolean showCardNameOverlay(CardView card) {
|
||||
return isShowingOverlays(card) && isPreferenceEnabled(FPref.UI_OVERLAY_CARD_NAME);
|
||||
}
|
||||
|
||||
private static boolean showCardPowerOverlay(Card card) {
|
||||
private static boolean showCardPowerOverlay(CardView card) {
|
||||
return isShowingOverlays(card) && isPreferenceEnabled(FPref.UI_OVERLAY_CARD_POWER);
|
||||
}
|
||||
|
||||
private static boolean showCardManaCostOverlay(Card card) {
|
||||
private static boolean showCardManaCostOverlay(CardView card) {
|
||||
return isShowingOverlays(card) &&
|
||||
isPreferenceEnabled(FPref.UI_OVERLAY_CARD_MANA_COST) &&
|
||||
!card.isFaceDown();
|
||||
}
|
||||
|
||||
private static boolean showCardIdOverlay(Card card) {
|
||||
return card.getUniqueNumber() > 0 && isShowingOverlays(card) && isPreferenceEnabled(FPref.UI_OVERLAY_CARD_ID);
|
||||
private static boolean showCardIdOverlay(CardView card) {
|
||||
return card.getId() > 0 && isShowingOverlays(card) && isPreferenceEnabled(FPref.UI_OVERLAY_CARD_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,25 +5,26 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
import forge.Graphics;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.game.card.Card;
|
||||
import forge.item.PaperCard;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.toolbox.FList;
|
||||
import forge.toolbox.FOverlay;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
public class CardZoom extends FOverlay {
|
||||
private static final float TAB_HEIGHT = Utils.AVG_FINGER_HEIGHT;
|
||||
private static final FSkinFont FONT = FSkinFont.get(14);
|
||||
private static final CardZoom cardZoom = new CardZoom();
|
||||
private static Card card;
|
||||
private static CardView card;
|
||||
private static boolean zoomMode = true;
|
||||
|
||||
public static <T> void show(final PaperCard pc0) {
|
||||
card = Card.getCardForUi(pc0);
|
||||
public static <T> void show(final IPaperCard pc0) {
|
||||
card = ViewUtil.getCardForUi(pc0);
|
||||
cardZoom.show();
|
||||
}
|
||||
public static <T> void show(final Card card0) {
|
||||
card = card0.getCardForUi();
|
||||
public static <T> void show(final CardView card0) {
|
||||
card = card0;
|
||||
cardZoom.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.deck;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.GuiBase;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.FDeckEditor.EditorType;
|
||||
import forge.deck.io.DeckPreferences;
|
||||
@@ -56,7 +57,7 @@ public class FDeckChooser extends FScreen {
|
||||
//Show screen to select a deck
|
||||
private static FDeckChooser deckChooserForPrompt;
|
||||
public static void promptForDeck(String title, GameType gameType, boolean forAi, final Callback<Deck> callback) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
if (deckChooserForPrompt == null) {
|
||||
deckChooserForPrompt = new FDeckChooser(gameType, forAi, null);
|
||||
}
|
||||
@@ -374,7 +375,7 @@ public class FDeckChooser extends FScreen {
|
||||
"White", "Blue", "Black", "Red", "Green" };
|
||||
ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>();
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
decks.add(new ColorDeckGenerator(colors[i], i, lstDecks, isAi));
|
||||
decks.add(new ColorDeckGenerator(GuiBase.getInterface(), colors[i], i, lstDecks, isAi));
|
||||
}
|
||||
|
||||
lstDecks.setPool(decks);
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
@@ -43,13 +44,13 @@ public class BugReportDialog extends FScreen { //use screen rather than dialog s
|
||||
btnReport.setCommand(new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
BugReporter.copyAndGoToForums(tvDetails.text);
|
||||
BugReporter.copyAndGoToForums(GuiBase.getInterface(), tvDetails.text);
|
||||
}
|
||||
});
|
||||
btnSave.setCommand(new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
BugReporter.saveToFile(tvDetails.text);
|
||||
BugReporter.saveToFile(GuiBase.getInterface(), tvDetails.text);
|
||||
}
|
||||
});
|
||||
btnContinue.setCommand(new FEventHandler() {
|
||||
|
||||
@@ -11,7 +11,6 @@ import forge.assets.ImageCache;
|
||||
import forge.card.CardRenderer;
|
||||
import forge.card.CardZoom;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.game.card.Card;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.PaperCard;
|
||||
@@ -32,6 +31,7 @@ import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.util.Utils;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
@@ -870,7 +870,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
public boolean longPress(float x, float y) {
|
||||
ItemInfo item = getItemAtPoint(x + getLeft(), y + getTop());
|
||||
if (item != null && item.item instanceof IPaperCard) {
|
||||
CardZoom.show(Card.getCardForUi((IPaperCard) item.item));
|
||||
CardZoom.show(ViewUtil.getCardForUi((IPaperCard) item.item));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Graphics;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.assets.FSkinFont;
|
||||
@@ -25,7 +26,7 @@ public class LoadingOverlay extends FOverlay {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runnable.run();
|
||||
|
||||
@@ -176,7 +176,7 @@ public class ConstructedScreen extends LaunchScreen {
|
||||
playerPanels.get(6).initialize(FPref.CONSTRUCTED_P7_DECK_STATE, DeckType.COLOR_DECK);
|
||||
playerPanels.get(7).initialize(FPref.CONSTRUCTED_P8_DECK_STATE, DeckType.COLOR_DECK);*/ //TODO: Support multiplayer and improve performance of loading this screen by using background thread
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
btnStart.setEnabled(true);
|
||||
@@ -935,12 +935,12 @@ public class ConstructedScreen extends LaunchScreen {
|
||||
super("Select Variants");
|
||||
|
||||
lstVariants.setListItemRenderer(new VariantRenderer());
|
||||
lstVariants.addItem(new Variant(GameType.Vanguard, "Each player has a special \"Avatar\" card that affects the game."));
|
||||
lstVariants.addItem(new Variant(GameType.MomirBasic, "Each player has a deck containing 60 basic lands and the Momir Vig avatar."));
|
||||
lstVariants.addItem(new Variant(GameType.Commander, "Each player has a legendary \"General\" card which can be cast at any time and determines deck colors."));
|
||||
lstVariants.addItem(new Variant(GameType.Planechase, "Plane cards apply global effects. Plane card changed when a player rolls \"Chaos\" on the planar die."));
|
||||
lstVariants.addItem(new Variant(GameType.Archenemy, "One player is the Archenemy and can play scheme cards."));
|
||||
lstVariants.addItem(new Variant(GameType.ArchenemyRumble, "All players are Archenemies and can play scheme cards."));
|
||||
lstVariants.addItem(new Variant(GameType.Vanguard));
|
||||
lstVariants.addItem(new Variant(GameType.MomirBasic));
|
||||
lstVariants.addItem(new Variant(GameType.Commander));
|
||||
lstVariants.addItem(new Variant(GameType.Planechase));
|
||||
lstVariants.addItem(new Variant(GameType.Archenemy));
|
||||
lstVariants.addItem(new Variant(GameType.ArchenemyRumble));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -950,11 +950,9 @@ public class ConstructedScreen extends LaunchScreen {
|
||||
|
||||
private class Variant {
|
||||
private final GameType gameType;
|
||||
private final String description;
|
||||
|
||||
private Variant(GameType gameType0, String description0) {
|
||||
private Variant(GameType gameType0) {
|
||||
gameType = gameType0;
|
||||
description = description0;
|
||||
}
|
||||
|
||||
private void draw(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float w, float h) {
|
||||
@@ -1025,7 +1023,7 @@ public class ConstructedScreen extends LaunchScreen {
|
||||
g.drawText(text, font, foreColor, x, y, w, h, false, HAlignment.LEFT, false);
|
||||
value.draw(g, font, foreColor, x, y, w, h);
|
||||
h += SettingsScreen.SETTING_PADDING;
|
||||
g.drawText(value.description, SettingsScreen.DESC_FONT, SettingsScreen.DESC_COLOR, x, y + h, w, totalHeight - h + w * SettingsScreen.INSETS_FACTOR, true, HAlignment.LEFT, false);
|
||||
g.drawText(value.gameType.getDescription(), SettingsScreen.DESC_FONT, SettingsScreen.DESC_COLOR, x, y + h, w, totalHeight - h + w * SettingsScreen.INSETS_FACTOR, true, HAlignment.LEFT, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.screens.draft;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.GuiBase;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.LaunchScreen;
|
||||
import forge.screens.LoadingOverlay;
|
||||
@@ -48,13 +49,13 @@ public class DraftScreen extends LaunchScreen {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //must run in game thread to prevent blocking UI thread
|
||||
@Override
|
||||
public void run() {
|
||||
final LimitedPoolType poolType = SGuiChoose.oneOrNone("Choose Draft Format", LimitedPoolType.values());
|
||||
final LimitedPoolType poolType = SGuiChoose.oneOrNone(GuiBase.getInterface(), "Choose Draft Format", LimitedPoolType.values());
|
||||
if (poolType == null) { return; }
|
||||
|
||||
final BoosterDraft draft = BoosterDraft.createDraft(poolType);
|
||||
final BoosterDraft draft = BoosterDraft.createDraft(GuiBase.getInterface(), poolType);
|
||||
if (draft == null) { return; }
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LoadingOverlay.show("Loading new draft...", new Runnable() {
|
||||
@@ -131,21 +132,21 @@ public class DraftScreen extends LaunchScreen {
|
||||
}
|
||||
}
|
||||
|
||||
final Integer rounds = SGuiChoose.getInteger("How many opponents are you willing to face?",
|
||||
final Integer rounds = SGuiChoose.getInteger(GuiBase.getInterface(), "How many opponents are you willing to face?",
|
||||
1, FModel.getDecks().getDraft().get(humanDeck.getName()).getAiDecks().size());
|
||||
if (rounds == null) {
|
||||
creatingMatch = false;
|
||||
return;
|
||||
}
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LoadingOverlay.show("Loading new game...", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FModel.getGauntletMini().resetGauntletDraft();
|
||||
FModel.getGauntletMini().launch(rounds, humanDeck.getDeck(), GameType.Draft);
|
||||
FModel.getGauntletMini(GuiBase.getInterface()).resetGauntletDraft();
|
||||
FModel.getGauntletMini(GuiBase.getInterface()).launch(rounds, humanDeck.getDeck(), GameType.Draft);
|
||||
creatingMatch = false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -284,14 +284,14 @@ public class GauntletScreen extends LaunchScreen {
|
||||
String gauntletName;
|
||||
String oldGauntletName = gauntlet.getName();
|
||||
while (true) {
|
||||
gauntletName = SOptionPane.showInputDialog("Enter new name for gauntlet:", "Rename Gauntlet", null, oldGauntletName);
|
||||
gauntletName = SOptionPane.showInputDialog(GuiBase.getInterface(), "Enter new name for gauntlet:", "Rename Gauntlet", null, oldGauntletName);
|
||||
if (gauntletName == null) { return; }
|
||||
|
||||
gauntletName = QuestUtil.cleanString(gauntletName);
|
||||
if (gauntletName.equals(oldGauntletName)) { return; } //quit if chose same name
|
||||
|
||||
if (gauntletName.isEmpty()) {
|
||||
SOptionPane.showMessageDialog("Please specify a gauntlet name.");
|
||||
SOptionPane.showMessageDialog(GuiBase.getInterface(), "Please specify a gauntlet name.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -303,13 +303,13 @@ public class GauntletScreen extends LaunchScreen {
|
||||
}
|
||||
}
|
||||
if (exists) {
|
||||
SOptionPane.showMessageDialog("A gauntlet already exists with that name. Please pick another gauntlet name.");
|
||||
SOptionPane.showMessageDialog(GuiBase.getInterface(), "A gauntlet already exists with that name. Please pick another gauntlet name.");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
final String newGauntletName = gauntletName;
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
gauntlet.rename(newGauntletName);
|
||||
@@ -327,7 +327,7 @@ public class GauntletScreen extends LaunchScreen {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!SOptionPane.showConfirmDialog(
|
||||
if (!SOptionPane.showConfirmDialog(GuiBase.getInterface(),
|
||||
"Are you sure you want to delete '" + gauntlet.getName() + "'?",
|
||||
"Delete Gauntlet", "Delete", "Cancel")) {
|
||||
return;
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -30,7 +29,6 @@ import forge.assets.FImage;
|
||||
import forge.assets.FSkin;
|
||||
import forge.assets.FTextureRegionImage;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.card.ColorSet;
|
||||
import forge.control.FControlGameEventHandler;
|
||||
import forge.control.FControlGamePlayback;
|
||||
import forge.events.IUiEventVisitor;
|
||||
@@ -38,7 +36,6 @@ import forge.events.UiEvent;
|
||||
import forge.events.UiEventAttackerDeclared;
|
||||
import forge.events.UiEventBlockerAssigned;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameRules;
|
||||
import forge.game.GameType;
|
||||
import forge.game.Match;
|
||||
@@ -53,13 +50,12 @@ import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.match.input.InputPlaybackControl;
|
||||
import forge.match.input.InputProxy;
|
||||
import forge.match.input.InputQueue;
|
||||
import forge.model.FModel;
|
||||
import forge.player.LobbyPlayerHuman;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.quest.QuestController;
|
||||
@@ -78,20 +74,25 @@ import forge.util.GuiDisplayUtil;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.NameGenerator;
|
||||
import forge.util.WaitCallback;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class FControl {
|
||||
private FControl() { } //don't allow creating instance
|
||||
|
||||
private static Game game;
|
||||
private static IGameView gameView;
|
||||
private static MatchScreen view;
|
||||
private static InputQueue inputQueue;
|
||||
private static InputProxy inputProxy;
|
||||
private static List<Player> sortedPlayers;
|
||||
private static final EventBus uiEvents;
|
||||
private static boolean gameHasHumanPlayer;
|
||||
private static final MatchUiEventVisitor visitor = new MatchUiEventVisitor();
|
||||
private static final FControlGameEventHandler fcVisitor = new FControlGameEventHandler();
|
||||
private static final FControlGamePlayback playbackControl = new FControlGamePlayback();
|
||||
private static FControlGameEventHandler fcVisitor;
|
||||
private static FControlGamePlayback playbackControl;
|
||||
private static final Map<LobbyPlayer, FImage> avatarImages = new HashMap<LobbyPlayer, FImage>();
|
||||
|
||||
static {
|
||||
@@ -121,6 +122,19 @@ public class FControl {
|
||||
startGame(new Match(rules, players));
|
||||
}
|
||||
|
||||
public static void startGameInSameMatch() {
|
||||
endCurrentGame();
|
||||
startGame(game.getMatch());
|
||||
}
|
||||
|
||||
public static void startGameInNewMatch() {
|
||||
endCurrentGame();
|
||||
final Match match = game.getMatch();
|
||||
match.clearGamesPlayed();
|
||||
FControl.endCurrentGame();
|
||||
startGame(match);
|
||||
}
|
||||
|
||||
public static void startGame(final Match match) {
|
||||
cardDetailsCache.clear(); //ensure details cache cleared before starting a new game
|
||||
CardAreaPanel.resetForNewGame(); //ensure card panels reset between games
|
||||
@@ -138,8 +152,7 @@ public class FControl {
|
||||
game.subscribeToEvents(qc); // this one listens to player's mulligans ATM
|
||||
}
|
||||
|
||||
inputQueue = new InputQueue();
|
||||
inputProxy = new InputProxy();
|
||||
inputQueue = new InputQueue(game);
|
||||
|
||||
game.subscribeToEvents(Forge.getSoundSystem());
|
||||
|
||||
@@ -148,7 +161,6 @@ public class FControl {
|
||||
initMatch(game.getRegisteredPlayers(), humanLobbyPlayer);
|
||||
|
||||
actuateMatchPreferences();
|
||||
inputProxy.setGame(game);
|
||||
|
||||
// Listen to DuelOutcome event to show ViewWinLose
|
||||
game.subscribeToEvents(fcVisitor);
|
||||
@@ -195,6 +207,10 @@ public class FControl {
|
||||
return game;
|
||||
}
|
||||
|
||||
public static IGameView getGameView() {
|
||||
return gameView;
|
||||
}
|
||||
|
||||
public static MatchScreen getView() {
|
||||
return view;
|
||||
}
|
||||
@@ -203,28 +219,20 @@ public class FControl {
|
||||
return inputQueue;
|
||||
}
|
||||
|
||||
public static InputProxy getInputProxy() {
|
||||
return inputProxy;
|
||||
}
|
||||
|
||||
public static boolean stopAtPhase(final Player turn, final PhaseType phase) {
|
||||
public static boolean stopAtPhase(final PlayerView turn, final PhaseType phase) {
|
||||
PhaseLabel label = getPlayerPanel(turn).getPhaseIndicator().getLabel(phase);
|
||||
return label == null || label.getStopAtPhase();
|
||||
}
|
||||
|
||||
public static void endCurrentTurn() {
|
||||
Player p = getCurrentPlayer();
|
||||
|
||||
if (p != null) {
|
||||
inputProxy.passPriority(p, PhaseType.CLEANUP);
|
||||
}
|
||||
gameView.passPriorityUntilEndOfTurn();
|
||||
}
|
||||
|
||||
public static void initMatch(final List<Player> players, Player localPlayer) {
|
||||
final String[] indices = FModel.getPreferences().getPref(FPref.UI_AVATARS).split(",");
|
||||
|
||||
// Instantiate all required field slots (user at 0)
|
||||
sortedPlayers = shiftPlayersPlaceLocalFirst(players, localPlayer);
|
||||
final List<Player> sortedPlayers = shiftPlayersPlaceLocalFirst(players, localPlayer);
|
||||
|
||||
List<VPlayerPanel> playerPanels = new ArrayList<VPlayerPanel>();
|
||||
|
||||
@@ -236,10 +244,17 @@ public class FControl {
|
||||
i++;
|
||||
}
|
||||
p.getLobbyPlayer().setAvatarIndex(avatarIndex);
|
||||
playerPanels.add(new VPlayerPanel(p));
|
||||
}
|
||||
|
||||
view = new MatchScreen(game, localPlayer, playerPanels);
|
||||
final PlayerControllerHuman humanController = (PlayerControllerHuman) localPlayer.getController();
|
||||
gameView = (IGameView) humanController;
|
||||
fcVisitor = new FControlGameEventHandler(humanController);
|
||||
playbackControl = new FControlGamePlayback(humanController);
|
||||
|
||||
for (Player p : sortedPlayers) {
|
||||
playerPanels.add(new VPlayerPanel(humanController.getPlayerView(p)));
|
||||
}
|
||||
view = new MatchScreen(gameView, humanController.getPlayerView(localPlayer), playerPanels);
|
||||
}
|
||||
|
||||
private static List<Player> shiftPlayersPlaceLocalFirst(final List<Player> players, Player localPlayer) {
|
||||
@@ -268,11 +283,11 @@ public class FControl {
|
||||
view.getPrompt().setMessage(s0);
|
||||
}
|
||||
|
||||
public static VPlayerPanel getPlayerPanel(Player p) {
|
||||
return view.getPlayerPanels().get(p);
|
||||
public static VPlayerPanel getPlayerPanel(final PlayerView playerView) {
|
||||
return view.getPlayerPanels().get(playerView);
|
||||
}
|
||||
|
||||
public static void highlightCard(final Card c) {
|
||||
public static void highlightCard(final CardView c) {
|
||||
for (VPlayerPanel playerPanel : FControl.getView().getPlayerPanels().values()) {
|
||||
for (FCardPanel p : playerPanel.getField().getCardPanels()) {
|
||||
if (p.getCard().equals(c)) {
|
||||
@@ -291,10 +306,6 @@ public class FControl {
|
||||
}
|
||||
}
|
||||
|
||||
public static Iterable<Player> getSortedPlayers() {
|
||||
return sortedPlayers;
|
||||
}
|
||||
|
||||
public static Player getCurrentPlayer() {
|
||||
// try current priority
|
||||
Player currentPriority = game.getPhaseHandler().getPriorityPlayer();
|
||||
@@ -312,10 +323,6 @@ public class FControl {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean mayShowCard(Card c) {
|
||||
return game == null || !gameHasHumanPlayer || c.canBeShownTo(getCurrentPlayer());
|
||||
}
|
||||
|
||||
public static void alphaStrike() {
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
|
||||
@@ -342,7 +349,7 @@ public class FControl {
|
||||
}
|
||||
}
|
||||
|
||||
public static void showCombat(Combat combat) {
|
||||
public static void showCombat(CombatView combat) {
|
||||
/*if (combat != null && combat.getAttackers().size() > 0 && combat.getAttackingPlayer().getGame().getStack().isEmpty()) {
|
||||
if (selectedDocBeforeCombat == null) {
|
||||
IVDoc<? extends ICDoc> combatDoc = EDocID.REPORT_COMBAT.getDoc();
|
||||
@@ -365,20 +372,20 @@ public class FControl {
|
||||
CCombat.SINGLETON_INSTANCE.update();*/
|
||||
}
|
||||
|
||||
public static Map<Card, Integer> getDamageToAssign(final Card attacker, final List<Card> blockers, final int damage, final GameEntity defender, final boolean overrideOrder) {
|
||||
public static Map<CardView, Integer> getDamageToAssign(final CardView attacker, final List<CardView> blockers, final int damage, final GameEntityView defender, final boolean overrideOrder) {
|
||||
if (damage <= 0) {
|
||||
return new HashMap<Card, Integer>();
|
||||
return new HashMap<CardView, Integer>();
|
||||
}
|
||||
|
||||
// If the first blocker can absorb all of the damage, don't show the Assign Damage dialog
|
||||
Card firstBlocker = blockers.get(0);
|
||||
if (!overrideOrder && !attacker.hasKeyword("Deathtouch") && firstBlocker.getLethalDamage() >= damage) {
|
||||
Map<Card, Integer> res = new HashMap<Card, Integer>();
|
||||
CardView firstBlocker = blockers.get(0);
|
||||
if (!overrideOrder && !attacker.getOriginal().hasDeathtouch() && firstBlocker.getLethalDamage() >= damage) {
|
||||
Map<CardView, Integer> res = new HashMap<CardView, Integer>();
|
||||
res.put(firstBlocker, damage);
|
||||
return res;
|
||||
}
|
||||
|
||||
return new WaitCallback<Map<Card, Integer>>() {
|
||||
return new WaitCallback<Map<CardView, Integer>>() {
|
||||
@Override
|
||||
public void run() {
|
||||
VAssignDamage v = new VAssignDamage(attacker, blockers, damage, defender, overrideOrder, this);
|
||||
@@ -387,8 +394,8 @@ public class FControl {
|
||||
}.invokeAndWait();
|
||||
}
|
||||
|
||||
private static Set<Player> highlightedPlayers = new HashSet<Player>();
|
||||
public static void setHighlighted(Player ge, boolean b) {
|
||||
private static Set<PlayerView> highlightedPlayers = new HashSet<PlayerView>();
|
||||
public static void setHighlighted(PlayerView ge, boolean b) {
|
||||
if (b) highlightedPlayers.add(ge);
|
||||
else highlightedPlayers.remove(ge);
|
||||
}
|
||||
@@ -397,115 +404,89 @@ public class FControl {
|
||||
return highlightedPlayers.contains(player);
|
||||
}
|
||||
|
||||
private static Set<Card> highlightedCards = new HashSet<Card>();
|
||||
private static Set<CardView> highlightedCards = new HashSet<CardView>();
|
||||
// used to highlight cards in UI
|
||||
public static void setUsedToPay(Card card, boolean value) {
|
||||
public static void setUsedToPay(CardView card, boolean value) {
|
||||
boolean hasChanged = value ? highlightedCards.add(card) : highlightedCards.remove(card);
|
||||
if (hasChanged) { // since we are in UI thread, may redraw the card right now
|
||||
updateSingleCard(card);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isUsedToPay(Card card) {
|
||||
public static boolean isUsedToPay(CardView card) {
|
||||
return highlightedCards.contains(card);
|
||||
}
|
||||
|
||||
public static void updateZones(List<Pair<Player, ZoneType>> zonesToUpdate) {
|
||||
for (Pair<Player, ZoneType> kv : zonesToUpdate) {
|
||||
Player owner = kv.getKey();
|
||||
public static void updateZones(List<Pair<PlayerView, ZoneType>> zonesToUpdate) {
|
||||
for (Pair<PlayerView, ZoneType> kv : zonesToUpdate) {
|
||||
PlayerView owner = kv.getKey();
|
||||
ZoneType zt = kv.getValue();
|
||||
getPlayerPanel(owner).updateZone(zt);
|
||||
}
|
||||
}
|
||||
|
||||
// Player's mana pool changes
|
||||
public static void updateManaPool(List<Player> manaPoolUpdate) {
|
||||
for (Player p : manaPoolUpdate) {
|
||||
public static void updateManaPool(List<PlayerView> manaPoolUpdate) {
|
||||
for (PlayerView p : manaPoolUpdate) {
|
||||
getPlayerPanel(p).updateManaPool();
|
||||
}
|
||||
}
|
||||
|
||||
// Player's lives and poison counters
|
||||
public static void updateLives(List<Player> livesUpdate) {
|
||||
for (Player p : livesUpdate) {
|
||||
public static void updateLives(List<PlayerView> livesUpdate) {
|
||||
for (PlayerView p : livesUpdate) {
|
||||
getPlayerPanel(p).updateLife();
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateCards(Set<Card> cardsToUpdate) {
|
||||
for (Card c : cardsToUpdate) {
|
||||
public static void updateCards(Set<CardView> cardsToUpdate) {
|
||||
for (CardView c : cardsToUpdate) {
|
||||
updateSingleCard(c);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<Integer, CardDetails> cardDetailsCache = new HashMap<Integer, CardDetails>();
|
||||
private static final Map<Integer, CardStateView> cardDetailsCache = new HashMap<Integer, CardStateView>();
|
||||
|
||||
public static CardDetails getCardDetails(Card card) {
|
||||
CardDetails details = cardDetailsCache.get(card.getUniqueNumber());
|
||||
public static CardStateView getCardDetails(CardView card) {
|
||||
final CardStateView details = cardDetailsCache.get(card.getId());
|
||||
if (details == null) {
|
||||
details = new CardDetails(card);
|
||||
cardDetailsCache.put(card.getUniqueNumber(), details);
|
||||
cardDetailsCache.put(card.getId(), card.getOriginal());
|
||||
return card.getOriginal();
|
||||
}
|
||||
return details;
|
||||
}
|
||||
|
||||
public static class CardDetails {
|
||||
public final int power, toughness, loyalty;
|
||||
public final boolean isCreature, isPlaneswalker, isLand;
|
||||
public final ColorSet colors;
|
||||
public static void refreshCardDetails(Iterable<CardView> cards) {
|
||||
Set<PlayerView> playersNeedingFieldUpdate = null;
|
||||
|
||||
private CardDetails(Card card) {
|
||||
isCreature = card.isCreature();
|
||||
if (isCreature) {
|
||||
power = card.getNetAttack();
|
||||
toughness = card.getNetDefense();
|
||||
}
|
||||
else {
|
||||
power = 0;
|
||||
toughness = 0;
|
||||
}
|
||||
isPlaneswalker = card.isPlaneswalker();
|
||||
if (isPlaneswalker) {
|
||||
loyalty = card.getCurrentLoyalty();
|
||||
}
|
||||
else {
|
||||
loyalty = 0;
|
||||
}
|
||||
colors = card.determineColor();
|
||||
isLand = card.isLand();
|
||||
}
|
||||
}
|
||||
|
||||
public static void refreshCardDetails(Collection<Card> cards) {
|
||||
Set<Player> playersNeedingFieldUpdate = null;
|
||||
|
||||
for (Card c : cards) {
|
||||
for (final CardView c : cards) {
|
||||
//for each card in play, if it changed from creature to non-creature or vice versa,
|
||||
//or if it changed from land to non-land or vice-versa,
|
||||
//ensure field containing that card is updated to reflect that change
|
||||
if (c.isInPlay()) {
|
||||
CardDetails oldDetails = cardDetailsCache.get(c);
|
||||
if (oldDetails == null || c.isCreature() != oldDetails.isCreature || c.isLand() != oldDetails.isLand) {
|
||||
final CardStateView state = c.getOriginal();
|
||||
if (c.getZone() == ZoneType.Battlefield) {
|
||||
CardStateView oldDetails = cardDetailsCache.get(c);
|
||||
if (oldDetails == null || state.isCreature() != oldDetails.isCreature() || state.isLand() != oldDetails.isLand()) {
|
||||
if (playersNeedingFieldUpdate == null) {
|
||||
playersNeedingFieldUpdate = new HashSet<Player>();
|
||||
playersNeedingFieldUpdate = new HashSet<PlayerView>();
|
||||
}
|
||||
playersNeedingFieldUpdate.add(c.getController());
|
||||
}
|
||||
}
|
||||
cardDetailsCache.put(c.getUniqueNumber(), new CardDetails(c));
|
||||
cardDetailsCache.put(c.getId(), c.getOriginal());
|
||||
}
|
||||
|
||||
if (playersNeedingFieldUpdate != null) { //update field for any players necessary
|
||||
for (Player p : playersNeedingFieldUpdate) {
|
||||
for (PlayerView p : playersNeedingFieldUpdate) {
|
||||
getPlayerPanel(p).getField().update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateSingleCard(Card c) {
|
||||
Zone zone = c.getZone();
|
||||
if (zone != null && zone.getZoneType() == ZoneType.Battlefield) {
|
||||
getPlayerPanel(zone.getPlayer()).getField().updateCard(c);
|
||||
public static void updateSingleCard(final CardView card) {
|
||||
final ZoneType zone = card.getZone();
|
||||
if (zone != null && zone == ZoneType.Battlefield) {
|
||||
getPlayerPanel(card.getController()).getField().updateCard(card);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,12 +852,12 @@ public class FControl {
|
||||
return player;
|
||||
}
|
||||
|
||||
private final static LobbyPlayer guiPlayer = new LobbyPlayerHuman("Human");
|
||||
private final static LobbyPlayer guiPlayer = new LobbyPlayerHuman("Human", GuiBase.getInterface());
|
||||
public final static LobbyPlayer getGuiPlayer() {
|
||||
return guiPlayer;
|
||||
}
|
||||
|
||||
public static FImage getPlayerAvatar(final Player p) {
|
||||
public static FImage getPlayerAvatar(final PlayerView p) {
|
||||
LobbyPlayer lp = p.getLobbyPlayer();
|
||||
FImage avatar = avatarImages.get(lp);
|
||||
if (avatar == null) {
|
||||
|
||||
@@ -9,9 +9,9 @@ import java.util.Map.Entry;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.menu.FMenuBar;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
@@ -34,20 +34,22 @@ import forge.animation.AbilityEffect;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinTexture;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.util.Callback;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class MatchScreen extends FScreen {
|
||||
public static FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS);
|
||||
|
||||
private final Map<Player, VPlayerPanel> playerPanels = new HashMap<Player, VPlayerPanel>();
|
||||
private final IGameView gameView;
|
||||
private final Map<PlayerView, VPlayerPanel> playerPanels = Maps.newHashMap();
|
||||
private final VPrompt prompt;
|
||||
private final VLog log;
|
||||
private final VStack stack;
|
||||
@@ -56,8 +58,9 @@ public class MatchScreen extends FScreen {
|
||||
private VPlayerPanel bottomPlayerPanel, topPlayerPanel;
|
||||
private AbilityEffect activeEffect;
|
||||
|
||||
public MatchScreen(Game game, Player localPlayer, List<VPlayerPanel> playerPanels0) {
|
||||
public MatchScreen(final IGameView game, PlayerView localPlayer, List<VPlayerPanel> playerPanels0) {
|
||||
super(new FMenuBar());
|
||||
this.gameView = game;
|
||||
|
||||
scroller = add(new FieldScroller());
|
||||
for (VPlayerPanel playerPanel : playerPanels0) {
|
||||
@@ -72,19 +75,19 @@ public class MatchScreen extends FScreen {
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
FControl.getInputProxy().selectButtonOK();
|
||||
game.selectButtonOk();
|
||||
}
|
||||
},
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
FControl.getInputProxy().selectButtonCancel();
|
||||
game.selectButtonCancel();
|
||||
}
|
||||
}));
|
||||
|
||||
log = new VLog(game.getGameLog());
|
||||
log = new VLog(game);
|
||||
log.setDropDownContainer(this);
|
||||
stack = new VStack(game.getStack(), localPlayer);
|
||||
stack = new VStack(game, localPlayer);
|
||||
stack.setDropDownContainer(this);
|
||||
devMenu = new VDevMenu();
|
||||
devMenu.setDropDownContainer(this);
|
||||
@@ -93,7 +96,7 @@ public class MatchScreen extends FScreen {
|
||||
players.setDropDownContainer(this);
|
||||
|
||||
FMenuBar menuBar = (FMenuBar)getHeader();
|
||||
menuBar.addTab("Game", new VGameMenu(localPlayer));
|
||||
menuBar.addTab("Game", new VGameMenu());
|
||||
menuBar.addTab("Players (" + playerPanels.size() + ")", players);
|
||||
menuBar.addTab("Log", log);
|
||||
menuBar.addTab("Dev", devMenu);
|
||||
@@ -126,7 +129,7 @@ public class MatchScreen extends FScreen {
|
||||
return bottomPlayerPanel;
|
||||
}
|
||||
|
||||
public Map<Player, VPlayerPanel> getPlayerPanels() {
|
||||
public Map<PlayerView, VPlayerPanel> getPlayerPanels() {
|
||||
return playerPanels;
|
||||
}
|
||||
|
||||
@@ -146,12 +149,12 @@ public class MatchScreen extends FScreen {
|
||||
@Override
|
||||
protected void drawOverlay(Graphics g) {
|
||||
//draw arrows for paired cards
|
||||
HashSet<Card> pairedCards = new HashSet<Card>();
|
||||
HashSet<CardView> pairedCards = new HashSet<CardView>();
|
||||
for (VPlayerPanel playerPanel : playerPanels.values()) {
|
||||
for (Card card : playerPanel.getField().getRow1().getOrderedCards()) {
|
||||
for (CardView card : playerPanel.getField().getRow1().getOrderedCards()) {
|
||||
if (pairedCards.contains(card)) { continue; } //prevent arrows going both ways
|
||||
|
||||
Card paired = card.getPairedWith();
|
||||
CardView paired = card.getPairedWith();
|
||||
if (paired != null) {
|
||||
TargetingOverlay.drawArrow(g, card, paired);
|
||||
}
|
||||
@@ -159,18 +162,16 @@ public class MatchScreen extends FScreen {
|
||||
}
|
||||
|
||||
//draw arrows for combat
|
||||
final Combat combat = FControl.getGame().getCombat();
|
||||
final CombatView combat = gameView.getCombat();
|
||||
if (combat != null) {
|
||||
for (final CardView attacker : combat.getAttackers()) {
|
||||
//connect each attacker with planeswalker it's attacking if applicable
|
||||
for (Card planeswalker : combat.getDefendingPlaneswalkers()) {
|
||||
for (Card attacker : combat.getAttackersOf(planeswalker)) {
|
||||
TargetingOverlay.drawArrow(g, attacker, planeswalker);
|
||||
final GameEntityView defender = combat.getDefender(attacker);
|
||||
if (defender instanceof CardView) {
|
||||
TargetingOverlay.drawArrow(g, attacker, (CardView) defender);
|
||||
}
|
||||
}
|
||||
|
||||
//connect each blocker with the attacker it's blocking
|
||||
for (Card blocker : combat.getAllBlockers()) {
|
||||
for (Card attacker : combat.getAttackersBlockedBy(blocker)) {
|
||||
for (final CardView blocker : combat.getBlockers(attacker)) {
|
||||
TargetingOverlay.drawArrow(g, blocker, attacker);
|
||||
}
|
||||
}
|
||||
@@ -214,7 +215,7 @@ public class MatchScreen extends FScreen {
|
||||
break;
|
||||
case Keys.Z: //undo on Ctrl+Z
|
||||
if (KeyInputAdapter.isCtrlKeyDown()) {
|
||||
MatchUtil.undoLastAction();
|
||||
gameView.tryUndoLastAction();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -20,10 +20,10 @@ package forge.screens.match;
|
||||
import forge.Graphics;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.screens.match.views.VCardDisplayArea.CardAreaPanel;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
@@ -49,17 +49,17 @@ public class TargetingOverlay {
|
||||
private TargetingOverlay() {
|
||||
}
|
||||
|
||||
public static void drawArrow(Graphics g, Card startCard, Card endCard) {
|
||||
public static void drawArrow(Graphics g, CardView startCard, CardView endCard) {
|
||||
drawArrow(g, CardAreaPanel.get(startCard).getTargetingArrowOrigin(),
|
||||
CardAreaPanel.get(endCard).getTargetingArrowOrigin(),
|
||||
startCard.getOwner().isOpponentOf(endCard.getOwner()));
|
||||
}
|
||||
public static void drawArrow(Graphics g, Vector2 start, Card targetCard, boolean connectsFoes) {
|
||||
public static void drawArrow(Graphics g, Vector2 start, CardView targetCard, boolean connectsFoes) {
|
||||
drawArrow(g, start,
|
||||
CardAreaPanel.get(targetCard).getTargetingArrowOrigin(),
|
||||
connectsFoes);
|
||||
}
|
||||
public static void drawArrow(Graphics g, Vector2 start, Player targetPlayer, boolean connectsFoes) {
|
||||
public static void drawArrow(Graphics g, Vector2 start, PlayerView targetPlayer, boolean connectsFoes) {
|
||||
drawArrow(g, start,
|
||||
FControl.getPlayerPanel(targetPlayer).getAvatar().getTargetingArrowOrigin(),
|
||||
connectsFoes);
|
||||
|
||||
@@ -24,10 +24,6 @@ import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.card.CardZoom;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.Player;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FCardPanel;
|
||||
@@ -41,6 +37,10 @@ import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.util.Callback;
|
||||
import forge.util.Utils;
|
||||
import forge.util.WaitCallback;
|
||||
import forge.view.CardView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -49,12 +49,11 @@ import java.util.Map;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
|
||||
|
||||
public class VAssignDamage extends FDialog {
|
||||
private static final float CARD_GAP_X = Utils.scaleX(10);
|
||||
private static final float ADD_BTN_HEIGHT = Utils.AVG_FINGER_HEIGHT * 0.75f;
|
||||
|
||||
private final Callback<Map<Card, Integer>> callback;
|
||||
private final Callback<Map<CardView, Integer>> callback;
|
||||
private final int totalDamageToAssign;
|
||||
|
||||
private boolean attackerHasDeathtouch = false;
|
||||
@@ -62,7 +61,7 @@ public class VAssignDamage extends FDialog {
|
||||
private boolean attackerHasInfect = false;
|
||||
private boolean overrideCombatantOrder = false;
|
||||
|
||||
private final GameEntity defender;
|
||||
private final GameEntityView defender;
|
||||
|
||||
private final FLabel lblTotalDamage = add(new FLabel.Builder().text("Available damage points: Unknown").align(HAlignment.CENTER).build());
|
||||
private final FLabel lblAssignRemaining = add(new FLabel.Builder().text("Distribute the remaining damage points among lethally wounded entities").align(HAlignment.CENTER).build());
|
||||
@@ -76,9 +75,9 @@ public class VAssignDamage extends FDialog {
|
||||
|
||||
// Indexes of defenders correspond to their indexes in the damage list and labels.
|
||||
private final List<DamageTarget> defenders = new ArrayList<DamageTarget>(); // NULL in this map means defender
|
||||
private final Map<Card, DamageTarget> damage = new HashMap<Card, DamageTarget>(); // NULL in this map means defender
|
||||
private final Map<CardView, DamageTarget> damage = new HashMap<CardView, DamageTarget>(); // NULL in this map means defender
|
||||
|
||||
private boolean canAssignTo(Card card) {
|
||||
private boolean canAssignTo(CardView card) {
|
||||
for (DamageTarget dt : defenders) {
|
||||
if (dt.card == card) { return true; }
|
||||
if (getDamageToKill(dt.card) > dt.damage) {
|
||||
@@ -91,24 +90,24 @@ public class VAssignDamage extends FDialog {
|
||||
/** Constructor.
|
||||
*
|
||||
* @param attacker0 {@link forge.game.card.Card}
|
||||
* @param defenderCards List<{@link forge.game.card.Card}>
|
||||
* @param blockers List<{@link forge.game.card.Card}>
|
||||
* @param damage0 int
|
||||
* @param defender GameEntity that's bein attacked
|
||||
* @param overrideOrder override combatant order
|
||||
*/
|
||||
public VAssignDamage(final Card attacker, final List<Card> defenderCards, final int damage0, final GameEntity defender0, boolean overrideOrder, final Callback<Map<Card, Integer>> callback0) {
|
||||
super("Assign damage dealt by " + attacker.getName());
|
||||
public VAssignDamage(final CardView attacker, final List<CardView> blockers, final int damage0, final GameEntityView defender0, boolean overrideOrder, final WaitCallback<Map<CardView, Integer>> waitCallback) {
|
||||
super("Assign damage dealt by " + attacker);
|
||||
|
||||
callback = callback0;
|
||||
callback = waitCallback;
|
||||
totalDamageToAssign = damage0;
|
||||
defender = defender0;
|
||||
attackerHasDeathtouch = attacker.hasKeyword("Deathtouch");
|
||||
attackerHasInfect = attacker.hasKeyword("Infect");
|
||||
attackerHasTrample = defender != null && attacker.hasKeyword("Trample");
|
||||
attackerHasDeathtouch = attacker.getOriginal().hasDeathtouch();
|
||||
attackerHasInfect = attacker.getOriginal().hasInfect();
|
||||
attackerHasTrample = defender != null && attacker.getOriginal().hasTrample();
|
||||
overrideCombatantOrder = overrideOrder;
|
||||
|
||||
pnlAttacker = add(new AttDefCardPanel(attacker));
|
||||
pnlDefenders = add(new DefendersPanel(defenderCards));
|
||||
pnlDefenders = add(new DefendersPanel(blockers));
|
||||
|
||||
btnAuto.setCommand(new FEventHandler() {
|
||||
@Override
|
||||
@@ -174,8 +173,8 @@ public class VAssignDamage extends FDialog {
|
||||
}
|
||||
|
||||
private class DefendersPanel extends FScrollPane {
|
||||
private DefendersPanel(final List<Card> defenderCards) {
|
||||
for (final Card c : defenderCards) {
|
||||
private DefendersPanel(final List<CardView> defenderCards) {
|
||||
for (final CardView c : defenderCards) {
|
||||
addDamageTarget(c);
|
||||
}
|
||||
|
||||
@@ -185,7 +184,7 @@ public class VAssignDamage extends FDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private void addDamageTarget(Card card) {
|
||||
private void addDamageTarget(CardView card) {
|
||||
DamageTarget dt = add(new DamageTarget(card));
|
||||
damage.put(card, dt);
|
||||
defenders.add(dt);
|
||||
@@ -211,25 +210,25 @@ public class VAssignDamage extends FDialog {
|
||||
}
|
||||
|
||||
private class DamageTarget extends FContainer {
|
||||
private final Card card;
|
||||
private final CardView card;
|
||||
private final FDisplayObject obj;
|
||||
private final FLabel label, btnSubtract, btnAdd;
|
||||
private int damage;
|
||||
|
||||
public DamageTarget(Card card0) {
|
||||
public DamageTarget(CardView card0) {
|
||||
card = card0;
|
||||
if (card != null) {
|
||||
obj = add(new AttDefCardPanel(card));
|
||||
}
|
||||
else if (defender instanceof Card) {
|
||||
obj = add(new AttDefCardPanel((Card)defender));
|
||||
else if (defender instanceof CardView) {
|
||||
obj = add(new AttDefCardPanel((CardView)defender));
|
||||
}
|
||||
else if (defender instanceof Player) {
|
||||
Player player = (Player)defender;
|
||||
else if (defender instanceof PlayerView) {
|
||||
PlayerView player = (PlayerView)defender;
|
||||
obj = add(new MiscAttDefPanel(player.getName(), FControl.getPlayerAvatar(player)));
|
||||
}
|
||||
else {
|
||||
obj = add(new MiscAttDefPanel(defender.getName(), FSkinImage.UNKNOWN));
|
||||
obj = add(new MiscAttDefPanel(defender.toString(), FSkinImage.UNKNOWN));
|
||||
}
|
||||
label = add(new FLabel.Builder().text("0").font(FSkinFont.get(18)).align(HAlignment.CENTER).build());
|
||||
btnSubtract = add(new FLabel.ButtonBuilder().icon(FSkinImage.MINUS).command(new FEventHandler() {
|
||||
@@ -262,7 +261,7 @@ public class VAssignDamage extends FDialog {
|
||||
}
|
||||
|
||||
private static class AttDefCardPanel extends FCardPanel {
|
||||
private AttDefCardPanel(Card card) {
|
||||
private AttDefCardPanel(CardView card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@@ -304,7 +303,7 @@ public class VAssignDamage extends FDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private void assignDamageTo(Card source, boolean isAdding) {
|
||||
private void assignDamageTo(CardView source, boolean isAdding) {
|
||||
if (!damage.containsKey(source)) {
|
||||
source = null;
|
||||
}
|
||||
@@ -394,7 +393,7 @@ public class VAssignDamage extends FDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private void addDamage(final Card card, int addedDamage) {
|
||||
private void addDamage(final CardView card, int addedDamage) {
|
||||
// If we don't have enough left or we're trying to unassign too much return
|
||||
int canAssign = getRemainingDamage();
|
||||
if (canAssign < addedDamage) {
|
||||
@@ -452,16 +451,16 @@ public class VAssignDamage extends FDialog {
|
||||
callback.run(getDamageMap());
|
||||
}
|
||||
|
||||
private int getDamageToKill(Card source) {
|
||||
private int getDamageToKill(CardView source) {
|
||||
int lethalDamage = 0;
|
||||
if (source == null) {
|
||||
if (defender instanceof Player) {
|
||||
Player p = (Player)defender;
|
||||
lethalDamage = attackerHasInfect ? p.getGame().getRules().getPoisonCountersToLose() - p.getPoisonCounters() : p.getLife();
|
||||
if (defender instanceof PlayerView) {
|
||||
PlayerView p = (PlayerView)defender;
|
||||
lethalDamage = attackerHasInfect ? FControl.getGameView().getPoisonCountersToLose() - p.getPoisonCounters() : p.getLife();
|
||||
}
|
||||
else if (defender instanceof Card) { // planeswalker
|
||||
Card pw = (Card)defender;
|
||||
lethalDamage = pw.getCounters(CounterType.LOYALTY);
|
||||
else if (defender instanceof CardView) { // planeswalker
|
||||
CardView pw = (CardView)defender;
|
||||
lethalDamage = pw.getOriginal().getLoyalty();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -470,8 +469,8 @@ public class VAssignDamage extends FDialog {
|
||||
return lethalDamage;
|
||||
}
|
||||
|
||||
public Map<Card, Integer> getDamageMap() {
|
||||
Map<Card, Integer> result = new HashMap<Card, Integer>();
|
||||
public Map<CardView, Integer> getDamageMap() {
|
||||
Map<CardView, Integer> result = new HashMap<CardView, Integer>();
|
||||
for (DamageTarget dt : defenders) {
|
||||
result.put(dt.card, dt.damage);
|
||||
}
|
||||
|
||||
@@ -4,20 +4,20 @@ import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import forge.Graphics;
|
||||
import forge.assets.FImage;
|
||||
import forge.game.player.Player;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.util.ThreadUtil;
|
||||
import forge.util.Utils;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VAvatar extends FDisplayObject {
|
||||
public static final float WIDTH = Utils.AVG_FINGER_WIDTH;
|
||||
public static final float HEIGHT = Utils.AVG_FINGER_HEIGHT;
|
||||
|
||||
private final Player player;
|
||||
private final PlayerView player;
|
||||
private final FImage image;
|
||||
|
||||
public VAvatar(Player player0) {
|
||||
public VAvatar(PlayerView player0) {
|
||||
player = player0;
|
||||
image = FControl.getPlayerAvatar(player);
|
||||
setSize(WIDTH, HEIGHT);
|
||||
@@ -28,7 +28,7 @@ public class VAvatar extends FDisplayObject {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //must invoke in game thread in case a dialog needs to be shown
|
||||
@Override
|
||||
public void run() {
|
||||
FControl.getInputProxy().selectPlayer(player, null);
|
||||
FControl.getGameView().selectPlayer(player, null);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
||||
@@ -9,19 +9,20 @@ import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Graphics;
|
||||
import forge.GuiBase;
|
||||
import forge.card.CardZoom;
|
||||
import forge.game.card.Card;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.toolbox.FCardPanel;
|
||||
import forge.util.ThreadUtil;
|
||||
import forge.view.CardView;
|
||||
|
||||
public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
private static final float CARD_STACK_OFFSET = 0.2f;
|
||||
|
||||
protected final List<Card> orderedCards = new ArrayList<Card>();
|
||||
protected final List<CardView> orderedCards = new ArrayList<CardView>();
|
||||
protected final List<CardAreaPanel> cardPanels = new ArrayList<CardAreaPanel>();
|
||||
|
||||
public Iterable<Card> getOrderedCards() {
|
||||
public Iterable<CardView> getOrderedCards() {
|
||||
return orderedCards;
|
||||
}
|
||||
|
||||
@@ -34,12 +35,12 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
return cardPanels.size();
|
||||
}
|
||||
|
||||
protected void refreshCardPanels(List<Card> model) {
|
||||
protected void refreshCardPanels(List<CardView> model) {
|
||||
clear();
|
||||
|
||||
CardAreaPanel newCardPanel = null;
|
||||
for (Card card : model) {
|
||||
if (card.getCardForUi() == card) { //only include cards that are meant for display
|
||||
for (CardView card : model) {
|
||||
if (card.isUiDisplayable()) { //only include cards that are meant for display
|
||||
CardAreaPanel cardPanel = CardAreaPanel.get(card);
|
||||
addCardPanelToDisplayArea(cardPanel);
|
||||
cardPanels.add(cardPanel);
|
||||
@@ -73,7 +74,7 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
}
|
||||
|
||||
public final void removeCardPanel(final CardAreaPanel fromPanel) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
/*if (CardPanelContainer.this.getMouseDragPanel() != null) {
|
||||
CardPanel.getDragAnimationPanel().setVisible(false);
|
||||
CardPanel.getDragAnimationPanel().repaint();
|
||||
@@ -152,11 +153,11 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
public static class CardAreaPanel extends FCardPanel {
|
||||
private static final Map<Integer, CardAreaPanel> allCardPanels = new HashMap<Integer, CardAreaPanel>();
|
||||
|
||||
public static CardAreaPanel get(Card card0) {
|
||||
CardAreaPanel cardPanel = allCardPanels.get(card0.getUniqueNumber());
|
||||
public static CardAreaPanel get(CardView card0) {
|
||||
CardAreaPanel cardPanel = allCardPanels.get(card0.getId());
|
||||
if (cardPanel == null || cardPanel.getCard() != card0) { //replace card panel if card copied
|
||||
cardPanel = new CardAreaPanel(card0);
|
||||
allCardPanels.put(card0.getUniqueNumber(), cardPanel);
|
||||
allCardPanels.put(card0.getId(), cardPanel);
|
||||
}
|
||||
return cardPanel;
|
||||
}
|
||||
@@ -178,7 +179,7 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
private CardAreaPanel nextPanelInStack, prevPanelInStack;
|
||||
|
||||
//use static get(card) function instead
|
||||
private CardAreaPanel(Card card0) {
|
||||
private CardAreaPanel(CardView card0) {
|
||||
super(card0);
|
||||
}
|
||||
|
||||
@@ -244,7 +245,7 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
}
|
||||
|
||||
public boolean selectCard() {
|
||||
if (FControl.getInputProxy().selectCard(getCard(), null)) {
|
||||
if (FControl.getGameView().selectCard(getCard(), null)) {
|
||||
return true;
|
||||
}
|
||||
//if panel can't do anything with card selection, try selecting previous panel in stack
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package forge.screens.match.views;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.game.player.Player;
|
||||
import forge.menu.FCheckBoxMenuItem;
|
||||
import forge.menu.FDropDownMenu;
|
||||
import forge.menu.FMenuItem;
|
||||
@@ -11,7 +9,6 @@ import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.util.GuiDisplayUtil;
|
||||
import forge.util.ThreadUtil;
|
||||
|
||||
public class VDevMenu extends FDropDownMenu {
|
||||
@@ -23,7 +20,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //must invoke all these in game thread since they may require synchronous user input
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModeGenerateMana();
|
||||
FControl.getGameView().devGenerateMana();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -34,7 +31,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModeTutor();
|
||||
FControl.getGameView().devTutorForCard();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -45,7 +42,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModeCardToHand();
|
||||
FControl.getGameView().devAddCardToHand();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -56,7 +53,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModeCardToBattlefield();
|
||||
FControl.getGameView().devAddCardToBattlefield();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -67,7 +64,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModeSetLife();
|
||||
FControl.getGameView().devSetPlayerLife();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -78,7 +75,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModeWinGame();
|
||||
FControl.getGameView().devWinGame();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -89,7 +86,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devSetupGameState();
|
||||
FControl.getGameView().devSetupGameState();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -102,12 +99,8 @@ public class VDevMenu extends FDropDownMenu {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
boolean unlimitedLands = !prefs.getPrefBoolean(FPref.DEV_UNLIMITED_LAND);
|
||||
FControl.getGameView().devTogglePlayManyLands(unlimitedLands);
|
||||
|
||||
for (Player p : FControl.getGame().getPlayers()) {
|
||||
if (p.getLobbyPlayer() == GuiBase.getInterface().getGuiPlayer() ) {
|
||||
p.canCheatPlayUnlimitedLands = unlimitedLands;
|
||||
}
|
||||
}
|
||||
// probably will need to call a synchronized method to have the game thread see changed value of the variable
|
||||
|
||||
prefs.setPref(FPref.DEV_UNLIMITED_LAND, String.valueOf(unlimitedLands));
|
||||
@@ -120,7 +113,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModeAddCounter();
|
||||
FControl.getGameView().devAddCounterToPermanent();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -131,7 +124,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModeTapPerm();
|
||||
FControl.getGameView().devTapPermanent();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -142,7 +135,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModeUntapPerm();
|
||||
FControl.getGameView().devUntapPermanent();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -153,7 +146,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModeRiggedPlanarRoll();
|
||||
FControl.getGameView().devRiggedPlanerRoll();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -164,7 +157,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiDisplayUtil.devModePlaneswalkTo();
|
||||
FControl.getGameView().devPlaneswalkTo();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,21 +4,21 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.GuiBase;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.screens.match.FControl.CardDetails;
|
||||
import forge.screens.match.views.VCardDisplayArea.CardAreaPanel;
|
||||
import forge.toolbox.FContainer;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VField extends FContainer {
|
||||
private final Player player;
|
||||
private final PlayerView player;
|
||||
private final FieldRow row1, row2;
|
||||
private boolean flipped;
|
||||
private float commandZoneWidth;
|
||||
|
||||
public VField(Player player0) {
|
||||
public VField(PlayerView player0) {
|
||||
player = player0;
|
||||
row1 = add(new FieldRow());
|
||||
row2 = add(new FieldRow());
|
||||
@@ -43,7 +43,7 @@ public class VField extends FContainer {
|
||||
}
|
||||
|
||||
public void update() {
|
||||
FThreads.invokeInEdtNowOrLater(updateRoutine);
|
||||
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), updateRoutine);
|
||||
}
|
||||
|
||||
private final Runnable updateRoutine = new Runnable() {
|
||||
@@ -51,25 +51,25 @@ public class VField extends FContainer {
|
||||
public void run() {
|
||||
clear();
|
||||
|
||||
List<Card> model = player.getZone(ZoneType.Battlefield).getCards();
|
||||
for (Card card : model) {
|
||||
List<CardView> model = player.getBfCards();
|
||||
for (CardView card : model) {
|
||||
updateCard(card);
|
||||
}
|
||||
|
||||
List<Card> creatures = new ArrayList<Card>();
|
||||
List<Card> lands = new ArrayList<Card>();
|
||||
List<Card> otherPermanents = new ArrayList<Card>();
|
||||
List<CardView> creatures = new ArrayList<CardView>();
|
||||
List<CardView> lands = new ArrayList<CardView>();
|
||||
List<CardView> otherPermanents = new ArrayList<CardView>();
|
||||
|
||||
for (Card card : model) {
|
||||
for (CardView card : model) {
|
||||
CardAreaPanel cardPanel = CardAreaPanel.get(card);
|
||||
CardDetails details = FControl.getCardDetails(card); //use details so creature/land check is accurate
|
||||
CardStateView details = FControl.getCardDetails(card); //use details so creature/land check is accurate
|
||||
if (cardPanel.getAttachedToPanel() == null) { //skip attached panels
|
||||
if (details.isCreature) {
|
||||
if (details.isCreature()) {
|
||||
if (!tryStackCard(card, creatures)) {
|
||||
creatures.add(card);
|
||||
}
|
||||
}
|
||||
else if (details.isLand) {
|
||||
else if (details.isLand()) {
|
||||
if (!tryStackCard(card, lands)) {
|
||||
lands.add(card);
|
||||
}
|
||||
@@ -94,16 +94,17 @@ public class VField extends FContainer {
|
||||
}
|
||||
};
|
||||
|
||||
private boolean tryStackCard(Card card, List<Card> cardsOfType) {
|
||||
private boolean tryStackCard(CardView card, List<CardView> cardsOfType) {
|
||||
if (card.isEnchanted() || card.isEquipped()) {
|
||||
return false; //can stack with enchanted or equipped card
|
||||
}
|
||||
if (card.isCreature() && !card.isToken()) {
|
||||
if (card.getOriginal().isCreature() && !card.isToken()) {
|
||||
return false; //don't stack non-token creatures
|
||||
}
|
||||
for (Card c : cardsOfType) {
|
||||
final String cardName = card.getOriginal().getName();
|
||||
for (CardView c : cardsOfType) {
|
||||
if (!c.isEnchanted() && !c.isEquipped() &&
|
||||
card.getName().equals(c.getName()) &&
|
||||
cardName.equals(c.getOriginal().getName()) &&
|
||||
card.getCounters().equals(card.getCounters()) &&
|
||||
card.isToken() == c.isToken()) { //don't stack tokens on top of non-tokens
|
||||
CardAreaPanel cPanel = CardAreaPanel.get(c);
|
||||
@@ -119,7 +120,7 @@ public class VField extends FContainer {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateCard(final Card card) {
|
||||
public void updateCard(final CardView card) {
|
||||
final CardAreaPanel toPanel = CardAreaPanel.get(card);
|
||||
if (toPanel == null) { return; }
|
||||
|
||||
@@ -134,8 +135,8 @@ public class VField extends FContainer {
|
||||
|
||||
toPanel.getAttachedPanels().clear();
|
||||
if (card.isEnchanted()) {
|
||||
final ArrayList<Card> enchants = card.getEnchantedBy();
|
||||
for (final Card e : enchants) {
|
||||
final Iterable<CardView> enchants = card.getEnchantedBy();
|
||||
for (final CardView e : enchants) {
|
||||
final CardAreaPanel cardE = CardAreaPanel.get(e);
|
||||
if (cardE != null) {
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
@@ -144,8 +145,8 @@ public class VField extends FContainer {
|
||||
}
|
||||
|
||||
if (card.isEquipped()) {
|
||||
final ArrayList<Card> enchants = card.getEquippedBy();
|
||||
for (final Card e : enchants) {
|
||||
final Iterable<CardView> enchants = card.getEquippedBy();
|
||||
for (final CardView e : enchants) {
|
||||
final CardAreaPanel cardE = CardAreaPanel.get(e);
|
||||
if (cardE != null) {
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
@@ -154,8 +155,8 @@ public class VField extends FContainer {
|
||||
}
|
||||
|
||||
if (card.isFortified()) {
|
||||
final ArrayList<Card> fortifications = card.getFortifiedBy();
|
||||
for (final Card e : fortifications) {
|
||||
final Iterable<CardView> fortifications = card.getFortifiedBy();
|
||||
for (final CardView e : fortifications) {
|
||||
final CardAreaPanel cardE = CardAreaPanel.get(e);
|
||||
if (cardE != null) {
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
@@ -163,14 +164,14 @@ public class VField extends FContainer {
|
||||
}
|
||||
}
|
||||
|
||||
if (card.isEnchantingCard()) {
|
||||
if (card.getEnchantingCard() != null) {
|
||||
toPanel.setAttachedToPanel(CardAreaPanel.get(card.getEnchantingCard()));
|
||||
}
|
||||
else if (card.isEquipping()) {
|
||||
toPanel.setAttachedToPanel(CardAreaPanel.get(card.getEquipping().get(0)));
|
||||
else if (card.getEquipping() != null) {
|
||||
toPanel.setAttachedToPanel(CardAreaPanel.get(card.getEquipping()));
|
||||
}
|
||||
else if (card.isFortifying()) {
|
||||
toPanel.setAttachedToPanel(CardAreaPanel.get(card.getFortifying().get(0)));
|
||||
else if (card.getFortifying() != null) {
|
||||
toPanel.setAttachedToPanel(CardAreaPanel.get(card.getFortifying()));
|
||||
}
|
||||
else {
|
||||
toPanel.setAttachedToPanel(null);
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
package forge.screens.match.views;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.player.Player;
|
||||
import forge.GuiBase;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VFlashbackZone extends VCardDisplayArea {
|
||||
private final Player player;
|
||||
private final PlayerView player;
|
||||
|
||||
public VFlashbackZone(Player player0) {
|
||||
public VFlashbackZone(PlayerView player0) {
|
||||
player = player0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
FThreads.invokeInEdtNowOrLater(updateRoutine);
|
||||
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), updateRoutine);
|
||||
}
|
||||
|
||||
private final Runnable updateRoutine = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
refreshCardPanels(player.getCardsActivableInExternalZones(false));
|
||||
refreshCardPanels(player.getFlashbackCards());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package forge.screens.match.views;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.deck.FDeckViewer;
|
||||
import forge.game.io.GameStateDeserializer;
|
||||
@@ -7,7 +9,6 @@ import forge.game.io.GameStateSerializer;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.menu.FDropDownMenu;
|
||||
import forge.menu.FMenuItem;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.screens.settings.SettingsScreen;
|
||||
@@ -40,7 +41,8 @@ public class VGameMenu extends FDropDownMenu {
|
||||
addItem(new FMenuItem("Deck List", FSkinImage.DECKLIST, new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
RegisteredPlayer player = GamePlayerUtil.getGuiRegisteredPlayer(FControl.getGame());
|
||||
final LobbyPlayer guiPlayer = GuiBase.getInterface().getGuiPlayer();
|
||||
final RegisteredPlayer player = FControl.getGameView().getGuiRegisteredPlayer(guiPlayer);
|
||||
if (player != null) {
|
||||
FDeckViewer.show(player.getDeck());
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.TextRenderer;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.game.GameLog;
|
||||
import forge.game.GameLogEntry;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.menu.FDropDown;
|
||||
@@ -17,6 +16,7 @@ import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.util.Utils;
|
||||
import forge.view.IGameView;
|
||||
|
||||
public class VLog extends FDropDown {
|
||||
private static final float PADDING = Utils.scaleMin(5);
|
||||
@@ -25,10 +25,10 @@ public class VLog extends FDropDown {
|
||||
private static final FSkinColor ROW_COLOR = ALT_ROW_COLOR.darker();
|
||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||
|
||||
private final GameLog log;
|
||||
private final IGameView gameView;
|
||||
|
||||
public VLog(GameLog log0) {
|
||||
log = log0;
|
||||
public VLog(IGameView log0) {
|
||||
gameView = log0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +48,7 @@ public class VLog extends FDropDown {
|
||||
clear();
|
||||
|
||||
GameLogEntryType logVerbosityFilter = GameLogEntryType.valueOf(FModel.getPreferences().getPref(FPref.DEV_LOG_ENTRY_TYPE));
|
||||
List<GameLogEntry> logEntrys = log.getLogEntries(logVerbosityFilter);
|
||||
List<GameLogEntry> logEntrys = gameView.getLogEntries(logVerbosityFilter);
|
||||
|
||||
LogEntryDisplay logEntryDisplay;
|
||||
float width = maxWidth - getMenuTab().getScreenPosition().x; //stretch from tab to edge of screen
|
||||
|
||||
@@ -12,22 +12,19 @@ import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.card.MagicColor;
|
||||
import forge.game.mana.ManaPool;
|
||||
import forge.game.player.Player;
|
||||
import forge.match.input.Input;
|
||||
import forge.match.input.InputPayMana;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VManaPool extends VDisplayArea {
|
||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||
private static final FSkinFont FONT = FSkinFont.get(16);
|
||||
|
||||
private final Player player;
|
||||
private final PlayerView player;
|
||||
private final List<ManaLabel> manaLabels = new ArrayList<ManaLabel>();
|
||||
private int totalMana;
|
||||
|
||||
public VManaPool(Player player0) {
|
||||
public VManaPool(PlayerView player0) {
|
||||
player = player0;
|
||||
|
||||
addManaLabel(FSkinImage.MANA_COLORLESS, MagicColor.COLORLESS);
|
||||
@@ -50,9 +47,8 @@ public class VManaPool extends VDisplayArea {
|
||||
@Override
|
||||
public void update() {
|
||||
totalMana = 0;
|
||||
ManaPool m = player.getManaPool();
|
||||
for (ManaLabel label : manaLabels) {
|
||||
int colorCount = m.getAmountOfColor(label.colorCode);
|
||||
int colorCount = player.getMana(label.colorCode);
|
||||
totalMana += colorCount;
|
||||
label.text = Integer.toString(colorCount);
|
||||
}
|
||||
@@ -86,11 +82,7 @@ public class VManaPool extends VDisplayArea {
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
if (player.getLobbyPlayer() == GuiBase.getInterface().getGuiPlayer()) {
|
||||
final Input input = FControl.getInputQueue().getInput();
|
||||
if (input instanceof InputPayMana) {
|
||||
// Do something
|
||||
((InputPayMana) input).useManaFromPool(colorCode);
|
||||
}
|
||||
FControl.getGameView().useMana(colorCode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@ import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -23,6 +21,8 @@ import forge.screens.match.MatchScreen;
|
||||
import forge.toolbox.FContainer;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VPlayerPanel extends FContainer {
|
||||
private static final FSkinFont LIFE_FONT = FSkinFont.get(18);
|
||||
@@ -32,7 +32,7 @@ public class VPlayerPanel extends FContainer {
|
||||
private static final float INFO_TAB_PADDING_X = Utils.scaleX(2);
|
||||
private static final float INFO_TAB_PADDING_Y = Utils.scaleY(2);
|
||||
|
||||
private final Player player;
|
||||
private final PlayerView player;
|
||||
private final VPhaseIndicator phaseIndicator;
|
||||
private final VField field;
|
||||
private final VAvatar avatar;
|
||||
@@ -44,7 +44,7 @@ public class VPlayerPanel extends FContainer {
|
||||
private final List<InfoTab> tabs = new ArrayList<InfoTab>();
|
||||
private InfoTab selectedTab;
|
||||
|
||||
public VPlayerPanel(Player player0) {
|
||||
public VPlayerPanel(PlayerView player0) {
|
||||
player = player0;
|
||||
phaseIndicator = add(new VPhaseIndicator());
|
||||
field = add(new VField(player));
|
||||
@@ -67,7 +67,7 @@ public class VPlayerPanel extends FContainer {
|
||||
commandZone = add(new CommandZoneDisplay(player));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
public PlayerView getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ public class VPlayerPanel extends FContainer {
|
||||
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
FControl.getInputProxy().selectPlayer(player, null); //treat tapping on life the same as tapping on the avatar
|
||||
FControl.getGameView().selectPlayer(player, null); //treat tapping on life the same as tapping on the avatar
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -411,12 +411,12 @@ public class VPlayerPanel extends FContainer {
|
||||
}
|
||||
|
||||
private class CommandZoneDisplay extends VZoneDisplay {
|
||||
private CommandZoneDisplay(Player player0) {
|
||||
private CommandZoneDisplay(PlayerView player0) {
|
||||
super(player0, ZoneType.Command);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshCardPanels(List<Card> model) {
|
||||
protected void refreshCardPanels(List<CardView> model) {
|
||||
int oldCount = getCount();
|
||||
super.refreshCardPanels(model);
|
||||
int newCount = getCount();
|
||||
|
||||
@@ -7,11 +7,6 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
import forge.Graphics;
|
||||
import forge.assets.FImage;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.game.GameType;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.menu.FDropDown;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -20,10 +15,12 @@ import forge.toolbox.FContainer;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.toolbox.FList;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VPlayers extends FDropDown {
|
||||
public VPlayers() {
|
||||
for (final Player p : FControl.getSortedPlayers()) {
|
||||
for (final PlayerView p : FControl.getGameView().getPlayers()) {
|
||||
add(new PlayerInfoPanel(p));
|
||||
}
|
||||
}
|
||||
@@ -49,9 +46,9 @@ public class VPlayers extends FDropDown {
|
||||
private static final FSkinFont FONT = FSkinFont.get(12);
|
||||
private static final float PADDING = Utils.scaleMin(5);
|
||||
private static final float HEIGHT = Utils.AVG_FINGER_HEIGHT * 1.8f;
|
||||
private final Player player;
|
||||
private final PlayerView player;
|
||||
|
||||
private PlayerInfoPanel(Player player0) {
|
||||
private PlayerInfoPanel(PlayerView player0) {
|
||||
player = player0;
|
||||
}
|
||||
|
||||
@@ -76,12 +73,12 @@ public class VPlayers extends FDropDown {
|
||||
builder.append(" | Poison counters: " + String.valueOf(player.getPoisonCounters()));
|
||||
builder.append(" | Maximum hand size: " + String.valueOf(player.getMaxHandSize()));
|
||||
builder.append(" | Cards drawn this turn: " + String.valueOf(player.getNumDrawnThisTurn()));
|
||||
builder.append(" | Damage Prevention: " + String.valueOf(player.getPreventNextDamageTotalShields()));
|
||||
builder.append(" | Damage Prevention: " + String.valueOf(player.getPreventNextDamage()));
|
||||
if (!player.getKeywords().isEmpty()) {
|
||||
builder.append(" | " + player.getKeywords().toString());
|
||||
}
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
|
||||
List<Card> list = player.getCardsIn(ZoneType.Ante);
|
||||
List<CardView> list = player.getAnteCards();
|
||||
builder.append(" | Ante'd: ");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
builder.append(list.get(i));
|
||||
@@ -90,8 +87,8 @@ public class VPlayers extends FDropDown {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player.getGame().getRules().getGameType() == GameType.Commander) {
|
||||
builder.append(" | " + CardFactoryUtil.getCommanderInfo(player));
|
||||
if (FControl.getGameView().isCommander()) {
|
||||
builder.append(" | " + player.getCommanderInfo());
|
||||
}
|
||||
|
||||
g.drawText(builder.toString(), FONT, FList.FORE_COLOR, x, y, getWidth() - PADDING - x, h, true, HAlignment.LEFT, true);
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package forge.screens.match.views;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
@@ -17,15 +20,7 @@ import forge.card.CardDetailUtil;
|
||||
import forge.card.CardRenderer;
|
||||
import forge.card.CardZoom;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerController;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.spellability.TargetChoices;
|
||||
import forge.game.zone.MagicStack;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.match.input.InputConfirm;
|
||||
import forge.menu.FCheckBoxMenuItem;
|
||||
import forge.menu.FDropDown;
|
||||
import forge.menu.FMenuItem;
|
||||
@@ -38,6 +33,10 @@ import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.StackItemView;
|
||||
|
||||
public class VStack extends FDropDown {
|
||||
public static final float CARD_WIDTH = Utils.AVG_FINGER_WIDTH;
|
||||
@@ -49,16 +48,16 @@ public class VStack extends FDropDown {
|
||||
private static final float ALPHA_COMPOSITE = 0.5f;
|
||||
private static final TextRenderer textRenderer = new TextRenderer(true);
|
||||
|
||||
private final MagicStack stack;
|
||||
private final Player localPlayer;
|
||||
private final IGameView gameView;
|
||||
private final PlayerView localPlayer;
|
||||
private StackInstanceDisplay activeItem;
|
||||
private SpellAbilityStackInstance activeStackInstance;
|
||||
private Map<Player, Object> playersWithValidTargets;
|
||||
private StackItemView activeStackInstance;
|
||||
private Map<PlayerView, Object> playersWithValidTargets;
|
||||
|
||||
private int stackSize;
|
||||
|
||||
public VStack(MagicStack stack0, Player localPlayer0) {
|
||||
stack = stack0;
|
||||
public VStack(IGameView stack0, PlayerView localPlayer0) {
|
||||
gameView = stack0;
|
||||
localPlayer = localPlayer0;
|
||||
}
|
||||
|
||||
@@ -71,8 +70,12 @@ public class VStack extends FDropDown {
|
||||
private void revealTargetZones() {
|
||||
if (activeStackInstance == null) { return; }
|
||||
|
||||
final List<ZoneType> zones = activeStackInstance.getZonesToOpen();
|
||||
playersWithValidTargets = activeStackInstance.getPlayersWithValidTargets();
|
||||
final Set<ZoneType> zones = new HashSet<ZoneType>();
|
||||
playersWithValidTargets = new HashMap<PlayerView, Object>();
|
||||
for (final CardView c : activeStackInstance.getTargetCards()) {
|
||||
zones.add(c.getZone());
|
||||
playersWithValidTargets.put(c.getController(), c);
|
||||
}
|
||||
if (zones != null && zones.size() > 0 && playersWithValidTargets != null && playersWithValidTargets.size() > 0) {
|
||||
GuiBase.getInterface().openZones(zones, playersWithValidTargets);
|
||||
}
|
||||
@@ -91,6 +94,7 @@ public class VStack extends FDropDown {
|
||||
activeStackInstance = null; //reset before updating stack
|
||||
restoreOldZones();
|
||||
|
||||
final List<StackItemView> stack = gameView.getStack();
|
||||
if (stackSize != stack.size()) {
|
||||
int oldStackSize = stackSize;
|
||||
stackSize = stack.size();
|
||||
@@ -121,6 +125,7 @@ public class VStack extends FDropDown {
|
||||
float totalWidth = Math.min(4 * CARD_WIDTH, maxWidth);
|
||||
float width = totalWidth - 2 * MARGINS;
|
||||
|
||||
final List<StackItemView> stack = gameView.getStack();
|
||||
if (stack.isEmpty()) { //show label if stack empty
|
||||
FLabel label = add(new FLabel.Builder().text("[Empty]").font(FONT).align(HAlignment.CENTER).build());
|
||||
|
||||
@@ -130,10 +135,10 @@ public class VStack extends FDropDown {
|
||||
}
|
||||
else {
|
||||
//iterate stack in reverse so most recent items appear on bottom
|
||||
SpellAbilityStackInstance stackInstance = null;
|
||||
StackItemView stackInstance = null;
|
||||
StackInstanceDisplay display = null;
|
||||
float overlap = Math.round(CARD_HEIGHT / 2 + PADDING + BORDER_THICKNESS);
|
||||
Iterator<SpellAbilityStackInstance> iterator = stack.reverseIterator();
|
||||
Iterator<StackItemView> iterator = stack.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
stackInstance = iterator.next();
|
||||
display = new StackInstanceDisplay(stackInstance, width);
|
||||
@@ -177,36 +182,35 @@ public class VStack extends FDropDown {
|
||||
activeItem.getLeft() + VStack.CARD_WIDTH * FCardPanel.TARGET_ORIGIN_FACTOR_X + VStack.PADDING + VStack.BORDER_THICKNESS,
|
||||
activeItem.getTop() + VStack.CARD_HEIGHT * FCardPanel.TARGET_ORIGIN_FACTOR_Y + VStack.PADDING + VStack.BORDER_THICKNESS);
|
||||
|
||||
TargetChoices targets = activeStackInstance.getSpellAbility().getTargets();
|
||||
Player activator = activeStackInstance.getActivator();
|
||||
PlayerView activator = activeStackInstance.getActivatingPlayer();
|
||||
arrowOrigin = arrowOrigin.add(getScreenPosition());
|
||||
|
||||
for (Card c : targets.getTargetCards()) {
|
||||
TargetingOverlay.drawArrow(g, arrowOrigin, c, activator.isOpponentOf(c.getOwner()));
|
||||
for (CardView c : activeStackInstance.getTargetCards()) {
|
||||
TargetingOverlay.drawArrow(g, arrowOrigin, c, activator.isOpponentOf(c.getController()));
|
||||
}
|
||||
for (Player p : targets.getTargetPlayers()) {
|
||||
for (PlayerView p : activeStackInstance.getTargetPlayers()) {
|
||||
TargetingOverlay.drawArrow(g, arrowOrigin, p, activator.isOpponentOf(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class StackInstanceDisplay extends FDisplayObject {
|
||||
private final SpellAbilityStackInstance stackInstance;
|
||||
private final StackItemView stackInstance;
|
||||
private final Color foreColor, backColor;
|
||||
private String text;
|
||||
private float preferredHeight;
|
||||
|
||||
private StackInstanceDisplay(SpellAbilityStackInstance stackInstance0, float width) {
|
||||
private StackInstanceDisplay(StackItemView stackInstance0, float width) {
|
||||
stackInstance = stackInstance0;
|
||||
Card card = stackInstance.getSourceCard().getCardForUi();
|
||||
CardView card = stackInstance.getSource();
|
||||
|
||||
text = stackInstance.getStackDescription();
|
||||
if (stackInstance.getSpellAbility().isOptionalTrigger() &&
|
||||
card.getController().getController().getLobbyPlayer().equals(localPlayer)) {
|
||||
text = stackInstance.getText();
|
||||
if (stackInstance.isOptionalTrigger() &&
|
||||
stackInstance0.getActivatingPlayer().getLobbyPlayer().equals(localPlayer)) {
|
||||
text = "(OPTIONAL) " + text;
|
||||
}
|
||||
|
||||
DetailColors color = CardDetailUtil.getBorderColor(card, !stackInstance.getStackDescription().startsWith("Morph "));
|
||||
DetailColors color = CardDetailUtil.getBorderColor(card.getOriginal());
|
||||
backColor = FSkinColor.fromRGB(color.r, color.g, color.b);
|
||||
foreColor = FSkinColor.getHighContrastColor(backColor);
|
||||
|
||||
@@ -226,59 +230,55 @@ public class VStack extends FDropDown {
|
||||
return true;
|
||||
}
|
||||
if (localPlayer != null) { //don't show menu if tapping on art
|
||||
final SpellAbility ability = stackInstance.getSpellAbility();
|
||||
if (ability.isAbility()) {
|
||||
if (stackInstance.isAbility()) {
|
||||
FPopupMenu menu = new FPopupMenu() {
|
||||
@Override
|
||||
protected void buildMenu() {
|
||||
final PlayerController controller = localPlayer.getController();
|
||||
final String key = ability.toUnsuppressedString();
|
||||
final boolean autoYield = controller.shouldAutoYield(key);
|
||||
final String key = stackInstance.getKey();
|
||||
final boolean autoYield = gameView.shouldAutoYield(key);
|
||||
addItem(new FCheckBoxMenuItem("Auto-Yield", autoYield,
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
controller.setShouldAutoYield(key, !autoYield);
|
||||
if (!autoYield && stack.peekAbility() == ability) {
|
||||
FControl.getGameView().setShouldAutoYield(key, !autoYield);
|
||||
if (!autoYield && stackInstance.equals(gameView.peekStack())) {
|
||||
//auto-pass priority if ability is on top of stack
|
||||
FControl.getInputProxy().passPriority();
|
||||
gameView.passPriority();
|
||||
}
|
||||
}
|
||||
}));
|
||||
if (ability.isOptionalTrigger() && ability.getActivatingPlayer() == localPlayer) {
|
||||
final int triggerID = ability.getSourceTrigger();
|
||||
if (stackInstance.isOptionalTrigger() && stackInstance.getActivatingPlayer() == localPlayer) {
|
||||
final int triggerID = stackInstance.getSourceTrigger();
|
||||
addItem(new FCheckBoxMenuItem("Always Yes",
|
||||
controller.shouldAlwaysAcceptTrigger(triggerID),
|
||||
gameView.shouldAlwaysAcceptTrigger(triggerID),
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
if (controller.shouldAlwaysAcceptTrigger(triggerID)) {
|
||||
controller.setShouldAlwaysAskTrigger(triggerID);
|
||||
if (gameView.shouldAlwaysAcceptTrigger(triggerID)) {
|
||||
gameView.setShouldAlwaysAskTrigger(triggerID);
|
||||
}
|
||||
else {
|
||||
controller.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (stack.peekAbility() == ability &&
|
||||
FControl.getInputQueue().getInput() instanceof InputConfirm) {
|
||||
gameView.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (stackInstance.equals(gameView.peekStack())) {
|
||||
//auto-yes if ability is on top of stack
|
||||
FControl.getInputProxy().selectButtonOK();
|
||||
gameView.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
addItem(new FCheckBoxMenuItem("Always No",
|
||||
controller.shouldAlwaysDeclineTrigger(triggerID),
|
||||
gameView.shouldAlwaysDeclineTrigger(triggerID),
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
if (controller.shouldAlwaysDeclineTrigger(triggerID)) {
|
||||
controller.setShouldAlwaysAskTrigger(triggerID);
|
||||
if (gameView.shouldAlwaysDeclineTrigger(triggerID)) {
|
||||
gameView.setShouldAlwaysAskTrigger(triggerID);
|
||||
}
|
||||
else {
|
||||
controller.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (stack.peekAbility() == ability &&
|
||||
FControl.getInputQueue().getInput() instanceof InputConfirm) {
|
||||
gameView.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (stackInstance.equals(gameView.peekStack())) {
|
||||
//auto-no if ability is on top of stack
|
||||
FControl.getInputProxy().selectButtonOK();
|
||||
gameView.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,7 +287,7 @@ public class VStack extends FDropDown {
|
||||
addItem(new FMenuItem("Zoom/Details", new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
CardZoom.show(stackInstance.getSourceCard());
|
||||
CardZoom.show(stackInstance.getSource());
|
||||
}
|
||||
}));
|
||||
};
|
||||
@@ -297,13 +297,13 @@ public class VStack extends FDropDown {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
CardZoom.show(stackInstance.getSourceCard());
|
||||
CardZoom.show(stackInstance.getSource());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean longPress(float x, float y) {
|
||||
CardZoom.show(stackInstance.getSourceCard());
|
||||
CardZoom.show(stackInstance.getSource());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ public class VStack extends FDropDown {
|
||||
|
||||
x += PADDING;
|
||||
y += PADDING;
|
||||
CardRenderer.drawCardWithOverlays(g, stackInstance.getSourceCard(), x, y, CARD_WIDTH, CARD_HEIGHT);
|
||||
CardRenderer.drawCardWithOverlays(g, stackInstance.getSource(), x, y, CARD_WIDTH, CARD_HEIGHT);
|
||||
|
||||
x += CARD_WIDTH + PADDING;
|
||||
w -= x + PADDING - BORDER_THICKNESS;
|
||||
|
||||
@@ -3,17 +3,18 @@ package forge.screens.match.views;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.player.Player;
|
||||
import forge.GuiBase;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.toolbox.FCardPanel;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VZoneDisplay extends VCardDisplayArea {
|
||||
private final Player player;
|
||||
private final PlayerView player;
|
||||
private final ZoneType zoneType;
|
||||
private FCardPanel revealedPanel;
|
||||
|
||||
public VZoneDisplay(Player player0, ZoneType zoneType0) {
|
||||
public VZoneDisplay(PlayerView player0, ZoneType zoneType0) {
|
||||
player = player0;
|
||||
zoneType = zoneType0;
|
||||
}
|
||||
@@ -24,13 +25,13 @@ public class VZoneDisplay extends VCardDisplayArea {
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
FThreads.invokeInEdtNowOrLater(updateRoutine);
|
||||
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), updateRoutine);
|
||||
}
|
||||
|
||||
private final Runnable updateRoutine = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
refreshCardPanels(player.getZone(zoneType).getCards());
|
||||
refreshCardPanels(player.getCards(zoneType));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package forge.screens.match.winlose;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.Match;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* Default controller for a ViewWinLose object. This class can
|
||||
@@ -14,11 +13,11 @@ import forge.toolbox.FEvent.FEventHandler;
|
||||
*/
|
||||
public class ControlWinLose {
|
||||
private final ViewWinLose view;
|
||||
protected final Game lastGame;
|
||||
protected final IGameView lastGame;
|
||||
|
||||
/** @param v   ViewWinLose
|
||||
* @param match */
|
||||
public ControlWinLose(final ViewWinLose v, Game game) {
|
||||
public ControlWinLose(final ViewWinLose v, IGameView game) {
|
||||
view = v;
|
||||
lastGame = game;
|
||||
addListeners();
|
||||
@@ -54,18 +53,14 @@ public class ControlWinLose {
|
||||
view.hide();
|
||||
saveOptions();
|
||||
|
||||
FControl.endCurrentGame();
|
||||
FControl.startGame(lastGame.getMatch());
|
||||
FControl.startGameInSameMatch();
|
||||
}
|
||||
|
||||
/** Action performed when "restart" button is pressed in default win/lose UI. */
|
||||
public void actionOnRestart() {
|
||||
view.hide();
|
||||
saveOptions();
|
||||
final Match match = lastGame.getMatch();
|
||||
match.clearGamesPlayed();
|
||||
FControl.endCurrentGame();
|
||||
FControl.startGame(match);
|
||||
FControl.startGameInNewMatch();
|
||||
}
|
||||
|
||||
/** Action performed when "quit" button is pressed in default win/lose UI. */
|
||||
|
||||
@@ -18,10 +18,11 @@ package forge.screens.match.winlose;
|
||||
*/
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.Game;
|
||||
import forge.gauntlet.GauntletWinLoseController;
|
||||
import forge.util.gui.SOptionPane;
|
||||
import forge.view.IGameView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,9 +39,9 @@ public class GauntletWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match
|
||||
*/
|
||||
public GauntletWinLose(final ViewWinLose view0, Game lastGame) {
|
||||
public GauntletWinLose(final ViewWinLose view0, IGameView lastGame) {
|
||||
super(view0, lastGame);
|
||||
controller = new GauntletWinLoseController(view0, lastGame) {
|
||||
controller = new GauntletWinLoseController(view0, lastGame, GuiBase.getInterface()) {
|
||||
@Override
|
||||
protected void showOutcome(final String message1, final String message2, final FSkinProp icon, final List<String> lstEventNames, final List<String> lstEventRecords, final int len, final int num) {
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@@ -66,7 +67,7 @@ public class GauntletWinLose extends ControlWinLose {
|
||||
sb.deleteCharAt(sb.length() - 1); //remove final new line character
|
||||
}
|
||||
|
||||
SOptionPane.showMessageDialog(sb.toString(), "Gauntlet Progress", icon);
|
||||
SOptionPane.showMessageDialog(GuiBase.getInterface(), sb.toString(), "Gauntlet Progress", icon);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ package forge.screens.match.winlose;
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.GuiBase;
|
||||
import forge.limited.LimitedWinLoseController;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* The Win/Lose handler for 'gauntlet' type tournament
|
||||
@@ -33,9 +34,9 @@ public class LimitedWinLose extends ControlWinLose {
|
||||
* @param view0 {@link forge.gui.match.ViewWinLose}
|
||||
* @param match {@link forge.game.Match}
|
||||
*/
|
||||
public LimitedWinLose(final ViewWinLose view0, Game lastGame) {
|
||||
public LimitedWinLose(final ViewWinLose view0, IGameView lastGame) {
|
||||
super(view0, lastGame);
|
||||
controller = new LimitedWinLoseController(view0, lastGame) {
|
||||
controller = new LimitedWinLoseController(view0, lastGame, GuiBase.getInterface()) {
|
||||
@Override
|
||||
protected void showOutcome(Runnable runnable) {
|
||||
//invoke reward logic in background thread so dialogs can be shown
|
||||
|
||||
@@ -19,12 +19,13 @@ package forge.screens.match.winlose;
|
||||
import java.util.List;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.Game;
|
||||
import forge.item.PaperCard;
|
||||
import forge.quest.*;
|
||||
import forge.quest.QuestWinLoseController;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
import forge.util.gui.SOptionPane;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -44,9 +45,9 @@ public class QuestWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match2
|
||||
*/
|
||||
public QuestWinLose(final ViewWinLose view0, Game lastGame) {
|
||||
public QuestWinLose(final ViewWinLose view0, IGameView lastGame) {
|
||||
super(view0, lastGame);
|
||||
controller = new QuestWinLoseController(lastGame) {
|
||||
controller = new QuestWinLoseController(lastGame, GuiBase.getInterface()) {
|
||||
@Override
|
||||
protected void showRewards(Runnable runnable) {
|
||||
//invoke reward logic in background thread so dialogs can be shown
|
||||
@@ -55,12 +56,12 @@ public class QuestWinLose extends ControlWinLose {
|
||||
|
||||
@Override
|
||||
protected void showCards(String title, List<PaperCard> cards) {
|
||||
SGuiChoose.reveal(title, cards);
|
||||
SGuiChoose.reveal(gui, title, cards);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showMessage(String message, String title, FSkinProp icon) {
|
||||
SOptionPane.showMessageDialog(message, title, icon);
|
||||
SOptionPane.showMessageDialog(gui, message, title, icon);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package forge.screens.match.winlose;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.GuiBase;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameLog;
|
||||
import forge.game.GameLogEntry;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.game.GameOutcome;
|
||||
import forge.game.player.Player;
|
||||
import forge.interfaces.IWinLoseView;
|
||||
import forge.menu.FMagnifyView;
|
||||
import forge.model.FModel;
|
||||
@@ -25,6 +25,7 @@ import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FOverlay;
|
||||
import forge.toolbox.FTextArea;
|
||||
import forge.util.Utils;
|
||||
import forge.view.IGameView;
|
||||
|
||||
public class ViewWinLose extends FOverlay implements IWinLoseView<FButton> {
|
||||
private static final float INSETS_FACTOR = 0.025f;
|
||||
@@ -34,9 +35,9 @@ public class ViewWinLose extends FOverlay implements IWinLoseView<FButton> {
|
||||
private final FLabel lblTitle, lblLog, lblStats, btnCopyLog;
|
||||
private final FTextArea txtLog;
|
||||
private final OutcomesPanel pnlOutcomes;
|
||||
private final Game game;
|
||||
private final IGameView game;
|
||||
|
||||
public ViewWinLose(final Game game0) {
|
||||
public ViewWinLose(final IGameView game0) {
|
||||
super(FSkinColor.get(Colors.CLR_OVERLAY).alphaColor(0.75f));
|
||||
|
||||
game = game0;
|
||||
@@ -52,7 +53,7 @@ public class ViewWinLose extends FOverlay implements IWinLoseView<FButton> {
|
||||
// Control of the win/lose is handled differently for various game
|
||||
// modes.
|
||||
ControlWinLose control = null;
|
||||
switch (game0.getRules().getGameType()) {
|
||||
switch (game0.getGameType()) {
|
||||
case Quest:
|
||||
control = new QuestWinLose(this, game0);
|
||||
break;
|
||||
@@ -60,7 +61,7 @@ public class ViewWinLose extends FOverlay implements IWinLoseView<FButton> {
|
||||
//control = new QuestDraftWinLose(this, game0);
|
||||
break;
|
||||
case Draft:
|
||||
if (!FModel.getGauntletMini().isGauntletDraft()) {
|
||||
if (!FModel.getGauntletMini(GuiBase.getInterface()).isGauntletDraft()) {
|
||||
break;
|
||||
}
|
||||
case Sealed:
|
||||
@@ -82,10 +83,10 @@ public class ViewWinLose extends FOverlay implements IWinLoseView<FButton> {
|
||||
btnRestart.setFont(btnContinue.getFont());
|
||||
btnQuit.setText("Quit Match");
|
||||
btnQuit.setFont(btnContinue.getFont());
|
||||
btnContinue.setEnabled(!game0.getMatch().isMatchOver());
|
||||
btnContinue.setEnabled(!game0.isMatchOver());
|
||||
|
||||
lblLog = add(new FLabel.Builder().text("Game Log").align(HAlignment.CENTER).font(FSkinFont.get(18)).build());
|
||||
txtLog = add(new FTextArea(true, game.getGameLog().getLogText(null).replace("[COMPUTER]", "[AI]")) {
|
||||
txtLog = add(new FTextArea(true, StringUtils.join(game.getLogEntries(null), "\r\n").replace("[COMPUTER]", "[AI]")) {
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
if (txtLog.getMaxScrollTop() > 0) {
|
||||
@@ -103,20 +104,20 @@ public class ViewWinLose extends FOverlay implements IWinLoseView<FButton> {
|
||||
}
|
||||
}).build());
|
||||
|
||||
lblTitle.setText(composeTitle(game0.getOutcome()));
|
||||
lblTitle.setText(composeTitle(game0));
|
||||
|
||||
showGameOutcomeSummary();
|
||||
showPlayerScores();
|
||||
control.showRewards();
|
||||
}
|
||||
|
||||
private String composeTitle(GameOutcome outcome) {
|
||||
Player winner = outcome.getWinningPlayer();
|
||||
int winningTeam = outcome.getWinningTeam();
|
||||
private String composeTitle(final IGameView game) {
|
||||
final LobbyPlayer winner = game.getWinningPlayer();
|
||||
final int winningTeam = game.getWinningTeam();
|
||||
if (winner == null) {
|
||||
return "It's a draw!";
|
||||
} else if (winningTeam != -1) {
|
||||
return "Team " + winner.getTeam() + " Won!";
|
||||
return "Team " + winningTeam + " Won!";
|
||||
} else {
|
||||
return winner.getName() + " Won!";
|
||||
}
|
||||
@@ -135,15 +136,13 @@ public class ViewWinLose extends FOverlay implements IWinLoseView<FButton> {
|
||||
}
|
||||
|
||||
private void showGameOutcomeSummary() {
|
||||
GameLog log = game.getGameLog();
|
||||
for (GameLogEntry o : log.getLogEntriesExact(GameLogEntryType.GAME_OUTCOME)) {
|
||||
for (GameLogEntry o : game.getLogEntriesExact(GameLogEntryType.GAME_OUTCOME)) {
|
||||
pnlOutcomes.add(new FLabel.Builder().text(o.message).font(FSkinFont.get(14)).build());
|
||||
}
|
||||
}
|
||||
|
||||
private void showPlayerScores() {
|
||||
GameLog log = game.getGameLog();
|
||||
for (GameLogEntry o : log.getLogEntriesExact(GameLogEntryType.MATCH_RESULTS)) {
|
||||
for (GameLogEntry o : game.getLogEntriesExact(GameLogEntryType.MATCH_RESULTS)) {
|
||||
lblStats.setText(removePlayerTypeFromLogMessage(o.message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.assets.FSkinFont;
|
||||
@@ -179,14 +180,14 @@ public class LoadQuestScreen extends FScreen {
|
||||
String questName;
|
||||
String oldQuestName = quest.getName();
|
||||
while (true) {
|
||||
questName = SOptionPane.showInputDialog("Enter new name for quest:", "Rename Quest", null, oldQuestName);
|
||||
questName = SOptionPane.showInputDialog(GuiBase.getInterface(), "Enter new name for quest:", "Rename Quest", null, oldQuestName);
|
||||
if (questName == null) { return; }
|
||||
|
||||
questName = QuestUtil.cleanString(questName);
|
||||
if (questName.equals(oldQuestName)) { return; } //quit if chose same name
|
||||
|
||||
if (questName.isEmpty()) {
|
||||
SOptionPane.showMessageDialog("Please specify a quest name.");
|
||||
SOptionPane.showMessageDialog(GuiBase.getInterface(), "Please specify a quest name.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -198,7 +199,7 @@ public class LoadQuestScreen extends FScreen {
|
||||
}
|
||||
}
|
||||
if (exists) {
|
||||
SOptionPane.showMessageDialog("A quest already exists with that name. Please pick another quest name.");
|
||||
SOptionPane.showMessageDialog(GuiBase.getInterface(), "A quest already exists with that name. Please pick another quest name.");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
@@ -215,7 +216,7 @@ public class LoadQuestScreen extends FScreen {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!SOptionPane.showConfirmDialog(
|
||||
if (!SOptionPane.showConfirmDialog(GuiBase.getInterface(),
|
||||
"Are you sure you want to delete '" + quest.getName() + "'?",
|
||||
"Delete Quest", "Delete", "Cancel")) {
|
||||
return;
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.apache.commons.lang3.text.WordUtils;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.card.MagicColor;
|
||||
@@ -427,7 +428,8 @@ public class NewQuestScreen extends FScreen {
|
||||
|
||||
case CustomFormat:
|
||||
if (customFormatCodes.isEmpty()) {
|
||||
if (!SOptionPane.showConfirmDialog("You have defined a custom format that doesn't contain any sets.\nThis will start a game without restriction.\n\nContinue?")) {
|
||||
if (!SOptionPane.showConfirmDialog(GuiBase.getInterface(),
|
||||
"You have defined a custom format that doesn't contain any sets.\nThis will start a game without restriction.\n\nContinue?")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -439,7 +441,8 @@ public class NewQuestScreen extends FScreen {
|
||||
case Cube:
|
||||
dckStartPool = getSelectedDeck();
|
||||
if (dckStartPool == null) {
|
||||
SOptionPane.showMessageDialog("You have not selected a deck to start.", "Cannot start a quest", SOptionPane.ERROR_ICON);
|
||||
SOptionPane.showMessageDialog(GuiBase.getInterface(),
|
||||
"You have not selected a deck to start.", "Cannot start a quest", SOptionPane.ERROR_ICON);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -485,7 +488,8 @@ public class NewQuestScreen extends FScreen {
|
||||
break;
|
||||
case CustomFormat:
|
||||
if (customPrizeFormatCodes.isEmpty()) {
|
||||
if (!SOptionPane.showConfirmDialog("You have defined custom format as containing no sets.\nThis will choose all editions without restriction as prized.\n\nContinue?")) {
|
||||
if (!SOptionPane.showConfirmDialog(GuiBase.getInterface(),
|
||||
"You have defined custom format as containing no sets.\nThis will choose all editions without restriction as prized.\n\nContinue?")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -501,17 +505,17 @@ public class NewQuestScreen extends FScreen {
|
||||
|
||||
String questName;
|
||||
while (true) {
|
||||
questName = SOptionPane.showInputDialog("Poets will remember your quest as:", "Quest Name");
|
||||
questName = SOptionPane.showInputDialog(GuiBase.getInterface(), "Poets will remember your quest as:", "Quest Name");
|
||||
if (questName == null) { return; }
|
||||
|
||||
questName = QuestUtil.cleanString(questName);
|
||||
|
||||
if (questName.isEmpty()) {
|
||||
SOptionPane.showMessageDialog("Please specify a quest name.");
|
||||
SOptionPane.showMessageDialog(GuiBase.getInterface(), "Please specify a quest name.");
|
||||
continue;
|
||||
}
|
||||
if (FileUtil.doesFileExist(ForgeConstants.QUEST_SAVE_DIR + questName + ".dat")) {
|
||||
SOptionPane.showMessageDialog("A quest already exists with that name. Please pick another quest name.");
|
||||
SOptionPane.showMessageDialog(GuiBase.getInterface(), "A quest already exists with that name. Please pick another quest name.");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
@@ -521,7 +525,7 @@ public class NewQuestScreen extends FScreen {
|
||||
}
|
||||
|
||||
private void startNewQuest(final String questName, final GameFormat fmtPrizes, final Deck dckStartPool, final GameFormat fmtStartPool) {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LoadingOverlay.show("Creating new quest...", new Runnable() {
|
||||
|
||||
@@ -8,9 +8,11 @@ import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FImage;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.QuestController;
|
||||
import forge.quest.QuestUtil;
|
||||
@@ -77,7 +79,7 @@ public class QuestBazaarScreen extends TabPageScreen<QuestBazaarScreen> {
|
||||
});
|
||||
|
||||
private BazaarPage(QuestStallDefinition stallDef0) {
|
||||
super(stallDef0.getName(), (FImage)stallDef0.getIcon());
|
||||
super(stallDef0.getName(), (FImage)GuiBase.getInterface().getSkinIcon(stallDef0.getIcon()));
|
||||
stallDef = stallDef0;
|
||||
|
||||
lblFluff.setFont(FSkinFont.get(12));
|
||||
@@ -157,7 +159,8 @@ public class QuestBazaarScreen extends TabPageScreen<QuestBazaarScreen> {
|
||||
|
||||
lblName.setText(item.getPurchaseName());
|
||||
lblDesc.setText(item.getPurchaseDescription(assets));
|
||||
lblIcon.setIcon((FImage)item.getIcon(assets));
|
||||
final FSkinProp f = FSkinProp.valueOf(FSkinProp.class, item.getIcon(assets));
|
||||
lblIcon.setIcon((FImage) GuiBase.getInterface().getSkinIcon(f));
|
||||
lblCost.setText(String.valueOf(buyingPrice));
|
||||
|
||||
lblDesc.setFont(FSkinFont.get(12));
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.deck.DeckgenUtil;
|
||||
@@ -70,10 +71,10 @@ public class QuestDecksScreen extends FScreen {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //must run in game thread to prevent blocking UI thread
|
||||
@Override
|
||||
public void run() {
|
||||
if (!QuestUtil.checkActiveQuest("Create a Deck.")) {
|
||||
if (!QuestUtil.checkActiveQuest(GuiBase.getInterface(), "Create a Deck.")) {
|
||||
return;
|
||||
}
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
QuestDeckEditor editor = new QuestDeckEditor();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package forge.screens.quest;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.QuestUtil;
|
||||
import forge.screens.LaunchScreen;
|
||||
@@ -27,14 +29,15 @@ public abstract class QuestLaunchScreen extends LaunchScreen {
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (QuestUtil.canStartGame()) {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
final IGuiBase gui = GuiBase.getInterface();
|
||||
if (QuestUtil.canStartGame(gui)) {
|
||||
FThreads.invokeInEdtLater(gui, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LoadingOverlay.show("Loading new game...", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
QuestUtil.finishStartingGame();
|
||||
QuestUtil.finishStartingGame(gui);
|
||||
creatingMatch = false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.FDeckEditor.DeckController;
|
||||
@@ -11,6 +12,7 @@ import forge.deck.FDeckEditor.EditorType;
|
||||
import forge.interfaces.IButton;
|
||||
import forge.interfaces.ICheckBox;
|
||||
import forge.interfaces.IComboBox;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.menu.FMenuItem;
|
||||
import forge.menu.FPopupMenu;
|
||||
import forge.model.FModel;
|
||||
@@ -79,13 +81,14 @@ public class QuestMenu extends FPopupMenu implements IVQuestStats {
|
||||
}
|
||||
});
|
||||
private static final FMenuItem unlockSetsItem = new FMenuItem("Unlock Sets", FSkinImage.QUEST_MAP, new FEventHandler() {
|
||||
final IGuiBase gui = GuiBase.getInterface();
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //invoke in background thread so prompts can work
|
||||
@Override
|
||||
public void run() {
|
||||
QuestUtil.chooseAndUnlockEdition();
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
QuestUtil.chooseAndUnlockEdition(gui);
|
||||
FThreads.invokeInEdtLater(gui, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateCurrentQuestScreen();
|
||||
@@ -96,13 +99,14 @@ public class QuestMenu extends FPopupMenu implements IVQuestStats {
|
||||
}
|
||||
});
|
||||
private static final FMenuItem travelItem = new FMenuItem("Travel", FSkinImage.QUEST_MAP, new FEventHandler() {
|
||||
final IGuiBase gui = GuiBase.getInterface();
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //invoke in background thread so prompts can work
|
||||
@Override
|
||||
public void run() {
|
||||
QuestUtil.travelWorld();
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
QuestUtil.travelWorld(gui);
|
||||
FThreads.invokeInEdtLater(gui, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateCurrentQuestScreen();
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FImage;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
@@ -132,7 +133,7 @@ public class QuestSpellShopScreen extends TabPageScreen<QuestSpellShopScreen> {
|
||||
ItemPool<InventoryItem> items = new ItemPool<InventoryItem>(InventoryItem.class);
|
||||
items.add(item, result);
|
||||
activateItems(items);
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
parentScreen.updateCreditsLabel();
|
||||
@@ -180,7 +181,7 @@ public class QuestSpellShopScreen extends TabPageScreen<QuestSpellShopScreen> {
|
||||
|
||||
@Override
|
||||
protected void activateItems(ItemPool<InventoryItem> items) {
|
||||
QuestSpellShop.buy(items, itemManager, ((InventoryPage)parentScreen.tabPages[1]).itemManager, true);
|
||||
QuestSpellShop.buy(GuiBase.getInterface(), items, itemManager, ((InventoryPage)parentScreen.tabPages[1]).itemManager, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,7 +211,7 @@ public class QuestSpellShopScreen extends TabPageScreen<QuestSpellShopScreen> {
|
||||
@Override
|
||||
public void run() {
|
||||
QuestSpellShop.sellExtras(((SpellShopPage)parentScreen.tabPages[0]).itemManager, itemManager);
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
parentScreen.updateCreditsLabel();
|
||||
@@ -240,7 +241,7 @@ public class QuestSpellShopScreen extends TabPageScreen<QuestSpellShopScreen> {
|
||||
|
||||
@Override
|
||||
protected void activateItems(ItemPool<InventoryItem> items) {
|
||||
QuestSpellShop.sell(items, ((SpellShopPage)parentScreen.tabPages[0]).itemManager, itemManager, true);
|
||||
QuestSpellShop.sell(GuiBase.getInterface(), items, ((SpellShopPage)parentScreen.tabPages[0]).itemManager, itemManager, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.screens.quest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.interfaces.IButton;
|
||||
@@ -127,7 +128,7 @@ public class QuestStatsScreen extends FScreen {
|
||||
lblZep.setCommand(new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
if (!QuestUtil.checkActiveQuest("Launch a Zeppelin.")) {
|
||||
if (!QuestUtil.checkActiveQuest(GuiBase.getInterface(), "Launch a Zeppelin.")) {
|
||||
return;
|
||||
}
|
||||
FModel.getQuest().getAchievements().setCurrentChallenges(null);
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.screens.sealed;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.deck.DeckGroup;
|
||||
import forge.deck.DeckProxy;
|
||||
@@ -46,10 +47,10 @@ public class SealedScreen extends LaunchScreen {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //must run in game thread to prevent blocking UI thread
|
||||
@Override
|
||||
public void run() {
|
||||
final DeckGroup sealed = SealedCardPoolGenerator.generateSealedDeck(false);
|
||||
final DeckGroup sealed = SealedCardPoolGenerator.generateSealedDeck(GuiBase.getInterface(), false);
|
||||
if (sealed == null) { return; }
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DeckPreferences.setSealedDeck(sealed.getName());
|
||||
@@ -115,7 +116,7 @@ public class SealedScreen extends LaunchScreen {
|
||||
}
|
||||
|
||||
int matches = FModel.getDecks().getSealed().get(human.getName()).getAiDecks().size();
|
||||
FModel.getGauntletMini().launch(matches, human.getDeck(), GameType.Sealed);
|
||||
FModel.getGauntletMini(GuiBase.getInterface()).launch(matches, human.getDeck(), GameType.Sealed);
|
||||
return false; //prevent launching via launch screen since gauntlet handles it
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.net.Proxy;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.download.GuiDownloadService;
|
||||
@@ -82,7 +83,7 @@ public class GuiDownloader extends FDialog {
|
||||
|
||||
show();
|
||||
|
||||
service.initialize(txtAddress, txtPort, progressBar, btnStart, cmdClose, new Runnable() {
|
||||
service.initialize(GuiBase.getInterface(), txtAddress, txtPort, progressBar, btnStart, cmdClose, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Gdx.graphics.setContinuousRendering(false);
|
||||
|
||||
@@ -2,8 +2,8 @@ package forge.toolbox;
|
||||
|
||||
import forge.Graphics;
|
||||
import forge.card.CardRenderer;
|
||||
import forge.game.card.Card;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
|
||||
public class FCardPanel extends FDisplayObject {
|
||||
public static final float TAPPED_ANGLE = -90;
|
||||
@@ -12,7 +12,7 @@ public class FCardPanel extends FDisplayObject {
|
||||
public static final float TARGET_ORIGIN_FACTOR_X = 0.15f;
|
||||
public static final float TARGET_ORIGIN_FACTOR_Y = 0.5f;
|
||||
|
||||
private Card card;
|
||||
private CardView card;
|
||||
private boolean tapped;
|
||||
private float tappedAngle = 0;
|
||||
private boolean highlighted;
|
||||
@@ -20,14 +20,14 @@ public class FCardPanel extends FDisplayObject {
|
||||
public FCardPanel() {
|
||||
this(null);
|
||||
}
|
||||
public FCardPanel(Card card0) {
|
||||
public FCardPanel(CardView card0) {
|
||||
card = card0;
|
||||
}
|
||||
|
||||
public Card getCard() {
|
||||
public CardView getCard() {
|
||||
return card;
|
||||
}
|
||||
public void setCard(Card card0) {
|
||||
public void setCard(CardView card0) {
|
||||
card = card0;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ import forge.screens.match.FControl;
|
||||
import forge.screens.match.views.VAvatar;
|
||||
import forge.screens.match.views.VStack;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.SpellAbilityView;
|
||||
|
||||
public class FChoiceList<T> extends FList<T> {
|
||||
public static final FSkinColor ITEM_COLOR = FSkinColor.get(Colors.CLR_ZEBRA);
|
||||
@@ -347,18 +350,18 @@ public class FChoiceList<T> extends FList<T> {
|
||||
|
||||
@Override
|
||||
public boolean tap(T value, float x, float y, int count) {
|
||||
return CardRenderer.cardListItemTap((Card)value, x, y, count, compactModeHandler.isCompactMode());
|
||||
return CardRenderer.cardListItemTap((CardView)value, x, y, count, compactModeHandler.isCompactMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean longPress(T value, float x, float y) {
|
||||
CardZoom.show((Card)value);
|
||||
CardZoom.show((CardView)value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawValue(Graphics g, T value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h) {
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, (Card)value, 0, null, x, y, w, h, compactModeHandler.isCompactMode());
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, (CardView)value, 0, null, x, y, w, h, compactModeHandler.isCompactMode());
|
||||
}
|
||||
}
|
||||
//special renderer for SpellAbilities
|
||||
@@ -378,7 +381,7 @@ public class FChoiceList<T> extends FList<T> {
|
||||
@Override
|
||||
public boolean tap(T value, float x, float y, int count) {
|
||||
if (x <= VStack.CARD_WIDTH + 2 * FList.PADDING) {
|
||||
CardZoom.show(((SpellAbility)value).getHostCard());
|
||||
CardZoom.show(((SpellAbilityView)value).getHostCard());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -386,13 +389,13 @@ public class FChoiceList<T> extends FList<T> {
|
||||
|
||||
@Override
|
||||
public boolean longPress(T value, float x, float y) {
|
||||
CardZoom.show(((SpellAbility)value).getHostCard());
|
||||
CardZoom.show(((SpellAbilityView)value).getHostCard());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawValue(Graphics g, T value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h) {
|
||||
SpellAbility spellAbility = (SpellAbility)value;
|
||||
SpellAbilityView spellAbility = (SpellAbilityView)value;
|
||||
CardRenderer.drawCardWithOverlays(g, spellAbility.getHostCard(), x, y, VStack.CARD_WIDTH, VStack.CARD_HEIGHT);
|
||||
|
||||
float dx = VStack.CARD_WIDTH + FList.PADDING;
|
||||
@@ -424,7 +427,7 @@ public class FChoiceList<T> extends FList<T> {
|
||||
|
||||
@Override
|
||||
public void drawValue(Graphics g, T value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h) {
|
||||
Player player = (Player)value;
|
||||
PlayerView player = (PlayerView)value;
|
||||
g.drawImage(FControl.getPlayerAvatar(player), x - FList.PADDING, y - FList.PADDING, VAvatar.WIDTH, VAvatar.HEIGHT);
|
||||
x += VAvatar.WIDTH;
|
||||
w -= VAvatar.WIDTH;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.ConcurrentModificationException;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import forge.Graphics;
|
||||
import forge.GuiBase;
|
||||
import forge.error.BugReporter;
|
||||
|
||||
public abstract class FContainer extends FDisplayObject {
|
||||
@@ -74,7 +75,7 @@ public abstract class FContainer extends FDisplayObject {
|
||||
//ignore concurrent modification exceptions during render
|
||||
}
|
||||
catch (Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ import forge.assets.FSkinImage;
|
||||
import forge.assets.ImageUtil;
|
||||
import forge.card.CardRenderer;
|
||||
import forge.card.CardZoom;
|
||||
import forge.game.card.Card;
|
||||
import forge.screens.match.views.VPrompt;
|
||||
import forge.toolbox.FEvent.*;
|
||||
import forge.util.Callback;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
|
||||
public class FOptionPane extends FDialog {
|
||||
public static final FSkinImage QUESTION_ICON = FSkinImage.QUESTION;
|
||||
@@ -89,7 +89,7 @@ public class FOptionPane extends FDialog {
|
||||
optionPane.show();
|
||||
}
|
||||
|
||||
public static void showCardOptionDialog(final Card card, String message, String title, FImage icon, String[] options, int defaultOption, final Callback<Integer> callback) {
|
||||
public static void showCardOptionDialog(final CardView card, String message, String title, FImage icon, String[] options, int defaultOption, final Callback<Integer> callback) {
|
||||
final FDisplayObject cardDisplay;
|
||||
if (card != null) {
|
||||
cardDisplay = new FDisplayObject() {
|
||||
@@ -110,7 +110,7 @@ public class FOptionPane extends FDialog {
|
||||
float x = (getWidth() - w) / 2;
|
||||
float y = 0;
|
||||
|
||||
CardRenderer.drawCard(g, card, true, x, y, w, h);
|
||||
CardRenderer.drawCard(g, card, x, y, w, h);
|
||||
}
|
||||
};
|
||||
cardDisplay.setHeight(Utils.SCREEN_HEIGHT / 2);
|
||||
|
||||
@@ -3,14 +3,13 @@ package forge.toolbox;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.util.Callback;
|
||||
import forge.view.CardView;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class GuiChoose {
|
||||
|
||||
/**
|
||||
@@ -240,22 +239,22 @@ public class GuiChoose {
|
||||
c.show(selected, false);
|
||||
}
|
||||
|
||||
public static <T> void many(final String title, final String topCaption, int cnt, final List<T> sourceChoices, Card referenceCard, final Callback<List<T>> callback) {
|
||||
public static <T> void many(final String title, final String topCaption, int cnt, final List<T> sourceChoices, CardView referenceCard, final Callback<List<T>> callback) {
|
||||
order(title, topCaption, cnt, cnt, sourceChoices, null, referenceCard, callback);
|
||||
}
|
||||
|
||||
public static <T> void many(final String title, final String topCaption, int min, int max, final List<T> sourceChoices, Card referenceCard, final Callback<List<T>> callback) {
|
||||
public static <T> void many(final String title, final String topCaption, int min, int max, final List<T> sourceChoices, CardView referenceCard, final Callback<List<T>> callback) {
|
||||
int m2 = min >= 0 ? sourceChoices.size() - min : -1;
|
||||
int m1 = max >= 0 ? sourceChoices.size() - max : -1;
|
||||
order(title, topCaption, m1, m2, sourceChoices, null, referenceCard, callback);
|
||||
}
|
||||
|
||||
public static <T> void order(final String title, final String top, final List<T> sourceChoices, Card referenceCard, final Callback<List<T>> callback) {
|
||||
public static <T> void order(final String title, final String top, final List<T> sourceChoices, CardView referenceCard, final Callback<List<T>> callback) {
|
||||
order(title, top, 0, 0, sourceChoices, null, referenceCard, callback);
|
||||
}
|
||||
|
||||
public static <T> void order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
final List<T> sourceChoices, final List<T> destChoices, final Card referenceCard, final Callback<List<T>> callback) {
|
||||
final List<T> sourceChoices, final List<T> destChoices, final CardView referenceCard, final Callback<List<T>> callback) {
|
||||
// An input box for handling the order of choices.
|
||||
DualListBox<T> dual = new DualListBox<T>(title, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, callback);
|
||||
dual.setSecondColumnLabelText(top);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package forge.toolbox;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.util.Callback;
|
||||
import forge.view.CardView;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -12,18 +12,18 @@ import org.apache.commons.lang3.StringUtils;
|
||||
public class GuiDialog {
|
||||
private static final String[] defaultConfirmOptions = { "Yes", "No" };
|
||||
|
||||
public static void confirm(final Card c, final String question, final Callback<Boolean> callback) {
|
||||
public static void confirm(final CardView c, final String question, final Callback<Boolean> callback) {
|
||||
GuiDialog.confirm(c, question, true, null, callback);
|
||||
}
|
||||
public static void confirm(final Card c, final String question, final boolean defaultChoice, final Callback<Boolean> callback) {
|
||||
public static void confirm(final CardView c, final String question, final boolean defaultChoice, final Callback<Boolean> callback) {
|
||||
GuiDialog.confirm(c, question, defaultChoice, null, callback);
|
||||
}
|
||||
public static void confirm(final Card c, final String question, String[] options, final Callback<Boolean> callback) {
|
||||
public static void confirm(final CardView c, final String question, String[] options, final Callback<Boolean> callback) {
|
||||
GuiDialog.confirm(c, question, true, options, callback);
|
||||
}
|
||||
|
||||
public static void confirm(final Card c, final String question, final boolean defaultIsYes, final String[] options, final Callback<Boolean> callback) {
|
||||
final String title = c == null ? "Question" : c.getCardForUi().getName() + " - Ability";
|
||||
public static void confirm(final CardView c, final String question, final boolean defaultIsYes, final String[] options, final Callback<Boolean> callback) {
|
||||
final String title = c == null ? "Question" : c + " - Ability";
|
||||
String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question;
|
||||
String[] opts = options == null ? defaultConfirmOptions : options;
|
||||
FOptionPane.showCardOptionDialog(c, questionToUse, title, FOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1, new Callback<Integer>() {
|
||||
|
||||
@@ -21,11 +21,13 @@ package forge.toolbox;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.util.Callback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -69,7 +71,7 @@ public class ListChooser<T> extends FContainer {
|
||||
private final Callback<List<T>> callback;
|
||||
|
||||
public ListChooser(final String title, final int minChoices, final int maxChoices, final Collection<T> list0, final Function<T, String> display0, final Callback<List<T>> callback0) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
list = list0;
|
||||
if (list.size() > 25) { //only show search field if more than 25 items
|
||||
txtSearch = add(new FTextField());
|
||||
|
||||
35
forge-gui-mobile/src/forge/util/WaitCallback.java
Normal file
35
forge-gui-mobile/src/forge/util/WaitCallback.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package forge.util;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
|
||||
public abstract class WaitCallback<T> extends Callback<T> implements Runnable {
|
||||
public class Lock {
|
||||
}
|
||||
|
||||
private final Lock lock = new Lock();
|
||||
|
||||
private T result;
|
||||
|
||||
@Override
|
||||
public final void run(T result0) {
|
||||
result = result0;
|
||||
synchronized(lock) {
|
||||
lock.notify();
|
||||
}
|
||||
}
|
||||
|
||||
public final T invokeAndWait() {
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), false); //not supported if on UI thread
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), this);
|
||||
try {
|
||||
synchronized(lock) {
|
||||
lock.wait();
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package forge.util;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
|
||||
public abstract class WaitRunnable implements Runnable {
|
||||
public class Lock {
|
||||
@@ -11,7 +12,7 @@ public abstract class WaitRunnable implements Runnable {
|
||||
private final Lock lock = new Lock();
|
||||
|
||||
public void invokeAndWait() {
|
||||
FThreads.assertExecutedByEdt(false);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), false);
|
||||
Gdx.app.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user