In-Game downloading Part 2:

1) Download Set Pictures will now download token images also
2) removed the old card-pictures-tokens.txt file
This commit is contained in:
slapshot5
2011-10-22 12:51:30 +00:00
parent dd40e886c7
commit 85cbb5317e
5 changed files with 23 additions and 48 deletions

1
.gitattributes vendored
View File

@@ -17,7 +17,6 @@ res/blockdata/boosters.txt -text
res/blockdata/formats.txt -text
res/blockdata/setdata.txt svneol=native#text/plain
res/booster-decks -text
res/card-pictures-token.txt -text
res/cardTemplateScript.py -text svneol=unset#text/x-python
res/cardsfolder/a/abandoned_outpost.txt svneol=native#text/plain
res/cardsfolder/a/abattoir_ghoul.txt -text

View File

@@ -1,17 +0,0 @@
[T]b_0_1_Thrull.jpg http://serv1.tcgimages.eu/img/cards/Duel_Decks_Divine_vs._Demonic/thrull_token_black_01.jpg
[T]b_1_1_faerie_rogue.jpg http://www.magickartenmarkt.de/img/cards/Morningtide/faerie_rogue_token.jpg
[T]b_1_1_rat.jpg http://www.magickartenmarkt.de/img/cards/Shadowmoor/rat_token_black_11.jpg
[T]b_20_20_marit_lage.jpg http://www.magickartenmarkt.de/img/cards/Game_Day_Cards/marit_lage_token.jpg
[T]b_2_2_zombie.jpg http://www.magickartenmarkt.de/img/cards/Shards_of_Alara/zombie_token_black_22.jpg
[T]bg_1_1_worm.jpg http://serv4.tcgimages.eu/img/cards/Eventide/worm_token_black_and_green_11.jpg
[T]c_0_1_eldrazi_spawn.jpg http://www.mtgmintcard.com/images/products/50/MAGIC-THE-GATHERING-EKDRAZI-SPAWN-1A-ROET001A.jpg
[T]c_1_1_shapeshifter.jpg http://www.magickartenmarkt.de/img/cards/Lorwyn/shapeshifter_token.jpg
[T]c_1_1_sliver.jpg http://www.magickartenmarkt.de/img/cards/Player_Rewards_Promos/sliver_token.jpg
[T]c_1_1_spirit.jpg http://serv3.tcgimages.eu/img/cards/Player_Rewards_Promos/spirit_token_white_112.jpg
[T]c_1_1_wasp.jpg http://www.magickartenmarkt.de/img/cards/Tenth_Edition/wasp_token.jpg
[T]c_3_4_gargoyle.jpg http://www.mtgmintcard.com/images/products/458/MAGIC-THE-GATHERING-GARGOYLE-TOKEN-M10C8.jpg
[T]c_5_5_tuktuk_the_returned.jpg http://www.mtgmintcard.com/images/products/89/MAGIC-THE-GATHERING-TUKTUK-THE-RETURNED-TOKEN-ROET005.jpg
[T]g_0_1_plant.jpg http://www.mtgmintcard.com/images/products/174/MAGIC-THE-GATHERING-PLANT-TOKEN-WWKC065.jpg
[T]g_1_1_elf_warrior.jpg http://www.magickartenmarkt.de/img/cards/Lorwyn/elf_warrior_token_green_11.jpg
[T]g_1_1_insect.jpg http://www.mtgmintcard.com/images/products/413/MAGIC-THE-GATHERING-INSECT-TOKEN-M10C6.jpg
[T]g_1_1_saproling.jpg http://www.magickartenmarkt.de/img/cards/Shards_of_Alara/saproling_token_green_11.jpg

View File

@@ -13,7 +13,6 @@ booster-decks--file=booster-deck
decks-dir--file=decks
card-pictures--file=card-pictures.txt
card-pictures_token_lq--file=card-pictures-token.txt
token-images--file=token-images.txt
card-pictures_a--file=pics_link/card-pictures_a.txt
card-pictures_b--file=pics_link/card-pictures_b.txt

View File

@@ -26,7 +26,7 @@ import java.net.Proxy;
import java.net.URL;
import java.util.ArrayList;
import java.util.Random;
//import java.util.StringTokenizer;
import java.util.StringTokenizer;
import static java.lang.Integer.parseInt;
import static javax.swing.JOptionPane.DEFAULT_OPTION;
@@ -123,14 +123,6 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
//Proxy config
p0.add(addr);
p0.add(port);
// JTextField[] tfs = {addr, port};
// String[] labels = {"Address", "Port"};
// for(int i = 0; i < labels.length; i++) {
// JPanel p1 = new JPanel(new BorderLayout());
// p0.add(p1);
//// p1.add(new JLabel(labels[i]), WEST);
// p1.add(tfs[i]);
// }
//Start
final JButton b = new JButton(ForgeProps.getLocalized(BUTTONS.START));
@@ -141,16 +133,13 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
b.setEnabled(false);
}
});
// p0.add(b);
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);
@@ -230,8 +219,6 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
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);
}
}
@@ -273,6 +260,10 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
BufferedOutputStream out;
File base = ForgeProps.getFile(IMAGE_BASE);
File tokenBase = ForgeProps.getFile(IMAGE_TOKEN);
if (!tokenBase.exists()) {
tokenBase.mkdirs();
}
Random r = MyRandom.random;
@@ -283,7 +274,6 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
} catch (Exception ex) {
ErrorViewer.showError(ex, ForgeProps.getLocalized(ERRORS.PROXY_CONNECT), addr.getText(),
port.getText());
// throw new RuntimeException("Gui_DownloadPictures : error 1 - " +ex);
return;
}
@@ -295,6 +285,7 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
try {
String url = cards[card].url;
String cName;
if (cards[card].name.substring(0, 3).equals("[T]")) {
base = ForgeProps.getFile(IMAGE_TOKEN);
cName = cards[card].name.substring(3, cards[card].name.length());
@@ -344,7 +335,6 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
}
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());
@@ -390,11 +380,10 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
* @return an array of {@link forge.Gui_DownloadSetPictures_LQ.mCard} objects.
*/
private static mCard[] getNeededCards() {
//read all card names and urls
//mCard[] cardPlay = readFile(CARD_PICTURES);
//mCard[] cardTokenLQ = readFile(CARD_PICTURES_TOKEN_LQ);
//read token names and urls
mCard[] cardTokenLQ = readFile(TOKEN_IMAGES);
ArrayList<mCard> CList = new ArrayList<mCard>();
ArrayList<mCard> cList = new ArrayList<mCard>();
//File imgBase = ForgeProps.getFile(NewConstants.IMAGE_BASE);
String URLBase = "http://cardforge.org/fpics/";
@@ -413,25 +402,32 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
int artsCnt = c.getCard().getSetInfo(SC3).getCopiesCount();
String fn = CardUtil.buildIdealFilename(c.getName(), c.getArtIndex(), artsCnt);
//System.out.println(fn);
CList.add(new mCard(SC3 + "/" + fn, URLBase + SC2 + "/" + Base64Coder.encodeString(fn, true), SC3));
cList.add(new mCard(SC3 + "/" + fn, URLBase + SC2 + "/" + Base64Coder.encodeString(fn, true), SC3));
}
}
File file;
File base = ForgeProps.getFile(IMAGE_TOKEN);
for (int i = 0; i < cardTokenLQ.length; i++) {
file = new File(base, cardTokenLQ[i].name.substring(3, cardTokenLQ[i].name.length()));
if (!file.exists()) cList.add(cardTokenLQ[i]);
}
//return all card names and urls that are needed
mCard[] out = new mCard[CList.size()];
CList.toArray(out);
mCard[] out = new mCard[cList.size()];
cList.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 ABC) {
try {
FileReader zrc = new FileReader(ForgeProps.getFile(ABC));
@@ -441,7 +437,7 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
StringTokenizer tok;
line = in.readLine();
while (line != null && (!line.equals(""))) {
while (line != null && (!line.equals("")) && !line.startsWith("#")) {
tok = new StringTokenizer(line);
list.add(new mCard(tok.nextToken(), tok.nextToken(), ""));
@@ -457,7 +453,7 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
throw new RuntimeException("Gui_DownloadPictures : readFile() error");
}
}//readFile()
*/
private class ProxyHandler implements ChangeListener {
private int type;

View File

@@ -32,8 +32,6 @@ public interface NewConstants {
String TOKENS = "tokens";
/** Constant <code>CARD_PICTURES="card-pictures"</code>. */
String CARD_PICTURES = "card-pictures";
/** Constant <code>CARD_PICTURES_TOKEN_LQ="card-pictures_token_lq"</code>. */
String CARD_PICTURES_TOKEN_LQ = "card-pictures_token_lq";
/** Constant <code>CARD_PICTURES_A="card-pictures_a"</code>. */
String CARD_PICTURES_A = "card-pictures_a";
/** Constant <code>CARD_PICTURES_B="card-pictures_b"</code>. */