diff --git a/forge-gui-desktop/src/main/java/forge/download/GuiDownloader.java b/forge-gui-desktop/src/main/java/forge/download/GuiDownloader.java index e6346a2f3d3..223a8a32af8 100644 --- a/forge-gui-desktop/src/main/java/forge/download/GuiDownloader.java +++ b/forge-gui-desktop/src/main/java/forge/download/GuiDownloader.java @@ -75,7 +75,7 @@ public class GuiDownloader extends DefaultBoundedRangeModel { btnClose.setBorder(new FSkin.LineSkinBorder(FSkin.getColor(FSkin.Colors.CLR_TEXT))); btnStart.setFont(FSkin.getFont(18)); - btnStart.setVisible(false); + btnStart.setEnabled(false); progressBar.reset(); progressBar.setString("Scanning for existing items..."); diff --git a/forge-gui-mobile/src/forge/screens/settings/FilesPage.java b/forge-gui-mobile/src/forge/screens/settings/FilesPage.java index 4de230d37ce..31f67a78cb4 100644 --- a/forge-gui-mobile/src/forge/screens/settings/FilesPage.java +++ b/forge-gui-mobile/src/forge/screens/settings/FilesPage.java @@ -1,16 +1,117 @@ package forge.screens.settings; +import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; + +import forge.Forge.Graphics; +import forge.assets.FSkinColor; +import forge.assets.FSkinFont; import forge.assets.FSkinImage; +import forge.download.GuiDownloadPicturesLQ; +import forge.download.GuiDownloadPrices; +import forge.download.GuiDownloadQuestImages; +import forge.download.GuiDownloadService; +import forge.download.GuiDownloadSetPicturesLQ; import forge.screens.TabPageScreen.TabPage; +import forge.toolbox.FGroupList; +import forge.toolbox.FList; public class FilesPage extends TabPage { + private final FGroupList lstItems = add(new FGroupList()); protected FilesPage() { super("Files", FSkinImage.OPEN); + + lstItems.setListItemRenderer(new FilesItemRenderer()); + + lstItems.addGroup("Content Downloaders"); + //lstItems.addGroup("Data Import"); + + //content downloaders + lstItems.addItem(new ContentDownloader("Download LQ Card Pictures", + "Download default card picture for each card.") { + @Override + protected GuiDownloadService createService() { + return new GuiDownloadPicturesLQ(); + } + }, 0); + lstItems.addItem(new ContentDownloader("Download LQ Set Pictures", + "Download all pictures of each card (one for each set the card appeared in)") { + @Override + protected GuiDownloadService createService() { + return new GuiDownloadSetPicturesLQ(); + } + }, 0); + lstItems.addItem(new ContentDownloader("Download Quest Images", + "Download tokens and icons used in Quest mode.") { + @Override + protected GuiDownloadService createService() { + return new GuiDownloadQuestImages(); + } + }, 0); + lstItems.addItem(new ContentDownloader("Download Card Prices", + "Download up-to-date price list for in-game card shops.") { + @Override + protected GuiDownloadService createService() { + return new GuiDownloadPrices(); + } + }, 0); } @Override protected void doLayout(float width, float height) { - + lstItems.setBounds(0, 0, width, height); + } + + private abstract class FilesItem { + protected String label; + protected String description; + + public FilesItem(String label0, String description0) { + label = label0; + description = description0; + } + + public abstract void select(); + } + + private static class FilesItemRenderer extends FList.ListItemRenderer { + @Override + public float getItemHeight() { + return SettingsScreen.SETTING_HEIGHT; + } + + @Override + public boolean tap(FilesItem value, float x, float y, int count) { + value.select(); + return true; + } + + @Override + public void drawValue(Graphics g, FilesItem value, FSkinFont font, FSkinColor color, boolean pressed, float x, float y, float w, float h) { + float offset = w * SettingsScreen.INSETS_FACTOR - FList.PADDING; //increase padding for settings items + x += offset; + y += offset; + w -= 2 * offset; + h -= 2 * offset; + + float totalHeight = h; + h = font.getMultiLineBounds(value.label).height + SettingsScreen.SETTING_PADDING; + + g.drawText(value.label, font, color, x, y, w, h, false, HAlignment.LEFT, false); + h += SettingsScreen.SETTING_PADDING; + g.drawText(value.description, SettingsScreen.DESC_FONT, SettingsScreen.DESC_COLOR, x, y + h, w, totalHeight - h + w * SettingsScreen.INSETS_FACTOR, true, HAlignment.LEFT, false); + } + } + + private abstract class ContentDownloader extends FilesItem { + public ContentDownloader(String label0, String description0) { + super(label0, description0); + } + + @Override + public void select() { + new GuiDownloader(createService()); + } + protected abstract GuiDownloadService createService(); } } diff --git a/forge-gui-mobile/src/forge/screens/settings/GuiDownloader.java b/forge-gui-mobile/src/forge/screens/settings/GuiDownloader.java index c82a6300c09..a83ff7199dc 100644 --- a/forge-gui-mobile/src/forge/screens/settings/GuiDownloader.java +++ b/forge-gui-mobile/src/forge/screens/settings/GuiDownloader.java @@ -55,6 +55,8 @@ public class GuiDownloader extends FDialog { txtAddress.setGhostText("Proxy Address"); txtPort.setGhostText("Proxy Port"); + txtAddress.setEnabled(false); + txtPort.setEnabled(false); RadioButtonGroup group = new RadioButtonGroup(); radProxyNone.setGroup(group); @@ -67,7 +69,7 @@ public class GuiDownloader extends FDialog { radProxyNone.setSelected(true); btnStart.setFont(FSkinFont.get(18)); - btnStart.setVisible(false); + btnStart.setEnabled(false); btnCancel.setFont(btnStart.getFont()); btnCancel.setCommand(cmdClose); @@ -102,13 +104,13 @@ public class GuiDownloader extends FDialog { float x = padding; float y = padding; float w = width - 2 * padding; - float radioButtonWidth = (w - 2 * padding) / 3; - float radioButtonHeight = radProxyNone.getHeight(); + float radioButtonWidth = w / 3; + float radioButtonHeight = radProxyNone.getAutoSizeBounds().height; radProxyNone.setBounds(x, y, radioButtonWidth, radioButtonHeight); - x += radioButtonWidth + padding; + x += radioButtonWidth; radProxyHTTP.setBounds(x, y, radioButtonWidth, radioButtonHeight); - x += radioButtonWidth + padding; + x += radioButtonWidth; radProxySocks.setBounds(x, y, radioButtonWidth, radioButtonHeight); x = padding; @@ -116,8 +118,8 @@ public class GuiDownloader extends FDialog { txtAddress.setBounds(x, y, w, txtAddress.getHeight()); y += txtAddress.getHeight() + padding; txtPort.setBounds(x, y, w, txtPort.getHeight()); - y += (txtPort.getHeight() + padding) * 2; - progressBar.setBounds(x, y, w, txtPort.getHeight() * 2); + y += txtPort.getHeight() + padding * 2; + progressBar.setBounds(x, y, w, txtPort.getHeight() * 1.5f); y += progressBar.getHeight() + padding * 2; float buttonWidth = (w - padding) / 2; @@ -125,6 +127,6 @@ public class GuiDownloader extends FDialog { btnStart.setBounds(x, y, buttonWidth, buttonHeight); x += w - buttonWidth; btnCancel.setBounds(x, y, buttonWidth, buttonHeight); - return y + buttonWidth + padding; + return y + buttonHeight + padding; } } diff --git a/forge-gui-mobile/src/forge/toolbox/FRadioButton.java b/forge-gui-mobile/src/forge/toolbox/FRadioButton.java index a7170cd7392..7aa0b2a0e8f 100644 --- a/forge-gui-mobile/src/forge/toolbox/FRadioButton.java +++ b/forge-gui-mobile/src/forge/toolbox/FRadioButton.java @@ -9,6 +9,7 @@ import forge.Forge.Graphics; import forge.assets.FImage; import forge.assets.FSkinColor; import forge.assets.FSkinColor.Colors; +import forge.util.Utils; public class FRadioButton extends FLabel { private static final FSkinColor INNER_CIRCLE_COLOR = FSkinColor.get(Colors.CLR_TEXT); @@ -72,9 +73,9 @@ public class FRadioButton extends FLabel { @Override public void draw(Graphics g, float x, float y, float w, float h) { float radius = h / 3; - x += w / 2; + x += w - radius; y += h / 2; - g.drawCircle(1, OUTER_CIRCLE_COLOR, x, y, radius); + g.drawCircle(Utils.scaleMin(1), OUTER_CIRCLE_COLOR, x, y, radius); if (isSelected()) { g.fillCircle(INNER_CIRCLE_COLOR, x, y, radius / 2); } diff --git a/forge-gui/src/main/java/forge/download/GuiDownloadService.java b/forge-gui/src/main/java/forge/download/GuiDownloadService.java index 53436a20b27..36e224a7d3c 100644 --- a/forge-gui/src/main/java/forge/download/GuiDownloadService.java +++ b/forge-gui/src/main/java/forge/download/GuiDownloadService.java @@ -118,7 +118,7 @@ public abstract class GuiDownloadService implements Runnable { //for(Entry kv : cards.entrySet()) System.out.printf("Will get %s from %s%n", kv.getKey(), kv.getValue()); btnStart.setCommand(cmdStartDownload); } - btnStart.setVisible(true); + btnStart.setEnabled(true); FThreads.invokeInEdtLater(new Runnable() { @Override