📄 skinromizationtool.java
字号:
}}/** * Integer property */class IntSkinProperty extends SkinPropertyBase { /** * Property's value: integer number */ int value; /** * Constructor * * @param idName name of the property's ID * @param id property's ID * @param value integer value as string */ IntSkinProperty(String idName, String id, String value) { super(idName, id); String v = value; try { this.value = evalValueExpression(v); } catch (Throwable t) { throw new IllegalArgumentException( "Invalid int property value: " + value); } } /** * Tests if two properties have the same value * * @param prop property to compare value with * @return true if properties have the same value */ boolean isEqualValue(SkinPropertyBase prop) { if (!(prop instanceof IntSkinProperty)) { return false; } IntSkinProperty p = (IntSkinProperty)prop; return (p.value == value); } /** * How many entries in values array is required for * storing this property value * * @return number of array entries required for storing * the value of this property */ int getValueOffsetDelta() { // For performance optimization, integers values aren't stored in // separate values array as in case for other properties. So there // is no offset delta for integer value. return 0; } /** * Prints values array entries for this property's value * * @param out where to print entries */ void outputValue(BinaryOutputStreamExt out) throws java.io.IOException { out.writeInt(value); }}/** * Integers sequence property */class IntSeqSkinProperty extends SkinPropertyBase { /** * Propety's value: array of integers */ int[] value; /** * Constructor * * @param idName name of the property's ID * @param id property's ID * @param value comma separated integer values as string */ IntSeqSkinProperty(String idName, String id, String value) { super(idName, id); // find number of integers in sequence int seqLen = 0; char[] chars = value.toCharArray(); int numStart = 0; for (int i = 0; i <= chars.length; ++i) { if (i == chars.length || chars[i] == ',') { seqLen++; numStart = i + 1; } } this.value = new int[seqLen]; // fill values array int idx = 0; numStart = 0; for (int i = 0; i <= chars.length; ++i) { if (i == chars.length || chars[i] == ',') { String v = (value.substring(numStart, i)).trim(); int intVal = 0; try { intVal = evalValueExpression(v); } catch (Throwable t) { throw new IllegalArgumentException( "Invalid integer sequence property value: " + value); } this.value[idx++] = intVal; numStart = i + 1; } } } /** * Tests if two properties have the same value * * @param prop property to compare value with * @return true if properties have the same value */ boolean isEqualValue(SkinPropertyBase prop) { if (!(prop instanceof IntSeqSkinProperty)) { return false; } IntSeqSkinProperty p = (IntSeqSkinProperty)prop; if (p.value.length != value.length) { return false; } for (int i = 0; i < value.length; ++i) { if (p.value[i] != value[i]) { return false; } } return true; } /** * How many entries in values array is required for * storing this property value * * @return number of array entries required for storing * the value of this property */ int getValueOffsetDelta() { // integers sequence value is stored as length of // the sequence followed by sequence integers return (1 + value.length); } /** * Prints values array entries for this property's value * * @param out where to print entries */ void outputValue(BinaryOutputStreamExt out) throws java.io.IOException { // out sequence length out.writeInt(value.length); // out sequence integers for (int i = 0; i < value.length; ++i) { out.writeInt(value[i]); } }}/** * String property */class StringSkinProperty extends SkinPropertyBase { /** * Property's value: string */ String value; /** * Constructor * * @param idName name of the property's ID * @param id property's ID * @param value string value */ StringSkinProperty(String idName, String id, String value) { super(idName, id); this.value = value; } /** * Tests if two properties have the same value * * @param prop property to compare value with * @return true if properties have the same value */ boolean isEqualValue(SkinPropertyBase prop) { if (!(prop instanceof StringSkinProperty)) { return false; } StringSkinProperty p = (StringSkinProperty)prop; return p.value.equals(value); } /** * How many entries in values array is required for * storing this property value * * @return number of array entries required for storing * the value of this property */ int getValueOffsetDelta() { return 1; } /** * Prints values array entries for this property's value * * @param out where to print entries */ void outputValue(BinaryOutputStreamExt out) throws java.io.IOException { out.writeString(value); }}/** * Font property */class FontSkinProperty extends SkinPropertyBase { /** * Property's value: integer font type */ int value; /** * Constructor * * @param idName name of the property's ID * @param id property's ID * @param value integer font ID as string */ FontSkinProperty(String idName, String id, String value) { super(idName, id); String v = value; try { this.value = evalValueExpression(v); } catch (Throwable t) { throw new IllegalArgumentException( "Invalid font property value: " + value); } } /** * Tests if two properties have the same value * * @param prop property to compare value with * @return true if properties have the same value */ boolean isEqualValue(SkinPropertyBase prop) { if (!(prop instanceof FontSkinProperty)) { return false; } FontSkinProperty p = (FontSkinProperty)prop; return (p.value == value); } /** * How many entries in values array is required for * storing this property value * * @return number of array entries required for storing * the value of this property */ int getValueOffsetDelta() { return 1; } /** * Prints values array entries for this property's value * * @param out where to print entries */ void outputValue(BinaryOutputStreamExt out) throws java.io.IOException { out.writeInt(value); }}/** * Image property */class ImageSkinProperty extends SkinPropertyBase { /** * Property's value: image file name without extension */ String value; /** * Romize this image */ boolean isRomized; /** * True, if image value has been specified, * i.e. it is not an empty string */ boolean hasValue; /** total unique images for all properties */ static int totalImages; /** * Constructor * * @param idName name of the property's ID * @param id property's ID * @param value image file name without extension * @param isRomized boolean value as string * @exception IllegalArgumentException if some of parameters * are invalid */ ImageSkinProperty(String idName, String id, String value, String isRomized) throws IllegalArgumentException { super(idName, id); this.value = value; if (isRomized.equals("true")) { this.isRomized = true; } else if (isRomized.equals("false")) { this.isRomized = false; } else { throw new IllegalArgumentException( "Skin property " + '"' + idName + '"' + " has illegal romization value: " + '"' + isRomized + '"'); } hasValue = true; if (value.equals("")) { hasValue = false; } } /** * Tests if two properties have the same value * * @param prop property to compare value with * @return true if properties have the same value */ boolean isEqualValue(SkinPropertyBase prop) { if (!(prop instanceof ImageSkinProperty)) { return false; } ImageSkinProperty p = (ImageSkinProperty)prop; return p.value.equals(value); } /** * How many entries in values array is required for * storing this property value * * @return number of array entries required for storing * the value of this property */ int getValueOffsetDelta() { return 1; } /** * Prints values array entries for this property's value * * @param out where to print entries */ void outputValue(BinaryOutputStreamExt out) throws java.io.IOException { out.writeString(value); }}/** * Composite image property. Composite image is an image that consists * of several pieces, where each piece is some image file. */class CompositeImageSkinProperty extends SkinPropertyBase { /** * Property's value: pieces files names without extension. * File name for each piece is constructed from base prefix by * addition of piece number, i.e. if the prefix is "image" and * number of pieces is 2, then file name for first piece is * "image0" and for the second piece is "image1". */ String[] value; /** * Number of pieces */ int totalPieces; /** * Romize this image */ boolean isRomized; /** * True, if image value has been specified, * i.e. it is not an empty string */ boolean hasValue; /** total unique images for all properties */ static int totalImages; /** * Constructor * * @param idName name of the property's ID * @param id property's ID * @param value base prefix for pieces files names * @param totalPieces number of pieces in composite image * @param isRomized boolean value as string * @exception IllegalArgumentException if some of parameters * are invalid */ CompositeImageSkinProperty(String idName, String id, String value, String totalPieces, String isRomized) throws IllegalArgumentException { super(idName, id); try { this.totalPieces = Integer.parseInt(totalPieces); } catch (NumberFormatException e) { throw new IllegalArgumentException( "Composite image skin property " + '"' + idName + '"' + " has illegal total pieces value: " + '"' + totalPieces + '"'); } this.value = new String[this.totalPieces]; for (int i = 0; i < this.totalPieces; ++i) { String v = ""; if (!value.equals("")) { v = value + i; } this.value[i] = v; } if (isRomized.equals("true")) { this.isRomized = true; } else if (isRomized.equals("false")) { this.isRomized = false; } else { throw new IllegalArgumentException( "Skin property " + '"' + idName + '"' + " has illegal romization value: " + '"' + isRomized + '"'); } hasValue = true; if (value.equals("")) { hasValue = false; } } /** * Tests if two properties have the same value *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -