From 68b547a9de60342bb79e0223504ad115bcef90b0 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sun, 8 Feb 2009 20:35:06 -0500 Subject: Added an RTP --- src/com/fourisland/fourpuzzle/Database.java | 2 +- .../fourpuzzle/resources/chipset/Basis.png | Bin 0 -> 34612 bytes .../fourpuzzle/resources/music/GameOver.mid | Bin 0 -> 6859 bytes .../fourpuzzle/resources/music/Opening1.mid | Bin 0 -> 48328 bytes .../fourpuzzle/resources/picture/GameOver.png | Bin 0 -> 27367 bytes .../fourpuzzle/resources/picture/System.png | Bin 0 -> 2075 bytes .../fourpuzzle/resources/picture/Title.png | Bin 0 -> 16801 bytes .../fourpuzzle/resources/sound/Cursor1.wav | Bin 0 -> 678 bytes .../fourisland/fourpuzzle/util/ObjectLoader.java | 49 +++++++++++---------- 9 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 src/com/fourisland/fourpuzzle/resources/chipset/Basis.png create mode 100644 src/com/fourisland/fourpuzzle/resources/music/GameOver.mid create mode 100755 src/com/fourisland/fourpuzzle/resources/music/Opening1.mid create mode 100644 src/com/fourisland/fourpuzzle/resources/picture/GameOver.png create mode 100644 src/com/fourisland/fourpuzzle/resources/picture/System.png create mode 100644 src/com/fourisland/fourpuzzle/resources/picture/Title.png create mode 100644 src/com/fourisland/fourpuzzle/resources/sound/Cursor1.wav diff --git a/src/com/fourisland/fourpuzzle/Database.java b/src/com/fourisland/fourpuzzle/Database.java index b6e97cf..30bc8a3 100755 --- a/src/com/fourisland/fourpuzzle/Database.java +++ b/src/com/fourisland/fourpuzzle/Database.java @@ -66,7 +66,7 @@ public class Database { public static void loadDefaultMusic() { - music.put("Title", "Opening"); + music.put("Title", "Opening1"); music.put("GameOver", "GameOver"); } diff --git a/src/com/fourisland/fourpuzzle/resources/chipset/Basis.png b/src/com/fourisland/fourpuzzle/resources/chipset/Basis.png new file mode 100644 index 0000000..7e71444 Binary files /dev/null and b/src/com/fourisland/fourpuzzle/resources/chipset/Basis.png differ diff --git a/src/com/fourisland/fourpuzzle/resources/music/GameOver.mid b/src/com/fourisland/fourpuzzle/resources/music/GameOver.mid new file mode 100644 index 0000000..8e17673 Binary files /dev/null and b/src/com/fourisland/fourpuzzle/resources/music/GameOver.mid differ diff --git a/src/com/fourisland/fourpuzzle/resources/music/Opening1.mid b/src/com/fourisland/fourpuzzle/resources/music/Opening1.mid new file mode 100755 index 0000000..c723287 Binary files /dev/null and b/src/com/fourisland/fourpuzzle/resources/music/Opening1.mid differ diff --git a/src/com/fourisland/fourpuzzle/resources/picture/GameOver.png b/src/com/fourisland/fourpuzzle/resources/picture/GameOver.png new file mode 100644 index 0000000..8c5d3de Binary files /dev/null and b/src/com/fourisland/fourpuzzle/resources/picture/GameOver.png differ diff --git a/src/com/fourisland/fourpuzzle/resources/picture/System.png b/src/com/fourisland/fourpuzzle/resources/picture/System.png new file mode 100644 index 0000000..d953dd2 Binary files /dev/null and b/src/com/fourisland/fourpuzzle/resources/picture/System.png differ diff --git a/src/com/fourisland/fourpuzzle/resources/picture/Title.png b/src/com/fourisland/fourpuzzle/resources/picture/Title.png new file mode 100644 index 0000000..850ad8d Binary files /dev/null and b/src/com/fourisland/fourpuzzle/resources/picture/Title.png differ diff --git a/src/com/fourisland/fourpuzzle/resources/sound/Cursor1.wav b/src/com/fourisland/fourpuzzle/resources/sound/Cursor1.wav new file mode 100644 index 0000000..c8d4169 Binary files /dev/null and b/src/com/fourisland/fourpuzzle/resources/sound/Cursor1.wav differ diff --git a/src/com/fourisland/fourpuzzle/util/ObjectLoader.java b/src/com/fourisland/fourpuzzle/util/ObjectLoader.java index 7f7128f..2000a1c 100755 --- a/src/com/fourisland/fourpuzzle/util/ObjectLoader.java +++ b/src/com/fourisland/fourpuzzle/util/ObjectLoader.java @@ -8,9 +8,9 @@ package com.fourisland.fourpuzzle.util; import com.fourisland.fourpuzzle.PuzzleApplication; import java.awt.Color; import java.awt.image.BufferedImage; -import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.util.HashMap; import java.util.Map.Entry; import java.util.logging.Level; @@ -56,14 +56,8 @@ public class ObjectLoader { if (!objectCache.containsKey(type + "/" + name)) { ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); - String filename = rm.getResourcesDir() + type.toLowerCase() + "/" + name + ".png"; + String filename = getFilename(type, name, "png"); InputStream str = rm.getClassLoader().getResourceAsStream(filename); - - if (str == null) - { - throw new ResourceNotFoundException(type, name); - } - BufferedImage bImg = null; try { bImg = ImageIO.read(str); @@ -82,14 +76,8 @@ public class ObjectLoader { if (!objectCache.containsKey(type + "/" + name)) { ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); - String filename = rm.getResourcesDir() + type.toLowerCase() + "/" + name + ".png"; + String filename = getFilename(type, name, "png"); InputStream str = rm.getClassLoader().getResourceAsStream(filename); - - if (str == null) - { - throw new ResourceNotFoundException(type, name); - } - BufferedImage bImg = null; try { bImg = ImageIO.read(str); @@ -120,13 +108,8 @@ public class ObjectLoader { if (!objectCache.containsKey("Music/" + name)) { ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); - String filename = rm.getResourcesDir() + "music/" + name + ".mid"; + String filename = getFilename("Music", name, "mid"); InputStream str = rm.getClassLoader().getResourceAsStream(filename); - if (str == null) - { - throw new ResourceNotFoundException("Music", name); - } - Sequence seq = null; try { seq = MidiSystem.getSequence(str); @@ -147,7 +130,7 @@ public class ObjectLoader { if (!objectCache.containsKey("Sound/" + name)) { ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); - String filename = rm.getResourcesDir() + "sound/" + name + ".wav"; + String filename = getFilename("Sound", name, "wav"); InputStream soundFile = rm.getClassLoader().getResourceAsStream(filename); AudioInputStream ais = null; try { @@ -155,7 +138,7 @@ public class ObjectLoader { } catch (UnsupportedAudioFileException ex) { Logger.getLogger(ObjectLoader.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { - throw new ResourceNotFoundException("Sound", name); + Logger.getLogger(ObjectLoader.class.getName()).log(Level.SEVERE, null, ex); } AudioFormat af = ais.getFormat(); @@ -181,4 +164,24 @@ public class ObjectLoader { return (Clip) objectCache.get("Sound/" + name); } + public static String getFilename(String type, String name, String ex) + { + ResourceMap rm = PuzzleApplication.INSTANCE.getContext().getResourceManager().getResourceMap(); + String f = rm.getResourcesDir() + type.toLowerCase() + "/" + name + "." + ex; + URL fu = rm.getClassLoader().getResource(f); + + if (fu == null) + { + f = "com/fourisland/fourpuzzle/resources/" + type.toLowerCase() + "/" + name + "." + ex; + fu = rm.getClassLoader().getResource(f); + + if (fu == null) + { + throw new ResourceNotFoundException(type, name); + } + } + + return f; + } + } -- cgit 1.4.1