summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-02-14 08:35:07 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-02-14 08:35:07 -0500
commit6b69a3558d5a7a5ea364a3054ca3494639a62961 (patch)
tree66d257044b6be326383a98f636052c0f565144c3 /src/com/fourisland/fourpuzzle/gamestate
parent2817c83dc733fdded75f3121cb694eb5081b4a59 (diff)
downloadfourpuzzle-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-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/ChipSet.java42
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;
8import com.fourisland.fourpuzzle.Layer; 8import com.fourisland.fourpuzzle.Layer;
9import com.fourisland.fourpuzzle.PuzzleApplication; 9import com.fourisland.fourpuzzle.PuzzleApplication;
10import com.fourisland.fourpuzzle.util.ObjectLoader; 10import com.fourisland.fourpuzzle.util.ObjectLoader;
11import com.fourisland.fourpuzzle.util.ResourceNotFoundException;
11import java.awt.image.BufferedImage; 12import java.awt.image.BufferedImage;
12import java.io.File; 13import java.io.File;
13import java.io.IOException; 14import java.io.IOException;
15import java.io.InputStream;
16import java.net.URISyntaxException;
14import java.net.URL; 17import java.net.URL;
15import java.util.HashMap; 18import java.util.HashMap;
16import java.util.logging.Level; 19import 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