mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Get downloaders working from mobile game
This commit is contained in:
@@ -75,7 +75,7 @@ public class GuiDownloader extends DefaultBoundedRangeModel {
|
|||||||
|
|
||||||
btnClose.setBorder(new FSkin.LineSkinBorder(FSkin.getColor(FSkin.Colors.CLR_TEXT)));
|
btnClose.setBorder(new FSkin.LineSkinBorder(FSkin.getColor(FSkin.Colors.CLR_TEXT)));
|
||||||
btnStart.setFont(FSkin.getFont(18));
|
btnStart.setFont(FSkin.getFont(18));
|
||||||
btnStart.setVisible(false);
|
btnStart.setEnabled(false);
|
||||||
|
|
||||||
progressBar.reset();
|
progressBar.reset();
|
||||||
progressBar.setString("Scanning for existing items...");
|
progressBar.setString("Scanning for existing items...");
|
||||||
|
|||||||
@@ -1,16 +1,117 @@
|
|||||||
package forge.screens.settings;
|
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.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.screens.TabPageScreen.TabPage;
|
||||||
|
import forge.toolbox.FGroupList;
|
||||||
|
import forge.toolbox.FList;
|
||||||
|
|
||||||
public class FilesPage extends TabPage {
|
public class FilesPage extends TabPage {
|
||||||
|
private final FGroupList<FilesItem> lstItems = add(new FGroupList<FilesItem>());
|
||||||
|
|
||||||
protected FilesPage() {
|
protected FilesPage() {
|
||||||
super("Files", FSkinImage.OPEN);
|
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
|
@Override
|
||||||
protected void doLayout(float width, float height) {
|
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<FilesItem> {
|
||||||
|
@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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ public class GuiDownloader extends FDialog {
|
|||||||
|
|
||||||
txtAddress.setGhostText("Proxy Address");
|
txtAddress.setGhostText("Proxy Address");
|
||||||
txtPort.setGhostText("Proxy Port");
|
txtPort.setGhostText("Proxy Port");
|
||||||
|
txtAddress.setEnabled(false);
|
||||||
|
txtPort.setEnabled(false);
|
||||||
|
|
||||||
RadioButtonGroup group = new RadioButtonGroup();
|
RadioButtonGroup group = new RadioButtonGroup();
|
||||||
radProxyNone.setGroup(group);
|
radProxyNone.setGroup(group);
|
||||||
@@ -67,7 +69,7 @@ public class GuiDownloader extends FDialog {
|
|||||||
radProxyNone.setSelected(true);
|
radProxyNone.setSelected(true);
|
||||||
|
|
||||||
btnStart.setFont(FSkinFont.get(18));
|
btnStart.setFont(FSkinFont.get(18));
|
||||||
btnStart.setVisible(false);
|
btnStart.setEnabled(false);
|
||||||
btnCancel.setFont(btnStart.getFont());
|
btnCancel.setFont(btnStart.getFont());
|
||||||
btnCancel.setCommand(cmdClose);
|
btnCancel.setCommand(cmdClose);
|
||||||
|
|
||||||
@@ -102,13 +104,13 @@ public class GuiDownloader 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 radioButtonWidth = (w - 2 * padding) / 3;
|
float radioButtonWidth = w / 3;
|
||||||
float radioButtonHeight = radProxyNone.getHeight();
|
float radioButtonHeight = radProxyNone.getAutoSizeBounds().height;
|
||||||
|
|
||||||
radProxyNone.setBounds(x, y, radioButtonWidth, radioButtonHeight);
|
radProxyNone.setBounds(x, y, radioButtonWidth, radioButtonHeight);
|
||||||
x += radioButtonWidth + padding;
|
x += radioButtonWidth;
|
||||||
radProxyHTTP.setBounds(x, y, radioButtonWidth, radioButtonHeight);
|
radProxyHTTP.setBounds(x, y, radioButtonWidth, radioButtonHeight);
|
||||||
x += radioButtonWidth + padding;
|
x += radioButtonWidth;
|
||||||
radProxySocks.setBounds(x, y, radioButtonWidth, radioButtonHeight);
|
radProxySocks.setBounds(x, y, radioButtonWidth, radioButtonHeight);
|
||||||
|
|
||||||
x = padding;
|
x = padding;
|
||||||
@@ -116,8 +118,8 @@ public class GuiDownloader extends FDialog {
|
|||||||
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() * 2);
|
progressBar.setBounds(x, y, w, txtPort.getHeight() * 1.5f);
|
||||||
y += progressBar.getHeight() + padding * 2;
|
y += progressBar.getHeight() + padding * 2;
|
||||||
|
|
||||||
float buttonWidth = (w - padding) / 2;
|
float buttonWidth = (w - padding) / 2;
|
||||||
@@ -125,6 +127,6 @@ public class GuiDownloader extends FDialog {
|
|||||||
btnStart.setBounds(x, y, buttonWidth, buttonHeight);
|
btnStart.setBounds(x, y, buttonWidth, buttonHeight);
|
||||||
x += w - buttonWidth;
|
x += w - buttonWidth;
|
||||||
btnCancel.setBounds(x, y, buttonWidth, buttonHeight);
|
btnCancel.setBounds(x, y, buttonWidth, buttonHeight);
|
||||||
return y + buttonWidth + padding;
|
return y + buttonHeight + padding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import forge.Forge.Graphics;
|
|||||||
import forge.assets.FImage;
|
import forge.assets.FImage;
|
||||||
import forge.assets.FSkinColor;
|
import forge.assets.FSkinColor;
|
||||||
import forge.assets.FSkinColor.Colors;
|
import forge.assets.FSkinColor.Colors;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class FRadioButton extends FLabel {
|
public class FRadioButton extends FLabel {
|
||||||
private static final FSkinColor INNER_CIRCLE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
private static final FSkinColor INNER_CIRCLE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
@@ -72,9 +73,9 @@ public class FRadioButton extends FLabel {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Graphics g, float x, float y, float w, float h) {
|
public void draw(Graphics g, float x, float y, float w, float h) {
|
||||||
float radius = h / 3;
|
float radius = h / 3;
|
||||||
x += w / 2;
|
x += w - radius;
|
||||||
y += h / 2;
|
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()) {
|
if (isSelected()) {
|
||||||
g.fillCircle(INNER_CIRCLE_COLOR, x, y, radius / 2);
|
g.fillCircle(INNER_CIRCLE_COLOR, x, y, radius / 2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public abstract class GuiDownloadService implements Runnable {
|
|||||||
//for(Entry<String, String> kv : cards.entrySet()) System.out.printf("Will get %s from %s%n", kv.getKey(), kv.getValue());
|
//for(Entry<String, String> kv : cards.entrySet()) System.out.printf("Will get %s from %s%n", kv.getKey(), kv.getValue());
|
||||||
btnStart.setCommand(cmdStartDownload);
|
btnStart.setCommand(cmdStartDownload);
|
||||||
}
|
}
|
||||||
btnStart.setVisible(true);
|
btnStart.setEnabled(true);
|
||||||
|
|
||||||
FThreads.invokeInEdtLater(new Runnable() {
|
FThreads.invokeInEdtLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user