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