mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Make FDialogs more mobile-friendly
Fix Concede so dialog shown
This commit is contained in:
@@ -106,7 +106,7 @@ public class KeyboardShortcuts {
|
|||||||
public void actionPerformed(final ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||||
if (matchUI == null) { return; }
|
if (matchUI == null) { return; }
|
||||||
matchUI.getGameController().concede();
|
matchUI.concede();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,13 @@ import com.badlogic.gdx.math.Rectangle;
|
|||||||
|
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
import forge.ImageKeys;
|
import forge.ImageKeys;
|
||||||
import forge.assets.FSkinColor;
|
|
||||||
import forge.assets.FSkinFont;
|
|
||||||
import forge.assets.FSkinColor.Colors;
|
|
||||||
import forge.assets.FSkinImage;
|
import forge.assets.FSkinImage;
|
||||||
import forge.game.card.CardView;
|
import forge.game.card.CardView;
|
||||||
import forge.item.IPaperCard;
|
import forge.item.IPaperCard;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
import forge.screens.FScreen;
|
|
||||||
import forge.screens.match.MatchController;
|
import forge.screens.match.MatchController;
|
||||||
import forge.toolbox.FCardPanel;
|
import forge.toolbox.FCardPanel;
|
||||||
|
import forge.toolbox.FDialog;
|
||||||
import forge.toolbox.FOptionPane;
|
import forge.toolbox.FOptionPane;
|
||||||
import forge.toolbox.FOverlay;
|
import forge.toolbox.FOverlay;
|
||||||
import forge.util.FCollectionView;
|
import forge.util.FCollectionView;
|
||||||
@@ -26,9 +23,6 @@ import forge.util.Utils;
|
|||||||
|
|
||||||
public class CardZoom extends FOverlay {
|
public class CardZoom extends FOverlay {
|
||||||
private static final float REQ_AMOUNT = Utils.AVG_FINGER_WIDTH;
|
private static final float REQ_AMOUNT = Utils.AVG_FINGER_WIDTH;
|
||||||
private static final FSkinFont MSG_FONT = FSkinFont.get(12);
|
|
||||||
private static final FSkinColor MSG_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT).alphaColor(0.9f);
|
|
||||||
private static final FSkinColor MSG_BACK_COLOR = FScreen.Header.BACK_COLOR.alphaColor(0.75f);
|
|
||||||
|
|
||||||
private static final CardZoom cardZoom = new CardZoom();
|
private static final CardZoom cardZoom = new CardZoom();
|
||||||
private static List<?> items;
|
private static List<?> items;
|
||||||
@@ -175,7 +169,7 @@ public class CardZoom extends FOverlay {
|
|||||||
public void drawOverlay(Graphics g) {
|
public void drawOverlay(Graphics g) {
|
||||||
float w = getWidth();
|
float w = getWidth();
|
||||||
float h = getHeight();
|
float h = getHeight();
|
||||||
float messageHeight = MSG_FONT.getCapHeight() * 2.5f;
|
float messageHeight = FDialog.MSG_HEIGHT;
|
||||||
float maxCardHeight = h - 2 * messageHeight;
|
float maxCardHeight = h - 2 * messageHeight;
|
||||||
|
|
||||||
float cardWidth, cardHeight, y;
|
float cardWidth, cardHeight, y;
|
||||||
@@ -218,11 +212,11 @@ public class CardZoom extends FOverlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentActivateAction != null) {
|
if (currentActivateAction != null) {
|
||||||
g.fillRect(MSG_BACK_COLOR, 0, 0, w, messageHeight);
|
g.fillRect(FDialog.MSG_BACK_COLOR, 0, 0, w, messageHeight);
|
||||||
g.drawText("Swipe up to " + currentActivateAction, MSG_FONT, MSG_FORE_COLOR, 0, 0, w, messageHeight, false, HAlignment.CENTER, true);
|
g.drawText("Swipe up to " + currentActivateAction, FDialog.MSG_FONT, FDialog.MSG_FORE_COLOR, 0, 0, w, messageHeight, false, HAlignment.CENTER, true);
|
||||||
}
|
}
|
||||||
g.fillRect(MSG_BACK_COLOR, 0, h - messageHeight, w, messageHeight);
|
g.fillRect(FDialog.MSG_BACK_COLOR, 0, h - messageHeight, w, messageHeight);
|
||||||
g.drawText("Swipe down to switch to " + (zoomMode ? "detail" : "picture") + " view", MSG_FONT, MSG_FORE_COLOR, 0, h - messageHeight, w, messageHeight, false, HAlignment.CENTER, true);
|
g.drawText("Swipe down to switch to " + (zoomMode ? "detail" : "picture") + " view", FDialog.MSG_FONT, FDialog.MSG_FORE_COLOR, 0, h - messageHeight, w, messageHeight, false, HAlignment.CENTER, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import forge.game.GameEntityView;
|
|||||||
import forge.game.card.CardView;
|
import forge.game.card.CardView;
|
||||||
import forge.screens.TabPageScreen;
|
import forge.screens.TabPageScreen;
|
||||||
import forge.toolbox.FChoiceList;
|
import forge.toolbox.FChoiceList;
|
||||||
import forge.toolbox.FDialog;
|
|
||||||
import forge.toolbox.FEvent;
|
import forge.toolbox.FEvent;
|
||||||
import forge.toolbox.FOptionPane;
|
import forge.toolbox.FOptionPane;
|
||||||
import forge.toolbox.FTextField;
|
import forge.toolbox.FTextField;
|
||||||
@@ -39,15 +38,9 @@ public class GameEntityPicker extends TabPageScreen<GameEntityPicker> {
|
|||||||
callback.run(null);
|
callback.run(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) {
|
});
|
||||||
@Override
|
|
||||||
protected boolean padDisplayObject() {
|
|
||||||
return false; //let tabs go right up to edges of dialog
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
setHeight(Forge.getCurrentScreen().getHeight() - FDialog.TITLE_HEIGHT -
|
setHeight(Forge.getCurrentScreen().getHeight() - 2 * FOptionPane.PADDING);
|
||||||
3 * FOptionPane.PADDING - FOptionPane.BUTTON_HEIGHT - FOptionPane.GAP_BELOW_BUTTONS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import forge.card.CardZoom;
|
|||||||
import forge.card.mana.ManaCostShard;
|
import forge.card.mana.ManaCostShard;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.toolbox.FButton;
|
|
||||||
import forge.toolbox.FCardPanel;
|
import forge.toolbox.FCardPanel;
|
||||||
import forge.toolbox.FComboBox;
|
import forge.toolbox.FComboBox;
|
||||||
import forge.toolbox.FContainer;
|
import forge.toolbox.FContainer;
|
||||||
@@ -88,9 +87,6 @@ public class AddBasicLandsDialog extends FDialog {
|
|||||||
|
|
||||||
private final FTextArea lblDeckInfo = add(new FTextArea(true));
|
private final FTextArea lblDeckInfo = add(new FTextArea(true));
|
||||||
|
|
||||||
private final FButton btnOK = add(new FButton("OK"));
|
|
||||||
private final FButton btnCancel = add(new FButton("Cancel"));
|
|
||||||
|
|
||||||
private int nonLandCount, oldLandCount;
|
private int nonLandCount, oldLandCount;
|
||||||
private CardEdition landSet;
|
private CardEdition landSet;
|
||||||
|
|
||||||
@@ -98,7 +94,7 @@ public class AddBasicLandsDialog extends FDialog {
|
|||||||
this(deck, defaultLandSet, null, callback0);
|
this(deck, defaultLandSet, null, callback0);
|
||||||
}
|
}
|
||||||
public AddBasicLandsDialog(Deck deck, CardEdition defaultLandSet, CardPool restrictedCatalog0, final Callback<CardPool> callback0) {
|
public AddBasicLandsDialog(Deck deck, CardEdition defaultLandSet, CardPool restrictedCatalog0, final Callback<CardPool> callback0) {
|
||||||
super("Add Basic Lands to " + deck.getName());
|
super("Add Basic Lands to " + deck.getName(), 2);
|
||||||
|
|
||||||
callback = callback0;
|
callback = callback0;
|
||||||
|
|
||||||
@@ -119,7 +115,7 @@ public class AddBasicLandsDialog extends FDialog {
|
|||||||
});
|
});
|
||||||
cbLandSet.setSelectedItem(defaultLandSet);
|
cbLandSet.setSelectedItem(defaultLandSet);
|
||||||
|
|
||||||
btnOK.setCommand(new FEventHandler() {
|
initButton(0, "OK", new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
CardPool landsToAdd = new CardPool();
|
CardPool landsToAdd = new CardPool();
|
||||||
@@ -136,7 +132,7 @@ public class AddBasicLandsDialog extends FDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnCancel.setCommand(new FEventHandler() {
|
initButton(1, "Cancel", new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
hide();
|
hide();
|
||||||
@@ -250,15 +246,7 @@ public class AddBasicLandsDialog extends FDialog {
|
|||||||
y += panelHeight + padding;
|
y += panelHeight + padding;
|
||||||
lblDeckInfo.setBounds(x, y, w, lblDeckInfo.getPreferredHeight(w));
|
lblDeckInfo.setBounds(x, y, w, lblDeckInfo.getPreferredHeight(w));
|
||||||
|
|
||||||
//layout buttons
|
return y;
|
||||||
y += lblDeckInfo.getHeight() + padding;
|
|
||||||
float gapBetweenButtons = padding / 2;
|
|
||||||
float buttonWidth = (w - gapBetweenButtons) / 2;
|
|
||||||
btnOK.setBounds(x, y, buttonWidth, FOptionPane.BUTTON_HEIGHT);
|
|
||||||
x += buttonWidth + gapBetweenButtons;
|
|
||||||
btnCancel.setBounds(x, y, buttonWidth, FOptionPane.BUTTON_HEIGHT);
|
|
||||||
|
|
||||||
return y + FOptionPane.BUTTON_HEIGHT + FOptionPane.GAP_BELOW_BUTTONS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDeckInfoLabel() {
|
private void updateDeckInfoLabel() {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import forge.itemmanager.filters.ItemFilter;
|
|||||||
import forge.menu.FDropDownMenu;
|
import forge.menu.FDropDownMenu;
|
||||||
import forge.menu.FMenuItem;
|
import forge.menu.FMenuItem;
|
||||||
import forge.screens.TabPageScreen;
|
import forge.screens.TabPageScreen;
|
||||||
import forge.toolbox.FButton;
|
|
||||||
import forge.toolbox.FDialog;
|
import forge.toolbox.FDialog;
|
||||||
import forge.toolbox.FEvent;
|
import forge.toolbox.FEvent;
|
||||||
import forge.toolbox.FOptionPane;
|
import forge.toolbox.FOptionPane;
|
||||||
@@ -23,16 +22,14 @@ import forge.util.Callback;
|
|||||||
|
|
||||||
public class FSideboardDialog extends FDialog {
|
public class FSideboardDialog extends FDialog {
|
||||||
private final SideboardTabs tabs;
|
private final SideboardTabs tabs;
|
||||||
private final FButton btnOK;
|
|
||||||
private final Callback<List<PaperCard>> callback;
|
private final Callback<List<PaperCard>> callback;
|
||||||
|
|
||||||
public FSideboardDialog(CardPool sideboard, CardPool main, final Callback<List<PaperCard>> callback0) {
|
public FSideboardDialog(CardPool sideboard, CardPool main, final Callback<List<PaperCard>> callback0) {
|
||||||
super("Update main deck from sideboard");
|
super("Update main deck from sideboard", 1);
|
||||||
|
|
||||||
callback = callback0;
|
callback = callback0;
|
||||||
tabs = add(new SideboardTabs(sideboard, main));
|
tabs = add(new SideboardTabs(sideboard, main));
|
||||||
btnOK = add(new FButton("OK"));
|
initButton(1, "OK", new FEventHandler() {
|
||||||
btnOK.setCommand(new FEventHandler() {
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
hide();
|
hide();
|
||||||
@@ -53,14 +50,7 @@ public class FSideboardDialog extends FDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float layoutAndGetHeight(float width, float maxHeight) {
|
protected float layoutAndGetHeight(float width, float maxHeight) {
|
||||||
float buttonHeight = FOptionPane.BUTTON_HEIGHT;
|
tabs.setBounds(0, 0, width, maxHeight);
|
||||||
float buttonTop = maxHeight - buttonHeight - FOptionPane.GAP_BELOW_BUTTONS;
|
|
||||||
|
|
||||||
tabs.setBounds(0, 0, width, buttonTop - FOptionPane.PADDING);
|
|
||||||
|
|
||||||
float buttonWidth = width / 2;
|
|
||||||
btnOK.setBounds((width - buttonWidth) / 2, buttonTop, buttonWidth, buttonHeight);
|
|
||||||
|
|
||||||
return maxHeight;
|
return maxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import forge.screens.FScreen;
|
|||||||
import forge.toolbox.FButton;
|
import forge.toolbox.FButton;
|
||||||
import forge.toolbox.FEvent;
|
import forge.toolbox.FEvent;
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
import forge.toolbox.FOptionPane;
|
|
||||||
import forge.toolbox.FScrollPane;
|
import forge.toolbox.FScrollPane;
|
||||||
import forge.toolbox.FTextArea;
|
import forge.toolbox.FTextArea;
|
||||||
import forge.util.Callback;
|
import forge.util.Callback;
|
||||||
@@ -20,6 +19,7 @@ import forge.util.Utils;
|
|||||||
|
|
||||||
public class BugReportDialog extends FScreen { //use screen rather than dialog so screen with bug isn't rendered
|
public class BugReportDialog extends FScreen { //use screen rather than dialog so screen with bug isn't rendered
|
||||||
private static final float PADDING = Utils.scale(5);
|
private static final float PADDING = Utils.scale(5);
|
||||||
|
private static final float BUTTON_HEIGHT = Utils.AVG_FINGER_HEIGHT * 0.75f;
|
||||||
private static boolean isOpen;
|
private static boolean isOpen;
|
||||||
|
|
||||||
public static void show(String title, String text, boolean showExitAppBtn) {
|
public static void show(String title, String text, boolean showExitAppBtn) {
|
||||||
@@ -87,7 +87,7 @@ public class BugReportDialog extends FScreen { //use screen rather than dialog s
|
|||||||
y += lblHeader.getHeight() + PADDING;
|
y += lblHeader.getHeight() + PADDING;
|
||||||
|
|
||||||
float buttonWidth = (w - PADDING) / 2;
|
float buttonWidth = (w - PADDING) / 2;
|
||||||
float buttonHeight = FOptionPane.BUTTON_HEIGHT;
|
float buttonHeight = BUTTON_HEIGHT;
|
||||||
|
|
||||||
tvDetails.setBounds(x, y, w, height - 2 * buttonHeight - 3 * PADDING - y);
|
tvDetails.setBounds(x, y, w, height - 2 * buttonHeight - 3 * PADDING - y);
|
||||||
y += tvDetails.getHeight() + PADDING;
|
y += tvDetails.getHeight() + PADDING;
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ import forge.assets.FSkinColor;
|
|||||||
import forge.assets.FSkinColor.Colors;
|
import forge.assets.FSkinColor.Colors;
|
||||||
import forge.assets.FSkinFont;
|
import forge.assets.FSkinFont;
|
||||||
import forge.assets.FSkinImage;
|
import forge.assets.FSkinImage;
|
||||||
import forge.toolbox.FDialog;
|
|
||||||
import forge.toolbox.FOverlay;
|
import forge.toolbox.FOverlay;
|
||||||
import forge.util.ThreadUtil;
|
import forge.util.ThreadUtil;
|
||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class LoadingOverlay extends FOverlay {
|
public class LoadingOverlay extends FOverlay {
|
||||||
|
private static final float INSETS = Utils.scale(10);
|
||||||
private static final float LOGO_SIZE_FACTOR = 0.7f;
|
private static final float LOGO_SIZE_FACTOR = 0.7f;
|
||||||
private static final float INSETS_FACTOR = 0.025f;
|
private static final float INSETS_FACTOR = 0.025f;
|
||||||
private static final FSkinFont FONT = FSkinFont.get(22);
|
private static final FSkinFont FONT = FSkinFont.get(22);
|
||||||
@@ -53,9 +53,8 @@ public class LoadingOverlay extends FOverlay {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawOverlay(Graphics g) {
|
public void drawOverlay(Graphics g) {
|
||||||
float insets = FDialog.INSETS;
|
float x = INSETS;
|
||||||
float x = insets;
|
float w = getWidth() - 2 * INSETS;
|
||||||
float w = getWidth() - 2 * insets;
|
|
||||||
|
|
||||||
float padding = w * INSETS_FACTOR;
|
float padding = w * INSETS_FACTOR;
|
||||||
float logoSize = w * LOGO_SIZE_FACTOR;
|
float logoSize = w * LOGO_SIZE_FACTOR;
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ public class MatchScreen extends FScreen {
|
|||||||
break;
|
break;
|
||||||
case Keys.Q: //concede game on Ctrl+Q
|
case Keys.Q: //concede game on Ctrl+Q
|
||||||
if (KeyInputAdapter.isCtrlKeyDown()) {
|
if (KeyInputAdapter.isCtrlKeyDown()) {
|
||||||
getGameController().concede();
|
MatchController.instance.concede();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import forge.game.GameEntityView;
|
|||||||
import forge.game.card.CardView;
|
import forge.game.card.CardView;
|
||||||
import forge.game.player.PlayerView;
|
import forge.game.player.PlayerView;
|
||||||
import forge.screens.match.MatchController;
|
import forge.screens.match.MatchController;
|
||||||
import forge.toolbox.FButton;
|
|
||||||
import forge.toolbox.FCardPanel;
|
import forge.toolbox.FCardPanel;
|
||||||
import forge.toolbox.FContainer;
|
import forge.toolbox.FContainer;
|
||||||
import forge.toolbox.FDialog;
|
import forge.toolbox.FDialog;
|
||||||
@@ -66,10 +65,6 @@ public class VAssignDamage extends FDialog {
|
|||||||
private final FLabel lblTotalDamage = add(new FLabel.Builder().text("Available damage points: Unknown").align(HAlignment.CENTER).build());
|
private final FLabel lblTotalDamage = add(new FLabel.Builder().text("Available damage points: Unknown").align(HAlignment.CENTER).build());
|
||||||
private final FLabel lblAssignRemaining = add(new FLabel.Builder().text("Distribute the remaining damage points among lethally wounded entities").align(HAlignment.CENTER).build());
|
private final FLabel lblAssignRemaining = add(new FLabel.Builder().text("Distribute the remaining damage points among lethally wounded entities").align(HAlignment.CENTER).build());
|
||||||
|
|
||||||
private final FButton btnOK = add(new FButton("OK"));
|
|
||||||
private final FButton btnReset = add(new FButton("Reset"));
|
|
||||||
private final FButton btnAuto = add(new FButton("Auto"));
|
|
||||||
|
|
||||||
private final AttDefCardPanel pnlAttacker;
|
private final AttDefCardPanel pnlAttacker;
|
||||||
private final DefendersPanel pnlDefenders;
|
private final DefendersPanel pnlDefenders;
|
||||||
|
|
||||||
@@ -96,7 +91,7 @@ public class VAssignDamage extends FDialog {
|
|||||||
* @param overrideOrder override combatant order
|
* @param overrideOrder override combatant order
|
||||||
*/
|
*/
|
||||||
public VAssignDamage(final CardView attacker, final List<CardView> blockers, final int damage0, final GameEntityView defender0, boolean overrideOrder, final WaitCallback<Map<CardView, Integer>> waitCallback) {
|
public VAssignDamage(final CardView attacker, final List<CardView> blockers, final int damage0, final GameEntityView defender0, boolean overrideOrder, final WaitCallback<Map<CardView, Integer>> waitCallback) {
|
||||||
super("Assign damage dealt by " + attacker);
|
super("Assign damage dealt by " + attacker, 3);
|
||||||
|
|
||||||
callback = waitCallback;
|
callback = waitCallback;
|
||||||
totalDamageToAssign = damage0;
|
totalDamageToAssign = damage0;
|
||||||
@@ -109,7 +104,7 @@ public class VAssignDamage extends FDialog {
|
|||||||
pnlAttacker = add(new AttDefCardPanel(attacker));
|
pnlAttacker = add(new AttDefCardPanel(attacker));
|
||||||
pnlDefenders = add(new DefendersPanel(blockers));
|
pnlDefenders = add(new DefendersPanel(blockers));
|
||||||
|
|
||||||
btnAuto.setCommand(new FEventHandler() {
|
initButton(0, "Auto", new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
resetAssignedDamage();
|
resetAssignedDamage();
|
||||||
@@ -117,13 +112,13 @@ public class VAssignDamage extends FDialog {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnOK.setCommand(new FEventHandler() {
|
initButton(1, "OK", new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnReset.setCommand(new FEventHandler() {
|
initButton(2, "Reset", new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
resetAssignedDamage();
|
resetAssignedDamage();
|
||||||
@@ -139,21 +134,9 @@ public class VAssignDamage extends FDialog {
|
|||||||
float padding = FOptionPane.PADDING;
|
float padding = FOptionPane.PADDING;
|
||||||
float w = width - 2 * padding;
|
float w = width - 2 * padding;
|
||||||
|
|
||||||
//layout buttons
|
|
||||||
float gapBetweenButtons = padding / 2;
|
|
||||||
float buttonWidth = (w - gapBetweenButtons * 2) / 3;
|
|
||||||
float buttonHeight = FOptionPane.BUTTON_HEIGHT;
|
|
||||||
float x = padding;
|
float x = padding;
|
||||||
float y = maxHeight - FOptionPane.GAP_BELOW_BUTTONS - buttonHeight;
|
|
||||||
btnAuto.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
x += buttonWidth + gapBetweenButtons;
|
|
||||||
btnOK.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
x += buttonWidth + gapBetweenButtons;
|
|
||||||
btnReset.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
|
|
||||||
x = padding;
|
|
||||||
float labelHeight = lblAssignRemaining.getAutoSizeBounds().height;
|
float labelHeight = lblAssignRemaining.getAutoSizeBounds().height;
|
||||||
y -= labelHeight + padding;
|
float y = maxHeight - labelHeight + padding;
|
||||||
lblAssignRemaining.setBounds(x, y, w, labelHeight);
|
lblAssignRemaining.setBounds(x, y, w, labelHeight);
|
||||||
|
|
||||||
float dtOffset = ADD_BTN_HEIGHT + defenders.get(0).label.getAutoSizeBounds().height;
|
float dtOffset = ADD_BTN_HEIGHT + defenders.get(0).label.getAutoSizeBounds().height;
|
||||||
@@ -436,7 +419,7 @@ public class VAssignDamage extends FDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lblTotalDamage.setText(String.format("Available damage points: %d (of %d)", damageLeft, totalDamageToAssign));
|
lblTotalDamage.setText(String.format("Available damage points: %d (of %d)", damageLeft, totalDamageToAssign));
|
||||||
btnOK.setEnabled(damageLeft == 0);
|
setButtonEnabled(1, damageLeft == 0);
|
||||||
lblAssignRemaining.setVisible(allHaveLethal && damageLeft > 0);
|
lblAssignRemaining.setVisible(allHaveLethal && damageLeft > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.util.List;
|
|||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
|
||||||
|
|
||||||
import forge.screens.match.MatchController;
|
import forge.screens.match.MatchController;
|
||||||
import forge.toolbox.FButton;
|
|
||||||
import forge.toolbox.FCheckBox;
|
import forge.toolbox.FCheckBox;
|
||||||
import forge.toolbox.FChoiceList;
|
import forge.toolbox.FChoiceList;
|
||||||
import forge.toolbox.FDialog;
|
import forge.toolbox.FDialog;
|
||||||
@@ -15,13 +14,11 @@ import forge.toolbox.FEvent.FEventHandler;
|
|||||||
import forge.toolbox.FOptionPane;
|
import forge.toolbox.FOptionPane;
|
||||||
|
|
||||||
public class VAutoYields extends FDialog {
|
public class VAutoYields extends FDialog {
|
||||||
private final FButton btnOk;
|
|
||||||
private final FButton btnRemove;
|
|
||||||
private final FChoiceList<String> lstAutoYields;
|
private final FChoiceList<String> lstAutoYields;
|
||||||
private final FCheckBox chkDisableAll;
|
private final FCheckBox chkDisableAll;
|
||||||
|
|
||||||
public VAutoYields() {
|
public VAutoYields() {
|
||||||
super("Auto-Yields");
|
super("Auto-Yields", 2);
|
||||||
List<String> autoYields = new ArrayList<String>();
|
List<String> autoYields = new ArrayList<String>();
|
||||||
for (String autoYield : MatchController.instance.getAutoYields()) {
|
for (String autoYield : MatchController.instance.getAutoYields()) {
|
||||||
autoYields.add(autoYield);
|
autoYields.add(autoYield);
|
||||||
@@ -44,26 +41,26 @@ public class VAutoYields extends FDialog {
|
|||||||
MatchController.instance.setDisableAutoYields(chkDisableAll.isSelected());
|
MatchController.instance.setDisableAutoYields(chkDisableAll.isSelected());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnOk = add(new FButton("OK", new FEventHandler() {
|
initButton(0, "OK", new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
btnRemove = add(new FButton("Remove Yield", new FEventHandler() {
|
initButton(1, "Remove Yield", new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
String selected = lstAutoYields.getSelectedItem();
|
String selected = lstAutoYields.getSelectedItem();
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
lstAutoYields.removeItem(selected);
|
lstAutoYields.removeItem(selected);
|
||||||
MatchController.instance.setShouldAutoYield(selected, false);
|
MatchController.instance.setShouldAutoYield(selected, false);
|
||||||
btnRemove.setEnabled(lstAutoYields.getCount() > 0);
|
setButtonEnabled(1, lstAutoYields.getCount() > 0);
|
||||||
lstAutoYields.cleanUpSelections();
|
lstAutoYields.cleanUpSelections();
|
||||||
VAutoYields.this.revalidate();
|
VAutoYields.this.revalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
btnRemove.setEnabled(autoYields.size() > 0);
|
setButtonEnabled(1, autoYields.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,12 +79,10 @@ public class VAutoYields extends FDialog {
|
|||||||
float x = padding;
|
float x = padding;
|
||||||
float y = padding;
|
float y = padding;
|
||||||
float w = width - 2 * padding;
|
float w = width - 2 * padding;
|
||||||
float buttonWidth = (w - padding) / 2;
|
|
||||||
float buttonHeight = FOptionPane.BUTTON_HEIGHT;
|
|
||||||
TextBounds checkBoxSize = chkDisableAll.getAutoSizeBounds();
|
TextBounds checkBoxSize = chkDisableAll.getAutoSizeBounds();
|
||||||
|
|
||||||
float listHeight = lstAutoYields.getListItemRenderer().getItemHeight() * lstAutoYields.getCount();
|
float listHeight = lstAutoYields.getListItemRenderer().getItemHeight() * lstAutoYields.getCount();
|
||||||
float maxListHeight = maxHeight - 3 * padding - checkBoxSize.height - buttonHeight - FOptionPane.GAP_BELOW_BUTTONS - padding;
|
float maxListHeight = maxHeight - 3 * padding - checkBoxSize.height;
|
||||||
if (listHeight > maxListHeight) {
|
if (listHeight > maxListHeight) {
|
||||||
listHeight = maxListHeight;
|
listHeight = maxListHeight;
|
||||||
}
|
}
|
||||||
@@ -96,9 +91,7 @@ public class VAutoYields extends FDialog {
|
|||||||
y += listHeight + padding;
|
y += listHeight + padding;
|
||||||
chkDisableAll.setBounds(x, y, Math.min(checkBoxSize.width, w), checkBoxSize.height);
|
chkDisableAll.setBounds(x, y, Math.min(checkBoxSize.width, w), checkBoxSize.height);
|
||||||
y += checkBoxSize.height + padding;
|
y += checkBoxSize.height + padding;
|
||||||
btnOk.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
btnRemove.setBounds(x + buttonWidth + padding, y, buttonWidth, buttonHeight);
|
|
||||||
|
|
||||||
return y + buttonHeight + FOptionPane.GAP_BELOW_BUTTONS;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class VGameMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MatchController.instance.getGameController().concede();
|
MatchController.instance.concede();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,20 +22,19 @@ import java.net.Proxy;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
|
|
||||||
import forge.UiCommand;
|
import forge.UiCommand;
|
||||||
import forge.assets.FSkinFont;
|
|
||||||
import forge.download.GuiDownloadService;
|
import forge.download.GuiDownloadService;
|
||||||
import forge.download.GuiDownloadZipService;
|
import forge.download.GuiDownloadZipService;
|
||||||
import forge.toolbox.*;
|
import forge.toolbox.*;
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
import forge.toolbox.FRadioButton.RadioButtonGroup;
|
import forge.toolbox.FRadioButton.RadioButtonGroup;
|
||||||
import forge.util.Callback;
|
import forge.util.Callback;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class GuiDownloader extends FDialog {
|
public class GuiDownloader extends FDialog {
|
||||||
public static final Proxy.Type[] TYPES = Proxy.Type.values();
|
public static final Proxy.Type[] TYPES = Proxy.Type.values();
|
||||||
|
private static final float PADDING = Utils.scale(10);
|
||||||
|
|
||||||
private final FProgressBar progressBar = add(new FProgressBar());
|
private final FProgressBar progressBar = add(new FProgressBar());
|
||||||
private final FButton btnStart = add(new FButton("Start"));
|
|
||||||
private final FButton btnCancel = add(new FButton("Cancel"));
|
|
||||||
private final FTextField txtAddress = add(new FTextField());
|
private final FTextField txtAddress = add(new FTextField());
|
||||||
private final FTextField txtPort = add(new FTextField());
|
private final FTextField txtPort = add(new FTextField());
|
||||||
private final FRadioButton radProxyNone = add(new FRadioButton("No Proxy"));
|
private final FRadioButton radProxyNone = add(new FRadioButton("No Proxy"));
|
||||||
@@ -50,7 +49,7 @@ public class GuiDownloader extends FDialog {
|
|||||||
service.setCancel(true);
|
service.setCancel(true);
|
||||||
hide();
|
hide();
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.run(btnStart.getText() == "OK"); //determine result based on whether download finished
|
callback.run(getButton(0).getText() == "OK"); //determine result based on whether download finished
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -62,7 +61,7 @@ public class GuiDownloader extends FDialog {
|
|||||||
this(service0, null);
|
this(service0, null);
|
||||||
}
|
}
|
||||||
public GuiDownloader(GuiDownloadService service0, Callback<Boolean> callback0) {
|
public GuiDownloader(GuiDownloadService service0, Callback<Boolean> callback0) {
|
||||||
super(service0.getTitle());
|
super(service0.getTitle(), 2);
|
||||||
service = service0;
|
service = service0;
|
||||||
callback = callback0;
|
callback = callback0;
|
||||||
|
|
||||||
@@ -81,10 +80,13 @@ public class GuiDownloader extends FDialog {
|
|||||||
radProxySocks.setCommand(new ProxyHandler(2));
|
radProxySocks.setCommand(new ProxyHandler(2));
|
||||||
radProxyNone.setSelected(true);
|
radProxyNone.setSelected(true);
|
||||||
|
|
||||||
btnStart.setFont(FSkinFont.get(18));
|
getButton(0).setText("Start");
|
||||||
btnStart.setEnabled(false);
|
initButton(1, "Cancel", new FEventHandler() {
|
||||||
btnCancel.setFont(btnStart.getFont());
|
@Override
|
||||||
btnCancel.setCommand(cmdClose);
|
public void handleEvent(FEvent e) {
|
||||||
|
cmdClose.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
progressBar.reset();
|
progressBar.reset();
|
||||||
progressBar.setShowProgressTrail(true);
|
progressBar.setShowProgressTrail(true);
|
||||||
@@ -93,7 +95,7 @@ public class GuiDownloader extends FDialog {
|
|||||||
|
|
||||||
show();
|
show();
|
||||||
|
|
||||||
service.initialize(txtAddress, txtPort, progressBar, btnStart, cmdClose, new Runnable() {
|
service.initialize(txtAddress, txtPort, progressBar, getButton(0), cmdClose, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!(service instanceof GuiDownloadZipService)) { //retain continuous rendering for zip service
|
if (!(service instanceof GuiDownloadZipService)) { //retain continuous rendering for zip service
|
||||||
@@ -123,10 +125,9 @@ public class GuiDownloader extends FDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float layoutAndGetHeight(float width, float maxHeight) {
|
protected float layoutAndGetHeight(float width, float maxHeight) {
|
||||||
float padding = FDialog.INSETS;
|
float x = PADDING;
|
||||||
float x = padding;
|
float y = PADDING;
|
||||||
float y = padding;
|
float w = width - 2 * PADDING;
|
||||||
float w = width - 2 * padding;
|
|
||||||
float radioButtonWidth = w / 3;
|
float radioButtonWidth = w / 3;
|
||||||
float radioButtonHeight = radProxyNone.getAutoSizeBounds().height;
|
float radioButtonHeight = radProxyNone.getAutoSizeBounds().height;
|
||||||
|
|
||||||
@@ -136,20 +137,14 @@ public class GuiDownloader extends FDialog {
|
|||||||
x += radioButtonWidth;
|
x += radioButtonWidth;
|
||||||
radProxySocks.setBounds(x, y, radioButtonWidth, radioButtonHeight);
|
radProxySocks.setBounds(x, y, radioButtonWidth, radioButtonHeight);
|
||||||
|
|
||||||
x = padding;
|
x = PADDING;
|
||||||
y += radioButtonHeight + padding;
|
y += radioButtonHeight + PADDING;
|
||||||
txtAddress.setBounds(x, y, w, txtAddress.getHeight());
|
txtAddress.setBounds(x, y, w, txtAddress.getHeight());
|
||||||
y += txtAddress.getHeight() + padding;
|
y += txtAddress.getHeight() + PADDING;
|
||||||
txtPort.setBounds(x, y, w, txtPort.getHeight());
|
txtPort.setBounds(x, y, w, txtPort.getHeight());
|
||||||
y += txtPort.getHeight() + padding * 2;
|
y += txtPort.getHeight() + PADDING * 2;
|
||||||
progressBar.setBounds(x, y, w, txtPort.getHeight() * 1.5f);
|
progressBar.setBounds(x, y, w, txtPort.getHeight() * 1.5f);
|
||||||
y += progressBar.getHeight() + padding * 2;
|
y += progressBar.getHeight() + PADDING * 2;
|
||||||
|
return y;
|
||||||
float buttonWidth = (w - padding) / 2;
|
|
||||||
float buttonHeight = txtPort.getHeight() * 1.5f;
|
|
||||||
btnStart.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
x += w - buttonWidth;
|
|
||||||
btnCancel.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
return y + buttonHeight + padding;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package forge.toolbox;
|
package forge.toolbox;
|
||||||
|
|
||||||
import forge.screens.match.views.VPrompt;
|
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
import forge.toolbox.FEvent.FEventType;
|
import forge.toolbox.FEvent.FEventType;
|
||||||
import forge.util.Callback;
|
import forge.util.Callback;
|
||||||
@@ -29,8 +28,6 @@ public class DualListBox<T> extends FDialog {
|
|||||||
private final FButton addAllButton;
|
private final FButton addAllButton;
|
||||||
private final FButton removeButton;
|
private final FButton removeButton;
|
||||||
private final FButton removeAllButton;
|
private final FButton removeAllButton;
|
||||||
private final FButton okButton;
|
|
||||||
private final FButton autoButton;
|
|
||||||
|
|
||||||
private final FLabel orderedLabel;
|
private final FLabel orderedLabel;
|
||||||
private final FLabel selectOrder;
|
private final FLabel selectOrder;
|
||||||
@@ -43,7 +40,7 @@ public class DualListBox<T> extends FDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DualListBox(String title, int remainingSourcesMin, int remainingSourcesMax, List<T> sourceElements, List<T> destElements, final Callback<List<T>> callback) {
|
public DualListBox(String title, int remainingSourcesMin, int remainingSourcesMax, List<T> sourceElements, List<T> destElements, final Callback<List<T>> callback) {
|
||||||
super(title);
|
super(title, 2);
|
||||||
targetRemainingSourcesMin = remainingSourcesMin;
|
targetRemainingSourcesMin = remainingSourcesMin;
|
||||||
targetRemainingSourcesMax = remainingSourcesMax;
|
targetRemainingSourcesMax = remainingSourcesMax;
|
||||||
|
|
||||||
@@ -116,14 +113,14 @@ public class DualListBox<T> extends FDialog {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Dual List Complete Buttons
|
// Dual List Complete Buttons
|
||||||
okButton = add(new FButton("OK", onAccept));
|
initButton(0, "OK", onAccept);
|
||||||
autoButton = add(new FButton("Auto", new FEventHandler() {
|
initButton(1, "Auto", new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
addAll();
|
addAll();
|
||||||
onAccept.handleEvent(e);
|
onAccept.handleEvent(e);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
selectOrder = add(new FLabel.Builder().align(HAlignment.CENTER).text("Select Order").build());
|
selectOrder = add(new FLabel.Builder().align(HAlignment.CENTER).text("Select Order").build());
|
||||||
orderedLabel = add(new FLabel.Builder().align(HAlignment.CENTER).build());
|
orderedLabel = add(new FLabel.Builder().align(HAlignment.CENTER).build());
|
||||||
@@ -136,12 +133,10 @@ public class DualListBox<T> extends FDialog {
|
|||||||
float x = FOptionPane.PADDING;
|
float x = FOptionPane.PADDING;
|
||||||
float y = FOptionPane.PADDING / 2;
|
float y = FOptionPane.PADDING / 2;
|
||||||
width -= 2 * x;
|
width -= 2 * x;
|
||||||
maxHeight -= 2 * (VPrompt.HEIGHT - FDialog.INSETS);
|
|
||||||
|
|
||||||
float gapBetweenButtons = FOptionPane.PADDING / 2;
|
float gapBetweenButtons = FOptionPane.PADDING / 2;
|
||||||
float buttonHeight = FOptionPane.BUTTON_HEIGHT;
|
|
||||||
float labelHeight = selectOrder.getAutoSizeBounds().height;
|
float labelHeight = selectOrder.getAutoSizeBounds().height;
|
||||||
float listHeight = (maxHeight - 2 * labelHeight - buttonHeight - FOptionPane.PADDING - 2 * FDialog.INSETS) / 2;
|
float listHeight = (maxHeight - 2 * labelHeight - FOptionPane.PADDING) / 2;
|
||||||
float addButtonWidth = addAllButton.getAutoSizeBounds().width * 1.2f;
|
float addButtonWidth = addAllButton.getAutoSizeBounds().width * 1.2f;
|
||||||
float addButtonHeight = listHeight / 2 - gapBetweenButtons;
|
float addButtonHeight = listHeight / 2 - gapBetweenButtons;
|
||||||
float listWidth = width - addButtonWidth - gapBetweenButtons;
|
float listWidth = width - addButtonWidth - gapBetweenButtons;
|
||||||
@@ -162,11 +157,6 @@ public class DualListBox<T> extends FDialog {
|
|||||||
destList.setBounds(x + width - listWidth, y, listWidth, listHeight);
|
destList.setBounds(x + width - listWidth, y, listWidth, listHeight);
|
||||||
y += listHeight + FOptionPane.PADDING;
|
y += listHeight + FOptionPane.PADDING;
|
||||||
|
|
||||||
float buttonWidth = (width - gapBetweenButtons) / 2;
|
|
||||||
okButton.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
x += buttonWidth + gapBetweenButtons;
|
|
||||||
autoButton.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
|
|
||||||
return maxHeight;
|
return maxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,13 +194,13 @@ public class DualListBox<T> extends FDialog {
|
|||||||
boolean canRemove = destList.getCount() != 0;
|
boolean canRemove = destList.getCount() != 0;
|
||||||
boolean targetReached = anySize || targetRemainingSourcesMin <= sourceList.getCount() && targetRemainingSourcesMax >= sourceList.getCount();
|
boolean targetReached = anySize || targetRemainingSourcesMin <= sourceList.getCount() && targetRemainingSourcesMax >= sourceList.getCount();
|
||||||
|
|
||||||
autoButton.setEnabled(targetRemainingSourcesMax == 0 && !targetReached);
|
setButtonEnabled(1, targetRemainingSourcesMax == 0 && !targetReached);
|
||||||
|
|
||||||
addButton.setEnabled(canAdd);
|
addButton.setEnabled(canAdd);
|
||||||
addAllButton.setEnabled(canAdd);
|
addAllButton.setEnabled(canAdd);
|
||||||
removeButton.setEnabled(canRemove);
|
removeButton.setEnabled(canRemove);
|
||||||
removeAllButton.setEnabled(canRemove);
|
removeAllButton.setEnabled(canRemove);
|
||||||
okButton.setEnabled(targetReached);
|
setButtonEnabled(0, targetReached);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChoiceList extends FChoiceList<T> {
|
private class ChoiceList extends FChoiceList<T> {
|
||||||
@@ -231,13 +221,13 @@ public class DualListBox<T> extends FDialog {
|
|||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case Keys.ENTER:
|
case Keys.ENTER:
|
||||||
case Keys.ESCAPE: //Enter and Escape should trigger either OK or Auto based on which is enabled
|
case Keys.ESCAPE: //Enter and Escape should trigger either OK or Auto based on which is enabled
|
||||||
if (okButton.trigger()) {
|
if (getButton(0).trigger()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return autoButton.trigger();
|
return getButton(1).trigger();
|
||||||
case Keys.SPACE: //Space should trigger OK button if enabled,
|
case Keys.SPACE: //Space should trigger OK button if enabled,
|
||||||
//otherwise it should trigger first enabled button (default container behavior)
|
//otherwise it should trigger first enabled button (default container behavior)
|
||||||
if (okButton.trigger()) {
|
if (getButton(0).trigger()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,52 +1,55 @@
|
|||||||
package forge.toolbox;
|
package forge.toolbox;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
|
||||||
|
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
import forge.assets.FSkinColor;
|
import forge.assets.FSkinColor;
|
||||||
import forge.assets.FSkinFont;
|
import forge.assets.FSkinFont;
|
||||||
import forge.assets.FSkinImage;
|
|
||||||
import forge.assets.FSkinTexture;
|
import forge.assets.FSkinTexture;
|
||||||
import forge.assets.FSkinColor.Colors;
|
import forge.assets.FSkinColor.Colors;
|
||||||
import forge.screens.FScreen;
|
import forge.screens.FScreen;
|
||||||
import forge.screens.match.MatchController;
|
import forge.screens.match.MatchController;
|
||||||
|
import forge.screens.match.views.VPrompt;
|
||||||
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
|
|
||||||
public abstract class FDialog extends FOverlay {
|
public abstract class FDialog extends FOverlay {
|
||||||
private static final FSkinFont TITLE_FONT = FSkinFont.get(12);
|
public static final FSkinFont MSG_FONT = FSkinFont.get(12);
|
||||||
private static final FSkinColor TITLE_BACK_COLOR = FSkinColor.get(Colors.CLR_THEME2);
|
public static final FSkinColor MSG_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT).alphaColor(0.9f);
|
||||||
|
public static final FSkinColor MSG_BACK_COLOR = FScreen.Header.BACK_COLOR.alphaColor(0.75f);
|
||||||
|
public static final float MSG_HEIGHT = MSG_FONT.getCapHeight() * 2.5f;
|
||||||
private static final FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS);
|
private static final FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS);
|
||||||
public static final float TITLE_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.6f);
|
private static float BORDER_THICKNESS = Utils.scale(1);
|
||||||
public static final float INSETS = Utils.scale(10);
|
|
||||||
private static int openDialogCount = 0;
|
private static int openDialogCount = 0;
|
||||||
|
|
||||||
public static boolean isDialogOpen() {
|
public static boolean isDialogOpen() {
|
||||||
return openDialogCount > 0;
|
return openDialogCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Titlebar lblTitlebar;
|
private final VPrompt prompt;
|
||||||
|
private final int buttonCount;
|
||||||
private float totalHeight;
|
private float totalHeight;
|
||||||
|
private boolean hidden;
|
||||||
|
|
||||||
protected FDialog(String title) {
|
protected FDialog(String title, int buttonCount0) {
|
||||||
lblTitlebar = add(new Titlebar(title));
|
title = title.replaceAll(" - ", "\n"); //breakup into lines
|
||||||
|
buttonCount = buttonCount0;
|
||||||
|
prompt = add(new VPrompt("", "", null, null));
|
||||||
|
prompt.setMessage(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final void doLayout(float width, float height) {
|
protected final void doLayout(float width, float height) {
|
||||||
width -= 2 * INSETS;
|
float contentHeight = layoutAndGetHeight(width, height - VPrompt.HEIGHT - 2 * MSG_HEIGHT);
|
||||||
|
totalHeight = contentHeight + VPrompt.HEIGHT;
|
||||||
|
|
||||||
float contentHeight = layoutAndGetHeight(width, height - TITLE_HEIGHT - 2 * INSETS);
|
prompt.setBounds(0, height - VPrompt.HEIGHT, width, VPrompt.HEIGHT);
|
||||||
totalHeight = contentHeight + TITLE_HEIGHT;
|
|
||||||
float y = (height - totalHeight) / 2;
|
|
||||||
|
|
||||||
lblTitlebar.setBounds(INSETS, y, width, TITLE_HEIGHT);
|
//shift all children into position
|
||||||
|
float dy = height - totalHeight;
|
||||||
//shift all children into position below titlebar
|
|
||||||
float dy = lblTitlebar.getBottom();
|
|
||||||
for (FDisplayObject child : getChildren()) {
|
for (FDisplayObject child : getChildren()) {
|
||||||
if (child != lblTitlebar) {
|
if (child != prompt) {
|
||||||
child.setLeft(child.getLeft() + INSETS);
|
|
||||||
child.setTop(child.getTop() + dy);
|
child.setTop(child.getTop() + dy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,10 +70,41 @@ public abstract class FDialog extends FOverlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract float layoutAndGetHeight(float width, float maxHeight);
|
protected abstract float layoutAndGetHeight(float width, float maxHeight);
|
||||||
|
|
||||||
|
protected void initButton(int index, String text, FEventHandler command) {
|
||||||
|
FButton button = getButton(index);
|
||||||
|
if (button == null) { return; }
|
||||||
|
|
||||||
|
button.setText(text);
|
||||||
|
button.setCommand(command);
|
||||||
|
button.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected FButton getButton(int index) {
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
return prompt.getBtnOk();
|
||||||
|
case 1:
|
||||||
|
return prompt.getBtnCancel();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isButtonEnabled(int index) {
|
||||||
|
FButton button = getButton(index);
|
||||||
|
return button != null ? button.isEnabled() : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setButtonEnabled(int index, boolean enabled) {
|
||||||
|
FButton button = getButton(index);
|
||||||
|
if (button != null) {
|
||||||
|
button.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isPointWithinDialog(float x, float y) {
|
private boolean isPointWithinDialog(float x, float y) {
|
||||||
Rectangle bounds = new Rectangle(lblTitlebar.getLeft(), lblTitlebar.getTop(), lblTitlebar.getWidth(), totalHeight);
|
return y >= getHeight() - totalHeight;
|
||||||
return bounds.contains(x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,82 +116,30 @@ public abstract class FDialog extends FOverlay {
|
|||||||
protected void drawBackground(Graphics g) {
|
protected void drawBackground(Graphics g) {
|
||||||
super.drawBackground(g);
|
super.drawBackground(g);
|
||||||
|
|
||||||
float x = lblTitlebar.getLeft();
|
float x = 0;
|
||||||
float y = lblTitlebar.getTop();
|
float y = getHeight() - totalHeight;
|
||||||
float w = lblTitlebar.getWidth();
|
float w = getWidth();
|
||||||
float h = totalHeight;
|
float h = totalHeight - VPrompt.HEIGHT;
|
||||||
g.drawImage(FSkinTexture.BG_TEXTURE, x, y, w, h);
|
g.drawImage(FSkinTexture.BG_TEXTURE, x, y, w, h);
|
||||||
g.fillRect(FScreen.TEXTURE_OVERLAY_COLOR, x, y, w, h);
|
g.fillRect(FScreen.TEXTURE_OVERLAY_COLOR, x, y, w, h);
|
||||||
|
|
||||||
//draw custom background behind titlebar
|
|
||||||
g.fillRect(TITLE_BACK_COLOR, x, y, w, TITLE_HEIGHT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawOverlay(Graphics g) {
|
public void drawOverlay(Graphics g) {
|
||||||
super.drawOverlay(g);
|
float w = getWidth();
|
||||||
|
String message;
|
||||||
float x = lblTitlebar.getLeft();
|
if (hidden) {
|
||||||
float y = lblTitlebar.getTop();
|
message = "Swipe up to show prompt again";
|
||||||
float w = lblTitlebar.getWidth();
|
|
||||||
float h = totalHeight;
|
|
||||||
|
|
||||||
//draw border around dialog
|
|
||||||
g.drawRect(1, BORDER_COLOR, x, y, w, h);
|
|
||||||
|
|
||||||
//draw bottom border of titlebar
|
|
||||||
y += TITLE_HEIGHT;
|
|
||||||
g.drawLine(1, BORDER_COLOR, x, y, x + w, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Titlebar extends FLabel {
|
|
||||||
private Titlebar(String title) {
|
|
||||||
super(new FLabel.Builder().text(title)
|
|
||||||
.icon(FSkinImage.FAVICON.getTextureRegion() != null ? FSkinImage.FAVICON : null) //don't show icon if on SplashScreen
|
|
||||||
.font(TITLE_FONT).align(HAlignment.LEFT));
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
@Override
|
message = "Swipe down to temporarily hide prompt";
|
||||||
public boolean pan(float x, float y, float deltaX, float deltaY, boolean moreVertical) {
|
|
||||||
for (FDisplayObject child : FDialog.this.getChildren()) {
|
|
||||||
child.setLeft(child.getLeft() + deltaX);
|
|
||||||
child.setTop(child.getTop() + deltaY);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
g.fillRect(FDialog.MSG_BACK_COLOR, 0, 0, w, MSG_HEIGHT);
|
||||||
|
g.drawText(message, FDialog.MSG_FONT, FDialog.MSG_FORE_COLOR, 0, 0, w, MSG_HEIGHT, false, HAlignment.CENTER, true);
|
||||||
|
|
||||||
@Override
|
float y = getHeight() - totalHeight;
|
||||||
public boolean panStop(float x, float y) {
|
g.drawLine(BORDER_THICKNESS, BORDER_COLOR, 0, y, w, y);
|
||||||
//ensure titlebar in view after stopping panning so it's accessible
|
y = prompt.getTop();
|
||||||
float dx = 0;
|
g.drawLine(BORDER_THICKNESS, BORDER_COLOR, 0, y, w, y);
|
||||||
float dy = 0;
|
|
||||||
float maxLeft = FDialog.this.getWidth() - lblTitlebar.getHeight();
|
|
||||||
if (lblTitlebar.getLeft() > maxLeft) {
|
|
||||||
dx = maxLeft - lblTitlebar.getLeft();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
float minRight = lblTitlebar.getHeight();
|
|
||||||
if (lblTitlebar.getRight() < minRight) {
|
|
||||||
dx = minRight - lblTitlebar.getRight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
float maxTop = FDialog.this.getHeight() - lblTitlebar.getHeight();
|
|
||||||
if (lblTitlebar.getTop() > maxTop) {
|
|
||||||
dy = maxTop - lblTitlebar.getTop();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
float minBottom = lblTitlebar.getHeight();
|
|
||||||
if (lblTitlebar.getBottom() < minBottom) {
|
|
||||||
dy = minBottom - lblTitlebar.getBottom();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dx != 0 || dy != 0) {
|
|
||||||
for (FDisplayObject child : FDialog.this.getChildren()) {
|
|
||||||
child.setLeft(child.getLeft() + dx);
|
|
||||||
child.setTop(child.getTop() + dy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,51 +48,8 @@ public class FFileChooser extends FDialog {
|
|||||||
private final FList<File> lstFiles = add(new FileList());
|
private final FList<File> lstFiles = add(new FileList());
|
||||||
private final FTextField txtFilename = add(new FilenameField());
|
private final FTextField txtFilename = add(new FilenameField());
|
||||||
|
|
||||||
private final FButton btnNewFolder = add(new FButton("New Folder", new FEventHandler() {
|
|
||||||
@Override
|
|
||||||
public void handleEvent(FEvent e) {
|
|
||||||
final File dir = getCurrentDir();
|
|
||||||
if (dir == null) {
|
|
||||||
FOptionPane.showErrorDialog("Cannot add new folder to invalid folder.", "Invalid Folder");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FOptionPane.showInputDialog("Enter name for new folder:", "New Folder", new Callback<String>() {
|
|
||||||
@Override
|
|
||||||
public void run(String result) {
|
|
||||||
if (StringUtils.isEmpty(result)) { return; }
|
|
||||||
|
|
||||||
try {
|
|
||||||
File newDir = new File(dir, result);
|
|
||||||
if (newDir.mkdirs()) {
|
|
||||||
txtFilename.setText(newDir.getAbsolutePath());
|
|
||||||
refreshFileList();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
FOptionPane.showErrorDialog("\"" + result + "\" is not a valid folder name.", "Invalid Name");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
private final FButton btnOK = add(new FButton("OK", new FEventHandler() {
|
|
||||||
@Override
|
|
||||||
public void handleEvent(FEvent e) {
|
|
||||||
activateSelectedFile(true);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
private final FButton btnCancel = add(new FButton("Cancel", new FEventHandler() {
|
|
||||||
@Override
|
|
||||||
public void handleEvent(FEvent e) {
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
private FFileChooser(String title0, ChoiceType choiceType0, String defaultFilename0, String baseDir0, Callback<String> callback0) {
|
private FFileChooser(String title0, ChoiceType choiceType0, String defaultFilename0, String baseDir0, Callback<String> callback0) {
|
||||||
super(title0);
|
super(title0, 3);
|
||||||
choiceType = choiceType0;
|
choiceType = choiceType0;
|
||||||
if (choiceType == ChoiceType.GetDirectory) {
|
if (choiceType == ChoiceType.GetDirectory) {
|
||||||
if (defaultFilename0.endsWith(File.separator)) { //if getting directory, don't end with a slash
|
if (defaultFilename0.endsWith(File.separator)) { //if getting directory, don't end with a slash
|
||||||
@@ -107,6 +64,50 @@ public class FFileChooser extends FDialog {
|
|||||||
refreshFileList();
|
refreshFileList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initButton(0, "OK", new FEventHandler() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(FEvent e) {
|
||||||
|
activateSelectedFile(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
initButton(1, "New Folder", new FEventHandler() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(FEvent e) {
|
||||||
|
final File dir = getCurrentDir();
|
||||||
|
if (dir == null) {
|
||||||
|
FOptionPane.showErrorDialog("Cannot add new folder to invalid folder.", "Invalid Folder");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FOptionPane.showInputDialog("Enter name for new folder:", "New Folder", new Callback<String>() {
|
||||||
|
@Override
|
||||||
|
public void run(String result) {
|
||||||
|
if (StringUtils.isEmpty(result)) { return; }
|
||||||
|
|
||||||
|
try {
|
||||||
|
File newDir = new File(dir, result);
|
||||||
|
if (newDir.mkdirs()) {
|
||||||
|
txtFilename.setText(newDir.getAbsolutePath());
|
||||||
|
refreshFileList();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
FOptionPane.showErrorDialog("\"" + result + "\" is not a valid folder name.", "Invalid Name");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
initButton(2, "Cancel", new FEventHandler() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(FEvent e) {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
baseDir = baseDir0;
|
baseDir = baseDir0;
|
||||||
callback = callback0;
|
callback = callback0;
|
||||||
refreshFileList();
|
refreshFileList();
|
||||||
@@ -117,22 +118,10 @@ public class FFileChooser extends FDialog {
|
|||||||
float padding = FOptionPane.PADDING;
|
float padding = FOptionPane.PADDING;
|
||||||
float w = width - 2 * padding;
|
float w = width - 2 * padding;
|
||||||
|
|
||||||
//layout buttons
|
|
||||||
float gapBetweenButtons = padding / 2;
|
|
||||||
float buttonWidth = (w - gapBetweenButtons * 2) / 3;
|
|
||||||
float buttonHeight = FOptionPane.BUTTON_HEIGHT;
|
|
||||||
float x = padding;
|
|
||||||
float y = maxHeight - FOptionPane.GAP_BELOW_BUTTONS - buttonHeight;
|
|
||||||
btnNewFolder.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
x += buttonWidth + gapBetweenButtons;
|
|
||||||
btnOK.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
x += buttonWidth + gapBetweenButtons;
|
|
||||||
btnCancel.setBounds(x, y, buttonWidth, buttonHeight);
|
|
||||||
|
|
||||||
float fieldHeight = txtFilename.getHeight();
|
float fieldHeight = txtFilename.getHeight();
|
||||||
float listHeight = y - fieldHeight - 3 * padding;
|
float listHeight = maxHeight - fieldHeight - 2 * padding;
|
||||||
x = padding;
|
float x = padding;
|
||||||
y = padding;
|
float y = padding;
|
||||||
txtFilename.setBounds(x, y, w, fieldHeight);
|
txtFilename.setBounds(x, y, w, fieldHeight);
|
||||||
y += fieldHeight + padding;
|
y += fieldHeight + padding;
|
||||||
lstFiles.setBounds(x, y, w, listHeight);
|
lstFiles.setBounds(x, y, w, listHeight);
|
||||||
|
|||||||
@@ -28,14 +28,9 @@ public class FOptionPane extends FDialog {
|
|||||||
public static final FSkinImage ERROR_ICON = FSkinImage.ERROR;
|
public static final FSkinImage ERROR_ICON = FSkinImage.ERROR;
|
||||||
|
|
||||||
public static final float PADDING = Utils.scale(10);
|
public static final float PADDING = Utils.scale(10);
|
||||||
public static final float GAP_BETWEEN_BUTTONS = Utils.scale(3);
|
|
||||||
public static final float GAP_BELOW_BUTTONS = PADDING * 0.5f;
|
|
||||||
public static final float BUTTON_HEIGHT = Utils.AVG_FINGER_HEIGHT * 0.75f;
|
|
||||||
public static final float MIN_BUTTON_WIDTH = Utils.scale(120);
|
|
||||||
|
|
||||||
public static float getMaxDisplayObjHeight() {
|
public static float getMaxDisplayObjHeight() {
|
||||||
return Forge.getCurrentScreen().getHeight() - 2 * VPrompt.HEIGHT - FDialog.TITLE_HEIGHT -
|
return Forge.getCurrentScreen().getHeight() - VPrompt.HEIGHT - 2 * FDialog.MSG_HEIGHT;
|
||||||
2 * PADDING - BUTTON_HEIGHT - GAP_BELOW_BUTTONS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showMessageDialog(String message) {
|
public static void showMessageDialog(String message) {
|
||||||
@@ -193,13 +188,12 @@ public class FOptionPane extends FDialog {
|
|||||||
private final FLabel lblIcon;
|
private final FLabel lblIcon;
|
||||||
private final FTextArea prompt;
|
private final FTextArea prompt;
|
||||||
protected final FDisplayObject displayObj;
|
protected final FDisplayObject displayObj;
|
||||||
private final FButton[] buttons;
|
|
||||||
private final Callback<Integer> callback;
|
private final Callback<Integer> callback;
|
||||||
private final int defaultOption;
|
private final int defaultOption;
|
||||||
private final boolean centerIcon;
|
private final boolean centerIcon;
|
||||||
|
|
||||||
public FOptionPane(String message, String title, FImage icon, FDisplayObject displayObj0, String[] options, int defaultOption0, final Callback<Integer> callback0) {
|
public FOptionPane(String message, String title, FImage icon, FDisplayObject displayObj0, String[] options, int defaultOption0, final Callback<Integer> callback0) {
|
||||||
super(title);
|
super(title, options.length);
|
||||||
|
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
centerIcon = icon.getWidth() >= 100; //for large icon, center in dialog
|
centerIcon = icon.getWidth() >= 100; //for large icon, center in dialog
|
||||||
@@ -231,16 +225,14 @@ public class FOptionPane extends FDialog {
|
|||||||
|
|
||||||
callback = callback0;
|
callback = callback0;
|
||||||
|
|
||||||
int optionCount = options.length;
|
for (int i = 0; i < options.length; i++) {
|
||||||
buttons = new FButton[optionCount];
|
|
||||||
for (int i = 0; i < optionCount; i++) {
|
|
||||||
final int option = i;
|
final int option = i;
|
||||||
buttons[i] = add(new FButton(options[i], new FEventHandler() {
|
initButton(i, options[i], new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
setResult(option);
|
setResult(option);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
defaultOption = defaultOption0;
|
defaultOption = defaultOption0;
|
||||||
}
|
}
|
||||||
@@ -252,24 +244,12 @@ public class FOptionPane extends FDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isButtonEnabled(int index) {
|
|
||||||
return buttons[index].isEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setButtonEnabled(int index, boolean enabled) {
|
|
||||||
buttons[index].setEnabled(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean padDisplayObject() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float layoutAndGetHeight(float width, float maxHeight) {
|
protected float layoutAndGetHeight(float width, float maxHeight) {
|
||||||
float x = PADDING;
|
float x = PADDING;
|
||||||
float y = PADDING;
|
float y = PADDING;
|
||||||
|
|
||||||
float maxPromptHeight = maxHeight - 2 * PADDING - BUTTON_HEIGHT - GAP_BELOW_BUTTONS;
|
float maxPromptHeight = maxHeight - 2 * PADDING;
|
||||||
if (displayObj != null) {
|
if (displayObj != null) {
|
||||||
maxPromptHeight -= displayObj.getHeight();
|
maxPromptHeight -= displayObj.getHeight();
|
||||||
}
|
}
|
||||||
@@ -314,40 +294,10 @@ public class FOptionPane extends FDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (displayObj != null) {
|
if (displayObj != null) {
|
||||||
if (padDisplayObject()) {
|
displayObj.setBounds(x - PADDING, y - PADDING, width, displayObj.getHeight());
|
||||||
displayObj.setBounds(x, y, width - 2 * x, displayObj.getHeight());
|
y += displayObj.getHeight() - PADDING;
|
||||||
y += displayObj.getHeight() + PADDING;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
displayObj.setBounds(x - PADDING, y - PADDING, width, displayObj.getHeight());
|
|
||||||
y += displayObj.getHeight();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return y;
|
||||||
//determine size for and position buttons
|
|
||||||
float maxButtonWidth = 0;
|
|
||||||
for (FButton btn : buttons) {
|
|
||||||
float buttonWidth = btn.getAutoSizeBounds().width;
|
|
||||||
if (buttonWidth > maxButtonWidth) {
|
|
||||||
maxButtonWidth = buttonWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
float buttonWidth = Math.max(maxButtonWidth, MIN_BUTTON_WIDTH); //account for margins and enforce minimum width
|
|
||||||
float dx = buttonWidth + GAP_BETWEEN_BUTTONS;
|
|
||||||
float totalButtonWidth = dx * buttons.length - GAP_BETWEEN_BUTTONS;
|
|
||||||
|
|
||||||
x = (width - totalButtonWidth) / 2;
|
|
||||||
if (x < PADDING) { //reduce button width if not enough room for buttons
|
|
||||||
buttonWidth = (width - 2 * PADDING - (buttons.length - 1) * GAP_BETWEEN_BUTTONS) / (float)buttons.length;
|
|
||||||
x = PADDING;
|
|
||||||
dx = buttonWidth + GAP_BETWEEN_BUTTONS;
|
|
||||||
}
|
|
||||||
for (FButton btn : buttons) {
|
|
||||||
btn.setBounds(x, y, buttonWidth, BUTTON_HEIGHT);
|
|
||||||
x += dx;
|
|
||||||
}
|
|
||||||
|
|
||||||
return y + BUTTON_HEIGHT + GAP_BELOW_BUTTONS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -363,8 +313,8 @@ public class FOptionPane extends FDialog {
|
|||||||
case Keys.BACK:
|
case Keys.BACK:
|
||||||
if (Forge.endKeyInput()) { return true; }
|
if (Forge.endKeyInput()) { return true; }
|
||||||
|
|
||||||
if (isButtonEnabled(buttons.length - 1)) {
|
if (isButtonEnabled(1)) {
|
||||||
setResult(buttons.length - 1); //set result to final option on Escape or Back
|
setResult(1); //set result to final option on Escape or Back
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ package forge.toolbox;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
|
import forge.Graphics;
|
||||||
import forge.assets.FSkinFont;
|
import forge.assets.FSkinFont;
|
||||||
import forge.toolbox.FEvent;
|
import forge.toolbox.FEvent;
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
@@ -106,7 +107,7 @@ public class ListChooser<T> extends FContainer {
|
|||||||
|
|
||||||
String[] options;
|
String[] options;
|
||||||
if (minChoices == 0) {
|
if (minChoices == 0) {
|
||||||
options = new String[] {"OK","Cancel"};
|
options = new String[] {"OK", "Cancel"};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
options = new String[] {"OK"};
|
options = new String[] {"OK"};
|
||||||
@@ -179,8 +180,10 @@ public class ListChooser<T> extends FContainer {
|
|||||||
protected void doLayout(float width, float height) {
|
protected void doLayout(float width, float height) {
|
||||||
float y = 0;
|
float y = 0;
|
||||||
if (txtSearch != null) {
|
if (txtSearch != null) {
|
||||||
txtSearch.setBounds(0, 0, width, txtSearch.getHeight());
|
float padding = txtSearch.getHeight() * 0.25f;
|
||||||
y += txtSearch.getHeight() * 1.25f;
|
y += padding;
|
||||||
|
txtSearch.setBounds(0, y, width, txtSearch.getHeight());
|
||||||
|
y += txtSearch.getHeight() + padding;
|
||||||
}
|
}
|
||||||
lstChoices.setBounds(0, y, width, height - y);
|
lstChoices.setBounds(0, y, width, height - y);
|
||||||
}
|
}
|
||||||
@@ -215,5 +218,10 @@ public class ListChooser<T> extends FContainer {
|
|||||||
protected void onCompactModeChange() {
|
protected void onCompactModeChange() {
|
||||||
updateHeight(); //update height and scroll bounds based on compact mode change
|
updateHeight(); //update height and scroll bounds based on compact mode change
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawOverlay(Graphics g) {
|
||||||
|
//don't draw border
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user