mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Fixed double listener bug in tabber.
Added toggle to "unlimited lands" button.
This commit is contained in:
@@ -35,6 +35,8 @@ import forge.view.match.ViewTabber;
|
|||||||
*/
|
*/
|
||||||
public class ControlTabber extends MyObservable {
|
public class ControlTabber extends MyObservable {
|
||||||
private final ViewTabber view;
|
private final ViewTabber view;
|
||||||
|
private MouseAdapter maMilling, maHand, maLibrary, maUnlimited,
|
||||||
|
maMana, maSetup, maTutor, maCounter, maTap, maUntap, maLife;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls the vertical tabber in sidebar used for viewing gameplay data:
|
* Controls the vertical tabber in sidebar used for viewing gameplay data:
|
||||||
@@ -45,6 +47,7 @@ public class ControlTabber extends MyObservable {
|
|||||||
*/
|
*/
|
||||||
public ControlTabber(final ViewTabber v) {
|
public ControlTabber(final ViewTabber v) {
|
||||||
this.view = v;
|
this.view = v;
|
||||||
|
|
||||||
if (Singletons.getModel().getPreferences().isMillingLossCondition()) {
|
if (Singletons.getModel().getPreferences().isMillingLossCondition()) {
|
||||||
this.view.getLblMilling().setEnabled(true);
|
this.view.getLblMilling().setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
@@ -62,6 +65,15 @@ public class ControlTabber extends MyObservable {
|
|||||||
} else {
|
} else {
|
||||||
this.view.getLblLibraryView().setEnabled(false);
|
this.view.getLblLibraryView().setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Singletons.getModel().getPreferences().getUnlimitedLand()) {
|
||||||
|
this.view.getLblUnlimitedLands().setEnabled(true);
|
||||||
|
} else {
|
||||||
|
this.view.getLblUnlimitedLands().setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Various mouse adapters for dev buttons
|
||||||
|
initMouseAdapters();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds observers to tabber. */
|
/** Adds observers to tabber. */
|
||||||
@@ -89,98 +101,48 @@ public class ControlTabber extends MyObservable {
|
|||||||
/** Adds listeners to various components in tabber. */
|
/** Adds listeners to various components in tabber. */
|
||||||
public void addListeners() {
|
public void addListeners() {
|
||||||
// Milling enable toggle
|
// Milling enable toggle
|
||||||
this.view.getLblMilling().addMouseListener(new MouseAdapter() {
|
this.view.getLblMilling().removeMouseListener(maMilling);
|
||||||
@Override
|
this.view.getLblMilling().addMouseListener(maMilling);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
ControlTabber.this.view.getLblMilling().toggleEnabled();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// View any hand toggle
|
// View any hand toggle
|
||||||
this.view.getLblHandView().addMouseListener(new MouseAdapter() {
|
this.view.getLblHandView().removeMouseListener(maHand);
|
||||||
@Override
|
this.view.getLblHandView().addMouseListener(maHand);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
ControlTabber.this.view.getLblHandView().toggleEnabled();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DevMode: View any library toggle
|
// DevMode: View any library toggle
|
||||||
this.view.getLblLibraryView().addMouseListener(new MouseAdapter() {
|
this.view.getLblLibraryView().removeMouseListener(maLibrary);
|
||||||
@Override
|
this.view.getLblLibraryView().addMouseListener(maLibrary);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
ControlTabber.this.view.getLblLibraryView().toggleEnabled();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DevMode: Play unlimited land this turn toggle
|
// DevMode: Play unlimited land this turn toggle
|
||||||
this.view.getLblUnlimitedLands().addMouseListener(new MouseAdapter() {
|
this.view.getLblUnlimitedLands().removeMouseListener(maUnlimited);
|
||||||
@Override
|
this.view.getLblUnlimitedLands().addMouseListener(maUnlimited);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
GuiDisplayUtil.devModeUnlimitedLand();
|
|
||||||
|
|
||||||
// TODO: Enable toggle for this (e.g. Unlimited land each turn:
|
|
||||||
// enabled)
|
|
||||||
// Also must change enabled/disabled text in ViewTabber to
|
|
||||||
// reflect this.
|
|
||||||
// view.getLblUnlimitedLands().toggleEnabled();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DevMode: Generate mana
|
// DevMode: Generate mana
|
||||||
this.view.getLblGenerateMana().addMouseListener(new MouseAdapter() {
|
this.view.getLblGenerateMana().removeMouseListener(maMana);
|
||||||
@Override
|
this.view.getLblGenerateMana().addMouseListener(maMana);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
GuiDisplayUtil.devModeGenerateMana();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DevMode: Battlefield setup
|
// DevMode: Battlefield setup
|
||||||
this.view.getLblSetupGame().addMouseListener(new MouseAdapter() {
|
this.view.getLblSetupGame().removeMouseListener(maSetup);
|
||||||
@Override
|
this.view.getLblSetupGame().addMouseListener(maSetup);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
GuiDisplayUtil.devSetupGameState();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DevMode: Tutor for card
|
// DevMode: Tutor for card
|
||||||
this.view.getLblTutor().addMouseListener(new MouseAdapter() {
|
this.view.getLblTutor().removeMouseListener(maTutor);
|
||||||
@Override
|
this.view.getLblTutor().addMouseListener(maTutor);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
GuiDisplayUtil.devModeTutor();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DevMode: Add counter to permanent
|
// DevMode: Add counter to permanent
|
||||||
this.view.getLblCounterPermanent().addMouseListener(new MouseAdapter() {
|
this.view.getLblCounterPermanent().removeMouseListener(maCounter);
|
||||||
@Override
|
this.view.getLblCounterPermanent().addMouseListener(maCounter);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
GuiDisplayUtil.devModeAddCounter();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DevMode: Tap permanent
|
// DevMode: Tap permanent
|
||||||
this.view.getLblTapPermanent().addMouseListener(new MouseAdapter() {
|
this.view.getLblTapPermanent().removeMouseListener(maTap);
|
||||||
@Override
|
this.view.getLblTapPermanent().addMouseListener(maTap);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
GuiDisplayUtil.devModeTapPerm();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DevMode: Untap permanent
|
// DevMode: Untap permanent
|
||||||
this.view.getLblUntapPermanent().addMouseListener(new MouseAdapter() {
|
this.view.getLblUntapPermanent().removeMouseListener(maUntap);
|
||||||
@Override
|
this.view.getLblUntapPermanent().addMouseListener(maUntap);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
GuiDisplayUtil.devModeUntapPerm();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DevMode: Set human life
|
// DevMode: Set life
|
||||||
this.view.getLblHumanLife().addMouseListener(new MouseAdapter() {
|
this.view.getLblSetLife().removeMouseListener(maLife);
|
||||||
@Override
|
this.view.getLblSetLife().addMouseListener(maLife);
|
||||||
public void mousePressed(final MouseEvent e) {
|
|
||||||
GuiDisplayUtil.devModeSetLife();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,4 +192,86 @@ public class ControlTabber extends MyObservable {
|
|||||||
public void showPnlStack() {
|
public void showPnlStack() {
|
||||||
this.view.getVtpTabber().showTab(0);
|
this.view.getVtpTabber().showTab(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Simple method that inits the mouse adapters for listeners,
|
||||||
|
* here to simplify life in the constructor.
|
||||||
|
*/
|
||||||
|
private void initMouseAdapters() {
|
||||||
|
maMilling = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
ControlTabber.this.view.getLblMilling().toggleEnabled();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maHand = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
ControlTabber.this.view.getLblHandView().toggleEnabled();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maLibrary = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
ControlTabber.this.view.getLblLibraryView().toggleEnabled();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maUnlimited = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
ControlTabber.this.view.getLblUnlimitedLands().toggleEnabled();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maMana = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
GuiDisplayUtil.devModeGenerateMana();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maSetup = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
GuiDisplayUtil.devSetupGameState();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maTutor = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
GuiDisplayUtil.devModeTutor();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maCounter = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
GuiDisplayUtil.devModeAddCounter();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maTap = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
GuiDisplayUtil.devModeTapPerm();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maUntap = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
GuiDisplayUtil.devModeUntapPerm();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maLife = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
GuiDisplayUtil.devModeSetLife();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ public class ForgePreferences extends Preferences {
|
|||||||
/** Library view toggle. */
|
/** Library view toggle. */
|
||||||
private boolean libraryView;
|
private boolean libraryView;
|
||||||
|
|
||||||
|
/** Unlimited land toggle. */
|
||||||
|
private boolean unlimitedLand;
|
||||||
|
|
||||||
/** Developer mode. */
|
/** Developer mode. */
|
||||||
private boolean developerMode;
|
private boolean developerMode;
|
||||||
|
|
||||||
@@ -146,6 +149,7 @@ public class ForgePreferences extends Preferences {
|
|||||||
this.setMillingLossCondition(this.getBoolean("loss.condition.milling", true));
|
this.setMillingLossCondition(this.getBoolean("loss.condition.milling", true));
|
||||||
this.setHandView(this.getBoolean("developer.handview", true));
|
this.setHandView(this.getBoolean("developer.handview", true));
|
||||||
this.setLibraryView(this.getBoolean("developer.libraryview", true));
|
this.setLibraryView(this.getBoolean("developer.libraryview", true));
|
||||||
|
this.setUnlimitedLand(this.getBoolean("developer.unlimitedland", true));
|
||||||
this.setDeveloperMode(this.getBoolean("developer.mode", false));
|
this.setDeveloperMode(this.getBoolean("developer.mode", false));
|
||||||
|
|
||||||
this.setUploadDraftAI(this.getBoolean("upload.Draft.AI", true));
|
this.setUploadDraftAI(this.getBoolean("upload.Draft.AI", true));
|
||||||
@@ -221,6 +225,7 @@ public class ForgePreferences extends Preferences {
|
|||||||
this.set("loss.condition.milling", this.isMillingLossCondition());
|
this.set("loss.condition.milling", this.isMillingLossCondition());
|
||||||
this.set("developer.handview", this.getHandView());
|
this.set("developer.handview", this.getHandView());
|
||||||
this.set("developer.libraryview", this.getLibraryView());
|
this.set("developer.libraryview", this.getLibraryView());
|
||||||
|
this.set("developer.unlimitedland", this.getUnlimitedLand());
|
||||||
this.set("developer.mode", this.isDeveloperMode());
|
this.set("developer.mode", this.isDeveloperMode());
|
||||||
this.set("upload.Draft.AI", this.isUploadDraftAI());
|
this.set("upload.Draft.AI", this.isUploadDraftAI());
|
||||||
|
|
||||||
@@ -415,6 +420,25 @@ public class ForgePreferences extends Preferences {
|
|||||||
this.libraryView = b0;
|
this.libraryView = b0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if "unlimited land" option in dev mode is enabled or not.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean getUnlimitedLand() {
|
||||||
|
return this.unlimitedLand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if "unlimited land" option in dev mode is enabled or not.
|
||||||
|
*
|
||||||
|
* @param b0
|
||||||
|
*   boolean
|
||||||
|
*/
|
||||||
|
public void setUnlimitedLand(final boolean b0) {
|
||||||
|
this.unlimitedLand = b0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the upload draft ai.
|
* Sets the upload draft ai.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class ViewTabber extends FRoundedPanel {
|
|||||||
private final FPanel pnlStack, pnlCombat, pnlConsole, pnlPlayers, pnlDev;
|
private final FPanel pnlStack, pnlCombat, pnlConsole, pnlPlayers, pnlDev;
|
||||||
|
|
||||||
private DevLabel lblMilling, lblHandView, lblLibraryView, lblGenerateMana, lblSetupGame, lblTutor,
|
private DevLabel lblMilling, lblHandView, lblLibraryView, lblGenerateMana, lblSetupGame, lblTutor,
|
||||||
lblCounterPermanent, lblTapPermanent, lblUntapPermanent, lblUnlimitedLands, lblHumanLife;
|
lblCounterPermanent, lblTapPermanent, lblUntapPermanent, lblUnlimitedLands, lblSetLife;
|
||||||
|
|
||||||
private final FVerticalTabPanel vtpTabber;
|
private final FVerticalTabPanel vtpTabber;
|
||||||
|
|
||||||
@@ -542,8 +542,8 @@ public class ViewTabber extends FRoundedPanel {
|
|||||||
*
|
*
|
||||||
* @return DevLabel
|
* @return DevLabel
|
||||||
*/
|
*/
|
||||||
public DevLabel getLblHumanLife() {
|
public DevLabel getLblSetLife() {
|
||||||
return this.lblHumanLife;
|
return this.lblSetLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -602,39 +602,39 @@ public class ViewTabber extends FRoundedPanel {
|
|||||||
lblMilling = new DevLabel("Loss by Milling: Enabled", "Loss by Milling: Disabled");
|
lblMilling = new DevLabel("Loss by Milling: Enabled", "Loss by Milling: Disabled");
|
||||||
lblHandView = new DevLabel("View Any Hand: Enabled", "View Any Hand: Disabled");
|
lblHandView = new DevLabel("View Any Hand: Enabled", "View Any Hand: Disabled");
|
||||||
lblLibraryView = new DevLabel("View Any Library: Enabled", "View Any Library: Disabled");
|
lblLibraryView = new DevLabel("View Any Library: Enabled", "View Any Library: Disabled");
|
||||||
|
lblUnlimitedLands = new DevLabel("Play Unlimited Lands This Turn: Enabled", "Play Unlimited Lands This Turn: Disabled");
|
||||||
lblGenerateMana = new DevLabel("Generate Mana");
|
lblGenerateMana = new DevLabel("Generate Mana");
|
||||||
lblSetupGame = new DevLabel("Setup Game State");
|
lblSetupGame = new DevLabel("Setup Game State");
|
||||||
lblTutor = new DevLabel("Tutor for Card");
|
lblTutor = new DevLabel("Tutor for Card");
|
||||||
lblCounterPermanent = new DevLabel("Add Counter to Permanent");
|
lblCounterPermanent = new DevLabel("Add Counter to Permanent");
|
||||||
lblTapPermanent = new DevLabel("Tap Permanent");
|
lblTapPermanent = new DevLabel("Tap Permanent");
|
||||||
lblUntapPermanent = new DevLabel("Untap Permanent");
|
lblUntapPermanent = new DevLabel("Untap Permanent");
|
||||||
lblUnlimitedLands = new DevLabel("Play Unlimited Lands This Turn");
|
lblSetLife = new DevLabel("Set Player Life");
|
||||||
lblHumanLife = new DevLabel("Set Player Life");
|
|
||||||
|
|
||||||
devLBLs.add(lblMilling);
|
devLBLs.add(lblMilling);
|
||||||
devLBLs.add(lblHandView);
|
devLBLs.add(lblHandView);
|
||||||
devLBLs.add(lblLibraryView);
|
devLBLs.add(lblLibraryView);
|
||||||
|
devLBLs.add(lblUnlimitedLands);
|
||||||
devLBLs.add(lblGenerateMana);
|
devLBLs.add(lblGenerateMana);
|
||||||
devLBLs.add(lblSetupGame);
|
devLBLs.add(lblSetupGame);
|
||||||
devLBLs.add(lblTutor);
|
devLBLs.add(lblTutor);
|
||||||
devLBLs.add(lblCounterPermanent);
|
devLBLs.add(lblCounterPermanent);
|
||||||
devLBLs.add(lblTapPermanent);
|
devLBLs.add(lblTapPermanent);
|
||||||
devLBLs.add(lblUntapPermanent);
|
devLBLs.add(lblUntapPermanent);
|
||||||
devLBLs.add(lblUnlimitedLands);
|
devLBLs.add(lblSetLife);
|
||||||
devLBLs.add(lblHumanLife);
|
|
||||||
|
|
||||||
final String constraints = "w 95%!, gap 0 0 5px 0";
|
final String constraints = "w 95%!, gap 0 0 5px 0";
|
||||||
viewport.add(this.lblMilling, constraints);
|
viewport.add(this.lblMilling, constraints);
|
||||||
viewport.add(this.lblHandView, constraints);
|
viewport.add(this.lblHandView, constraints);
|
||||||
viewport.add(this.lblLibraryView, constraints);
|
viewport.add(this.lblLibraryView, constraints);
|
||||||
|
viewport.add(this.lblUnlimitedLands, constraints);
|
||||||
viewport.add(this.lblGenerateMana, constraints);
|
viewport.add(this.lblGenerateMana, constraints);
|
||||||
viewport.add(this.lblSetupGame, constraints);
|
viewport.add(this.lblSetupGame, constraints);
|
||||||
viewport.add(this.lblTutor, constraints);
|
viewport.add(this.lblTutor, constraints);
|
||||||
viewport.add(this.lblCounterPermanent, constraints);
|
viewport.add(this.lblCounterPermanent, constraints);
|
||||||
viewport.add(this.lblTapPermanent, constraints);
|
viewport.add(this.lblTapPermanent, constraints);
|
||||||
viewport.add(this.lblUntapPermanent, constraints);
|
viewport.add(this.lblUntapPermanent, constraints);
|
||||||
viewport.add(this.lblUnlimitedLands, constraints);
|
viewport.add(this.lblSetLife, constraints);
|
||||||
viewport.add(this.lblHumanLife, constraints);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Assembles swing components for "console" panel. */
|
/** Assembles swing components for "console" panel. */
|
||||||
|
|||||||
Reference in New Issue
Block a user