From 82fe0e94129e673786535a9b4bb3529f106d0caa Mon Sep 17 00:00:00 2001 From: Arinerron Date: Thu, 23 Mar 2017 22:15:17 -0700 Subject: [PATCH] Change file format to Mooncat Compressed Image (MCI) --- res/{character_spritesheet.dat => .mci} | Bin res/character_spritesheet.mci | Bin 0 -> 314 bytes res/tiles/{dirt.dat => dirt.mci} | Bin res/tiles/{gravel.dat => gravel.mci} | Bin res/tiles/{ice.dat => ice.mci} | 0 res/tiles/{lava.dat => lava.mci} | Bin res/tiles/{null.dat => null.mci} | Bin res/tiles/{water.dat => water.mci} | Bin res/tileset.txt | 2 +- src/game/Game.java | 4 +++- src/tileeditor/Main.java | 6 +++--- 11 files changed, 7 insertions(+), 5 deletions(-) rename res/{character_spritesheet.dat => .mci} (100%) create mode 100644 res/character_spritesheet.mci rename res/tiles/{dirt.dat => dirt.mci} (100%) rename res/tiles/{gravel.dat => gravel.mci} (100%) rename res/tiles/{ice.dat => ice.mci} (100%) rename res/tiles/{lava.dat => lava.mci} (100%) rename res/tiles/{null.dat => null.mci} (100%) rename res/tiles/{water.dat => water.mci} (100%) diff --git a/res/character_spritesheet.dat b/res/.mci similarity index 100% rename from res/character_spritesheet.dat rename to res/.mci diff --git a/res/character_spritesheet.mci b/res/character_spritesheet.mci new file mode 100644 index 0000000000000000000000000000000000000000..6f93cd5d1fa2158fd9fb8ecca3dc8af0c3770e13 GIT binary patch literal 314 zcmV-A0mc4!oaI(Q4#Xe`e8JqC-ueTN{{LkwN>x;#sfXQUNz?L!a~Qv^U4VZc#nK<`#E@e#I!Og90yL65A>eC-1ZWW4KM1&00(bT6wryplRgMf z*IBgbo$%^Um&VUAzy<5$h+_~tb1=5M=x z-1>Zk|GRkMG2&PAqol{lpRA9d*H58?#eXVK$$!=?IEMPhg8!l82lHFyf90RTe>7S0 z->`?%KceU#wts^E)A>67Yw@Z4SL18s$Ib6^{u}gv#D4?+d)bKJX8tzo2Xp<-^GVk4 zIN!AS-}oc@!!Tc8&wrlpD*s#ics~Do|62cA&wp?v$No9~AC3KU{=eGj-`n%Ut [keywords] # # The image path is relative to res/ folder. -# Do not include the file extension (always PNG). +# Do not include the file extension (always MCI). # If image path is null, it won't render. # # The OPTIONAL case-insensitive keywords are: diff --git a/src/game/Game.java b/src/game/Game.java index e662bc9..563f0a2 100644 --- a/src/game/Game.java +++ b/src/game/Game.java @@ -817,7 +817,7 @@ public int charId(boolean down, boolean right, boolean up, boolean left) { // loads a bufferedimage in by filename public BufferedImage getImage(String name) throws Exception { - byte[] imagedata = decompress(Files.readAllBytes(new File("../res/" + name + ".dat").toPath())); + byte[] imagedata = decompress(Files.readAllBytes(new File("../res/" + name + ".mci").toPath())); int xmax = imagedata[0]; int ymax = (imagedata.length - 1) / xmax; BufferedImage b = new BufferedImage(xmax, ymax, BufferedImage.TYPE_INT_ARGB); @@ -830,6 +830,7 @@ public BufferedImage getImage(String name) throws Exception { return b; } + // decompresses the data into a byte array public static byte[] decompress(byte[] data) throws IOException, DataFormatException { Inflater inflater = new Inflater(); inflater.setInput(data); @@ -881,6 +882,7 @@ class Tile { } class Colors { + // all of the colors in the images public static final int[] colors = new int[] { 0xff747474, 0xff24188c, diff --git a/src/tileeditor/Main.java b/src/tileeditor/Main.java index 41d5a2c..40f269b 100644 --- a/src/tileeditor/Main.java +++ b/src/tileeditor/Main.java @@ -94,7 +94,7 @@ public class Main { public static void main(String[] args) { fc.setAcceptAllFileFilterUsed(true); fc.setMultiSelectionEnabled(false); - fc.setFileFilter(new FileNameExtensionFilter(".dat File", "dat")); + fc.setFileFilter(new FileNameExtensionFilter("Mooncat Compressed Image (.mci)", "mci")); refresh(); frame = new JFrame("Tile Editor"); panel1 = new JPanel() { @@ -260,8 +260,8 @@ public static void save() { colormap[0] = (byte)xmax; File f = fc.getSelectedFile(); String filePath = f.getAbsolutePath(); - if(!filePath.endsWith(".dat")) { - f = new File(filePath + ".dat"); + if(!filePath.endsWith(".mci")) { + f = new File(filePath + ".mci"); } Files.write(f.toPath(), compress(colormap)); } catch(Exception e) {