Skip to content

Commit

Permalink
Change file format to Mooncat Compressed Image (MCI)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arinerron committed Mar 24, 2017
1 parent 0c02424 commit 82fe0e9
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 5 deletions.
File renamed without changes.
Binary file added res/character_spritesheet.mci
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion res/tileset.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# <char> <imagepath> [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:
Expand Down
4 changes: 3 additions & 1 deletion src/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -881,6 +882,7 @@ class Tile {
}

class Colors {
// all of the colors in the images
public static final int[] colors = new int[] {
0xff747474,
0xff24188c,
Expand Down
6 changes: 3 additions & 3 deletions src/tileeditor/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 82fe0e9

Please sign in to comment.