Fix the last problems related to inputs. All errors are fixed, it's time to test!

This commit is contained in:
elcnesh
2014-09-04 10:53:00 +00:00
parent 89b3395cec
commit 2d1f2dc1ae
11 changed files with 93 additions and 38 deletions

View File

@@ -332,7 +332,7 @@ public class GuiDesktop implements IGuiBase {
new Runnable() {
@Override
public void run() {
CPrompt.SINGLETON_INSTANCE.getInputControl().selectAbility(ab);
CPrompt.SINGLETON_INSTANCE.selectAbility(ab);
}
}, enabled);
if (shortcut > 0) {

View File

@@ -81,7 +81,6 @@ import forge.screens.match.VMatchUI;
import forge.screens.match.controllers.CDock;
import forge.screens.match.controllers.CLog;
import forge.screens.match.controllers.CPlayers;
import forge.screens.match.controllers.CPrompt;
import forge.screens.match.controllers.CStack;
import forge.screens.match.views.VAntes;
import forge.screens.match.views.VDev;
@@ -523,8 +522,6 @@ public enum FControl implements KeyEventDispatcher {
setCurrentScreen(FScreen.MATCH_SCREEN);
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
CPrompt.SINGLETON_INSTANCE.getInputControl().setGame(game0);
// Listen to DuelOutcome event to show ViewWinLose
game0.subscribeToEvents(fcVisitor);

View File

@@ -62,7 +62,7 @@ public enum CDock implements ICDoc {
*/
public void endTurn() {
game.autoPassUntilEndOfTurn();
if (!CPrompt.SINGLETON_INSTANCE.getInputControl().passPriority()) {
if (!CPrompt.SINGLETON_INSTANCE.passPriority()) {
game.autoPassCancel();
}
}

View File

@@ -53,7 +53,7 @@ public class CField implements ICDoc {
private final MouseListener madAvatar = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
CPrompt.SINGLETON_INSTANCE.getInputControl().selectPlayer(player, new MouseTriggerEvent(e));
CPrompt.SINGLETON_INSTANCE.selectPlayer(player, new MouseTriggerEvent(e));
}
};
@@ -103,7 +103,7 @@ public class CField implements ICDoc {
return;
}
CPrompt.SINGLETON_INSTANCE.getInputControl().selectCard(c, null);
CPrompt.SINGLETON_INSTANCE.selectCard(c, null);
// Temporarily commenting out the below to route, Flashback cards through the InputProxy
/*
final Game game = player.getGame();

View File

@@ -32,10 +32,13 @@ import forge.Singletons;
import forge.UiCommand;
import forge.gui.framework.ICDoc;
import forge.gui.framework.SDisplayUtil;
import forge.match.input.InputProxy;
import forge.screens.match.views.VPrompt;
import forge.toolbox.FSkin;
import forge.util.ITriggerEvent;
import forge.view.CardView;
import forge.view.IGameView;
import forge.view.PlayerView;
import forge.view.SpellAbilityView;
/**
* Controls the prompt panel in the match UI.
@@ -46,20 +49,19 @@ public enum CPrompt implements ICDoc {
/** */
SINGLETON_INSTANCE;
private InputProxy inputControl = new InputProxy();
private Component lastFocusedButton = null;
private VPrompt view = VPrompt.SINGLETON_INSTANCE;
private final VPrompt view = VPrompt.SINGLETON_INSTANCE;
private final ActionListener actCancel = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent evt) {
inputControl.selectButtonCancel();
selectButtonCancel();
}
};
private final ActionListener actOK = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent evt) {
inputControl.selectButtonOK();
selectButtonOk();
}
};
@@ -87,13 +89,28 @@ public enum CPrompt implements ICDoc {
_initButton(view.getBtnOK(), actOK);
}
/**
* Gets the input control.
*
* @return GuiInput
*/
public InputProxy getInputControl() {
return this.inputControl;
public void selectButtonOk() {
Singletons.getControl().getGameView().selectButtonOk();
}
public void selectButtonCancel() {
Singletons.getControl().getGameView().selectButtonCancel();
}
public boolean passPriority() {
return Singletons.getControl().getGameView().passPriority();
}
public void selectPlayer(final PlayerView player, final ITriggerEvent triggerEvent) {
Singletons.getControl().getGameView().selectPlayer(player, triggerEvent);
}
public void selectCard(final CardView card, final ITriggerEvent triggerEvent) {
Singletons.getControl().getGameView().selectCard(card, triggerEvent);
}
public void selectAbility(final SpellAbilityView sa) {
Singletons.getControl().getGameView().selectAbility(sa);
}
/** @param s0   {@link java.lang.String} */
@@ -117,6 +134,13 @@ public enum CPrompt implements ICDoc {
/* (non-Javadoc)
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
*/
@Override
public void update() {
// set focus back to button that last had it
if (null != lastFocusedButton) {
lastFocusedButton.requestFocusInWindow();
}
}
public void updateText() {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
@@ -125,12 +149,4 @@ public enum CPrompt implements ICDoc {
view.getLblGames().setText(text);
view.getLblGames().setToolTipText(String.format("%s: Game #%d of %d, turn %d", game.getGameType(), game.getNumPlayedGamesInMatch() + 1, game.getNumGamesInMatch(), game.getTurnNumber()));
}
@Override
public void update() {
// set focus back to button that last had it
if (null != lastFocusedButton) {
lastFocusedButton.requestFocusInWindow();
}
}
}

View File

@@ -260,7 +260,7 @@ public enum VStack implements IVDoc<CStack> {
game.setShouldAutoYield(key, !autoYield);
if (!autoYield && game.peekStack() == item) {
//auto-pass priority if ability is on top of stack
CPrompt.SINGLETON_INSTANCE.getInputControl().passPriority();
CPrompt.SINGLETON_INSTANCE.passPriority();
}
}
});
@@ -278,7 +278,7 @@ public enum VStack implements IVDoc<CStack> {
if (game.peekStack() == item &&
Singletons.getControl().getInputQueue().getInput() instanceof InputConfirm) {
//auto-yes if ability is on top of stack
CPrompt.SINGLETON_INSTANCE.getInputControl().selectButtonOK();
CPrompt.SINGLETON_INSTANCE.selectButtonOk();
}
}
}
@@ -297,7 +297,7 @@ public enum VStack implements IVDoc<CStack> {
if (game.peekStack() == item &&
Singletons.getControl().getInputQueue().getInput() instanceof InputConfirm) {
//auto-no if ability is on top of stack
CPrompt.SINGLETON_INSTANCE.getInputControl().selectButtonOK();
CPrompt.SINGLETON_INSTANCE.selectButtonOk();
}
}
}

View File

@@ -62,14 +62,14 @@ public class HandArea extends CardArea {
/** {@inheritDoc} */
@Override
public final void mouseLeftClicked(final CardPanel panel, final MouseEvent evt) {
CPrompt.SINGLETON_INSTANCE.getInputControl().selectCard(panel.getCard(), new MouseTriggerEvent(evt));
CPrompt.SINGLETON_INSTANCE.selectCard(panel.getCard(), new MouseTriggerEvent(evt));
super.mouseLeftClicked(panel, evt);
}
/** {@inheritDoc} */
@Override
public final void mouseRightClicked(final CardPanel panel, final MouseEvent evt) {
CPrompt.SINGLETON_INSTANCE.getInputControl().selectCard(panel.getCard(), new MouseTriggerEvent(evt));
CPrompt.SINGLETON_INSTANCE.selectCard(panel.getCard(), new MouseTriggerEvent(evt));
super.mouseRightClicked(panel, evt);
}
}

View File

@@ -571,7 +571,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
/** {@inheritDoc} */
@Override
public final void mouseLeftClicked(final CardPanel panel, final MouseEvent evt) {
CPrompt.SINGLETON_INSTANCE.getInputControl().selectCard(panel.getCard(), new MouseTriggerEvent(evt));
CPrompt.SINGLETON_INSTANCE.selectCard(panel.getCard(), new MouseTriggerEvent(evt));
if ((panel.getTappedAngle() != 0) && (panel.getTappedAngle() != CardPanel.TAPPED_ANGLE)) {
return;
}
@@ -581,7 +581,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
/** {@inheritDoc} */
@Override
public final void mouseRightClicked(final CardPanel panel, final MouseEvent evt) {
CPrompt.SINGLETON_INSTANCE.getInputControl().selectCard(panel.getCard(), new MouseTriggerEvent(evt));
CPrompt.SINGLETON_INSTANCE.selectCard(panel.getCard(), new MouseTriggerEvent(evt));
super.mouseRightClicked(panel, evt);
}