mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Cleanup GuiDesktop
This commit is contained in:
@@ -60,15 +60,16 @@ import forge.screens.match.views.VPrompt;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.special.PhaseLabel;
|
||||
import forge.util.BuildInfo;
|
||||
|
||||
public class GuiDesktop implements IGuiBase {
|
||||
public void invokeInEdtLater(Runnable runnable) {
|
||||
SwingUtilities.invokeLater(runnable);
|
||||
@Override
|
||||
public void invokeInEdtLater(Runnable proc) {
|
||||
SwingUtilities.invokeLater(proc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeInEdtAndWait(final Runnable proc) {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
// Just run in the current thread.
|
||||
@@ -87,68 +88,81 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGuiThread() {
|
||||
return SwingUtilities.isEventDispatchThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssetsRoot() {
|
||||
return StringUtils.containsIgnoreCase(BuildInfo.getVersionString(), "svn") ?
|
||||
"../forge-gui/res/" : "res/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayShowCard(Card card) {
|
||||
return Singletons.getControl().mayShowCard(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportBug(String details) {
|
||||
BugReporter.reportBug(details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportException(Throwable ex) {
|
||||
BugReporter.reportException(ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportException(Throwable ex, String message) {
|
||||
BugReporter.reportException(ex, message);
|
||||
}
|
||||
|
||||
public boolean showConfirmDialog(String message) {
|
||||
return FOptionPane.showConfirmDialog(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkinImage getUnskinnedIcon(String path) {
|
||||
return new FSkin.UnskinnedIcon(path);
|
||||
}
|
||||
|
||||
public int showOptionDialog(String message, String title, ISkinImage icon, String[] options, int defaultOption) {
|
||||
return FOptionPane.showOptionDialog(message, title, (SkinImage)icon, options, defaultOption);
|
||||
@Override
|
||||
public int showOptionDialog(String message, String title, FSkinProp icon, String[] options, int defaultOption) {
|
||||
return FOptionPane.showOptionDialog(message, title, FSkin.getImage(icon), options, defaultOption);
|
||||
}
|
||||
|
||||
public <T> T showInputDialog(String message, String title, ISkinImage icon, T initialInput, T[] inputOptions) {
|
||||
return FOptionPane.showInputDialog(message, title, (SkinImage)icon, initialInput, inputOptions);
|
||||
@Override
|
||||
public <T> T showInputDialog(String message, String title, FSkinProp icon, T initialInput, T[] inputOptions) {
|
||||
return FOptionPane.showInputDialog(message, title, FSkin.getImage(icon), initialInput, inputOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices, final T selected, final Function<T, String> display) {
|
||||
return GuiChoose.getChoices(message, min, max, choices, selected, display);
|
||||
}
|
||||
|
||||
@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) {
|
||||
return GuiChoose.order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, referenceCard, sideboardingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCardList(final String title, final String message, final List<PaperCard> list) {
|
||||
final CardListViewer cardView = new CardListViewer(title, message, list);
|
||||
cardView.setVisible(true);
|
||||
cardView.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IButton getBtnOK() {
|
||||
return VMatchUI.SINGLETON_INSTANCE.getBtnOK();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IButton getBtnCancel() {
|
||||
return VMatchUI.SINGLETON_INSTANCE.getBtnCancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusButton(final IButton button) {
|
||||
// ensure we don't steal focus from an overlay
|
||||
if (!SOverlayUtils.overlayHasFocus()) {
|
||||
@@ -161,10 +175,12 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flashIncorrectAction() {
|
||||
SDisplayUtil.remind(VPrompt.SINGLETON_INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePhase() {
|
||||
PhaseHandler pH = Singletons.getControl().getObservedGame().getPhaseHandler();
|
||||
Player p = pH.getPlayerTurn();
|
||||
@@ -174,15 +190,19 @@ public class GuiDesktop implements IGuiBase {
|
||||
PhaseLabel lbl = matchUi.getFieldViewFor(p).getPhaseIndicator().getLabelFor(ph);
|
||||
|
||||
matchUi.resetAllPhaseButtons();
|
||||
if (lbl != null) lbl.setActive(true);
|
||||
if (lbl != null) {
|
||||
lbl.setActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTurn(final GameEventTurnBegan event, final Game game) {
|
||||
VField nextField = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(event.turnOwner);
|
||||
SDisplayUtil.showTab(nextField);
|
||||
CPrompt.SINGLETON_INSTANCE.updateText(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePlayerControl() {
|
||||
CMatchUI.SINGLETON_INSTANCE.initHandViews(FServer.getLobby().getGuiPlayer());
|
||||
SLayoutIO.loadLayout(null);
|
||||
@@ -192,23 +212,28 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishGame() {
|
||||
new ViewWinLose(Singletons.getControl().getObservedGame());
|
||||
SOverlayUtils.showOverlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStack() {
|
||||
CStack.SINGLETON_INSTANCE.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startMatch(GameType gameType, List<RegisteredPlayer> players) {
|
||||
FControl.instance.startMatch(gameType, players);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPanelSelection(Card c) {
|
||||
GuiUtils.setPanelSelection(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility getAbilityToPlay(List<SpellAbility> abilities, Object triggerEvent) {
|
||||
if (triggerEvent == null) {
|
||||
if (abilities.isEmpty()) {
|
||||
@@ -269,10 +294,12 @@ public class GuiDesktop implements IGuiBase {
|
||||
return null; //delay ability until choice made
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hear(LobbyPlayer player, String message) {
|
||||
FNetOverlay.SINGLETON_INSTANCE.addMessage(player.getName(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvatarCount() {
|
||||
if (FSkin.isLoaded()) {
|
||||
FSkin.getAvatars().size();
|
||||
@@ -280,16 +307,6 @@ public class GuiDesktop implements IGuiBase {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int showOptionDialog(String message, String title, FSkinProp icon, String[] options, int defaultOption) {
|
||||
return FOptionPane.showOptionDialog(message, title, FSkin.getImage(icon), options, defaultOption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T showInputDialog(String message, String title, FSkinProp icon, T initialInput, T[] inputOptions) {
|
||||
return FOptionPane.showInputDialog(message, title, FSkin.getImage(icon), initialInput, inputOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireEvent(UiEvent e) {
|
||||
CMatchUI.SINGLETON_INSTANCE.fireEvent(e);
|
||||
|
||||
Reference in New Issue
Block a user