diff --git a/.idea/libraries/KotlinJavaRuntime.xml b/.idea/libraries/KotlinJavaRuntime.xml deleted file mode 100644 index b0b18f4e3..000000000 --- a/.idea/libraries/KotlinJavaRuntime.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml index 147d598bf..544fa9b7c 100644 --- a/.idea/libraries/lib.xml +++ b/.idea/libraries/lib.xml @@ -1,11 +1,23 @@ - + + + + + + + + + + + + + + - @@ -21,10 +33,5 @@ - - - - - \ No newline at end of file diff --git a/Terrarum_renewed.iml b/Terrarum_renewed.iml index 0069b3d80..35a74489f 100644 --- a/Terrarum_renewed.iml +++ b/Terrarum_renewed.iml @@ -9,6 +9,5 @@ - \ No newline at end of file diff --git a/res/batchtest.txt b/res/batchtest.txt index 126f6c3e7..995dc3d1a 100644 --- a/res/batchtest.txt +++ b/res/batchtest.txt @@ -1,4 +1,5 @@ -echo "Hello, world!" -echo "This is a batch test." +echo "Hello, world! This is a batch test." +echo "Will add actorvalue 'batch = true' to player" setav batch true +echo "Checking if command did something." getav batch \ No newline at end of file diff --git a/res/graphics/fonts/han_johab.png b/res/graphics/fonts/han_johab.png index c4024ee27..93eff33c4 100644 Binary files a/res/graphics/fonts/han_johab.png and b/res/graphics/fonts/han_johab.png differ diff --git a/res/graphics/gui/message_twoline_black_body.png b/res/graphics/gui/message_twoline_black_body.png index 67c251fdf..76ddb9d6a 100644 Binary files a/res/graphics/gui/message_twoline_black_body.png and b/res/graphics/gui/message_twoline_black_body.png differ diff --git a/res/graphics/gui/message_twoline_black_left.png b/res/graphics/gui/message_twoline_black_left.png index f2a93064b..3a4e0d802 100644 Binary files a/res/graphics/gui/message_twoline_black_left.png and b/res/graphics/gui/message_twoline_black_left.png differ diff --git a/res/graphics/gui/message_twoline_black_right.png b/res/graphics/gui/message_twoline_black_right.png index 47bb835fd..860d8fa42 100644 Binary files a/res/graphics/gui/message_twoline_black_right.png and b/res/graphics/gui/message_twoline_black_right.png differ diff --git a/res/graphics/health_bar_colouring_4096.png b/res/graphics/health_bar_colouring_4096.png index edb8afebb..c022e19fb 100644 Binary files a/res/graphics/health_bar_colouring_4096.png and b/res/graphics/health_bar_colouring_4096.png differ diff --git a/res/graphics/sky_colour.png b/res/graphics/sky_colour.png index 906d5de7b..ebacbd067 100644 Binary files a/res/graphics/sky_colour.png and b/res/graphics/sky_colour.png differ diff --git a/res/graphics/sprites/test_player.png b/res/graphics/sprites/test_player.png index e77017d25..91a3a2905 100644 Binary files a/res/graphics/sprites/test_player.png and b/res/graphics/sprites/test_player.png differ diff --git a/res/graphics/terrain/terrain.png b/res/graphics/terrain/terrain.png index 7a09cbfa5..d4a10ca52 100644 Binary files a/res/graphics/terrain/terrain.png and b/res/graphics/terrain/terrain.png differ diff --git a/src/com/Torvald/CSVFetcher.java b/src/com/Torvald/CSVFetcher.java deleted file mode 100644 index 31467e9da..000000000 --- a/src/com/Torvald/CSVFetcher.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.Torvald; - -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVParser; -import org.apache.commons.csv.CSVRecord; - -import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.util.List; - -/** - * Created by minjaesong on 16-02-16. - */ -public class CSVFetcher { - - private static StringBuffer csvString; - - public static List readCSV(String csvFilePath) throws IOException { - csvString = new StringBuffer(); // reset buffer every time it called - readCsvFileAsString(csvFilePath); - - CSVParser csvParser = CSVParser.parse(csvString.toString() - , CSVFormat.DEFAULT.withIgnoreSurroundingSpaces().withHeader() - .withIgnoreEmptyLines().withDelimiter(';') - .withCommentMarker('#').withNullString("N/A") - .withRecordSeparator('\n') - ); - - List csvRecordList = csvParser.getRecords(); - csvParser.close(); - - return csvRecordList; - } - - private static void readCsvFileAsString(String path) throws IOException { - Files.lines( - FileSystems.getDefault().getPath(path) - ).forEach(s -> csvString.append(s += "\n")); - } -} diff --git a/src/com/Torvald/CSVFetcher.kt b/src/com/Torvald/CSVFetcher.kt new file mode 100644 index 000000000..68ac10ae8 --- /dev/null +++ b/src/com/Torvald/CSVFetcher.kt @@ -0,0 +1,48 @@ +package com.Torvald + +import org.apache.commons.csv.CSVFormat +import org.apache.commons.csv.CSVParser +import org.apache.commons.csv.CSVRecord + +import java.io.IOException +import java.nio.file.FileSystems +import java.nio.file.Files + +/** + * Created by minjaesong on 16-02-16. + */ +object CSVFetcher { + + private var csvString: StringBuffer? = null + + @Throws(IOException::class) + fun readCSV(csvFilePath: String): List { + csvString = StringBuffer() // reset buffer every time it called + readCSVasString(csvFilePath) + + val csvParser = CSVParser.parse( + csvString!!.toString(), + CSVFormat.DEFAULT.withIgnoreSurroundingSpaces() + .withHeader() + .withIgnoreEmptyLines() + .withDelimiter(';') + .withCommentMarker('#') + .withNullString("N/A") + .withRecordSeparator('\n') + ) + + val csvRecordList = csvParser.records + csvParser.close() + + return csvRecordList + } + + @Throws(IOException::class) + fun readCSVasString(path: String): String { + csvString = StringBuffer() + Files.lines(FileSystems.getDefault().getPath(path)).forEach( + { s -> csvString!!.append("$s\n") } + ) + return csvString!!.toString() + } +} diff --git a/src/com/Torvald/ColourUtil/Col216.java b/src/com/Torvald/ColourUtil/Col216.java deleted file mode 100644 index 851c19ebb..000000000 --- a/src/com/Torvald/ColourUtil/Col216.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.Torvald.ColourUtil; - -import org.newdawn.slick.Color; - -/** - * Created by minjaesong on 16-02-11. - */ -public class Col216 implements LimitedColours { - - private byte data; - private static transient final int[] LOOKUP = {0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF}; - - public static final int MUL = 6; - public static final int MUL_2 = MUL * MUL; - public static final int MAX_STEP = MUL - 1; - public static final int COLOUR_DOMAIN_SIZE = MUL_2 * MUL; - - /** - * - * @param data - */ - public Col216(byte data) { - create(data); - } - - /** - * - * @param r 0-5 - * @param g 0-5 - * @param b 0-5 - */ - public Col216(int r, int g, int b) { - create(r, g, b); - } - - @Override - public Color createSlickColor(int raw) { - assertRaw(raw); - int r = raw / MUL_2; - int g = (raw % MUL_2) / MUL; - int b = raw % MUL; - - return createSlickColor(r, g, b); - } - - @Override - public Color createSlickColor(int r, int g, int b) { - assertRGB(r, g, b); - return new Color(LOOKUP[r], LOOKUP[g], LOOKUP[b]); - } - - @Override - public void create(int raw) { - assertRaw(raw); - data = (byte) raw; - } - - @Override - public void create(int r, int g, int b) { - assertRGB(r, g, b); - data = (byte) (MUL_2 * r + MUL * g + b); - } - - public byte getRaw() { return data; } - - private void assertRaw(int i) { - if (i >= COLOUR_DOMAIN_SIZE || i < 0) { - System.out.println("i: " + String.valueOf(i)); - throw new IllegalArgumentException(); - } - } - - private void assertRGB(int r, int g, int b) { - if (r > MAX_STEP || g > MAX_STEP || b > MAX_STEP || r < 0 || g < 0 || b < 0) { - System.out.println("r: " + String.valueOf(r)); - System.out.println("g: " + String.valueOf(g)); - System.out.println("b: " + String.valueOf(b)); - throw new IllegalArgumentException(); - } - } -} diff --git a/src/com/Torvald/ColourUtil/Col216.kt b/src/com/Torvald/ColourUtil/Col216.kt new file mode 100644 index 000000000..870092833 --- /dev/null +++ b/src/com/Torvald/ColourUtil/Col216.kt @@ -0,0 +1,82 @@ +package com.Torvald.ColourUtil + +import org.newdawn.slick.Color + +/** + * 6-Step RGB with builtin utils. + * Created by minjaesong on 16-02-11. + */ +class Col216 : LimitedColours { + + var raw: Byte = 0 + private set + + /** + + * @param data + */ + constructor(data: Byte) { + create(data.toInt()) + } + + /** + + * @param r 0-5 + * * + * @param g 0-5 + * * + * @param b 0-5 + */ + constructor(r: Int, g: Int, b: Int) { + create(r, g, b) + } + + override fun createSlickColor(raw: Int): Color { + assertRaw(raw) + val r = raw / MUL_2 + val g = raw % MUL_2 / MUL + val b = raw % MUL + + return createSlickColor(r, g, b) + } + + override fun createSlickColor(r: Int, g: Int, b: Int): Color { + assertRGB(r, g, b) + return Color(LOOKUP[r], LOOKUP[g], LOOKUP[b]) + } + + override fun create(raw: Int) { + assertRaw(raw) + this.raw = raw.toByte() + } + + override fun create(r: Int, g: Int, b: Int) { + assertRGB(r, g, b) + raw = (MUL_2 * r + MUL * g + b).toByte() + } + + private fun assertRaw(i: Int) { + if (i >= COLOUR_DOMAIN_SIZE || i < 0) { + println("i: " + i.toString()) + throw IllegalArgumentException() + } + } + + private fun assertRGB(r: Int, g: Int, b: Int) { + if (r !in 0..MAX_STEP || g !in 0..MAX_STEP || b !in 0..MAX_STEP) { + println("r: " + r.toString()) + println("g: " + g.toString()) + println("b: " + b.toString()) + throw IllegalArgumentException() + } + } + + companion object { + @Transient private val LOOKUP = intArrayOf(0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF) + + const val MUL = 6 + const val MUL_2 = MUL * MUL + const val MAX_STEP = MUL - 1 + const val COLOUR_DOMAIN_SIZE = MUL_2 * MUL + } +} diff --git a/src/com/Torvald/ColourUtil/Col40.java b/src/com/Torvald/ColourUtil/Col40.java deleted file mode 100644 index 51c45e818..000000000 --- a/src/com/Torvald/ColourUtil/Col40.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.Torvald.ColourUtil; - -import org.newdawn.slick.Color; - -/** - * Created by minjaesong on 16-02-20. - */ -public class Col40 implements LimitedColours { - - private char data; - private static transient final int[] LOOKUP = {0,7,13,20,26,33,39,46,52,59,65,72,78,85,92,98,105,111,118,124 - ,131,137,144,150,157,163,170,177,183,190,196,203,209,216,222,229,235,242,248,255}; - - public static final int MUL = 40; - public static final int MUL_2 = MUL * MUL; - public static final int MAX_STEP = MUL - 1; - public static final int COLOUR_DOMAIN_SIZE = MUL_2 * MUL; - - @Override - public Color createSlickColor(int raw) { - assertRaw(raw); - int r = raw / MUL_2; - int g = (raw % MUL_2) / MUL; - int b = raw % MUL; - - return createSlickColor(r, g, b); - } - - @Override - public Color createSlickColor(int r, int g, int b) { - assertRGB(r, g, b); - return new Color((LOOKUP[r] << 16) | (LOOKUP[g] << 8) | LOOKUP[b]); - } - - @Override - public void create(int raw) { - assertRaw(raw); - data = (char) raw; - } - - @Override - public void create(int r, int g, int b) { - assertRGB(r, g, b); - data = (char) (MUL_2 * r + MUL * g + b); - } - - public char getRaw() { return data; } - - private void assertRaw(int i) { - if (i >= COLOUR_DOMAIN_SIZE || i < 0) { - System.out.println("i: " + String.valueOf(i)); - throw new IllegalArgumentException(); - } - } - - private void assertRGB(int r, int g, int b) { - if (r > MAX_STEP || g > MAX_STEP || b > MAX_STEP || r < 0 || g < 0 || b < 0) { - System.out.println("r: " + String.valueOf(r)); - System.out.println("g: " + String.valueOf(g)); - System.out.println("b: " + String.valueOf(b)); - throw new IllegalArgumentException(); - } - } -} diff --git a/src/com/Torvald/ColourUtil/Col40.kt b/src/com/Torvald/ColourUtil/Col40.kt new file mode 100644 index 000000000..3c2da2897 --- /dev/null +++ b/src/com/Torvald/ColourUtil/Col40.kt @@ -0,0 +1,72 @@ +package com.Torvald.ColourUtil + +import org.newdawn.slick.Color + +/** + * 40-Step RGB with builtin utils. + * Created by minjaesong on 16-02-20. + */ +class Col40 : LimitedColours { + + var raw: Char = ' ' + private set + + override fun createSlickColor(raw: Int): Color { + assertRaw(raw) + val r = raw / MUL_2 + val g = raw % MUL_2 / MUL + val b = raw % MUL + + return createSlickColor(r, g, b) + } + + override fun createSlickColor(r: Int, g: Int, b: Int): Color { + assertRGB(r, g, b) + return Color(LOOKUP[r] shl 16 or (LOOKUP[g] shl 8) or LOOKUP[b]) + } + + override fun create(raw: Int) { + assertRaw(raw) + this.raw = raw.toChar() + } + + override fun create(r: Int, g: Int, b: Int) { + assertRGB(r, g, b) + raw = (MUL_2 * r + MUL * g + b).toChar() + } + + constructor() { + } + + constructor(c: Color) { + create( + Math.round(c.r * (MUL - 1)), + Math.round(c.g * (MUL - 1)), + Math.round(c.b * (MUL - 1))) + } + + private fun assertRaw(i: Int) { + if (i >= COLOUR_DOMAIN_SIZE || i < 0) { + println("i: " + i.toString()) + throw IllegalArgumentException() + } + } + + private fun assertRGB(r: Int, g: Int, b: Int) { + if (r !in 0..MAX_STEP || g !in 0..MAX_STEP || b !in 0..MAX_STEP) { + println("r: " + r.toString()) + println("g: " + g.toString()) + println("b: " + b.toString()) + throw IllegalArgumentException() + } + } + + companion object { + @Transient private val LOOKUP = intArrayOf(0, 7, 13, 20, 26, 33, 39, 46, 52, 59, 65, 72, 78, 85, 92, 98, 105, 111, 118, 124, 131, 137, 144, 150, 157, 163, 170, 177, 183, 190, 196, 203, 209, 216, 222, 229, 235, 242, 248, 255) + + const val MUL = 40 + const val MUL_2 = MUL * MUL + const val MAX_STEP = MUL - 1 + const val COLOUR_DOMAIN_SIZE = MUL_2 * MUL + } +} diff --git a/src/com/Torvald/ColourUtil/Col4096.java b/src/com/Torvald/ColourUtil/Col4096.java deleted file mode 100644 index 0fa482df7..000000000 --- a/src/com/Torvald/ColourUtil/Col4096.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.Torvald.ColourUtil; - -import org.newdawn.slick.Color; - -/** - * Created by minjaesong on 16-01-23. - * - * 12-bit RGB - */ -public class Col4096 implements LimitedColours { - - private short data; - - /** - * - * @param data - */ - public Col4096(int data) { - create(data); - } - - /** - * - * @param r 0-15 - * @param g 0-15 - * @param b 0-15 - */ - public Col4096(int r, int g, int b) { - create(r, g, b); - } - - /** - * Create Col4096 colour and convert it to Slick Color - * @param i - * @return - */ - public Color createSlickColor(int i) { - assertRaw(i); - - int a, r, g, b; - - r = (i & 0xF00) >> 8; - g = (i & 0x0F0) >> 4; - b = i & 0x00F; - - if (i > 0xFFF) { - a = (i & 0xF000) >> 12; - - return new Color( - (r << 4) | r - , (g << 4) | g - , (b << 4) | b - , (a << 4) | a - ); - } - else { - return new Color( - (r << 4) | r - , (g << 4) | g - , (b << 4) | b - ); - } - } - - @Override - public Color createSlickColor(int r, int g, int b) { - assertARGB(0, r, g, b); - return createSlickColor(r << 8 | g << 4 | b); - } - - public Color createSlickColor(int a, int r, int g, int b) { - assertARGB(a, r, g, b); - return createSlickColor(a << 12 |r << 8 | g << 4 | b); - } - - @Override - public void create(int raw) { - assertRaw(raw); - data = (short) (raw & 0xFFFF); - } - - @Override - public void create(int r, int g, int b) { - assertARGB(0, r, g, b); - data = (short) (r << 8 | g << 4 | b); - } - - public void create(int a, int r, int g, int b) { - assertARGB(a, r, g, b); - data = (short) (a << 12 | r << 8 | g << 4 | b); - } - - /** - * Convert to 3 byte values, for raster imaging. - * @return byte[RR, GG, BB] e.g. 0x4B3 -> 0x44, 0xBB, 0x33 - */ - public byte[] toByteArray() { - byte[] ret = new byte[3]; - int r = (data & 0xF00) >> 8; - int g = (data & 0x0F0) >> 4; - int b = data & 0x00F; - - ret[0] = (byte) ((r << 4) | r); - ret[1] = (byte) ((g << 4) | g); - ret[2] = (byte) ((b << 4) | b); - - return ret; - } - - /** - * Retrieve raw ARGB value - * @return 0xARGB - */ - public short getRaw() { - return data; - } - - private void assertRaw(int i) { - if (i > 0xFFFF || i < 0) { - System.out.println("i: " + String.valueOf(i)); - throw new IllegalArgumentException(); - } - } - - private void assertARGB(int a, int r, int g, int b) { - if (a > 16 || r > 16 || g > 16 || b > 16 || r < 0 || g < 0 || b < 0 || a < 0) { - System.out.println("a: " + String.valueOf(a)); - System.out.println("r: " + String.valueOf(r)); - System.out.println("g: " + String.valueOf(g)); - System.out.println("b: " + String.valueOf(b)); - throw new IllegalArgumentException(); - } - } - -} diff --git a/src/com/Torvald/ColourUtil/Col4096.kt b/src/com/Torvald/ColourUtil/Col4096.kt new file mode 100644 index 000000000..2199f430d --- /dev/null +++ b/src/com/Torvald/ColourUtil/Col4096.kt @@ -0,0 +1,127 @@ +package com.Torvald.ColourUtil + +import org.newdawn.slick.Color + +/** + * 12-bit (16-step) RGB with builtin utils. + * Created by minjaesong on 16-01-23. + */ +class Col4096 : LimitedColours { + + /** + * Retrieve raw ARGB value + * @return 0xARGB + */ + var raw: Short = 0 + private set + + /** + + * @param data + */ + constructor(data: Int) { + create(data) + } + + /** + + * @param r 0-15 + * * + * @param g 0-15 + * * + * @param b 0-15 + */ + constructor(r: Int, g: Int, b: Int) { + create(r, g, b) + } + + /** + * Create Col4096 colour and convert it to Slick Color + * @param i + * * + * @return + */ + override fun createSlickColor(raw: Int): Color { + assertRaw(raw) + + val a: Int + val r: Int + val g: Int + val b: Int + + r = raw and 0xF00 shr 8 + g = raw and 0x0F0 shr 4 + b = raw and 0x00F + + if (raw > 0xFFF) { + a = raw and 0xF000 shr 12 + + return Color( + r shl 4 or r, g shl 4 or g, b shl 4 or b, a shl 4 or a) + } + else { + return Color( + r shl 4 or r, g shl 4 or g, b shl 4 or b) + } + } + + override fun createSlickColor(r: Int, g: Int, b: Int): Color { + assertARGB(0, r, g, b) + return createSlickColor(r shl 8 or g shl 4 or b) + } + + fun createSlickColor(a: Int, r: Int, g: Int, b: Int): Color { + assertARGB(a, r, g, b) + return createSlickColor(a shl 12 or r shl 8 or g shl 4 or b) + } + + override fun create(raw: Int) { + assertRaw(raw) + this.raw = (raw and 0xFFFF).toShort() + } + + override fun create(r: Int, g: Int, b: Int) { + assertARGB(0, r, g, b) + raw = (r shl 8 or g shl 4 or b).toShort() + } + + fun create(a: Int, r: Int, g: Int, b: Int) { + assertARGB(a, r, g, b) + raw = (a shl 12 or r shl 8 or g shl 4 or b).toShort() + } + + /** + * Convert to 3 byte values, for raster imaging. + * @return byte[RR, GG, BB] e.g. 0x4B3 -> 0x44, 0xBB, 0x33 + */ + fun toByteArray(): ByteArray { + val ret = ByteArray(3) + val r = (raw.toInt() and 0xF00) shr 8 + val g = (raw.toInt() and 0x0F0) shr 4 + val b = (raw.toInt() and 0x00F) + + ret[0] = (r shl 4 or r).toByte() + ret[1] = (g shl 4 or g).toByte() + ret[2] = (b shl 4 or b).toByte() + + return ret + } + + private fun assertRaw(i: Int) { + if (i > 0xFFFF || i < 0) { + println("i: " + i.toString()) + throw IllegalArgumentException() + } + } + + private fun assertARGB(a: Int, r: Int, g: Int, b: Int) { + if (a !in 0..16 || r !in 0..16 || g !in 0..16 || b !in 0..16) { + println("a: " + a.toString()) + println("r: " + r.toString()) + println("g: " + g.toString()) + println("b: " + b.toString()) + throw IllegalArgumentException() + } + } + +} diff --git a/src/com/Torvald/ColourUtil/HSV.java b/src/com/Torvald/ColourUtil/HSV.java deleted file mode 100644 index c4cc944eb..000000000 --- a/src/com/Torvald/ColourUtil/HSV.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.Torvald.ColourUtil; - -/** - * Created by minjaesong on 16-03-10. - */ -public class HSV { - private float H; - private float S; - private float V; - - public HSV() { - } - - /** - * - * @param h 0-359 - * @param s 0-1 - * @param v 0-1 - */ - public HSV(float h, float s, float v) { - H = h; - S = s; - V = v; - } - - public float getH() { - return H; - } - - public void setH(float h) { - H = h; - } - - public float getS() { - return S; - } - - public void setS(float s) { - S = s; - } - - public float getV() { - return V; - } - - public void setV(float v) { - V = v; - } -} diff --git a/src/com/Torvald/ColourUtil/HSV.kt b/src/com/Torvald/ColourUtil/HSV.kt new file mode 100644 index 000000000..4cf940a74 --- /dev/null +++ b/src/com/Torvald/ColourUtil/HSV.kt @@ -0,0 +1,15 @@ +package com.Torvald.ColourUtil + +/** + * Created by minjaesong on 16-03-10. + */ +/** + * @param h : Hue 0-359 + * @param s : Saturation 0-1 + * @param v : Value (brightness in Adobe Photoshop(TM)) 0-1 + */ +data class HSV( + var h: Float, + var s: Float, + var v: Float +) diff --git a/src/com/Torvald/ColourUtil/HSVUtil.java b/src/com/Torvald/ColourUtil/HSVUtil.java deleted file mode 100644 index 9a79a1108..000000000 --- a/src/com/Torvald/ColourUtil/HSVUtil.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.Torvald.ColourUtil; - -import com.jme3.math.FastMath; -import org.newdawn.slick.Color; - -/** - * Created by minjaesong on 16-01-16. - */ -public class HSVUtil { - - /** - * Convert HSV parameters to RGB color. - * @param H 0-359 Hue - * @param S 0-1 Saturation - * @param V 0-1 Value - * @return org.newdawn.slick.Color - * @link http://www.rapidtables.com/convert/color/hsv-to-rgb.htm - */ - public static Color toRGB(float H, float S, float V) { - H %= 360; - - float C = V * S; - float X = C * (1 - FastMath.abs( - (H / 60f) % 2 - 1 - )); - float m = V - C; - - float R_prime = Float.NaN; - float G_prime = Float.NaN; - float B_prime = Float.NaN; - - if (H < 60) { - R_prime = C; - G_prime = X; - B_prime = 0; - } - else if (H < 120) { - R_prime = X; - G_prime = C; - B_prime = 0; - } - else if (H < 180) { - R_prime = 0; - G_prime = C; - B_prime = X; - } - else if (H < 240) { - R_prime = 0; - G_prime = X; - B_prime = C; - } - else if (H < 300) { - R_prime = X; - G_prime = 0; - B_prime = C; - } - else if (H < 360) { - R_prime = C; - G_prime = 0; - B_prime = X; - } - - return new Color( - (R_prime + m) - , (G_prime + m) - , (B_prime + m) - ); - } - - public static Color toRGB(HSV hsv) { - return toRGB(hsv.getH(), hsv.getS(), hsv.getV()); - } - - public static HSV fromRGB(Color color) { - float r = color.r; - float g = color.g; - float b = color.b; - - float rgbMin = FastMath.min(r, g, b); - float rgbMax = FastMath.max(r, g, b); - - float h; - float s; - float v = rgbMax; - - float delta = rgbMax - rgbMin; - - if (rgbMax != 0) - s = delta / rgbMax; - else { - h = 0; - s = 0; - return new HSV(h, s, v); - } - - if (r == rgbMax) - h = (g - b) / delta; - else if (g == rgbMax) - h = 2 + (b - r) / delta; - else - h = 4 + (r - g) / delta; - - h *= 60; - if (h < 0) h += 360; - - return new HSV(h, s, v); - } - -} diff --git a/src/com/Torvald/ColourUtil/HSVUtil.kt b/src/com/Torvald/ColourUtil/HSVUtil.kt new file mode 100644 index 000000000..fd2268ae5 --- /dev/null +++ b/src/com/Torvald/ColourUtil/HSVUtil.kt @@ -0,0 +1,110 @@ +package com.Torvald.ColourUtil + +import com.jme3.math.FastMath +import org.newdawn.slick.Color + +/** + * Created by minjaesong on 16-01-16. + */ +object HSVUtil { + + /** + * Convert HSV parameters to RGB color. + * @param H 0-359 Hue + * * + * @param S 0-1 Saturation + * * + * @param V 0-1 Value + * * + * @return org.newdawn.slick.Color + * * + * @link http://www.rapidtables.com/convert/color/hsv-to-rgb.htm + */ + fun toRGB(H: Float, S: Float, V: Float): Color { + var H = H + H %= 360f + + val C = V * S + val X = C * (1 - FastMath.abs( + H / 60f % 2 - 1)) + val m = V - C + + var R_prime = java.lang.Float.NaN + var G_prime = java.lang.Float.NaN + var B_prime = java.lang.Float.NaN + + if (H < 60) { + R_prime = C + G_prime = X + B_prime = 0f + } + else if (H < 120) { + R_prime = X + G_prime = C + B_prime = 0f + } + else if (H < 180) { + R_prime = 0f + G_prime = C + B_prime = X + } + else if (H < 240) { + R_prime = 0f + G_prime = X + B_prime = C + } + else if (H < 300) { + R_prime = X + G_prime = 0f + B_prime = C + } + else if (H < 360) { + R_prime = C + G_prime = 0f + B_prime = X + } + + return Color( + R_prime + m, G_prime + m, B_prime + m) + } + + fun toRGB(hsv: HSV): Color { + return toRGB(hsv.h, hsv.s, hsv.v) + } + + fun fromRGB(color: Color): HSV { + val r = color.r + val g = color.g + val b = color.b + + val rgbMin = FastMath.min(r, g, b) + val rgbMax = FastMath.max(r, g, b) + + var h: Float + val s: Float + val v = rgbMax + + val delta = rgbMax - rgbMin + + if (rgbMax != 0f) + s = delta / rgbMax + else { + h = 0f + s = 0f + return HSV(h, s, v) + } + + if (r == rgbMax) + h = (g - b) / delta + else if (g == rgbMax) + h = 2 + (b - r) / delta + else + h = 4 + (r - g) / delta + + h *= 60f + if (h < 0) h += 360f + + return HSV(h, s, v) + } + +} diff --git a/src/com/Torvald/ColourUtil/LimitedColours.java b/src/com/Torvald/ColourUtil/LimitedColours.java deleted file mode 100644 index 61f4ddd81..000000000 --- a/src/com/Torvald/ColourUtil/LimitedColours.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.Torvald.ColourUtil; - -import org.newdawn.slick.Color; - -/** - * Created by minjaesong on 16-02-11. - */ -public interface LimitedColours { - - - - Color createSlickColor(int raw); - Color createSlickColor(int r, int g, int b); - - void create(int raw); - void create(int r, int g, int b); - -} diff --git a/src/com/Torvald/ColourUtil/LimitedColours.kt b/src/com/Torvald/ColourUtil/LimitedColours.kt new file mode 100644 index 000000000..82cc14fd3 --- /dev/null +++ b/src/com/Torvald/ColourUtil/LimitedColours.kt @@ -0,0 +1,17 @@ +package com.Torvald.ColourUtil + +import org.newdawn.slick.Color + +/** + * Created by minjaesong on 16-02-11. + */ +interface LimitedColours { + + + fun createSlickColor(raw: Int): Color + fun createSlickColor(r: Int, g: Int, b: Int): Color + + fun create(raw: Int) + fun create(r: Int, g: Int, b: Int) + +} diff --git a/src/com/Torvald/ImageFont/GameFontBase.java b/src/com/Torvald/ImageFont/GameFontBase.java deleted file mode 100644 index 3c2e57ceb..000000000 --- a/src/com/Torvald/ImageFont/GameFontBase.java +++ /dev/null @@ -1,621 +0,0 @@ -package com.Torvald.ImageFont; - -import com.Torvald.Terrarum.Terrarum; -import org.lwjgl.opengl.GL11; -import org.newdawn.slick.*; - -import java.util.Arrays; - -/** - * Created by minjaesong on 16-01-27. - */ -public class GameFontBase implements Font { - - static SpriteSheet hangulSheet; - static SpriteSheet asciiSheet; - static SpriteSheet asciiSheetEF; - static SpriteSheet runicSheet; - static SpriteSheet extASheet; - static SpriteSheet extASheetEF; - static SpriteSheet kanaSheet; - static SpriteSheet cjkPunct; - // static SpriteSheet uniHan; - static SpriteSheet cyrilic; - static SpriteSheet cyrilicEF; - static SpriteSheet fullwidthForms; - static SpriteSheet uniPunct; - static SpriteSheet wenQuanYi_1; - static SpriteSheet wenQuanYi_2; - - static final int JUNG_COUNT = 21; - static final int JONG_COUNT = 28; - - static final int W_CJK = 10; - static final int W_UNIHAN = 16; - static final int W_LATIN_WIDE = 9; // width of regular letters, including m - static final int W_LATIN_NARROW = 5; // width of letter f, t, i, l - static final int H = 20; - static final int H_HANGUL = 16; - static final int H_UNIHAN = 16; - static final int H_KANA = 20; - - static final int SHEET_ASCII_EM = 0; - static final int SHEET_ASCII_EF = 1; - static final int SHEET_HANGUL = 2; - static final int SHEET_RUNIC = 3; - static final int SHEET_EXTA_EM = 4; - static final int SHEET_EXTA_EF = 5; - static final int SHEET_KANA = 6; - static final int SHEET_CJK_PUNCT = 7; - static final int SHEET_UNIHAN = 8; - static final int SHEET_CYRILIC_EM = 9; - static final int SHEET_CYRILIC_EF = 10; - static final int SHEET_FW_UNI = 11; - static final int SHEET_UNI_PUNCT = 12; - static final int SHEET_WENQUANYI_1 = 13; - static final int SHEET_WENQUANYI_2 = 14; - - static SpriteSheet[] sheetKey; - static final Character[] asciiEFList = { - ' ','!','"','\'','(',')',',','.',':',';','I','[',']','`','f','i' - ,'j','l','t','{','|','}',0xA1,'Ì','Í','Î','Ï','ì','í','î','ï','·' - }; - - static final Character[] extAEFList = { - 0x12E, 0x12F, 0x130, 0x131, 0x135, 0x13A, 0x13C, 0x142, 0x163, 0x167, 0x17F - }; - - static final Character[] cyrilecEFList = { - 0x406, 0x407, 0x456, 0x457, 0x458 - }; - - /** - * Runic letters list used for game. The set is - * Younger Futhark + Medieval rune 'e' + Punct + Runic Almanac - * - * BEWARE OF SIMILAR-LOOKING RUNES, especially: - * - * * Algiz ᛉ instead of Maðr ᛘ - * - * * Short-Twig Hagall ᚽ instead of Runic Letter E ᛂ - * - * * Runic Letter OE ᚯ instead of Óss ᚬ - * - * Examples: - * ᛭ᛋᛁᚴᚱᛁᚦᛦ᛭ - * ᛭ᛂᛚᛋᛅ᛭ᛏᚱᚢᛏᚾᛁᚾᚴᚢᚾᛅ᛬ᛅᚱᚾᛅᛏᛅᛚᛋ - */ - static final Character[] runicList = { - 'ᚠ','ᚢ','ᚦ','ᚬ','ᚱ','ᚴ','ᚼ','ᚾ','ᛁ','ᛅ','ᛋ','ᛏ','ᛒ','ᛘ','ᛚ','ᛦ' - ,'ᛂ','᛬','᛫','᛭','ᛮ','ᛯ','ᛰ' - }; - - static int interchar = 0; - - - public GameFontBase() throws SlickException { - - } - - private int[] getHan(int hanIndex) { - int han_x = hanIndex % JONG_COUNT; - int han_y = hanIndex / JONG_COUNT; - int[] ret = {han_x, han_y}; - return ret; - } - - private int getHanChosung(int hanIndex) { - return hanIndex / (JUNG_COUNT * JONG_COUNT); - } - - private int getHanJungseong(int hanIndex) { - return hanIndex / (JONG_COUNT) % JUNG_COUNT; - } - - private int getHanJongseong(int hanIndex) { - return hanIndex % JONG_COUNT; - } - - private int getHanChoseongRow(int hanIndex) { - int jungseongIndex = getHanJungseong(hanIndex); - Integer[] jungseongWide = {8, 12, 13, 17, 18, 21}; - Integer[] jungseongComplex = {9, 10, 11, 14, 15, 16, 22}; - int ret; - - if (Arrays.asList(jungseongWide).contains(jungseongIndex)) { - ret = 2; - } - else if (Arrays.asList(jungseongComplex).contains(jungseongIndex)) { - ret = 4; - } - else { - ret = 0; - } - return (getHanJongseong(hanIndex) == 0) ? ret : ret + 1; - } - - private int getHanJungseongRow(int hanIndex) { - return (getHanJongseong(hanIndex) == 0) ? 6 : 7; - } - - private int getHanJongseongRow() { - return 8; - } - - private boolean isAsciiEF(char c) { - return (Arrays.asList(asciiEFList).contains(c)); - } - - private boolean isExtAEF(char c) { - return (Arrays.asList(extAEFList).contains(c)); - } - - private boolean isHangul(char c) { - return (c >= 0xAC00 && c < 0xD7A4); - } - - private boolean isAscii(char c) { return (c > 0 && c <= 0xFF); } - - private boolean isRunic(char c) { - return (Arrays.asList(runicList).contains(c)); - } - - private boolean isExtA(char c) { - return (c >= 0x100 && c < 0x180); - } - - private boolean isKana(char c) { - return (c >= 0x3040 && c < 0x3100); - } - - private boolean isCJKPunct(char c) { - return (c >= 0x3000 && c < 0x3040); - } - - private boolean isUniHan(char c) { - return (c >= 0x3400 && c < 0xA000); - } - - private boolean isCyrilic(char c) { - return (c >= 0x400 && c < 0x460); - } - - private boolean isCyrilicEF(char c) { - return (Arrays.asList(cyrilecEFList).contains(c)); - } - - private boolean isFullwidthUni(char c) { - return (c >= 0xFF00 && c < 0xFF20); - } - - private boolean isUniPunct(char c) { - return (c >= 0x2000 && c < 0x2070); - } - - private boolean isWenQuanYi1(char c) { - return (c >= 0x33F3 && c <= 0x69FC); - } - - private boolean isWenQuanYi2(char c) { - return (c >= 0x69FD && c <= 0x9FDC); - } - - /** */ - - private int asciiEFindexX(char c) { - return (Arrays.asList(asciiEFList).indexOf(c) % 16); - } - - private int asciiEFindexY(char c) { - return (Arrays.asList(asciiEFList).indexOf(c) / 16); - } - - private int extAEFindexX(char c) { - return (Arrays.asList(extAEFList).indexOf(c) % 16); - } - - private int extAEFindexY(char c) { - return (Arrays.asList(extAEFList).indexOf(c) / 16); - } - - private int runicIndexX(char c) { - return (Arrays.asList(runicList).indexOf(c) % 16); - } - - private int runicIndexY(char c) { - return (Arrays.asList(runicList).indexOf(c) / 16); - } - - private int kanaIndexX(char c) { - return (c - 0x3040) % 16; - } - - private int kanaIndexY(char c) { - return (c - 0x3040) / 16; - } - - private int cjkPunctIndexX(char c) { - return (c - 0x3000) % 16; - } - - private int cjkPunctIndexY(char c) { - return (c - 0x3000) / 16; - } - - private int uniHanIndexX(char c) { - return (c - 0x3400) % 256; - } - - private int uniHanIndexY(char c) { - return (c - 0x3400) / 256; - } - - private int cyrilicIndexX(char c) { - return (c - 0x400) % 16; - } - - private int cyrilicIndexY(char c) { - return (c - 0x400) / 16; - } - - private int cyrilicEFindexX(char c) { - return (Arrays.asList(cyrilecEFList).indexOf(c) % 16); - } - - private int cyrilicEFindexY(char c) { - return (Arrays.asList(cyrilecEFList).indexOf(c) / 16); - } - - private int fullwidthUniIndexX(char c) { - return (c - 0xFF00) % 16; - } - - private int fullwidthUniIndexY(char c) { - return (c - 0xFF00) / 16; - } - - private int uniPunctIndexX(char c) { - return (c - 0x2000) % 16; - } - - private int uniPunctIndexY(char c) { - return (c - 0x2000) / 16; - } - - private int wenQuanYiIndexX(char c) { - // v Ext1 v Unihan - return (c - (c <= 0x4DB5 ? 0x33F3 : 0x33F3 + 0x4A)) % 32; - } - - private int wenQuanYi1IndexY(char c) { - return (c - (0x33F3 + 0x4A)) / 32; - } - - private int wenQuanYi2IndexY(char c) { - return (c - 0x69FD) / 32; - } - - @Override - public int getWidth(String s) { - return getWidthSubstr(s, s.length()); - } - - private int getWidthSubstr(String s, int endIndex) { - int len = 0; - for (int i = 0; i < endIndex; i++) { - int c = getSheetType(s.charAt(i)); - - if (i > 0 && s.charAt(i) > 0x20) { // Kerning - int cpre = getSheetType(s.charAt(i - 1)); - if ( - ((cpre == SHEET_UNIHAN || cpre == SHEET_HANGUL) - && !(c == SHEET_UNIHAN || c == SHEET_HANGUL)) - - || ((c == SHEET_UNIHAN || c == SHEET_HANGUL) - && !(cpre == SHEET_UNIHAN || cpre == SHEET_HANGUL)) - ) { - // margin after/before hangul/unihan - len += 2; - } - else if ((c == SHEET_HANGUL || c == SHEET_KANA) - && (cpre == SHEET_HANGUL || cpre == SHEET_KANA)) { - // margin between hangul/kana - len += 1; - } - - } - - if (c == SHEET_ASCII_EF || c == SHEET_EXTA_EF || c == SHEET_CYRILIC_EF) - len += W_LATIN_NARROW; - else if (c == SHEET_KANA || c == SHEET_HANGUL || c == SHEET_CJK_PUNCT) - len += W_CJK; - else if (c == SHEET_UNIHAN || c == SHEET_FW_UNI || c == SHEET_WENQUANYI_1 || c == SHEET_WENQUANYI_2) - len += W_UNIHAN; - else - len += W_LATIN_WIDE; - - if (i < endIndex - 1) len += interchar; - } - return len; - } - - @Override - public int getHeight(String s) { - return H; - } - - @Override - public int getLineHeight() { - return H; - } - - @Override - public void drawString(float x, float y, String s) { - drawString(x, y, s, Color.white); - } - - @Override - public void drawString(float x, float y, String s, Color color) { - // hangul fonts first - hangulSheet.startUse(); - // JOHAB - for (int i = 0; i < s.length(); i++) { - char ch = s.charAt(i); - - if (isHangul(ch)) { - int hIndex = ch - 0xAC00; - - int indexCho = getHanChosung(hIndex); - int indexJung = getHanJungseong(hIndex); - int indexJong = getHanJongseong(hIndex); - - int choRow = getHanChoseongRow(hIndex); - int jungRow = getHanJungseongRow(hIndex); - int jongRow = getHanJongseongRow(); - - int glyphW = getWidth("" + ch); - - // chosung - hangulSheet.renderInUse( - Math.round(x - + getWidthSubstr(s, i + 1) - glyphW - ) - , Math.round((H - H_HANGUL) / 2 + y + 1) - , indexCho - , choRow - ); - // jungseong - hangulSheet.renderInUse( - Math.round(x - + getWidthSubstr(s, i + 1) - glyphW - ) - , Math.round((H - H_HANGUL) / 2 + y + 1) - , indexJung - , jungRow - ); - // jongseong - hangulSheet.renderInUse( - Math.round(x - + getWidthSubstr(s, i + 1) - glyphW - ) - , Math.round((H - H_HANGUL) / 2 + y + 1) - , indexJong - , jongRow - ); - } - } - hangulSheet.endUse(); - - // unihan fonts - /*uniHan.startUse(); - for (int i = 0; i < s.length(); i++) { - char ch = s.charAt(i); - - if (isUniHan(ch)) { - int glyphW = getWidth("" + ch); - uniHan.renderInUse( - Math.round(x - + getWidthSubstr(s, i + 1) - glyphW - ) - , Math.round((H - H_UNIHAN) / 2 + y) - , uniHanIndexX(ch) - , uniHanIndexY(ch) - ); - } - } - - uniHan.endUse();*/ - - // WenQuanYi 1 - wenQuanYi_1.startUse(); - - for (int i = 0; i < s.length(); i++) { - char ch = s.charAt(i); - - if (isWenQuanYi1(ch)) { - int glyphW = getWidth("" + ch); - wenQuanYi_1.renderInUse( - Math.round(x - + getWidthSubstr(s, i + 1) - glyphW - ) - , Math.round((H - H_UNIHAN) / 2 + y - 1) - , wenQuanYiIndexX(ch) - , wenQuanYi1IndexY(ch) - ); - } - } - - wenQuanYi_1.endUse(); - wenQuanYi_2.startUse(); - - for (int i = 0; i < s.length(); i++) { - char ch = s.charAt(i); - - if (isWenQuanYi2(ch)) { - int glyphW = getWidth("" + ch); - wenQuanYi_2.renderInUse( - Math.round(x - + getWidthSubstr(s, i + 1) - glyphW - ) - , Math.round((H - H_UNIHAN) / 2 + y - 1) - , wenQuanYiIndexX(ch) - , wenQuanYi2IndexY(ch) - ); - } - } - - wenQuanYi_2.endUse(); - - //ascii fonts - int prevInstance = -1; - for (int i = 0; i < s.length(); i++) { - char ch = s.charAt(i); - - if (!isHangul(ch) && !isUniHan(ch)) { - - // if not init, enduse first - if (prevInstance != -1) { - sheetKey[prevInstance].endUse(); - } - sheetKey[getSheetType(ch)].startUse(); - prevInstance = getSheetType(ch); - - int sheetX; - int sheetY; - switch (prevInstance) { - case SHEET_ASCII_EF: - sheetX = asciiEFindexX(ch); - sheetY = asciiEFindexY(ch); - break; - case SHEET_EXTA_EF: - sheetX = extAEFindexX(ch); - sheetY = extAEFindexY(ch); - break; - case SHEET_RUNIC: - sheetX = runicIndexX(ch); - sheetY = runicIndexY(ch); - break; - case SHEET_EXTA_EM: - sheetX = (ch - 0x100) % 16; - sheetY = (ch - 0x100) / 16; - break; - case SHEET_KANA: - sheetX = kanaIndexX(ch); - sheetY = kanaIndexY(ch); - break; - case SHEET_CJK_PUNCT: - sheetX = cjkPunctIndexX(ch); - sheetY = cjkPunctIndexY(ch); - break; - case SHEET_CYRILIC_EM: - sheetX = cyrilicIndexX(ch); - sheetY = cyrilicIndexY(ch); - break; - case SHEET_CYRILIC_EF: - sheetX = cyrilicEFindexX(ch); - sheetY = cyrilicEFindexY(ch); - break; - case SHEET_FW_UNI: - sheetX = fullwidthUniIndexX(ch); - sheetY = fullwidthUniIndexY(ch); - break; - case SHEET_UNI_PUNCT: - sheetX = uniPunctIndexX(ch); - sheetY = uniPunctIndexY(ch); - break; - default: - sheetX = ch % 16; - sheetY = ch / 16; - break; - } - - try { - int glyphW = getWidth("" + ch); - sheetKey[prevInstance].renderInUse( - Math.round(x + getWidthSubstr(s, i + 1) - glyphW) - // Interchar: pull punct right next to hangul to the left - + ((i > 0 && isHangul(s.charAt(i - 1))) ? -3 : 0) - , Math.round(y) - + ((prevInstance == SHEET_CJK_PUNCT) ? -1 : - (prevInstance == SHEET_FW_UNI) ? (H - H_HANGUL) / 2 : 0) - , sheetX - , sheetY - ); - } - catch (ArrayIndexOutOfBoundsException e) { - // System.out.println("ArrayIndexOutOfBoundsException") - // System.out.println("char: '" + ch + "' (" + String.valueOf((int) ch) + ")"); - // System.out.println("sheet: " + prevInstance); - // System.out.println("sheetX: " + sheetX); - // System.out.println("sheetY: " + sheetY); - } - - } - - } - if (prevInstance != -1) { - sheetKey[prevInstance].endUse(); - } - } - - private int getSheetType(char c) { - // EFs - if (isAsciiEF(c)) return SHEET_ASCII_EF; - else if (isExtAEF(c)) return SHEET_EXTA_EF; - else if (isCyrilicEF(c)) return SHEET_CYRILIC_EF; - // fixed width - else if (isRunic(c)) return SHEET_RUNIC; - else if (isHangul(c)) return SHEET_HANGUL; - else if (isKana(c)) return SHEET_KANA; - else if (isUniHan(c)) return SHEET_UNIHAN; - else if (isAscii(c)) return SHEET_ASCII_EM; - else if (isExtA(c)) return SHEET_EXTA_EM; - else if (isCyrilic(c)) return SHEET_CYRILIC_EM; - else if (isUniPunct(c)) return SHEET_UNI_PUNCT; - // fixed width punctuations - else if (isCJKPunct(c)) return SHEET_CJK_PUNCT; - else if (isFullwidthUni(c)) return SHEET_FW_UNI; - - else return SHEET_ASCII_EM; // fallback - } - - /** - * Draw part of a string to the screen. Note that this will still position the text as though - * it's part of the bigger string. - * @param x - * @param y - * @param s - * @param color - * @param startIndex - * @param endIndex - */ - @Override - public void drawString(float x, float y, String s, Color color, int startIndex, int endIndex) { - String unprintedHead = s.substring(0, startIndex); - String printedBody = s.substring(startIndex, endIndex); - int xoff = getWidth(unprintedHead); - drawString(x + xoff, y, printedBody, color); - } - - public void reloadUnihan() throws SlickException { - - } - - /** - * Set margin between characters - * @param margin - */ - public void setInterchar(int margin) { - interchar = margin; - } - - private void setBlendModeMul() { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - - private void setBlendModeNormal() { - GL11.glDisable(GL11.GL_BLEND); - Terrarum.appgc.getGraphics().setDrawMode(Graphics.MODE_NORMAL); - } -} diff --git a/src/com/Torvald/ImageFont/GameFontBase.kt b/src/com/Torvald/ImageFont/GameFontBase.kt new file mode 100644 index 000000000..9cea5ddd2 --- /dev/null +++ b/src/com/Torvald/ImageFont/GameFontBase.kt @@ -0,0 +1,500 @@ +package com.Torvald.ImageFont + +import com.Torvald.Terrarum.Terrarum +import org.lwjgl.opengl.GL11 +import org.newdawn.slick.* + +/** + * Created by minjaesong on 16-01-27. + */ +open class GameFontBase @Throws(SlickException::class) +constructor() : Font { + + private fun getHan(hanIndex: Int): IntArray { + val han_x = hanIndex % JONG_COUNT + val han_y = hanIndex / JONG_COUNT + val ret = intArrayOf(han_x, han_y) + return ret + } + + private fun getHanChosung(hanIndex: Int) = hanIndex / (JUNG_COUNT * JONG_COUNT) + + private fun getHanJungseong(hanIndex: Int) = hanIndex / JONG_COUNT % JUNG_COUNT + + private fun getHanJongseong(hanIndex: Int) = hanIndex % JONG_COUNT + + + private fun getHanChoseongRow(hanIndex: Int): Int { + val jungseongIndex = getHanJungseong(hanIndex) + val jungseongWide = arrayOf(8, 12, 13, 17, 18, 21) + val jungseongComplex = arrayOf(9, 10, 11, 14, 15, 16, 22) + val ret: Int + + if (jungseongWide.contains(jungseongIndex)) { + ret = 2 + } + else if (jungseongComplex.contains(jungseongIndex)) { + ret = 4 + } + else { + ret = 0 + } + return if (getHanJongseong(hanIndex) == 0) ret else ret + 1 + } + + private fun getHanJungseongRow(hanIndex: Int) = if (getHanJongseong(hanIndex) == 0) 6 else 7 + + private val hanJongseongRow: Int + get() = 8 + + private fun isAsciiEF(c: Char) = asciiEFList.contains(c) + + private fun isExtAEF(c: Char) = extAEFList.contains(c) + + private fun isHangul(c: Char) = c.toInt() >= 0xAC00 && c.toInt() < 0xD7A4 + + private fun isAscii(c: Char) = c.toInt() > 0 && c.toInt() <= 0xFF + + private fun isRunic(c: Char) = runicList.contains(c) + + private fun isExtA(c: Char) = c.toInt() >= 0x100 && c.toInt() < 0x180 + + private fun isKana(c: Char) = c.toInt() >= 0x3040 && c.toInt() < 0x3100 + + private fun isCJKPunct(c: Char) = c.toInt() >= 0x3000 && c.toInt() < 0x3040 + + private fun isUniHan(c: Char) = c.toInt() >= 0x3400 && c.toInt() < 0xA000 + + private fun isCyrilic(c: Char) = c.toInt() >= 0x400 && c.toInt() < 0x460 + + private fun isCyrilicEF(c: Char) = cyrilecEFList.contains(c) + + private fun isFullwidthUni(c: Char) = c.toInt() >= 0xFF00 && c.toInt() < 0xFF20 + + private fun isUniPunct(c: Char) = c.toInt() >= 0x2000 && c.toInt() < 0x2070 + + private fun isWenQuanYi1(c: Char) = c.toInt() >= 0x33F3 && c.toInt() <= 0x69FC + + private fun isWenQuanYi2(c: Char) = c.toInt() >= 0x69FD && c.toInt() <= 0x9FDC + + + + private fun asciiEFindexX(c: Char) = asciiEFList.indexOf(c) % 16 + private fun asciiEFindexY(c: Char) = asciiEFList.indexOf(c) / 16 + + private fun extAEFindexX(c: Char) = extAEFList.indexOf(c) % 16 + private fun extAEFindexY(c: Char) = extAEFList.indexOf(c) / 16 + + private fun runicIndexX(c: Char) = runicList.indexOf(c) % 16 + private fun runicIndexY(c: Char) = runicList.indexOf(c) / 16 + + private fun kanaIndexX(c: Char) = (c.toInt() - 0x3040) % 16 + private fun kanaIndexY(c: Char) = (c.toInt() - 0x3040) / 16 + + private fun cjkPunctIndexX(c: Char) = (c.toInt() - 0x3000) % 16 + private fun cjkPunctIndexY(c: Char) = (c.toInt() - 0x3000) / 16 + + private fun uniHanIndexX(c: Char) = (c.toInt() - 0x3400) % 256 + private fun uniHanIndexY(c: Char) = (c.toInt() - 0x3400) / 256 + + private fun cyrilicIndexX(c: Char) = (c.toInt() - 0x400) % 16 + private fun cyrilicIndexY(c: Char) = (c.toInt() - 0x400) / 16 + + private fun cyrilicEFindexX(c: Char) = cyrilecEFList.indexOf(c) % 16 + private fun cyrilicEFindexY(c: Char) = cyrilecEFList.indexOf(c) / 16 + + private fun fullwidthUniIndexX(c: Char) = (c.toInt() - 0xFF00) % 16 + private fun fullwidthUniIndexY(c: Char) = (c.toInt() - 0xFF00) / 16 + + private fun uniPunctIndexX(c: Char) = (c.toInt() - 0x2000) % 16 + private fun uniPunctIndexY(c: Char) = (c.toInt() - 0x2000) / 16 + + private fun wenQuanYiIndexX(c: Char) = + (c.toInt() - if (c.toInt() <= 0x4DB5) 0x33F3 else 0x33F3 + 0x4A) % 32 + private fun wenQuanYi1IndexY(c: Char) = (c.toInt() - (0x33F3 + 0x4A)) / 32 + private fun wenQuanYi2IndexY(c: Char) = (c.toInt() - 0x69FD) / 32 + + override fun getWidth(s: String) = getWidthSubstr(s, s.length) + + + private fun getWidthSubstr(s: String, endIndex: Int): Int { + var len = 0 + for (i in 0..endIndex - 1) { + val c = getSheetType(s[i]) + + if (i > 0 && s[i].toInt() > 0x20) { + // Kerning + val cpre = getSheetType(s[i - 1]) + if ((cpre == SHEET_UNIHAN || cpre == SHEET_HANGUL) && !(c == SHEET_UNIHAN || c == SHEET_HANGUL) + + || (c == SHEET_UNIHAN || c == SHEET_HANGUL) && !(cpre == SHEET_UNIHAN || cpre == SHEET_HANGUL)) { + // margin after/before hangul/unihan + len += 2 + } + else if ((c == SHEET_HANGUL || c == SHEET_KANA) && (cpre == SHEET_HANGUL || cpre == SHEET_KANA)) { + // margin between hangul/kana + len += 1 + } + + } + + if (c == SHEET_ASCII_EF || c == SHEET_EXTA_EF || c == SHEET_CYRILIC_EF) + len += W_LATIN_NARROW + else if (c == SHEET_KANA || c == SHEET_HANGUL || c == SHEET_CJK_PUNCT) + len += W_CJK + else if (c == SHEET_UNIHAN || c == SHEET_FW_UNI || c == SHEET_WENQUANYI_1 || c == SHEET_WENQUANYI_2) + len += W_UNIHAN + else + len += W_LATIN_WIDE + + if (i < endIndex - 1) len += interchar + } + return len + } + + override fun getHeight(s: String) = H + + override fun getLineHeight() = H + + override fun drawString(x: Float, y: Float, s: String) { + drawString(x, y, s, Color.white) + } + + override fun drawString(x: Float, y: Float, s: String, color: Color) { + // hangul fonts first + hangulSheet.startUse() + // JOHAB + for (i in 0..s.length - 1) { + val ch = s[i] + + if (isHangul(ch)) { + val hIndex = ch.toInt() - 0xAC00 + + val indexCho = getHanChosung(hIndex) + val indexJung = getHanJungseong(hIndex) + val indexJong = getHanJongseong(hIndex) + + val choRow = getHanChoseongRow(hIndex) + val jungRow = getHanJungseongRow(hIndex) + val jongRow = hanJongseongRow + + val glyphW = getWidth("" + ch) + + // chosung + hangulSheet.renderInUse( + Math.round(x + getWidthSubstr(s, i + 1) - glyphW), Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f), indexCho, choRow) + // jungseong + hangulSheet.renderInUse( + Math.round(x + getWidthSubstr(s, i + 1) - glyphW), Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f), indexJung, jungRow) + // jongseong + hangulSheet.renderInUse( + Math.round(x + getWidthSubstr(s, i + 1) - glyphW), Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f), indexJong, jongRow) + } + } + hangulSheet.endUse() + + // unihan fonts + /*uniHan.startUse(); + for (int i = 0; i < s.length(); i++) { + char ch = s.charAt(i); + + if (isUniHan(ch)) { + int glyphW = getWidth("" + ch); + uniHan.renderInUse( + Math.round(x + + getWidthSubstr(s, i + 1) - glyphW + ) + , Math.round((H - H_UNIHAN) / 2 + y) + , uniHanIndexX(ch) + , uniHanIndexY(ch) + ); + } + } + + uniHan.endUse();*/ + + // WenQuanYi 1 + wenQuanYi_1.startUse() + + for (i in 0..s.length - 1) { + val ch = s[i] + + if (isWenQuanYi1(ch)) { + val glyphW = getWidth("" + ch) + wenQuanYi_1.renderInUse( + Math.round(x + getWidthSubstr(s, i + 1) - glyphW), + Math.round((H - H_UNIHAN) / 2 + y), + wenQuanYiIndexX(ch), + wenQuanYi1IndexY(ch) + ) + } + } + + wenQuanYi_1.endUse() + wenQuanYi_2.startUse() + + for (i in 0..s.length - 1) { + val ch = s[i] + + if (isWenQuanYi2(ch)) { + val glyphW = getWidth("" + ch) + wenQuanYi_2.renderInUse( + Math.round(x + getWidthSubstr(s, i + 1) - glyphW), + Math.round((H - H_UNIHAN) / 2 + y), + wenQuanYiIndexX(ch), + wenQuanYi2IndexY(ch) + ) + } + } + + wenQuanYi_2.endUse() + + //ascii fonts + var prevInstance = -1 + for (i in 0..s.length - 1) { + val ch = s[i] + + if (!isHangul(ch) && !isUniHan(ch)) { + + // if not init, endUse first + if (prevInstance != -1) { + sheetKey[prevInstance].endUse() + } + sheetKey[getSheetType(ch)].startUse() + prevInstance = getSheetType(ch) + + val sheetX: Int + val sheetY: Int + when (prevInstance) { + SHEET_ASCII_EF -> { + sheetX = asciiEFindexX(ch) + sheetY = asciiEFindexY(ch) + } + SHEET_EXTA_EF -> { + sheetX = extAEFindexX(ch) + sheetY = extAEFindexY(ch) + } + SHEET_RUNIC -> { + sheetX = runicIndexX(ch) + sheetY = runicIndexY(ch) + } + SHEET_EXTA_EM -> { + sheetX = (ch.toInt() - 0x100) % 16 + sheetY = (ch.toInt() - 0x100) / 16 + } + SHEET_KANA -> { + sheetX = kanaIndexX(ch) + sheetY = kanaIndexY(ch) + } + SHEET_CJK_PUNCT -> { + sheetX = cjkPunctIndexX(ch) + sheetY = cjkPunctIndexY(ch) + } + SHEET_CYRILIC_EM -> { + sheetX = cyrilicIndexX(ch) + sheetY = cyrilicIndexY(ch) + } + SHEET_CYRILIC_EF -> { + sheetX = cyrilicEFindexX(ch) + sheetY = cyrilicEFindexY(ch) + } + SHEET_FW_UNI -> { + sheetX = fullwidthUniIndexX(ch) + sheetY = fullwidthUniIndexY(ch) + } + SHEET_UNI_PUNCT -> { + sheetX = uniPunctIndexX(ch) + sheetY = uniPunctIndexY(ch) + } + else -> { + sheetX = ch.toInt() % 16 + sheetY = ch.toInt() / 16 + } + } + + val glyphW = getWidth("" + ch) + sheetKey[prevInstance].renderInUse( + Math.round(x + getWidthSubstr(s, i + 1) - glyphW) // Interchar: pull punct right next to hangul to the left + + if (i > 0 && isHangul(s[i - 1])) -3 else 0, Math.round(y) + if (prevInstance == SHEET_CJK_PUNCT) + -1 + else if (prevInstance == SHEET_FW_UNI) (H - H_HANGUL) / 2 else 0, sheetX, sheetY) + + } + + } + if (prevInstance != -1) { + sheetKey[prevInstance].endUse() + } + } + + private fun getSheetType(c: Char): Int { + // EFs + if (isAsciiEF(c)) + return SHEET_ASCII_EF + else if (isExtAEF(c)) + return SHEET_EXTA_EF + else if (isCyrilicEF(c)) + return SHEET_CYRILIC_EF + else if (isRunic(c)) + return SHEET_RUNIC + else if (isHangul(c)) + return SHEET_HANGUL + else if (isKana(c)) + return SHEET_KANA + else if (isUniHan(c)) + return SHEET_UNIHAN + else if (isAscii(c)) + return SHEET_ASCII_EM + else if (isExtA(c)) + return SHEET_EXTA_EM + else if (isCyrilic(c)) + return SHEET_CYRILIC_EM + else if (isUniPunct(c)) + return SHEET_UNI_PUNCT + else if (isCJKPunct(c)) + return SHEET_CJK_PUNCT + else if (isFullwidthUni(c)) + return SHEET_FW_UNI + else + return SHEET_ASCII_EM// fixed width punctuations + // fixed width + // fallback + } + + /** + * Draw part of a string to the screen. Note that this will still position the text as though + * it's part of the bigger string. + * @param x + * * + * @param y + * * + * @param s + * * + * @param color + * * + * @param startIndex + * * + * @param endIndex + */ + override fun drawString(x: Float, y: Float, s: String, color: Color, startIndex: Int, endIndex: Int) { + val unprintedHead = s.substring(0, startIndex) + val printedBody = s.substring(startIndex, endIndex) + val xoff = getWidth(unprintedHead) + drawString(x + xoff, y, printedBody, color) + } + + @Throws(SlickException::class) + open fun reloadUnihan() { + + } + + /** + * Set margin between characters + * @param margin + */ + fun setInterchar(margin: Int) { + interchar = margin + } + + private fun setBlendModeMul() { + GL11.glEnable(GL11.GL_BLEND) + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_ONE_MINUS_SRC_ALPHA) + } + + private fun setBlendModeNormal() { + GL11.glDisable(GL11.GL_BLEND) + Terrarum.appgc.graphics.setDrawMode(Graphics.MODE_NORMAL) + } + + companion object { + + lateinit internal var hangulSheet: SpriteSheet + lateinit internal var asciiSheet: SpriteSheet + lateinit internal var asciiSheetEF: SpriteSheet + lateinit internal var runicSheet: SpriteSheet + lateinit internal var extASheet: SpriteSheet + lateinit internal var extASheetEF: SpriteSheet + lateinit internal var kanaSheet: SpriteSheet + lateinit internal var cjkPunct: SpriteSheet + // static SpriteSheet uniHan; + lateinit internal var cyrilic: SpriteSheet + lateinit internal var cyrilicEF: SpriteSheet + lateinit internal var fullwidthForms: SpriteSheet + lateinit internal var uniPunct: SpriteSheet + lateinit internal var wenQuanYi_1: SpriteSheet + lateinit internal var wenQuanYi_2: SpriteSheet + + internal val JUNG_COUNT = 21 + internal val JONG_COUNT = 28 + + internal val W_CJK = 10 + internal val W_UNIHAN = 16 + internal val W_LATIN_WIDE = 9 // width of regular letters, including m + internal val W_LATIN_NARROW = 5 // width of letter f, t, i, l + internal val H = 20 + internal val H_HANGUL = 16 + internal val H_UNIHAN = 16 + internal val H_KANA = 20 + + internal val SHEET_ASCII_EM = 0 + internal val SHEET_ASCII_EF = 1 + internal val SHEET_HANGUL = 2 + internal val SHEET_RUNIC = 3 + internal val SHEET_EXTA_EM = 4 + internal val SHEET_EXTA_EF = 5 + internal val SHEET_KANA = 6 + internal val SHEET_CJK_PUNCT = 7 + internal val SHEET_UNIHAN = 8 + internal val SHEET_CYRILIC_EM = 9 + internal val SHEET_CYRILIC_EF = 10 + internal val SHEET_FW_UNI = 11 + internal val SHEET_UNI_PUNCT = 12 + internal val SHEET_WENQUANYI_1 = 13 + internal val SHEET_WENQUANYI_2 = 14 + + lateinit internal var sheetKey: Array + internal val asciiEFList = arrayOf(' ', '!', '"', '\'', '(', ')', ',', '.', ':', ';', 'I', '[', ']', '`', 'f', 'i', 'j', 'l', 't', '{', '|', '}', 0xA1.toChar(), 'Ì', 'Í', 'Î', 'Ï', 'ì', 'í', 'î', 'ï', '·') + + internal val extAEFList = arrayOf( + 0x12E.toChar(), + 0x12F.toChar(), + 0x130.toChar(), + 0x131.toChar(), + 0x135.toChar(), + 0x13A.toChar(), + 0x13C.toChar(), + 0x142.toChar(), + 0x163.toChar(), + 0x167.toChar(), + 0x17F.toChar() + ) + + internal val cyrilecEFList = arrayOf( + 0x406.toChar(), + 0x407.toChar(), + 0x456.toChar(), + 0x457.toChar(), + 0x458.toChar() + ) + + /** + * Runic letters list used for game. The set is + * Younger Futhark + Medieval rune 'e' + Punct + Runic Almanac + + * BEWARE OF SIMILAR-LOOKING RUNES, especially: + + * * Algiz ᛉ instead of Maðr ᛘ + + * * Short-Twig Hagall ᚽ instead of Runic Letter E ᛂ + + * * Runic Letter OE ᚯ instead of Óss ᚬ + + * Examples: + * ᛭ᛋᛁᚴᚱᛁᚦᛦ᛭ + * ᛭ᛂᛚᛋᛅ᛭ᛏᚱᚢᛏᚾᛁᚾᚴᚢᚾᛅ᛬ᛅᚱᚾᛅᛏᛅᛚᛋ + */ + internal val runicList = arrayOf('ᚠ', 'ᚢ', 'ᚦ', 'ᚬ', 'ᚱ', 'ᚴ', 'ᚼ', 'ᚾ', 'ᛁ', 'ᛅ', 'ᛋ', 'ᛏ', 'ᛒ', 'ᛘ', 'ᛚ', 'ᛦ', 'ᛂ', '᛬', '᛫', '᛭', 'ᛮ', 'ᛯ', 'ᛰ') + + internal var interchar = 0 + } +} diff --git a/src/com/Torvald/ImageFont/GameFontWhite.java b/src/com/Torvald/ImageFont/GameFontWhite.java deleted file mode 100644 index e8ad5d55d..000000000 --- a/src/com/Torvald/ImageFont/GameFontWhite.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.Torvald.ImageFont; - -import com.Torvald.Terrarum.Terrarum; -import org.newdawn.slick.*; - -/** - * Created by minjaesong on 16-01-20. - */ -public class GameFontWhite extends GameFontBase { - - public GameFontWhite() throws SlickException { - super(); - - hangulSheet = new SpriteSheet( - "./res/graphics/fonts/han_johab.png" - , W_CJK, H_HANGUL - ); - asciiSheet = new SpriteSheet( - "./res/graphics/fonts/ascii_majuscule.png" - , W_LATIN_WIDE, H - ); - asciiSheetEF = new SpriteSheet( - "./res/graphics/fonts/ascii_special_ef.png" - , W_LATIN_NARROW, H - ); - runicSheet = new SpriteSheet( - "./res/graphics/fonts/futhark.png" - , W_LATIN_WIDE, H - ); - extASheet = new SpriteSheet( - "./res/graphics/fonts/LatinExtA_majuscule.png" - , W_LATIN_WIDE, H - ); - extASheetEF = new SpriteSheet( - "./res/graphics/fonts/LatinExtA_ef.png" - , W_LATIN_NARROW, H - ); - kanaSheet = new SpriteSheet( - "./res/graphics/fonts/kana.png" - , W_CJK, H_KANA - ); - cjkPunct = new SpriteSheet( - "./res/graphics/fonts/cjkpunct.png" - , W_CJK, H_KANA - ); - /*uniHan = new SpriteSheet( - "./res/graphics/fonts/unifont_unihan" - + ((!Terrarum.gameLocale.contains("zh")) - ? "_ja" : "") - +".png" - , W_UNIHAN, H_UNIHAN - );*/ - cyrilic = new SpriteSheet( - "./res/graphics/fonts/cyrilic_majuscule.png" - , W_LATIN_WIDE, H - ); - cyrilicEF = new SpriteSheet( - "./res/graphics/fonts/cyrilic_ef.png" - , W_LATIN_NARROW, H - ); - fullwidthForms = new SpriteSheet( - "./res/graphics/fonts/fullwidth_forms.png" - , W_UNIHAN, H_UNIHAN - ); - uniPunct = new SpriteSheet( - "./res/graphics/fonts/unipunct.png" - , W_LATIN_WIDE, H - ); - wenQuanYi_1 = new SpriteSheet( - "./res/graphics/fonts/wenquanyi_11pt_part1.png" - , 16, 18, 2 - ); - wenQuanYi_2 = new SpriteSheet( - "./res/graphics/fonts/wenquanyi_11pt_part2.png" - , 16, 18, 2 - ); - - SpriteSheet[] shk = { - asciiSheet - , asciiSheetEF - , hangulSheet - , runicSheet - , extASheet - , extASheetEF - , kanaSheet - , cjkPunct - //, uniHan - , null - , cyrilic - , cyrilicEF - , fullwidthForms - , uniPunct - , wenQuanYi_1 - , wenQuanYi_2 - }; - sheetKey = shk; - } - - @Override - public void reloadUnihan() throws SlickException { - /*uniHan = new SpriteSheet( - "./res/graphics/fonts/unifont_unihan" - + ((!Terrarum.gameLocale.contains("zh")) - ? "_ja" : "") - +".png" - , W_UNIHAN, H_UNIHAN - );*/ - } -} diff --git a/src/com/Torvald/ImageFont/GameFontWhite.kt b/src/com/Torvald/ImageFont/GameFontWhite.kt new file mode 100644 index 000000000..65270bbf8 --- /dev/null +++ b/src/com/Torvald/ImageFont/GameFontWhite.kt @@ -0,0 +1,79 @@ +package com.Torvald.ImageFont + +import com.Torvald.Terrarum.Terrarum +import org.newdawn.slick.* + +/** + * Created by minjaesong on 16-01-20. + */ +class GameFontWhite @Throws(SlickException::class) +constructor() : GameFontBase() { + + init { + + GameFontBase.hangulSheet = SpriteSheet( + "./res/graphics/fonts/han_johab.png", GameFontBase.W_CJK, GameFontBase.H_HANGUL) + GameFontBase.asciiSheet = SpriteSheet( + "./res/graphics/fonts/ascii_majuscule.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) + GameFontBase.asciiSheetEF = SpriteSheet( + "./res/graphics/fonts/ascii_special_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H) + GameFontBase.runicSheet = SpriteSheet( + "./res/graphics/fonts/futhark.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) + GameFontBase.extASheet = SpriteSheet( + "./res/graphics/fonts/LatinExtA_majuscule.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) + GameFontBase.extASheetEF = SpriteSheet( + "./res/graphics/fonts/LatinExtA_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H) + GameFontBase.kanaSheet = SpriteSheet( + "./res/graphics/fonts/kana.png", GameFontBase.W_CJK, GameFontBase.H_KANA) + GameFontBase.cjkPunct = SpriteSheet( + "./res/graphics/fonts/cjkpunct.png", GameFontBase.W_CJK, GameFontBase.H_KANA) + /*uniHan = new SpriteSheet( + "./res/graphics/fonts/unifont_unihan" + + ((!Terrarum.gameLocale.contains("zh")) + ? "_ja" : "") + +".png" + , W_UNIHAN, H_UNIHAN + );*/ + GameFontBase.cyrilic = SpriteSheet( + "./res/graphics/fonts/cyrilic_majuscule.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) + GameFontBase.cyrilicEF = SpriteSheet( + "./res/graphics/fonts/cyrilic_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H) + GameFontBase.fullwidthForms = SpriteSheet( + "./res/graphics/fonts/fullwidth_forms.png", GameFontBase.W_UNIHAN, GameFontBase.H_UNIHAN) + GameFontBase.uniPunct = SpriteSheet( + "./res/graphics/fonts/unipunct.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) + GameFontBase.wenQuanYi_1 = SpriteSheet( + "./res/graphics/fonts/wenquanyi_11pt_part1.png", 16, 18, 2) + GameFontBase.wenQuanYi_2 = SpriteSheet( + "./res/graphics/fonts/wenquanyi_11pt_part2.png", 16, 18, 2) + + val shk = arrayOf( + GameFontBase.asciiSheet, + GameFontBase.asciiSheetEF, + GameFontBase.hangulSheet, + GameFontBase.runicSheet, + GameFontBase.extASheet, + GameFontBase.extASheetEF, + GameFontBase.kanaSheet, + GameFontBase.cjkPunct, + GameFontBase.asciiSheet, // Filler + GameFontBase.cyrilic, + GameFontBase.cyrilicEF, + GameFontBase.fullwidthForms, + GameFontBase.uniPunct, + GameFontBase.wenQuanYi_1, + GameFontBase.wenQuanYi_2)//, uniHan + GameFontBase.sheetKey = shk + } + + @Throws(SlickException::class) + override fun reloadUnihan() { + /*uniHan = new SpriteSheet( + "./res/graphics/fonts/unifont_unihan" + + ((!Terrarum.gameLocale.contains("zh")) + ? "_ja" : "") + +".png" + , W_UNIHAN, H_UNIHAN + );*/ + } +} diff --git a/src/com/Torvald/JsonFetcher.java b/src/com/Torvald/JsonFetcher.java deleted file mode 100644 index c8829538a..000000000 --- a/src/com/Torvald/JsonFetcher.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.Torvald; - -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Created by minjaesong on 16-02-15. - */ -public class JsonFetcher { - - private static StringBuffer jsonString; - - public static JsonObject readJson(String jsonFilePath) throws IOException { - jsonString = new StringBuffer(); // reset buffer every time it called - readJsonFileAsString(jsonFilePath); - - JsonParser jsonParser = new JsonParser(); - JsonObject jsonObj = jsonParser.parse(jsonString.toString()).getAsJsonObject(); - - return jsonObj; - } - - public static ArrayList readJsonAsString(String jsonFilePath) throws IOException { - ArrayList jsonFileLines = new ArrayList<>(); - Files.lines( - FileSystems.getDefault().getPath(jsonFilePath) - ).forEach(jsonFileLines::add); - return jsonFileLines; - } - - private static void readJsonFileAsString(String path) throws IOException { - Files.lines( - FileSystems.getDefault().getPath(path) - ).forEach(jsonString::append); // JSON does not require line break - } -} diff --git a/src/com/Torvald/JsonFetcher.kt b/src/com/Torvald/JsonFetcher.kt new file mode 100644 index 000000000..5249ed84a --- /dev/null +++ b/src/com/Torvald/JsonFetcher.kt @@ -0,0 +1,36 @@ +package com.Torvald + +import com.google.gson.JsonObject +import com.google.gson.JsonParser + +import java.io.IOException +import java.nio.file.FileSystems +import java.nio.file.Files +import java.util.ArrayList +import java.util.function.Consumer + +/** + * Created by minjaesong on 16-02-15. + */ +object JsonFetcher { + + private var jsonString: StringBuffer? = null + + @Throws(IOException::class) + fun readJson(jsonFilePath: String): JsonObject { + jsonString = StringBuffer() // reset buffer every time it called + readJsonFileAsString(jsonFilePath) + + val jsonParser = JsonParser() + val jsonObj = jsonParser.parse(jsonString!!.toString()).asJsonObject + + return jsonObj + } + + @Throws(IOException::class) + private fun readJsonFileAsString(path: String) { + Files.lines(FileSystems.getDefault().getPath(path)).forEach( + { jsonString!!.append(it) } + ) // JSON does not require line break + } +} diff --git a/src/com/Torvald/JsonWriter.java b/src/com/Torvald/JsonWriter.java deleted file mode 100644 index a580938ff..000000000 --- a/src/com/Torvald/JsonWriter.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.Torvald; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.io.FileWriter; -import java.io.IOException; - -/** - * Created by minjaesong on 16-03-04. - */ -public class JsonWriter { - - public static void writeToFile(Object c, String path) throws IOException { - JsonElement classElem = new Gson().toJsonTree(c); - String jsonString = classElem.toString(); - FileWriter writer = new FileWriter(path); - writer.write(jsonString); - writer.close(); - } - - public static void writeToFile(JsonObject jsonObject, String path) throws IOException { - FileWriter writer = new FileWriter(path); - writer.write(jsonObject.toString()); - writer.close(); - } - -} diff --git a/src/com/Torvald/JsonWriter.kt b/src/com/Torvald/JsonWriter.kt new file mode 100644 index 000000000..52563b523 --- /dev/null +++ b/src/com/Torvald/JsonWriter.kt @@ -0,0 +1,31 @@ +package com.Torvald + +import com.google.gson.Gson +import com.google.gson.JsonElement +import com.google.gson.JsonObject + +import java.io.FileWriter +import java.io.IOException + +/** + * Created by minjaesong on 16-03-04. + */ +object JsonWriter { + + @Throws(IOException::class) + fun writeToFile(c: Any, path: String) { + val classElem = Gson().toJsonTree(c) + val jsonString = classElem.toString() + val writer = FileWriter(path) + writer.write(jsonString) + writer.close() + } + + @Throws(IOException::class) + fun writeToFile(jsonObject: JsonObject, path: String) { + val writer = FileWriter(path) + writer.write(jsonObject.toString()) + writer.close() + } + +} diff --git a/src/com/Torvald/Rand/Fudge3.java b/src/com/Torvald/Rand/Fudge3.java deleted file mode 100644 index 115da3334..000000000 --- a/src/com/Torvald/Rand/Fudge3.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.Torvald.Rand; - -import java.util.Random; - -/** - * Created by minjaesong on 16-02-03. - */ -public class Fudge3 extends FudgeDice { - - /** - * Define new set of fudge dice with three dice. - * @param randfunc java.util.Random or its extension - */ - public Fudge3(Random randfunc) { - super(randfunc, 3); - } - - -} diff --git a/src/com/Torvald/Rand/Fudge3.kt b/src/com/Torvald/Rand/Fudge3.kt new file mode 100644 index 000000000..a2a2ab060 --- /dev/null +++ b/src/com/Torvald/Rand/Fudge3.kt @@ -0,0 +1,13 @@ +package com.Torvald.Rand + +import java.util.Random + +/** + * Created by minjaesong on 16-02-03. + */ +class Fudge3 +/** + * Define new set of fudge dice with three dice. + * @param randfunc java.util.Random or its extension + */ +(randfunc: Random) : FudgeDice(randfunc, 3) diff --git a/src/com/Torvald/Rand/FudgeDice.java b/src/com/Torvald/Rand/FudgeDice.java deleted file mode 100644 index c45fe477b..000000000 --- a/src/com/Torvald/Rand/FudgeDice.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.Torvald.Rand; - -import java.util.Random; - -/** - * Created by minjaesong on 16-02-03. - */ -public class FudgeDice { - - private Random randfunc; - private int diceCounts; - - /** - * Define new set of fudge dice with given counts. - * @param randfunc java.util.Random or its extension - * @param counts amount of die - */ - public FudgeDice(Random randfunc, int counts) { - this.randfunc = randfunc; - diceCounts = counts; - } - - /** - * Roll dice and get result. - * @return Normal distributed integer [-N , N] for diceCount of N. 0 is the most frequent return. - */ - public int roll() { - int diceResult = 0; - for (int c = 0; c < diceCounts; c++) { - diceResult += rollSingleDie(); - } - - return diceResult; - } - - /** - * Roll dice and get result, for array index - * @return Normal distributed integer [0 , N] for N = 2 × DiceCounts + 1. 0 is the most frequent return. - */ - public int rollForArray() { - return roll() + diceCounts; - } - - public int getDiceCounts() { - return diceCounts; - } - - public int getSizeOfProbabilityRange() { - return 2 * diceCounts + 1; - } - - /** - * @return integer randomly picked from {-1, 0, 1} - */ - private int rollSingleDie() { - return (randfunc.nextInt(3)) - 1; - } -} diff --git a/src/com/Torvald/Rand/FudgeDice.kt b/src/com/Torvald/Rand/FudgeDice.kt new file mode 100644 index 000000000..7ac5a2704 --- /dev/null +++ b/src/com/Torvald/Rand/FudgeDice.kt @@ -0,0 +1,47 @@ +package com.Torvald.Rand + +import java.util.Random + +/** + * Created by minjaesong on 16-02-03. + */ +open class FudgeDice +/** + * Define new set of fudge dice with given counts. + * @param randfunc java.util.Random or its extension + * * + * @param counts amount of die + */ +(private val randfunc: Random, val diceCounts: Int) { + + /** + * Roll dice and get result. + * @return Normal distributed integer [-N , N] for diceCount of N. 0 is the most frequent return. + */ + fun roll(): Int { + var diceResult = 0 + for (c in 0..diceCounts - 1) { + diceResult += rollSingleDie() + } + + return diceResult + } + + /** + * Roll dice and get result, for array index + * @return Normal distributed integer [0 , N] for N = 2 × DiceCounts + 1. 0 is the most frequent return. + */ + fun rollForArray(): Int { + return roll() + diceCounts + } + + val sizeOfProbabilityRange: Int + get() = 2 * diceCounts + 1 + + /** + * @return integer randomly picked from {-1, 0, 1} + */ + private fun rollSingleDie(): Int { + return randfunc.nextInt(3) - 1 + } +} diff --git a/src/com/Torvald/RasterWriter.java b/src/com/Torvald/RasterWriter.java deleted file mode 100644 index d861dedd1..000000000 --- a/src/com/Torvald/RasterWriter.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.Torvald; - -import com.Torvald.Terrarum.Terrarum; - -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.color.ColorSpace; -import java.awt.image.*; -import java.io.File; -import java.io.IOException; - -/** - * Created by minjaesong on 16-03-04. - */ -public class RasterWriter { - - public static final int[] BANDOFFSET_RGB = {0, 1, 2}; - public static final int[] BANDOFFSET_RGBA = {0, 1, 2, 3}; - public static final int[] BANDOFFSET_ARGB = {3, 0, 1, 2}; - public static final int[] BANDOFFSET_MONO = {0}; - - public static final int COLORSPACE_SRGB = ColorSpace.CS_sRGB; - public static final int COLORSPACE_GRAY = ColorSpace.CS_GRAY; - public static final int COLORSPACE_GREY = COLORSPACE_GRAY; - public static final int COLORSPACE_CIEXYZ = ColorSpace.CS_CIEXYZ; - public static final int COLORSPACE_RGB_LINEAR_GAMMA = ColorSpace.CS_LINEAR_RGB; - - public static void writePNG_RGB(int w, int h, byte[] rasterData, String path) throws IOException { - writePNG(w, h, rasterData, BANDOFFSET_RGB, COLORSPACE_SRGB, path); - } - - public static void writePNG_Mono(int w, int h, byte[] rasterData, String path) throws IOException { - writePNG(w, h, rasterData, BANDOFFSET_MONO, COLORSPACE_GREY, path); - } - - public static void writePNG(int w, int h, byte[] rasterData, int[] bandOffsets, int awt_colorspace, String path) throws IOException { - DataBuffer buffer = new DataBufferByte(rasterData, rasterData.length); - WritableRaster raster = Raster.createInterleavedRaster( - buffer - , w - , h - , bandOffsets.length * w - , bandOffsets.length - , bandOffsets - , null - ); - - ColorModel colorModel = new ComponentColorModel(ColorSpace.getInstance(awt_colorspace), false, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); - - BufferedImage image = new BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), null); - - ImageIO.write(image, "PNG", new File(path)); - } - -} diff --git a/src/com/Torvald/RasterWriter.kt b/src/com/Torvald/RasterWriter.kt new file mode 100644 index 000000000..182399e14 --- /dev/null +++ b/src/com/Torvald/RasterWriter.kt @@ -0,0 +1,51 @@ +package com.Torvald + +import com.Torvald.Terrarum.Terrarum + +import javax.imageio.ImageIO +import java.awt.* +import java.awt.color.ColorSpace +import java.awt.image.* +import java.io.File +import java.io.IOException + +/** + * Created by minjaesong on 16-03-04. + */ +object RasterWriter { + + val BANDOFFSET_RGB = intArrayOf(0, 1, 2) + val BANDOFFSET_RGBA = intArrayOf(0, 1, 2, 3) + val BANDOFFSET_ARGB = intArrayOf(3, 0, 1, 2) + val BANDOFFSET_MONO = intArrayOf(0) + + val COLORSPACE_SRGB = ColorSpace.CS_sRGB + val COLORSPACE_GRAY = ColorSpace.CS_GRAY + val COLORSPACE_GREY = COLORSPACE_GRAY + val COLORSPACE_CIEXYZ = ColorSpace.CS_CIEXYZ + val COLORSPACE_RGB_LINEAR_GAMMA = ColorSpace.CS_LINEAR_RGB + + @Throws(IOException::class) + fun writePNG_RGB(w: Int, h: Int, rasterData: ByteArray, path: String) { + writePNG(w, h, rasterData, BANDOFFSET_RGB, COLORSPACE_SRGB, path) + } + + @Throws(IOException::class) + fun writePNG_Mono(w: Int, h: Int, rasterData: ByteArray, path: String) { + writePNG(w, h, rasterData, BANDOFFSET_MONO, COLORSPACE_GREY, path) + } + + @Throws(IOException::class) + fun writePNG(w: Int, h: Int, rasterData: ByteArray, bandOffsets: IntArray, awt_colorspace: Int, path: String) { + val buffer = DataBufferByte(rasterData, rasterData.size) + val raster = Raster.createInterleavedRaster( + buffer, w, h, bandOffsets.size * w, bandOffsets.size, bandOffsets, null) + + val colorModel = ComponentColorModel(ColorSpace.getInstance(awt_colorspace), false, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE) + + val image = BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied, null) + + ImageIO.write(image, "PNG", File(path)) + } + +} diff --git a/src/com/Torvald/Serialise/WriteCSV.kt b/src/com/Torvald/Serialise/WriteCSV.kt new file mode 100644 index 000000000..8eafa130d --- /dev/null +++ b/src/com/Torvald/Serialise/WriteCSV.kt @@ -0,0 +1,65 @@ +package com.Torvald.Serialise + +import com.Torvald.CSVFetcher +import com.Torvald.Terrarum.ItemProperties.ItemPropCodex +import com.Torvald.Terrarum.ItemProperties.MaterialPropCodex +import com.Torvald.Terrarum.Terrarum +import com.Torvald.Terrarum.TileProperties.TilePropCodex +import java.io.IOException +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardCopyOption + +/** + * Created by minjaesong on 16-03-18. + */ +object WriteCSV { + val META_FILENAME_TILE = "worldinfo2" + val META_FILENAME_ITEM = "worldinfo3" + val META_FILENAME_MAT = "worldinfo4" + + fun write(saveDirectoryName: String): Boolean { + val tileCSV = CSVFetcher.readCSVasString(TilePropCodex.CSV_PATH) + val itemCSV = CSVFetcher.readCSVasString(ItemPropCodex.CSV_PATH) + val matCSV = CSVFetcher.readCSVasString(MaterialPropCodex.CSV_PATH) + + val pathTile = Paths.get("${Terrarum.defaultSaveDir}" + + "/$saveDirectoryName/${META_FILENAME_TILE}") + val pathItem = Paths.get("${Terrarum.defaultSaveDir}" + + "/$saveDirectoryName/${META_FILENAME_ITEM}") + val pathMat = Paths.get("${Terrarum.defaultSaveDir}" + + "/$saveDirectoryName/${META_FILENAME_MAT}") + val tempPathTile = Files.createTempFile(pathTile.toString(), "_temp") + val tempPathItem = Files.createTempFile(pathItem.toString(), "_temp") + val tempPathMat = Files.createTempFile(pathMat.toString(), "_temp") + + // TODO gzip + + // write CSV to path + Files.write(tempPathTile, tileCSV.toByteArray(Charsets.UTF_8)) + Files.write(tempPathItem, itemCSV.toByteArray(Charsets.UTF_8)) + Files.write(tempPathMat, matCSV.toByteArray(Charsets.UTF_8)) + + // replace savemeta with tempfile + try { + Files.copy(tempPathTile, pathTile, StandardCopyOption.REPLACE_EXISTING) + Files.deleteIfExists(tempPathTile) + + Files.copy(tempPathItem, pathItem, StandardCopyOption.REPLACE_EXISTING) + Files.deleteIfExists(tempPathItem) + + Files.copy(tempPathMat, pathMat, StandardCopyOption.REPLACE_EXISTING) + Files.deleteIfExists(tempPathMat) + + println("Saved map data '${WriteGameMapData.META_FILENAME}' to $saveDirectoryName.") + + return true + } + catch (e: IOException) { + e.printStackTrace() + } + return false + } + +} \ No newline at end of file diff --git a/src/com/Torvald/Serialise/WriteGameMapData.kt b/src/com/Torvald/Serialise/WriteGameMapData.kt new file mode 100644 index 000000000..9a41b8563 --- /dev/null +++ b/src/com/Torvald/Serialise/WriteGameMapData.kt @@ -0,0 +1,79 @@ +package com.Torvald.Serialise + +import com.Torvald.Terrarum.GameMap.GameMap +import com.Torvald.Terrarum.Terrarum +import java.io.IOException +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardCopyOption + +/** + * Created by minjaesong on 16-03-18. + */ +object WriteGameMapData { + + val META_FILENAME = "worldinfo1" + + val MAGIC: ByteArray = byteArrayOf( + 'T'.toByte(), + 'E'.toByte(), + 'M'.toByte(), + 'D'.toByte() + ) + + val BYTE_NULL: Byte = 0 + + + fun write(saveDirectoryName: String): Boolean { + val path = Paths.get("${Terrarum.defaultSaveDir}" + + "/$saveDirectoryName/${WriteMeta.META_FILENAME}") + val tempPath = Files.createTempFile(path.toString(), "_temp") + val map = Terrarum.game.map + + // TODO gzip + + // write binary + Files.write(tempPath, MAGIC) + Files.write(tempPath, byteArrayOf(GameMap.BITS)) + Files.write(tempPath, byteArrayOf(GameMap.LAYERS)) + Files.write(tempPath, byteArrayOf(BYTE_NULL)) + Files.write(tempPath, byteArrayOf(BYTE_NULL)) + Files.write(tempPath, toByteArray(map.width)) + Files.write(tempPath, toByteArray(map.height)) + Files.write(tempPath, toByteArray(map.spawnX)) + Files.write(tempPath, toByteArray(map.spawnY)) + map.layerTerrain.forEach( + {b -> Files.write(tempPath, byteArrayOf(b))}) + map.layerWall.forEach( + {b -> Files.write(tempPath, byteArrayOf(b))}) + map.terrainDamage.forEach( + {b -> Files.write(tempPath, byteArrayOf(b))}) + map.wallDamage.forEach( + {b -> Files.write(tempPath, byteArrayOf(b))}) + map.layerWire.forEach( + {b -> Files.write(tempPath, byteArrayOf(b))}) + + // replace savemeta with tempfile + try { + Files.copy(tempPath, path, StandardCopyOption.REPLACE_EXISTING) + Files.deleteIfExists(tempPath) + println("Saved map data '$META_FILENAME' to $saveDirectoryName.") + + return true + } + catch (e: IOException) { + e.printStackTrace() + } + return false + } + + fun toByteArray(int: Int): ByteArray { + return byteArrayOf( + ((int ushr 0x18) and 0xFF).toByte(), + ((int ushr 0x10) and 0xFF).toByte(), + ((int ushr 0x08) and 0xFF).toByte(), + ((int ) and 0xFF).toByte() + ) + } +} \ No newline at end of file diff --git a/src/com/Torvald/Serialise/WriteMeta.kt b/src/com/Torvald/Serialise/WriteMeta.kt index c44c3f045..f5af48c4e 100644 --- a/src/com/Torvald/Serialise/WriteMeta.kt +++ b/src/com/Torvald/Serialise/WriteMeta.kt @@ -2,10 +2,13 @@ package com.Torvald.Serialise import com.Torvald.Terrarum.MapGenerator.MapGenerator import com.Torvald.Terrarum.MapGenerator.RoguelikeRandomiser +import com.Torvald.Terrarum.Terrarum import com.Torvald.Terrarum.TileProperties.TilePropCodex import org.apache.commons.codec.digest.DigestUtils import java.io.FileInputStream import java.io.File +import java.io.IOException +import java.nio.file.* import java.util.* /** @@ -13,19 +16,31 @@ import java.util.* */ object WriteMeta { - val MAGIC: Array = arrayOf( - 'T'.toByte() - , 'E'.toByte() - , 'S'.toByte() - , 'V'.toByte() + val META_FILENAME = "world" + + val MAGIC: ByteArray = byteArrayOf( + 'T'.toByte(), + 'E'.toByte(), + 'S'.toByte(), + 'V'.toByte() ) + val BYTE_NULL: Byte = 0 + val terraseed: Long = MapGenerator.getGeneratorSeed() val rogueseed: Long = RoguelikeRandomiser.getGeneratorSeed() - fun write() { - var hashArray: ArrayList = ArrayList() + /** + * Write save meta to specified directory. Returns false if something went wrong. + * @param saveDirectoryName + * @param savegameName -- Nullable. If the value is not specified, saveDirectoryName will be used instead. + */ + fun write(saveDirectoryName: String, savegameName: String?): Boolean { + val hashArray: ArrayList = ArrayList() + val savenameAsByteArray: ByteArray = + (savegameName ?: saveDirectoryName).toByteArray(Charsets.UTF_8) + // define files to get hash val fileArray: Array = arrayOf( File(TilePropCodex.CSV_PATH) //, File(ItemPropCodex.CSV_PATH) @@ -33,11 +48,54 @@ object WriteMeta { //, ) + // get and store hash from fileArray for (file in fileArray) { val inputStream = FileInputStream(file) val hash = DigestUtils.sha256(inputStream) hashArray.add(hash) } + + // open file and delete it + val metaPath = Paths.get("${Terrarum.defaultSaveDir}" + + "/$saveDirectoryName/$META_FILENAME") + val metaTempPath = Files.createTempFile(metaPath.toString(), "_temp") + + // TODO gzip + + // write bytes in tempfile + Files.write(metaTempPath, MAGIC) + Files.write(metaTempPath, savenameAsByteArray) + Files.write(metaTempPath, byteArrayOf(BYTE_NULL)) + Files.write(metaTempPath, toByteArray(terraseed)) + Files.write(metaTempPath, toByteArray(rogueseed)) + for (hash in hashArray) + Files.write(metaTempPath, hash) + + // replace savemeta with tempfile + try { + Files.copy(metaTempPath, metaPath, StandardCopyOption.REPLACE_EXISTING) + Files.deleteIfExists(metaTempPath) + println("Saved metadata to $saveDirectoryName.") + + return true + } + catch (e: IOException) { + e.printStackTrace() + } + return false + } + + fun toByteArray(long: Long): ByteArray { + return byteArrayOf( + ((long ushr 0x38) and 0xFF).toByte(), + ((long ushr 0x30) and 0xFF).toByte(), + ((long ushr 0x28) and 0xFF).toByte(), + ((long ushr 0x20) and 0xFF).toByte(), + ((long ushr 0x18) and 0xFF).toByte(), + ((long ushr 0x10) and 0xFF).toByte(), + ((long ushr 0x08) and 0xFF).toByte(), + ((long ) and 0xFF).toByte() + ) } } \ No newline at end of file diff --git a/src/com/Torvald/SimpleCipher/ROTUtil.kt b/src/com/Torvald/SimpleCipher/ROTUtil.kt new file mode 100644 index 000000000..89316d54c --- /dev/null +++ b/src/com/Torvald/SimpleCipher/ROTUtil.kt @@ -0,0 +1,77 @@ +package com.Torvald.SimpleCipher + +/** + * Created by minjaesong on 16-03-20. + */ +object ROTUtil { + + const val CODE_CAP_A = 'A'.toInt() + const val CODE_LOW_A = 'a'.toInt() + + /** + * ROT encryption, default setting + * + * * Latin alph: removes diacritics and do ROT13, string reverse, capitalised. + * Ligatures are disassembled. Even if the target language does not have + * certain alphabet (e.g. C in Icelandic), such alphabet will be printed anyway. + * + * * Cyrillic: removes diacritics and do ROTnn, string reverse, capitalised. + * + * * Kana: raise Sutegana, ROT3 on vowels (a i u e o -> e o a i u), string reverse + * (Wa Wo -> Wo Wa), Nn will remain untouched, forced Katakana. + * + * * Hangul: ROT3 on initials\*, lower double initials to single + * (ㄱ ㄲ ㄴ ㄷ ㄸ ㄹ ㅁ ㅂ ㅃ ㅅ ㅆ ㅇ ㅈ ㅉ ㅊ ㅋ ㅌ ㅍ ㅎ -> ㄹ ㄹ ㅁ ㅂ ㅂ ㅅ ㅇ ㅇ ㅈ ㅈ ㅊ ㅋ ㅋ ㅌ ㅍ ㅎ ㄱ ㄴ ㄷ), + * string reverse + * + * * Chinese: NOT SUPPORTED + * + * * Numeric: no encrypt + */ + fun encrypt(plaintext: String): String { + + fun removeDiacritics(c: Char): Char { + val normaliseMap = hashMapOf( + Pair('À', "A"), + Pair('Á', "A"), + Pair('Â', "A"), + Pair('À', "A"), + Pair('Ã', "A"), + Pair('Å', "A"), + Pair('Æ', "AE"), + Pair('Ç', "C"), + Pair('È', "E"), + Pair('É', "E"), + Pair('Ê', "E"), + Pair('Ë', "E"), + Pair('Ì', "I"), + Pair('Í', "I"), + Pair('Î', "I"), + Pair('Ï', "I"), + Pair('Ð', "D") + ) + throw NotImplementedError("Feature WIP") + } + + throw NotImplementedError("Feature WIP") + } + + /** + * Note; range starts with zero + * @param number to rotate + * @param rotation + * @param range size of the rotation table. 4 means (0,1,2,3) + */ + fun rotN(number: Int, rotation: Int, range: Int): Int { + return if (number < range - rotation + 1) number + rotation + else number - (range - rotation + 1) + } + + fun rot13(c: Char): Char { + return if (c in 'a'..'z') + (rotN((c.toInt() - CODE_LOW_A), 13, 26) + CODE_LOW_A).toChar() + else if (c in 'A'..'Z') + (rotN((c.toInt() - CODE_CAP_A), 13, 26) + CODE_CAP_A).toChar() + else c + } +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/Actors/ActorInventory.kt b/src/com/Torvald/Terrarum/Actors/ActorInventory.kt index 889b364e1..72b3f52c9 100644 --- a/src/com/Torvald/Terrarum/Actors/ActorInventory.kt +++ b/src/com/Torvald/Terrarum/Actors/ActorInventory.kt @@ -1,14 +1,14 @@ package com.Torvald.Terrarum.Actors import com.Torvald.Terrarum.GameItem.InventoryItem -import com.Torvald.Terrarum.GameItem.ItemPropCodex +import com.Torvald.Terrarum.ItemProperties.ItemPropCodex import java.util.* /** * Created by minjaesong on 16-03-15. */ -class ActorInventory { +class ActorInventory() { @Transient val CAPACITY_MAX = 0x7FFFFFFF @Transient val CAPACITY_MODE_NO_ENCUMBER = 0 @@ -16,22 +16,31 @@ class ActorInventory { @Transient val CAPACITY_MODE_WEIGHT = 2 - private var capacityByCount: Int = 0 - private var capacityByWeight: Int = 0 - private var capacityMode: Int = 0 + private var capacityByCount: Int + private var capacityByWeight: Int + private var capacityMode: Int /** * <ReferenceID, Amounts> */ private val itemList: HashMap = HashMap() + /** + * Default constructor with no encumbrance. + */ + init { + capacityMode = CAPACITY_MODE_NO_ENCUMBER + capacityByCount = 0 + capacityByWeight = 0 + } + /** * Construct new inventory with specified capacity. * @param capacity if is_weight is true, killogramme value is required, counts of items otherwise. * * * @param is_weight whether encumbrance should be calculated upon the weight of the inventory. False to use item counts. */ - constructor(capacity: Int, is_weight: Boolean) { + constructor(capacity: Int, is_weight: Boolean) : this() { if (is_weight) { capacityByWeight = capacity capacityMode = CAPACITY_MODE_WEIGHT @@ -81,7 +90,7 @@ class ActorInventory { var weight = 0f for (item in itemList.entries) { - weight += ItemPropCodex.getItem(item.key).weight * item.value + weight += ItemPropCodex.getItem(item.key).mass * item.value } return weight diff --git a/src/com/Torvald/Terrarum/Actors/ActorValue.java b/src/com/Torvald/Terrarum/Actors/ActorValue.java deleted file mode 100644 index 9b8640b24..000000000 --- a/src/com/Torvald/Terrarum/Actors/ActorValue.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.Torvald.Terrarum.Actors; - -import com.Torvald.Terrarum.KVHashMap; - -/** - * Created by minjaesong on 16-01-03. - */ -public class ActorValue extends KVHashMap { - -} diff --git a/src/com/Torvald/Terrarum/Actors/ActorValue.kt b/src/com/Torvald/Terrarum/Actors/ActorValue.kt new file mode 100644 index 000000000..6d98c83fa --- /dev/null +++ b/src/com/Torvald/Terrarum/Actors/ActorValue.kt @@ -0,0 +1,8 @@ +package com.Torvald.Terrarum.Actors + +import com.Torvald.Terrarum.KVHashMap + +/** + * Created by minjaesong on 16-03-19. + */ +class ActorValue : KVHashMap() \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/Actors/ActorWithBody.kt b/src/com/Torvald/Terrarum/Actors/ActorWithBody.kt index c80d20a51..f92a7a550 100644 --- a/src/com/Torvald/Terrarum/Actors/ActorWithBody.kt +++ b/src/com/Torvald/Terrarum/Actors/ActorWithBody.kt @@ -252,10 +252,8 @@ open class ActorWithBody constructor() : Actor, Visible, Glowing { val A = scale * scale val D = DRAG_COEFF * 0.5f * 1.292f * veloY * veloY * A - val fluidResistance = tileMvmtRstc - veloY += clampCeil( - (W - D) / mass * SI_TO_GAME_ACC * G_MUL_PLAYABLE_CONST, VELO_HARD_LIMIT)// * mvmtRstcToMultiplier(fluidResistance) // eliminate shoot-up from fluids + (W - D) / mass * SI_TO_GAME_ACC * G_MUL_PLAYABLE_CONST, VELO_HARD_LIMIT) } } @@ -406,30 +404,6 @@ open class ActorWithBody constructor() : Actor, Visible, Glowing { // set tile positions val tileX: Int val tileY: Int - /*if (side == CONTACT_AREA_BOTTOM) { - tileX = div16TruncateToMapWidth(Math.round(nextHitbox.getHitboxStart().getX()) - + i + translateX); - tileY = div16TruncateToMapHeight(FastMath.floor(nextHitbox.getHitboxEnd().getY()) - + translateY); - } - else if (side == CONTACT_AREA_TOP) { - tileX = div16TruncateToMapWidth(Math.round(nextHitbox.getHitboxStart().getX()) - + i + translateX); - tileY = div16TruncateToMapHeight(FastMath.ceil(nextHitbox.getHitboxStart().getY()) - + translateY); - } - else if (side == CONTACT_AREA_RIGHT) { - tileX = div16TruncateToMapWidth(FastMath.floor(nextHitbox.getHitboxEnd().getX()) - + translateX); - tileY = div16TruncateToMapHeight(Math.round(nextHitbox.getHitboxStart().getY()) - + i + translateY); - } - else if (side == CONTACT_AREA_LEFT) { - tileX = div16TruncateToMapWidth(FastMath.ceil(nextHitbox.getHitboxStart().getX()) - + translateX); - tileY = div16TruncateToMapHeight(Math.round(nextHitbox.getHitboxStart().getY()) - + i + translateY); - }*/ if (side == CONTACT_AREA_BOTTOM) { tileX = div16TruncateToMapWidth(Math.round(nextHitbox!!.hitboxStart.x) + i + translateX) @@ -459,6 +433,41 @@ open class ActorWithBody constructor() : Actor, Visible, Glowing { return contactAreaCounter } + private fun getContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int { + var contactAreaCounter = 0 + for (i in 0..Math.round(if (side % 2 == 0) nextHitbox!!.width else nextHitbox!!.height) - 1) { + // set tile positions + val tileX: Int + val tileY: Int + if (side == CONTACT_AREA_BOTTOM) { + tileX = div16TruncateToMapWidth(Math.round(nextHitbox!!.hitboxStart.x) + + i + translateX) + tileY = div16TruncateToMapHeight(Math.round(nextHitbox!!.hitboxEnd.y) + translateY) + } else if (side == CONTACT_AREA_TOP) { + tileX = div16TruncateToMapWidth(Math.round(nextHitbox!!.hitboxStart.x) + + i + translateX) + tileY = div16TruncateToMapHeight(Math.round(nextHitbox!!.hitboxStart.y) + translateY) + } else if (side == CONTACT_AREA_RIGHT) { + tileX = div16TruncateToMapWidth(Math.round(nextHitbox!!.hitboxEnd.x) + translateX) + tileY = div16TruncateToMapHeight(Math.round(nextHitbox!!.hitboxStart.y) + + i + translateY) + } else if (side == CONTACT_AREA_LEFT) { + tileX = div16TruncateToMapWidth(Math.round(nextHitbox!!.hitboxStart.x) + translateX) + tileY = div16TruncateToMapHeight(Math.round(nextHitbox!!.hitboxStart.y) + + i + translateY) + } else { + throw IllegalArgumentException(side.toString() + ": Wrong side input") + } + + // evaluate + if (TilePropCodex.getProp(map.getTileFromTerrain(tileX, tileY)).isFluid) { + contactAreaCounter += 1 + } + } + + return contactAreaCounter + } + /** * [N] = [kg * m / s^2] * F(bo) = density * submerged_volume * gravitational_acceleration [N] @@ -476,52 +485,25 @@ open class ActorWithBody constructor() : Actor, Visible, Glowing { } } - private //System.out.println("fluidHeight: "+fluidHeight+", submerged: "+submergedVolume); - //submergedHeight / TILE_SIZE * 1^2 (pixel to meter) - val submergedVolume: Float - get() { - val GAME_TO_SI_VOL = FastMath.pow(1f / METER, 3f) - - if (density > 0) { - return submergedHeight * - nextHitbox!!.width * nextHitbox!!.width * - GAME_TO_SI_VOL - } else { - return 0f - } - } + private val submergedVolume: Float + get() = submergedHeight * hitbox!!.width * hitbox!!.width private val submergedHeight: Float - get() = FastMath.clamp( - nextHitbox!!.pointedY - fluidLevel, 0f, nextHitbox!!.height) + get() = Math.max( + getContactingAreaFluid(CONTACT_AREA_LEFT), + getContactingAreaFluid(CONTACT_AREA_RIGHT) + ).toFloat() - private val fluidLevel: Int - get() { - val tilePosXStart = Math.round(nextHitbox!!.posX / TSIZE) - val tilePosXEnd = Math.round(nextHitbox!!.hitboxEnd.x / TSIZE) - val tilePosY = Math.round(nextHitbox!!.posY / TSIZE) - - var fluidHeight = 2147483647 - - for (x in tilePosXStart..tilePosXEnd) { - val tile = map.getTileFromTerrain(x, tilePosY) - if (TilePropCodex.getProp(tile).isFluid && tilePosY * TSIZE < fluidHeight) { - fluidHeight = tilePosY * TSIZE - } - } - - return fluidHeight - } /** * Get highest friction value from feet tiles. * @return */ - private //get density - val tileFriction: Int + private val tileFriction: Int get() { var friction = 0 + //get highest fluid density val tilePosXStart = Math.round(nextHitbox!!.posX / TSIZE) val tilePosXEnd = Math.round(nextHitbox!!.hitboxEnd.x / TSIZE) val tilePosY = Math.round(nextHitbox!!.pointedY / TSIZE) @@ -541,11 +523,11 @@ open class ActorWithBody constructor() : Actor, Visible, Glowing { * Get highest movement resistance value from tiles that the body occupies. * @return */ - private //get density - val tileMvmtRstc: Int + private val tileMvmtRstc: Int get() { var resistance = 0 + //get highest fluid density val tilePosXStart = Math.round(nextHitbox!!.posX / TSIZE) val tilePosYStart = Math.round(nextHitbox!!.posY / TSIZE) val tilePosXEnd = Math.round(nextHitbox!!.hitboxEnd.x / TSIZE) @@ -568,11 +550,11 @@ open class ActorWithBody constructor() : Actor, Visible, Glowing { * Get highest density (specific gravity) value from tiles that the body occupies. * @return */ - private //get density - val tileDensity: Int + private val tileDensity: Int get() { var density = 0 + //get highest fluid density val tilePosXStart = Math.round(nextHitbox!!.posX / TSIZE) val tilePosYStart = Math.round(nextHitbox!!.posY / TSIZE) val tilePosXEnd = Math.round(nextHitbox!!.hitboxEnd.x / TSIZE) @@ -608,18 +590,19 @@ open class ActorWithBody constructor() : Actor, Visible, Glowing { private fun updateNextHitboxFromVelo() { val fluidResistance = mvmtRstcToMultiplier(tileMvmtRstc) val submergedRatio = FastMath.clamp( - submergedHeight / nextHitbox!!.height, 0f, 1f) - - val applyResistance = !isNoSubjectToFluidResistance && submergedRatio > FLUID_RESISTANCE_IGNORE_THRESHOLD_RATIO - val resistanceMulInterValueSize = FLUID_RESISTANCE_APPLY_FULL_RATIO - FLUID_RESISTANCE_IGNORE_THRESHOLD_RATIO - val resistanceMultiplier = FastMath.interpolateLinear( - (submergedRatio - FLUID_RESISTANCE_IGNORE_THRESHOLD_RATIO) * FastMath.pow(resistanceMulInterValueSize, -1f), 0f, 1f) - val adjustedResistance = FastMath.interpolateLinear( - resistanceMultiplier, 1f, fluidResistance) + submergedHeight / nextHitbox!!.height, + 0f, 1f + ) + val applyResistance: Boolean = !isNoSubjectToFluidResistance + && submergedRatio > FLUID_RESISTANCE_IGNORE_THRESHOLD_RATIO + val resistance: Float = FastMath.interpolateLinear( + submergedRatio, + 1f, fluidResistance + ) nextHitbox!!.set( - Math.round(hitbox!!.posX + veloX * (if (!applyResistance) 1f else adjustedResistance)).toFloat() - , Math.round(hitbox!!.posY + veloY * (if (!applyResistance) 1f else adjustedResistance)).toFloat() + Math.round(hitbox!!.posX + veloX * (if (!applyResistance) 1f else resistance)).toFloat() + , Math.round(hitbox!!.posY + veloY * (if (!applyResistance) 1f else resistance)).toFloat() , Math.round(baseHitboxW * scale).toFloat() , Math.round(baseHitboxH * scale).toFloat()) /** Full quantisation; wonder what havoc these statements would wreak... @@ -658,12 +641,12 @@ open class ActorWithBody constructor() : Actor, Visible, Glowing { } } - override fun updateGlowSprite(gc: GameContainer, delta_t: Int) { - if (spriteGlow != null) spriteGlow!!.update(delta_t) + override fun updateGlowSprite(gc: GameContainer, delta: Int) { + if (spriteGlow != null) spriteGlow!!.update(delta) } - override fun updateBodySprite(gc: GameContainer, delta_t: Int) { - if (sprite != null) sprite!!.update(delta_t) + override fun updateBodySprite(gc: GameContainer, delta: Int) { + if (sprite != null) sprite!!.update(delta) } private fun clampW(x: Float): Float { diff --git a/src/com/Torvald/Terrarum/Actors/Faction/Faction.java b/src/com/Torvald/Terrarum/Actors/Faction/Faction.java deleted file mode 100644 index 3060054fb..000000000 --- a/src/com/Torvald/Terrarum/Actors/Faction/Faction.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.Torvald.Terrarum.Actors.Faction; - -import java.util.HashSet; - -/** - * Created by minjaesong on 16-02-15. - */ -public class Faction { - - private String factionName; - private HashSet factionAmicable; - private HashSet factionNeutral; - private HashSet factionHostile; - private HashSet factionFearful; - - public Faction(String factionName) { - this.factionName = factionName; - factionAmicable = new HashSet<>(); - factionNeutral = new HashSet<>(); - factionHostile = new HashSet<>(); - factionFearful = new HashSet<>(); - } - - public String getFactionName() { - return factionName; - } - - public void renewFactionName(String factionName) { - this.factionName = factionName; - } - - public HashSet getFactionFearful() { - return factionFearful; - } - - public void setFactionFearful(HashSet factionFearful) { - this.factionFearful = factionFearful; - } - - public HashSet getFactionAmicable() { - return factionAmicable; - } - - public void setFactionAmicable(HashSet factionAmicable) { - this.factionAmicable = factionAmicable; - } - - public HashSet getFactionNeutral() { - return factionNeutral; - } - - public void setFactionNeutral(HashSet factionNeutral) { - this.factionNeutral = factionNeutral; - } - - public HashSet getFactionHostile() { - return factionHostile; - } - - public void setFactionHostile(HashSet factionHostile) { - this.factionHostile = factionHostile; - } - - public void addFactionAmicable(String faction) { - factionAmicable.add(faction); - } - - public void addFactionNeutral(String faction) { - factionNeutral.add(faction); - } - - public void addFactionHostile(String faction) { - factionHostile.add(faction); - } - - public void addFactionFearful(String faction) { - factionFearful.add(faction); - } - - public void removeFactionAmicable(String faction) { - factionAmicable.remove(faction); - } - - public void removeFactionNeutral(String faction) { - factionNeutral.remove(faction); - } - - public void removeFactionHostile(String faction) { - factionHostile.remove(faction); - } - - public void removeFactionFearful(String faction) { - factionFearful.remove(faction); - } - -} diff --git a/src/com/Torvald/Terrarum/Actors/Faction/Faction.kt b/src/com/Torvald/Terrarum/Actors/Faction/Faction.kt new file mode 100644 index 000000000..b03817944 --- /dev/null +++ b/src/com/Torvald/Terrarum/Actors/Faction/Faction.kt @@ -0,0 +1,60 @@ +package com.Torvald.Terrarum.Actors.Faction + +import java.util.HashSet + +/** + * Created by minjaesong on 16-02-15. + */ +class Faction(factionName: String) { + + lateinit var factionName: String + lateinit var factionAmicable: HashSet + lateinit var factionNeutral: HashSet + lateinit var factionHostile: HashSet + lateinit var factionFearful: HashSet + + init { + this.factionName = factionName + factionAmicable = HashSet() + factionNeutral = HashSet() + factionHostile = HashSet() + factionFearful = HashSet() + } + + fun renewFactionName(factionName: String) { + this.factionName = factionName + } + + fun addFactionAmicable(faction: String) { + factionAmicable.add(faction) + } + + fun addFactionNeutral(faction: String) { + factionNeutral.add(faction) + } + + fun addFactionHostile(faction: String) { + factionHostile.add(faction) + } + + fun addFactionFearful(faction: String) { + factionFearful.add(faction) + } + + fun removeFactionAmicable(faction: String) { + factionAmicable.remove(faction) + } + + fun removeFactionNeutral(faction: String) { + factionNeutral.remove(faction) + } + + fun removeFactionHostile(faction: String) { + factionHostile.remove(faction) + } + + fun removeFactionFearful(faction: String) { + factionFearful.remove(faction) + } + +} diff --git a/src/com/Torvald/Terrarum/Actors/Faction/FactionRelatorFactory.java b/src/com/Torvald/Terrarum/Actors/Faction/FactionRelatorFactory.java deleted file mode 100644 index 06182e65d..000000000 --- a/src/com/Torvald/Terrarum/Actors/Faction/FactionRelatorFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.Torvald.Terrarum.Actors.Faction; - -import com.Torvald.JsonFetcher; -import com.google.gson.JsonObject; - -import java.io.IOException; - -/** - * Created by minjaesong on 16-02-15. - */ -public class FactionRelatorFactory { - - private static final String JSONPATH = "./res/raw/"; - - public Faction build(String filename) throws IOException { - JsonObject jsonObj = JsonFetcher.readJson(JSONPATH + filename); - Faction factionObj = new Faction(jsonObj.get("factionname").getAsString()); - - - jsonObj.get("factionamicable").getAsJsonArray().forEach( - s -> factionObj.addFactionAmicable(s.getAsString()) - ); - jsonObj.get("factionneutral").getAsJsonArray().forEach( - s -> factionObj.addFactionNeutral(s.getAsString()) - ); - jsonObj.get("factionhostile").getAsJsonArray().forEach( - s -> factionObj.addFactionHostile(s.getAsString()) - ); - jsonObj.get("factionfearful").getAsJsonArray().forEach( - s -> factionObj.addFactionFearful(s.getAsString()) - ); - - return factionObj; - } - -} diff --git a/src/com/Torvald/Terrarum/Actors/Faction/FactionRelatorFactory.kt b/src/com/Torvald/Terrarum/Actors/Faction/FactionRelatorFactory.kt new file mode 100644 index 000000000..1f8a9abab --- /dev/null +++ b/src/com/Torvald/Terrarum/Actors/Faction/FactionRelatorFactory.kt @@ -0,0 +1,32 @@ +package com.Torvald.Terrarum.Actors.Faction + +import com.Torvald.JsonFetcher +import com.google.gson.JsonObject + +import java.io.IOException + +/** + * Created by minjaesong on 16-02-15. + */ +class FactionRelatorFactory { + + @Throws(IOException::class) + fun build(filename: String): Faction { + val jsonObj = JsonFetcher.readJson(JSONPATH + filename) + val factionObj = Faction(jsonObj.get("factionname").asString) + + + jsonObj.get("factionamicable").asJsonArray.forEach { s -> factionObj.addFactionAmicable(s.asString) } + jsonObj.get("factionneutral").asJsonArray.forEach { s -> factionObj.addFactionNeutral(s.asString) } + jsonObj.get("factionhostile").asJsonArray.forEach { s -> factionObj.addFactionHostile(s.asString) } + jsonObj.get("factionfearful").asJsonArray.forEach { s -> factionObj.addFactionFearful(s.asString) } + + return factionObj + } + + companion object { + + val JSONPATH = "./res/raw/" + } + +} diff --git a/src/com/Torvald/Terrarum/Actors/Factionable.kt b/src/com/Torvald/Terrarum/Actors/Factionable.kt index cad117824..912e8248e 100644 --- a/src/com/Torvald/Terrarum/Actors/Factionable.kt +++ b/src/com/Torvald/Terrarum/Actors/Factionable.kt @@ -8,8 +8,6 @@ import java.util.* */ interface Factionable { - fun assignFaction(f: Faction) - fun unassignFaction(f: Faction) - var faction: HashSet? + var faction: HashSet } \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/Actors/ItemProperties/Material.java b/src/com/Torvald/Terrarum/Actors/ItemProperties/Material.java deleted file mode 100644 index 9c74cf3ea..000000000 --- a/src/com/Torvald/Terrarum/Actors/ItemProperties/Material.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.Torvald.Terrarum.Actors.ItemProperties; - -/** - * Created by minjaesong on 16-03-06. - */ -public class Material { - - /** How sharp the material is. Default to 1000.*/ - int maxEdge; - /** Self-explanatory. [kPa in Vickers hardness]*/ - int hardness; - /** Self-explanatory. [g/l]*/ - int density; - - public Material() { - } - - public int getMaxEdge() { - return maxEdge; - } - - void setMaxEdge(int maxEdge) { - this.maxEdge = maxEdge; - } - - public int getHardness() { - return hardness; - } - - void setHardness(int hardness) { - this.hardness = hardness; - } - - public int getDensity() { - return density; - } - - void setDensity(int density) { - this.density = density; - } -} diff --git a/src/com/Torvald/Terrarum/Actors/ItemProperties/MaterialFactory.java b/src/com/Torvald/Terrarum/Actors/ItemProperties/MaterialFactory.java deleted file mode 100644 index 1eb09d4d7..000000000 --- a/src/com/Torvald/Terrarum/Actors/ItemProperties/MaterialFactory.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.Torvald.Terrarum.Actors.ItemProperties; - -/** - * Created by minjaesong on 16-03-06. - */ -public class MaterialFactory { - - /** - * Load from CSV - */ - -} diff --git a/src/com/Torvald/Terrarum/Actors/NPCIntelligentBase.kt b/src/com/Torvald/Terrarum/Actors/NPCIntelligentBase.kt index b9eda19a9..f5a1cd3de 100644 --- a/src/com/Torvald/Terrarum/Actors/NPCIntelligentBase.kt +++ b/src/com/Torvald/Terrarum/Actors/NPCIntelligentBase.kt @@ -17,7 +17,17 @@ open class NPCIntelligentBase : ActorWithBody() override var itemData: InventoryItem = object : InventoryItem { override var itemID = HQRNG().nextLong() - override var weight = 0f + override var mass: Float + get() = actorValue.get("mass") as Float + set(value) { + actorValue.set("mass", value) + } + + override var scale: Float + get() = actorValue.get("scale") as Float + set(value) { + actorValue.set("scale", value) + } override fun effectWhileInPocket(gc: GameContainer, delta_t: Int) { @@ -41,13 +51,13 @@ open class NPCIntelligentBase : ActorWithBody() } @Transient private var ai: ActorAI? = null - override var inventory: ActorInventory? = null + override var inventory: ActorInventory = ActorInventory() private val factionSet = HashSet() override var referenceID: Long = HQRNG().nextLong() - override var faction: HashSet? = null + override var faction: HashSet = HashSet() override var houseDesignation: ArrayList? = null /** @@ -56,14 +66,6 @@ open class NPCIntelligentBase : ActorWithBody() */ private var houseTiles = ArrayList() - override fun assignFaction(f: Faction) { - factionSet.add(f) - } - - override fun unassignFaction(f: Faction) { - factionSet.remove(f) - } - override fun attachItemData() { } diff --git a/src/com/Torvald/Terrarum/Actors/PFSigrid.kt b/src/com/Torvald/Terrarum/Actors/PFSigrid.kt index 04289aacc..15dc20294 100644 --- a/src/com/Torvald/Terrarum/Actors/PFSigrid.kt +++ b/src/com/Torvald/Terrarum/Actors/PFSigrid.kt @@ -69,13 +69,13 @@ object PFSigrid { p.setPosition((4096 * 16).toFloat(), (300 * 16).toFloat()) - p.assignFaction(loadFactioningData("FactionSigrid.json")) + p.faction.add(loadFactioningData("FactionSigrid.json")) return p } private fun loadFactioningData(filename: String): Faction { - var jsonObject: JsonObject? = null + var jsonObject: JsonObject = JsonObject() try { jsonObject = JsonFetcher.readJson(FACTION_PATH + filename) } catch (e: IOException) { @@ -83,7 +83,7 @@ object PFSigrid { System.exit(-1) } - val faction = Faction(jsonObject!!.get("factionname").asString) + val faction = Faction(jsonObject.get("factionname").asString) jsonObject.get("factionamicable").asJsonArray.forEach { jobj -> faction.addFactionAmicable(jobj.asString) } jsonObject.get("factionneutral").asJsonArray.forEach { jobj -> faction.addFactionNeutral(jobj.asString) } diff --git a/src/com/Torvald/Terrarum/Actors/Player.kt b/src/com/Torvald/Terrarum/Actors/Player.kt index 9f8e9f9b2..3b6312f04 100644 --- a/src/com/Torvald/Terrarum/Actors/Player.kt +++ b/src/com/Torvald/Terrarum/Actors/Player.kt @@ -61,16 +61,20 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan @Transient private val BASE_DENSITY = 1020 /** Must be set by PlayerFactory */ - override var inventory: ActorInventory? = null + override var inventory: ActorInventory = ActorInventory() /** Must be set by PlayerFactory */ - override var faction: HashSet? = null + override var faction: HashSet = HashSet() override var houseDesignation: ArrayList? = null override var luminosity: Char - get() = if (actorValue.get("luminosity") != null) actorValue.getAsInt("luminosity").toChar() - else 0 as Char + get() { + if (actorValue.get("luminosity") != null) + return actorValue.getAsInt("luminosity")!!.toChar() + else + return 0.toChar() + } set(value) { actorValue.set("luminosity", value) } @@ -115,8 +119,8 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan } private fun updatePhysicalInfos() { - scale = actorValue.getAsFloat("scale") - mass = actorValue.getAsFloat("basemass") * FastMath.pow(scale, 3f) + scale = actorValue.getAsFloat("scale")!! + mass = actorValue.getAsFloat("basemass")!! * FastMath.pow(scale, 3f) if (elasticity != 0f) elasticity = 0f } @@ -129,8 +133,8 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan private fun walkHorizontal(left: Boolean, absAxisVal: Float) { //if ((!super.isWalledLeft() && left) || (!super.isWalledRight() && !left)) { readonly_totalX = veloX + - actorValue.getAsFloat("accel") * - actorValue.getAsFloat("accelmult") * + actorValue.getAsFloat("accel")!! * + actorValue.getAsFloat("accelmult")!! * FastMath.sqrt(scale) * applyAccelRealism(walkPowerCounter) * (if (left) -1 else 1).toFloat() * @@ -143,8 +147,8 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan } // Clamp veloX - veloX = absClamp(veloX, actorValue.getAsFloat("speed") - * actorValue.getAsFloat("speedmult") + veloX = absClamp(veloX, actorValue.getAsFloat("speed")!! + * actorValue.getAsFloat("speedmult")!! * FastMath.sqrt(scale)) // Heading flag @@ -163,8 +167,8 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan */ private fun walkVertical(up: Boolean, absAxisVal: Float) { readonly_totalY = veloY + - actorValue.getAsFloat("accel") * - actorValue.getAsFloat("accelmult") * + actorValue.getAsFloat("accel")!! * + actorValue.getAsFloat("accelmult")!! * FastMath.sqrt(scale) * applyAccelRealism(walkPowerCounter) * (if (up) -1 else 1).toFloat() * @@ -177,8 +181,8 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan } // Clamp veloX - veloY = absClamp(veloY, actorValue.getAsFloat("speed") - * actorValue.getAsFloat("speedmult") + veloY = absClamp(veloY, actorValue.getAsFloat("speed")!! + * actorValue.getAsFloat("speedmult")!! * FastMath.sqrt(scale)) } @@ -211,15 +215,15 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan private fun walkHStop() { if (veloX > 0) { - veloX -= actorValue.getAsFloat("accel") * - actorValue.getAsFloat("accelmult") * + veloX -= actorValue.getAsFloat("accel")!! * + actorValue.getAsFloat("accelmult")!! * FastMath.sqrt(scale) // compensate overshoot if (veloX < 0) veloX = 0f } else if (veloX < 0) { - veloX += actorValue.getAsFloat("accel") * - actorValue.getAsFloat("accelmult") * + veloX += actorValue.getAsFloat("accel")!! * + actorValue.getAsFloat("accelmult")!! * FastMath.sqrt(scale) // compensate overshoot @@ -234,7 +238,7 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan private fun walkVStop() { if (veloY > 0) { veloY -= WALK_STOP_ACCEL * - actorValue.getAsFloat("accelmult") * + actorValue.getAsFloat("accelmult")!! * FastMath.sqrt(scale) // compensate overshoot @@ -242,7 +246,7 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan veloY = 0f } else if (veloY < 0) { veloY += WALK_STOP_ACCEL * - actorValue.getAsFloat("accelmult") * + actorValue.getAsFloat("accelmult")!! * FastMath.sqrt(scale) // compensate overshoot @@ -406,22 +410,10 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan private fun jump() { if (jumping) { val len = MAX_JUMP_LENGTH.toFloat() - val pwr = actorValue.getAsFloat("jumppower") + val pwr = actorValue.getAsFloat("jumppower")!! // increment jump counter if (jumpCounter < len) jumpCounter += 1 - // quadratic time (convex) mode - /* - float sumT = (jumpCounter * (jumpCounter + 1)) / 2f; - float timedJumpCharge = ((len + 1) / 2f) - (sumT / len); - if (timedJumpCharge < 0) timedJumpCharge = 0; - - float jumpAcc = pwr * timedJumpCharge * JUMP_ACCELERATION_MOD; - - super.setVeloY(veloY - - jumpAcc - ); - */ // linear time mode val init = (len + 1) / 2f @@ -432,7 +424,7 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan veloY -= jumpAcc - // concave mode? + // try concave mode? } // for mob AI: @@ -501,14 +493,6 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan return actorValue } - override fun assignFaction(f: Faction) { - factionSet.add(f) - } - - override fun unassignFaction(f: Faction) { - factionSet.remove(f) - } - override fun addHouseTile(x: Int, y: Int) { throw UnsupportedOperationException() } diff --git a/src/com/Torvald/Terrarum/Actors/Pocketed.kt b/src/com/Torvald/Terrarum/Actors/Pocketed.kt index c2ff9625f..b482f0e21 100644 --- a/src/com/Torvald/Terrarum/Actors/Pocketed.kt +++ b/src/com/Torvald/Terrarum/Actors/Pocketed.kt @@ -5,6 +5,6 @@ package com.Torvald.Terrarum.Actors */ interface Pocketed { - var inventory: ActorInventory? + var inventory: ActorInventory } \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Authenticator.java b/src/com/Torvald/Terrarum/ConsoleCommand/Authenticator.java deleted file mode 100644 index 8d13a2e5d..000000000 --- a/src/com/Torvald/Terrarum/ConsoleCommand/Authenticator.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.Torvald.Terrarum.ConsoleCommand; - -import com.Torvald.Terrarum.Terrarum; -import com.Torvald.Terrarum.UserInterface.ConsoleWindow; -import org.apache.commons.codec.digest.DigestUtils; - -/** - * Created by minjaesong on 16-02-19. - */ -public class Authenticator implements ConsoleCommand { - - private static boolean a = false; - - @Override - public void execute(String[] args) { - if (args.length == 2) { - String pwd = args[1]; - String hashedPwd = DigestUtils.sha256Hex(pwd); - - if ("54c5b3dd459d5ef778bb2fa1e23a5fb0e1b62ae66970bcb436e8f81a1a1a8e41" - .equalsIgnoreCase(hashedPwd)) { // alpine - String msg = (a) ? "Locked" : "Authenticated"; - new Echo().execute(msg); - System.out.println("[Authenticator] " + msg); - a = !a; - ((ConsoleWindow) (Terrarum.game.consoleHandler.getUI())).reset(); - } - else { - printUsage(); // thou shalt not pass! - } - } - else { - printUsage(); - } - } - - public boolean b() { - return a; - } - - @Override - public void printUsage() { - CommandInterpreter.echoUnknownCmd("auth"); - } -} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Authenticator.kt b/src/com/Torvald/Terrarum/ConsoleCommand/Authenticator.kt new file mode 100644 index 000000000..831af50f2 --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/Authenticator.kt @@ -0,0 +1,46 @@ +package com.Torvald.Terrarum.ConsoleCommand + +import com.Torvald.Terrarum.Terrarum +import com.Torvald.Terrarum.UserInterface.ConsoleWindow +import org.apache.commons.codec.digest.DigestUtils + +/** + * Created by minjaesong on 16-02-19. + */ +class Authenticator : ConsoleCommand { + + override fun execute(args: Array) { + if (args.size == 2) { + val pwd = args[1] + val hashedPwd = DigestUtils.sha256Hex(pwd) + + if ("54c5b3dd459d5ef778bb2fa1e23a5fb0e1b62ae66970bcb436e8f81a1a1a8e41".equals(hashedPwd, ignoreCase = true)) { + // alpine + val msg = if (a) "Locked" else "Authenticated" + Echo().execute(msg) + println("[Authenticator] " + msg) + a = !a + (Terrarum.game.consoleHandler.UI as ConsoleWindow).reset() + } + else { + printUsage() // thou shalt not pass! + } + } + else { + printUsage() + } + } + + fun b(): Boolean { + return a + } + + override fun printUsage() { + CommandInterpreter.echoUnknownCmd("auth") + } + + companion object { + + private var a = false + } +} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Batch.java b/src/com/Torvald/Terrarum/ConsoleCommand/Batch.java deleted file mode 100644 index 0837e34ed..000000000 --- a/src/com/Torvald/Terrarum/ConsoleCommand/Batch.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.Torvald.Terrarum.ConsoleCommand; - -import java.nio.file.FileSystems; -import java.nio.file.Files; - -/** - * Created by minjaesong on 16-03-07. - */ -public class Batch implements ConsoleCommand { - @Override - public void execute(String[] args) throws Exception { - if (args.length == 2) { - Files.lines(FileSystems.getDefault().getPath(args[1])).forEach - (CommandInterpreter::execute); - } - else { - printUsage(); - } - } - - @Override - public void printUsage() { - new Echo().execute("batch path/to/batch.txt"); - } -} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Batch.kt b/src/com/Torvald/Terrarum/ConsoleCommand/Batch.kt new file mode 100644 index 000000000..1f3a04450 --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/Batch.kt @@ -0,0 +1,24 @@ +package com.Torvald.Terrarum.ConsoleCommand + +import java.nio.file.FileSystems +import java.nio.file.Files + +/** + * Created by minjaesong on 16-03-07. + */ +class Batch : ConsoleCommand { + @Throws(Exception::class) + override fun execute(args: Array) { + if (args.size == 2) { + Files.lines(FileSystems.getDefault().getPath(args[1])).forEach( + { CommandInterpreter.execute(it) }) + } + else { + printUsage() + } + } + + override fun printUsage() { + Echo().execute("batch path/to/batch.txt") + } +} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/CodexEdictis.java b/src/com/Torvald/Terrarum/ConsoleCommand/CodexEdictis.java deleted file mode 100644 index 220b65e68..000000000 --- a/src/com/Torvald/Terrarum/ConsoleCommand/CodexEdictis.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.Torvald.Terrarum.ConsoleCommand; - -import com.Torvald.Terrarum.Game; -import com.Torvald.Terrarum.LangPack.Lang; -import com.Torvald.Terrarum.UserInterface.ConsoleWindow; - -import java.util.Formatter; - -/** - * Created by minjaesong on 16-01-16. - */ -public class CodexEdictis implements ConsoleCommand { - @Override - public void execute(String[] args) { - if (args.length == 1) { - printList(); - } - else{ - try { - ConsoleCommand commandObj = CommandDict.getCommand(args[1].toLowerCase()); - commandObj.printUsage(); - } - catch (NullPointerException e) { - StringBuilder sb = new StringBuilder(); - Formatter formatter = new Formatter(sb); - - new Echo().execute("Codex: " - + formatter.format(Lang.get("DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN") - , args[1] - ).toString() - ); - } - } - } - - @Override - public void printUsage() { - Echo echo = new Echo(); - echo.execute("Usage: codex (command)"); - echo.execute("shows how to use 'command'"); - echo.execute("leave blank to get list of available commands"); - } - - private void printList() { - Echo echo = new Echo(); - echo.execute(Lang.get("DEV_MESSAGE_CONSOLE_AVAILABLE_COMMANDS")); - CommandDict.dict.keySet().forEach((s) -> echo.execute("] " + s)); - } - -} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/CodexEdictis.kt b/src/com/Torvald/Terrarum/ConsoleCommand/CodexEdictis.kt new file mode 100644 index 000000000..e36db126c --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/CodexEdictis.kt @@ -0,0 +1,45 @@ +package com.Torvald.Terrarum.ConsoleCommand + +import com.Torvald.Terrarum.Game +import com.Torvald.Terrarum.LangPack.Lang +import com.Torvald.Terrarum.UserInterface.ConsoleWindow + +import java.util.Formatter + +/** + * Created by minjaesong on 16-01-16. + */ +class CodexEdictis : ConsoleCommand { + override fun execute(args: Array) { + if (args.size == 1) { + printList() + } + else { + try { + val commandObj = CommandDict.getCommand(args[1].toLowerCase()) + commandObj.printUsage() + } + catch (e: NullPointerException) { + val sb = StringBuilder() + val formatter = Formatter(sb) + + Echo().execute("Codex: " + formatter.format(Lang.get("DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"), args[1]).toString()) + } + + } + } + + override fun printUsage() { + val echo = Echo() + echo.execute("Usage: codex (command)") + echo.execute("shows how to use 'command'") + echo.execute("leave blank to get list of available commands") + } + + private fun printList() { + val echo = Echo() + echo.execute(Lang.get("DEV_MESSAGE_CONSOLE_AVAILABLE_COMMANDS")) + CommandDict.dict.keys.forEach { s -> echo.execute("] " + s) } + } + +} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/CommandDict.java b/src/com/Torvald/Terrarum/ConsoleCommand/CommandDict.java deleted file mode 100644 index 4041c2781..000000000 --- a/src/com/Torvald/Terrarum/ConsoleCommand/CommandDict.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.Torvald.Terrarum.ConsoleCommand; - -import com.Torvald.Terrarum.Terrarum; - -import java.util.HashMap; - -/** - * Created by minjaesong on 16-01-15. - */ -public class CommandDict { - - protected static HashMap dict; - - public CommandDict() { - dict = new HashMap<>(); - - dict.put("echo", new Echo()); - dict.put("setav", new SetAV()); - dict.put("qqq", new QuitApp()); - dict.put("codex", new CodexEdictis()); - dict.put("export", new ExportMap()); - dict.put("gc", new ForceGC()); - dict.put("getav", new GetAV()); - dict.put("getlocale", new GetLocale()); - dict.put("togglenoclip", new ToggleNoClip()); - dict.put("nc", dict.get("togglenoclip")); - dict.put("bulletintest", new SetBulletin()); - dict.put("setlocale", new SetLocale()); - dict.put("zoom", new Zoom()); - dict.put("teleport", new TeleportPlayer()); - dict.put("tp", dict.get("teleport")); - dict.put("cat", new CatStdout()); - dict.put("exportav", new ExportAV()); - dict.put("gsontest", new GsonTest()); - dict.put("setgl", new SetGlobalLightLevel()); - dict.put("getfaction", new GetFactioning()); - dict.put("auth", Terrarum.game.auth); - dict.put("spawnball", new SpawnPhysTestBall()); - dict.put("batch", new Batch()); - } - - public static ConsoleCommand getCommand(String commandName) { - return dict.get(commandName); - } - -} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/CommandDict.kt b/src/com/Torvald/Terrarum/ConsoleCommand/CommandDict.kt new file mode 100644 index 000000000..2cd02bfcf --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/CommandDict.kt @@ -0,0 +1,47 @@ +package com.Torvald.Terrarum.ConsoleCommand + +import com.Torvald.Terrarum.Terrarum + +import java.util.HashMap + +/** + * Created by minjaesong on 16-01-15. + */ +object CommandDict { + + internal var dict: HashMap = hashMapOf( + Pair("echo", Echo()), + Pair("setav", SetAV()), + Pair("qqq", QuitApp()), + Pair("codex", CodexEdictis()), + Pair("export", ExportMap()), + Pair("gc", ForceGC()), + Pair("getav", GetAV()), + Pair("getlocale", GetLocale()), + Pair("togglenoclip", ToggleNoClip()), + Pair("nc", ToggleNoClip()), + Pair("setlocale", SetLocale()), + Pair("zoom", Zoom()), + Pair("teleport", TeleportPlayer()), + Pair("tp", TeleportPlayer()), + Pair("cat", CatStdout()), + Pair("exportav", ExportAV()), + Pair("setgl", SetGlobalLightLevel()), + Pair("getfaction", GetFactioning()), + Pair("auth", Terrarum.game.auth), + Pair("spawnball", SpawnPhysTestBall()), + Pair("batch", Batch()), + Pair("settime", SetTime()), + Pair("gettime", GetTime()), + Pair("settimedelta", SetTimeDelta()), + Pair("help", Help()), + + // Test codes + Pair("bulletintest", SetBulletin()), + Pair("gsontest", GsonTest()) + ) + + fun getCommand(commandName: String): ConsoleCommand { + return dict[commandName]!! + } +} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/CommandInterpreter.java b/src/com/Torvald/Terrarum/ConsoleCommand/CommandInterpreter.java deleted file mode 100644 index a10c226fa..000000000 --- a/src/com/Torvald/Terrarum/ConsoleCommand/CommandInterpreter.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.Torvald.Terrarum.ConsoleCommand; - -import com.Torvald.Terrarum.LangPack.Lang; -import com.Torvald.Terrarum.Terrarum; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Formatter; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Created by minjaesong on 16-01-15. - */ -public class CommandInterpreter { - - private static String[] commandsAvailableWOAuth = {"auth", "qqq", "zoom", "setlocale", "getlocale"}; - - public static void execute(String command) { - CommandInput[] cmd = parse(command); - - for (CommandInput single_command : cmd) { - ConsoleCommand commandObj = null; - try { - if (Arrays.asList(commandsAvailableWOAuth).contains(single_command.getName().toLowerCase())) { - commandObj = CommandDict.getCommand(single_command.getName().toLowerCase()); - } - else { - if (Terrarum.game.auth.b()) { - commandObj = CommandDict.getCommand( - single_command.getName().toLowerCase() - ); - } - else { - // System.out.println("ee1"); - throw new NullPointerException(); // if not authorised, say "Unknown command" - } - } - } - catch (NullPointerException e) { - - } - finally { - try { - if (commandObj != null) { - commandObj.execute(single_command.toStringArray()); - } - else { - echoUnknownCmd(single_command.getName()); - // System.out.println("ee3"); - } - } - catch (Exception e) { - System.out.println("[CommandInterpreter] :"); - e.printStackTrace(); - new Echo().execute(Lang.get("ERROR_GENERIC_TEXT")); - } - } - } - } - - private static CommandInput[] parse(String input) { - Pattern patternCommands = Pattern.compile("[^;]+"); - Pattern patternTokensInCommand = Pattern.compile("[\"'][^;]+[\"']|[^ ]+"); - - ArrayList commands = new ArrayList<>(); - - // split multiple commands - Matcher m = patternCommands.matcher(input); - while (m.find()) commands.add(m.group()); - - // split command tokens from a command - CommandInput[] parsedCommands = new CommandInput[commands.size()]; - - - for (int i = 0; i < parsedCommands.length; i++) { - ArrayList tokens = new ArrayList<>(); - - m = patternTokensInCommand.matcher(commands.get(i)); - while (m.find()) { - String regexGroup = m.group().replaceAll("[\"\']", ""); - tokens.add(regexGroup); - } - - // create new command - parsedCommands[i] = new CommandInput(tokens.toArray()); - - } - - return parsedCommands; - } - - static void echoUnknownCmd(String cmdname) { - StringBuilder sb = new StringBuilder(); - Formatter formatter = new Formatter(sb); - - new Echo().execute( - formatter.format(Lang.get("DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN") - , cmdname - ).toString() - ); - } - -} - -class CommandInput { - private String[] tokens; - - CommandInput(Object[] o) { - tokens = new String[o.length]; - for (int i = 0; i < o.length; i++) { - tokens[i] = (String) o[i]; - } - } - - String[] toStringArray() { - return tokens; - } - - String getName() { - return tokens[0]; - } - - int getArgsCount() { - return tokens.length; - } -} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/CommandInterpreter.kt b/src/com/Torvald/Terrarum/ConsoleCommand/CommandInterpreter.kt new file mode 100644 index 000000000..d1105246c --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/CommandInterpreter.kt @@ -0,0 +1,116 @@ +package com.Torvald.Terrarum.ConsoleCommand + +import com.Torvald.Terrarum.LangPack.Lang +import com.Torvald.Terrarum.Terrarum + +import java.util.ArrayList +import java.util.Formatter +import java.util.regex.Pattern + +/** + * Created by minjaesong on 16-01-15. + */ +object CommandInterpreter { + + private val commandsNoAuth = arrayOf("auth", "qqq", "zoom", "setlocale", "getlocale", "help") + + fun execute(command: String) { + val cmd = parse(command) + + for (single_command in cmd) { + var commandObj: ConsoleCommand? = null + try { + if (commandsNoAuth.contains(single_command!!.name.toLowerCase())) { + commandObj = CommandDict.getCommand(single_command.name.toLowerCase()) + } + else { + if (Terrarum.game.auth.b()) { + commandObj = CommandDict.getCommand( + single_command.name.toLowerCase()) + } + else { + // System.out.println("ee1"); + throw NullPointerException() // if not authorised, say "Unknown command" + } + } + } + catch (e: NullPointerException) { + + } + finally { + try { + if (commandObj != null) { + commandObj.execute(single_command!!.toStringArray()) + } + else { + echoUnknownCmd(single_command!!.name) + // System.out.println("ee3"); + } + } + catch (e: Exception) { + println("[CommandInterpreter] :") + e.printStackTrace() + Echo().execute(Lang.get("ERROR_GENERIC_TEXT")) + } + + } + } + } + + private fun parse(input: String): Array { + val patternCommands = Pattern.compile("[^;]+") + val patternTokensInCommand = Pattern.compile("[\"'][^;]+[\"']|[^ ]+") + + val commands = ArrayList() + + // split multiple commands + var m = patternCommands.matcher(input) + while (m.find()) commands.add(m.group()) + + // split command tokens from a command + val parsedCommands = arrayOfNulls(commands.size) + + + for (i in parsedCommands.indices) { + val tokens = ArrayList() + + m = patternTokensInCommand.matcher(commands[i]) + while (m.find()) { + val regexGroup = m.group().replace("[\"\']".toRegex(), "") + tokens.add(regexGroup) + } + + // create new command + parsedCommands[i] = CommandInput(tokens.toArray()) + + } + + return parsedCommands + } + + internal fun echoUnknownCmd(cmdname: String) { + val sb = StringBuilder() + val formatter = Formatter(sb) + + Echo().execute( + formatter.format(Lang.get("DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"), cmdname).toString()) + } + + private class CommandInput(o: Array) { + private val tokens: Array + + init { + tokens = Array(o.size, { i -> o[i] as String }) + } + + fun toStringArray(): Array { + return tokens + } + + val name: String + get() = tokens[0] + + val argsCount: Int + get() = tokens.size + } +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/ConsoleCommand.kt b/src/com/Torvald/Terrarum/ConsoleCommand/ConsoleCommand.kt index 359235ca5..6cdf45ea2 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/ConsoleCommand.kt +++ b/src/com/Torvald/Terrarum/ConsoleCommand/ConsoleCommand.kt @@ -1,7 +1,7 @@ package com.Torvald.Terrarum.ConsoleCommand /** - * Created by minjaesong on 16-03-15. + * Created by minjaesong on 16-01-15. */ interface ConsoleCommand { diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Echo.java b/src/com/Torvald/Terrarum/ConsoleCommand/Echo.java index c2b38ef17..d90cabb7f 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/Echo.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/Echo.java @@ -4,7 +4,6 @@ import com.Torvald.Terrarum.Terrarum; import com.Torvald.Terrarum.UserInterface.ConsoleWindow; import java.util.Arrays; -import java.util.List; /** * Created by minjaesong on 16-01-16. diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/ExportAV.java b/src/com/Torvald/Terrarum/ConsoleCommand/ExportAV.java index d664124eb..d625c5cb5 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/ExportAV.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/ExportAV.java @@ -13,7 +13,7 @@ public class ExportAV implements ConsoleCommand { public void execute(String[] args) { if (args.length == 2) { try { - JsonWriter.writeToFile(Terrarum.game.getPlayer().getActorValue() + JsonWriter.INSTANCE.writeToFile(Terrarum.game.player.getActorValue() , Terrarum.defaultDir + "/Exports/" + args[1] + ".json" ); diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/ExportMap.java b/src/com/Torvald/Terrarum/ConsoleCommand/ExportMap.java index c958ecf29..5df05bf63 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/ExportMap.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/ExportMap.java @@ -57,7 +57,7 @@ public class ExportMap implements ConsoleCommand { if (args.length == 2) { buildColorTable(); - mapData = new byte[Terrarum.game.map.width * Terrarum.game.map.height * 3]; + mapData = new byte[Terrarum.game.map.getWidth() * Terrarum.game.map.getHeight() * 3]; for (byte tile : Terrarum.game.map.getLayerTerrain()) { byte[] colArray = colorTable.getOrDefault(tile, new Col4096(0xFFF)) @@ -77,9 +77,9 @@ public class ExportMap implements ConsoleCommand { } try { - RasterWriter.writePNG_RGB( - Terrarum.game.map.width - , Terrarum.game.map.height + RasterWriter.INSTANCE.writePNG_RGB( + Terrarum.game.map.getWidth() + , Terrarum.game.map.getHeight() , mapData , dir + args[1] + ".png" ); diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java b/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java index b3630dcf3..6902b8feb 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java @@ -18,7 +18,7 @@ public class GetAV implements ConsoleCommand { try { if (args.length == 1) { // print all actorvalue of player - ActorValue av = Terrarum.game.getPlayer().getActorValue(); + ActorValue av = Terrarum.game.player.getActorValue(); Set keyset = av.getKeySet(); keyset.forEach( @@ -31,9 +31,9 @@ public class GetAV implements ConsoleCommand { } else if (args.length == 2) { echo.execute("player." + args[1] + " = " - + Terrarum.game.getPlayer().getActorValue().get(args[1]) + + Terrarum.game.player.getActorValue().get(args[1]) + " (" - + Terrarum.game.getPlayer().getActorValue().get(args[1]).getClass() + + Terrarum.game.player.getActorValue().get(args[1]).getClass() .getSimpleName() + ")" ); diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/GetFactioning.java b/src/com/Torvald/Terrarum/ConsoleCommand/GetFactioning.java index fc6adc70a..e58532f85 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/GetFactioning.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/GetFactioning.java @@ -18,7 +18,12 @@ public class GetFactioning implements ConsoleCommand { Echo echo = new Echo(); if (args.length == 1) { // get all factioning data of player - HashSet factionSet = Terrarum.game.getPlayer().getFaction(); + HashSet factionSet = Terrarum.game.player.getFaction(); + + if (factionSet == null) { + echo.execute("The actor has null faction set."); + return; + } int count = factionSet.size(); echo.execute(String.valueOf(count) + Lang.pluralise(" faction", count) + " assigned."); diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Gettime.kt b/src/com/Torvald/Terrarum/ConsoleCommand/Gettime.kt new file mode 100644 index 000000000..52e0c22ac --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/Gettime.kt @@ -0,0 +1,20 @@ +package com.Torvald.Terrarum.ConsoleCommand + +import com.Torvald.Terrarum.Terrarum + +/** + * Created by minjaesong on 16-03-20. + */ +class GetTime : ConsoleCommand { + override fun execute(args: Array) { + val echo = Echo() + echo.execute("Day ${Terrarum.game.map.worldTime.days}, " + + "${Terrarum.game.map.worldTime.getFormattedTime()} " + + "(${Terrarum.game.map.worldTime.elapsedSeconds()} s)" + ) + } + + override fun printUsage() { + Echo().execute("Print current world time in convenient form") + } +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/GsonTest.java b/src/com/Torvald/Terrarum/ConsoleCommand/GsonTest.java index 2652f1320..2d23740d9 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/GsonTest.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/GsonTest.java @@ -15,7 +15,7 @@ public class GsonTest implements ConsoleCommand { @Override public void execute(String[] args) { if (args.length == 2) { - JsonElement avelem = new Gson().toJsonTree(Terrarum.game.getPlayer()); + JsonElement avelem = new Gson().toJsonTree(Terrarum.game.player); String jsonString = avelem.toString(); diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Help.kt b/src/com/Torvald/Terrarum/ConsoleCommand/Help.kt new file mode 100644 index 000000000..9f5f2d015 --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/Help.kt @@ -0,0 +1,20 @@ +package com.Torvald.Terrarum.ConsoleCommand + +/** + * Created by minjaesong on 16-03-22. + */ +class Help : ConsoleCommand { + override fun execute(args: Array) { + Echo().execute(arrayOf( + "echo", + "Utility keys:", + "F3: Basic debug information", + "F7: Toggle lightmap blending", + "F8: Toggle smooth lighting" + )) + } + + override fun printUsage() { + Echo().execute("Prints some utility functions assigned to runction row of the keyboard.") + } +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java b/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java index 1a30f8c36..a73f5f2e4 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java @@ -48,7 +48,7 @@ class SetAV implements ConsoleCommand { } } - Terrarum.game.getPlayer().getActorValue().set(args[1], val); + Terrarum.game.player.getActorValue().set(args[1], val); echo.execute("Set " + args[1] + " to " + val); } else if (args.length == 4) { diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.java b/src/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.java index 6c0d71144..b4368a6be 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.java @@ -13,7 +13,8 @@ public class SetBulletin implements ConsoleCommand { String[] testMsg = { //Lang.get("ERROR_SAVE_CORRUPTED") //, Lang.get("MENU_LABEL_CONTINUE_QUESTION") - "갎갎갎갎갎갎갎갎갎갎갎갎갎갎" + "Bulletin test “Hello, world!”", + "世界一みんなの人気者 それは彼女のこと アシュリー 달이 차오른다 가자" }; send(testMsg); } diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/SetGlobalLightLevel.java b/src/com/Torvald/Terrarum/ConsoleCommand/SetGlobalLightLevel.java deleted file mode 100644 index 5280db619..000000000 --- a/src/com/Torvald/Terrarum/ConsoleCommand/SetGlobalLightLevel.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.Torvald.Terrarum.ConsoleCommand; - -import com.Torvald.Terrarum.MapDrawer.LightmapRenderer; -import com.Torvald.Terrarum.Terrarum; - -/** - * Created by minjaesong on 16-02-17. - */ -public class SetGlobalLightLevel implements ConsoleCommand { - @Override - public void execute(String[] args) { - if (args.length == 4) { - try { - int r = new Integer(args[1]); - int g = new Integer(args[2]); - int b = new Integer(args[3]); - char GL = LightmapRenderer.constructRGBFromInt(r, g, b); - - Terrarum.game.map.setGlobalLight(GL); - } - catch (NumberFormatException e) { - new Echo().execute("Wrong number input."); - } - catch (IllegalArgumentException e1) { - new Echo().execute("Range: 0-" + LightmapRenderer.getCHANNEL_MAX() + " per channel"); - } - } - else if (args.length == 2) { - try { - char GL = (char) (new Integer(args[1]).intValue()); - - if (GL < 0 || GL >= LightmapRenderer.getCOLOUR_DOMAIN_SIZE()) { - new Echo().execute("Range: 0-" + (LightmapRenderer.getCOLOUR_DOMAIN_SIZE() - 1)); - } - else { - Terrarum.game.map.setGlobalLight(GL); - } - } - catch (NumberFormatException e) { - new Echo().execute("Wrong number input."); - } - - } - else{ - printUsage(); - } - } - - @Override - public void printUsage() { - new Echo().execute("Usage: setgl [raw_value|r g b]"); - } -} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/SetGlobalLightLevel.kt b/src/com/Torvald/Terrarum/ConsoleCommand/SetGlobalLightLevel.kt new file mode 100644 index 000000000..0dc65825f --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/SetGlobalLightLevel.kt @@ -0,0 +1,52 @@ +package com.Torvald.Terrarum.ConsoleCommand + +import com.Torvald.Terrarum.MapDrawer.LightmapRenderer +import com.Torvald.Terrarum.Terrarum + +/** + * Created by minjaesong on 16-02-17. + */ +class SetGlobalLightLevel : ConsoleCommand { + override fun execute(args: Array) { + if (args.size == 4) { + try { + val r = args[1].toInt() + val g = args[2].toInt() + val b = args[3].toInt() + val GL = LightmapRenderer.constructRGBFromInt(r, g, b) + + Terrarum.game.map.globalLight = GL + } + catch (e: NumberFormatException) { + Echo().execute("Wrong number input.") + } + catch (e1: IllegalArgumentException) { + Echo().execute("Range: 0-" + LightmapRenderer.CHANNEL_MAX + " per channel") + } + + } + else if (args.size == 2) { + try { + val GL = Integer(args[1]).toInt().toChar() + + if (GL.toInt() < 0 || GL.toInt() >= LightmapRenderer.COLOUR_DOMAIN_SIZE) { + Echo().execute("Range: 0-" + (LightmapRenderer.COLOUR_DOMAIN_SIZE - 1)) + } + else { + Terrarum.game.map.globalLight = GL + } + } + catch (e: NumberFormatException) { + Echo().execute("Wrong number input.") + } + + } + else { + printUsage() + } + } + + override fun printUsage() { + Echo().execute("Usage: setgl [raw_value|r g b]") + } +} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/SetLocale.java b/src/com/Torvald/Terrarum/ConsoleCommand/SetLocale.java index c656b26d4..7c2b7220f 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/SetLocale.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/SetLocale.java @@ -15,15 +15,15 @@ public class SetLocale implements ConsoleCommand { @Override public void execute(String[] args) { if (args.length == 2) { - String prevLocale = Terrarum.gameLocale; - Terrarum.gameLocale = args[1]; + String prevLocale = Terrarum.Companion.getGameLocale(); + Terrarum.Companion.setGameLocale(args[1]); try { new Lang(); - new Echo().execute("Set locale to '" + Terrarum.gameLocale + "'."); + new Echo().execute("Set locale to '" + Terrarum.Companion.getGameLocale() + "'."); } catch (IOException e) { new Echo().execute("could not read lang file."); - Terrarum.gameLocale = prevLocale; + Terrarum.Companion.setGameLocale(prevLocale); } } else if (args.length == 1) { diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/SetTimeDelta.kt b/src/com/Torvald/Terrarum/ConsoleCommand/SetTimeDelta.kt new file mode 100644 index 000000000..f56096d2b --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/SetTimeDelta.kt @@ -0,0 +1,25 @@ +package com.Torvald.Terrarum.ConsoleCommand + +import com.Torvald.Terrarum.Terrarum + +/** + * Created by minjaesong on 16-03-20. + */ +class SetTimeDelta : ConsoleCommand { + override fun execute(args: Array) { + if (args.size == 2) { + Terrarum.game.map.worldTime.setTimeDelta(args[1].toInt()) + if (Terrarum.game.map.worldTime.timeDelta == 0) + Echo().execute("時間よ止まれ!ザ・ワルド!!") + else + Echo().execute("Set time delta to ${Terrarum.game.map.worldTime.timeDelta}") + } + else { + printUsage() + } + } + + override fun printUsage() { + Echo().execute("usage: settimedelta ") + } +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Settime.kt b/src/com/Torvald/Terrarum/ConsoleCommand/Settime.kt new file mode 100644 index 000000000..601674225 --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/Settime.kt @@ -0,0 +1,42 @@ +package com.Torvald.Terrarum.ConsoleCommand + +import com.Torvald.Terrarum.GameMap.WorldTime +import com.Torvald.Terrarum.Terrarum + +/** + * Created by minjaesong on 16-03-20. + */ +class SetTime : ConsoleCommand { + override fun execute(args: Array) { + if (args.size == 2) { + val lowercaseTime = args[1].toLowerCase() + val timeToSet = + if (args[1].length >= 4) { + lowercaseTime.substringBefore('h').toInt() * WorldTime.HOUR_SEC + + lowercaseTime.substringAfter('h').toInt() * WorldTime.MINUTE_SEC + } + else if (args[1].endsWith("h", true)) { + lowercaseTime.substring(0, args[1].length - 1).toInt() * WorldTime.HOUR_SEC + } + else { + lowercaseTime.toInt() + } + + Terrarum.game.map.worldTime.setTime(timeToSet) + + Echo().execute("Set time to ${Terrarum.game.map.worldTime.elapsedSeconds()} " + + "(${Terrarum.game.map.worldTime.hours}h${formatMin(Terrarum.game.map.worldTime.minutes)})") + } + else { + printUsage() + } + } + + private fun formatMin(min: Int): String { + return if (min < 10) "0${min.toString()}" else min.toString() + } + + override fun printUsage() { + Echo().execute("usage: settime <39201-in sec or 13h32-in hour>") + } +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.java b/src/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.java index 0cbd720f5..cc4e8ccce 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.java @@ -26,7 +26,7 @@ public class TeleportPlayer implements ConsoleCommand { return; } - Terrarum.game.getPlayer().setPosition(x, y); + Terrarum.game.player.setPosition(x, y); } } diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.java b/src/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.java index 0fd72a919..4d6efb387 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.java @@ -9,9 +9,9 @@ import com.Torvald.Terrarum.Terrarum; public class ToggleNoClip implements ConsoleCommand { @Override public void execute(String[] args) { - boolean status = Terrarum.game.getPlayer().isNoClip(); + boolean status = Terrarum.game.player.isNoClip(); - Terrarum.game.getPlayer().setNoClip(!status); + Terrarum.game.player.setNoClip(!status); new Echo().execute("Set no-clip status to " + String.valueOf(!status)); } diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Zoom.java b/src/com/Torvald/Terrarum/ConsoleCommand/Zoom.java deleted file mode 100644 index cec68b4c9..000000000 --- a/src/com/Torvald/Terrarum/ConsoleCommand/Zoom.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.Torvald.Terrarum.ConsoleCommand; - -import com.Torvald.Terrarum.Game; -import com.Torvald.Terrarum.Terrarum; - -/** - * Created by minjaesong on 16-01-25. - */ -public class Zoom implements ConsoleCommand { - @Override - public void execute(String[] args) { - if (args.length == 2) { - - float zoom; - try { - zoom = new Float(args[1]); - } - catch (NumberFormatException e) { - new Echo().execute("Wrong number input."); - return; - } - - if (zoom < Terrarum.game.ZOOM_MIN) { - zoom = Terrarum.game.ZOOM_MIN; - } - else if (zoom > Terrarum.game.ZOOM_MAX) { - zoom = Terrarum.game.ZOOM_MAX; - } - - Terrarum.game.screenZoom = zoom; - - System.gc(); - - new Echo().execute("Set screen zoom to " + String.valueOf(zoom)); - } - else { - printUsage(); - } - } - - @Override - public void printUsage() { - new Echo().execute("Usage: zoom [zoom]"); - } -} diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Zoom.kt b/src/com/Torvald/Terrarum/ConsoleCommand/Zoom.kt new file mode 100644 index 000000000..ab96aca58 --- /dev/null +++ b/src/com/Torvald/Terrarum/ConsoleCommand/Zoom.kt @@ -0,0 +1,42 @@ +package com.Torvald.Terrarum.ConsoleCommand + +import com.Torvald.Terrarum.Terrarum + +/** + * Created by minjaesong on 16-01-25. + */ +class Zoom : ConsoleCommand { + override fun execute(args: Array) { + if (args.size == 2) { + + var zoom: Float + try { + zoom = args[1].toFloat() + } + catch (e: NumberFormatException) { + Echo().execute("Wrong number input.") + return + } + + if (zoom < Terrarum.game.ZOOM_MIN) { + zoom = Terrarum.game.ZOOM_MIN + } + else if (zoom > Terrarum.game.ZOOM_MAX) { + zoom = Terrarum.game.ZOOM_MAX + } + + Terrarum.game.screenZoom = zoom + + System.gc() + + Echo().execute("Set screen zoom to " + zoom.toString()) + } + else { + printUsage() + } + } + + override fun printUsage() { + Echo().execute("Usage: zoom [zoom]") + } +} diff --git a/src/com/Torvald/Terrarum/DefaultConfig.java b/src/com/Torvald/Terrarum/DefaultConfig.java deleted file mode 100644 index 8c6f69734..000000000 --- a/src/com/Torvald/Terrarum/DefaultConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.Torvald.Terrarum; - -import com.google.gson.JsonObject; - -/** - * Created by minjaesong on 16-03-12. - */ -public class DefaultConfig { - - public static JsonObject fetch() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("smoothlighting", true); - jsonObject.addProperty("imtooyoungtodie", false); - jsonObject.addProperty("language", Terrarum.getSysLang()); - jsonObject.addProperty("notificationshowuptime", 6500); - - return jsonObject; - } - -} diff --git a/src/com/Torvald/Terrarum/DefaultConfig.kt b/src/com/Torvald/Terrarum/DefaultConfig.kt new file mode 100644 index 000000000..cc0ffeb51 --- /dev/null +++ b/src/com/Torvald/Terrarum/DefaultConfig.kt @@ -0,0 +1,19 @@ +package com.Torvald.Terrarum + +import com.google.gson.JsonObject + +/** + * Created by minjaesong on 16-03-19. + */ +object DefaultConfig { + fun fetch(): JsonObject { + val jsonObject = JsonObject() + + jsonObject.addProperty("smoothlighting", true) + jsonObject.addProperty("imtooyoungtodie", false) + jsonObject.addProperty("language", Terrarum.sysLang) + jsonObject.addProperty("notificationshowuptime", 6500) + + return jsonObject + } +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/Exceptions/InvalidValueException.java b/src/com/Torvald/Terrarum/Exceptions/InvalidValueException.java deleted file mode 100644 index 9aca6d067..000000000 --- a/src/com/Torvald/Terrarum/Exceptions/InvalidValueException.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.Torvald.Terrarum.Exceptions; - -/** - * Created by minjaesong on 16-01-04. - */ -public class InvalidValueException extends Exception { - -} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/Game.java b/src/com/Torvald/Terrarum/Game similarity index 99% rename from src/com/Torvald/Terrarum/Game.java rename to src/com/Torvald/Terrarum/Game index 1552f29f0..34aec2639 100644 --- a/src/com/Torvald/Terrarum/Game.java +++ b/src/com/Torvald/Terrarum/Game @@ -51,7 +51,7 @@ public class Game extends BasicGameState { public UIHandler debugWindow; public UIHandler notifinator; - @NotNull Player player; + Player player; private Image GRADIENT_IMAGE; private Rectangle skyBox; @@ -101,7 +101,7 @@ public class Game extends BasicGameState { map.setGravitation(9.8f); MapGenerator.attachMap(map); - MapGenerator.setSeed(0x51621D); + MapGenerator.setSeed(0x51621D2); //MapGenerator.setSeed(new HQRNG().nextLong()); MapGenerator.generateMap(); diff --git a/src/com/Torvald/Terrarum/Game.kt b/src/com/Torvald/Terrarum/Game.kt new file mode 100644 index 000000000..c03429853 --- /dev/null +++ b/src/com/Torvald/Terrarum/Game.kt @@ -0,0 +1,357 @@ +package com.Torvald.Terrarum + +import com.Torvald.ColourUtil.Col40 +import com.Torvald.Terrarum.Actors.* +import com.Torvald.Terrarum.ConsoleCommand.Authenticator +import com.Torvald.Terrarum.ConsoleCommand.CommandDict +import com.Torvald.Terrarum.GameControl.GameController +import com.Torvald.Terrarum.GameControl.Key +import com.Torvald.Terrarum.GameControl.KeyMap +import com.Torvald.Terrarum.GameControl.KeyToggler +import com.Torvald.Terrarum.GameMap.GameMap +import com.Torvald.Terrarum.GameMap.WorldTime +import com.Torvald.Terrarum.MapDrawer.LightmapRenderer +import com.Torvald.Terrarum.MapDrawer.MapCamera +import com.Torvald.Terrarum.MapDrawer.MapDrawer +import com.Torvald.Terrarum.MapGenerator.MapGenerator +import com.Torvald.Terrarum.MapGenerator.RoguelikeRandomiser +import com.Torvald.Terrarum.TileProperties.TilePropCodex +import com.Torvald.Terrarum.TileStat.TileStat +import com.Torvald.Terrarum.UserInterface.BasicDebugInfoWindow +import com.Torvald.Terrarum.UserInterface.ConsoleWindow +import com.Torvald.Terrarum.UserInterface.Notification +import com.Torvald.Terrarum.UserInterface.UIHandler +import com.jme3.math.FastMath +import org.lwjgl.opengl.ARBShaderObjects +import org.lwjgl.opengl.GL11 +import org.newdawn.slick.* +import org.newdawn.slick.fills.GradientFill +import org.newdawn.slick.geom.Rectangle +import org.newdawn.slick.state.BasicGameState +import org.newdawn.slick.state.StateBasedGame +import shader.Shader +import java.lang.management.ManagementFactory +import java.util.* + +/** + * Created by minjaesong on 16-03-19. + */ +class Game @Throws(SlickException::class) +constructor() : BasicGameState() { + internal var game_mode = 0 + + lateinit var map: GameMap + + var actorContainer = HashSet() + var uiContainer = HashSet() + + lateinit var consoleHandler: UIHandler + lateinit var debugWindow: UIHandler + lateinit var notifinator: UIHandler + + lateinit internal var player: Player + + private var GRADIENT_IMAGE: Image? = null + private var skyBox: Rectangle? = null + + var screenZoom = 1.0f + val ZOOM_MAX = 2.0f + val ZOOM_MIN = 0.25f + + private var shader12BitCol: Shader? = null + private var shaderBlurH: Shader? = null + private var shaderBlurV: Shader? = null + + + private val useShader: Boolean = false + private val shaderProgram = 0 + + + private val ENV_COLTEMP_SUNRISE = 2500 + private val ENV_SUNLIGHT_DELTA = MapDrawer.ENV_COLTEMP_NOON - ENV_COLTEMP_SUNRISE + + + var memInUse: Long = 0 + get() = ManagementFactory.getMemoryMXBean().heapMemoryUsage.used shr 20 + var totalVMMem: Long = 0 + get() = Runtime.getRuntime().maxMemory() shr 20 + + var auth = Authenticator() + + private var update_delta: Int = 0 + + private val KEY_LIGHTMAP_RENDER = Key.F7 + private val KEY_LIGHTMAP_SMOOTH = Key.F8 + + @Throws(SlickException::class) + override fun init(gameContainer: GameContainer, stateBasedGame: StateBasedGame) { + KeyMap.build() + + shader12BitCol = Shader.makeShader("./res/4096.vrt", "./res/4096.frg") + shaderBlurH = Shader.makeShader("./res/blurH.vrt", "./res/blur.frg") + shaderBlurV = Shader.makeShader("./res/blurV.vrt", "./res/blur.frg") + + + GRADIENT_IMAGE = Image("res/graphics/sky_colour.png") + skyBox = Rectangle(0f, 0f, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat()) + + TilePropCodex() + // new ItemPropCodex() -- This is kotlin object and already initialised. + + map = GameMap(8192, 2048) + map.gravitation = 9.8f + + MapGenerator.attachMap(map) + MapGenerator.setSeed(0x51621D2) + //MapGenerator.setSeed(new HQRNG().nextLong()); + MapGenerator.generateMap() + + RoguelikeRandomiser.setSeed(0x540198) + //RoguelikeRandomiser.setSeed(new HQRNG().nextLong()); + + + // add new player and put it to actorContainer + //player = new Player(); + player = PFSigrid.build() + //player.setNoClip(true); + actorContainer.add(player) + + consoleHandler = UIHandler(ConsoleWindow()) + consoleHandler.setPosition(0, 0) + + debugWindow = UIHandler(BasicDebugInfoWindow()) + debugWindow.setPosition(0, 0) + + notifinator = UIHandler(Notification()) + notifinator.setPosition( + (Terrarum.WIDTH - notifinator.UI.width) / 2, Terrarum.HEIGHT - notifinator.UI.height) + notifinator.setVisibility(true) + + if (Terrarum.gameConfig.getAsBoolean("smoothlighting") == true) + KeyToggler.forceSet(KEY_LIGHTMAP_SMOOTH, true) + else + KeyToggler.forceSet(KEY_LIGHTMAP_SMOOTH, false) + } + + override fun update(gc: GameContainer, sbg: StateBasedGame, delta: Int) { + update_delta = delta + setAppTitle() + + // GL at after_sunrise-noon_before_sunset + map.updateWorldTime(delta) + map.setGlobalLight(globalLightByTime); + + GameController.processInput(gc.input) + + TileStat.update() + + MapDrawer.update(gc, delta) + MapCamera.update(gc, delta) + + actorContainer.forEach { actor -> actor.update(gc, delta) } + actorContainer.forEach { actor -> + if (actor is Visible) { + actor.updateBodySprite(gc, delta) + } + if (actor is Glowing) { + actor.updateGlowSprite(gc, delta) + } + } + + uiContainer.forEach { ui -> ui.update(gc, delta) } + consoleHandler.update(gc, delta) + debugWindow.update(gc, delta) + + + notifinator.update(gc, delta) + + Terrarum.appgc.setVSync(Terrarum.appgc.fps >= Terrarum.VSYNC_TRIGGER_THRESHOLD) + } + + private fun setAppTitle() { + Terrarum.appgc.setTitle( + "Simple Slick Game — FPS: " + + Terrarum.appgc.fps + " (" + + Terrarum.TARGET_INTERNAL_FPS.toString() + + ") — " + + memInUse.toString() + "M / " + + totalVMMem.toString() + "M") + } + + override fun render(gc: GameContainer, sbg: StateBasedGame, g: Graphics) { + Terrarum.gameConfig["smoothlighting"] = KeyToggler.isOn(KEY_LIGHTMAP_SMOOTH) + + if (!g.isAntiAlias) g.isAntiAlias = true + + drawSkybox(g) + + // compensate for zoom. UIs have to be treated specially! (see UIHandler) + g.translate( + -MapCamera.getCameraX() * screenZoom, -MapCamera.getCameraY() * screenZoom) + + MapCamera.renderBehind(gc, g) + + actorContainer.forEach { actor -> if (actor is Visible) actor.drawBody(gc, g) } + actorContainer.forEach { actor -> if (actor is Glowing) actor.drawGlow(gc, g) } + + LightmapRenderer.renderLightMap() + + MapCamera.renderFront(gc, g) + MapDrawer.render(gc, g) + + + setBlendModeMul() + + MapDrawer.drawEnvOverlay(g) + + if (!KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) setBlendModeMul() + else setBlendModeNormal() + + LightmapRenderer.draw(g) + + setBlendModeNormal() + + uiContainer.forEach { ui -> ui.render(gc, g) } + debugWindow.render(gc, g) + consoleHandler.render(gc, g) + notifinator.render(gc, g) + } + + fun addActor(e: Actor): Boolean { + return actorContainer.add(e) + } + + fun removeActor(e: Actor): Boolean { + return actorContainer.remove(e) + } + + private fun getGradientColour(): Array { + val gradMapWidth = GRADIENT_IMAGE!!.width + val phase = Math.round( + map.worldTime.elapsedSeconds().toFloat() / WorldTime.DAY_LENGTH.toFloat() * gradMapWidth + ) + + //update in every INTERNAL_FRAME frames + return arrayOf( + GRADIENT_IMAGE!!.getColor(phase, 0), + GRADIENT_IMAGE!!.getColor(phase, GRADIENT_IMAGE!!.height - 1) + ) + } + + override fun keyPressed(key: Int, c: Char) { + GameController.keyPressed(key, c) + } + + override fun keyReleased(key: Int, c: Char) { + GameController.keyReleased(key, c) + } + + override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { + GameController.mouseMoved(oldx, oldy, newx, newy) + } + + override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { + GameController.mouseDragged(oldx, oldy, newx, newy) + } + + override fun mousePressed(button: Int, x: Int, y: Int) { + GameController.mousePressed(button, x, y) + } + + override fun mouseReleased(button: Int, x: Int, y: Int) { + GameController.mouseReleased(button, x, y) + } + + override fun mouseWheelMoved(change: Int) { + GameController.mouseWheelMoved(change) + } + + override fun controllerButtonPressed(controller: Int, button: Int) { + GameController.controllerButtonPressed(controller, button) + } + + override fun controllerButtonReleased(controller: Int, button: Int) { + GameController.controllerButtonReleased(controller, button) + } + + override fun getID(): Int { + return Terrarum.SCENE_ID_GAME + } + + private fun drawSkybox(g: Graphics) { + val colourTable = getGradientColour() + val skyColourFill = GradientFill( + 0f, 0f, colourTable[0], + 0f, Terrarum.HEIGHT.toFloat(), colourTable[1] + ) + g.fill(skyBox, skyColourFill) + } + + private fun setBlendModeMul() { + GL11.glEnable(GL11.GL_BLEND) + GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_ONE_MINUS_SRC_ALPHA) + } + + private fun setBlendModeNormal() { + GL11.glDisable(GL11.GL_BLEND) + Terrarum.appgc.graphics.setDrawMode(Graphics.MODE_NORMAL) + } + + fun sendNotification(msg: Array) { + (notifinator.UI as Notification).sendNotification(Terrarum.appgc, update_delta, msg) + notifinator.setAsOpening() + } + + private val globalLightByTime: Char + get() { + /** + * y = -DELTA(x-1)^RAYLEIGH + MAX + * See documentation 'sky colour' + */ + val INTENSITY_MIN = 9 + val INTENSITY_MAX = 39 + + val COLTEMP_MIN = 2500 + val COLTEMP_MAX = MapDrawer.ENV_COLTEMP_NOON + val COLTEMP_DELTA = COLTEMP_MAX - COLTEMP_MIN + val RAYLEIGH_INDEX = 3.3f + + /** + * get colour temperature + */ + val dusk_len_colouring = 0.5f + val daytime_len = 10 + var secs_offset: Int = Math.round(WorldTime.HOUR_SEC * dusk_len_colouring) // 1h as Seconds + var time_domain_x_in_sec = (daytime_len + 2*dusk_len_colouring) * WorldTime.HOUR_SEC // 11h as Seconds + + var today_secs: Float = map.worldTime.elapsedSeconds().toFloat() + secs_offset + if (today_secs > time_domain_x_in_sec - secs_offset) today_secs - WorldTime.DAY_LENGTH // 79000 -> -200 + + var func_x: Float = (today_secs / time_domain_x_in_sec) * 2f // 0-46800 -> 0-2.0 + if (func_x < 1) func_x = 2f - func_x // mirror graph + if (func_x > 2) func_x = 2f // clamp + + // println("x: $func_x") + + val sunAltColouring: Int = FastMath.ceil( + -COLTEMP_DELTA * FastMath.pow(func_x - 1, RAYLEIGH_INDEX) + COLTEMP_MAX + ) + val sunColour: Col40 = Col40(MapDrawer.getColourFromMap(sunAltColouring)) + + /** + * get intensity + */ + val dusk_len = 1.5f + val intensity: Int = 39 + secs_offset = Math.round(WorldTime.HOUR_SEC * dusk_len) // 1h30 as Seconds + time_domain_x_in_sec = (daytime_len + 2*dusk_len) * WorldTime.HOUR_SEC // 13h as Seconds + + today_secs = map.worldTime.elapsedSeconds().toFloat() + secs_offset + if (today_secs > time_domain_x_in_sec - secs_offset) today_secs - WorldTime.DAY_LENGTH // 79000 -> -200 + + + + + return LightmapRenderer.darkenUniformInt(sunColour.raw, INTENSITY_MAX - intensity) + } +} diff --git a/src/com/Torvald/Terrarum/GameConfig.java b/src/com/Torvald/Terrarum/GameConfig.java deleted file mode 100644 index 94572d996..000000000 --- a/src/com/Torvald/Terrarum/GameConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.Torvald.Terrarum; - -/** - * Created by minjaesong on 15-12-30. - */ -public class GameConfig extends KVHashMap { - -} diff --git a/src/com/Torvald/Terrarum/GameConfig.kt b/src/com/Torvald/Terrarum/GameConfig.kt new file mode 100644 index 000000000..2bb01c682 --- /dev/null +++ b/src/com/Torvald/Terrarum/GameConfig.kt @@ -0,0 +1,6 @@ +package com.Torvald.Terrarum + +/** + * Created by minjaesong on 16-03-19. + */ +class GameConfig : KVHashMap() diff --git a/src/com/Torvald/Terrarum/GameControl/EnumKeyFunc.java b/src/com/Torvald/Terrarum/GameControl/EnumKeyFunc.kt similarity index 66% rename from src/com/Torvald/Terrarum/GameControl/EnumKeyFunc.java rename to src/com/Torvald/Terrarum/GameControl/EnumKeyFunc.kt index 9d4d553a2..eb57e4b9c 100644 --- a/src/com/Torvald/Terrarum/GameControl/EnumKeyFunc.java +++ b/src/com/Torvald/Terrarum/GameControl/EnumKeyFunc.kt @@ -1,9 +1,9 @@ -package com.Torvald.Terrarum.GameControl; +package com.Torvald.Terrarum.GameControl /** * Created by minjaesong on 15-12-31. */ -public enum EnumKeyFunc{ +enum class EnumKeyFunc { UI_CONSOLE, UI_BASIC_INFO, MOVE_LEFT, MOVE_RIGHT, MOVE_UP, MOVE_DOWN, JUMP } \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/GameControl/GameController.java b/src/com/Torvald/Terrarum/GameControl/GameController.java deleted file mode 100644 index 0b20c8f8b..000000000 --- a/src/com/Torvald/Terrarum/GameControl/GameController.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.Torvald.Terrarum.GameControl; - -import com.Torvald.Terrarum.Actors.Controllable; -import com.Torvald.Terrarum.Actors.Player; -import com.Torvald.Terrarum.MapDrawer.MapCamera; -import com.Torvald.Terrarum.MapDrawer.MapDrawer; -import com.Torvald.Terrarum.Terrarum; -import com.Torvald.Terrarum.TileProperties.TileNameCode; -import com.Torvald.Terrarum.TileProperties.TilePropCodex; -import com.Torvald.Terrarum.UserInterface.UIHandler; -import org.newdawn.slick.Input; - -/** - * Created by minjaesong on 15-12-31. - */ -public class GameController { - - private static KeyMap keyMap; - - public GameController() { - - } - - public static void setKeyMap(KeyMap map) { - keyMap = map; - } - - public static void processInput(Input input) { - int mouseTileX = (int) ((MapCamera.getCameraX() + input.getMouseX() / Terrarum.game.screenZoom) - / MapDrawer.getTILE_SIZE()); - int mouseTileY = (int) ((MapCamera.getCameraY() + input.getMouseY() / Terrarum.game.screenZoom) - / MapDrawer.getTILE_SIZE()); - - - KeyToggler.update(input); - - - if (!Terrarum.game.consoleHandler.isTakingControl()) { - if (Terrarum.game.getPlayer().getVehicleRiding() != null) { - Terrarum.game.getPlayer().getVehicleRiding().processInput(input); - } - - Terrarum.game.getPlayer().processInput(input); - - for (UIHandler ui : Terrarum.game.uiContainer) { - ui.processInput(input); - } - } - else { - Terrarum.game.consoleHandler.processInput(input); - } - - - if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { - // test tile remove - try { - Terrarum.game.map.setTileTerrain(mouseTileX, mouseTileY, TileNameCode.AIR); - // Terrarum.game.map.setTileWall(mouseTileX, mouseTileY, TileNameCode.AIR); - } - catch (ArrayIndexOutOfBoundsException e) { - } - } - else if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) { - // test tile place - try { - Terrarum.game.map.setTileTerrain(mouseTileX, mouseTileY - , Terrarum.game.getPlayer().getActorValue().getAsInt("selectedtile")); - } - catch (ArrayIndexOutOfBoundsException e) { - } - } - } - - public static void keyPressed(int key, char c) { - if (keyPressedByCode(key, EnumKeyFunc.UI_CONSOLE)) { - Terrarum.game.consoleHandler.toggleOpening(); - } - else if (keyPressedByCode(key, EnumKeyFunc.UI_BASIC_INFO)) { - Terrarum.game.debugWindow.toggleOpening(); - } - - - - if (!Terrarum.game.consoleHandler.isTakingControl()) { - if (Terrarum.game.getPlayer().getVehicleRiding() != null) { - Terrarum.game.getPlayer().getVehicleRiding().keyPressed(key, c); - } - - Terrarum.game.getPlayer().keyPressed(key, c); - } - else { - Terrarum.game.consoleHandler.keyPressed(key, c); - } - - //System.out.println(String.valueOf(key) + ", " + String.valueOf(c)); - } - - public static void keyReleased(int key, char c) { - - } - - public static void mouseMoved(int oldx, int oldy, int newx, int newy) { - - } - - public static void mouseDragged(int oldx, int oldy, int newx, int newy) { - - } - - public static void mousePressed(int button, int x, int y) { - - } - - public static void mouseReleased(int button, int x, int y) { - - } - - public static void mouseWheelMoved(int change) { - - } - - public static void controllerButtonPressed(int controller, int button) { - - } - - public static void controllerButtonReleased(int controller, int button) { - - } - - private static boolean keyPressedByCode(int key, EnumKeyFunc fn) { - return (KeyMap.getKeyCode(fn) == key); - } - -} diff --git a/src/com/Torvald/Terrarum/GameControl/GameController.kt b/src/com/Torvald/Terrarum/GameControl/GameController.kt new file mode 100644 index 000000000..05dca0526 --- /dev/null +++ b/src/com/Torvald/Terrarum/GameControl/GameController.kt @@ -0,0 +1,122 @@ +package com.Torvald.Terrarum.GameControl + +import com.Torvald.Terrarum.Actors.Controllable +import com.Torvald.Terrarum.Actors.Player +import com.Torvald.Terrarum.MapDrawer.MapCamera +import com.Torvald.Terrarum.MapDrawer.MapDrawer +import com.Torvald.Terrarum.Terrarum +import com.Torvald.Terrarum.TileProperties.TileNameCode +import com.Torvald.Terrarum.TileProperties.TilePropCodex +import com.Torvald.Terrarum.UserInterface.UIHandler +import org.newdawn.slick.Input + +/** + * Created by minjaesong on 15-12-31. + */ +object GameController { + + fun processInput(input: Input) { + val mouseTileX = ((MapCamera.getCameraX() + input.mouseX / Terrarum.game.screenZoom) / MapDrawer.TILE_SIZE).toInt() + val mouseTileY = ((MapCamera.getCameraY() + input.mouseY / Terrarum.game.screenZoom) / MapDrawer.TILE_SIZE).toInt() + + + KeyToggler.update(input) + + + if (!Terrarum.game.consoleHandler.isTakingControl) { + if (Terrarum.game.player.vehicleRiding != null) { + Terrarum.game.player.vehicleRiding!!.processInput(input) + } + + Terrarum.game.player.processInput(input) + + for (ui in Terrarum.game.uiContainer) { + ui.processInput(input) + } + } + else { + Terrarum.game.consoleHandler.processInput(input) + } + + + if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { + // test tile remove + try { + Terrarum.game.map.setTileTerrain(mouseTileX, mouseTileY, TileNameCode.AIR) + // Terrarum.game.map.setTileWall(mouseTileX, mouseTileY, TileNameCode.AIR); + } + catch (e: ArrayIndexOutOfBoundsException) { + } + + } + else if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) { + // test tile place + try { + Terrarum.game.map.setTileTerrain(mouseTileX, mouseTileY, Terrarum.game.player.getActorValue().getAsInt("selectedtile")!!) + } + catch (e: ArrayIndexOutOfBoundsException) { + } + + } + } + + fun keyPressed(key: Int, c: Char) { + if (keyPressedByCode(key, EnumKeyFunc.UI_CONSOLE)) { + Terrarum.game.consoleHandler.toggleOpening() + } + else if (keyPressedByCode(key, EnumKeyFunc.UI_BASIC_INFO)) { + Terrarum.game.debugWindow.toggleOpening() + } + + + + if (!Terrarum.game.consoleHandler.isTakingControl) { + if (Terrarum.game.player.vehicleRiding != null) { + Terrarum.game.player.vehicleRiding!!.keyPressed(key, c) + } + + Terrarum.game.player.keyPressed(key, c) + } + else { + Terrarum.game.consoleHandler.keyPressed(key, c) + } + + //System.out.println(String.valueOf(key) + ", " + String.valueOf(c)); + } + + fun keyReleased(key: Int, c: Char) { + + } + + fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { + + } + + fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { + + } + + fun mousePressed(button: Int, x: Int, y: Int) { + + } + + fun mouseReleased(button: Int, x: Int, y: Int) { + + } + + fun mouseWheelMoved(change: Int) { + + } + + fun controllerButtonPressed(controller: Int, button: Int) { + + } + + fun controllerButtonReleased(controller: Int, button: Int) { + + } + + private fun keyPressedByCode(key: Int, fn: EnumKeyFunc): Boolean { + return KeyMap.getKeyCode(fn) == key + } +} diff --git a/src/com/Torvald/Terrarum/GameControl/Key.java b/src/com/Torvald/Terrarum/GameControl/Key.java deleted file mode 100644 index 9a7a89dc3..000000000 --- a/src/com/Torvald/Terrarum/GameControl/Key.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.Torvald.Terrarum.GameControl; - -/** - * Created by minjaesong on 16-01-15. - */ -public class Key { - - public static final int RET = 28; - public static final int BKSP = 14; - public static final int GRAVE = 41; - public static final int TAB = 15; - public static final int ESCAPE = 1; - public static final int SPACE = 57; - - public static final int L_SHIFT = 42; - public static final int R_SHIFT = 54; - - public static final int UP = 200; - public static final int DOWN = 208; - public static final int LEFT = 203; - public static final int RIGHT = 205; - - public static final int F1 = 59; - public static final int F2 = 60; - public static final int F3 = 61; - public static final int F4 = 62; - - public static final int F5 = 63; - public static final int F6 = 64; - public static final int F7 = 65; - public static final int F8 = 66; - - public static final int F9 = 67; - public static final int F10 = 68; - public static final int F11 = 87; - public static final int F12 = 88; - - public static final int NUM_1 = 2; - public static final int NUM_2 = 3; - public static final int NUM_3 = 4; - public static final int NUM_4 = 5; - public static final int NUM_5 = 6; - public static final int NUM_6 = 7; - public static final int NUM_7 = 8; - public static final int NUM_8 = 9; - public static final int NUM_9 = 10; - public static final int NUM_0 = 11; - - public static final int Q = 16; - public static final int W = 17; - public static final int E = 18; - public static final int R = 19; - public static final int T = 20; - - public static final int Y = 21; - public static final int U = 22; - public static final int I = 23; - public static final int O = 24; - public static final int P = 25; - - public static final int A = 30; - public static final int S = 31; - public static final int D = 32; - public static final int F = 33; - public static final int G = 34; - - public static final int H = 35; - public static final int J = 36; - public static final int K = 37; - public static final int L = 38; - public static final int SEMICOLON = 39; - - public static final int Z = 44; - public static final int X = 45; - public static final int C = 46; - public static final int V = 47; - public static final int B = 48; - - public static final int N = 49; - public static final int M = 50; - - public static final int PGUP = 201; - public static final int PGDN = 209; - public static final int HOME = 199; - public static final int END = 207; -} diff --git a/src/com/Torvald/Terrarum/GameControl/Key.kt b/src/com/Torvald/Terrarum/GameControl/Key.kt new file mode 100644 index 000000000..851825994 --- /dev/null +++ b/src/com/Torvald/Terrarum/GameControl/Key.kt @@ -0,0 +1,86 @@ +package com.Torvald.Terrarum.GameControl + +/** + * Created by minjaesong on 16-01-15. + */ +object Key { + + val RET = 28 + val BKSP = 14 + val GRAVE = 41 + val TAB = 15 + val ESCAPE = 1 + val SPACE = 57 + + val L_SHIFT = 42 + val R_SHIFT = 54 + + val UP = 200 + val DOWN = 208 + val LEFT = 203 + val RIGHT = 205 + + val F1 = 59 + val F2 = 60 + val F3 = 61 + val F4 = 62 + + val F5 = 63 + val F6 = 64 + val F7 = 65 + val F8 = 66 + + val F9 = 67 + val F10 = 68 + val F11 = 87 + val F12 = 88 + + val NUM_1 = 2 + val NUM_2 = 3 + val NUM_3 = 4 + val NUM_4 = 5 + val NUM_5 = 6 + val NUM_6 = 7 + val NUM_7 = 8 + val NUM_8 = 9 + val NUM_9 = 10 + val NUM_0 = 11 + + val Q = 16 + val W = 17 + val E = 18 + val R = 19 + val T = 20 + + val Y = 21 + val U = 22 + val I = 23 + val O = 24 + val P = 25 + + val A = 30 + val S = 31 + val D = 32 + val F = 33 + val G = 34 + + val H = 35 + val J = 36 + val K = 37 + val L = 38 + val SEMICOLON = 39 + + val Z = 44 + val X = 45 + val C = 46 + val V = 47 + val B = 48 + + val N = 49 + val M = 50 + + val PGUP = 201 + val PGDN = 209 + val HOME = 199 + val END = 207 +} diff --git a/src/com/Torvald/Terrarum/GameControl/KeyMap.java b/src/com/Torvald/Terrarum/GameControl/KeyMap.java deleted file mode 100644 index d1897cde8..000000000 --- a/src/com/Torvald/Terrarum/GameControl/KeyMap.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.Torvald.Terrarum.GameControl; - -import java.util.Hashtable; - -/** - * Created by minjaesong on 15-12-31. - */ -public class KeyMap { - - public static Hashtable map_code = new Hashtable<>(); - - public static void build(){ - - map_code.put(EnumKeyFunc.MOVE_UP, Key.E); - map_code.put(EnumKeyFunc.MOVE_LEFT, Key.S); - map_code.put(EnumKeyFunc.MOVE_DOWN, Key.D); - map_code.put(EnumKeyFunc.MOVE_RIGHT, Key.F); - map_code.put(EnumKeyFunc.JUMP, Key.SPACE); - map_code.put(EnumKeyFunc.UI_CONSOLE, Key.GRAVE); - map_code.put(EnumKeyFunc.UI_BASIC_INFO, Key.F3); - } - - public static int getKeyCode(EnumKeyFunc fn) { - return map_code.get(fn); - } - - public static void set(EnumKeyFunc func, int key){ - map_code.put(func, key); - } - -} diff --git a/src/com/Torvald/Terrarum/GameControl/KeyMap.kt b/src/com/Torvald/Terrarum/GameControl/KeyMap.kt new file mode 100644 index 000000000..98dcfbff0 --- /dev/null +++ b/src/com/Torvald/Terrarum/GameControl/KeyMap.kt @@ -0,0 +1,31 @@ +package com.Torvald.Terrarum.GameControl + +import java.util.Hashtable + +/** + * Created by minjaesong on 15-12-31. + */ +object KeyMap { + + var map_code = Hashtable() + + fun build() { + + map_code.put(EnumKeyFunc.MOVE_UP, Key.E) + map_code.put(EnumKeyFunc.MOVE_LEFT, Key.S) + map_code.put(EnumKeyFunc.MOVE_DOWN, Key.D) + map_code.put(EnumKeyFunc.MOVE_RIGHT, Key.F) + map_code.put(EnumKeyFunc.JUMP, Key.SPACE) + map_code.put(EnumKeyFunc.UI_CONSOLE, Key.GRAVE) + map_code.put(EnumKeyFunc.UI_BASIC_INFO, Key.F3) + } + + fun getKeyCode(fn: EnumKeyFunc): Int { + return map_code[fn]!! + } + + operator fun set(func: EnumKeyFunc, key: Int) { + map_code.put(func, key) + } + +} diff --git a/src/com/Torvald/Terrarum/GameControl/KeyToggler.java b/src/com/Torvald/Terrarum/GameControl/KeyToggler.java deleted file mode 100644 index edc2eb637..000000000 --- a/src/com/Torvald/Terrarum/GameControl/KeyToggler.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.Torvald.Terrarum.GameControl; - -import org.newdawn.slick.GameContainer; -import org.newdawn.slick.Input; - -public class KeyToggler { - - private static boolean[] currentState = new boolean[256]; - private static boolean[] isPressed = new boolean[256]; - private static boolean[] isToggled = new boolean[256]; - - public static boolean isOn(int key){ - return currentState[key]; - } - - public static void update(Input input){ - for (int i = 0; i < 256; i++) { - if (input.isKeyDown(i)) { - isPressed[i] = true; - } else { - isPressed[i] = false; - } - } - - for (int i = 0; i < 256; i++){ - if (isPressed[i] && !currentState[i] && !isToggled[i]){ - currentState[i] = true; - isToggled[i] = true; - } - else if(isPressed[i] && currentState[i] && !isToggled[i]){ - currentState[i] = false; - isToggled[i] = true; - } - - if (!isPressed[i] && isToggled[i]){ - isToggled[i] = false; - } - } - } - - public static void forceSet(int key, boolean b) { - currentState[key] = b; - isToggled[key] = true; - } - -} diff --git a/src/com/Torvald/Terrarum/GameControl/KeyToggler.kt b/src/com/Torvald/Terrarum/GameControl/KeyToggler.kt new file mode 100644 index 000000000..5eef3b513 --- /dev/null +++ b/src/com/Torvald/Terrarum/GameControl/KeyToggler.kt @@ -0,0 +1,47 @@ +package com.Torvald.Terrarum.GameControl + +import org.newdawn.slick.GameContainer +import org.newdawn.slick.Input + +object KeyToggler { + + private val currentState = BooleanArray(256) + private val isPressed = BooleanArray(256) + private val isToggled = BooleanArray(256) + + fun isOn(key: Int): Boolean { + return currentState[key] + } + + fun update(input: Input) { + for (i in 0..255) { + if (input.isKeyDown(i)) { + isPressed[i] = true + } + else { + isPressed[i] = false + } + } + + for (i in 0..255) { + if (isPressed[i] && !currentState[i] && !isToggled[i]) { + currentState[i] = true + isToggled[i] = true + } + else if (isPressed[i] && currentState[i] && !isToggled[i]) { + currentState[i] = false + isToggled[i] = true + } + + if (!isPressed[i] && isToggled[i]) { + isToggled[i] = false + } + } + } + + fun forceSet(key: Int, b: Boolean) { + currentState[key] = b + isToggled[key] = true + } + +} diff --git a/src/com/Torvald/Terrarum/GameItem/InventoryItem.kt b/src/com/Torvald/Terrarum/GameItem/InventoryItem.kt index 7ce4389fa..eed2fd7b5 100644 --- a/src/com/Torvald/Terrarum/GameItem/InventoryItem.kt +++ b/src/com/Torvald/Terrarum/GameItem/InventoryItem.kt @@ -3,7 +3,7 @@ package com.Torvald.Terrarum.GameItem import org.newdawn.slick.GameContainer /** - * Created by minjaesong on 16-03-15. + * Created by minjaesong on 16-01-16. */ interface InventoryItem { /** @@ -17,7 +17,12 @@ interface InventoryItem { /** * Weight of the item, Float */ - var weight: Float + var mass: Float + + /** + * Scale of the item. Real mass: mass * (scale^3) + */ + var scale: Float /** * Effects applied while in pocket diff --git a/src/com/Torvald/Terrarum/GameItem/TileAsItem.kt b/src/com/Torvald/Terrarum/GameItem/TileAsItem.kt index dd79b2229..cab35535a 100644 --- a/src/com/Torvald/Terrarum/GameItem/TileAsItem.kt +++ b/src/com/Torvald/Terrarum/GameItem/TileAsItem.kt @@ -9,11 +9,12 @@ import org.newdawn.slick.GameContainer class TileAsItem(tileNum: Int) : InventoryItem { override var itemID: Long = -1 - override var weight: Float = 0f + override var mass: Float = 0f + override var scale: Float = 1f init { - itemID = tileNum as Long - weight = TilePropCodex.getProp(tileNum).density / 1000f + itemID = tileNum.toLong() + mass = TilePropCodex.getProp(tileNum).density / 1000f } override fun effectWhileInPocket(gc: GameContainer, delta_t: Int) { diff --git a/src/com/Torvald/Terrarum/GameMap/GameMap.java b/src/com/Torvald/Terrarum/GameMap/GameMap.java index 877df4432..29a4f0802 100644 --- a/src/com/Torvald/Terrarum/GameMap/GameMap.java +++ b/src/com/Torvald/Terrarum/GameMap/GameMap.java @@ -9,29 +9,22 @@ package com.Torvald.Terrarum.GameMap; -import com.sun.istack.internal.NotNull; import org.newdawn.slick.SlickException; -import java.io.Serializable; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Spliterator; -import java.util.function.Consumer; - public class GameMap { //layers private volatile MapLayer layerWall; private volatile MapLayer layerTerrain; private volatile MapLayer layerWire; - private volatile PairedMapLayer wallDamageCode; - private volatile PairedMapLayer terrainDamageCode; + private volatile PairedMapLayer wallDamage; + private volatile PairedMapLayer terrainDamage; //properties - public int width; - public int height; - public int spawnX; - public int spawnY; + private int width; + private int height; + private int spawnX; + private int spawnY; public static transient final int WALL = 0; public static transient final int TERRAIN = 1; @@ -44,6 +37,8 @@ public class GameMap { private WorldTime worldTime; public static transient final int TILES_SUPPORTED = MapLayer.RANGE * PairedMapLayer.RANGE; + public static transient final byte BITS = 1; // 1 for Byte, 2 for Char, 4 for Int, 8 for Long + public static transient final byte LAYERS = 4; // terrain, wall (terrainDamage + wallDamage), wire /** * @param width @@ -59,8 +54,8 @@ public class GameMap { layerTerrain = new MapLayer(width, height); layerWall = new MapLayer(width, height); layerWire = new MapLayer(width, height); - terrainDamageCode = new PairedMapLayer(width, height); - wallDamageCode = new PairedMapLayer(width, height); + terrainDamage = new PairedMapLayer(width, height); + wallDamage = new PairedMapLayer(width, height); globalLight = (char) 63999; worldTime = new WorldTime(); @@ -103,7 +98,7 @@ public class GameMap { * @return byte[][] damage code pair */ public byte[][] getDamageDataArray() { - return terrainDamageCode.dataPair; + return terrainDamage.dataPair; } /** @@ -123,12 +118,12 @@ public class GameMap { return layerWire; } - public PairedMapLayer getTerrainDamageCode() { - return terrainDamageCode; + public PairedMapLayer getTerrainDamage() { + return terrainDamage; } - public PairedMapLayer getWallDamageCode() { - return wallDamageCode; + public PairedMapLayer getWallDamage() { + return wallDamage; } public int getTileFromWall(int x, int y) { @@ -144,11 +139,11 @@ public class GameMap { } public int getWallDamage(int x, int y) { - return wallDamageCode.getData(x, y); + return wallDamage.getData(x, y); } public int getTerrainDamage(int x, int y) { - return terrainDamageCode.getData(x, y); + return terrainDamage.getData(x, y); } /** @@ -177,12 +172,12 @@ public class GameMap { public void setTileWall(int x, int y, byte tile, int damage) { layerWall.setTile(x, y, tile); - wallDamageCode.setData(x, y, damage); + wallDamage.setData(x, y, damage); } public void setTileTerrain(int x, int y, byte tile, int damage) { layerTerrain.setTile(x, y, tile); - terrainDamageCode.setData(x, y, damage); + terrainDamage.setData(x, y, damage); } public void setTileWire(int x, int y, byte tile) { @@ -229,4 +224,24 @@ public class GameMap { public WorldTime getWorldTime() { return worldTime; } + + public void updateWorldTime(int delta) { + worldTime.update(delta); + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + public int getSpawnX() { + return spawnX; + } + + public int getSpawnY() { + return spawnY; + } } \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/GameMap/PairedMapLayer.java b/src/com/Torvald/Terrarum/GameMap/PairedMapLayer.java index 107942ca8..23e003d45 100644 --- a/src/com/Torvald/Terrarum/GameMap/PairedMapLayer.java +++ b/src/com/Torvald/Terrarum/GameMap/PairedMapLayer.java @@ -8,7 +8,7 @@ import java.util.function.Consumer; /** * Created by minjaesong on 16-02-15. */ -public class PairedMapLayer implements Iterable { +public class PairedMapLayer implements Iterable { /** * 0b_xxxx_yyyy, x for lower index, y for higher index @@ -40,28 +40,29 @@ public class PairedMapLayer implements Iterable { /** * Returns an iterator over elements of type {@code T}. + * Note: this iterator will return combined damage, that is 0bxxxx_yyyy as whole. * * @return an Iterator. */ @Override - public Iterator iterator() { - return new Iterator() { + public Iterator iterator() { + return new Iterator() { private int iteratorCount = 0; @Override public boolean hasNext() { - return iteratorCount < width * height * 2; + return iteratorCount < width * height; } @Override - public Integer next() { - int y = iteratorCount / (width * 2); - int x = iteratorCount % (width * 2); + public Byte next() { + int y = iteratorCount / width; + int x = iteratorCount % width; // advance counter iteratorCount += 1; - return getData(x, y); + return dataPair[y][x]; } }; } @@ -74,6 +75,8 @@ public class PairedMapLayer implements Iterable { * is specified). Exceptions thrown by the action are relayed to the * caller. * + * Note: this iterator will return combined damage, that is 0bxxxx_yyyy as whole. + * * @param action The action to be performed for each element * @throws NullPointerException if the specified action is null * @implSpec

The default implementation behaves as if: @@ -85,7 +88,9 @@ public class PairedMapLayer implements Iterable { */ @Override public void forEach(Consumer action) { - throw new UnsupportedOperationException(); + for (Byte b : this) { + action.accept(b); + } } /** @@ -106,7 +111,7 @@ public class PairedMapLayer implements Iterable { * @since 1.8 */ @Override - public Spliterator spliterator() { + public Spliterator spliterator() { throw new UnsupportedOperationException(); } diff --git a/src/com/Torvald/Terrarum/GameMap/WorldTime.java b/src/com/Torvald/Terrarum/GameMap/WorldTime.java deleted file mode 100644 index 444d87266..000000000 --- a/src/com/Torvald/Terrarum/GameMap/WorldTime.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.Torvald.Terrarum.GameMap; - -import java.io.Serializable; - -/** - * Created by minjaesong on 16-01-24. - */ -public class WorldTime { - - private static int seconds = 0; - private static int minutes = 0; - private static int hours = 0; - - private static int daysCount = 0; //NOT a calendar day - - private static int days = 1; - private static int months = 1; - private static int years = 1; - - private static int dayOfWeek = 0; //0: Mondag-The first day of weekday - - /** - * 22h - */ - public static transient final int DAY_LENGTH = 79200; //must be the multiple of 3600 - private static int timeDelta = 1; - - private static transient final int HOUR_SEC = 3600; - private static transient final int MINUTE_SEC = 60; - - public static final String[] DAYNAMES = { //daynames are taken from Nynorsk (å -> o) - "Mondag" - ,"Tysdag" - ,"Midtedag" //From Islenska Miðvikudagur - ,"Torsdag" - ,"Fredag" - ,"Laurdag" - ,"Sundag" - ,"Verdag" //From Norsk word 'verd' - }; - public static final String[] DAYNAMES_SHORT = { - "Mon" - ,"Tys" - ,"Mid" - ,"Tor" - ,"Fre" - ,"Lau" - ,"Sun" - ,"Ver" - }; - - public WorldTime() { - } - - /** - * Note: Target FPS must be 60. - */ - public static void update(){ - //time - seconds += timeDelta; - - kickVariables(); - - //calendar (the world calendar) - if (dayOfWeek == 7){ - dayOfWeek = 0; - } - if ((months == 12 || (months == 7 && isLeapYear())) && days == 31){ - dayOfWeek = 7; - } - - if ((months == 12 || (months == 7 && isLeapYear())) && days == 32){ - days = 1; - months = 1; - years++; - } - else if ((months == 1 || months == 4 || months == 7 || months == 10) && days > 31){ - days = 0; - months++; - } - else if (days > 30){ - days = 0; - months++; - } - - if (months > 12){ - months = 1; - years++; - } - } - - /** - * How much time has passed today, in seconds.
- * 0 == 6 AM - * @return - */ - public static int elapsedSeconds(){ - return (HOUR_SEC * hours + MINUTE_SEC * minutes + seconds) % DAY_LENGTH; - } - - /** - * How much time has passed since the beginning, in seconds. - * @return - */ - public static long totalSeconds(){ - return (long)(DAY_LENGTH) * daysCount + HOUR_SEC * hours + MINUTE_SEC * minutes + seconds; - } - - public static boolean isLeapYear(){ - return ((years % 4 == 0) && (years % 100 != 0)) || (years % 400 == 0); - } - - public static void setTime(int t){ - days += t / DAY_LENGTH; - hours = t / HOUR_SEC; - minutes = (t - HOUR_SEC * hours) / MINUTE_SEC; - seconds = t - minutes * MINUTE_SEC; - } - - public static void addTime(int t){ - setTime(elapsedSeconds() + t); - } - - public static void setTimeDelta(int d){ - timeDelta = (d == 0) ? 1 : d; - } - - public static String getDayName(){ - return DAYNAMES[dayOfWeek]; - } - - private static void kickVariables() { - if (seconds >= 60){ - seconds = 0; - minutes++; - } - - if (minutes >= 60){ - minutes = 0; - hours++; - } - - if (hours >= DAY_LENGTH/3600){ - hours = 0; - days++; - daysCount++; - dayOfWeek++; - } - } -} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/GameMap/WorldTime.kt b/src/com/Torvald/Terrarum/GameMap/WorldTime.kt new file mode 100644 index 000000000..d2629dc2c --- /dev/null +++ b/src/com/Torvald/Terrarum/GameMap/WorldTime.kt @@ -0,0 +1,150 @@ +package com.Torvald.Terrarum.GameMap + +/** + * Created by minjaesong on 16-01-24. + */ +class WorldTime { + internal var seconds: Int + internal var minutes: Int + internal var hours: Int + + internal var daysCount: Int //NOT a calendar day + + internal var days: Int + internal var months: Int + internal var years: Int + + internal var dayOfWeek: Int //0: Mondag-The first day of weekday + + internal var timeDelta = 1 + + @Transient private var realMillisec: Int + + val DAYNAMES = arrayOf(//daynames are taken from Nynorsk (å -> o) + "Mondag", "Tysdag", "Midtedag" //From Islenska Miðvikudagur + , "Torsdag", "Fredag", "Laurdag", "Sundag", "Verdag" //From Norsk word 'verd' + ) + val DAYNAMES_SHORT = arrayOf("Mon", "Tys", "Mid", "Tor", "Fre", "Lau", "Sun", "Ver") + + + @Transient val REAL_SEC_IN_MILLI = 1000 + + init { + seconds = 0 + minutes = 0 + hours = 0 + daysCount = 0 + days = 1 + months = 1 + years = 1 + dayOfWeek = 0 + realMillisec = 0 + } + + fun update(delta: Int) { + //time + realMillisec += delta * timeDelta + seconds = Math.round(GAME_MIN_TO_REAL_SEC.toFloat() / REAL_SEC_IN_MILLI.toFloat() * realMillisec.toFloat()) + + if (realMillisec >= REAL_SEC_IN_MILLI) + realMillisec -= REAL_SEC_IN_MILLI + + kickVariables() + } + + /** + * How much time has passed today, in seconds. + * 0 == 6 AM + * @return + */ + fun elapsedSeconds(): Int { + return (HOUR_SEC * hours + MINUTE_SEC * minutes + seconds) % DAY_LENGTH + } + + val isLeapYear: Boolean + get() = years % 4 == 0 && years % 100 != 0 || years % 400 == 0 + + fun setTime(t: Int) { + days += t / DAY_LENGTH + hours = t / HOUR_SEC + minutes = (t - HOUR_SEC * hours) / MINUTE_SEC + seconds = t - minutes * MINUTE_SEC + } + + fun addTime(t: Int) { + setTime(elapsedSeconds() + t) + } + + fun setTimeDelta(d: Int) { + timeDelta = if (d < 0) 0 else d + } + + val dayName: String + get() = DAYNAMES[dayOfWeek] + + private fun kickVariables() { + if (seconds >= MINUTE_SEC) { + seconds = 0 + minutes += 1 + } + + if (minutes >= HOUR_MIN) { + minutes = 0 + hours += 1 + } + + if (hours >= DAY_LENGTH / HOUR_SEC) { + hours = 0 + days += 1 + daysCount += 1 + dayOfWeek += 1 + } + + //calendar (the world calendar) + if (dayOfWeek == 7) { + dayOfWeek = 0 + } + if ((months == 12 || months == 7 && isLeapYear) && days == 31) { + dayOfWeek = 7 + } + + if ((months == 12 || months == 7 && isLeapYear) && days == 32) { + days = 1 + months = 1 + years++ + } + else if ((months == 1 || months == 4 || months == 7 || months == 10) && days > 31) { + days = 0 + months++ + } + else if (days > 30) { + days = 0 + months++ + } + + if (months > 12) { + months = 1 + years++ + } + } + + fun getFormattedTime(): String { + fun formatMin(min: Int): String { + return if (min < 10) "0${min.toString()}" else min.toString() + } + + return "${hours}h${formatMin(minutes)}" + } + + companion object { + /** + * 22h + */ + @Transient val DAY_LENGTH = 79200 //must be the multiple of 3600 + + @Transient val HOUR_SEC: Int = 3600 + @Transient val MINUTE_SEC: Int = 60 + @Transient val HOUR_MIN: Int = 60 + @Transient val GAME_MIN_TO_REAL_SEC: Float = 60f + } +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/ItemProperties/ItemProp.kt b/src/com/Torvald/Terrarum/ItemProperties/ItemProp.kt new file mode 100644 index 000000000..511051468 --- /dev/null +++ b/src/com/Torvald/Terrarum/ItemProperties/ItemProp.kt @@ -0,0 +1,9 @@ +package com.Torvald.Terrarum.ItemProperties + +/** + * Created by minjaesong on 16-03-18. + */ +internal data class ItemProp ( + var baseMass: Float, + var material: Material +) \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/GameItem/ItemPropCodex.kt b/src/com/Torvald/Terrarum/ItemProperties/ItemPropCodex.kt similarity index 84% rename from src/com/Torvald/Terrarum/GameItem/ItemPropCodex.kt rename to src/com/Torvald/Terrarum/ItemProperties/ItemPropCodex.kt index eeb38bd34..111f97511 100644 --- a/src/com/Torvald/Terrarum/GameItem/ItemPropCodex.kt +++ b/src/com/Torvald/Terrarum/ItemProperties/ItemPropCodex.kt @@ -1,6 +1,7 @@ -package com.Torvald.Terrarum.GameItem +package com.Torvald.Terrarum.ItemProperties import com.Torvald.Terrarum.Actors.CanBeStoredAsItem +import com.Torvald.Terrarum.GameItem.InventoryItem import com.Torvald.Terrarum.Terrarum import org.newdawn.slick.GameContainer import java.util.* @@ -30,10 +31,10 @@ object ItemPropCodex { fun getItem(code: Long): InventoryItem { if (code < ITEM_UNIQUE_MAX) - return itemCodex[code as Int]!! + return itemCodex[(code and 0xFFFFFFFF).toInt()] else { for (actor in Terrarum.game.actorContainer) { - if (actor is CanBeStoredAsItem && actor.referenceID!!.equals(code)) + if (actor is CanBeStoredAsItem && actor.referenceID.equals(code)) return actor.itemData } diff --git a/src/com/Torvald/Terrarum/ItemProperties/Material.kt b/src/com/Torvald/Terrarum/ItemProperties/Material.kt new file mode 100644 index 000000000..174cedcfc --- /dev/null +++ b/src/com/Torvald/Terrarum/ItemProperties/Material.kt @@ -0,0 +1,10 @@ +package com.Torvald.Terrarum.ItemProperties + +/** + * Created by minjaesong on 16-03-18. + */ +internal data class Material ( + var maxEdge: Int, + var hardness: Int, + var density: Int +) \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/ItemProperties/MaterialFactory.kt b/src/com/Torvald/Terrarum/ItemProperties/MaterialFactory.kt new file mode 100644 index 000000000..4655052f7 --- /dev/null +++ b/src/com/Torvald/Terrarum/ItemProperties/MaterialFactory.kt @@ -0,0 +1,7 @@ +package com.Torvald.Terrarum.ItemProperties + +/** + * Created by minjaesong on 16-03-19. + */ +object MaterialFactory { +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/ItemProperties/MaterialPropCodex.kt b/src/com/Torvald/Terrarum/ItemProperties/MaterialPropCodex.kt new file mode 100644 index 000000000..085ce9130 --- /dev/null +++ b/src/com/Torvald/Terrarum/ItemProperties/MaterialPropCodex.kt @@ -0,0 +1,9 @@ +package com.Torvald.Terrarum.ItemProperties + +/** + * Created by minjaesong on 16-03-18. + */ +object MaterialPropCodex { + val CSV_PATH = "./src/com/Torvald/Terrarum/ItemProperties/materialprop.csv" + +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/KVHashMap.java b/src/com/Torvald/Terrarum/KVHashMap.java deleted file mode 100644 index f909cef33..000000000 --- a/src/com/Torvald/Terrarum/KVHashMap.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.Torvald.Terrarum; - -import com.google.gson.JsonPrimitive; - -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Set; - -/** - * Created by minjaesong on 15-12-30. - */ -public class KVHashMap { - - private HashMap hashMap; - - public KVHashMap() { - hashMap = new HashMap<>(); - } - - /** - * Add key-value pair to the configuration table. - * If key does not exist on the table, new key will be generated. - * If key already exists, the value will be overwritten. - * - * @param key case insensitive - * @param value - */ - public void set(String key, Object value){ - hashMap.put(key.toLowerCase(), value); - } - - /** - * Get value using key from configuration table. - * - * @param key case insensitive - * @return Object value - */ - public Object get(String key){ - return hashMap.get(key.toLowerCase()); - } - - public int getAsInt(String key) { - return (int) get(key); - } - - public float getAsFloat(String key) { - Object value = get(key); - if (value instanceof Integer) return ((Integer) value).floatValue(); - else if (value instanceof JsonPrimitive) return ((JsonPrimitive) value).getAsFloat(); - return (float) value; - } - - public String getAsString(String key) { - Object value = get(key); - if (value instanceof JsonPrimitive) return ((JsonPrimitive) value).getAsString(); - return (String) value; - } - - public boolean getAsBoolean(String key) { - Object value = get(key); - if (value instanceof JsonPrimitive) return ((JsonPrimitive) value).getAsBoolean(); - return (boolean) value; - } - - public boolean hasKey(String key) { - return hashMap.containsKey(key); - } - - public Set getKeySet() { - return hashMap.keySet(); - } - -} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/KVHashMap.kt b/src/com/Torvald/Terrarum/KVHashMap.kt new file mode 100644 index 000000000..be065ff2a --- /dev/null +++ b/src/com/Torvald/Terrarum/KVHashMap.kt @@ -0,0 +1,72 @@ +package com.Torvald.Terrarum + +import com.google.gson.JsonPrimitive +import java.util.* + +/** + * Created by minjaesong on 16-03-19. + */ +open class KVHashMap { + + private val hashMap: HashMap + + init { + hashMap = HashMap() + } + + /** + * Add key-value pair to the configuration table. + * If key does not exist on the table, new key will be generated. + * If key already exists, the value will be overwritten. + + * @param key case insensitive + * * + * @param value + */ + operator fun set(key: String, value: Any) { + hashMap.put(key.toLowerCase(), value) + } + + /** + * Get value using key from configuration table. + + * @param key case insensitive + * * + * @return Object value + */ + operator fun get(key: String): Any? { + return hashMap[key.toLowerCase()] + } + + fun getAsInt(key: String): Int? { + return get(key) as Int + } + + fun getAsFloat(key: String): Float? { + val value = get(key) + if (value is Int) + return value.toFloat() + else if (value is JsonPrimitive) return value.asFloat + return value as Float + } + + fun getAsString(key: String): String? { + val value = get(key) + if (value is JsonPrimitive) return value.asString + return value as String + } + + fun getAsBoolean(key: String): Boolean? { + val value = get(key) + if (value is JsonPrimitive) return value.asBoolean + return value as Boolean + } + + fun hasKey(key: String): Boolean { + return hashMap.containsKey(key) + } + + val keySet: Set + get() = hashMap.keys + +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/LangPack/Lang.java b/src/com/Torvald/Terrarum/LangPack/Lang.java index 78a77f54a..442671266 100644 --- a/src/com/Torvald/Terrarum/LangPack/Lang.java +++ b/src/com/Torvald/Terrarum/LangPack/Lang.java @@ -52,7 +52,7 @@ public class Lang { public Lang() throws IOException { lang = new Hashtable<>(); - List langPackCSV = CSVFetcher.readCSV(PATH_TO_CSV + CSV_MAIN); + List langPackCSV = CSVFetcher.INSTANCE.readCSV(PATH_TO_CSV + CSV_MAIN); File file = new File(PATH_TO_CSV); FilenameFilter filter = new FilenameFilter() { @@ -62,7 +62,7 @@ public class Lang { } }; for (String csvfilename : file.list(filter)) { - List csv = CSVFetcher.readCSV(PATH_TO_CSV + csvfilename); + List csv = CSVFetcher.INSTANCE.readCSV(PATH_TO_CSV + csvfilename); csv.forEach(langPackCSV::add); } @@ -92,7 +92,7 @@ public class Lang { public static String get(String key) { String value = null; - try { value = lang.get(key).get(Terrarum.gameLocale); } + try { value = lang.get(key).get(Terrarum.Companion.getGameLocale()); } catch (IllegalArgumentException e) { value = key; } return value; } @@ -104,7 +104,7 @@ public class Lang { public static String pluralise(String word, int count) { if (count < 2) return word; - switch (Terrarum.gameLocale) { + switch (Terrarum.Companion.getGameLocale()) { case ("fr"): if (Arrays.binarySearch(FRENCH_WORD_NORMAL_PLURAL, word) >= 0) { return word + "s"; diff --git a/src/com/Torvald/Terrarum/MapDrawer/LightmapLantern.kt b/src/com/Torvald/Terrarum/MapDrawer/LightmapLantern.kt index e6a9a7ab5..bfeed9f52 100644 --- a/src/com/Torvald/Terrarum/MapDrawer/LightmapLantern.kt +++ b/src/com/Torvald/Terrarum/MapDrawer/LightmapLantern.kt @@ -3,4 +3,8 @@ package com.Torvald.Terrarum.MapDrawer /** * Created by minjaesong on 16-03-15. */ -internal data class LightmapLantern(var x: Int, var y: Int, var intensity: Char) \ No newline at end of file +internal data class LightmapLantern( + var x: Int, + var y: Int, + var intensity: Char +) \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.kt b/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.kt index d59b79968..156ca9b69 100644 --- a/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.kt +++ b/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.kt @@ -12,7 +12,7 @@ import org.newdawn.slick.Graphics import java.util.* /** - * Created by minjaesong on 16-03-15. + * Created by minjaesong on 16-01-25. */ object LightmapRenderer { @@ -38,14 +38,16 @@ object LightmapRenderer { private val TSIZE = MapDrawer.TILE_SIZE // color model related vars - @JvmStatic val MUL = Col40.MUL - @JvmStatic val MUL_2 = Col40.MUL_2 - @JvmStatic val CHANNEL_MAX = Col40.MAX_STEP - @JvmStatic val CHANNEL_MAX_FLOAT = CHANNEL_MAX.toFloat() - @JvmStatic val COLOUR_DOMAIN_SIZE = Col40.COLOUR_DOMAIN_SIZE + const val MUL = Col40.MUL + const val MUL_2 = Col40.MUL_2 + const val CHANNEL_MAX = Col40.MAX_STEP + const val CHANNEL_MAX_FLOAT = CHANNEL_MAX.toFloat() + const val COLOUR_DOMAIN_SIZE = Col40.COLOUR_DOMAIN_SIZE - @Deprecated("") - @JvmStatic + + private const val deprecatedFeatureDebatable = "This feature is debatable. Do not use it yet." + + @Deprecated(deprecatedFeatureDebatable) fun addLantern(x: Int, y: Int, intensity: Char) { val thisLantern = LightmapLantern(x, y, intensity) @@ -63,8 +65,7 @@ object LightmapRenderer { lanterns.add(thisLantern) } - @Deprecated("") - @JvmStatic + @Deprecated(deprecatedFeatureDebatable) fun removeLantern(x: Int, y: Int) { for (i in lanterns.indices.reversed()) { val lantern = lanterns[i] @@ -74,7 +75,6 @@ object LightmapRenderer { } } - @JvmStatic fun renderLightMap() { if (staticLightMap == null) { staticLightMap = Array(Terrarum.game.map.height) { CharArray(Terrarum.game.map.width) } @@ -106,7 +106,7 @@ object LightmapRenderer { purgePartOfLightmap(for_x_start, for_y_start, for_x_end, for_y_end) // if wider purge were not applied, GL changing (sunset, sunrise) will behave incorrectly - // ("leakage" of non-updated sunlight) + // ("leakage" of not updated sunlight) try { // Round 1 @@ -142,7 +142,6 @@ object LightmapRenderer { } - @JvmStatic fun draw(g: Graphics) { val for_x_start = MapCamera.getRenderStartX() - 1 val for_y_start = MapCamera.getRenderStartY() - 1 @@ -155,7 +154,7 @@ object LightmapRenderer { var x = for_x_start while (x < for_x_end) { // smooth - if (Terrarum.game.screenZoom >= 1 && Terrarum.gameConfig.getAsBoolean("smoothlighting")) { + if (Terrarum.game.screenZoom >= 1 && Terrarum.gameConfig.getAsBoolean("smoothlighting") ?: false) { val thisLightLevel = staticLightMap!![y][x] if (y > 0 && x < for_x_end && thisLightLevel.toInt() == 0 && staticLightMap!![y - 1][x].toInt() == 0) { try { @@ -271,9 +270,7 @@ object LightmapRenderer { } - private fun calculate(x: Int, y: Int): Char { - return calculate(x, y, false) - } + private fun calculate(x: Int, y: Int): Char = calculate(x, y, false) private fun calculate(x: Int, y: Int, doNotCalculateAmbient: Boolean): Char { var lightLevelThis: Char = 0.toChar() @@ -288,14 +285,15 @@ object LightmapRenderer { if (thisTerrain == AIR && thisWall == AIR) { lightLevelThis = sunLight } + // luminous tile on top of air else if (thisWall == AIR && thisTileLuminosity.toInt() > 0) { val darkenSunlight = darkenColoured(sunLight, thisTileOpacity) - lightLevelThis = screenBlend(darkenSunlight, thisTileLuminosity) + lightLevelThis = maximiseRGB(darkenSunlight, thisTileLuminosity) } + // opaque wall and luminous tile else if (thisWall != AIR && thisTileLuminosity.toInt() > 0) { lightLevelThis = thisTileLuminosity - }// luminous tile (opaque) - // luminous tile transparent (allows sunlight to pass) + } // END MIX TILE // mix lantern @@ -370,16 +368,16 @@ object LightmapRenderer { /** * Subtract each channel's RGB value. + * * It works like: + * * f(data, darken) = RGB(data.r - darken.r, data.g - darken.g, data.b - darken.b) - - * @param data Raw channel value [0-39] per channel - * * - * @param darken [0-39] per channel - * * - * @return darkened data [0-39] per channel + * + * @param data Raw channel value (0-39) per channel + * @param darken (0-39) per channel + * @return darkened data (0-39) per channel */ - private fun darkenColoured(data: Char, darken: Char): Char { + fun darkenColoured(data: Char, darken: Char): Char { if (darken.toInt() < 0 || darken.toInt() >= COLOUR_DOMAIN_SIZE) { throw IllegalArgumentException("darken: out of " + "range") } @@ -393,15 +391,16 @@ object LightmapRenderer { /** * Darken each channel by 'darken' argument + * * It works like: + * * f(data, darken) = RGB(data.r - darken, data.g - darken, data.b - darken) - * @param data [0-39] per channel - * * - * @param darken [0-1] - * * + * + * @param data (0-39) per channel + * @param darken (0-1) * @return */ - private fun darkenUniformFloat(data: Char, darken: Float): Char { + fun darkenUniformFloat(data: Char, darken: Float): Char { if (darken < 0 || darken > 1f) { throw IllegalArgumentException("darken: out of " + "range") } @@ -415,15 +414,15 @@ object LightmapRenderer { /** * Darken each channel by 'darken' argument + * * It works like: + * * f(data, darken) = RGB(data.r - darken, data.g - darken, data.b - darken) - * @param data [0-39] per channel - * * - * @param darken [0-39] - * * + * @param data (0-39) per channel + * @param darken (0-39) * @return */ - private fun darkenUniformInt(data: Char, darken: Int): Char { + fun darkenUniformInt(data: Char, darken: Int): Char { if (darken < 0 || darken > CHANNEL_MAX) { throw IllegalArgumentException("darken: out of " + "range") } @@ -438,8 +437,10 @@ object LightmapRenderer { /** * Add each channel's RGB value. + * * It works like: - * f(data, brighten) = RGB(data.r + darken.r, data.g + darken.g, data.b + darken.b) + * + * f(data, brighten) = RGB(data.r + brighten.r, data.g + brighten.g, data.b + brighten.b) * @param data Raw channel value [0-39] per channel * * * @param brighten [0-39] per channel @@ -542,7 +543,6 @@ object LightmapRenderer { return constructRGBFromInt(newR, newG, newB) } - @JvmStatic fun constructRGBFromInt(r: Int, g: Int, b: Int): Char { if (r < 0 || r > CHANNEL_MAX) { throw IllegalArgumentException("Red: out of range") @@ -556,7 +556,6 @@ object LightmapRenderer { return (r * MUL_2 + g * MUL + b).toChar() } - @JvmStatic fun constructRGBFromFloat(r: Float, g: Float, b: Float): Char { if (r < 0 || r > 1.0f) { throw IllegalArgumentException("Red: out of range") @@ -607,40 +606,27 @@ object LightmapRenderer { return i[0] } - private fun outOfBounds(x: Int, y: Int): Boolean { - return x < 0 || y < 0 || x >= Terrarum.game.map.width || y >= Terrarum.game.map.height - } + private fun outOfBounds(x: Int, y: Int): Boolean = + x < 0 || y < 0 || x >= Terrarum.game.map.width || y >= Terrarum.game.map.height - private fun outOfMapBounds(x: Int, y: Int): Boolean { - return x < 0 || y < 0 || x >= staticLightMap!![0].size || y >= staticLightMap!!.size - } + private fun outOfMapBounds(x: Int, y: Int): Boolean = + x < 0 || y < 0 || x >= staticLightMap!![0].size || y >= staticLightMap!!.size - private fun clampZero(i: Int): Int { - return if (i < 0) 0 else i - } + private fun clampZero(i: Int): Int = if (i < 0) 0 else i - private fun clampZero(i: Float): Float { - return if (i < 0) 0f else i - } + private fun clampZero(i: Float): Float = if (i < 0) 0f else i - private fun clampByte(i: Int): Int { - return if (i < 0) 0 else if (i > CHANNEL_MAX) CHANNEL_MAX else i - } + private fun clampByte(i: Int): Int = if (i < 0) 0 else if (i > CHANNEL_MAX) CHANNEL_MAX else i - private fun clampFloat(i: Float): Float { - return if (i < 0) 0f else if (i > 1) 1f else i - } + private fun clampFloat(i: Float): Float = if (i < 0) 0f else if (i > 1) 1f else i - @JvmStatic - fun getValueFromMap(x: Int, y: Int): Char { - return staticLightMap!![y][x] - } + fun getValueFromMap(x: Int, y: Int): Char = staticLightMap!![y][x] private fun purgePartOfLightmap(x1: Int, y1: Int, x2: Int, y2: Int) { try { - for (y in y1 - 1..y2 + 1 - 1) { - for (x in x1 - 1..x2 + 1 - 1) { - if (y == y1 - 1 || y == y2 || x == x1 - 1 || x == x2) { + for (y in y1 - 1..y2 + 1) { + for (x in x1 - 1..x2 + 1) { + if (y == y1 - 1 || y == y2 + 1 || x == x1 - 1 || x == x2 + 1) { // fill the rim with (pre) calculation staticLightMap!![y][x] = preCalculateUpdateGLOnly(x, y) } @@ -656,26 +642,49 @@ object LightmapRenderer { } private fun preCalculateUpdateGLOnly(x: Int, y: Int): Char { - val thisWall = Terrarum.game.map.getTileFromWall(x, y) + var lightLevelThis: Char = 0.toChar() val thisTerrain = Terrarum.game.map.getTileFromTerrain(x, y) + val thisWall = Terrarum.game.map.getTileFromWall(x, y) val thisTileLuminosity = TilePropCodex.getProp(thisTerrain).luminosity val thisTileOpacity = TilePropCodex.getProp(thisTerrain).opacity val sunLight = Terrarum.game.map.globalLight - val lightLevelThis: Char - // MIX TILE // open air if (thisTerrain == AIR && thisWall == AIR) { lightLevelThis = sunLight } + // luminous tile on top of air else if (thisWall == AIR && thisTileLuminosity.toInt() > 0) { val darkenSunlight = darkenColoured(sunLight, thisTileOpacity) - lightLevelThis = screenBlend(darkenSunlight, thisTileLuminosity) + lightLevelThis = maximiseRGB(darkenSunlight, thisTileLuminosity) } - else { - lightLevelThis = getValueFromMap(x, y) - }// luminous tile transparent (allows sunlight to pass) + // opaque wall and luminous tile + else if (thisWall != AIR && thisTileLuminosity.toInt() > 0) { + lightLevelThis = thisTileLuminosity + } + // END MIX TILE + + // mix lantern + for (lantern in lanterns) { + if (lantern.x == x && lantern.y == y) { + lightLevelThis = screenBlend(lightLevelThis, lantern.intensity) + break + } + } + + // mix luminous actor + for (actor in Terrarum.game.actorContainer) { + if (actor is Luminous && actor is ActorWithBody) { + val tileX = Math.round(actor.hitbox!!.pointedX / TSIZE) + val tileY = Math.round(actor.hitbox!!.pointedY / TSIZE) - 1 + val actorLuminosity = actor.luminosity + if (x == tileX && y == tileY) { + lightLevelThis = screenBlend(lightLevelThis, actorLuminosity) + } + } + } + return lightLevelThis } @@ -711,7 +720,5 @@ object LightmapRenderer { return Math.round(sum / i.size.toFloat()) } - private fun toTargetColour(raw: Char): Color { - return Col40().createSlickColor(raw.toInt()) - } + private fun toTargetColour(raw: Char): Color = Col40().createSlickColor(raw.toInt()) } diff --git a/src/com/Torvald/Terrarum/MapDrawer/MapCamera.kt b/src/com/Torvald/Terrarum/MapDrawer/MapCamera.kt index aae4d1342..aa43771e9 100644 --- a/src/com/Torvald/Terrarum/MapDrawer/MapCamera.kt +++ b/src/com/Torvald/Terrarum/MapDrawer/MapCamera.kt @@ -14,7 +14,7 @@ import org.newdawn.slick.SpriteSheet import java.util.* /** - * Created by minjaesong on 16-03-15. + * Created by minjaesong on 16-01-19. */ object MapCamera { private val map: GameMap = Terrarum.game.map; diff --git a/src/com/Torvald/Terrarum/MapDrawer/MapDrawer.kt b/src/com/Torvald/Terrarum/MapDrawer/MapDrawer.kt index 9dc3592f1..878c680cb 100644 --- a/src/com/Torvald/Terrarum/MapDrawer/MapDrawer.kt +++ b/src/com/Torvald/Terrarum/MapDrawer/MapDrawer.kt @@ -8,7 +8,7 @@ import com.jme3.math.FastMath import org.newdawn.slick.* /** - * Created by minjaesong on 16-03-15. + * Created by minjaesong on 15-12-31. */ object MapDrawer { @JvmStatic val TILE_SIZE = 16 @@ -69,7 +69,6 @@ object MapDrawer { return Math.round((ENV_COLTEMP_HIGHEST - ENV_COLTEMP_LOWEST) / 2 * FastMath.clamp(x, -1f, 1f) + colTempMedian) } - @JvmStatic fun getColourFromMap(K: Int): Color { return envOverlayColourmap.getColor(colTempToImagePos(K), 0) } diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslandsPreset.java b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslandsPreset.java deleted file mode 100644 index 3ef121b70..000000000 --- a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslandsPreset.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.Torvald.Terrarum.MapGenerator; - -import com.Torvald.Rand.HQRNG; - -import java.util.Random; - -public class FloatingIslandsPreset { - - public static final int PRESETS = 5; - - static int[][] generatePreset(HQRNG random) { - int index = random.nextInt(PRESETS); - return generatePreset(index, random); - } - - static int[][] generatePreset(int index, Random random){ - if (index == 0){ - return processPreset(random, FloatingIslePreset01.data, FloatingIslePreset01.w, FloatingIslePreset01.h); - } - else if (index == 1){ - return processPreset(random, FloatingIslePreset02.data, FloatingIslePreset02.w, FloatingIslePreset02.h); - } - else if (index == 2){ - return processPreset(random, FloatingIslePreset03.data, FloatingIslePreset03.w, FloatingIslePreset03.h); - } - else if (index == 3){ - return processPreset(random, FloatingIslePreset04.data, FloatingIslePreset04.w, FloatingIslePreset04.h); - } - else if (index == 4){ - return processPreset(random, FloatingIslePreset05.data, FloatingIslePreset05.w, FloatingIslePreset05.h); - } - return null; - } - - private static int[][] processPreset(Random random, int[] preset, int w, int h){ - int[][] temp = new int[h][w]; - int counter = 0; - boolean mirrored = random.nextBoolean(); - - for (int i = 0; i < h; i++){ - for (int j = 0; j < w; j++){ - if (!mirrored){ - if (counter < preset.length - 1){ - temp[i][j] = preset[counter]; - counter++; - } - else{ - temp[i][j] = 0; - } - } - else{ - if (counter < preset.length - 1){ - temp[i][w - 1 - j] = preset[counter]; - counter++; - } - else{ - temp[i][w - 1 - j] = 0; - } - } - } - } - - return temp; - } -} diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslandsPreset.kt b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslandsPreset.kt new file mode 100644 index 000000000..e429d1665 --- /dev/null +++ b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslandsPreset.kt @@ -0,0 +1,65 @@ +package com.Torvald.Terrarum.MapGenerator + +import com.Torvald.Rand.HQRNG +import com.sun.javaws.exceptions.InvalidArgumentException + +import java.util.Random + +object FloatingIslandsPreset { + + val PRESETS = 5 + + internal fun generatePreset(random: HQRNG): Array { + val index = random.nextInt(PRESETS) + return generatePreset(index, random) + } + + internal fun generatePreset(index: Int, random: Random): Array { + if (index == 0) { + return processPreset(random, FloatingIslePreset01.data, FloatingIslePreset01.w, FloatingIslePreset01.h) + } + else if (index == 1) { + return processPreset(random, FloatingIslePreset02.data, FloatingIslePreset02.w, FloatingIslePreset02.h) + } + else if (index == 2) { + return processPreset(random, FloatingIslePreset03.data, FloatingIslePreset03.w, FloatingIslePreset03.h) + } + else if (index == 3) { + return processPreset(random, FloatingIslePreset04.data, FloatingIslePreset04.w, FloatingIslePreset04.h) + } + else { + return processPreset(random, FloatingIslePreset05.data, FloatingIslePreset05.w, FloatingIslePreset05.h) + } + } + + private fun processPreset(random: Random, preset: IntArray, w: Int, h: Int): Array { + val temp = Array(h) { IntArray(w) } + var counter = 0 + val mirrored = random.nextBoolean() + + for (i in 0..h - 1) { + for (j in 0..w - 1) { + if (!mirrored) { + if (counter < preset.size - 1) { + temp[i][j] = preset[counter] + counter++ + } + else { + temp[i][j] = 0 + } + } + else { + if (counter < preset.size - 1) { + temp[i][w - 1 - j] = preset[counter] + counter++ + } + else { + temp[i][w - 1 - j] = 0 + } + } + } + } + + return temp + } +} diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset01.java b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset01.java deleted file mode 100644 index 2d8fc71a0..000000000 --- a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset01.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.Torvald.Terr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0,0,0,0,0,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}; -} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset01.kt b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset01.kt new file mode 100644 index 000000000..1337f14bd --- /dev/null +++ b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset01.kt @@ -0,0 +1,7 @@ +package com.Torvald.Terrarum.MapGenerator + +internal object FloatingIslePreset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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2) +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset02.java b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset02.java deleted file mode 100644 index 973bc9f34..000000000 --- a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset02.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.Torvald.Terrarum.MapGenerator; - -class FloatingIslePreset02{ - public static int w = 80; - public static int h = 50; - public static int[] data = {0,0,3,3,0,3,3,3,0,0,0,0,0,0,3,3,3,0,0,0,0,3,3,3,3,3,3,3,3,0,0,0,3,3,3,3,0,0,3,3,3,3,3,3,0,0,0,0,0,3,3,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,0,0,3,3,3,3,3,0,0,0,0,0,0,0,0,0,2,2,3,2,2,2,3,3,3,3,3,3,2,2,2,3,3,3,3,2,2,2,2,2,2,2,2,3,3,3,2,2,2,2,3,3,2,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,3,3,2,2,2,2,2,3,3,3,3,0,0,0,0,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,0,0,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,2,2,2,2,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}; -} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset02.kt b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset02.kt new file mode 100644 index 000000000..071ad2d57 --- /dev/null +++ b/src/com/Torvald/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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2) +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset03.java b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset03.java deleted file mode 100644 index 22746fe01..000000000 --- a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset03.java +++ /dev/null @@ -1,7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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}; -} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset03.kt b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset03.kt new file mode 100644 index 000000000..7ce8b0a69 --- /dev/null +++ b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset03.kt @@ -0,0 +1,7 @@ +package com.Torvald.Terrarum.MapGenerator + +internal object FloatingIslePreset03 { + var w = 66 + var h = 44 + var data = intArrayOf(0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 3, 3, 2, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 2, 3, 3, 0, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2) +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset04.java b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset04.java deleted file mode 100644 index 795465a9c..000000000 --- a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset04.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.Torvald.Terrarum.MapGenerator; - -class FloatingIslePreset04{ - public static int w = 88; - public static int h = 48; - public static int[] data = {0,0,0,3,3,3,3,3,3,3,3,3,3,3,0,0,3,0,0,0,3,3,3,0,0,0,3,3,3,0,0,0,0,0,3,3,3,3,0,0,0,0,0,3,3,3,0,3,3,3,3,0,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,3,3,3,3,0,0,0,3,3,3,3,3,3,3,3,3,3,0,0,0,0,0,3,3,2,2,2,2,2,2,2,2,2,2,2,3,3,2,3,3,3,2,2,2,3,3,3,2,2,2,3,3,3,3,3,2,2,2,2,3,3,3,3,3,2,2,2,3,2,2,2,2,3,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,2,2,2,2,3,3,3,2,2,2,2,2,2,2,2,2,2,3,3,0,0,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2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com/Torvald/Terrarum/MapGenerator/FloatingIslePreset04.kt new file mode 100644 index 000000000..23ac7d93c --- /dev/null +++ b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset04.kt @@ -0,0 +1,7 @@ +package com.Torvald.Terrarum.MapGenerator + +internal object FloatingIslePreset04 { + var w = 88 + var h = 48 + var data = intArrayOf(0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 0, 0, 0, 3, 3, 3, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 2, 3, 3, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 0, 0, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2) +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset05.java b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset05.java deleted file mode 100644 index a95037647..000000000 --- a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset05.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.Torvald.Terrarum.MapGenerator; - -class FloatingIslePreset05{ - public static int w = 74; - public static int h = 77; - public static int[] data = {0,0,0,0,3,3,3,3,3,3,0,0,0,3,0,0,0,0,3,3,3,3,3,3,0,0,0,3,3,3,3,3,3,3,3,3,0,0,0,0,3,3,3,0,3,3,3,3,3,3,0,3,3,3,0,0,0,0,0,0,0,0,3,3,3,3,3,3,0,0,0,0,0,0,0,3,3,3,2,2,2,2,2,2,3,3,3,2,3,3,3,3,2,2,2,2,2,2,3,3,3,2,2,2,2,2,2,2,2,2,3,3,3,3,2,2,2,3,2,2,2,2,2,2,3,2,2,2,3,3,3,3,3,3,3,3,2,2,2,2,2,2,3,3,3,3,3,0,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,2,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}; -} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset05.kt b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset05.kt new file mode 100644 index 000000000..9edfb89e8 --- /dev/null +++ b/src/com/Torvald/Terrarum/MapGenerator/FloatingIslePreset05.kt @@ -0,0 +1,7 @@ +package com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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2) +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapGenerator/MapGenerator.kt b/src/com/Torvald/Terrarum/MapGenerator/MapGenerator.kt index 913068c29..5dc7d11ca 100644 --- a/src/com/Torvald/Terrarum/MapGenerator/MapGenerator.kt +++ b/src/com/Torvald/Terrarum/MapGenerator/MapGenerator.kt @@ -7,9 +7,6 @@ import com.Torvald.Terrarum.TileProperties.TileNameCode import com.jme3.math.FastMath import java.util.* -/** - * Created by minjaesong on 16-03-15. - */ object MapGenerator { private lateinit var map: GameMap @@ -959,9 +956,13 @@ object MapGenerator { /* Post-process */ private fun fillOcean() { - val thisSandList = intArrayOf(TileNameCode.SAND_BEACH, TileNameCode.SAND_BLACK, TileNameCode.SAND_GREEN, TileNameCode.SAND_BEACH, TileNameCode.SAND_BEACH, TileNameCode.SAND_BLACK) + val thisSandList = intArrayOf( + TileNameCode.SAND_BEACH, TileNameCode.SAND_BLACK, TileNameCode.SAND_GREEN, + TileNameCode.SAND_BEACH, TileNameCode.SAND_BEACH, TileNameCode.SAND_BLACK + ) val thisRand = HQRNG(seed!! xor random.nextLong()) val thisSand = thisSandList[thisRand.nextInt(thisSandList.size)] + // val thisSand = TileNameCode.SAND_GREEN val thisSandStr = if (thisSand == TileNameCode.SAND_BLACK) "black" @@ -1060,7 +1061,7 @@ object MapGenerator { * @return */ private fun getTerrainHeightFromHeightMap(x: Int): Int { - return TERRAIN_AVERAGE_HEIGHT - heightMap!![x] + return TERRAIN_AVERAGE_HEIGHT - heightMap[x] } @JvmStatic diff --git a/src/com/Torvald/Terrarum/MapGenerator/RoguelikeRandomiser.kt b/src/com/Torvald/Terrarum/MapGenerator/RoguelikeRandomiser.kt index 95d441fe5..2166fc591 100644 --- a/src/com/Torvald/Terrarum/MapGenerator/RoguelikeRandomiser.kt +++ b/src/com/Torvald/Terrarum/MapGenerator/RoguelikeRandomiser.kt @@ -5,7 +5,7 @@ import com.Torvald.Rand.HQRNG import java.util.* /** - * Created by minjaesong on 16-03-15. + * Created by minjaesong on 16-02-23. */ object RoguelikeRandomiser { diff --git a/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise.java b/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise.java deleted file mode 100644 index d32ff4cab..000000000 --- a/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.Torvald.Terrarum.MapGenerator; - -import com.Torvald.Rand.HQRNG; -import com.jme3.math.FastMath; - -public class SimplexNoise { - - SimplexNoise_octave[] octaves; - float[] frequencys; - float[] amplitudes; - - int largestFeature; - float persistence; - long seed; - - /** - * @param largestFeature - * @param persistence higher the value, rougher the output - * @param seed - */ - public SimplexNoise(int largestFeature, float persistence, long seed) { - this.largestFeature = largestFeature; - this.persistence = persistence; - this.seed = seed; - - //receives a number (e.g. 128) and calculates what power of 2 it is (e.g. 2^7) - int numberOfOctaves = FastMath.intLog2(largestFeature); - - octaves = new SimplexNoise_octave[numberOfOctaves]; - frequencys = new float[numberOfOctaves]; - amplitudes = new float[numberOfOctaves]; - - HQRNG rnd = new HQRNG(seed); - - for (int i = 0; i < numberOfOctaves; i++) { - octaves[i] = new SimplexNoise_octave(rnd.nextInt()); - - frequencys[i] = FastMath.pow(2, i); - amplitudes[i] = FastMath.pow(persistence, octaves.length - i); - - - } - - } - - - public float getNoise(int x, int y) { - - float result = 0; - - for (int i = 0; i < octaves.length; i++) { - //float frequency = FastMath.pow(2,i); - //float amplitude = FastMath.pow(persistence,octaves.length-i); - - result = result + (float) (octaves[i].noise(x / frequencys[i], y / frequencys[i]) * amplitudes[i]); - } - - - return result; - - } - - public float getNoise(int x, int y, int z) { - - float result = 0; - - for (int i = 0; i < octaves.length; i++) { - float frequency = FastMath.pow(2, i); - float amplitude = FastMath.pow(persistence, octaves.length - i); - - result = result + (float) (octaves[i].noise(x / frequency, y / frequency, z / frequency) * amplitude); - } - - - return result; - - } -} diff --git a/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise.kt b/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise.kt new file mode 100644 index 000000000..ef3885360 --- /dev/null +++ b/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise.kt @@ -0,0 +1,75 @@ +package com.Torvald.Terrarum.MapGenerator + +import com.Torvald.Rand.HQRNG +import com.jme3.math.FastMath + +class SimplexNoise +/** + * @param largestFeature + * * + * @param persistence higher the value, rougher the output + * * + * @param seed + */ +(internal var largestFeature: + + Int, internal var persistence: Float, internal var seed: Long) { + + internal var octaves: Array + internal var frequencys: FloatArray + internal var amplitudes: FloatArray + + init { + + //receives a number (e.g. 128) and calculates what power of 2 it is (e.g. 2^7) + val numberOfOctaves = FastMath.intLog2(largestFeature) + val rnd = HQRNG(seed) + + octaves = Array(numberOfOctaves, {i -> SimplexNoise_octave(rnd.nextInt())}) + frequencys = FloatArray(numberOfOctaves) + amplitudes = FloatArray(numberOfOctaves) + + for (i in 0..numberOfOctaves - 1) { + octaves[i] = SimplexNoise_octave(rnd.nextInt()) + + frequencys[i] = FastMath.pow(2f, i.toFloat()) + amplitudes[i] = FastMath.pow(persistence, (octaves.size - i).toFloat()) + + + } + + } + + + fun getNoise(x: Int, y: Int): Float { + + var result = 0f + + for (i in octaves.indices) { + //float frequency = FastMath.pow(2,i); + //float amplitude = FastMath.pow(persistence,octaves.length-i); + + result += (octaves[i].noise((x / frequencys[i]).toDouble(), (y / frequencys[i]).toDouble()) * amplitudes[i]).toFloat() + } + + + return result + + } + + fun getNoise(x: Int, y: Int, z: Int): Float { + + var result = 0f + + for (i in octaves.indices) { + val frequency = FastMath.pow(2f, i.toFloat()) + val amplitude = FastMath.pow(persistence, (octaves.size - i).toFloat()) + + result += (octaves[i].noise((x / frequency).toDouble(), (y / frequency).toDouble(), (z / frequency).toDouble()) * amplitude).toFloat() + } + + + return result + + } +} diff --git a/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise_octave.java b/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise_octave.java deleted file mode 100644 index 3387c3061..000000000 --- a/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise_octave.java +++ /dev/null @@ -1,388 +0,0 @@ -package com.Torvald.Terrarum.MapGenerator; - -/* - * A speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. - * - * Based on example code by Stefan Gustavson (stegu@itn.liu.se). - * Optimisations by Peter Eastman (peastman@drizzle.stanford.edu). - * Better rank ordering method by Stefan Gustavson in 2012. - * - * This could be speeded up even further, but it's useful as it is. - * - * Version 2012-03-09 - * - * This code was placed in the public domain by its original author, - * Stefan Gustavson. You may use it as you see fit, but - * attribution is appreciated. - * - */ - -import com.Torvald.Rand.HQRNG; - -public class SimplexNoise_octave { // Simplex noise in 2D, 3D and 4D - - public static int RANDOMSEED=0; - private static int NUMBEROFSWAPS=400; - - private static Grad grad3[] = {new Grad(1,1,0),new Grad(-1,1,0),new Grad(1,-1,0),new Grad(-1,-1,0), - new Grad(1,0,1),new Grad(-1,0,1),new Grad(1,0,-1),new Grad(-1,0,-1), - new Grad(0,1,1),new Grad(0,-1,1),new Grad(0,1,-1),new Grad(0,-1,-1)}; - - private static Grad grad4[]= {new Grad(0,1,1,1),new Grad(0,1,1,-1),new Grad(0,1,-1,1),new Grad(0,1,-1,-1), - new Grad(0,-1,1,1),new Grad(0,-1,1,-1),new Grad(0,-1,-1,1),new Grad(0,-1,-1,-1), - new Grad(1,0,1,1),new Grad(1,0,1,-1),new Grad(1,0,-1,1),new Grad(1,0,-1,-1), - new Grad(-1,0,1,1),new Grad(-1,0,1,-1),new Grad(-1,0,-1,1),new Grad(-1,0,-1,-1), - new Grad(1,1,0,1),new Grad(1,1,0,-1),new Grad(1,-1,0,1),new Grad(1,-1,0,-1), - new Grad(-1,1,0,1),new Grad(-1,1,0,-1),new Grad(-1,-1,0,1),new Grad(-1,-1,0,-1), - new Grad(1,1,1,0),new Grad(1,1,-1,0),new Grad(1,-1,1,0),new Grad(1,-1,-1,0), - new Grad(-1,1,1,0),new Grad(-1,1,-1,0),new Grad(-1,-1,1,0),new Grad(-1,-1,-1,0)}; - - private static short p_supply[] = {151,160,137,91,90,15, //this contains all the numbers between 0 and 255, these are put in a random order depending upon the seed - 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, - 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, - 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, - 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244, - 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196, - 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123, - 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42, - 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9, - 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228, - 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, - 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, - 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180}; - - private short p[]=new short[p_supply.length]; - - // To remove the need for index wrapping, double the permutation table length - private short perm[] = new short[512]; - private short permMod12[] = new short[512]; - public SimplexNoise_octave(int seed) { - p=p_supply.clone(); - - if (seed==RANDOMSEED){ - throw new IllegalArgumentException("Seed cannot be zero."); - } - - //the random for the swaps - HQRNG rand=new HQRNG(seed); - - //the seed determines the swaps that occur between the default order and the order we're actually going to use - for(int i=0;iy0) {i1=1; j1=0;} // lower triangle, XY order: (0,0)->(1,0)->(1,1) - else {i1=0; j1=1;} // upper triangle, YX order: (0,0)->(0,1)->(1,1) - // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and - // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where - // c = (3-sqrt(3))/6 - double x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords - double y1 = y0 - j1 + G2; - double x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords - double y2 = y0 - 1.0 + 2.0 * G2; - // Work out the hashed gradient indices of the three simplex corners - int ii = i & 255; - int jj = j & 255; - int gi0 = permMod12[ii+perm[jj]]; - int gi1 = permMod12[ii+i1+perm[jj+j1]]; - int gi2 = permMod12[ii+1+perm[jj+1]]; - // Calculate the contribution from the three corners - double t0 = 0.5 - x0*x0-y0*y0; - if(t0<0) n0 = 0.0; - else { - t0 *= t0; - n0 = t0 * t0 * dot(grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient - } - double t1 = 0.5 - x1*x1-y1*y1; - if(t1<0) n1 = 0.0; - else { - t1 *= t1; - n1 = t1 * t1 * dot(grad3[gi1], x1, y1); - } - double t2 = 0.5 - x2*x2-y2*y2; - if(t2<0) n2 = 0.0; - else { - t2 *= t2; - n2 = t2 * t2 * dot(grad3[gi2], x2, y2); - } - // Add contributions from each corner to get the final noise value. - // The result is scaled to return values in the interval [-1,1]. - return 70.0 * (n0 + n1 + n2); - } - - - // 3D simplex noise - public double noise(double xin, double yin, double zin) { - double n0, n1, n2, n3; // Noise contributions from the four corners - // Skew the input space to determine which simplex cell we're in - double s = (xin+yin+zin)*F3; // Very nice and simple skew factor for 3D - int i = fastfloor(xin+s); - int j = fastfloor(yin+s); - int k = fastfloor(zin+s); - double t = (i+j+k)*G3; - double X0 = i-t; // Unskew the cell origin back to (x,y,z) space - double Y0 = j-t; - double Z0 = k-t; - double x0 = xin-X0; // The x,y,z distances from the cell origin - double y0 = yin-Y0; - double z0 = zin-Z0; - // For the 3D case, the simplex shape is a slightly irregular tetrahedron. - // Determine which simplex we are in. - int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords - int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords - if(x0>=y0) { - if(y0>=z0) - { i1=1; j1=0; k1=0; i2=1; j2=1; k2=0; } // X Y Z order - else if(x0>=z0) { i1=1; j1=0; k1=0; i2=1; j2=0; k2=1; } // X Z Y order - else { i1=0; j1=0; k1=1; i2=1; j2=0; k2=1; } // Z X Y order - } - else { // x0 y0) rankx++; else ranky++; - if(x0 > z0) rankx++; else rankz++; - if(x0 > w0) rankx++; else rankw++; - if(y0 > z0) ranky++; else rankz++; - if(y0 > w0) ranky++; else rankw++; - if(z0 > w0) rankz++; else rankw++; - int i1, j1, k1, l1; // The integer offsets for the second simplex corner - int i2, j2, k2, l2; // The integer offsets for the third simplex corner - int i3, j3, k3, l3; // The integer offsets for the fourth simplex corner - // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order. - // Many values of c will never occur, since e.g. x>y>z>w makes x= 3 ? 1 : 0; - j1 = ranky >= 3 ? 1 : 0; - k1 = rankz >= 3 ? 1 : 0; - l1 = rankw >= 3 ? 1 : 0; - // Rank 2 denotes the second largest coordinate. - i2 = rankx >= 2 ? 1 : 0; - j2 = ranky >= 2 ? 1 : 0; - k2 = rankz >= 2 ? 1 : 0; - l2 = rankw >= 2 ? 1 : 0; - // Rank 1 denotes the second smallest coordinate. - i3 = rankx >= 1 ? 1 : 0; - j3 = ranky >= 1 ? 1 : 0; - k3 = rankz >= 1 ? 1 : 0; - l3 = rankw >= 1 ? 1 : 0; - // The fifth corner has all coordinate offsets = 1, so no need to compute that. - double x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords - double y1 = y0 - j1 + G4; - double z1 = z0 - k1 + G4; - double w1 = w0 - l1 + G4; - double x2 = x0 - i2 + 2.0*G4; // Offsets for third corner in (x,y,z,w) coords - double y2 = y0 - j2 + 2.0*G4; - double z2 = z0 - k2 + 2.0*G4; - double w2 = w0 - l2 + 2.0*G4; - double x3 = x0 - i3 + 3.0*G4; // Offsets for fourth corner in (x,y,z,w) coords - double y3 = y0 - j3 + 3.0*G4; - double z3 = z0 - k3 + 3.0*G4; - double w3 = w0 - l3 + 3.0*G4; - double x4 = x0 - 1.0 + 4.0*G4; // Offsets for last corner in (x,y,z,w) coords - double y4 = y0 - 1.0 + 4.0*G4; - double z4 = z0 - 1.0 + 4.0*G4; - double w4 = w0 - 1.0 + 4.0*G4; - // Work out the hashed gradient indices of the five simplex corners - int ii = i & 255; - int jj = j & 255; - int kk = k & 255; - int ll = l & 255; - int gi0 = perm[ii+perm[jj+perm[kk+perm[ll]]]] % 32; - int gi1 = perm[ii+i1+perm[jj+j1+perm[kk+k1+perm[ll+l1]]]] % 32; - int gi2 = perm[ii+i2+perm[jj+j2+perm[kk+k2+perm[ll+l2]]]] % 32; - int gi3 = perm[ii+i3+perm[jj+j3+perm[kk+k3+perm[ll+l3]]]] % 32; - int gi4 = perm[ii+1+perm[jj+1+perm[kk+1+perm[ll+1]]]] % 32; - // Calculate the contribution from the five corners - double t0 = 0.6 - x0*x0 - y0*y0 - z0*z0 - w0*w0; - if(t0<0) n0 = 0.0; - else { - t0 *= t0; - n0 = t0 * t0 * dot(grad4[gi0], x0, y0, z0, w0); - } - double t1 = 0.6 - x1*x1 - y1*y1 - z1*z1 - w1*w1; - if(t1<0) n1 = 0.0; - else { - t1 *= t1; - n1 = t1 * t1 * dot(grad4[gi1], x1, y1, z1, w1); - } - double t2 = 0.6 - x2*x2 - y2*y2 - z2*z2 - w2*w2; - if(t2<0) n2 = 0.0; - else { - t2 *= t2; - n2 = t2 * t2 * dot(grad4[gi2], x2, y2, z2, w2); - } - double t3 = 0.6 - x3*x3 - y3*y3 - z3*z3 - w3*w3; - if(t3<0) n3 = 0.0; - else { - t3 *= t3; - n3 = t3 * t3 * dot(grad4[gi3], x3, y3, z3, w3); - } - double t4 = 0.6 - x4*x4 - y4*y4 - z4*z4 - w4*w4; - if(t4<0) n4 = 0.0; - else { - t4 *= t4; - n4 = t4 * t4 * dot(grad4[gi4], x4, y4, z4, w4); - } - // Sum up and scale the result to cover the range [-1,1] - return 27.0 * (n0 + n1 + n2 + n3 + n4); - } - - // Inner class to speed upp gradient computations - // (array access is a lot slower than member access) - private static class Grad - { - double x, y, z, w; - - Grad(double x, double y, double z) - { - this.x = x; - this.y = y; - this.z = z; - } - - Grad(double x, double y, double z, double w) - { - this.x = x; - this.y = y; - this.z = z; - this.w = w; - } - } - -} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise_octave.kt b/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise_octave.kt new file mode 100644 index 000000000..e856502d6 --- /dev/null +++ b/src/com/Torvald/Terrarum/MapGenerator/SimplexNoise_octave.kt @@ -0,0 +1,457 @@ +package com.Torvald.Terrarum.MapGenerator + +/* + * A speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. + * + * Based on example code by Stefan Gustavson (stegu@itn.liu.se). + * Optimisations by Peter Eastman (peastman@drizzle.stanford.edu). + * Better rank ordering method by Stefan Gustavson in 2012. + * + * This could be speeded up even further, but it's useful as it is. + * + * Version 2012-03-09 + * + * This code was placed in the public domain by its original author, + * Stefan Gustavson. You may use it as you see fit, but + * attribution is appreciated. + * + */ + +import com.Torvald.Rand.HQRNG + +class SimplexNoise_octave(seed: Int) { // Simplex noise in 2D, 3D and 4D + + private var p = ShortArray(p_supply.size) + + // To remove the need for index wrapping, double the permutation table length + private val perm = ShortArray(512) + private val permMod12 = ShortArray(512) + + init { + p = p_supply.clone() + + if (seed == RANDOMSEED) { + throw IllegalArgumentException("Seed cannot be zero.") + } + + //the random for the swaps + val rand = HQRNG(seed.toLong()) + + //the seed determines the swaps that occur between the default order and the order we're actually going to use + for (i in 0..NUMBEROFSWAPS - 1) { + val swapFrom = rand.nextInt(p.size) + val swapTo = rand.nextInt(p.size) + + val temp = p[swapFrom] + p[swapFrom] = p[swapTo] + p[swapTo] = temp + } + + + for (i in 0..511) { + perm[i] = p[i and 255] + permMod12[i] = (perm[i] % 12).toShort() + } + } + + + // 2D simplex noise + fun noise(xin: Double, yin: Double): Double { + val n0: Double + val n1: Double + val n2: Double // Noise contributions from the three corners + // Skew the input space to determine which simplex cell we're in + val s = (xin + yin) * F2 // Hairy factor for 2D + val i = fastfloor(xin + s) + val j = fastfloor(yin + s) + val t = (i + j) * G2 + val X0 = i - t // Unskew the cell origin back to (x,y) space + val Y0 = j - t + val x0 = xin - X0 // The x,y distances from the cell origin + val y0 = yin - Y0 + // For the 2D case, the simplex shape is an equilateral triangle. + // Determine which simplex we are in. + val i1: Int + val j1: Int // Offsets for second (middle) corner of simplex in (i,j) coords + if (x0 > y0) { + i1 = 1 + j1 = 0 + } // lower triangle, XY order: (0,0)->(1,0)->(1,1) + else { + i1 = 0 + j1 = 1 + } // upper triangle, YX order: (0,0)->(0,1)->(1,1) + // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and + // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where + // c = (3-sqrt(3))/6 + val x1 = x0 - i1 + G2 // Offsets for middle corner in (x,y) unskewed coords + val y1 = y0 - j1 + G2 + val x2 = x0 - 1.0 + 2.0 * G2 // Offsets for last corner in (x,y) unskewed coords + val y2 = y0 - 1.0 + 2.0 * G2 + // Work out the hashed gradient indices of the three simplex corners + val ii = i and 255 + val jj = j and 255 + val gi0 = permMod12[ii + perm[jj]].toInt() + val gi1 = permMod12[ii + i1 + perm[jj + j1].toInt()].toInt() + val gi2 = permMod12[ii + 1 + perm[jj + 1].toInt()].toInt() + // Calculate the contribution from the three corners + var t0 = 0.5 - x0 * x0 - y0 * y0 + if (t0 < 0) + n0 = 0.0 + else { + t0 *= t0 + n0 = t0 * t0 * dot(grad3[gi0], x0, y0) // (x,y) of grad3 used for 2D gradient + } + var t1 = 0.5 - x1 * x1 - y1 * y1 + if (t1 < 0) + n1 = 0.0 + else { + t1 *= t1 + n1 = t1 * t1 * dot(grad3[gi1], x1, y1) + } + var t2 = 0.5 - x2 * x2 - y2 * y2 + if (t2 < 0) + n2 = 0.0 + else { + t2 *= t2 + n2 = t2 * t2 * dot(grad3[gi2], x2, y2) + } + // Add contributions from each corner to get the final noise value. + // The result is scaled to return values in the interval [-1,1]. + return 70.0 * (n0 + n1 + n2) + } + + + // 3D simplex noise + fun noise(xin: Double, yin: Double, zin: Double): Double { + val n0: Double + val n1: Double + val n2: Double + val n3: Double // Noise contributions from the four corners + // Skew the input space to determine which simplex cell we're in + val s = (xin + yin + zin) * F3 // Very nice and simple skew factor for 3D + val i = fastfloor(xin + s) + val j = fastfloor(yin + s) + val k = fastfloor(zin + s) + val t = (i + j + k) * G3 + val X0 = i - t // Unskew the cell origin back to (x,y,z) space + val Y0 = j - t + val Z0 = k - t + val x0 = xin - X0 // The x,y,z distances from the cell origin + val y0 = yin - Y0 + val z0 = zin - Z0 + // For the 3D case, the simplex shape is a slightly irregular tetrahedron. + // Determine which simplex we are in. + val i1: Int + val j1: Int + val k1: Int // Offsets for second corner of simplex in (i,j,k) coords + val i2: Int + val j2: Int + val k2: Int // Offsets for third corner of simplex in (i,j,k) coords + if (x0 >= y0) { + if (y0 >= z0) { + i1 = 1 + j1 = 0 + k1 = 0 + i2 = 1 + j2 = 1 + k2 = 0 + } // X Y Z order + else if (x0 >= z0) { + i1 = 1 + j1 = 0 + k1 = 0 + i2 = 1 + j2 = 0 + k2 = 1 + } // X Z Y order + else { + i1 = 0 + j1 = 0 + k1 = 1 + i2 = 1 + j2 = 0 + k2 = 1 + } // Z X Y order + } + else { + // x0 y0) rankx++ else ranky++ + if (x0 > z0) rankx++ else rankz++ + if (x0 > w0) rankx++ else rankw++ + if (y0 > z0) ranky++ else rankz++ + if (y0 > w0) ranky++ else rankw++ + if (z0 > w0) rankz++ else rankw++ + val i1: Int + val j1: Int + val k1: Int + val l1: Int // The integer offsets for the second simplex corner + val i2: Int + val j2: Int + val k2: Int + val l2: Int // The integer offsets for the third simplex corner + val i3: Int + val j3: Int + val k3: Int + val l3: Int // The integer offsets for the fourth simplex corner + // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order. + // Many values of c will never occur, since e.g. x>y>z>w makes x= 3) 1 else 0 + j1 = if (ranky >= 3) 1 else 0 + k1 = if (rankz >= 3) 1 else 0 + l1 = if (rankw >= 3) 1 else 0 + // Rank 2 denotes the second largest coordinate. + i2 = if (rankx >= 2) 1 else 0 + j2 = if (ranky >= 2) 1 else 0 + k2 = if (rankz >= 2) 1 else 0 + l2 = if (rankw >= 2) 1 else 0 + // Rank 1 denotes the second smallest coordinate. + i3 = if (rankx >= 1) 1 else 0 + j3 = if (ranky >= 1) 1 else 0 + k3 = if (rankz >= 1) 1 else 0 + l3 = if (rankw >= 1) 1 else 0 + // The fifth corner has all coordinate offsets = 1, so no need to compute that. + val x1 = x0 - i1 + G4 // Offsets for second corner in (x,y,z,w) coords + val y1 = y0 - j1 + G4 + val z1 = z0 - k1 + G4 + val w1 = w0 - l1 + G4 + val x2 = x0 - i2 + 2.0 * G4 // Offsets for third corner in (x,y,z,w) coords + val y2 = y0 - j2 + 2.0 * G4 + val z2 = z0 - k2 + 2.0 * G4 + val w2 = w0 - l2 + 2.0 * G4 + val x3 = x0 - i3 + 3.0 * G4 // Offsets for fourth corner in (x,y,z,w) coords + val y3 = y0 - j3 + 3.0 * G4 + val z3 = z0 - k3 + 3.0 * G4 + val w3 = w0 - l3 + 3.0 * G4 + val x4 = x0 - 1.0 + 4.0 * G4 // Offsets for last corner in (x,y,z,w) coords + val y4 = y0 - 1.0 + 4.0 * G4 + val z4 = z0 - 1.0 + 4.0 * G4 + val w4 = w0 - 1.0 + 4.0 * G4 + // Work out the hashed gradient indices of the five simplex corners + val ii = i and 255 + val jj = j and 255 + val kk = k and 255 + val ll = l and 255 + val gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32 + val gi1 = perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1].toInt()].toInt()].toInt()] % 32 + val gi2 = perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2].toInt()].toInt()].toInt()] % 32 + val gi3 = perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3].toInt()].toInt()].toInt()] % 32 + val gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1].toInt()].toInt()].toInt()] % 32 + // Calculate the contribution from the five corners + var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0 + if (t0 < 0) + n0 = 0.0 + else { + t0 *= t0 + n0 = t0 * t0 * dot(grad4[gi0], x0, y0, z0, w0) + } + var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1 + if (t1 < 0) + n1 = 0.0 + else { + t1 *= t1 + n1 = t1 * t1 * dot(grad4[gi1], x1, y1, z1, w1) + } + var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2 + if (t2 < 0) + n2 = 0.0 + else { + t2 *= t2 + n2 = t2 * t2 * dot(grad4[gi2], x2, y2, z2, w2) + } + var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3 + if (t3 < 0) + n3 = 0.0 + else { + t3 *= t3 + n3 = t3 * t3 * dot(grad4[gi3], x3, y3, z3, w3) + } + var t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4 + if (t4 < 0) + n4 = 0.0 + else { + t4 *= t4 + n4 = t4 * t4 * dot(grad4[gi4], x4, y4, z4, w4) + } + // Sum up and scale the result to cover the range [-1,1] + return 27.0 * (n0 + n1 + n2 + n3 + n4) + } + + // Inner class to speed upp gradient computations + // (array access is a lot slower than member access) + private class Grad { + internal var x: Double = 0.toDouble() + internal var y: Double = 0.toDouble() + internal var z: Double = 0.toDouble() + internal var w: Double = 0.toDouble() + + internal constructor(x: Double, y: Double, z: Double) { + this.x = x + this.y = y + this.z = z + } + + internal constructor(x: Double, y: Double, z: Double, w: Double) { + this.x = x + this.y = y + this.z = z + this.w = w + } + } + + companion object { + + var RANDOMSEED = 0 + private val NUMBEROFSWAPS = 400 + + private val grad3 = arrayOf(Grad(1.0, 1.0, 0.0), Grad(-1.0, 1.0, 0.0), Grad(1.0, -1.0, 0.0), Grad(-1.0, -1.0, 0.0), Grad(1.0, 0.0, 1.0), Grad(-1.0, 0.0, 1.0), Grad(1.0, 0.0, -1.0), Grad(-1.0, 0.0, -1.0), Grad(0.0, 1.0, 1.0), Grad(0.0, -1.0, 1.0), Grad(0.0, 1.0, -1.0), Grad(0.0, -1.0, -1.0)) + + private val grad4 = arrayOf(Grad(0.0, 1.0, 1.0, 1.0), Grad(0.0, 1.0, 1.0, -1.0), Grad(0.0, 1.0, -1.0, 1.0), Grad(0.0, 1.0, -1.0, -1.0), Grad(0.0, -1.0, 1.0, 1.0), Grad(0.0, -1.0, 1.0, -1.0), Grad(0.0, -1.0, -1.0, 1.0), Grad(0.0, -1.0, -1.0, -1.0), Grad(1.0, 0.0, 1.0, 1.0), Grad(1.0, 0.0, 1.0, -1.0), Grad(1.0, 0.0, -1.0, 1.0), Grad(1.0, 0.0, -1.0, -1.0), Grad(-1.0, 0.0, 1.0, 1.0), Grad(-1.0, 0.0, 1.0, -1.0), Grad(-1.0, 0.0, -1.0, 1.0), Grad(-1.0, 0.0, -1.0, -1.0), Grad(1.0, 1.0, 0.0, 1.0), Grad(1.0, 1.0, 0.0, -1.0), Grad(1.0, -1.0, 0.0, 1.0), Grad(1.0, -1.0, 0.0, -1.0), Grad(-1.0, 1.0, 0.0, 1.0), Grad(-1.0, 1.0, 0.0, -1.0), Grad(-1.0, -1.0, 0.0, 1.0), Grad(-1.0, -1.0, 0.0, -1.0), Grad(1.0, 1.0, 1.0, 0.0), Grad(1.0, 1.0, -1.0, 0.0), Grad(1.0, -1.0, 1.0, 0.0), Grad(1.0, -1.0, -1.0, 0.0), Grad(-1.0, 1.0, 1.0, 0.0), Grad(-1.0, 1.0, -1.0, 0.0), Grad(-1.0, -1.0, 1.0, 0.0), Grad(-1.0, -1.0, -1.0, 0.0)) + + private val p_supply = shortArrayOf(151, 160, 137, 91, 90, 15, //this contains all the numbers between 0 and 255, these are put in a random order depending upon the seed + 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180) + + // Skewing and unskewing factors for 2, 3, and 4 dimensions + private val F2 = 0.5 * (Math.sqrt(3.0) - 1.0) + private val G2 = (3.0 - Math.sqrt(3.0)) / 6.0 + private val F3 = 1.0 / 3.0 + private val G3 = 1.0 / 6.0 + private val F4 = (Math.sqrt(5.0) - 1.0) / 4.0 + private val G4 = (5.0 - Math.sqrt(5.0)) / 20.0 + + // This method is a *lot* faster than using (int)Math.floor(x) + private fun fastfloor(x: Double): Int { + val xi = x.toInt() + return if (x < xi) xi - 1 else xi + } + + private fun dot(g: Grad, x: Double, y: Double): Double { + return g.x * x + g.y * y + } + + private fun dot(g: Grad, x: Double, y: Double, z: Double): Double { + return g.x * x + g.y * y + g.z * z + } + + private fun dot(g: Grad, x: Double, y: Double, z: Double, w: Double): Double { + return g.x * x + g.y * y + g.z * z + g.w * w + } + } + +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/NoNegative.java b/src/com/Torvald/Terrarum/NoNegative.java deleted file mode 100644 index 4471df1ce..000000000 --- a/src/com/Torvald/Terrarum/NoNegative.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.Torvald.Terrarum; - -/** - * Created by minjaesong on 16-03-05. - */ -public @interface NoNegative { - String info() default "Only positive number is acceptable."; -} diff --git a/src/com/Torvald/Terrarum/NonZero.java b/src/com/Torvald/Terrarum/NonZero.java deleted file mode 100644 index 54e882d1b..000000000 --- a/src/com/Torvald/Terrarum/NonZero.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.Torvald.Terrarum; - -/** - * Created by minjaesong on 16-03-05. - */ -public @interface NonZero { - String info() default "Non-zero value"; -} diff --git a/src/com/Torvald/Terrarum/NotNull.java b/src/com/Torvald/Terrarum/NotNull.java deleted file mode 100644 index 1e1377862..000000000 --- a/src/com/Torvald/Terrarum/NotNull.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.Torvald.Terrarum; - -/** - * Created by minjaesong on 16-03-05. - */ -public @interface NotNull { - String info() default "Cannot be null."; -} diff --git a/src/com/Torvald/Terrarum/Nullable.java b/src/com/Torvald/Terrarum/Nullable.java deleted file mode 100644 index 8008721de..000000000 --- a/src/com/Torvald/Terrarum/Nullable.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.Torvald.Terrarum; - -/** - * Created by minjaesong on 16-03-05. - */ -public @interface Nullable { - String info() default "Null value is acceptable."; -} diff --git a/src/com/Torvald/Terrarum/SAVE_FORMAT b/src/com/Torvald/Terrarum/SAVE_FORMAT index 5c51e7748..27aa87ba0 100644 --- a/src/com/Torvald/Terrarum/SAVE_FORMAT +++ b/src/com/Torvald/Terrarum/SAVE_FORMAT @@ -14,6 +14,7 @@ Byte[32] hash3 SHA-256 hash of worldinfo3 being stored Byte[32] hash4 SHA-256 hash of worldinfo4 being stored (TEMD data) [32, 214, 42, 3, 76, ...] + Endianness: Big * Actor data - GZip'd GSON @@ -22,17 +23,12 @@ * Prop data - GZip'd CSV - - Filename : worldinfo1 -- tileprop.csv - worldinfo2 -- itemprop.csv - worldinfo3 -- materialprop.csv + - Filename : worldinfo2 -- tileprop.csv + worldinfo3 -- itemprop.csv + worldinfo4 -- materialprop.csv (with no extension) -* Roguelike randomiser data - - GZip'd GSON - - Filename : worldinfo3 - - * Human-readable - Tiles_list.txt -- list of tiles in csv - Items_list.txt -- list of items in csv @@ -52,7 +48,7 @@ --- Items_list.txt Human-readable --- Tiles_list.txt Human-readable --- world save meta - --- worldinfo1 tileprop - --- worldinfo2 itemprop - --- worldinfo3 materialprop - --- worldinfo4 TEMD binary + --- worldinfo1 TEMD binary + --- worldinfo2 tileprop + --- worldinfo3 itemprop + --- worldinfo4 materialprop diff --git a/src/com/Torvald/Terrarum/Terrarum.java b/src/com/Torvald/Terrarum/Terrarum similarity index 100% rename from src/com/Torvald/Terrarum/Terrarum.java rename to src/com/Torvald/Terrarum/Terrarum diff --git a/src/com/Torvald/Terrarum/Terrarum.kt b/src/com/Torvald/Terrarum/Terrarum.kt new file mode 100644 index 000000000..36bde460e --- /dev/null +++ b/src/com/Torvald/Terrarum/Terrarum.kt @@ -0,0 +1,337 @@ +package com.Torvald.Terrarum + +import com.Torvald.ImageFont.GameFontWhite +import com.Torvald.JsonFetcher +import com.Torvald.JsonWriter +import com.Torvald.Terrarum.LangPack.Lang +import org.lwjgl.input.Controllers +import org.newdawn.slick.AppGameContainer +import org.newdawn.slick.Font +import org.newdawn.slick.GameContainer +import org.newdawn.slick.SlickException +import org.newdawn.slick.state.StateBasedGame +import java.io.File +import java.io.IOException +import java.util.logging.Level +import java.util.logging.Logger + +/** + * Created by minjaesong on 15-12-30. + * Kotlin code: Created by minjaesong on 16-03-19. + */ +class Terrarum @Throws(SlickException::class) +constructor(gamename: String) : StateBasedGame(gamename) { + + init { + + gameConfig = GameConfig() + + getDefaultDirectory() + createDirs() + + val readFromDisk = readConfigJson() + if (!readFromDisk) readConfigJson() + + // get locale from config + gameLocale = gameConfig.getAsString("language") ?: sysLang + + // if bad game locale were set, use system locale + if (gameLocale.length < 4) + gameLocale = sysLang + + println("[Terrarum] Locale: " + gameLocale) + } + + @Throws(SlickException::class) + override fun initStatesList(gc: GameContainer) { + gameFontWhite = GameFontWhite() + + try { + Lang() + } + catch (e: IOException) { + e.printStackTrace() + } + + hasController = gc.input.controllerCount > 0 + if (hasController) { + for (c in 0..Controllers.getController(0).axisCount - 1) { + Controllers.getController(0).setDeadZone(c, CONTROLLER_DEADZONE) + } + } + + appgc.input.enableKeyRepeat() + + game = Game() + addState(game) + } + + companion object { + + /** + * To be used with physics simulator + */ + val TARGET_FPS = 50 + + /** + * To be used with render, to achieve smooth frame drawing + + * TARGET_INTERNAL_FPS > TARGET_FPS for smooth frame drawing + + * Must choose a value so that (1000 / VAL) is still integer + */ + val TARGET_INTERNAL_FPS = 100 + + lateinit var appgc: AppGameContainer + + val WIDTH = 1060 + val HEIGHT = 742 // IMAX ratio + var VSYNC = true + val VSYNC_TRIGGER_THRESHOLD = 56 + + lateinit var game: Game + lateinit var gameConfig: GameConfig + + lateinit var OSName: String + lateinit var OSVersion: String + lateinit var OperationSystem: String + lateinit var defaultDir: String + lateinit var defaultSaveDir: String + + var gameLocale = "" // locale override + + lateinit var gameFontWhite: Font + + val SCENE_ID_HOME = 1 + val SCENE_ID_GAME = 3 + + var hasController = false + val CONTROLLER_DEADZONE = 0.1f + + private lateinit var configDir: String + + @JvmStatic fun main(args: Array) { + try { + appgc = AppGameContainer(Terrarum("Terrarum")) + appgc.setDisplayMode(WIDTH, HEIGHT, false) + + appgc.setTargetFrameRate(TARGET_INTERNAL_FPS) + appgc.setVSync(VSYNC) + appgc.setMaximumLogicUpdateInterval(1000 / TARGET_INTERNAL_FPS) + appgc.setMinimumLogicUpdateInterval(1000 / TARGET_INTERNAL_FPS - 1) + + appgc.setShowFPS(false) + appgc.setUpdateOnlyWhenVisible(false) + + appgc.start() + } + catch (ex: SlickException) { + Logger.getLogger(Terrarum::class.java.name).log(Level.SEVERE, null, ex) + } + + } + + private fun getDefaultDirectory() { + OSName = System.getProperty("os.name") + OSVersion = System.getProperty("os.version") + + val OS = System.getProperty("os.name").toUpperCase() + if (OS.contains("WIN")) { + OperationSystem = "WINDOWS" + defaultDir = System.getenv("APPDATA") + "/Terrarum" + } + else if (OS.contains("OS X")) { + OperationSystem = "OSX" + defaultDir = System.getProperty("user.home") + "/Library/Application Support/Terrarum" + } + else if (OS.contains("NUX") || OS.contains("NIX")) { + OperationSystem = "LINUX" + defaultDir = System.getProperty("user.home") + "/.terrarum" + } + else if (OS.contains("SUNOS")) { + OperationSystem = "SOLARIS" + defaultDir = System.getProperty("user.home") + "/.terrarum" + } + else { + OperationSystem = "UNKNOWN" + defaultDir = System.getProperty("user.home") + "/.terrarum" + } + + defaultSaveDir = defaultDir + "/Saves" + configDir = defaultDir + "/config.json" + } + + private fun createDirs() { + val dirs = arrayOf(File(defaultSaveDir)) + + for (d in dirs) { + if (!d.exists()) { + d.mkdirs() + } + } + } + + @Throws(IOException::class) + private fun createConfigJson() { + val configFile = File(configDir) + + if (!configFile.exists() || configFile.length() == 0L) { + JsonWriter.writeToFile(DefaultConfig.fetch(), configDir) + } + } + + private fun readConfigJson(): Boolean { + try { + // read from disk and build config from it + val jsonObject = JsonFetcher.readJson(configDir) + + // make config + jsonObject.entrySet().forEach { entry -> gameConfig[entry.key] = entry.value } + + return true + } + catch (e: IOException) { + // write default config to game dir. Call this method again to read config from it. + try { + createConfigJson() + } + catch (e1: IOException) { + e.printStackTrace() + } + + return false + } + + } + + // exception handling + val sysLang: String + get() { + val lan = System.getProperty("user.language") + var country = System.getProperty("user.country") + if (lan == "en") + country = "US" + else if (lan == "fr") + country = "FR" + else if (lan == "de") + country = "DE" + else if (lan == "ko") country = "KR" + + return lan + country + } + + + /** + * Return config from config set. If the config does not exist, default value will be returned. + * @param key + * * + * @return Config from config set or default config if it does not exist. + * * + * @throws NullPointerException if the specified config simply does not exist. + */ + fun getConfigInt(key: String): Int { + var cfg: Int = 0 + try { + cfg = gameConfig.getAsInt(key)!! + } + catch (e: NullPointerException) { + // if the config set does not have the key, try for the default config + try { + cfg = DefaultConfig.fetch().get(key).asInt + } + catch (e1: NullPointerException) { + e.printStackTrace() + } + } + catch (e: TypeCastException) { + // if the config set does not have the key, try for the default config + try { + cfg = DefaultConfig.fetch().get(key).asInt + } + catch (e1: kotlin.TypeCastException) { + e.printStackTrace() + } + } + + return cfg + } + + /** + * Return config from config set. If the config does not exist, default value will be returned. + * @param key + * * + * @return Config from config set or default config if it does not exist. + * * + * @throws NullPointerException if the specified config simply does not exist. + */ + fun getConfigFloat(key: String): Float { + var cfg = 0f + try { + cfg = gameConfig.getAsFloat(key)!! + } + catch (e: NullPointerException) { + try { + cfg = DefaultConfig.fetch().get(key).asFloat + } + catch (e1: NullPointerException) { + e.printStackTrace() + } + + } + + return cfg + } + + /** + * Return config from config set. If the config does not exist, default value will be returned. + * @param key + * * + * @return Config from config set or default config if it does not exist. + * * + * @throws NullPointerException if the specified config simply does not exist. + */ + fun getConfigString(key: String): String { + var cfg = "" + try { + cfg = gameConfig.getAsString(key)!! + } + catch (e: NullPointerException) { + try { + cfg = DefaultConfig.fetch().get(key).asString + } + catch (e1: NullPointerException) { + e.printStackTrace() + } + + } + + return cfg + } + + /** + * Return config from config set. If the config does not exist, default value will be returned. + * @param key + * * + * @return Config from config set or default config if it does not exist. + * * + * @throws NullPointerException if the specified config simply does not exist. + */ + fun getConfigBoolean(key: String): Boolean { + var cfg = false + try { + cfg = gameConfig.getAsBoolean(key)!! + } + catch (e: NullPointerException) { + try { + cfg = DefaultConfig.fetch().get(key).asBoolean + } + catch (e1: NullPointerException) { + e.printStackTrace() + } + + } + + return cfg + } + } +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/TileProperties/TileNameCode.java b/src/com/Torvald/Terrarum/TileProperties/TileNameCode.java deleted file mode 100644 index 93c0a4fe4..000000000 --- a/src/com/Torvald/Terrarum/TileProperties/TileNameCode.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.Torvald.Terrarum.TileProperties; - -import com.Torvald.Terrarum.Terrarum; - -/** - * Created by minjaesong on 16-02-21. - */ -public class TileNameCode { - - public static final int AIR = 0; - - public static final int STONE = TilePropCodex.indexDamageToArrayAddr(1, 0); - public static final int STONE_QUARRIED = TilePropCodex.indexDamageToArrayAddr(1, 1); - - public static final int DIRT = TilePropCodex.indexDamageToArrayAddr(2, 0); - public static final int GRASS = TilePropCodex.indexDamageToArrayAddr(2, 1); - - public static final int PLANK_NORMAL = TilePropCodex.indexDamageToArrayAddr(3, 0); - public static final int PLANK_EBONY = TilePropCodex.indexDamageToArrayAddr(3, 1); - public static final int PLANK_BIRCH = TilePropCodex.indexDamageToArrayAddr(3, 2); - public static final int PLANK_BLOODROSE = TilePropCodex.indexDamageToArrayAddr(3, 3); - - public static final int TRUNK_NORMAL = TilePropCodex.indexDamageToArrayAddr(4, 0); - public static final int TRUNK_EBONY = TilePropCodex.indexDamageToArrayAddr(4, 1); - public static final int TRUNK_BIRCH = TilePropCodex.indexDamageToArrayAddr(4, 2); - public static final int TRUNK_BLOODROSE = TilePropCodex.indexDamageToArrayAddr(4, 3); - - public static final int SAND = TilePropCodex.indexDamageToArrayAddr(5, 0); - public static final int SAND_BEACH = TilePropCodex.indexDamageToArrayAddr(5, 1); - public static final int SAND_RED = TilePropCodex.indexDamageToArrayAddr(5, 2); - public static final int SAND_DESERT = TilePropCodex.indexDamageToArrayAddr(5, 3); - public static final int SAND_BLACK = TilePropCodex.indexDamageToArrayAddr(5, 4); - public static final int SAND_GREEN = TilePropCodex.indexDamageToArrayAddr(5, 5); - - public static final int GRAVEL = TilePropCodex.indexDamageToArrayAddr(6, 0); - public static final int GRAVEL_GREY = TilePropCodex.indexDamageToArrayAddr(6, 1); - - public static final int ORE_COPPER = TilePropCodex.indexDamageToArrayAddr(7, 0); - public static final int ORE_IRON = TilePropCodex.indexDamageToArrayAddr(7, 1); - public static final int ORE_GOLD = TilePropCodex.indexDamageToArrayAddr(7, 2); - public static final int ORE_SILVER = TilePropCodex.indexDamageToArrayAddr(7, 3); - public static final int ORE_ILMENITE = TilePropCodex.indexDamageToArrayAddr(7, 4); - public static final int ORE_AURICHALCUM = TilePropCodex.indexDamageToArrayAddr(7, 5); - - public static final int RAW_RUBY = TilePropCodex.indexDamageToArrayAddr(8, 0); - public static final int RAW_EMERALD = TilePropCodex.indexDamageToArrayAddr(8, 1); - public static final int RAW_SAPPHIRE = TilePropCodex.indexDamageToArrayAddr(8, 2); - public static final int RAW_TOPAZ = TilePropCodex.indexDamageToArrayAddr(8, 3); - public static final int RAW_DIAMOND = TilePropCodex.indexDamageToArrayAddr(8, 4); - public static final int RAW_AMETHYST = TilePropCodex.indexDamageToArrayAddr(8, 5); - - public static final int SNOW = TilePropCodex.indexDamageToArrayAddr(9, 0); - public static final int ICE_FRAGILE = TilePropCodex.indexDamageToArrayAddr(9, 1); - public static final int ICE_NATURAL = TilePropCodex.indexDamageToArrayAddr(9, 2); - public static final int ICE_MAGICAL = TilePropCodex.indexDamageToArrayAddr(9, 3); - - public static final int PLATFORM_STONE = TilePropCodex.indexDamageToArrayAddr(10, 0); - public static final int PLATFORM_WOODEN = TilePropCodex.indexDamageToArrayAddr(10, 1); - public static final int PLATFORM_EBONY = TilePropCodex.indexDamageToArrayAddr(10, 2); - public static final int PLATFORM_BIRCH = TilePropCodex.indexDamageToArrayAddr(10, 3); - public static final int PLATFORM_BLOODROSE = TilePropCodex.indexDamageToArrayAddr(10, 4); - - public static final int TORCH = TilePropCodex.indexDamageToArrayAddr(11, 0); - public static final int TORCH_FROST = TilePropCodex.indexDamageToArrayAddr(11, 1); - - public static final int TORCH_OFF = TilePropCodex.indexDamageToArrayAddr(12, 0); - public static final int TORCH_FROST_OFF = TilePropCodex.indexDamageToArrayAddr(12, 1); - - public static final int ILLUMINATOR_WHITE = TilePropCodex.indexDamageToArrayAddr(13, 0); - public static final int ILLUMINATOR_YELLOW = TilePropCodex.indexDamageToArrayAddr(13, 1); - public static final int ILLUMINATOR_ORANGE = TilePropCodex.indexDamageToArrayAddr(13, 2); - public static final int ILLUMINATOR_RED = TilePropCodex.indexDamageToArrayAddr(13, 3); - public static final int ILLUMINATOR_FUCHSIA = TilePropCodex.indexDamageToArrayAddr(13, 4); - public static final int ILLUMINATOR_PURPLE = TilePropCodex.indexDamageToArrayAddr(13, 5); - public static final int ILLUMINATOR_BLUE = TilePropCodex.indexDamageToArrayAddr(13, 6); - public static final int ILLUMINATOR_CYAN = TilePropCodex.indexDamageToArrayAddr(13, 7); - public static final int ILLUMINATOR_GREEN = TilePropCodex.indexDamageToArrayAddr(13, 8); - public static final int ILLUMINATOR_GREEN_DARK = TilePropCodex.indexDamageToArrayAddr(13, 9); - public static final int ILLUMINATOR_BROWN = TilePropCodex.indexDamageToArrayAddr(13, 10); - public static final int ILLUMINATOR_TAN = TilePropCodex.indexDamageToArrayAddr(13, 11); - public static final int ILLUMINATOR_GREY_LIGHT = TilePropCodex.indexDamageToArrayAddr(13, 12); - public static final int ILLUMINATOR_GREY_MED = TilePropCodex.indexDamageToArrayAddr(13, 13); - public static final int ILLUMINATOR_GREY_DARK = TilePropCodex.indexDamageToArrayAddr(13, 14); - public static final int ILLUMINATOR_BLACK = TilePropCodex.indexDamageToArrayAddr(13, 15); - - public static final int ILLUMINATOR_WHITE_OFF = TilePropCodex.indexDamageToArrayAddr(14, 0); - public static final int ILLUMINATOR_YELLOW_OFF = TilePropCodex.indexDamageToArrayAddr(14, 1); - public static final int ILLUMINATOR_ORANGE_OFF = TilePropCodex.indexDamageToArrayAddr(14, 2); - public static final int ILLUMINATOR_RED_OFF = TilePropCodex.indexDamageToArrayAddr(14, 3); - public static final int ILLUMINATOR_FUCHSIA_OFF = TilePropCodex.indexDamageToArrayAddr(14, 4); - public static final int ILLUMINATOR_PURPLE_OFF = TilePropCodex.indexDamageToArrayAddr(14, 5); - public static final int ILLUMINATOR_BLUE_OFF = TilePropCodex.indexDamageToArrayAddr(14, 6); - public static final int ILLUMINATOR_CYAN_OFF = TilePropCodex.indexDamageToArrayAddr(14, 7); - public static final int ILLUMINATOR_GREEN_OFF = TilePropCodex.indexDamageToArrayAddr(14, 8); - public static final int ILLUMINATOR_GREEN_DARK_OFF = TilePropCodex.indexDamageToArrayAddr(14, 9); - public static final int ILLUMINATOR_BROWN_OFF = TilePropCodex.indexDamageToArrayAddr(14, 10); - public static final int ILLUMINATOR_TAN_OFF = TilePropCodex.indexDamageToArrayAddr(14, 11); - public static final int ILLUMINATOR_GREY_LIGHT_OFF = TilePropCodex.indexDamageToArrayAddr(14, 12); - public static final int ILLUMINATOR_GREY_MED_OFF = TilePropCodex.indexDamageToArrayAddr(14, 13); - public static final int ILLUMINATOR_GREY_DARK_OFF = TilePropCodex.indexDamageToArrayAddr(14, 14); - public static final int ILLUMINATOR_BLACK_OFF = TilePropCodex.indexDamageToArrayAddr(14, 15); - - public static final int SANDSTONE = TilePropCodex.indexDamageToArrayAddr(15, 0); - public static final int SANDSTONE_WHITE = TilePropCodex.indexDamageToArrayAddr(15, 1); - public static final int SANDSTONE_RED = TilePropCodex.indexDamageToArrayAddr(15, 2); - public static final int SANDSTONE_DESERT = TilePropCodex.indexDamageToArrayAddr(15, 3); - public static final int SANDSTONE_BLACK = TilePropCodex.indexDamageToArrayAddr(15, 4); - public static final int SANDSTONE_GREEN = TilePropCodex.indexDamageToArrayAddr(15, 5); - - public static final int WATER_1 = TilePropCodex.indexDamageToArrayAddr(254, 0); - public static final int WATER_2 = TilePropCodex.indexDamageToArrayAddr(254, 1); - public static final int WATER_3 = TilePropCodex.indexDamageToArrayAddr(254, 2); - public static final int WATER_4 = TilePropCodex.indexDamageToArrayAddr(254, 3); - public static final int WATER_5 = TilePropCodex.indexDamageToArrayAddr(254, 4); - public static final int WATER_6 = TilePropCodex.indexDamageToArrayAddr(254, 5); - public static final int WATER_7 = TilePropCodex.indexDamageToArrayAddr(254, 6); - public static final int WATER_8 = TilePropCodex.indexDamageToArrayAddr(254, 7); - public static final int WATER_9 = TilePropCodex.indexDamageToArrayAddr(254, 8); - public static final int WATER_10 = TilePropCodex.indexDamageToArrayAddr(254, 9); - public static final int WATER_11 = TilePropCodex.indexDamageToArrayAddr(254, 10); - public static final int WATER_12 = TilePropCodex.indexDamageToArrayAddr(254, 11); - public static final int WATER_13 = TilePropCodex.indexDamageToArrayAddr(254, 12); - public static final int WATER_14 = TilePropCodex.indexDamageToArrayAddr(254, 13); - public static final int WATER_15 = TilePropCodex.indexDamageToArrayAddr(254, 14); - public static final int WATER = TilePropCodex.indexDamageToArrayAddr(254, 15); - - public static final int LAVA_1 = TilePropCodex.indexDamageToArrayAddr(255, 0); - public static final int LAVA_2 = TilePropCodex.indexDamageToArrayAddr(255, 1); - public static final int LAVA_3 = TilePropCodex.indexDamageToArrayAddr(255, 2); - public static final int LAVA_4 = TilePropCodex.indexDamageToArrayAddr(255, 3); - public static final int LAVA_5 = TilePropCodex.indexDamageToArrayAddr(255, 4); - public static final int LAVA_6 = TilePropCodex.indexDamageToArrayAddr(255, 5); - public static final int LAVA_7 = TilePropCodex.indexDamageToArrayAddr(255, 6); - public static final int LAVA_8 = TilePropCodex.indexDamageToArrayAddr(255, 7); - public static final int LAVA_9 = TilePropCodex.indexDamageToArrayAddr(255, 8); - public static final int LAVA_10 = TilePropCodex.indexDamageToArrayAddr(255, 9); - public static final int LAVA_11 = TilePropCodex.indexDamageToArrayAddr(255, 10); - public static final int LAVA_12 = TilePropCodex.indexDamageToArrayAddr(255, 11); - public static final int LAVA_13 = TilePropCodex.indexDamageToArrayAddr(255, 12); - public static final int LAVA_14 = TilePropCodex.indexDamageToArrayAddr(255, 13); - public static final int LAVA_15 = TilePropCodex.indexDamageToArrayAddr(255, 14); - public static final int LAVA = TilePropCodex.indexDamageToArrayAddr(255, 15); - -} diff --git a/src/com/Torvald/Terrarum/TileProperties/TileNameCode.kt b/src/com/Torvald/Terrarum/TileProperties/TileNameCode.kt new file mode 100644 index 000000000..f1e744f57 --- /dev/null +++ b/src/com/Torvald/Terrarum/TileProperties/TileNameCode.kt @@ -0,0 +1,144 @@ +package com.Torvald.Terrarum.TileProperties + +import com.Torvald.Terrarum.Terrarum + +/** + * Created by minjaesong on 16-02-21. + */ +object TileNameCode { + + val AIR = 0 + + val STONE = TilePropCodex.indexDamageToArrayAddr(1, 0) + val STONE_QUARRIED = TilePropCodex.indexDamageToArrayAddr(1, 1) + + val DIRT = TilePropCodex.indexDamageToArrayAddr(2, 0) + val GRASS = TilePropCodex.indexDamageToArrayAddr(2, 1) + + val PLANK_NORMAL = TilePropCodex.indexDamageToArrayAddr(3, 0) + val PLANK_EBONY = TilePropCodex.indexDamageToArrayAddr(3, 1) + val PLANK_BIRCH = TilePropCodex.indexDamageToArrayAddr(3, 2) + val PLANK_BLOODROSE = TilePropCodex.indexDamageToArrayAddr(3, 3) + + val TRUNK_NORMAL = TilePropCodex.indexDamageToArrayAddr(4, 0) + val TRUNK_EBONY = TilePropCodex.indexDamageToArrayAddr(4, 1) + val TRUNK_BIRCH = TilePropCodex.indexDamageToArrayAddr(4, 2) + val TRUNK_BLOODROSE = TilePropCodex.indexDamageToArrayAddr(4, 3) + + val SAND = TilePropCodex.indexDamageToArrayAddr(5, 0) + val SAND_BEACH = TilePropCodex.indexDamageToArrayAddr(5, 1) + val SAND_RED = TilePropCodex.indexDamageToArrayAddr(5, 2) + val SAND_DESERT = TilePropCodex.indexDamageToArrayAddr(5, 3) + val SAND_BLACK = TilePropCodex.indexDamageToArrayAddr(5, 4) + val SAND_GREEN = TilePropCodex.indexDamageToArrayAddr(5, 5) + + val GRAVEL = TilePropCodex.indexDamageToArrayAddr(6, 0) + val GRAVEL_GREY = TilePropCodex.indexDamageToArrayAddr(6, 1) + + val ORE_COPPER = TilePropCodex.indexDamageToArrayAddr(7, 0) + val ORE_IRON = TilePropCodex.indexDamageToArrayAddr(7, 1) + val ORE_GOLD = TilePropCodex.indexDamageToArrayAddr(7, 2) + val ORE_SILVER = TilePropCodex.indexDamageToArrayAddr(7, 3) + val ORE_ILMENITE = TilePropCodex.indexDamageToArrayAddr(7, 4) + val ORE_AURICHALCUM = TilePropCodex.indexDamageToArrayAddr(7, 5) + + val RAW_RUBY = TilePropCodex.indexDamageToArrayAddr(8, 0) + val RAW_EMERALD = TilePropCodex.indexDamageToArrayAddr(8, 1) + val RAW_SAPPHIRE = TilePropCodex.indexDamageToArrayAddr(8, 2) + val RAW_TOPAZ = TilePropCodex.indexDamageToArrayAddr(8, 3) + val RAW_DIAMOND = TilePropCodex.indexDamageToArrayAddr(8, 4) + val RAW_AMETHYST = TilePropCodex.indexDamageToArrayAddr(8, 5) + + val SNOW = TilePropCodex.indexDamageToArrayAddr(9, 0) + val ICE_FRAGILE = TilePropCodex.indexDamageToArrayAddr(9, 1) + val ICE_NATURAL = TilePropCodex.indexDamageToArrayAddr(9, 2) + val ICE_MAGICAL = TilePropCodex.indexDamageToArrayAddr(9, 3) + + val PLATFORM_STONE = TilePropCodex.indexDamageToArrayAddr(10, 0) + val PLATFORM_WOODEN = TilePropCodex.indexDamageToArrayAddr(10, 1) + val PLATFORM_EBONY = TilePropCodex.indexDamageToArrayAddr(10, 2) + val PLATFORM_BIRCH = TilePropCodex.indexDamageToArrayAddr(10, 3) + val PLATFORM_BLOODROSE = TilePropCodex.indexDamageToArrayAddr(10, 4) + + val TORCH = TilePropCodex.indexDamageToArrayAddr(11, 0) + val TORCH_FROST = TilePropCodex.indexDamageToArrayAddr(11, 1) + + val TORCH_OFF = TilePropCodex.indexDamageToArrayAddr(12, 0) + val TORCH_FROST_OFF = TilePropCodex.indexDamageToArrayAddr(12, 1) + + val ILLUMINATOR_WHITE = TilePropCodex.indexDamageToArrayAddr(13, 0) + val ILLUMINATOR_YELLOW = TilePropCodex.indexDamageToArrayAddr(13, 1) + val ILLUMINATOR_ORANGE = TilePropCodex.indexDamageToArrayAddr(13, 2) + val ILLUMINATOR_RED = TilePropCodex.indexDamageToArrayAddr(13, 3) + val ILLUMINATOR_FUCHSIA = TilePropCodex.indexDamageToArrayAddr(13, 4) + val ILLUMINATOR_PURPLE = TilePropCodex.indexDamageToArrayAddr(13, 5) + val ILLUMINATOR_BLUE = TilePropCodex.indexDamageToArrayAddr(13, 6) + val ILLUMINATOR_CYAN = TilePropCodex.indexDamageToArrayAddr(13, 7) + val ILLUMINATOR_GREEN = TilePropCodex.indexDamageToArrayAddr(13, 8) + val ILLUMINATOR_GREEN_DARK = TilePropCodex.indexDamageToArrayAddr(13, 9) + val ILLUMINATOR_BROWN = TilePropCodex.indexDamageToArrayAddr(13, 10) + val ILLUMINATOR_TAN = TilePropCodex.indexDamageToArrayAddr(13, 11) + val ILLUMINATOR_GREY_LIGHT = TilePropCodex.indexDamageToArrayAddr(13, 12) + val ILLUMINATOR_GREY_MED = TilePropCodex.indexDamageToArrayAddr(13, 13) + val ILLUMINATOR_GREY_DARK = TilePropCodex.indexDamageToArrayAddr(13, 14) + val ILLUMINATOR_BLACK = TilePropCodex.indexDamageToArrayAddr(13, 15) + + val ILLUMINATOR_WHITE_OFF = TilePropCodex.indexDamageToArrayAddr(14, 0) + val ILLUMINATOR_YELLOW_OFF = TilePropCodex.indexDamageToArrayAddr(14, 1) + val ILLUMINATOR_ORANGE_OFF = TilePropCodex.indexDamageToArrayAddr(14, 2) + val ILLUMINATOR_RED_OFF = TilePropCodex.indexDamageToArrayAddr(14, 3) + val ILLUMINATOR_FUCHSIA_OFF = TilePropCodex.indexDamageToArrayAddr(14, 4) + val ILLUMINATOR_PURPLE_OFF = TilePropCodex.indexDamageToArrayAddr(14, 5) + val ILLUMINATOR_BLUE_OFF = TilePropCodex.indexDamageToArrayAddr(14, 6) + val ILLUMINATOR_CYAN_OFF = TilePropCodex.indexDamageToArrayAddr(14, 7) + val ILLUMINATOR_GREEN_OFF = TilePropCodex.indexDamageToArrayAddr(14, 8) + val ILLUMINATOR_GREEN_DARK_OFF = TilePropCodex.indexDamageToArrayAddr(14, 9) + val ILLUMINATOR_BROWN_OFF = TilePropCodex.indexDamageToArrayAddr(14, 10) + val ILLUMINATOR_TAN_OFF = TilePropCodex.indexDamageToArrayAddr(14, 11) + val ILLUMINATOR_GREY_LIGHT_OFF = TilePropCodex.indexDamageToArrayAddr(14, 12) + val ILLUMINATOR_GREY_MED_OFF = TilePropCodex.indexDamageToArrayAddr(14, 13) + val ILLUMINATOR_GREY_DARK_OFF = TilePropCodex.indexDamageToArrayAddr(14, 14) + val ILLUMINATOR_BLACK_OFF = TilePropCodex.indexDamageToArrayAddr(14, 15) + + val SANDSTONE = TilePropCodex.indexDamageToArrayAddr(15, 0) + val SANDSTONE_WHITE = TilePropCodex.indexDamageToArrayAddr(15, 1) + val SANDSTONE_RED = TilePropCodex.indexDamageToArrayAddr(15, 2) + val SANDSTONE_DESERT = TilePropCodex.indexDamageToArrayAddr(15, 3) + val SANDSTONE_BLACK = TilePropCodex.indexDamageToArrayAddr(15, 4) + val SANDSTONE_GREEN = TilePropCodex.indexDamageToArrayAddr(15, 5) + + val WATER_1 = TilePropCodex.indexDamageToArrayAddr(254, 0) + val WATER_2 = TilePropCodex.indexDamageToArrayAddr(254, 1) + val WATER_3 = TilePropCodex.indexDamageToArrayAddr(254, 2) + val WATER_4 = TilePropCodex.indexDamageToArrayAddr(254, 3) + val WATER_5 = TilePropCodex.indexDamageToArrayAddr(254, 4) + val WATER_6 = TilePropCodex.indexDamageToArrayAddr(254, 5) + val WATER_7 = TilePropCodex.indexDamageToArrayAddr(254, 6) + val WATER_8 = TilePropCodex.indexDamageToArrayAddr(254, 7) + val WATER_9 = TilePropCodex.indexDamageToArrayAddr(254, 8) + val WATER_10 = TilePropCodex.indexDamageToArrayAddr(254, 9) + val WATER_11 = TilePropCodex.indexDamageToArrayAddr(254, 10) + val WATER_12 = TilePropCodex.indexDamageToArrayAddr(254, 11) + val WATER_13 = TilePropCodex.indexDamageToArrayAddr(254, 12) + val WATER_14 = TilePropCodex.indexDamageToArrayAddr(254, 13) + val WATER_15 = TilePropCodex.indexDamageToArrayAddr(254, 14) + val WATER = TilePropCodex.indexDamageToArrayAddr(254, 15) + + val LAVA_1 = TilePropCodex.indexDamageToArrayAddr(255, 0) + val LAVA_2 = TilePropCodex.indexDamageToArrayAddr(255, 1) + val LAVA_3 = TilePropCodex.indexDamageToArrayAddr(255, 2) + val LAVA_4 = TilePropCodex.indexDamageToArrayAddr(255, 3) + val LAVA_5 = TilePropCodex.indexDamageToArrayAddr(255, 4) + val LAVA_6 = TilePropCodex.indexDamageToArrayAddr(255, 5) + val LAVA_7 = TilePropCodex.indexDamageToArrayAddr(255, 6) + val LAVA_8 = TilePropCodex.indexDamageToArrayAddr(255, 7) + val LAVA_9 = TilePropCodex.indexDamageToArrayAddr(255, 8) + val LAVA_10 = TilePropCodex.indexDamageToArrayAddr(255, 9) + val LAVA_11 = TilePropCodex.indexDamageToArrayAddr(255, 10) + val LAVA_12 = TilePropCodex.indexDamageToArrayAddr(255, 11) + val LAVA_13 = TilePropCodex.indexDamageToArrayAddr(255, 12) + val LAVA_14 = TilePropCodex.indexDamageToArrayAddr(255, 13) + val LAVA_15 = TilePropCodex.indexDamageToArrayAddr(255, 14) + val LAVA = TilePropCodex.indexDamageToArrayAddr(255, 15) + +} diff --git a/src/com/Torvald/Terrarum/TileProperties/TileProp.java b/src/com/Torvald/Terrarum/TileProperties/TileProp.java deleted file mode 100644 index 2b169dd92..000000000 --- a/src/com/Torvald/Terrarum/TileProperties/TileProp.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.Torvald.Terrarum.TileProperties; - -/** - * Created by minjaesong on 16-02-16. - */ -public class TileProp { - - private int id; - private int damage; - private String name; - - private char opacity; // colour attenuation - - private int strength; - - private int density; - - private boolean fluid; - private int movementResistance; - - private boolean solid; // transparent or not - - private boolean wallable; - - private char luminosity; - - private int drop; - private int dropDamage; - - private boolean fallable; - - private int friction; - - public int getId() { - return id; - } - - void setId(int id) { - this.id = id; - } - - public int getDamage() { - return damage; - } - - public void setDamage(int damage) { - this.damage = damage; - } - - public String getName() { - return name; - } - - void setName(String name) { - this.name = name; - } - - public char getOpacity() { - return opacity; - } - - void setOpacity(char opacity) { - this.opacity = opacity; - } - - public int getStrength() { - return strength; - } - - void setStrength(int strength) { - this.strength = strength; - } - - public boolean isFluid() { - return fluid; - } - - void setFluid(boolean fluid) { - this.fluid = fluid; - } - - public int getMovementResistance() { - return movementResistance; - } - - void setMovementResistance(int movementResistance) { - this.movementResistance = movementResistance; - } - - public boolean isSolid() { - return solid; - } - - void setSolid(boolean solid) { - this.solid = solid; - } - - public boolean isWallable() { - return wallable; - } - - void setWallable(boolean wallable) { - this.wallable = wallable; - } - - /** - * Raw RGB value, without alpha - * @return - */ - public char getLuminosity() { - return luminosity; - } - - /** - * - * @param luminosity Raw RGB value, without alpha - */ - void setLuminosity(char luminosity) { - this.luminosity = luminosity; - } - - public int getDrop() { - return drop; - } - - void setDrop(int drop) { - this.drop = drop; - } - - public int getDropDamage() { - return dropDamage; - } - - public void setDropDamage(int dropDamage) { - this.dropDamage = dropDamage; - } - - public boolean isFallable() { - return fallable; - } - - void setFallable(boolean fallable) { - this.fallable = fallable; - } - - public int getFriction() { - return friction; - } - - void setFriction(int friction) { - this.friction = friction; - } - - public int getDensity() { - return density; - } - - public void setDensity(int density) { - this.density = density; - } -} diff --git a/src/com/Torvald/Terrarum/TileProperties/TileProp.kt b/src/com/Torvald/Terrarum/TileProperties/TileProp.kt new file mode 100644 index 000000000..43381ff73 --- /dev/null +++ b/src/com/Torvald/Terrarum/TileProperties/TileProp.kt @@ -0,0 +1,41 @@ +package com.Torvald.Terrarum.TileProperties + +/** + * Created by minjaesong on 16-02-16. + */ +class TileProp { + + var id: Int = 0 + + var damage: Int = 0 + var name: String = "" + + /** + * @param opacity Raw RGB value, without alpha + */ + var opacity: Char = ' ' // colour attenuation + + var strength: Int = 0 + + + var density: Int = 0 + + var isFluid: Boolean = false + var movementResistance: Int = 0 + + var isSolid: Boolean = false + + var isWallable: Boolean = false + + /** + * @param luminosity Raw RGB value, without alpha + */ + var luminosity: Char = ' ' + + var drop: Int = 0 + var dropDamage: Int = 0 + + var isFallable: Boolean = false + + var friction: Int = 0 +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/TileProperties/TilePropCodex.java b/src/com/Torvald/Terrarum/TileProperties/TilePropCodex.java deleted file mode 100644 index 86647c591..000000000 --- a/src/com/Torvald/Terrarum/TileProperties/TilePropCodex.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.Torvald.Terrarum.TileProperties; - -import com.Torvald.CSVFetcher; -import com.Torvald.Terrarum.GameMap.MapLayer; -import com.Torvald.Terrarum.GameMap.PairedMapLayer; -import org.apache.commons.csv.CSVRecord; - -import java.io.IOException; -import java.util.List; - -/** - * Created by minjaesong on 16-02-16. - */ -public class TilePropCodex { - - private static TileProp[] tileProps; - - public static final String CSV_PATH = "./src/com/Torvald/Terrarum/TileProperties/tileprop.csv"; - - public TilePropCodex() { - tileProps = new TileProp[MapLayer.RANGE * (PairedMapLayer.RANGE)]; - - for (int i = 0; i < tileProps.length; i++) { - tileProps[i] = new TileProp(); - } - - try { - // todo verify CSV using pre-calculated SHA256 hash - List records = CSVFetcher.readCSV(CSV_PATH); - - System.out.println("[TilePropCodex] Building tile properties table"); - - records.forEach(record -> - setProp(tileProps[indexDamageToArrayAddr - (intVal(record, "id") - , intVal(record, "dmg")) - ], record - )); - } - catch (IOException e) { - e.printStackTrace(); - } - } - - public static TileProp getProp(int index, int damage) { - try { - tileProps[indexDamageToArrayAddr(index, damage)].getId(); - } - catch (NullPointerException e) { - throw new NullPointerException("Tile prop with id " + index - + " and damage " + damage - + " does not exist."); - } - - return tileProps[indexDamageToArrayAddr(index, damage)]; - } - - public static TileProp getProp(int rawIndex) { - try { - tileProps[rawIndex].getId(); - } - catch (NullPointerException e) { - throw new NullPointerException("Tile prop with raw id " + rawIndex - + " does not exist."); - } - - return tileProps[rawIndex]; - } - - private static void setProp(TileProp prop, CSVRecord record) { - prop.setName(record.get("name")); - - prop.setId(intVal(record, "id")); - prop.setDamage(intVal(record, "dmg")); - - prop.setOpacity((char) intVal(record, "opacity")); - prop.setStrength(intVal(record, "strength")); - prop.setDensity(intVal(record, "dsty")); - prop.setLuminosity((char) intVal(record, "lumcolor")); - prop.setDrop(intVal(record, "drop")); - prop.setDropDamage(intVal(record, "ddmg")); - prop.setFriction(intVal(record, "friction")); - - prop.setFluid(boolVal(record, "fluid")); - prop.setSolid(boolVal(record, "solid")); - prop.setWallable(boolVal(record, "wall")); - prop.setFallable(boolVal(record, "fall")); - - if (prop.isFluid()) prop.setMovementResistance(intVal(record, "movr")); - - System.out.print(formatNum3(prop.getId()) + ":" + formatNum2(prop.getDamage())); - System.out.println("\t" + prop.getName()); - } - - private static int intVal(CSVRecord rec, String s) { - int ret = -1; - try { ret = Integer.decode(rec.get(s)); } - catch (NullPointerException e) {} - return ret; - } - - private static boolean boolVal(CSVRecord rec, String s) { - return !(intVal(rec, s) == 0); - } - - public static int indexDamageToArrayAddr(int index, int damage) { - return (index * (PairedMapLayer.RANGE) + damage); - } - - private static String formatNum3(int i) { - if (i < 10) return "00" + i; - else if (i < 100) return "0" + i; - else return String.valueOf(i); - } - - private static String formatNum2(int i) { - if (i < 10) return "0" + i; - else return String.valueOf(i); - } -} diff --git a/src/com/Torvald/Terrarum/TileProperties/TilePropCodex.kt b/src/com/Torvald/Terrarum/TileProperties/TilePropCodex.kt new file mode 100644 index 000000000..9ac51c38a --- /dev/null +++ b/src/com/Torvald/Terrarum/TileProperties/TilePropCodex.kt @@ -0,0 +1,129 @@ +package com.Torvald.Terrarum.TileProperties + +import com.Torvald.CSVFetcher +import com.Torvald.Terrarum.GameMap.MapLayer +import com.Torvald.Terrarum.GameMap.PairedMapLayer +import org.apache.commons.csv.CSVRecord + +import java.io.IOException + +/** + * Created by minjaesong on 16-02-16. + */ +class TilePropCodex { + + init { + tileProps = Array(MapLayer.RANGE * PairedMapLayer.RANGE, + {i -> TileProp() } + ) + + for (i in tileProps.indices) { + tileProps[i] = TileProp() + } + + try { + // todo verify CSV using pre-calculated SHA256 hash + val records = CSVFetcher.readCSV(CSV_PATH) + + println("[TilePropCodex] Building tile properties table") + + records.forEach { record -> setProp( + tileProps[indexDamageToArrayAddr(intVal(record, "id"), intVal(record, "dmg"))] + , record) + } + } + catch (e: IOException) { + e.printStackTrace() + } + + } + + companion object { + + private lateinit var tileProps: Array + + val CSV_PATH = "./src/com/Torvald/Terrarum/TileProperties/tileprop.csv" + + fun getProp(index: Int, damage: Int): TileProp { + try { + tileProps[indexDamageToArrayAddr(index, damage)].id + } + catch (e: NullPointerException) { + throw NullPointerException("Tile prop with id $index and damage $damage does not exist.") + } + + return tileProps[indexDamageToArrayAddr(index, damage)] + } + + fun getProp(rawIndex: Int): TileProp { + try { + tileProps[rawIndex].id + } + catch (e: NullPointerException) { + throw NullPointerException("Tile prop with raw id $rawIndex does not exist.") + } + + return tileProps[rawIndex] + } + + private fun setProp(prop: TileProp, record: CSVRecord) { + prop.name = record.get("name") + + prop.id = intVal(record, "id") + prop.damage = intVal(record, "dmg") + + prop.opacity = intVal(record, "opacity").toChar() + prop.strength = intVal(record, "strength") + prop.density = intVal(record, "dsty") + prop.luminosity = intVal(record, "lumcolor").toChar() + prop.drop = intVal(record, "drop") + prop.dropDamage = intVal(record, "ddmg") + prop.friction = intVal(record, "friction") + + prop.isFluid = boolVal(record, "fluid") + prop.isSolid = boolVal(record, "solid") + prop.isWallable = boolVal(record, "wall") + prop.isFallable = boolVal(record, "fall") + + if (prop.isFluid) prop.movementResistance = intVal(record, "movr") + + print(formatNum3(prop.id) + ":" + formatNum2(prop.damage)) + println("\t" + prop.name!!) + } + + private fun intVal(rec: CSVRecord, s: String): Int { + var ret = -1 + try { + ret = Integer.decode(rec.get(s))!! + } + catch (e: NullPointerException) { + } + + return ret + } + + private fun boolVal(rec: CSVRecord, s: String): Boolean { + return intVal(rec, s) != 0 + } + + fun indexDamageToArrayAddr(index: Int, damage: Int): Int { + return index * PairedMapLayer.RANGE + damage + } + + private fun formatNum3(i: Int): String { + if (i < 10) + return "00" + i + else if (i < 100) + return "0" + i + else + return i.toString() + } + + private fun formatNum2(i: Int): String { + if (i < 10) + return "0" + i + else + return i.toString() + } + } +} diff --git a/src/com/Torvald/Terrarum/TileStat/TileStat.java b/src/com/Torvald/Terrarum/TileStat/TileStat.java deleted file mode 100644 index 6383975c1..000000000 --- a/src/com/Torvald/Terrarum/TileStat/TileStat.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.Torvald.Terrarum.TileStat; - -import com.Torvald.Terrarum.Actors.Player; -import com.Torvald.Terrarum.GameMap.GameMap; -import com.Torvald.Terrarum.GameMap.MapLayer; -import com.Torvald.Terrarum.MapDrawer.MapCamera; -import com.Torvald.Terrarum.MapDrawer.MapDrawer; -import com.Torvald.Terrarum.Terrarum; -import com.jme3.math.FastMath; - -import java.util.Arrays; - -/** - * Created by minjaesong on 16-02-01. - */ -public class TileStat { - - private static short[] tilestat = new short[GameMap.TILES_SUPPORTED]; - - private static final int TSIZE = MapDrawer.getTILE_SIZE(); - - /** - * Update tile stats from tiles on screen - */ - public static void update() { - Arrays.fill(tilestat, (short) 0); - - // Get stats on no-zoomed screen area. In other words, will behave as if screen zoom were 1.0 - // no matter how the screen is zoomed. - GameMap map = Terrarum.game.map; - Player player = Terrarum.game.getPlayer(); - - int renderWidth = FastMath.ceil(Terrarum.WIDTH); - int renderHeight = FastMath.ceil(Terrarum.HEIGHT); - - int noZoomCameraX = Math.round(FastMath.clamp( - player.getHitbox().getCenteredX() - (renderWidth / 2) - , TSIZE, map.width * TSIZE - renderWidth - TSIZE - )); - int noZoomCameraY = Math.round(FastMath.clamp( - player.getHitbox().getCenteredY() - (renderHeight / 2) - , TSIZE, map.height * TSIZE - renderHeight - TSIZE - )); - - int for_x_start = MapCamera.div16(noZoomCameraX); - int for_y_start = MapCamera.div16(noZoomCameraY); - int for_y_end = MapCamera.clampHTile(for_y_start + MapCamera.div16(renderHeight) + 2); - int for_x_end = MapCamera.clampWTile(for_x_start + MapCamera.div16(renderWidth) + 2); - - for (int y = for_y_start; y < for_y_end; y++) { - for (int x = for_x_start; x < for_x_end; x++) { - int tileWall = map.getTileFromWall(x, y); - int tileTerrain = map.getTileFromTerrain(x, y); - tilestat[tileWall] += 1; - tilestat[tileTerrain] += 1; - } - } - } - - public static int getCount(byte... tile) { - int sum = 0; - for (int i = 0; i < tile.length; i++) { - int newArgs = Byte.toUnsignedInt(tile[i]); - sum += Short.toUnsignedInt(tilestat[ newArgs ]); - } - - return sum; - } - - public static int getCount(int... tile) { - int sum = 0; - for (int i = 0; i < tile.length; i++) { - sum += Short.toUnsignedInt(tilestat[ tile[i] ]); - } - return sum; - } - - /** - * - * @return copy of the stat data - */ - public static short[] getStatCopy() { - return Arrays.copyOf(tilestat, MapLayer.RANGE); - } - -} diff --git a/src/com/Torvald/Terrarum/TileStat/TileStat.kt b/src/com/Torvald/Terrarum/TileStat/TileStat.kt new file mode 100644 index 000000000..9174492ae --- /dev/null +++ b/src/com/Torvald/Terrarum/TileStat/TileStat.kt @@ -0,0 +1,81 @@ +package com.Torvald.Terrarum.TileStat + +import com.Torvald.Terrarum.Actors.Player +import com.Torvald.Terrarum.GameMap.GameMap +import com.Torvald.Terrarum.GameMap.MapLayer +import com.Torvald.Terrarum.MapDrawer.MapCamera +import com.Torvald.Terrarum.MapDrawer.MapDrawer +import com.Torvald.Terrarum.Terrarum +import com.jme3.math.FastMath + +import java.util.Arrays + +/** + * Created by minjaesong on 16-02-01. + */ +object TileStat { + + private val tilestat = ShortArray(GameMap.TILES_SUPPORTED) + + private val TSIZE = MapDrawer.TILE_SIZE + + /** + * Update tile stats from tiles on screen + */ + fun update() { + Arrays.fill(tilestat, 0.toShort()) + + // Get stats on no-zoomed screen area. In other words, will behave as if screen zoom were 1.0 + // no matter how the screen is zoomed. + val map = Terrarum.game.map + val player = Terrarum.game.player + + val renderWidth = FastMath.ceil(Terrarum.WIDTH.toFloat()) + val renderHeight = FastMath.ceil(Terrarum.HEIGHT.toFloat()) + + val noZoomCameraX = Math.round(FastMath.clamp( + player.hitbox!!.centeredX - renderWidth / 2, TSIZE.toFloat(), map.width * TSIZE - renderWidth - TSIZE.toFloat())) + val noZoomCameraY = Math.round(FastMath.clamp( + player.hitbox!!.centeredY - renderHeight / 2, TSIZE.toFloat(), map.width * TSIZE - renderHeight - TSIZE.toFloat())) + + val for_x_start = MapCamera.div16(noZoomCameraX) + val for_y_start = MapCamera.div16(noZoomCameraY) + val for_y_end = MapCamera.clampHTile(for_y_start + MapCamera.div16(renderHeight) + 2) + val for_x_end = MapCamera.clampWTile(for_x_start + MapCamera.div16(renderWidth) + 2) + + for (y in for_y_start..for_y_end - 1) { + for (x in for_x_start..for_x_end - 1) { + val tileWall = map.getTileFromWall(x, y) + val tileTerrain = map.getTileFromTerrain(x, y) + ++tilestat[tileWall] + ++tilestat[tileTerrain] + } + } + } + + fun getCount(vararg tile: Byte): Int { + var sum = 0 + for (i in tile.indices) { + val newArgs = java.lang.Byte.toUnsignedInt(tile[i]) + sum += java.lang.Short.toUnsignedInt(tilestat[newArgs]) + } + + return sum + } + + fun getCount(vararg tile: Int): Int { + var sum = 0 + for (i in tile.indices) { + sum += java.lang.Short.toUnsignedInt(tilestat[tile[i]]) + } + return sum + } + + /** + + * @return copy of the stat data + */ + val statCopy: ShortArray + get() = Arrays.copyOf(tilestat, MapLayer.RANGE) + +} diff --git a/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow b/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow deleted file mode 100644 index 318abdc41..000000000 --- a/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow +++ /dev/null @@ -1,220 +0,0 @@ -package com.Torvald.Terrarum.UserInterface; - -import com.Torvald.Terrarum.Actors.PlayerDebugger; -import com.Torvald.Terrarum.Actors.Hitbox; -import com.Torvald.Terrarum.GameMap.PairedMapLayer; -import com.Torvald.Terrarum.LangPack.Lang; -import com.Torvald.Terrarum.MapDrawer.LightmapRenderer; -import com.Torvald.Terrarum.MapDrawer.MapDrawer; -import com.Torvald.Terrarum.Terrarum; -import com.Torvald.Terrarum.MapDrawer.MapCamera; -import org.newdawn.slick.Color; -import org.newdawn.slick.GameContainer; -import org.newdawn.slick.Graphics; -import org.newdawn.slick.Input; - -import java.util.Formatter; - -/** - * Created by minjaesong on 16-01-19. - */ -public class BasicDebugInfoWindow implements UICanvas { - - private static PlayerDebugger playerDbg; - - int width; - int height; - - /** - * Call AFTER player constuction! - */ - public BasicDebugInfoWindow() { - width = Terrarum.WIDTH; - height = Terrarum.HEIGHT; - } - - @Override - public void render(GameContainer gc, Graphics g) { - if (playerDbg == null) { - playerDbg = new PlayerDebugger(Terrarum.game.getPlayer()); - } - - - StringBuilder sb = new StringBuilder(); - Formatter formatter = new Formatter(sb); - - int mouseTileX = (int) ((MapCamera.getCameraX() + gc.getInput().getMouseX() / Terrarum.game.screenZoom) - / MapDrawer.TILE_SIZE); - int mouseTileY = (int) ((MapCamera.getCameraY() + gc.getInput().getMouseY() / Terrarum.game.screenZoom) - / MapDrawer.TILE_SIZE); - - g.setColor(Color.white); - - Hitbox hitbox = playerDbg.hitbox(); - Hitbox nextHitbox = playerDbg.nextHitbox(); - - printLine(g, 1, "posX : " - + String.valueOf(hitbox.getPointedX()) - + " (" - + String.valueOf((int) (hitbox.getPointedX() / MapDrawer.TILE_SIZE)) - + ")" - ); - printLine(g, 2, "posY : " - + String.valueOf(hitbox.getPointedY()) - + " (" - + String.valueOf((int) (hitbox.getPointedY() / MapDrawer.TILE_SIZE)) - + ")" - ); - printLine(g, 3, "veloX : " + String.valueOf(playerDbg.veloX())); - printLine(g, 4, "veloY : " + String.valueOf(playerDbg.veloY())); - printLine(g, 5, "grounded : " + String.valueOf(playerDbg.grounded())); - printLine(g, 6, "noClip : " + String.valueOf(playerDbg.noClip())); - printLine(g, 7, "mass : " + String.valueOf(playerDbg.mass()) + " [kg]"); - - String lightVal; - String mtX = String.valueOf(mouseTileX), mtY = String.valueOf(mouseTileY); - try { - char valRaw = LightmapRenderer.getValueFromMap(mouseTileX, mouseTileY); - int rawR = LightmapRenderer.getRawR(valRaw); - int rawG = LightmapRenderer.getRawG(valRaw); - int rawB = LightmapRenderer.getRawB(valRaw); - lightVal = String.valueOf((int)valRaw) + " (" - + String.valueOf(rawR) + " " - + String.valueOf(rawG) + " " - + String.valueOf(rawB) + ")"; - } - catch (ArrayIndexOutOfBoundsException e) { - lightVal = "out of bounds"; - mtX = "---"; - mtY = "---"; - } - printLine(g, 8, "light at cursor : " + lightVal - ); - - String tileNo; - try { - int tileNumRaw = Terrarum.game.map.getTileFromTerrain(mouseTileX, mouseTileY); - int tilenum = tileNumRaw / PairedMapLayer.RANGE; - int tiledmg = tileNumRaw % PairedMapLayer.RANGE; - tileNo = tilenum + ":" + tiledmg; - } - catch (ArrayIndexOutOfBoundsException e) { - tileNo = "-"; - } - printLine(g, 9, "tile : " + tileNo + " (" + mtX + ", " + mtY + ")"); - - /** - * Second column - */ - - int collisonFlag = playerDbg.eventMoving(); - printLineColumn(g, 2, 1, "Vsync : " + Terrarum.appgc.isVSyncRequested()); - printLineColumn(g, 2, 2, "Env colour temp : " + MapDrawer.getColTemp()); - - /** - * On screen - */ - - // Memory allocation - long memInUse = Terrarum.game.memInUse; - long totalVMMem = Terrarum.game.totalVMMem; - - g.setColor(new Color(0xFF7F00)); - g.drawString( - Lang.get("DEV_MEMORY_SHORT_CAP") - + " : " - + formatter.format( - Lang.get("DEV_MEMORY_A_OF_B") - , memInUse - , totalVMMem - ) - , Terrarum.WIDTH - 200, line(1) - ); - - // Hitbox - float zoom = Terrarum.game.screenZoom; - g.setColor(new Color(0x007f00)); - g.drawRect(hitbox.getHitboxStart().getX() * zoom - - MapCamera.getCameraX() * zoom - , hitbox.getHitboxStart().getY() * zoom - - MapCamera.getCameraY() * zoom - , hitbox.getWidth() * zoom - , hitbox.getHeight() * zoom - ); - // ...and its point - g.fillRect( - (hitbox.getPointedX() - 1) * zoom - - MapCamera.getCameraX() * zoom - , (hitbox.getPointedY() - 1) * zoom - - MapCamera.getCameraY() * zoom - , 3 - , 3 - ); - g.drawString( - Lang.get("DEV_COLOUR_LEGEND_GREEN") - + " : hitbox", Terrarum.WIDTH - 200 - , line(2) - ); - - // Next hitbox - g.setColor(Color.blue); - g.drawRect(nextHitbox.getHitboxStart().getX() * zoom - - MapCamera.getCameraX() * zoom - , nextHitbox.getHitboxStart().getY() * zoom - - MapCamera.getCameraY() * zoom - , nextHitbox.getWidth() * zoom - , nextHitbox.getHeight() * zoom - ); - // ...and its point - g.fillRect( - (nextHitbox.getPointedX() - 1) * zoom - - MapCamera.getCameraX() * zoom - , (nextHitbox.getPointedY() - 1) * zoom - - MapCamera.getCameraY() * zoom - , 3 - , 3 - ); - g.drawString( - Lang.get("DEV_COLOUR_LEGEND_BLUE") - + " : nextHitbox", Terrarum.WIDTH - 200 - , line(3) - ); - } - - private static void printLine(Graphics g, int l, String s) { - g.drawString(s, 20, line(l)); - } - - private static void printLineColumn(Graphics g, int col, int row, String s) { - g.drawString(s, 20 + column(col), line(row)); - } - - private static int line(int i) { - return i * 20; - } - - private static int column(int i) { - return (250 * (i - 1)); - } - - @Override - public void update(GameContainer gc, int delta_t) { - - } - - @Override - public void processInput(Input input) { - - } - - @Override - public int getWidth() { - return width; - } - - @Override - public int getHeight() { - return height; - } - -} diff --git a/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.kt b/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.kt index 278e08702..d90897ebb 100644 --- a/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.kt +++ b/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.kt @@ -17,8 +17,10 @@ import java.util.* */ class BasicDebugInfoWindow : UICanvas { - override var width: Int? = Terrarum.WIDTH - override var height: Int? = Terrarum.HEIGHT + override var width: Int = Terrarum.WIDTH + override var height: Int = Terrarum.HEIGHT + + override var openCloseTime: Int = 0 override fun processInput(input: Input) { @@ -45,7 +47,7 @@ class BasicDebugInfoWindow : UICanvas { printLine(g, 1, "posX : " + "${hitbox!!.pointedX.toString()}" + " (" - + "${(hitbox!!.pointedX / MapDrawer.TILE_SIZE).toInt().toString()}" + + "${(hitbox.pointedX / MapDrawer.TILE_SIZE).toInt().toString()}" + ")") printLine(g, 2, "posY : " + hitbox.pointedY.toString() @@ -56,7 +58,6 @@ class BasicDebugInfoWindow : UICanvas { printLine(g, 4, "veloY : ${player.veloY}") printLine(g, 5, "grounded : ${player.grounded}") printLine(g, 6, "noClip : ${player.noClip}") - printLine(g, 7, "mass : ${player.mass} [kg]") val lightVal: String var mtX = mouseTileX.toString() @@ -76,7 +77,7 @@ class BasicDebugInfoWindow : UICanvas { mtY = "---" } - printLine(g, 8, "light at cursor : " + lightVal) + printLine(g, 7, "light at cursor : " + lightVal) val tileNo: String try { @@ -88,7 +89,7 @@ class BasicDebugInfoWindow : UICanvas { tileNo = "-" } - printLine(g, 9, "tile : $tileNo ($mtX, $mtY)") + printLine(g, 8, "tile at cursor : $tileNo ($mtX, $mtY)") /** * Second column @@ -96,6 +97,8 @@ class BasicDebugInfoWindow : UICanvas { printLineColumn(g, 2, 1, "Vsync : " + Terrarum.appgc.isVSyncRequested) printLineColumn(g, 2, 2, "Env colour temp : " + MapDrawer.getColTemp()) + printLineColumn(g, 2, 3, "Time : ${Terrarum.game.map.worldTime.elapsedSeconds()}" + + " (${Terrarum.game.map.worldTime.getFormattedTime()})") /** * On screen @@ -136,7 +139,7 @@ class BasicDebugInfoWindow : UICanvas { , nextHitbox.getHeight() * zoom) // ...and its point g.fillRect( - (nextHitbox!!.getPointedX() - 1) * zoom - MapCamera.cameraX * zoom + (nextHitbox.getPointedX() - 1) * zoom - MapCamera.cameraX * zoom , (nextHitbox.getPointedY() - 1) * zoom - MapCamera.cameraY * zoom , 3f, 3f) g.drawString( @@ -159,4 +162,20 @@ class BasicDebugInfoWindow : UICanvas { private fun column(i: Int): Int { return 250 * (i - 1) } + + override fun doOpening(gc: GameContainer, delta: Int) { + + } + + override fun doClosing(gc: GameContainer, delta: Int) { + + } + + override fun endOpening(gc: GameContainer, delta: Int) { + + } + + override fun endClosing(gc: GameContainer, delta: Int) { + + } } \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/UserInterface/ConsoleWindow.java b/src/com/Torvald/Terrarum/UserInterface/ConsoleWindow.java deleted file mode 100644 index 22e4bf3b6..000000000 --- a/src/com/Torvald/Terrarum/UserInterface/ConsoleWindow.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.Torvald.Terrarum.UserInterface; - -import com.Torvald.Terrarum.LangPack.Lang; -import com.Torvald.Terrarum.Terrarum; -import com.Torvald.Terrarum.ConsoleCommand.CommandInterpreter; -import com.Torvald.Terrarum.GameControl.Key; -import org.jetbrains.annotations.Nullable; -import org.newdawn.slick.Color; -import org.newdawn.slick.GameContainer; -import org.newdawn.slick.Graphics; -import org.newdawn.slick.Input; - -/** - * Created by minjaesong on 15-12-31. - */ -public class ConsoleWindow implements UICanvas, UITypable { - - Color UIColour = new Color(0x90000000); - - private StringBuffer commandInputPool; - private String prevCommand; - - private int inputCursorPos; - - private final int MESSAGES_MAX = 5000; - private String[] messages; - private int messageDisplayPos; - private int messagesCount; - - private final int LINE_HEIGHT = 20; - private final int MESSAGES_DISPLAY_COUNT = 9; - - int width; - int height; - - public ConsoleWindow() { - super(); - reset(); - } - - @Override - public void update(GameContainer gc, int delta_t) { - - } - - @Override - public void render(GameContainer gc, Graphics g) { - g.setColor(UIColour); - g.fillRect(0, 0, width, height); - g.fillRect(0, 0, width, LINE_HEIGHT); - - String input = commandInputPool.toString(); - int inputDrawWidth = g.getFont().getWidth(input); - int inputDrawHeight = g.getFont().getLineHeight(); - - g.setColor(Color.white); - g.drawString(input, 1, 0); - g.fillRect(inputDrawWidth, 0, 2, inputDrawHeight); - - for (int i = 0; i < MESSAGES_DISPLAY_COUNT; i++) { - String message = messages[messageDisplayPos + i]; - if (message != null) { - g.drawString(message, 1, LINE_HEIGHT * (i + 1)); - } - } - } - - - - public void keyPressed(int key, char c) { - // execute - if (key == Key.RET && commandInputPool.length() > 0) { - prevCommand = commandInputPool.toString(); - executeCommand(); - commandInputPool = new StringBuffer(); - } - // backspace - else if (key == Key.BKSP && commandInputPool.length() > 0) { - commandInputPool.deleteCharAt(commandInputPool.length() - 1); - } - // get input - else if ((key >= 2 && key <= 13) - || (key >= 16 && key <= 27) - || (key >= 30 && key <= 40) - || (key >= 44 && key <= 53) - || (commandInputPool.length() > 0 && key == 57)){ - commandInputPool.append(c); - inputCursorPos += 1; - } - // prev command - else if (key == Key.UP) { - commandInputPool = new StringBuffer(); - commandInputPool.append(prevCommand); - } - // scroll up - else if (key == Key.PGUP) { - setDisplayPos(-MESSAGES_DISPLAY_COUNT + 1); - } - // scroll down - else if (key == Key.PGDN) { - setDisplayPos(MESSAGES_DISPLAY_COUNT - 1); - } - } - - @Override - public void keyReleased(int key, char c) { - - } - - @Override - public void processInput(Input input) { - - } - - private void executeCommand() { - sendMessage("> " + commandInputPool.toString()); - CommandInterpreter.execute(commandInputPool.toString()); - } - - public void sendMessage(String msg) { - messages[messagesCount] = new String(msg); - messagesCount += 1; - if (messagesCount > MESSAGES_DISPLAY_COUNT) { - messageDisplayPos = messagesCount - MESSAGES_DISPLAY_COUNT; - } - } - - private void setDisplayPos(int change) { - int lowLim = 0; - int highLim = (messagesCount <= MESSAGES_DISPLAY_COUNT) - ? 0 - : messagesCount - MESSAGES_DISPLAY_COUNT; - int newVal = messageDisplayPos + change; - - if (newVal < lowLim) { - messageDisplayPos = lowLim; - } - else if (newVal > highLim) { - messageDisplayPos = highLim; - } - else { - messageDisplayPos = newVal; - } - - } - - public void reset() { - setWidth(Terrarum.WIDTH); - setHeight(200); - - messages = new String[MESSAGES_MAX]; - messageDisplayPos = 0; - messagesCount = 0; - inputCursorPos = 0; - prevCommand = ""; - commandInputPool = new StringBuffer(); - - if (Terrarum.game.auth.b()) sendMessage(Lang.get("DEV_MESSAGE_CONSOLE_CODEX")); - } - - @Nullable - @Override - public Integer getWidth() { - return width; - } - - @Override - public void setWidth(@Nullable Integer integer) { - width = integer; - } - - @Nullable - @Override - public Integer getHeight() { - return height; - } - - @Override - public void setHeight(@Nullable Integer integer) { - height = integer; - } -} diff --git a/src/com/Torvald/Terrarum/UserInterface/ConsoleWindow.kt b/src/com/Torvald/Terrarum/UserInterface/ConsoleWindow.kt new file mode 100644 index 000000000..6d57dd72d --- /dev/null +++ b/src/com/Torvald/Terrarum/UserInterface/ConsoleWindow.kt @@ -0,0 +1,182 @@ +package com.Torvald.Terrarum.UserInterface + +import com.Torvald.Terrarum.LangPack.Lang +import com.Torvald.Terrarum.Terrarum +import com.Torvald.Terrarum.ConsoleCommand.CommandInterpreter +import com.Torvald.Terrarum.GameControl.Key +import com.jme3.math.FastMath +import org.newdawn.slick.Color +import org.newdawn.slick.GameContainer +import org.newdawn.slick.Graphics +import org.newdawn.slick.Input + +/** + * Created by minjaesong on 15-12-31. + */ +class ConsoleWindow : UICanvas, UITypable { + + internal var UIColour = Color(0xB0000000.toInt()) + + private var commandInputPool: StringBuffer? = null + private var prevCommand: String? = null + + private var inputCursorPos: Int = 0 + + private val MESSAGES_MAX = 5000 + private var messages = Array(MESSAGES_MAX, {""}) + private var messageDisplayPos: Int = 0 + private var messagesCount: Int = 0 + + private val LINE_HEIGHT = 20 + private val MESSAGES_DISPLAY_COUNT = 9 + + override var width: Int = Terrarum.WIDTH + override var height: Int = 200 + + override var openCloseTime: Int = 0 + + private var drawOffX: Float = 0f + private var drawOffY: Float = -height.toFloat() + private var openingTimeCounter = 0 + + init { + reset() + } + + override fun update(gc: GameContainer, delta_t: Int) { + + } + + override fun render(gc: GameContainer, g: Graphics) { + // background + g.color = UIColour + g.fillRect(drawOffX, drawOffY, width.toFloat(), height.toFloat()) + g.fillRect(drawOffX, drawOffY, width.toFloat(), LINE_HEIGHT.toFloat()) + + val input = commandInputPool!!.toString() + val inputDrawWidth = g.font.getWidth(input) + val inputDrawHeight = g.font.lineHeight + + // text and cursor + g.color = Color.white + g.drawString(input, 1f + drawOffX, drawOffY) + g.fillRect(inputDrawWidth.toFloat() + drawOffX, drawOffY, 2f, inputDrawHeight.toFloat()) + + // messages + for (i in 0..MESSAGES_DISPLAY_COUNT - 1) { + val message = messages[messageDisplayPos + i] + g.drawString(message, 1f + drawOffX, (LINE_HEIGHT * (i + 1)).toFloat() + drawOffY) + } + } + + + override fun keyPressed(key: Int, c: Char) { + // execute + if (key == Key.RET && commandInputPool!!.length > 0) { + prevCommand = commandInputPool!!.toString() + executeCommand() + commandInputPool = StringBuffer() + } + else if (key == Key.BKSP && commandInputPool!!.length > 0) { + commandInputPool!!.deleteCharAt(commandInputPool!!.length - 1) + } + else if (key >= 2 && key <= 13 + || key >= 16 && key <= 27 + || key >= 30 && key <= 40 + || key >= 44 && key <= 53 + || commandInputPool!!.length > 0 && key == 57) { + commandInputPool!!.append(c) + inputCursorPos += 1 + } + else if (key == Key.UP) { + commandInputPool = StringBuffer() + commandInputPool!!.append(prevCommand) + } + else if (key == Key.PGUP) { + setDisplayPos(-MESSAGES_DISPLAY_COUNT + 1) + } + else if (key == Key.PGDN) { + setDisplayPos(MESSAGES_DISPLAY_COUNT - 1) + }// scroll down + // scroll up + // prev command + // get input + // backspace + } + + override fun keyReleased(key: Int, c: Char) { + + } + + override fun processInput(input: Input) { + + } + + private fun executeCommand() { + sendMessage("> " + commandInputPool!!.toString()) + CommandInterpreter.execute(commandInputPool!!.toString()) + } + + fun sendMessage(msg: String) { + messages[messagesCount] = msg + messagesCount += 1 + if (messagesCount > MESSAGES_DISPLAY_COUNT) { + messageDisplayPos = messagesCount - MESSAGES_DISPLAY_COUNT + } + } + + private fun setDisplayPos(change: Int) { + val lowLim = 0 + val highLim = if (messagesCount <= MESSAGES_DISPLAY_COUNT) + 0 + else + messagesCount - MESSAGES_DISPLAY_COUNT + val newVal = messageDisplayPos + change + + if (newVal < lowLim) { + messageDisplayPos = lowLim + } + else if (newVal > highLim) { + messageDisplayPos = highLim + } + else { + messageDisplayPos = newVal + } + + } + + fun reset() { + messages = Array(MESSAGES_MAX, {""}) + messageDisplayPos = 0 + messagesCount = 0 + inputCursorPos = 0 + prevCommand = "" + commandInputPool = StringBuffer() + + if (Terrarum.game.auth.b()) sendMessage(Lang.get("DEV_MESSAGE_CONSOLE_CODEX")) + } + + override fun doOpening(gc: GameContainer, delta: Int) { + /*openingTimeCounter += delta + drawOffY = MovementInterpolator.fastPullOut(openingTimeCounter.toFloat() / openCloseTime.toFloat(), + -height.toFloat(), 0f + )*/ + } + + override fun doClosing(gc: GameContainer, delta: Int) { + /*openingTimeCounter += delta + drawOffY = MovementInterpolator.fastPullOut(openingTimeCounter.toFloat() / openCloseTime.toFloat(), + 0f, -height.toFloat() + )*/ + } + + override fun endOpening(gc: GameContainer, delta: Int) { + drawOffY = 0f + openingTimeCounter = 0 + } + + override fun endClosing(gc: GameContainer, delta: Int) { + drawOffY = -height.toFloat() + openingTimeCounter = 0 + } +} diff --git a/src/com/Torvald/Terrarum/UserInterface/Message.java b/src/com/Torvald/Terrarum/UserInterface/Message.java deleted file mode 100644 index f9a1196e6..000000000 --- a/src/com/Torvald/Terrarum/UserInterface/Message.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.Torvald.Terrarum.UserInterface; - -import com.Torvald.ImageFont.GameFontWhite; -import org.jetbrains.annotations.Nullable; -import org.newdawn.slick.*; - -/** - * Created by minjaesong on 16-01-27. - */ -public class Message implements UICanvas { - - private Image segmentLeft, segmentRight, segmentBody; - - private String[] messagesList; - // private int messagesShowingIndex = 0; - private static final int MESSAGES_DISPLAY = 2; - - private int width; - private int height; - private int messageWindowRadius; - - private Font uiFont; - private final int GLYPH_HEIGHT = 20; - - public Message(int width, boolean isBlackVariant) throws SlickException { - if (!isBlackVariant) { - //segmentLeft = new Image("./res/graphics/gui/message_twoline_white_left.png"); - //segmentRight = new Image("./res/graphics/gui/message_twoline_white_right.png"); - //segmentBody = new Image("./res/graphics/gui/message_twoline_white_body.png"); - //uiFont = new GameFontBlack(); - throw new SlickException("Black font not supported for now"); - } - else { - segmentLeft = new Image("./res/graphics/gui/message_twoline_black_left.png"); - segmentRight = new Image("./res/graphics/gui/message_twoline_black_right.png"); - segmentBody = new Image("./res/graphics/gui/message_twoline_black_body.png"); - uiFont = new GameFontWhite(); - } - - this.width = width; - height = segmentLeft.getHeight(); - messageWindowRadius = segmentLeft.getWidth(); - } - - public void setMessage(String[] messagesList) { - this.messagesList = messagesList; - } - - @Override - public void update(GameContainer gc, int delta_t) { - - } - - @Override - public void render(GameContainer gc, Graphics g) { - g.drawImage(segmentLeft, 0, 0); - Image scaledSegCentre = segmentBody.getScaledCopy( - width - (segmentRight.getWidth() + segmentLeft.getWidth()) - , segmentLeft.getHeight() - ); - g.drawImage(scaledSegCentre, segmentLeft.getWidth(), 0); - g.drawImage(segmentRight, width - segmentRight.getWidth(), 0); - - g.setFont(uiFont); - //g.setDrawMode(Graphics.MODE_NORMAL); - for (int i = 0; i < Math.min(messagesList.length, MESSAGES_DISPLAY); i++) { - g.drawString(messagesList[i] - , messageWindowRadius + 4 - , messageWindowRadius + (GLYPH_HEIGHT * i) - ); - } - //g.setDrawMode(Graphics.MODE_NORMAL); - } - - @Override - public void processInput(Input input) { - - } - - @Nullable - @Override - public Integer getWidth() { - return width; - } - - @Override - public void setWidth(@Nullable Integer integer) { - width = integer; - } - - @Nullable - @Override - public Integer getHeight() { - return height; - } - - @Override - public void setHeight(@Nullable Integer integer) { - height = integer; - } -} diff --git a/src/com/Torvald/Terrarum/UserInterface/MessageWindow.kt b/src/com/Torvald/Terrarum/UserInterface/MessageWindow.kt new file mode 100644 index 000000000..c1b385913 --- /dev/null +++ b/src/com/Torvald/Terrarum/UserInterface/MessageWindow.kt @@ -0,0 +1,121 @@ +package com.Torvald.Terrarum.UserInterface + +import com.Torvald.ImageFont.GameFontWhite +import com.jme3.math.FastMath +import org.lwjgl.opengl.GL11 +import org.newdawn.slick.* + +/** + * Created by minjaesong on 16-01-27. + */ +class MessageWindow @Throws(SlickException::class) +constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas { + + private var segmentLeft: Image? = null + private var segmentRight: Image? = null + private var segmentBody: Image? = null + + private lateinit var messagesList: Array + override var height: Int = 0 + private val messageWindowRadius: Int + + private var uiFont: Font? = null + private val GLYPH_HEIGHT = 20 + + override var openCloseTime: Int = OPEN_CLOSE_TIME + + internal var opacity = 0f + internal var openCloseCounter = 0 + + private lateinit var uidrawCanvas: Image // render all the images and fonts here; will be faded + + init { + if (!isBlackVariant) { + //segmentLeft = new Image("./res/graphics/gui/message_twoline_white_left.png"); + //segmentRight = new Image("./res/graphics/gui/message_twoline_white_right.png"); + //segmentBody = new Image("./res/graphics/gui/message_twoline_white_body.png"); + //uiFont = new GameFontBlack(); + TODO("Black font not supported for now") + } + else { + segmentLeft = Image("./res/graphics/gui/message_twoline_black_left.png") + segmentRight = Image("./res/graphics/gui/message_twoline_black_right.png") + segmentBody = Image("./res/graphics/gui/message_twoline_black_body.png") + uiFont = GameFontWhite() + } + height = segmentLeft!!.height + messageWindowRadius = segmentLeft!!.width + messagesList = arrayOf("", "") + uidrawCanvas = Image(FastMath.nearestPowerOfTwo(width), FastMath.nearestPowerOfTwo(height)) + } + + fun setMessage(messagesList: Array) { + this.messagesList = messagesList + } + + override fun update(gc: GameContainer, delta_t: Int) { + + } + + override fun render(gc: GameContainer, g: Graphics) { + val canvasG = uidrawCanvas.graphics + + canvasG.setDrawMode(Graphics.MODE_NORMAL) + drawSegments(canvasG) + canvasG.setDrawMode(Graphics.MODE_ALPHA_MAP) + drawSegments(canvasG) + + canvasG.font = uiFont + + canvasG.setDrawMode(Graphics.MODE_NORMAL) + for (i in 0..Math.min(messagesList.size, MESSAGES_DISPLAY) - 1) { + canvasG.drawString(messagesList[i], (messageWindowRadius + 4).toFloat(), (messageWindowRadius + GLYPH_HEIGHT * i).toFloat()) + } + + g.drawImage(uidrawCanvas, 0f, 0f, Color(1f,1f,1f,opacity)) + + canvasG.clear() + } + + override fun processInput(input: Input) { + + } + + override fun doOpening(gc: GameContainer, delta: Int) { + openCloseCounter += delta + opacity = FastMath.interpolateLinear(openCloseCounter.toFloat() / openCloseTime.toFloat(), + 0f, 1f + ) + } + + override fun doClosing(gc: GameContainer, delta: Int) { + openCloseCounter += delta + opacity = FastMath.interpolateLinear(openCloseCounter.toFloat() / openCloseTime.toFloat(), + 1f, 0f + ) + } + + override fun endOpening(gc: GameContainer, delta: Int) { + opacity = 1f + openCloseCounter = 0 + } + + override fun endClosing(gc: GameContainer, delta: Int) { + opacity = 0f + openCloseCounter = 0 + } + + private fun drawSegments(g: Graphics) { + g.drawImage(segmentLeft, 0f, 0f) + val scaledSegCentre = segmentBody!!.getScaledCopy( + width - (segmentRight!!.width + segmentLeft!!.width), segmentLeft!!.height) + g.drawImage(scaledSegCentre, segmentLeft!!.width.toFloat(), 0f) + g.drawImage(segmentRight, (width - segmentRight!!.width).toFloat(), 0f) + } + + companion object { + // private int messagesShowingIndex = 0; + val MESSAGES_DISPLAY = 2 + val OPEN_CLOSE_TIME = 200 + } +} diff --git a/src/com/Torvald/Terrarum/UserInterface/MovementInterpolator.kt b/src/com/Torvald/Terrarum/UserInterface/MovementInterpolator.kt new file mode 100644 index 000000000..96cfd4a82 --- /dev/null +++ b/src/com/Torvald/Terrarum/UserInterface/MovementInterpolator.kt @@ -0,0 +1,30 @@ +package com.Torvald.Terrarum.UserInterface + +import com.jme3.math.FastMath + +/** + * Created by minjaesong on 16-03-22. + */ +object MovementInterpolator { + /** + * Pretty fast at the beginning, getting slow over time. + */ + fun fastPullOut(scale: Float, start: Float = 0f, end: Float = 1f): Float = + if (scale < 0f) start + else if (scale > 1f) end + else (start - end) * FastMath.sqr(scale - 1) + end + + /** + * Slow at the beginning, getting fast over time. + */ + fun dropDown(scale: Float, start: Float = 0f, end: Float = 1f): Float = + if (scale < 0f) start + else if (scale > 1f) end + else (end - start) * FastMath.sqr(scale) + start + + fun sinusoid(scale: Float, start: Float = 0f, end: Float = 1f): Float = + if (scale < 0f) start + else if (scale > 1f) end + else (start - end) * FastMath.cos2(0.5f * FastMath.PI * scale) + end + +} \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/UserInterface/Notification.java b/src/com/Torvald/Terrarum/UserInterface/Notification.java deleted file mode 100644 index c1e155588..000000000 --- a/src/com/Torvald/Terrarum/UserInterface/Notification.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.Torvald.Terrarum.UserInterface; - -import com.Torvald.Terrarum.Terrarum; -import org.jetbrains.annotations.Nullable; -import org.newdawn.slick.*; -import org.newdawn.slick.geom.RoundedRectangle; - -/** - * Created by minjaesong on 16-01-23. - */ -public class Notification implements UICanvas { - - int width; - int height; - - int visibleTime; - int showupTimeConuter = 0; - - boolean isShowing = false; - String[] message; - - Message msgUI; - - public Notification() throws SlickException { - width = 400; - msgUI = new Message(width, true); - height = msgUI.getHeight(); - visibleTime = Terrarum.getConfigInt("notificationshowuptime"); - } - - @Override - public void update(GameContainer gc, int delta_t) { - if (showupTimeConuter >= visibleTime) { - isShowing = false; - } - - if (isShowing) { - showupTimeConuter += delta_t; - } - } - - @Override - public void render(GameContainer gc, Graphics g) { - if (isShowing) { - msgUI.render(gc, g); - } - } - - @Override - public void processInput(Input input) { - - } - - @Nullable - @Override - public Integer getWidth() { - return width; - } - - @Override - public void setWidth(@Nullable Integer integer) { - width = integer; - } - - @Nullable - @Override - public Integer getHeight() { - return height; - } - - @Override - public void setHeight(@Nullable Integer integer) { - height = integer; - } - - public void sendNotification(String[] message) { - isShowing = true; - this.message = message; - showupTimeConuter = 0; - msgUI.setMessage(this.message); - } -} diff --git a/src/com/Torvald/Terrarum/UserInterface/Notification.kt b/src/com/Torvald/Terrarum/UserInterface/Notification.kt new file mode 100644 index 000000000..9428ece2b --- /dev/null +++ b/src/com/Torvald/Terrarum/UserInterface/Notification.kt @@ -0,0 +1,87 @@ +package com.Torvald.Terrarum.UserInterface + +import com.Torvald.Terrarum.Terrarum +import org.newdawn.slick.GameContainer +import org.newdawn.slick.Graphics +import org.newdawn.slick.Input +import org.newdawn.slick.SlickException + +/** + * Created by minjaesong on 16-01-23. + */ +class Notification @Throws(SlickException::class) +constructor() : UICanvas { + + override var width: Int = 0 + override var height: Int = 0 + internal var visibleTime: Int + internal var showupTimeConuter = 0 + + internal var isShowing = false + internal var message: Array = Array(MessageWindow.MESSAGES_DISPLAY, { i -> ""}) + + internal var msgUI: MessageWindow + + override var openCloseTime: Int = MessageWindow.OPEN_CLOSE_TIME + + private val SHOWUP_MAX = 15000 + + init { + width = 500 + msgUI = MessageWindow(width, true) + height = msgUI.height + visibleTime = Math.min( + Terrarum.getConfigInt("notificationshowuptime"), + SHOWUP_MAX + ) + } + + override fun update(gc: GameContainer, delta: Int) { + if (showupTimeConuter >= visibleTime && isShowing) { + // invoke closing mode + doClosing(gc, delta) + // check if msgUI is fully fade out + if (msgUI.opacity <= 0.001f) { + endClosing(gc, delta) + isShowing = false + } + } + + if (isShowing) { + showupTimeConuter += delta + } + } + + override fun render(gc: GameContainer, g: Graphics) { + if (isShowing) { + msgUI.render(gc, g) + } + } + + override fun doOpening(gc: GameContainer, delta: Int) { + msgUI.doOpening(gc, delta) + } + + override fun doClosing(gc: GameContainer, delta: Int) { + msgUI.doClosing(gc, delta) + } + + override fun endOpening(gc: GameContainer, delta: Int) { + msgUI.endOpening(gc, delta) + } + + override fun endClosing(gc: GameContainer, delta: Int) { + msgUI.endClosing(gc, delta) + } + + override fun processInput(input: Input) { + + } + + fun sendNotification(gc: GameContainer, delta: Int, message: Array) { + isShowing = true + this.message = message + msgUI.setMessage(this.message) + showupTimeConuter = 0 + } +} diff --git a/src/com/Torvald/Terrarum/UserInterface/UICanvas.kt b/src/com/Torvald/Terrarum/UserInterface/UICanvas.kt index 07e105666..cf6652970 100644 --- a/src/com/Torvald/Terrarum/UserInterface/UICanvas.kt +++ b/src/com/Torvald/Terrarum/UserInterface/UICanvas.kt @@ -5,17 +5,28 @@ import org.newdawn.slick.Graphics import org.newdawn.slick.Input /** - * Created by minjaesong on 16-03-14. + * Created by minjaesong on 15-12-31. */ interface UICanvas { - var width: Int? - var height: Int? + var width: Int + var height: Int + /** + * In milliseconds + */ + var openCloseTime: Int - fun update(gc: GameContainer, delta_t: Int) + fun update(gc: GameContainer, delta: Int) fun render(gc: GameContainer, g: Graphics) fun processInput(input: Input) + fun doOpening(gc: GameContainer, delta: Int) + + fun doClosing(gc: GameContainer, delta: Int) + + fun endOpening(gc: GameContainer, delta: Int) + + fun endClosing(gc: GameContainer, delta: Int) } \ No newline at end of file diff --git a/src/com/Torvald/Terrarum/UserInterface/UIClickable.kt b/src/com/Torvald/Terrarum/UserInterface/UIClickable.kt index 2d24eb925..814ffad94 100644 --- a/src/com/Torvald/Terrarum/UserInterface/UIClickable.kt +++ b/src/com/Torvald/Terrarum/UserInterface/UIClickable.kt @@ -1,7 +1,7 @@ package com.Torvald.Terrarum.UserInterface /** - * Created by minjaesong on 16-03-14. + * Created by minjaesong on 16-03-06. */ interface UIClickable { fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) diff --git a/src/com/Torvald/Terrarum/UserInterface/UIHandler.java b/src/com/Torvald/Terrarum/UserInterface/UIHandler.java deleted file mode 100644 index 2a24b4481..000000000 --- a/src/com/Torvald/Terrarum/UserInterface/UIHandler.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.Torvald.Terrarum.UserInterface; - -import com.Torvald.Terrarum.MapDrawer.MapCamera; -import com.Torvald.Terrarum.Terrarum; -import com.Torvald.Terrarum.Game; -import com.jme3.math.FastMath; -import com.sun.istack.internal.Nullable; -import org.newdawn.slick.*; - -/** - * Created by minjaesong on 15-12-31. - */ -public class UIHandler { - - private UICanvas ui; - - // X/Y Position to the game window. - private int posX; - private int posY; - private boolean visible = false; - - private boolean alwaysVisible = false; - - private Graphics UIGraphicInstance; - private Image UIDrawnCanvas; - - private boolean opening = false; - private boolean closing = false; - - /** - * Construct new UIHandler with given UI attached. - * Invisible in default. - * @param ui - * @throws SlickException - */ - public UIHandler(UICanvas ui) throws SlickException{ - System.out.println(("[UIHandler] Creating UI '" + ui.getClass().getTypeName()) + "'"); - - this.ui = ui; - - UIDrawnCanvas = new Image( - FastMath.nearestPowerOfTwo(ui.getWidth()) - , FastMath.nearestPowerOfTwo(ui.getHeight()) - ); - - UIGraphicInstance = UIDrawnCanvas.getGraphics(); - - visible = false; - } - - - - public void update(GameContainer gc, int delta_t){ - if (visible || alwaysVisible) { - ui.update(gc, delta_t); - } - } - - public void render(GameContainer gc, Graphics gameGraphicInstance) { - if (visible || alwaysVisible) { - UIGraphicInstance.clear(); - UIGraphicInstance.setFont(Terrarum.gameFontWhite); - - ui.render(gc, UIGraphicInstance); - gameGraphicInstance.drawImage(UIDrawnCanvas - // compensate for screenZoom AND camera translation - // (see Game.render -> g.translate()) - , posX + MapCamera.getCameraX() * Terrarum.game.screenZoom - , posY + MapCamera.getCameraY() * Terrarum.game.screenZoom - ); - } - } - - public void setPosition(int x, int y){ - posX = x; - posY = y; - } - - public void setVisibility(boolean b){ - if (alwaysVisible) { - throw new RuntimeException("[UIHandler] Tried to 'set visibility of' constant UI"); - } - visible = b; - } - - - - public int getPosX() { - return posX; - } - - public int getPosY() { - return posY; - } - - public boolean isVisible() { - if (alwaysVisible) { - return true; - } else { - return visible; - } - } - - public void setAsAlwaysVisible() { - alwaysVisible = true; - visible = true; - } - - - - public void setAsOpening(){ - if (alwaysVisible) { - throw new RuntimeException("[UIHandler] Tried to 'open' constant UI"); - } - visible = true; - } - - public void setAsClosing(){ - if (alwaysVisible) { - throw new RuntimeException("[UIHandler] Tried to 'close' constant UI"); - } - visible = false; - } - - public void toggleOpening() { - if (alwaysVisible) { - throw new RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI"); - } - if (visible) { - if (!closing) { - setAsClosing(); - } - } - else { - if (!opening) { - setAsOpening(); - } - } - } - - public void processInput(Input input) { - if (visible) { ui.processInput(input); } - } - - public void keyPressed(int key, char c) { - if (visible && ui instanceof UITypable) { ((UITypable) (ui)).keyPressed(key, c); } - } - - public void keyReleased(int key, char c) { - if (visible && ui instanceof UITypable) { ((UITypable) (ui)).keyReleased(key, c); } - } - - public void mouseMoved(int oldx, int oldy, int newx, int newy) { - if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).mouseMoved(oldx, oldy, newx, newy); } - } - - public void mouseDragged(int oldx, int oldy, int newx, int newy) { - if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).mouseDragged(oldx, oldy, newx, newy); } - } - - public void mousePressed(int button, int x, int y) { - if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).mousePressed(button, x, y); } - } - - public void mouseReleased(int button, int x, int y) { - if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).mouseReleased(button, x, y); } - } - - public void mouseWheelMoved(int change) { - if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).mouseWheelMoved(change); } - } - - public void controllerButtonPressed(int controller, int button) { - if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).controllerButtonPressed(controller, button); } - } - - public void controllerButtonReleased(int controller, int button) { - if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).controllerButtonReleased(controller, button); } - } - - public boolean isTakingControl() { - if (alwaysVisible) { - return false; // constant UI can't take control - } - return (visible && !opening); - } - - public UICanvas getUI() { - return ui; - } -} diff --git a/src/com/Torvald/Terrarum/UserInterface/UIHandler.kt b/src/com/Torvald/Terrarum/UserInterface/UIHandler.kt new file mode 100644 index 000000000..d8eba8b2a --- /dev/null +++ b/src/com/Torvald/Terrarum/UserInterface/UIHandler.kt @@ -0,0 +1,235 @@ +package com.Torvald.Terrarum.UserInterface + +import com.Torvald.Terrarum.MapDrawer.MapCamera +import com.Torvald.Terrarum.Terrarum +import com.jme3.math.FastMath +import org.newdawn.slick.* + +/** + * Created by minjaesong on 15-12-31. + */ +class UIHandler +/** + * Construct new UIHandler with given UI attached. + * Invisible in default. + * @param UI + * * + * @throws SlickException + */ +@Throws(SlickException::class) +constructor(val UI: UICanvas) { + + // X/Y Position to the game window. + var posX: Int = 0 + private set + var posY: Int = 0 + private set + + private var alwaysVisible = false + + private val UIGraphicInstance: Graphics + private val UIDrawnCanvas: Image + + private var opening = false + private var closing = false + private var opened = false // fully opened + private var visible = false + + var openCloseCounter = 0 + + init { + println("[UIHandler] Creating UI '${UI.javaClass.simpleName}'") + + UIDrawnCanvas = Image( + FastMath.nearestPowerOfTwo(UI.width), FastMath.nearestPowerOfTwo(UI.height)) + + UIGraphicInstance = UIDrawnCanvas.graphics + } + + + fun update(gc: GameContainer, delta: Int) { + if (visible || alwaysVisible) { + UI.update(gc, delta) + } + + if (opening) { + visible = true + openCloseCounter += delta + + // println("UI ${UI.javaClass.simpleName} (open)") + // println("-> timecounter $openCloseCounter / ${UI.openCloseTime} timetakes") + + if (openCloseCounter < UI.openCloseTime) { + UI.doOpening(gc, delta) + // println("UIHandler.opening ${UI.javaClass.simpleName}") + } + else { + UI.endOpening(gc, delta) + opening = false + opened = true + openCloseCounter = 0 + } + } + else if (closing) { + openCloseCounter += delta + + // println("UI ${UI.javaClass.simpleName} (close)") + // println("-> timecounter $openCloseCounter / ${UI.openCloseTime} timetakes") + + if (openCloseCounter < UI.openCloseTime) { + UI.doClosing(gc, delta) + // println("UIHandler.closing ${UI.javaClass.simpleName}") + } + else { + UI.endClosing(gc, delta) + closing = false + opened = false + visible = false + openCloseCounter = 0 + } + } + } + + fun render(gc: GameContainer, gameGraphicInstance: Graphics) { + if (visible || alwaysVisible) { + UIGraphicInstance.clear() + UIGraphicInstance.font = Terrarum.gameFontWhite + + UI.render(gc, UIGraphicInstance) + gameGraphicInstance.drawImage(UIDrawnCanvas, posX + MapCamera.getCameraX() * Terrarum.game.screenZoom, posY + MapCamera.getCameraY() * Terrarum.game.screenZoom)// compensate for screenZoom AND camera translation + // (see Game.render -> g.translate()) + } + } + + fun setPosition(x: Int, y: Int) { + posX = x + posY = y + } + + fun setVisibility(b: Boolean) { + if (alwaysVisible) { + throw RuntimeException("[UIHandler] Tried to 'set visibility of' constant UI") + } + visible = b + } + + val isVisible: Boolean + get() { + if (alwaysVisible) { + return true + } + else { + return visible + } + } + + fun setAsAlwaysVisible() { + alwaysVisible = true + visible = true + opened = true + opening = false + closing = false + } + + + fun setAsOpening() { + if (alwaysVisible) { + throw RuntimeException("[UIHandler] Tried to 'open' constant UI") + } + opened = false + opening = true + } + + fun setAsClosing() { + if (alwaysVisible) { + throw RuntimeException("[UIHandler] Tried to 'close' constant UI") + } + opened = false + closing = true + } + + fun toggleOpening() { + if (alwaysVisible) { + throw RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI") + } + if (visible) { + if (!closing) { + setAsClosing() + } + } + else { + if (!opening) { + setAsOpening() + } + } + } + + fun processInput(input: Input) { + if (visible) { + UI.processInput(input) + } + } + + fun keyPressed(key: Int, c: Char) { + if (visible && UI is UITypable) { + UI.keyPressed(key, c) + } + } + + fun keyReleased(key: Int, c: Char) { + if (visible && UI is UITypable) { + UI.keyReleased(key, c) + } + } + + fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { + if (visible && UI is UIClickable) { + UI.mouseMoved(oldx, oldy, newx, newy) + } + } + + fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { + if (visible && UI is UIClickable) { + UI.mouseDragged(oldx, oldy, newx, newy) + } + } + + fun mousePressed(button: Int, x: Int, y: Int) { + if (visible && UI is UIClickable) { + UI.mousePressed(button, x, y) + } + } + + fun mouseReleased(button: Int, x: Int, y: Int) { + if (visible && UI is UIClickable) { + UI.mouseReleased(button, x, y) + } + } + + fun mouseWheelMoved(change: Int) { + if (visible && UI is UIClickable) { + UI.mouseWheelMoved(change) + } + } + + fun controllerButtonPressed(controller: Int, button: Int) { + if (visible && UI is UIClickable) { + UI.controllerButtonPressed(controller, button) + } + } + + fun controllerButtonReleased(controller: Int, button: Int) { + if (visible && UI is UIClickable) { + UI.controllerButtonReleased(controller, button) + } + } + + // constant UI can't take control + val isTakingControl: Boolean + get() { + if (alwaysVisible) { + return false + } + return visible && !opening + } +} diff --git a/src/com/Torvald/Terrarum/UserInterface/UIItem.java b/src/com/Torvald/Terrarum/UserInterface/UIItem.java deleted file mode 100644 index 5ee8ae1c2..000000000 --- a/src/com/Torvald/Terrarum/UserInterface/UIItem.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.Torvald.Terrarum.UserInterface; - -/** - * Created by minjaesong on 15-12-31. - */ -public class UIItem { - - // X/Y Position relative to the containing canvas - int posX; - int posY; - - - -} diff --git a/src/com/Torvald/Terrarum/UserInterface/UIItem.kt b/src/com/Torvald/Terrarum/UserInterface/UIItem.kt new file mode 100644 index 000000000..860697517 --- /dev/null +++ b/src/com/Torvald/Terrarum/UserInterface/UIItem.kt @@ -0,0 +1,13 @@ +package com.Torvald.Terrarum.UserInterface + +/** + * Created by minjaesong on 15-12-31. + */ +class UIItem { + + // X/Y Position relative to the containing canvas + internal var posX: Int = 0 + internal var posY: Int = 0 + + +} diff --git a/src/com/Torvald/Terrarum/UserInterface/UITypable.kt b/src/com/Torvald/Terrarum/UserInterface/UITypable.kt index 1a62bc206..f27ec1253 100644 --- a/src/com/Torvald/Terrarum/UserInterface/UITypable.kt +++ b/src/com/Torvald/Terrarum/UserInterface/UITypable.kt @@ -1,7 +1,7 @@ package com.Torvald.Terrarum.UserInterface /** - * Created by minjaesong on 16-03-14. + * Created by minjaesong on 16-03-06. */ interface UITypable { fun keyPressed(key: Int, c: Char) diff --git a/src/com/Torvald/spriteAnimation/SpriteAnimation.java b/src/com/Torvald/spriteAnimation/SpriteAnimation.java index 51b8fec3e..b5080d7ec 100644 --- a/src/com/Torvald/spriteAnimation/SpriteAnimation.java +++ b/src/com/Torvald/spriteAnimation/SpriteAnimation.java @@ -14,21 +14,21 @@ import org.newdawn.slick.SlickException; import org.newdawn.slick.SpriteSheet; public class SpriteAnimation { - - private SpriteSheet spriteImage; - private Image[][] sprites; - private int height; - private int width; - private int currentFrame = 1; - private int currentRow = 1; - private int nFrames; - private int nRows; - private int delay = 200; - private int delta = 0; - private boolean looping = true; - private boolean animationRunning = true; - private boolean flipHorizontal = false; - private boolean flipVertical = false; + + private SpriteSheet spriteImage; + private Image[][] sprites; + private int height; + private int width; + private int currentFrame = 1; + private int currentRow = 1; + private int nFrames; + private int nRows; + private int delay = 200; + private int delta = 0; + private boolean looping = true; + private boolean animationRunning = true; + private boolean flipHorizontal = false; + private boolean flipVertical = false; private boolean visible = false; private int offsetX = 0; @@ -37,9 +37,9 @@ public class SpriteAnimation { private float prevScale = 1f; private Image currentImage; - public SpriteAnimation() throws SlickException{ + public SpriteAnimation() throws SlickException{ - } + } /** * Sets spritesheet. @@ -47,7 +47,7 @@ public class SpriteAnimation { * @param imagePath path to the sprite sheet image. * @throws SlickException */ - public void setSpriteImage(String imagePath) throws SlickException { + public void setSpriteImage(String imagePath) throws SlickException { spriteImage = new SpriteSheet(imagePath, this.width, this.height); } @@ -105,23 +105,23 @@ public class SpriteAnimation { visible = false; } - public void update(int delta){ - if (animationRunning){//skip this if animation is stopped - this.delta += delta; - - //check if it's time to advance the frame - if ( this.delta >= ( this.delay ) ){ - //if set to not loop, keep the frame at the last frame - if ( this.currentFrame == this.nFrames && !(this.looping) ){ - this.currentFrame = this.nFrames - 1; - } - - //advance one frame, then reset delta counter - this.currentFrame = (this.currentFrame % this.nFrames) + 1; - this.delta = 0; - } - } - } + public void update(int delta){ + if (animationRunning){//skip this if animation is stopped + this.delta += delta; + + //check if it's time to advance the frame + if ( this.delta >= ( this.delay ) ){ + //if set to not loop, keep the frame at the last frame + if ( this.currentFrame == this.nFrames && !(this.looping) ){ + this.currentFrame = this.nFrames - 1; + } + + //advance one frame, then reset delta counter + this.currentFrame = (this.currentFrame % this.nFrames) + 1; + this.delta = 0; + } + } + } /** * Render to specific coordinates. Will assume bottom-center point as image position. @@ -131,8 +131,8 @@ public class SpriteAnimation { * @param posY bottom-center point * @param scale */ - public void render(Graphics g, float posX, float posY, float scale){ - scale *= Terrarum.game.screenZoom; + public void render(Graphics g, float posX, float posY, float scale){ + scale *= Terrarum.game.getScreenZoom(); // Null checking if (currentImage == null) { @@ -150,93 +150,93 @@ public class SpriteAnimation { flippedImage.startUse(); flippedImage.drawEmbedded( - Math.round(posX * Terrarum.game.screenZoom) - , Math.round(posY * Terrarum.game.screenZoom) + Math.round(posX * Terrarum.game.getScreenZoom()) + , Math.round(posY * Terrarum.game.getScreenZoom()) , FastMath.floor(width * scale) , FastMath.floor(height * scale) ); flippedImage.endUse(); } - } - - public void render(Graphics g, float posX, float posY){ - render(g, posX, posY, 1); } - - public void switchSprite(int newRow){ - currentRow = newRow; - - //if beyond the frame index then reset - if (currentFrame > nFrames){ - reset(); - } - } - - public void switchSprite(int newRow, int newMax){ - if (newMax > 0){ - nFrames = newMax; - } - - currentRow = newRow; - - //if beyond the frame index then reset - if (currentFrame > nFrames){ - reset(); - } - } - - public void switchSpriteDelay(int newDelay){ - if (newDelay > 0){ - delay = newDelay; - } - } - - public void switchSprite(int newRow, int newMax, int newDelay){ - if (newMax > 0){ - nFrames = newMax; - } - - if (newDelay > 0){ - delay = newDelay; - } - - currentRow = newRow; - - //if beyond the frame index then reset - if (currentFrame > nFrames){ - reset(); - } - } - - public void reset(){ - currentFrame = 1; - } - - public void start(){ //starts the animation - animationRunning = true; - } - - public void start(int selectFrame){ //starts the animation - animationRunning = true; - - //optional: seleft the frame no which to start the animation - currentFrame = selectFrame; - } - - public void stop(){ - animationRunning = false; - } - - public void stop(int selectFrame){ - animationRunning = false; - - currentFrame = selectFrame; - } - - public void flip(boolean horizontal, boolean vertical){ - flipHorizontal = horizontal; - flipVertical = vertical; - } + + public void render(Graphics g, float posX, float posY){ + render(g, posX, posY, 1); + } + + public void switchSprite(int newRow){ + currentRow = newRow; + + //if beyond the frame index then reset + if (currentFrame > nFrames){ + reset(); + } + } + + public void switchSprite(int newRow, int newMax){ + if (newMax > 0){ + nFrames = newMax; + } + + currentRow = newRow; + + //if beyond the frame index then reset + if (currentFrame > nFrames){ + reset(); + } + } + + public void switchSpriteDelay(int newDelay){ + if (newDelay > 0){ + delay = newDelay; + } + } + + public void switchSprite(int newRow, int newMax, int newDelay){ + if (newMax > 0){ + nFrames = newMax; + } + + if (newDelay > 0){ + delay = newDelay; + } + + currentRow = newRow; + + //if beyond the frame index then reset + if (currentFrame > nFrames){ + reset(); + } + } + + public void reset(){ + currentFrame = 1; + } + + public void start(){ //starts the animation + animationRunning = true; + } + + public void start(int selectFrame){ //starts the animation + animationRunning = true; + + //optional: seleft the frame no which to start the animation + currentFrame = selectFrame; + } + + public void stop(){ + animationRunning = false; + } + + public void stop(int selectFrame){ + animationRunning = false; + + currentFrame = selectFrame; + } + + public void flip(boolean horizontal, boolean vertical){ + flipHorizontal = horizontal; + flipVertical = vertical; + } public boolean flippedHorizontal() { return flipHorizontal; @@ -246,13 +246,13 @@ public class SpriteAnimation { return flipVertical; } - public int getWidth(){ - return width; - } - - public int getHeight(){ - return height; - } + public int getWidth(){ + return width; + } + + public int getHeight(){ + return height; + } private Image getScaledSprite(float scale) { Image selectedImage = sprites[currentRow - 1][currentFrame - 1]; diff --git a/work_files/DataFormats/Map data format.numbers b/work_files/DataFormats/Map data format.numbers index f623c74f1..006363586 100644 Binary files a/work_files/DataFormats/Map data format.numbers and b/work_files/DataFormats/Map data format.numbers differ diff --git a/work_files/UI_fast_pull_out.gcx b/work_files/UI_fast_pull_out.gcx new file mode 100644 index 000000000..4031173b7 Binary files /dev/null and b/work_files/UI_fast_pull_out.gcx differ diff --git a/work_files/UI_sinusoid.gcx b/work_files/UI_sinusoid.gcx new file mode 100644 index 000000000..25e006636 Binary files /dev/null and b/work_files/UI_sinusoid.gcx differ diff --git a/work_files/sky colour.gcx b/work_files/sky colour.gcx new file mode 100644 index 000000000..ccd026927 Binary files /dev/null and b/work_files/sky colour.gcx differ diff --git a/work_files/sky colour.numbers b/work_files/sky colour.numbers index 12c19978e..a53712c0f 100644 Binary files a/work_files/sky colour.numbers and b/work_files/sky colour.numbers differ