mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
In-Game downloading part 4:
1) add Booster pack image downloading into the quest downloads 2) begin refactor (The only real necessary difference in the downloaders is the getNeededCards(). The rest of the code was duplicate.) (Still work-in-progress)
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -9720,6 +9720,7 @@ res/pics_link/card-pictures_x.txt svneol=native#text/plain
|
|||||||
res/pics_link/card-pictures_y.txt svneol=native#text/plain
|
res/pics_link/card-pictures_y.txt svneol=native#text/plain
|
||||||
res/pics_link/card-pictures_z.txt svneol=native#text/plain
|
res/pics_link/card-pictures_z.txt svneol=native#text/plain
|
||||||
res/quest/all-prices.txt svneol=native#text/plain
|
res/quest/all-prices.txt svneol=native#text/plain
|
||||||
|
res/quest/booster-images.txt -text
|
||||||
res/quest/booster-prices.txt -text
|
res/quest/booster-prices.txt -text
|
||||||
res/quest/decks/Abraham[!!-~]Lincoln[!!-~]3.dck -text
|
res/quest/decks/Abraham[!!-~]Lincoln[!!-~]3.dck -text
|
||||||
res/quest/decks/Albert[!!-~]Einstein[!!-~]2.dck -text
|
res/quest/decks/Albert[!!-~]Einstein[!!-~]2.dck -text
|
||||||
@@ -10176,6 +10177,7 @@ src/main/java/forge/GameEntity.java -text
|
|||||||
src/main/java/forge/GuiDisplay4.java svneol=native#text/plain
|
src/main/java/forge/GuiDisplay4.java svneol=native#text/plain
|
||||||
src/main/java/forge/GuiDisplayUtil.java svneol=native#text/plain
|
src/main/java/forge/GuiDisplayUtil.java svneol=native#text/plain
|
||||||
src/main/java/forge/GuiDownloadQuestImages.java -text
|
src/main/java/forge/GuiDownloadQuestImages.java -text
|
||||||
|
src/main/java/forge/GuiDownloader.java -text
|
||||||
src/main/java/forge/GuiInput.java svneol=native#text/plain
|
src/main/java/forge/GuiInput.java svneol=native#text/plain
|
||||||
src/main/java/forge/Gui_DownloadPictures_LQ.java svneol=native#text/plain
|
src/main/java/forge/Gui_DownloadPictures_LQ.java svneol=native#text/plain
|
||||||
src/main/java/forge/Gui_DownloadPrices.java svneol=native#text/plain
|
src/main/java/forge/Gui_DownloadPrices.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ lang--transparent-properties=lang/lang.properties
|
|||||||
image/base--file=pics
|
image/base--file=pics
|
||||||
image/token--file=pics/tokens
|
image/token--file=pics/tokens
|
||||||
image/icon--file=pics/icons
|
image/icon--file=pics/icons
|
||||||
|
pics/booster--file=pics/booster
|
||||||
|
pics/booster/images--file=quest/booster-images.txt
|
||||||
symbols/small--file=images/symbols-13
|
symbols/small--file=images/symbols-13
|
||||||
sound/base--file=sound
|
sound/base--file=sound
|
||||||
|
|
||||||
|
|||||||
52
res/quest/booster-images.txt
Normal file
52
res/quest/booster-images.txt
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
http://www.cardforge.org/fpics/booster/10E.png
|
||||||
|
http://www.cardforge.org/fpics/booster/5DN.png
|
||||||
|
http://www.cardforge.org/fpics/booster/7E.png
|
||||||
|
http://www.cardforge.org/fpics/booster/8ED.png
|
||||||
|
http://www.cardforge.org/fpics/booster/9ED.png
|
||||||
|
http://www.cardforge.org/fpics/booster/ALA.png
|
||||||
|
http://www.cardforge.org/fpics/booster/AP.png
|
||||||
|
http://www.cardforge.org/fpics/booster/ARB.png
|
||||||
|
http://www.cardforge.org/fpics/booster/BOK.png
|
||||||
|
http://www.cardforge.org/fpics/booster/CFX.png
|
||||||
|
http://www.cardforge.org/fpics/booster/CHK.png
|
||||||
|
http://www.cardforge.org/fpics/booster/CSP.png
|
||||||
|
http://www.cardforge.org/fpics/booster/DIS.png
|
||||||
|
http://www.cardforge.org/fpics/booster/DPA.png
|
||||||
|
http://www.cardforge.org/fpics/booster/DST.png
|
||||||
|
http://www.cardforge.org/fpics/booster/EVE.png
|
||||||
|
http://www.cardforge.org/fpics/booster/EX.png
|
||||||
|
http://www.cardforge.org/fpics/booster/FUT.png
|
||||||
|
http://www.cardforge.org/fpics/booster/GPT.png
|
||||||
|
http://www.cardforge.org/fpics/booster/IN.png
|
||||||
|
http://www.cardforge.org/fpics/booster/JUD.png
|
||||||
|
http://www.cardforge.org/fpics/booster/LGN.png
|
||||||
|
http://www.cardforge.org/fpics/booster/LRW.png
|
||||||
|
http://www.cardforge.org/fpics/booster/M10.png
|
||||||
|
http://www.cardforge.org/fpics/booster/M11.png
|
||||||
|
http://www.cardforge.org/fpics/booster/M12.png
|
||||||
|
http://www.cardforge.org/fpics/booster/MBS.png
|
||||||
|
http://www.cardforge.org/fpics/booster/MI.png
|
||||||
|
http://www.cardforge.org/fpics/booster/MOR.png
|
||||||
|
http://www.cardforge.org/fpics/booster/MRD.png
|
||||||
|
http://www.cardforge.org/fpics/booster/NPH.png
|
||||||
|
http://www.cardforge.org/fpics/booster/OD.png
|
||||||
|
http://www.cardforge.org/fpics/booster/ONS.png
|
||||||
|
http://www.cardforge.org/fpics/booster/PLC.png
|
||||||
|
http://www.cardforge.org/fpics/booster/PS.png
|
||||||
|
http://www.cardforge.org/fpics/booster/RAV.png
|
||||||
|
http://www.cardforge.org/fpics/booster/ROE.png
|
||||||
|
http://www.cardforge.org/fpics/booster/SCG.png
|
||||||
|
http://www.cardforge.org/fpics/booster/SHM.png
|
||||||
|
http://www.cardforge.org/fpics/booster/SOK.png
|
||||||
|
http://www.cardforge.org/fpics/booster/SOM.png
|
||||||
|
http://www.cardforge.org/fpics/booster/ST.png
|
||||||
|
http://www.cardforge.org/fpics/booster/TE.png
|
||||||
|
http://www.cardforge.org/fpics/booster/TOR.png
|
||||||
|
http://www.cardforge.org/fpics/booster/TSP.png
|
||||||
|
http://www.cardforge.org/fpics/booster/UD.png
|
||||||
|
http://www.cardforge.org/fpics/booster/UL.png
|
||||||
|
http://www.cardforge.org/fpics/booster/UZ.png
|
||||||
|
http://www.cardforge.org/fpics/booster/VI.png
|
||||||
|
http://www.cardforge.org/fpics/booster/WL.png
|
||||||
|
http://www.cardforge.org/fpics/booster/WWK.png
|
||||||
|
http://www.cardforge.org/fpics/booster/ZEN.png
|
||||||
@@ -1,31 +1,13 @@
|
|||||||
package forge;
|
package forge;
|
||||||
|
|
||||||
import com.esotericsoftware.minlog.Log;
|
|
||||||
|
|
||||||
import forge.error.ErrorViewer;
|
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.io.File;
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.ConnectException;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
import static java.lang.Integer.parseInt;
|
import javax.swing.JFrame;
|
||||||
import static javax.swing.JOptionPane.DEFAULT_OPTION;
|
|
||||||
import static javax.swing.JOptionPane.PLAIN_MESSAGE;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,431 +15,53 @@ import static javax.swing.JOptionPane.PLAIN_MESSAGE;
|
|||||||
*
|
*
|
||||||
* @author Forge
|
* @author Forge
|
||||||
*/
|
*/
|
||||||
public class GuiDownloadQuestImages extends DefaultBoundedRangeModel implements Runnable, NewConstants, NewConstants.LANG.Gui_DownloadPictures {
|
public class GuiDownloadQuestImages extends GuiDownloader {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8596808503046590349L;
|
private static final long serialVersionUID = -8596808503046590349L;
|
||||||
|
|
||||||
/** Constant <code>types</code> */
|
|
||||||
public static final Proxy.Type[] types = Proxy.Type.values();
|
|
||||||
|
|
||||||
//proxy
|
|
||||||
private int type;
|
|
||||||
private JTextField addr, port;
|
|
||||||
|
|
||||||
//progress
|
|
||||||
private mCard[] cards;
|
|
||||||
private int card;
|
|
||||||
private boolean cancel;
|
|
||||||
private JProgressBar bar;
|
|
||||||
|
|
||||||
private JOptionPane dlg;
|
|
||||||
private JButton close;
|
|
||||||
|
|
||||||
private long times[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
private int tptr = 0;
|
|
||||||
private long lTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>getAverageTimePerCard.</p>
|
|
||||||
*
|
|
||||||
* @return a int.
|
|
||||||
*/
|
|
||||||
private int getAverageTimePerCard() {
|
|
||||||
int aTime = 0;
|
|
||||||
int nz = 10;
|
|
||||||
|
|
||||||
if (tptr > 9)
|
|
||||||
tptr = 0;
|
|
||||||
|
|
||||||
times[tptr] = System.currentTimeMillis() - lTime;
|
|
||||||
lTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
int tTime = 0;
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
tTime += times[i];
|
|
||||||
if (times[i] == 0)
|
|
||||||
nz--;
|
|
||||||
}
|
|
||||||
aTime = tTime / nz;
|
|
||||||
|
|
||||||
tptr++;
|
|
||||||
|
|
||||||
return aTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructor for GuiDownloadQuestImages.</p>
|
* <p>Constructor for GuiDownloadQuestImages.</p>
|
||||||
*
|
*
|
||||||
* @param c an array of {@link forge.Gui_DownloadSetPictures_LQ.mCard} objects.
|
* @param frame a array of {@link javax.swing.JFrame} objects.
|
||||||
*/
|
*/
|
||||||
private GuiDownloadQuestImages(mCard[] c) {
|
public GuiDownloadQuestImages(final JFrame frame) {
|
||||||
this.cards = c;
|
super(frame);
|
||||||
addr = new JTextField(ForgeProps.getLocalized(PROXY_ADDRESS));
|
|
||||||
port = new JTextField(ForgeProps.getLocalized(PROXY_PORT));
|
|
||||||
bar = new JProgressBar(this);
|
|
||||||
|
|
||||||
JPanel p0 = new JPanel();
|
|
||||||
p0.setLayout(new BoxLayout(p0, BoxLayout.Y_AXIS));
|
|
||||||
|
|
||||||
//Proxy Choice
|
|
||||||
ButtonGroup bg = new ButtonGroup();
|
|
||||||
String[] labels = {
|
|
||||||
ForgeProps.getLocalized(NO_PROXY), ForgeProps.getLocalized(HTTP_PROXY),
|
|
||||||
ForgeProps.getLocalized(SOCKS_PROXY)};
|
|
||||||
for (int i = 0; i < types.length; i++) {
|
|
||||||
JRadioButton rb = new JRadioButton(labels[i]);
|
|
||||||
rb.addChangeListener(new ProxyHandler(i));
|
|
||||||
bg.add(rb);
|
|
||||||
p0.add(rb);
|
|
||||||
if (i == 0) rb.setSelected(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Proxy config
|
|
||||||
p0.add(addr);
|
|
||||||
p0.add(port);
|
|
||||||
|
|
||||||
//Start
|
|
||||||
final JButton b = new JButton(ForgeProps.getLocalized(BUTTONS.START));
|
|
||||||
b.addActionListener(new ActionListener() {
|
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
new Thread(GuiDownloadQuestImages.this).start();
|
|
||||||
b.setEnabled(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
p0.add(Box.createVerticalStrut(5));
|
|
||||||
|
|
||||||
//Progress
|
|
||||||
p0.add(bar);
|
|
||||||
bar.setStringPainted(true);
|
|
||||||
//bar.setString(ForgeProps.getLocalized(BAR_BEFORE_START));
|
|
||||||
bar.setString(card + "/" + cards.length);
|
|
||||||
//bar.setString(String.format(ForgeProps.getLocalized(card == cards.length? BAR_CLOSE:BAR_WAIT), this.card, cards.length));
|
|
||||||
Dimension d = bar.getPreferredSize();
|
|
||||||
d.width = 300;
|
|
||||||
bar.setPreferredSize(d);
|
|
||||||
|
|
||||||
//JOptionPane
|
|
||||||
Object[] options = {b, close = new JButton(ForgeProps.getLocalized(BUTTONS.CANCEL))};
|
|
||||||
dlg = new JOptionPane(p0, DEFAULT_OPTION, PLAIN_MESSAGE, null, options, options[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public int getMinimum() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return card;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public int getExtent() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public int getMaximum() {
|
|
||||||
return cards == null ? 0 : cards.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>update.</p>
|
|
||||||
*
|
|
||||||
* @param card a int.
|
|
||||||
*/
|
|
||||||
private void update(int card) {
|
|
||||||
this.card = card;
|
|
||||||
|
|
||||||
final class Worker implements Runnable {
|
|
||||||
private int card;
|
|
||||||
|
|
||||||
Worker(int card) {
|
|
||||||
this.card = card;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
fireStateChanged();
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
int a = getAverageTimePerCard();
|
|
||||||
|
|
||||||
if (card != cards.length) {
|
|
||||||
sb.append(card + "/" + cards.length + " - ");
|
|
||||||
|
|
||||||
long t2Go = (cards.length - card) * a;
|
|
||||||
|
|
||||||
boolean secOnly = true;
|
|
||||||
if (t2Go > 3600000) {
|
|
||||||
sb.append(String.format("%02d:", t2Go / 3600000));
|
|
||||||
t2Go = t2Go % 3600000;
|
|
||||||
secOnly = false;
|
|
||||||
}
|
|
||||||
if (t2Go > 60000) {
|
|
||||||
sb.append(String.format("%02d:", t2Go / 60000));
|
|
||||||
t2Go = t2Go % 60000;
|
|
||||||
secOnly = false;
|
|
||||||
}
|
|
||||||
if (!secOnly)
|
|
||||||
sb.append(String.format("%02d remaining.", t2Go / 1000));
|
|
||||||
else
|
|
||||||
sb.append(String.format("0:%02d remaining.", t2Go / 1000));
|
|
||||||
} else
|
|
||||||
sb.append(String.format(ForgeProps.getLocalized(BAR_CLOSE), card, cards.length));
|
|
||||||
|
|
||||||
bar.setString(sb.toString());
|
|
||||||
//bar.setString(String.format(ForgeProps.getLocalized(card == cards.length? BAR_CLOSE:BAR_WAIT), card,
|
|
||||||
// cards.length));
|
|
||||||
System.out.println(card + "/" + cards.length + " - " + a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
;
|
|
||||||
EventQueue.invokeLater(new Worker(card));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Getter for the field <code>dlg</code>.</p>
|
|
||||||
*
|
|
||||||
* @param frame a {@link javax.swing.JFrame} object.
|
|
||||||
* @return a {@link javax.swing.JDialog} object.
|
|
||||||
*/
|
|
||||||
public JDialog getDlg(JFrame frame) {
|
|
||||||
final JDialog dlg = this.dlg.createDialog(frame, ForgeProps.getLocalized(TITLE));
|
|
||||||
close.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
dlg.setVisible(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return dlg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Setter for the field <code>cancel</code>.</p>
|
|
||||||
*
|
|
||||||
* @param cancel a boolean.
|
|
||||||
*/
|
|
||||||
public void setCancel(boolean cancel) {
|
|
||||||
this.cancel = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>run.</p>
|
|
||||||
*/
|
|
||||||
public void run() {
|
|
||||||
BufferedInputStream in;
|
|
||||||
BufferedOutputStream out;
|
|
||||||
|
|
||||||
//File base = ForgeProps.getFile(QUEST.OPPONENT_DIR);
|
|
||||||
|
|
||||||
Random r = MyRandom.random;
|
|
||||||
|
|
||||||
Proxy p = null;
|
|
||||||
if (type == 0) p = Proxy.NO_PROXY;
|
|
||||||
else try {
|
|
||||||
p = new Proxy(types[type], new InetSocketAddress(addr.getText(), parseInt(port.getText())));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ErrorViewer.showError(ex, ForgeProps.getLocalized(ERRORS.PROXY_CONNECT), addr.getText(),
|
|
||||||
port.getText());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p != null) {
|
|
||||||
byte[] buf = new byte[1024];
|
|
||||||
int len;
|
|
||||||
//System.out.println("basedir: " + base);
|
|
||||||
for (update(0); card < cards.length && !cancel; update(card + 1)) {
|
|
||||||
try {
|
|
||||||
String url = cards[card].url;
|
|
||||||
String cName;
|
|
||||||
//base = ForgeProps.getFile(IMAGE_BASE);
|
|
||||||
cName = cards[card].name;
|
|
||||||
//if (Constant.Runtime.DevMode[0])
|
|
||||||
// System.out.println(cName + " - " + url);
|
|
||||||
cName = cName.replace("%20"," ");
|
|
||||||
|
|
||||||
File base = new File(cards[card].folder);
|
|
||||||
File f = new File(base, cName);
|
|
||||||
|
|
||||||
System.out.println("Trying to download: "+cName+" "+cards[card].folder+" "+url);
|
|
||||||
|
|
||||||
//test for folder existenceFile test = new File(base, cards[card].folder);
|
|
||||||
if (!base.exists()) {
|
|
||||||
// create folder
|
|
||||||
if (!base.mkdir())
|
|
||||||
System.out.println("Can't create folder" + cards[card].folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
in = new BufferedInputStream(new URL(url).openConnection(p).getInputStream());
|
|
||||||
out = new BufferedOutputStream(new FileOutputStream(f));
|
|
||||||
|
|
||||||
while ((len = in.read(buf)) != -1) {
|
|
||||||
//user cancelled
|
|
||||||
if (cancel) {
|
|
||||||
in.close();
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
|
|
||||||
//delete what was written so far
|
|
||||||
f.delete();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}//if - cancel
|
|
||||||
|
|
||||||
out.write(buf, 0, len);
|
|
||||||
}//while - read and write file
|
|
||||||
|
|
||||||
in.close();
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
catch (ConnectException ce) {
|
|
||||||
System.out.println("Connection refused for url: " + url);
|
|
||||||
}
|
|
||||||
catch (MalformedURLException mURLe) {
|
|
||||||
System.out.println("Error - possibly missing URL for: " + cards[card].name);
|
|
||||||
//Log.error("LQ Pictures", "Malformed URL for: "+cards[card].name, mURLe);
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException fnfe) {
|
|
||||||
System.out.println("Error - the LQ picture for " + cards[card].name + " could not be found on the server. [" + cards[card].url + "] - " + fnfe.getMessage());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Log.error("LQ Pictures", "Error downloading pictures", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// pause
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(r.nextInt(750) + 420);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Log.error("Quest Image Download", "Sleep Error", e);
|
|
||||||
}
|
|
||||||
}//for
|
|
||||||
}
|
|
||||||
close.setText(ForgeProps.getLocalized(BUTTONS.CLOSE));
|
|
||||||
}//run
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>startDownload.</p>
|
|
||||||
*
|
|
||||||
* @param frame a {@link javax.swing.JFrame} object.
|
|
||||||
*/
|
|
||||||
public static void startDownload(JFrame frame) {
|
|
||||||
final mCard[] card = getNeededImages();
|
|
||||||
|
|
||||||
if (card.length == 0) {
|
|
||||||
JOptionPane.showMessageDialog(frame, ForgeProps.getLocalized(NO_MORE));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GuiDownloadQuestImages download = new GuiDownloadQuestImages(card);
|
|
||||||
JDialog dlg = download.getDlg(frame);
|
|
||||||
dlg.setVisible(true);
|
|
||||||
dlg.dispose();
|
|
||||||
download.setCancel(true);
|
|
||||||
}//startDownload()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>getNeededCards.</p>
|
* <p>getNeededCards.</p>
|
||||||
*
|
*
|
||||||
* @return an array of {@link forge.Gui_DownloadSetPictures_LQ.mCard} objects.
|
* @return an array of {@link forge.Gui_DownloadSetPictures_LQ.mCard} objects.
|
||||||
*/
|
*/
|
||||||
private static mCard[] getNeededImages() {
|
protected final DownloadObject[] getNeededImages() {
|
||||||
//read all card names and urls
|
//read all card names and urls
|
||||||
mCard[] questOpponents = readFile(QUEST.OPPONENT_ICONS, ForgeProps.getFile(QUEST.OPPONENT_DIR));
|
DownloadObject[] questOpponents = readFile(QUEST.OPPONENT_ICONS, ForgeProps.getFile(QUEST.OPPONENT_DIR));
|
||||||
ArrayList<mCard> urls = new ArrayList<mCard>();
|
DownloadObject[] boosterImages = readFile(PICS_BOOSTER_IMAGES, ForgeProps.getFile(PICS_BOOSTER));
|
||||||
|
ArrayList<DownloadObject> urls = new ArrayList<DownloadObject>();
|
||||||
|
|
||||||
//File imgBase = ForgeProps.getFile(NewConstants.IMAGE_BASE);
|
|
||||||
//File opponents = ForgeProps.getFile(NewConstants.QUEST.OPPONENTS);
|
|
||||||
|
|
||||||
File file;
|
File file;
|
||||||
File base = ForgeProps.getFile(QUEST.OPPONENT_DIR);
|
File dir = ForgeProps.getFile(QUEST.OPPONENT_DIR);
|
||||||
for (int i = 0; i < questOpponents.length; i++) {
|
for (int i = 0; i < questOpponents.length; i++) {
|
||||||
file = new File(base, questOpponents[i].name);
|
file = new File(dir, questOpponents[i].name.replace("%20", " "));
|
||||||
if (!file.exists()) urls.add(questOpponents[i]);
|
if (!file.exists()) {
|
||||||
|
urls.add(questOpponents[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dir = ForgeProps.getFile(PICS_BOOSTER);
|
||||||
|
for (int i = 0; i < boosterImages.length; i++) {
|
||||||
|
file = new File(dir, boosterImages[i].name.replace("%20", " "));
|
||||||
|
if (!file.exists()) {
|
||||||
|
urls.add(boosterImages[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//return all card names and urls that are needed
|
//return all card names and urls that are needed
|
||||||
mCard[] out = new mCard[urls.size()];
|
DownloadObject[] out = new DownloadObject[urls.size()];
|
||||||
urls.toArray(out);
|
urls.toArray(out);
|
||||||
|
|
||||||
for (int i = 0; i < out.length; i++) { System.out.println(out[i].name + " " + out[i].url); }
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}//getNeededCards()
|
} //getNeededCards()
|
||||||
|
|
||||||
/**
|
} //end class GuiDownloadQuestImages
|
||||||
* <p>readFile.</p>
|
|
||||||
*
|
|
||||||
* @param ABC a {@link java.lang.String} object.
|
|
||||||
* @return an array of {@link forge.Gui_DownloadSetPictures_LQ.mCard} objects.
|
|
||||||
*/
|
|
||||||
private static mCard[] readFile(String filename, File dir) {
|
|
||||||
try {
|
|
||||||
FileReader zrc = new FileReader(ForgeProps.getFile(filename));
|
|
||||||
BufferedReader in = new BufferedReader(zrc);
|
|
||||||
String line;
|
|
||||||
ArrayList<mCard> list = new ArrayList<mCard>();
|
|
||||||
StringTokenizer tok;
|
|
||||||
|
|
||||||
line = in.readLine();
|
|
||||||
while (line != null && (!line.equals("")) && !line.startsWith("#")) {
|
|
||||||
tok = new StringTokenizer(line, "/");
|
|
||||||
String last = null;
|
|
||||||
while(tok.hasMoreTokens()) {
|
|
||||||
last = tok.nextToken();
|
|
||||||
}
|
|
||||||
list.add(new mCard(last, line, dir.getPath()));
|
|
||||||
//URL url = new URL(line);
|
|
||||||
System.out.println("Creating new mCard with: "+last+" "+line+" "+dir.getPath());
|
|
||||||
//list.add(new mCard(url.getFile(), url.toString(), dir.getPath()));
|
|
||||||
|
|
||||||
line = in.readLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
mCard[] out = new mCard[list.size()];
|
|
||||||
list.toArray(out);
|
|
||||||
return out;
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ErrorViewer.showError(ex, "Gui_DownloadPictures: readFile() error");
|
|
||||||
throw new RuntimeException("Gui_DownloadPictures : readFile() error");
|
|
||||||
}
|
|
||||||
}//readFile()
|
|
||||||
|
|
||||||
private class ProxyHandler implements ChangeListener {
|
|
||||||
private int type;
|
|
||||||
|
|
||||||
public ProxyHandler(int type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stateChanged(ChangeEvent e) {
|
|
||||||
if (((AbstractButton) e.getSource()).isSelected()) {
|
|
||||||
GuiDownloadQuestImages.this.type = type;
|
|
||||||
addr.setEnabled(type != 0);
|
|
||||||
port.setEnabled(type != 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class mCard {
|
|
||||||
final public String name;
|
|
||||||
final public String url;
|
|
||||||
final public String folder;
|
|
||||||
|
|
||||||
mCard(String cardName, String cardURL, String cardFolder) {
|
|
||||||
name = cardName;
|
|
||||||
url = cardURL;
|
|
||||||
folder = cardFolder;
|
|
||||||
}
|
|
||||||
}//mCard
|
|
||||||
}
|
|
||||||
|
|||||||
430
src/main/java/forge/GuiDownloader.java
Normal file
430
src/main/java/forge/GuiDownloader.java
Normal file
@@ -0,0 +1,430 @@
|
|||||||
|
package forge;
|
||||||
|
|
||||||
|
import com.esotericsoftware.minlog.Log;
|
||||||
|
|
||||||
|
import forge.error.ErrorViewer;
|
||||||
|
import forge.properties.ForgeProps;
|
||||||
|
import forge.properties.NewConstants;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.net.ConnectException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import static java.lang.Integer.parseInt;
|
||||||
|
import static javax.swing.JOptionPane.DEFAULT_OPTION;
|
||||||
|
import static javax.swing.JOptionPane.PLAIN_MESSAGE;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>GuiDownloadQuestImages class.</p>
|
||||||
|
*
|
||||||
|
* @author Forge
|
||||||
|
*/
|
||||||
|
public abstract class GuiDownloader extends DefaultBoundedRangeModel implements Runnable, NewConstants, NewConstants.LANG.Gui_DownloadPictures {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -8596808503046590349L;
|
||||||
|
|
||||||
|
/** Constant <code>types</code> */
|
||||||
|
public static final Proxy.Type[] types = Proxy.Type.values();
|
||||||
|
|
||||||
|
//proxy
|
||||||
|
protected int type;
|
||||||
|
protected JTextField addr, port;
|
||||||
|
|
||||||
|
//progress
|
||||||
|
protected DownloadObject[] cards;
|
||||||
|
protected int card;
|
||||||
|
protected boolean cancel;
|
||||||
|
protected JProgressBar bar;
|
||||||
|
|
||||||
|
protected JOptionPane dlg;
|
||||||
|
protected JButton close;
|
||||||
|
|
||||||
|
protected long times[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
protected int tptr = 0;
|
||||||
|
protected long lTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>getAverageTimePerObject.</p>
|
||||||
|
*
|
||||||
|
* @return a int.
|
||||||
|
*/
|
||||||
|
protected int getAverageTimePerObject() {
|
||||||
|
int aTime = 0;
|
||||||
|
int nz = 10;
|
||||||
|
|
||||||
|
if (tptr > 9)
|
||||||
|
tptr = 0;
|
||||||
|
|
||||||
|
times[tptr] = System.currentTimeMillis() - lTime;
|
||||||
|
lTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
int tTime = 0;
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
tTime += times[i];
|
||||||
|
if (times[i] == 0)
|
||||||
|
nz--;
|
||||||
|
}
|
||||||
|
aTime = tTime / nz;
|
||||||
|
|
||||||
|
tptr++;
|
||||||
|
|
||||||
|
return aTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor for GuiDownloader.</p>
|
||||||
|
*
|
||||||
|
* @param frame a {@link javax.swing.JFrame} object.
|
||||||
|
*/
|
||||||
|
protected GuiDownloader(final JFrame frame) {
|
||||||
|
|
||||||
|
cards = getNeededImages();
|
||||||
|
|
||||||
|
if (cards.length == 0) {
|
||||||
|
JOptionPane.showMessageDialog(frame, ForgeProps.getLocalized(NO_MORE));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr = new JTextField(ForgeProps.getLocalized(PROXY_ADDRESS));
|
||||||
|
port = new JTextField(ForgeProps.getLocalized(PROXY_PORT));
|
||||||
|
bar = new JProgressBar(this);
|
||||||
|
|
||||||
|
JPanel p0 = new JPanel();
|
||||||
|
p0.setLayout(new BoxLayout(p0, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
//Proxy Choice
|
||||||
|
ButtonGroup bg = new ButtonGroup();
|
||||||
|
String[] labels = {
|
||||||
|
ForgeProps.getLocalized(NO_PROXY), ForgeProps.getLocalized(HTTP_PROXY),
|
||||||
|
ForgeProps.getLocalized(SOCKS_PROXY)};
|
||||||
|
for (int i = 0; i < types.length; i++) {
|
||||||
|
JRadioButton rb = new JRadioButton(labels[i]);
|
||||||
|
rb.addChangeListener(new ProxyHandler(i));
|
||||||
|
bg.add(rb);
|
||||||
|
p0.add(rb);
|
||||||
|
if (i == 0) rb.setSelected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Proxy config
|
||||||
|
p0.add(addr);
|
||||||
|
p0.add(port);
|
||||||
|
|
||||||
|
//Start
|
||||||
|
final JButton b = new JButton(ForgeProps.getLocalized(BUTTONS.START));
|
||||||
|
b.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
new Thread(GuiDownloader.this).start();
|
||||||
|
b.setEnabled(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
p0.add(Box.createVerticalStrut(5));
|
||||||
|
|
||||||
|
//Progress
|
||||||
|
p0.add(bar);
|
||||||
|
bar.setStringPainted(true);
|
||||||
|
//bar.setString(ForgeProps.getLocalized(BAR_BEFORE_START));
|
||||||
|
bar.setString(card + "/" + cards.length);
|
||||||
|
//bar.setString(String.format(ForgeProps.getLocalized(card == cards.length? BAR_CLOSE:BAR_WAIT), this.card, cards.length));
|
||||||
|
Dimension d = bar.getPreferredSize();
|
||||||
|
d.width = 300;
|
||||||
|
bar.setPreferredSize(d);
|
||||||
|
|
||||||
|
//JOptionPane
|
||||||
|
Object[] options = {b, close = new JButton(ForgeProps.getLocalized(BUTTONS.CANCEL))};
|
||||||
|
dlg = new JOptionPane(p0, DEFAULT_OPTION, PLAIN_MESSAGE, null, options, options[1]);
|
||||||
|
|
||||||
|
JDialog jdlg = getDlg(frame);
|
||||||
|
jdlg.setVisible(true);
|
||||||
|
jdlg.dispose();
|
||||||
|
setCancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public int getMinimum() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public int getValue() {
|
||||||
|
return card;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public int getExtent() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public int getMaximum() {
|
||||||
|
return cards == null ? 0 : cards.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>update.</p>
|
||||||
|
*
|
||||||
|
* @param card a int.
|
||||||
|
*/
|
||||||
|
private void update(int card) {
|
||||||
|
this.card = card;
|
||||||
|
|
||||||
|
final class Worker implements Runnable {
|
||||||
|
private int card;
|
||||||
|
|
||||||
|
Worker(int card) {
|
||||||
|
this.card = card;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
fireStateChanged();
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
int a = getAverageTimePerObject();
|
||||||
|
|
||||||
|
if (card != cards.length) {
|
||||||
|
sb.append(card + "/" + cards.length + " - ");
|
||||||
|
|
||||||
|
long t2Go = (cards.length - card) * a;
|
||||||
|
|
||||||
|
boolean secOnly = true;
|
||||||
|
if (t2Go > 3600000) {
|
||||||
|
sb.append(String.format("%02d:", t2Go / 3600000));
|
||||||
|
t2Go = t2Go % 3600000;
|
||||||
|
secOnly = false;
|
||||||
|
}
|
||||||
|
if (t2Go > 60000) {
|
||||||
|
sb.append(String.format("%02d:", t2Go / 60000));
|
||||||
|
t2Go = t2Go % 60000;
|
||||||
|
secOnly = false;
|
||||||
|
}
|
||||||
|
if (!secOnly)
|
||||||
|
sb.append(String.format("%02d remaining.", t2Go / 1000));
|
||||||
|
else
|
||||||
|
sb.append(String.format("0:%02d remaining.", t2Go / 1000));
|
||||||
|
} else
|
||||||
|
sb.append(String.format(ForgeProps.getLocalized(BAR_CLOSE), card, cards.length));
|
||||||
|
|
||||||
|
bar.setString(sb.toString());
|
||||||
|
System.out.println(card + "/" + cards.length + " - " + a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
EventQueue.invokeLater(new Worker(card));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Getter for the field <code>dlg</code>.</p>
|
||||||
|
*
|
||||||
|
* @param frame a {@link javax.swing.JFrame} object.
|
||||||
|
* @return a {@link javax.swing.JDialog} object.
|
||||||
|
*/
|
||||||
|
private JDialog getDlg(JFrame frame) {
|
||||||
|
final JDialog dlg = this.dlg.createDialog(frame, ForgeProps.getLocalized(TITLE));
|
||||||
|
close.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
dlg.setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return dlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Setter for the field <code>cancel</code>.</p>
|
||||||
|
*
|
||||||
|
* @param cancel a boolean.
|
||||||
|
*/
|
||||||
|
public void setCancel(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>run.</p>
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
|
BufferedInputStream in;
|
||||||
|
BufferedOutputStream out;
|
||||||
|
|
||||||
|
Random r = MyRandom.random;
|
||||||
|
|
||||||
|
Proxy p = null;
|
||||||
|
if (type == 0) p = Proxy.NO_PROXY;
|
||||||
|
else try {
|
||||||
|
p = new Proxy(types[type], new InetSocketAddress(addr.getText(), parseInt(port.getText())));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ErrorViewer.showError(ex, ForgeProps.getLocalized(ERRORS.PROXY_CONNECT), addr.getText(),
|
||||||
|
port.getText());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p != null) {
|
||||||
|
byte[] buf = new byte[1024];
|
||||||
|
int len;
|
||||||
|
for (update(0); card < cards.length && !cancel; update(card + 1)) {
|
||||||
|
try {
|
||||||
|
String url = cards[card].url;
|
||||||
|
String cName;
|
||||||
|
cName = cards[card].name;
|
||||||
|
cName = cName.replace("%20"," ");
|
||||||
|
|
||||||
|
File base = new File(cards[card].dir);
|
||||||
|
File f = new File(base, cName);
|
||||||
|
|
||||||
|
//test for folder existence
|
||||||
|
if (!base.exists()) {
|
||||||
|
// create folder
|
||||||
|
if (!base.mkdir()) {
|
||||||
|
System.out.println("Can't create folder" + cards[card].dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
in = new BufferedInputStream(new URL(url).openConnection(p).getInputStream());
|
||||||
|
out = new BufferedOutputStream(new FileOutputStream(f));
|
||||||
|
|
||||||
|
while ((len = in.read(buf)) != -1) {
|
||||||
|
//user cancelled
|
||||||
|
if (cancel) {
|
||||||
|
in.close();
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
//delete what was written so far
|
||||||
|
f.delete();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}//if - cancel
|
||||||
|
|
||||||
|
out.write(buf, 0, len);
|
||||||
|
}//while - read and write file
|
||||||
|
|
||||||
|
in.close();
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (ConnectException ce) {
|
||||||
|
System.out.println("Connection refused for url: " + url);
|
||||||
|
}
|
||||||
|
catch (MalformedURLException mURLe) {
|
||||||
|
System.out.println("Error - possibly missing URL for: " + cards[card].name);
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException fnfe) {
|
||||||
|
System.out.println("Error - the LQ picture for " + cards[card].name + " could not be found on the server. [" + cards[card].url + "] - " + fnfe.getMessage());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Log.error("LQ Pictures", "Error downloading pictures", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// throttle
|
||||||
|
try {
|
||||||
|
Thread.sleep(r.nextInt(750) + 420);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Log.error("GuiDownloader", "Sleep Error", e);
|
||||||
|
}
|
||||||
|
}//for
|
||||||
|
}
|
||||||
|
close.setText(ForgeProps.getLocalized(BUTTONS.CLOSE));
|
||||||
|
}//run
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>getNeededCards.</p>
|
||||||
|
*
|
||||||
|
* @return an array of {@link forge.GuiDownloader.DownloadObject} objects.
|
||||||
|
*/
|
||||||
|
protected abstract DownloadObject[] getNeededImages();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>readFile.</p>
|
||||||
|
*
|
||||||
|
* @param filename a {@link java.lang.String} object.
|
||||||
|
* @param dir a {@link java.util.File} object.
|
||||||
|
* @return an array of {@link forge.GuiDownloader.DownloadObject} objects.
|
||||||
|
*/
|
||||||
|
protected static DownloadObject[] readFile(String filename, File dir) {
|
||||||
|
try {
|
||||||
|
FileReader zrc = new FileReader(ForgeProps.getFile(filename));
|
||||||
|
BufferedReader in = new BufferedReader(zrc);
|
||||||
|
ArrayList<DownloadObject> list = new ArrayList<DownloadObject>();
|
||||||
|
|
||||||
|
String line;
|
||||||
|
StringTokenizer tok;
|
||||||
|
|
||||||
|
line = in.readLine();
|
||||||
|
while (line != null && (!line.equals("")) && !line.startsWith("#")) {
|
||||||
|
tok = new StringTokenizer(line, "/");
|
||||||
|
|
||||||
|
//Maybe there's a better way to do this, but I just want the filename from a URL
|
||||||
|
String last = null;
|
||||||
|
while(tok.hasMoreTokens()) {
|
||||||
|
last = tok.nextToken();
|
||||||
|
}
|
||||||
|
list.add(new DownloadObject(last, line, dir.getPath()));
|
||||||
|
|
||||||
|
line = in.readLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
DownloadObject[] out = new DownloadObject[list.size()];
|
||||||
|
list.toArray(out);
|
||||||
|
return out;
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ErrorViewer.showError(ex, "GuiDownloader: readFile() error");
|
||||||
|
throw new RuntimeException("GuiDownloader : readFile() error");
|
||||||
|
}
|
||||||
|
}//readFile()
|
||||||
|
|
||||||
|
protected class ProxyHandler implements ChangeListener {
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
public ProxyHandler(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
if (((AbstractButton) e.getSource()).isSelected()) {
|
||||||
|
GuiDownloader.this.type = type;
|
||||||
|
addr.setEnabled(type != 0);
|
||||||
|
port.setEnabled(type != 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static class DownloadObject {
|
||||||
|
final public String name;
|
||||||
|
final public String url;
|
||||||
|
final public String dir;
|
||||||
|
|
||||||
|
DownloadObject(String nameIn, String urlIn, String dirIn) {
|
||||||
|
name = nameIn;
|
||||||
|
url = urlIn;
|
||||||
|
dir = dirIn;
|
||||||
|
}
|
||||||
|
}//DownloadObject
|
||||||
|
}
|
||||||
@@ -88,7 +88,7 @@ public interface NewConstants {
|
|||||||
String CARD_PICTURES_OTHER = "card-pictures_other";
|
String CARD_PICTURES_OTHER = "card-pictures_other";
|
||||||
/** Constant <code>CARD_PICTURES_TOKEN_HQ="card-pictures_token_hq"</code>. */
|
/** Constant <code>CARD_PICTURES_TOKEN_HQ="card-pictures_token_hq"</code>. */
|
||||||
String CARD_PICTURES_TOKEN_HQ = "card-pictures_token_hq";
|
String CARD_PICTURES_TOKEN_HQ = "card-pictures_token_hq";
|
||||||
/** Constant <code>CARD_PICTURES_TOKEN_HQ="card-pictures_token_hq"</code>. */
|
/** Constant <code>TOKEN_IMAGES="token-images"</code>. */
|
||||||
String TOKEN_IMAGES = "token-images";
|
String TOKEN_IMAGES = "token-images";
|
||||||
/** Constant <code>CARDS="cards"</code>. */
|
/** Constant <code>CARDS="cards"</code>. */
|
||||||
String CARDS = "cards";
|
String CARDS = "cards";
|
||||||
@@ -110,6 +110,10 @@ public interface NewConstants {
|
|||||||
String IMAGE_TOKEN = "image/token";
|
String IMAGE_TOKEN = "image/token";
|
||||||
/** Constant <code>IMAGE_ICON="image/icon"</code>. */
|
/** Constant <code>IMAGE_ICON="image/icon"</code>. */
|
||||||
String IMAGE_ICON = "image/icon";
|
String IMAGE_ICON = "image/icon";
|
||||||
|
/** Constant <code>PICS_BOOSTER="pics/booster"</code>. */
|
||||||
|
String PICS_BOOSTER = "pics/booster";
|
||||||
|
/** Constant <code>PICS_BOOSTER_IMAGES="pics/booster/images"</code>. */
|
||||||
|
String PICS_BOOSTER_IMAGES = "pics/booster/images";
|
||||||
/** Constant <code>SOUND_BASE="sound/base"</code>. */
|
/** Constant <code>SOUND_BASE="sound/base"</code>. */
|
||||||
String SOUND_BASE = "sound/base";
|
String SOUND_BASE = "sound/base";
|
||||||
|
|
||||||
|
|||||||
@@ -1139,7 +1139,8 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final void actionPerformed(final ActionEvent e) {
|
public final void actionPerformed(final ActionEvent e) {
|
||||||
GuiDownloadQuestImages.startDownload(null);
|
//GuiDownloadQuestImages.startDownload(null);
|
||||||
|
new GuiDownloadQuestImages(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user