diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2009-02-14 08:35:07 -0500 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2009-02-14 08:35:07 -0500 |
commit | 6b69a3558d5a7a5ea364a3054ca3494639a62961 (patch) | |
tree | 66d257044b6be326383a98f636052c0f565144c3 /src/com/fourisland/fourpuzzle/gamestate | |
parent | 2817c83dc733fdded75f3121cb694eb5081b4a59 (diff) | |
download | fourpuzzle-6b69a3558d5a7a5ea364a3054ca3494639a62961.tar.gz fourpuzzle-6b69a3558d5a7a5ea364a3054ca3494639a62961.tar.bz2 fourpuzzle-6b69a3558d5a7a5ea364a3054ca3494639a62961.zip |
Engine: Added chipset data to RTP
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate')
-rwxr-xr-x | src/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java index 5ae3fbd..ddf7c94 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java | |||
@@ -8,9 +8,12 @@ package com.fourisland.fourpuzzle.gamestate.mapview; | |||
8 | import com.fourisland.fourpuzzle.Layer; | 8 | import com.fourisland.fourpuzzle.Layer; |
9 | import com.fourisland.fourpuzzle.PuzzleApplication; | 9 | import com.fourisland.fourpuzzle.PuzzleApplication; |
10 | import com.fourisland.fourpuzzle.util.ObjectLoader; | 10 | import com.fourisland.fourpuzzle.util.ObjectLoader; |
11 | import com.fourisland.fourpuzzle.util.ResourceNotFoundException; | ||
11 | import java.awt.image.BufferedImage; | 12 | import java.awt.image.BufferedImage; |
12 | import java.io.File; | 13 | import java.io.File; |
13 | import java.io.IOException; | 14 | import java.io.IOException; |
15 | import java.io.InputStream; | ||
16 | import java.net.URISyntaxException; | ||
14 | import java.net.URL; | 17 | import java.net.URL; |
15 | import java.util.HashMap; | 18 | import java.util.HashMap; |
16 | import java.util.logging.Level; | 19 | import java.util.logging.Level; |
@@ -45,23 +48,31 @@ public class ChipSet { | |||
45 | return chipSetData; | 48 | return chipSetData; |
46 | } | 49 | } |
47 | 50 | ||
48 | public static void initalize() | 51 | public static void initalize(String name) |
49 | { | 52 | { |
50 | ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); | 53 | ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); |
51 | File folder = new File(new File(rm.getResourcesDir()).getParent() + "/gamedata/chipset/"); | 54 | InputStream cs = null; |
52 | URL path = rm.getClassLoader().getResource(folder.toString()); | 55 | |
53 | File[] files = new File(path.getPath().replace("%20", " ")).listFiles(); | 56 | if (rm.getClassLoader().getResource(rm.getResourcesDir() + "chipset/" + name + ".tsx") == null) |
54 | for (File cs : files) | ||
55 | { | 57 | { |
56 | try { | 58 | if (rm.getClassLoader().getResource("com/fourisland/fourpuzzle/resources/chipset/" + name + ".tsx") == null) |
57 | SAXParserFactory.newInstance().newSAXParser().parse(cs, new ChipSetDefaultHandler()); | 59 | { |
58 | } catch (SAXException ex) { | 60 | throw new ResourceNotFoundException("ChipSet", name); |
59 | Logger.getLogger(ChipSet.class.getName()).log(Level.SEVERE, null, ex); | 61 | } else { |
60 | } catch (IOException ex) { | 62 | cs = rm.getClassLoader().getResourceAsStream("com/fourisland/fourpuzzle/resources/chipset/" + name + ".tsx"); |
61 | Logger.getLogger(ChipSet.class.getName()).log(Level.SEVERE, null, ex); | ||
62 | } catch (ParserConfigurationException ex) { | ||
63 | Logger.getLogger(ChipSet.class.getName()).log(Level.SEVERE, null, ex); | ||
64 | } | 63 | } |
64 | } else { | ||
65 | cs = rm.getClassLoader().getResourceAsStream(rm.getResourcesDir() + "chipset/" + name + ".tsx"); | ||
66 | } | ||
67 | |||
68 | try { | ||
69 | SAXParserFactory.newInstance().newSAXParser().parse(cs, new ChipSetDefaultHandler()); | ||
70 | } catch (ParserConfigurationException ex) { | ||
71 | Logger.getLogger(ChipSet.class.getName()).log(Level.SEVERE, null, ex); | ||
72 | } catch (SAXException ex) { | ||
73 | Logger.getLogger(ChipSet.class.getName()).log(Level.SEVERE, null, ex); | ||
74 | } catch (IOException ex) { | ||
75 | Logger.getLogger(ChipSet.class.getName()).log(Level.SEVERE, null, ex); | ||
65 | } | 76 | } |
66 | } | 77 | } |
67 | 78 | ||
@@ -77,6 +88,11 @@ public class ChipSet { | |||
77 | private static HashMap<String, ChipSet> chipSets = new HashMap<String, ChipSet>(); | 88 | private static HashMap<String, ChipSet> chipSets = new HashMap<String, ChipSet>(); |
78 | public static ChipSet getChipSet(String name) | 89 | public static ChipSet getChipSet(String name) |
79 | { | 90 | { |
91 | if (!chipSets.containsKey(name)) | ||
92 | { | ||
93 | initalize(name); | ||
94 | } | ||
95 | |||
80 | return chipSets.get(name); | 96 | return chipSets.get(name); |
81 | } | 97 | } |
82 | 98 | ||