mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Add fields to import dialog
This commit is contained in:
@@ -21,6 +21,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
|
import forge.Graphics;
|
||||||
import forge.deck.DeckRecognizer.TokenType;
|
import forge.deck.DeckRecognizer.TokenType;
|
||||||
import forge.toolbox.FCheckBox;
|
import forge.toolbox.FCheckBox;
|
||||||
import forge.toolbox.FComboBox;
|
import forge.toolbox.FComboBox;
|
||||||
@@ -43,6 +44,7 @@ public class FDeckImportDialog extends FDialog {
|
|||||||
private final FComboBox<String> monthDropdown = add(new FComboBox<String>()); //don't need wrappers since skin can't change while this dialog is open
|
private final FComboBox<String> monthDropdown = add(new FComboBox<String>()); //don't need wrappers since skin can't change while this dialog is open
|
||||||
private final FComboBox<Integer> yearDropdown = add(new FComboBox<Integer>());
|
private final FComboBox<Integer> yearDropdown = add(new FComboBox<Integer>());
|
||||||
|
|
||||||
|
private final boolean showOptions;
|
||||||
private final DeckImportController controller;
|
private final DeckImportController controller;
|
||||||
|
|
||||||
public FDeckImportDialog(final boolean replacingDeck, final Callback<Deck> callback0) {
|
public FDeckImportDialog(final boolean replacingDeck, final Callback<Deck> callback0) {
|
||||||
@@ -84,24 +86,59 @@ public class FDeckImportDialog extends FDialog {
|
|||||||
//ensure at least one known card found on clipboard
|
//ensure at least one known card found on clipboard
|
||||||
for (DeckRecognizer.Token token : tokens) {
|
for (DeckRecognizer.Token token : tokens) {
|
||||||
if (token.getType() == TokenType.KnownCard) {
|
if (token.getType() == TokenType.KnownCard) {
|
||||||
|
showOptions = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showOptions = false;
|
||||||
setButtonEnabled(0, false);
|
setButtonEnabled(0, false);
|
||||||
txtInput.setText("No known cards found on clipboard.\n\nCopy the decklist to the clipboard, then reopen this dialog.");
|
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
|
@Override
|
||||||
protected float layoutAndGetHeight(float width, float maxHeight) {
|
protected float layoutAndGetHeight(float width, float maxHeight) {
|
||||||
float padding = FOptionPane.PADDING;
|
float padding = FOptionPane.PADDING;
|
||||||
|
float x = padding;
|
||||||
|
float y = padding;
|
||||||
float w = width - 2 * padding;
|
float w = width - 2 * padding;
|
||||||
float h = txtInput.getPreferredHeight(w);
|
float h;
|
||||||
float maxTextBoxHeight = maxHeight - 2 * padding;
|
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) {
|
if (h > maxTextBoxHeight) {
|
||||||
h = maxTextBoxHeight;
|
h = maxTextBoxHeight;
|
||||||
}
|
}
|
||||||
txtInput.setBounds(padding, padding, w, h);
|
txtInput.setBounds(x, y, w, h);
|
||||||
return h + 2 * padding;
|
y += h + padding;
|
||||||
|
if (showOptions) {
|
||||||
|
h = newEditionCheck.getHeight();
|
||||||
|
}
|
||||||
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_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 FSkinColor MSG_BACK_COLOR = FScreen.Header.BACK_COLOR.alphaColor(0.75f);
|
||||||
public static final float MSG_HEIGHT = MSG_FONT.getCapHeight() * 2.5f;
|
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);
|
protected 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 float BORDER_THICKNESS = Utils.scale(1);
|
||||||
private static final FSkinColor SWIPE_BAR_COLOR = FScreen.Header.BACK_COLOR;
|
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 FSkinColor SWIPE_BAR_DOT_COLOR = FSkinColor.get(Colors.CLR_TEXT).alphaColor(0.75f);
|
||||||
private static final float SWIPE_BAR_HEIGHT = Utils.scale(12);
|
private static final float SWIPE_BAR_HEIGHT = Utils.scale(12);
|
||||||
|
|||||||
Reference in New Issue
Block a user