Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ public void actionPerformed(final ActionEvent e) {
if (matchUI == null) { return; }
StackItemView si = matchUI.getGameView().peekStack();
if (si != null && si.isAbility()) {
matchUI.setShouldAutoYield(si.getKey(), true);
matchUI.getGameController().setShouldAutoYield(si.getKey(), true);
int triggerID = si.getSourceTrigger();
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) {
matchUI.setShouldAlwaysAcceptTrigger(triggerID);
matchUI.getGameController().setShouldAlwaysAcceptTrigger(triggerID);
}
matchUI.getGameController().passPriority();
}
Expand All @@ -177,10 +177,10 @@ public void actionPerformed(final ActionEvent e) {
if (matchUI == null) { return; }
StackItemView si = matchUI.getGameView().peekStack();
if (si != null && si.isAbility()) {
matchUI.setShouldAutoYield(si.getKey(), true);
matchUI.getGameController().setShouldAutoYield(si.getKey(), true);
int triggerID = si.getSourceTrigger();
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) {
matchUI.setShouldAlwaysDeclineTrigger(triggerID);
matchUI.getGameController().setShouldAlwaysDeclineTrigger(triggerID);
}
matchUI.getGameController().passPriority();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public VAutoYields(final CMatchUI matchUI) {
setTitle(Localizer.getInstance().getMessage("lblAutoYields"));

autoYields = new ArrayList<>();
for (final String autoYield : matchUI.getAutoYields()) {
for (final String autoYield : matchUI.getGameController().getAutoYields()) {
autoYields.add(autoYield);
}
lstAutoYields = new FList<>(new AutoYieldsListModel());
Expand All @@ -46,8 +46,8 @@ public VAutoYields(final CMatchUI matchUI) {

listScroller = new FScrollPane(lstAutoYields, true);

chkDisableAll = new FCheckBox(Localizer.getInstance().getMessage("lblDisableAllAutoYields"), matchUI.getDisableAutoYields());
chkDisableAll.addChangeListener(e -> matchUI.setDisableAutoYields(chkDisableAll.isSelected()));
chkDisableAll = new FCheckBox(Localizer.getInstance().getMessage("lblDisableAllAutoYields"), matchUI.getGameController().getDisableAutoYields());
chkDisableAll.addChangeListener(e -> matchUI.getGameController().setDisableAutoYields(chkDisableAll.isSelected()));

btnOk = new FButton(Localizer.getInstance().getMessage("lblOK"));
btnOk.setCommand((UiCommand) () -> setVisible(false));
Expand All @@ -57,7 +57,7 @@ public VAutoYields(final CMatchUI matchUI) {
if (selected != null) {
autoYields.remove(selected);
btnRemove.setEnabled(autoYields.size() > 0);
matchUI.setShouldAutoYield(selected, false);
matchUI.getGameController().setShouldAutoYield(selected, false);
VAutoYields.this.revalidate();
lstAutoYields.repaint();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ public AbilityMenu(){
jmiAutoYield = new JCheckBoxMenuItem(Localizer.getInstance().getMessage("cbpAutoYieldMode"));
jmiAutoYield.addActionListener(arg0 -> {
final String key = item.getKey();
final boolean autoYield = controller.getMatchUI().shouldAutoYield(key);
controller.getMatchUI().setShouldAutoYield(key, !autoYield);
final boolean autoYield = controller.getMatchUI().getGameController().shouldAutoYield(key);
controller.getMatchUI().getGameController().setShouldAutoYield(key, !autoYield);
if (!autoYield && controller.getMatchUI().getGameView().peekStack() == item) {
//auto-pass priority if ability is on top of stack
controller.getMatchUI().getGameController().passPriority();
Expand All @@ -303,22 +303,22 @@ public AbilityMenu(){

jmiAlwaysYes = new JCheckBoxMenuItem(Localizer.getInstance().getMessage("lblAlwaysYes"));
jmiAlwaysYes.addActionListener(arg0 -> {
if (controller.getMatchUI().shouldAlwaysAcceptTrigger(triggerID)) {
controller.getMatchUI().setShouldAlwaysAskTrigger(triggerID);
if (controller.getMatchUI().getGameController().shouldAlwaysAcceptTrigger(triggerID)) {
controller.getMatchUI().getGameController().setShouldAlwaysAskTrigger(triggerID);
}
else {
controller.getMatchUI().setShouldAlwaysAcceptTrigger(triggerID);
controller.getMatchUI().getGameController().setShouldAlwaysAcceptTrigger(triggerID);
}
});
add(jmiAlwaysYes);

jmiAlwaysNo = new JCheckBoxMenuItem(Localizer.getInstance().getMessage("lblAlwaysNo"));
jmiAlwaysNo.addActionListener(arg0 -> {
if (controller.getMatchUI().shouldAlwaysDeclineTrigger(triggerID)) {
controller.getMatchUI().setShouldAlwaysAskTrigger(triggerID);
if (controller.getMatchUI().getGameController().shouldAlwaysDeclineTrigger(triggerID)) {
controller.getMatchUI().getGameController().setShouldAlwaysAskTrigger(triggerID);
}
else {
controller.getMatchUI().setShouldAlwaysDeclineTrigger(triggerID);
controller.getMatchUI().getGameController().setShouldAlwaysDeclineTrigger(triggerID);
}
});
add(jmiAlwaysNo);
Expand All @@ -328,11 +328,11 @@ public void setStackInstance(final StackItemView item0) {
item = item0;
triggerID = item.getSourceTrigger();

jmiAutoYield.setSelected(controller.getMatchUI().shouldAutoYield(item.getKey()));
jmiAutoYield.setSelected(controller.getMatchUI().getGameController().shouldAutoYield(item.getKey()));

if (item.isOptionalTrigger() && controller.getMatchUI().isLocalPlayer(item.getActivatingPlayer())) {
jmiAlwaysYes.setSelected(controller.getMatchUI().shouldAlwaysAcceptTrigger(triggerID));
jmiAlwaysNo.setSelected(controller.getMatchUI().shouldAlwaysDeclineTrigger(triggerID));
jmiAlwaysYes.setSelected(controller.getMatchUI().getGameController().shouldAlwaysAcceptTrigger(triggerID));
jmiAlwaysNo.setSelected(controller.getMatchUI().getGameController().shouldAlwaysDeclineTrigger(triggerID));
jmiAlwaysYes.setVisible(true);
jmiAlwaysNo.setVisible(true);
} else {
Expand Down
19 changes: 8 additions & 11 deletions forge-gui-mobile/src/forge/screens/match/MatchScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import forge.card.CardRenderer;
import forge.card.CardZoom;
import forge.game.spellability.StackItemView;
import forge.gui.interfaces.IGuiGame;
import forge.screens.match.views.VField;
import forge.screens.match.views.VReveal;
import forge.toolbox.FDisplayObject;
Expand Down Expand Up @@ -664,7 +663,6 @@ public boolean keyDown(int keyCode) {
break;
case Keys.Y: //auto-yield, always yes, Ctrl+Y on Android, Y when running on desktop
if (KeyInputAdapter.isCtrlKeyDown() || GuiBase.getInterface().isRunningOnDesktop()) {
final IGuiGame gui = MatchController.instance;
final IGameController controller = MatchController.instance.getGameController();
final GameView gameView = MatchController.instance.getGameView();
final FCollectionView<StackItemView> stack = MatchController.instance.getGameView().getStack();
Expand All @@ -677,18 +675,18 @@ public boolean keyDown(int keyCode) {
}
final int triggerID = stackInstance.getSourceTrigger();

if (gui.shouldAlwaysAcceptTrigger(triggerID)) {
gui.setShouldAlwaysAskTrigger(triggerID);
if (controller.shouldAlwaysAcceptTrigger(triggerID)) {
controller.setShouldAlwaysAskTrigger(triggerID);
} else {
gui.setShouldAlwaysAcceptTrigger(triggerID);
controller.setShouldAlwaysAcceptTrigger(triggerID);
if (stackInstance.equals(gameView.peekStack())) {
//auto-yes if ability is on top of stack
controller.selectButtonOk();
}
}

final String key = stackInstance.getKey();
gui.setShouldAutoYield(key, true);
controller.setShouldAutoYield(key, true);
if (stackInstance.equals(gameView.peekStack())) {
//auto-pass priority if ability is on top of stack
controller.passPriority();
Expand All @@ -697,7 +695,6 @@ public boolean keyDown(int keyCode) {
break;
case Keys.N: //auto-yield, always no, Ctrl+N on Android, N when running on desktop
if (KeyInputAdapter.isCtrlKeyDown() || GuiBase.getInterface().isRunningOnDesktop()) {
final IGuiGame gui = MatchController.instance;
final IGameController controller = MatchController.instance.getGameController();
final GameView gameView = MatchController.instance.getGameView();
final FCollectionView<StackItemView> stack = MatchController.instance.getGameView().getStack();
Expand All @@ -710,18 +707,18 @@ public boolean keyDown(int keyCode) {
}
final int triggerID = stackInstance.getSourceTrigger();

if (gui.shouldAlwaysDeclineTrigger(triggerID)) {
gui.setShouldAlwaysAskTrigger(triggerID);
if (controller.shouldAlwaysDeclineTrigger(triggerID)) {
controller.setShouldAlwaysAskTrigger(triggerID);
} else {
gui.setShouldAlwaysDeclineTrigger(triggerID);
controller.setShouldAlwaysDeclineTrigger(triggerID);
if (stackInstance.equals(gameView.peekStack())) {
//auto-no if ability is on top of stack
controller.selectButtonCancel();
}
}

final String key = stackInstance.getKey();
gui.setShouldAutoYield(key, true);
controller.setShouldAutoYield(key, true);
if (stackInstance.equals(gameView.peekStack())) {
//auto-pass priority if ability is on top of stack
controller.passPriority();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class VAutoYields extends FDialog {
public VAutoYields() {
super(Forge.getLocalizer().getMessage("lblAutoYields"), 2);
List<String> autoYields = new ArrayList<>();
for (String autoYield : MatchController.instance.getAutoYields()) {
for (String autoYield : MatchController.instance.getGameController().getAutoYields()) {
autoYields.add(autoYield);
}
lstAutoYields = add(new FChoiceList<String>(autoYields) {
Expand All @@ -32,14 +32,14 @@ protected boolean allowDefaultItemWrap() {
return true;
}
});
chkDisableAll = add(new FCheckBox(Forge.getLocalizer().getMessage("lblDisableAllAutoYields"), MatchController.instance.getDisableAutoYields()));
chkDisableAll.setCommand(e -> MatchController.instance.setDisableAutoYields(chkDisableAll.isSelected()));
chkDisableAll = add(new FCheckBox(Forge.getLocalizer().getMessage("lblDisableAllAutoYields"), MatchController.instance.getGameController().getDisableAutoYields()));
chkDisableAll.setCommand(e -> MatchController.instance.getGameController().setDisableAutoYields(chkDisableAll.isSelected()));
initButton(0, Forge.getLocalizer().getMessage("lblOK"), e -> hide());
initButton(1, Forge.getLocalizer().getMessage("lblRemoveYield"), e -> {
String selected = lstAutoYields.getSelectedItem();
if (selected != null) {
lstAutoYields.removeItem(selected);
MatchController.instance.setShouldAutoYield(selected, false);
MatchController.instance.getGameController().setShouldAutoYield(selected, false);
setButtonEnabled(1, lstAutoYields.getCount() > 0);
lstAutoYields.cleanUpSelections();
VAutoYields.this.revalidate();
Expand Down
10 changes: 5 additions & 5 deletions forge-gui-mobile/src/forge/screens/match/views/VGameMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ public void handleEvent(FEvent e) {
addItem(new FMenuItem(Forge.getLocalizer().getMessage("lblAutoYields"), Forge.hdbuttons ? FSkinImage.HDYIELD : FSkinImage.WARNING, new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
final boolean autoYieldsDisabled = MatchController.instance.getDisableAutoYields();
final boolean autoYieldsDisabled = MatchController.instance.getGameController().getDisableAutoYields();
final VAutoYields autoYields = new VAutoYields() {
@Override
public void setVisible(boolean b0) {
super.setVisible(b0);
if (!b0) {
if (autoYieldsDisabled && !MatchController.instance.getDisableAutoYields()) {
if (autoYieldsDisabled && !MatchController.instance.getGameController().getDisableAutoYields()) {
//if re-enabling auto-yields, auto-yield to current ability on stack if applicable
if (MatchController.instance.getGameView().peekStack() != null) {
final String key = MatchController.instance.getGameView().peekStack().getKey();
final boolean autoYield = MatchController.instance.shouldAutoYield(key);
MatchController.instance.setShouldAutoYield(key, !autoYield);
if (!autoYield && MatchController.instance.shouldAutoYield(key)) {
final boolean autoYield = MatchController.instance.getGameController().shouldAutoYield(key);
MatchController.instance.getGameController().setShouldAutoYield(key, !autoYield);
if (!autoYield && MatchController.instance.getGameController().shouldAutoYield(key)) {
//auto-pass priority if ability is on top of stack
MatchController.instance.getGameController().passPriority();
}
Expand Down
22 changes: 10 additions & 12 deletions forge-gui-mobile/src/forge/screens/match/views/VStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import forge.game.zone.ZoneType;
import forge.gui.card.CardDetailUtil;
import forge.gui.card.CardDetailUtil.DetailColors;
import forge.gui.interfaces.IGuiGame;
import forge.interfaces.IGameController;
import forge.menu.FCheckBoxMenuItem;
import forge.menu.FDropDown;
Expand Down Expand Up @@ -282,7 +281,6 @@ public boolean tap(float x, float y, int count) {
return true;
}
final GameView gameView = MatchController.instance.getGameView();
final IGuiGame gui = MatchController.instance;
final IGameController controller = MatchController.instance.getGameController();
final PlayerView player = MatchController.instance.getCurrentPlayer();
if (player != null) { //don't show menu if tapping on art
Expand All @@ -291,10 +289,10 @@ public boolean tap(float x, float y, int count) {
@Override
protected void buildMenu() {
final String key = stackInstance.getKey();
final boolean autoYield = gui.shouldAutoYield(key);
final boolean autoYield = controller.shouldAutoYield(key);
addItem(new FCheckBoxMenuItem(Forge.getLocalizer().getMessage("cbpAutoYieldMode"), autoYield,
e -> {
gui.setShouldAutoYield(key, !autoYield);
controller.setShouldAutoYield(key, !autoYield);
if (!autoYield && stackInstance.equals(gameView.peekStack())) {
//auto-pass priority if ability is on top of stack
controller.passPriority();
Expand All @@ -303,27 +301,27 @@ protected void buildMenu() {
if (stackInstance.isOptionalTrigger() && stackInstance.getActivatingPlayer().equals(player)) {
final int triggerID = stackInstance.getSourceTrigger();
addItem(new FCheckBoxMenuItem(Forge.getLocalizer().getMessage("lblAlwaysYes"),
gui.shouldAlwaysAcceptTrigger(triggerID),
controller.shouldAlwaysAcceptTrigger(triggerID),
e -> {
if (gui.shouldAlwaysAcceptTrigger(triggerID)) {
gui.setShouldAlwaysAskTrigger(triggerID);
if (controller.shouldAlwaysAcceptTrigger(triggerID)) {
controller.setShouldAlwaysAskTrigger(triggerID);
}
else {
gui.setShouldAlwaysAcceptTrigger(triggerID);
controller.setShouldAlwaysAcceptTrigger(triggerID);
if (stackInstance.equals(gameView.peekStack())) {
//auto-yes if ability is on top of stack
controller.selectButtonOk();
}
}
}));
addItem(new FCheckBoxMenuItem(Forge.getLocalizer().getMessage("lblAlwaysNo"),
gui.shouldAlwaysDeclineTrigger(triggerID),
controller.shouldAlwaysDeclineTrigger(triggerID),
e -> {
if (gui.shouldAlwaysDeclineTrigger(triggerID)) {
gui.setShouldAlwaysAskTrigger(triggerID);
if (controller.shouldAlwaysDeclineTrigger(triggerID)) {
controller.setShouldAlwaysAskTrigger(triggerID);
}
else {
gui.setShouldAlwaysDeclineTrigger(triggerID);
controller.setShouldAlwaysDeclineTrigger(triggerID);
if (stackInstance.equals(gameView.peekStack())) {
//auto-no if ability is on top of stack
controller.selectButtonCancel();
Expand Down
Loading
Loading