From e190ccd96e0ac7ae32ecaea5049e3711b79d4423 Mon Sep 17 00:00:00 2001 From: drdev Date: Sun, 5 Apr 2015 22:00:00 +0000 Subject: [PATCH] Add fields to import dialog --- .../src/forge/deck/FDeckImportDialog.java | 45 +++++++++++++++++-- .../src/forge/toolbox/FDialog.java | 4 +- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/forge-gui-mobile/src/forge/deck/FDeckImportDialog.java b/forge-gui-mobile/src/forge/deck/FDeckImportDialog.java index b236faca025..37e134f4875 100644 --- a/forge-gui-mobile/src/forge/deck/FDeckImportDialog.java +++ b/forge-gui-mobile/src/forge/deck/FDeckImportDialog.java @@ -21,6 +21,7 @@ import java.util.List; import forge.FThreads; import forge.Forge; +import forge.Graphics; import forge.deck.DeckRecognizer.TokenType; import forge.toolbox.FCheckBox; import forge.toolbox.FComboBox; @@ -43,6 +44,7 @@ public class FDeckImportDialog extends FDialog { private final FComboBox monthDropdown = add(new FComboBox()); //don't need wrappers since skin can't change while this dialog is open private final FComboBox yearDropdown = add(new FComboBox()); + private final boolean showOptions; private final DeckImportController controller; public FDeckImportDialog(final boolean replacingDeck, final Callback callback0) { @@ -84,24 +86,59 @@ public class FDeckImportDialog extends FDialog { //ensure at least one known card found on clipboard for (DeckRecognizer.Token token : tokens) { if (token.getType() == TokenType.KnownCard) { + showOptions = true; return; } } + showOptions = false; setButtonEnabled(0, false); txtInput.setText("No known cards found on clipboard.\n\nCopy the decklist to the clipboard, then reopen this dialog."); } + @Override + public void drawOverlay(Graphics g) { + super.drawOverlay(g); + if (showOptions) { + float y = txtInput.getTop() - FOptionPane.PADDING; + g.drawLine(BORDER_THICKNESS, BORDER_COLOR, 0, y, getWidth(), y); + } + } + @Override protected float layoutAndGetHeight(float width, float maxHeight) { float padding = FOptionPane.PADDING; + float x = padding; + float y = padding; float w = width - 2 * padding; - float h = txtInput.getPreferredHeight(w); - float maxTextBoxHeight = maxHeight - 2 * padding; + float h; + if (showOptions) { + h = monthDropdown.getHeight(); + float fieldPadding = padding / 2; + + newEditionCheck.setBounds(x, y, w, h); + y += h + fieldPadding; + dateTimeCheck.setBounds(x, y, w, h); + y += h + fieldPadding; + + float dropDownWidth = (w - fieldPadding) / 2; + monthDropdown.setBounds(x, y, dropDownWidth, h); + yearDropdown.setBounds(x + dropDownWidth + fieldPadding, y, dropDownWidth, h); + y += h + fieldPadding; + + onlyCoreExpCheck.setBounds(x, y, w, h); + y += h + 2 * padding; + } + h = txtInput.getPreferredHeight(w); + float maxTextBoxHeight = maxHeight - y - padding; if (h > maxTextBoxHeight) { h = maxTextBoxHeight; } - txtInput.setBounds(padding, padding, w, h); - return h + 2 * padding; + txtInput.setBounds(x, y, w, h); + y += h + padding; + if (showOptions) { + h = newEditionCheck.getHeight(); + } + return y; } } diff --git a/forge-gui-mobile/src/forge/toolbox/FDialog.java b/forge-gui-mobile/src/forge/toolbox/FDialog.java index df94137b07a..2bca476f300 100644 --- a/forge-gui-mobile/src/forge/toolbox/FDialog.java +++ b/forge-gui-mobile/src/forge/toolbox/FDialog.java @@ -22,8 +22,8 @@ public abstract class FDialog extends FOverlay { 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).alphaColor(0.8f); - private static final float BORDER_THICKNESS = Utils.scale(1); + protected static final FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS).alphaColor(0.8f); + protected static final float BORDER_THICKNESS = Utils.scale(1); private static final FSkinColor SWIPE_BAR_COLOR = FScreen.Header.BACK_COLOR; private static final FSkinColor SWIPE_BAR_DOT_COLOR = FSkinColor.get(Colors.CLR_TEXT).alphaColor(0.75f); private static final float SWIPE_BAR_HEIGHT = Utils.scale(12);