mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
In-Game downloading Part 3:
1) add downloading of Quest Opponent Icons 2) add this menu option to the Old GUI (Note: This is still work in progress with refactoring coming)
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -10025,6 +10025,7 @@ res/quest/decks/quest7.dck -text
|
|||||||
res/quest/decks/quest8.dck -text
|
res/quest/decks/quest8.dck -text
|
||||||
res/quest/decks/quest9.dck -text
|
res/quest/decks/quest9.dck -text
|
||||||
res/quest/price.txt svneol=native#text/plain
|
res/quest/price.txt svneol=native#text/plain
|
||||||
|
res/quest/quest-opponent-icons.txt -text
|
||||||
res/quest/quest.preferences -text
|
res/quest/quest.preferences -text
|
||||||
res/quest/quest.properties svneol=native#text/plain
|
res/quest/quest.properties svneol=native#text/plain
|
||||||
res/quest/themes/-1[!!-~]-1[!!-~]Counters[!!-~]BG.thm -text
|
res/quest/themes/-1[!!-~]-1[!!-~]Counters[!!-~]BG.thm -text
|
||||||
@@ -10174,6 +10175,7 @@ src/main/java/forge/GameActionUtil.java svneol=native#text/plain
|
|||||||
src/main/java/forge/GameEntity.java -text
|
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/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
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ NewGame/menu/lookAndFeel=Display Options
|
|||||||
NewGame/menu/download=Download Card HQ Pictures
|
NewGame/menu/download=Download Card HQ Pictures
|
||||||
NewGame/menu/downloadlq=Download Card LQ Pictures
|
NewGame/menu/downloadlq=Download Card LQ Pictures
|
||||||
NewGame/menu/downloadsetlq=Download Card Set LQ Pictures
|
NewGame/menu/downloadsetlq=Download Card Set LQ Pictures
|
||||||
|
NewGame/menu/downloadquest=Download Quest Images
|
||||||
NewGame/menu/importPicture=Import Pictures
|
NewGame/menu/importPicture=Import Pictures
|
||||||
NewGame/menu/downloadPrice=Update Price
|
NewGame/menu/downloadPrice=Update Price
|
||||||
NewGame/menu/cardSizes=Specify Max Card Size
|
NewGame/menu/cardSizes=Specify Max Card Size
|
||||||
|
|||||||
177
res/quest/quest-opponent-icons.txt
Normal file
177
res/quest/quest-opponent-icons.txt
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
http://www.cardforge.org/fpics/questAvatars/A%20Wolf%20in%20Sheeps%20Clothing.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Abraham%20Lincoln.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Albert%20Einstein.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Alice%20in%20Wonderland.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Ancient%20Battlefield.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Apu%20Nahasapeemapetilon.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Aquaman.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Aragorn.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Atomic%20Robo.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Bamm%20Bamm%20Rubble.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Barney%20Rubble.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Barroom%20Brawl.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Bart%20Simpson.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Batman.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Bela%20Lugosi.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Betty%20Rubble.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Blackbeard.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Blood%20Oath.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Boba%20Fett.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Boris%20Karloff.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Boromir.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Bridge%20Troll.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Buffy.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Bushwhacked.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/C3PO.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Captain%20America.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Catwoman.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Chief_Wiggum.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Comic%20Book%20Guy.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Conan%20the%20Barbarian.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Cow.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Crocodile%20Dundee.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Crows%20in%20the%20Field.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Cyclops.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Da%20Vinci.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Darrin%20Stephens.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Darth%20Vader.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Data.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Deadpool.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Demon.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dilbert.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dino.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Doc%20Holiday.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dogbert.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dont%20Play%20With%20Matches.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Doran.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dr%20No.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dr%20Strangelove.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dream.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dungeon%20Crawling%20Black.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dungeon%20Crawling%20Blue.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dungeon%20Crawling%20Colorless.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dungeon%20Crawling%20Gold.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dungeon%20Crawling%20Green.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dungeon%20Crawling%20Red.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Dungeon%20Crawling%20White.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Electro.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Elrond.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Endora.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Eomer.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Ezio.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Fat%20Albert.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Fin%20Fang%20Foom.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Frankenstein.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Fred%20Flintstone.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Frodo.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Galadriel.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Galahad.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Gambit.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Genghis%20Khan.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/George%20of%20the%20Jungle.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Gimli.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Gold%20Finger.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Grampa%20Simpson.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Green%20Arrow.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Green%20Lantern.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Hagrid.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Han%20Solo.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Hans.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Harry%20Potter.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Hellboy.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Hercules.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Hermione%20Granger.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Higgins.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Hobbes.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Homer%20Simpson.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/House%20Party.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Iceman.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Indiana%20Jones.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Jabba%20the%20Hut.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Jack%20Sparrow.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/James%20Bond.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/James%20T%20Kirk.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Joe%20Kidd.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Kang.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/King%20Arthur.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/King%20Edward.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/King%20Goldemar.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/King%20Kong.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Kojak.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Krypto.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Leprechaun.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Lisa%20Simpson.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Luke%20Skywalker.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Maggie%20Simpson.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Magneto.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Magnum.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Marge%20Simpson.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Mines%20of%20Kazum%20Durl.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Mister%20Fantastic.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Morpheus.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Mr%20Slate.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Napoleon.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Ned%20Flanders.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Neo.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Newton.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Oberon.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Odin.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Optimus%20Prime.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Pebbles%20Flintstone.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Picard.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Pinky%20and%20the%20Brain.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Pointy%20Haired%20Boss.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Princess%20Selenia.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Private%20Domain.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Professor%20X.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/questAIicons.txt
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/R2-D2.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Radagast.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Radiant.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Radioactive%20Man.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Ratbert.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Reactor%20Meltdown.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Redwall.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Repressed%20Magic.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Reverend%20Lovejoy.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Riddler.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Rocky.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Rogue.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Sabertooth.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Samantha%20Stephens.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Samwise%20Gamgee.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Saruman.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Sauron.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Scooby%20Doo.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Scotty.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Seabiscuit.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Secret%20Squirrel.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Sherlock%20Holmes.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Shrek.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Silver%20Samurai.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Silver%20Surfer.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Spiderman.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Spock.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Starfire.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Storm.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Sun%20Quan.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Superman.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Swan.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Tarzan.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Terminator.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/The%20Backlash%20Machine.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/The%20Court%20Jester.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/The%20Desert%20Caravan.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/The%20Great%20Gazoo.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/The%20Kings%20Contest.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/The%20Pied%20Piper.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/The%20Thing.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Tom%20Bombadil.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Totoro.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Treebeard.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Uncle%20Owen.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Walle.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Wally.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/White%20Knight.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Wilma%20Flintstone.jpg
|
||||||
|
http://www.cardforge.org/fpics/questAvatars/Wolverine.jpg
|
||||||
463
src/main/java/forge/GuiDownloadQuestImages.java
Normal file
463
src/main/java/forge/GuiDownloadQuestImages.java
Normal file
@@ -0,0 +1,463 @@
|
|||||||
|
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.*;
|
||||||
|
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.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 class GuiDownloadQuestImages 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
|
||||||
|
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>
|
||||||
|
*
|
||||||
|
* @param c an array of {@link forge.Gui_DownloadSetPictures_LQ.mCard} objects.
|
||||||
|
*/
|
||||||
|
private GuiDownloadQuestImages(mCard[] c) {
|
||||||
|
this.cards = c;
|
||||||
|
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>
|
||||||
|
*
|
||||||
|
* @return an array of {@link forge.Gui_DownloadSetPictures_LQ.mCard} objects.
|
||||||
|
*/
|
||||||
|
private static mCard[] getNeededImages() {
|
||||||
|
//read all card names and urls
|
||||||
|
mCard[] questOpponents = readFile(QUEST.OPPONENT_ICONS, ForgeProps.getFile(QUEST.OPPONENT_DIR));
|
||||||
|
ArrayList<mCard> urls = new ArrayList<mCard>();
|
||||||
|
|
||||||
|
//File imgBase = ForgeProps.getFile(NewConstants.IMAGE_BASE);
|
||||||
|
//File opponents = ForgeProps.getFile(NewConstants.QUEST.OPPONENTS);
|
||||||
|
|
||||||
|
File file;
|
||||||
|
File base = ForgeProps.getFile(QUEST.OPPONENT_DIR);
|
||||||
|
for (int i = 0; i < questOpponents.length; i++) {
|
||||||
|
file = new File(base, questOpponents[i].name);
|
||||||
|
if (!file.exists()) urls.add(questOpponents[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//return all card names and urls that are needed
|
||||||
|
mCard[] out = new mCard[urls.size()];
|
||||||
|
urls.toArray(out);
|
||||||
|
|
||||||
|
for (int i = 0; i < out.length; i++) { System.out.println(out[i].name + " " + out[i].url); }
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}//getNeededCards()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <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
|
||||||
|
}
|
||||||
@@ -157,7 +157,8 @@ public interface NewConstants {
|
|||||||
String DECKS = "quest/decks-dir";
|
String DECKS = "quest/decks-dir";
|
||||||
String XMLDATA = "quest/data-xml";
|
String XMLDATA = "quest/data-xml";
|
||||||
|
|
||||||
String OPPONENTS = "quest/opponent/icons";
|
String OPPONENT_ICONS = "quest/opponent/icons";
|
||||||
|
String OPPONENT_DIR = "image/icon";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -433,6 +434,7 @@ public interface NewConstants {
|
|||||||
String DOWNLOAD = "%s/NewGame/menu/download";
|
String DOWNLOAD = "%s/NewGame/menu/download";
|
||||||
String DOWNLOADLQ = "%s/NewGame/menu/downloadlq";
|
String DOWNLOADLQ = "%s/NewGame/menu/downloadlq";
|
||||||
String DOWNLOADSETLQ = "%s/NewGame/menu/downloadsetlq";
|
String DOWNLOADSETLQ = "%s/NewGame/menu/downloadsetlq";
|
||||||
|
String DOWNLOADQUESTIMG = "%s/NewGame/menu/downloadquest";
|
||||||
String IMPORTPICTURE = "%s/NewGame/menu/importPicture";
|
String IMPORTPICTURE = "%s/NewGame/menu/importPicture";
|
||||||
String CARD_SIZES = "%s/NewGame/menu/cardSizes";
|
String CARD_SIZES = "%s/NewGame/menu/cardSizes";
|
||||||
String CARD_STACK = "%s/NewGame/menu/cardStack";
|
String CARD_STACK = "%s/NewGame/menu/cardStack";
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
|
|||||||
// private Action DOWNLOAD_ACTION = new DownloadAction();
|
// private Action DOWNLOAD_ACTION = new DownloadAction();
|
||||||
private final Action DOWNLOAD_ACTION_LQ = new DownloadActionLQ();
|
private final Action DOWNLOAD_ACTION_LQ = new DownloadActionLQ();
|
||||||
private final Action DOWNLOAD_ACTION_SETLQ = new DownloadActionSetLQ();
|
private final Action DOWNLOAD_ACTION_SETLQ = new DownloadActionSetLQ();
|
||||||
|
private final Action DOWNLOAD_ACTION_QUEST = new DownloadActionQuest();
|
||||||
private final Action IMPORT_PICTURE = new ImportPictureAction();
|
private final Action IMPORT_PICTURE = new ImportPictureAction();
|
||||||
private final Action CARD_SIZES_ACTION = new CardSizesAction();
|
private final Action CARD_SIZES_ACTION = new CardSizesAction();
|
||||||
private final Action CARD_STACK_ACTION = new CardStackAction();
|
private final Action CARD_STACK_ACTION = new CardStackAction();
|
||||||
@@ -197,8 +198,8 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
|
|||||||
// LOOK_AND_FEEL_ACTION, DNLD_PRICES_ACTION, DOWNLOAD_ACTION,
|
// LOOK_AND_FEEL_ACTION, DNLD_PRICES_ACTION, DOWNLOAD_ACTION,
|
||||||
// DOWNLOAD_ACTION_LQ, DOWNLOAD_ACTION_SETLQ, IMPORT_PICTURE,
|
// DOWNLOAD_ACTION_LQ, DOWNLOAD_ACTION_SETLQ, IMPORT_PICTURE,
|
||||||
// CARD_SIZES_ACTION,
|
// CARD_SIZES_ACTION,
|
||||||
LOOK_AND_FEEL_ACTION, DNLD_PRICES_ACTION, DOWNLOAD_ACTION_LQ, DOWNLOAD_ACTION_SETLQ, IMPORT_PICTURE,
|
LOOK_AND_FEEL_ACTION, DNLD_PRICES_ACTION, DOWNLOAD_ACTION_LQ, DOWNLOAD_ACTION_SETLQ, DOWNLOAD_ACTION_QUEST,
|
||||||
CARD_SIZES_ACTION, CARD_STACK_ACTION, CARD_STACK_OFFSET_ACTION, BUGZ_REPORTER_ACTION,
|
IMPORT_PICTURE, CARD_SIZES_ACTION, CARD_STACK_ACTION, CARD_STACK_OFFSET_ACTION, BUGZ_REPORTER_ACTION,
|
||||||
ErrorViewer.ALL_THREADS_ACTION, ABOUT_ACTION, EXIT_ACTION };
|
ErrorViewer.ALL_THREADS_ACTION, ABOUT_ACTION, EXIT_ACTION };
|
||||||
JMenu menu = new JMenu(ForgeProps.getLocalized(MENU.TITLE));
|
JMenu menu = new JMenu(ForgeProps.getLocalized(MENU.TITLE));
|
||||||
for (Action a : actions) {
|
for (Action a : actions) {
|
||||||
@@ -1119,6 +1120,29 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author slapshot5
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static class DownloadActionQuest extends AbstractAction {
|
||||||
|
private static final long serialVersionUID = -4439763134551377894L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public DownloadActionQuest() {
|
||||||
|
super(ForgeProps.getLocalized(MENU_BAR.MENU.DOWNLOADQUESTIMG));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final void actionPerformed(final ActionEvent e) {
|
||||||
|
GuiDownloadQuestImages.startDownload(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author dhudson
|
* @author dhudson
|
||||||
|
|||||||
Reference in New Issue
Block a user