mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Fix the last problems related to inputs. All errors are fixed, it's time to test!
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ import forge.match.input.InputConfirm;
|
||||
import forge.match.input.InputConfirmMulligan;
|
||||
import forge.match.input.InputPassPriority;
|
||||
import forge.match.input.InputProliferate;
|
||||
import forge.match.input.InputProxy;
|
||||
import forge.match.input.InputSelectCardsForConvoke;
|
||||
import forge.match.input.InputSelectCardsFromList;
|
||||
import forge.match.input.InputSelectEntitiesFromList;
|
||||
@@ -105,8 +106,10 @@ import forge.view.ViewUtil;
|
||||
* Handles phase skips for now.
|
||||
*/
|
||||
public class PlayerControllerLocal extends PlayerControllerHuman implements IGameView {
|
||||
private final InputProxy inputProxy;
|
||||
public PlayerControllerLocal(final Game game0, final Player p, final LobbyPlayer lp, final IGuiBase gui) {
|
||||
super(game0, p, lp, gui);
|
||||
this.inputProxy = new InputProxy(this);
|
||||
// aggressively cache a view for each player
|
||||
for (final Player player : game.getRegisteredPlayers()) {
|
||||
getPlayerView(player);
|
||||
@@ -1406,6 +1409,36 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectButtonOk() {
|
||||
inputProxy.selectButtonOK();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
inputProxy.selectButtonCancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passPriority() {
|
||||
return inputProxy.passPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPlayer(final PlayerView player, final ITriggerEvent triggerEvent) {
|
||||
inputProxy.selectPlayer(player, triggerEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(final CardView card, final ITriggerEvent triggerEvent) {
|
||||
inputProxy.selectCard(card, triggerEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAbility(final SpellAbilityView sa) {
|
||||
inputProxy.selectAbility(sa);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.IGameView#getGuiRegisteredPlayer(forge.LobbyPlayer)
|
||||
*/
|
||||
@@ -1682,4 +1715,5 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
public void devPlaneswalkTo() {
|
||||
DevModeUtil.devModeRiggedPlanarRoll(game, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ public class QuestAchievements {
|
||||
// Difficulty - will store only index from now.
|
||||
private int difficulty;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public QuestAchievements() { //needed for XML serialization
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import forge.game.GameOutcome;
|
||||
import forge.game.GameType;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.util.ITriggerEvent;
|
||||
|
||||
public interface IGameView {
|
||||
|
||||
@@ -45,11 +46,19 @@ public interface IGameView {
|
||||
public abstract CombatView getCombat();
|
||||
|
||||
public abstract void addLogObserver(Observer o);
|
||||
public abstract List<GameLogEntry> getLogEntries(final GameLogEntryType maxLogLevel);
|
||||
public abstract List<GameLogEntry> getLogEntriesExact(final GameLogEntryType logLevel);
|
||||
public abstract List<GameLogEntry> getLogEntries(GameLogEntryType maxLogLevel);
|
||||
public abstract List<GameLogEntry> getLogEntriesExact(GameLogEntryType logLevel);
|
||||
|
||||
// Input controls
|
||||
public abstract boolean tryUndoLastAction();
|
||||
|
||||
public abstract void selectButtonOk();
|
||||
public abstract void selectButtonCancel();
|
||||
public abstract boolean passPriority();
|
||||
public abstract void selectPlayer(PlayerView player, ITriggerEvent triggerEvent);
|
||||
public abstract void selectCard(CardView card, ITriggerEvent triggerEvent);
|
||||
public abstract void selectAbility(SpellAbilityView sa);
|
||||
|
||||
// the following method should eventually be replaced by methods returning
|
||||
// View classes
|
||||
@Deprecated
|
||||
|
||||
Reference in New Issue
Block a user