add new files
This commit is contained in:
parent
4e90a93d68
commit
8038516a66
65 changed files with 7996 additions and 0 deletions
24
java/src/game/util/CharValidator.java
Normal file
24
java/src/game/util/CharValidator.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package game.util;
|
||||
|
||||
public interface CharValidator {
|
||||
boolean valid(char ch);
|
||||
|
||||
default String filter(String str) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int z = 0; z < str.length(); z++) {
|
||||
char ch = str.charAt(z);
|
||||
if(this.valid(ch))
|
||||
sb.append(ch);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
default boolean valid(String str) {
|
||||
for(int z = 0; z < str.length(); z++) {
|
||||
char ch = str.charAt(z);
|
||||
if(!this.valid(ch))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
44
java/src/game/util/DC32.java
Normal file
44
java/src/game/util/DC32.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package game.util;
|
||||
|
||||
public class DC32 {
|
||||
public static final byte[] ASCII = { // 0x1f -> AUX1
|
||||
0, ' ', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'G', // $00, $80
|
||||
'H', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'V', 'W', 'X', 'Z', 0 // $10, $90
|
||||
};
|
||||
|
||||
public static final byte[] AUX1 = { // 0x01 -> lc / UC, 0x1f -> AUX2
|
||||
0, 0, '!', '"', '#', '$', '%', '&', '\'', '*', '+', ',', '-', '.', '/', 'F', // $20, $A0
|
||||
':', '1', 'J', ';', '=', '?', '0', '\\', 'Q', '^', '_', 'U', '|', '~', 'Y', 0 // $30, $B0
|
||||
};
|
||||
|
||||
public static final byte[] AUX2 = { // 0x0f -> [0x10 ~ 0x1f ... 0x0f -> UTF] | [0x01 ~ 0x0e -> AUX3], 0x0c -> STR_WSPC
|
||||
0, 0x01, '(', ')', '<', '>', '@', '[', ']', '`', '{', '}', 0, 0x7f, 0x0a, 0, // $40
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f // $50
|
||||
};
|
||||
|
||||
public static final byte[] AUX3 = { // 0x01 -> SYM_DEMON
|
||||
0, 0, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0 // $60
|
||||
};
|
||||
|
||||
public static final char[] ASCII_TO_DC32 = {
|
||||
0x00, 0x41, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x4e, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x01, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x42, 0x43, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
|
||||
0x36, 0x31, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x30, 0x33, 0x44, 0x34, 0x45, 0x35,
|
||||
0x46, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x2f, 0x0f, 0x10, 0x11, 0x32, 0x12, 0x13, 0x14, 0x15, 0x16,
|
||||
0x17, 0x38, 0x18, 0x19, 0x1a, 0x3b, 0x1b, 0x1c, 0x1d, 0x3e, 0x1e, 0x47, 0x37, 0x48, 0x39, 0x3a,
|
||||
0x49, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0xaf, 0x8f, 0x90, 0x91, 0xb2, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0xb8, 0x98, 0x99, 0x9a, 0xbb, 0x9b, 0x9c, 0x9d, 0xbe, 0x9e, 0x4a, 0x3c, 0x4b, 0x3d, 0x4d
|
||||
};
|
||||
|
||||
public static final byte[] ASCII_TO_DC32S = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0x16, 0x11, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0, 0, 0, 0, 0, 0,
|
||||
0, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x1b, 0x0f, 0x10, 0x11, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
|
||||
0x17, 0x16, 0x18, 0x19, 0x1a, 0x1b, 0x1b, 0x1c, 0x1d, 0x1d, 0x1e, 0, 0, 0, 0, 0,
|
||||
0, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x1b, 0x0f, 0x10, 0x11, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
|
||||
0x17, 0x16, 0x18, 0x19, 0x1a, 0x1b, 0x1b, 0x1c, 0x1d, 0x1d, 0x1e, 0, 0, 0, 0, 0
|
||||
};
|
||||
}
|
5
java/src/game/util/Displayable.java
Normal file
5
java/src/game/util/Displayable.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package game.util;
|
||||
|
||||
public interface Displayable {
|
||||
public String getDisplay();
|
||||
}
|
163
java/src/game/util/ExtMath.java
Executable file
163
java/src/game/util/ExtMath.java
Executable file
|
@ -0,0 +1,163 @@
|
|||
package game.util;
|
||||
|
||||
public abstract class ExtMath {
|
||||
private static final float[] SIN_TABLE = new float[65536];
|
||||
private static final double ATAN_ADD = Double.longBitsToDouble(4805340802404319232L);
|
||||
private static final double[] ATAN_SIN = new double[257];
|
||||
private static final double[] ATAN_COS = new double[257];
|
||||
|
||||
static {
|
||||
for(int z = 0; z < 65536; z++) {
|
||||
SIN_TABLE[z] = (float)Math.sin((double)z * Math.PI * 2.0D / 65536.0D);
|
||||
}
|
||||
for(int z = 0; z < 257; z++) {
|
||||
double a = Math.asin((double)z / 256.0D);
|
||||
ATAN_COS[z] = Math.cos(a);
|
||||
ATAN_SIN[z] = a;
|
||||
}
|
||||
}
|
||||
|
||||
public static float sin(float value) {
|
||||
return SIN_TABLE[(int)(value * 10430.378F) & 65535];
|
||||
}
|
||||
|
||||
public static float cos(float value) {
|
||||
return SIN_TABLE[(int)(value * 10430.378F + 16384.0F) & 65535];
|
||||
}
|
||||
|
||||
public static float sqrtf(float value) {
|
||||
return (float)Math.sqrt((double)value);
|
||||
}
|
||||
|
||||
public static float sqrtd(double value) {
|
||||
return (float)Math.sqrt(value);
|
||||
}
|
||||
|
||||
public static int floorf(float value) {
|
||||
int i = (int)value;
|
||||
return value < (float)i ? i - 1 : i;
|
||||
}
|
||||
|
||||
public static int floord(double value) {
|
||||
int i = (int)value;
|
||||
return value < (double)i ? i - 1 : i;
|
||||
}
|
||||
|
||||
public static float absf(float value) {
|
||||
return value >= 0.0F ? value : -value;
|
||||
}
|
||||
|
||||
public static int absi(int value) {
|
||||
return value >= 0 ? value : -value;
|
||||
}
|
||||
|
||||
public static int ceilf(float value) {
|
||||
int i = (int)value;
|
||||
return value > (float)i ? i + 1 : i;
|
||||
}
|
||||
|
||||
public static int ceild(double value) {
|
||||
int i = (int)value;
|
||||
return value > (double)i ? i + 1 : i;
|
||||
}
|
||||
|
||||
public static int clampi(int num, int min, int max) {
|
||||
return num < min ? min : (num > max ? max : num);
|
||||
}
|
||||
|
||||
public static float clampf(float num, float min, float max) {
|
||||
return num < min ? min : (num > max ? max : num);
|
||||
}
|
||||
|
||||
public static double clampd(double num, double min, double max) {
|
||||
return num < min ? min : (num > max ? max : num);
|
||||
}
|
||||
|
||||
public static float wrapf(float value) {
|
||||
value = value % 360.0F;
|
||||
|
||||
if(value >= 180.0F) {
|
||||
value -= 360.0F;
|
||||
}
|
||||
|
||||
if(value < -180.0F) {
|
||||
value += 360.0F;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static double wrapd(double value) {
|
||||
value = value % 360.0D;
|
||||
|
||||
if(value >= 180.0D) {
|
||||
value -= 360.0D;
|
||||
}
|
||||
|
||||
if(value < -180.0D) {
|
||||
value += 360.0D;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static double atan2(double v1, double v2) {
|
||||
double d0 = v2 * v2 + v1 * v1;
|
||||
|
||||
if(Double.isNaN(d0)) {
|
||||
return Double.NaN;
|
||||
}
|
||||
else {
|
||||
boolean flag = v1 < 0.0D;
|
||||
|
||||
if(flag) {
|
||||
v1 = -v1;
|
||||
}
|
||||
|
||||
boolean flag1 = v2 < 0.0D;
|
||||
|
||||
if(flag1) {
|
||||
v2 = -v2;
|
||||
}
|
||||
|
||||
boolean flag2 = v1 > v2;
|
||||
|
||||
if(flag2) {
|
||||
double d1 = v2;
|
||||
v2 = v1;
|
||||
v1 = d1;
|
||||
}
|
||||
|
||||
double p1 = 0.5D * d0;
|
||||
long li = Double.doubleToRawLongBits(d0);
|
||||
li = 6910469410427058090L - (li >> 1);
|
||||
d0 = Double.longBitsToDouble(li);
|
||||
d0 = d0 * (1.5D - p1 * d0 * d0);
|
||||
|
||||
v2 = v2 * d0;
|
||||
v1 = v1 * d0;
|
||||
double d2 = ATAN_ADD + v1;
|
||||
int i = (int)Double.doubleToRawLongBits(d2);
|
||||
double d3 = ATAN_SIN[i];
|
||||
double d4 = ATAN_COS[i];
|
||||
double d5 = d2 - ATAN_ADD;
|
||||
double d6 = v1 * d4 - v2 * d5;
|
||||
double d7 = (6.0D + d6 * d6) * d6 * 0.16666666666666666D;
|
||||
double d8 = d3 + d7;
|
||||
|
||||
if(flag2) {
|
||||
d8 = (Math.PI / 2D) - d8;
|
||||
}
|
||||
|
||||
if(flag1) {
|
||||
d8 = Math.PI - d8;
|
||||
}
|
||||
|
||||
if(flag) {
|
||||
d8 = -d8;
|
||||
}
|
||||
|
||||
return d8;
|
||||
}
|
||||
}
|
||||
}
|
7
java/src/game/util/FileCallback.java
Normal file
7
java/src/game/util/FileCallback.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
package game.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface FileCallback {
|
||||
void selected(File file);
|
||||
}
|
97
java/src/game/util/FileUtils.java
Normal file
97
java/src/game/util/FileUtils.java
Normal file
|
@ -0,0 +1,97 @@
|
|||
package game.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import game.log.Log;
|
||||
import game.net.util.CharsetUtil;
|
||||
|
||||
public class FileUtils {
|
||||
public static String read(InputStream input) throws IOException {
|
||||
return new String(readBytes(input), CharsetUtil.UTF_8);
|
||||
}
|
||||
|
||||
public static byte[] readBytes(InputStream input) throws IOException {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[4096];
|
||||
long count = 0L;
|
||||
int n;
|
||||
for(boolean u = false; -1 != (n = input.read(buffer)); count += (long)n) {
|
||||
output.write(buffer, 0, n);
|
||||
}
|
||||
return output.toByteArray();
|
||||
}
|
||||
|
||||
public static String read(File file) throws IOException {
|
||||
FileInputStream in = null;
|
||||
String s;
|
||||
try {
|
||||
in = new FileInputStream(file);
|
||||
s = FileUtils.read(in);
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if(in != null)
|
||||
in.close();
|
||||
}
|
||||
catch(IOException e) {
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static void write(File file, String data) throws IOException {
|
||||
FileOutputStream out = null;
|
||||
try {
|
||||
out = new FileOutputStream(file);
|
||||
if(out != null) {
|
||||
out.write(data.getBytes(CharsetUtil.UTF_8));
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if(out != null)
|
||||
out.close();
|
||||
}
|
||||
catch(IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static InputStream getResource(String path) throws FileNotFoundException {
|
||||
InputStream in = FileUtils.class.getResourceAsStream("/" + path);
|
||||
if(in == null)
|
||||
throw new FileNotFoundException(path);
|
||||
return in;
|
||||
}
|
||||
|
||||
public static boolean deleteFiles(File[] files) {
|
||||
if(files == null) {
|
||||
Log.JNI.warn("Konnte Ordner nicht löschen");
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int i = 0; i < files.length; ++i) {
|
||||
File file = files[i];
|
||||
Log.JNI.info("Lösche " + file);
|
||||
|
||||
if(file.isDirectory() && !deleteFiles(file.listFiles())) {
|
||||
Log.JNI.warn("Konnte Ordner " + file + " nicht löschen");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!file.delete()) {
|
||||
Log.JNI.warn("Konnte Datei " + file + " nicht löschen");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
7
java/src/game/util/Formatter.java
Normal file
7
java/src/game/util/Formatter.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
package game.util;
|
||||
|
||||
import game.gui.element.Element;
|
||||
|
||||
public interface Formatter<T extends Element> {
|
||||
String use(T elem);
|
||||
}
|
56
java/src/game/util/PerfSection.java
Normal file
56
java/src/game/util/PerfSection.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package game.util;
|
||||
|
||||
import game.window.WCF;
|
||||
|
||||
public enum PerfSection {
|
||||
TIMING("Timing"),
|
||||
INPUT("Input"),
|
||||
TICK("Tick"),
|
||||
UPDATE("Update"),
|
||||
RENDER("Render"),
|
||||
GUI("Gui"),
|
||||
REST("Rest"),
|
||||
SWAP("Swap"),
|
||||
EVENTS("Events"),
|
||||
WAIT("Wait");
|
||||
|
||||
private static PerfSection section;
|
||||
private static int swap;
|
||||
private static long start;
|
||||
private static long total;
|
||||
|
||||
private final String name;
|
||||
|
||||
private long time;
|
||||
private long[] last = new long[2];
|
||||
|
||||
private PerfSection(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void enter() {
|
||||
this.time = WCF.getTime();
|
||||
if(section != null)
|
||||
section.last[swap] = section.time = this.time - section.time;
|
||||
section = this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public long getLast() {
|
||||
return this.last[swap ^ 1];
|
||||
}
|
||||
|
||||
public static void swap() {
|
||||
long current = WCF.getTime();
|
||||
total = current - start;
|
||||
start = current;
|
||||
swap ^= 1;
|
||||
}
|
||||
|
||||
public static long getTotal(boolean wait) {
|
||||
return total - (wait ? 0L : WAIT.getLast());
|
||||
}
|
||||
}
|
645
java/src/game/util/Predicates.java
Normal file
645
java/src/game/util/Predicates.java
Normal file
|
@ -0,0 +1,645 @@
|
|||
/*
|
||||
* Copyright (C) 2007 The Guava Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package game.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Static utility methods pertaining to {@code Predicate} instances.
|
||||
*
|
||||
* <p>All methods returns serializable predicates as long as they're given
|
||||
* serializable parameters.
|
||||
*
|
||||
* <p>See the Guava User Guide article on <a href=
|
||||
* "http://code.google.com/p/guava-libraries/wiki/FunctionalExplained">the
|
||||
* use of {@code Predicate}</a>.
|
||||
*
|
||||
* @author Kevin Bourrillion
|
||||
* @since 2.0 (imported from Google Collections Library)
|
||||
*/
|
||||
|
||||
public final class Predicates {
|
||||
private Predicates() {}
|
||||
|
||||
// TODO(kevinb): considering having these implement a VisitablePredicate
|
||||
// interface which specifies an accept(PredicateVisitor) method.
|
||||
|
||||
/**
|
||||
* Returns a predicate that always evaluates to {@code true}.
|
||||
*/
|
||||
|
||||
public static <T> Predicate<T> alwaysTrue() {
|
||||
return ObjectPredicate.ALWAYS_TRUE.withNarrowedType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that always evaluates to {@code false}.
|
||||
*/
|
||||
//
|
||||
// public static <T> Predicate<T> alwaysFalse() {
|
||||
// return ObjectPredicate.ALWAYS_FALSE.withNarrowedType();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if the object reference
|
||||
* being tested is null.
|
||||
*/
|
||||
|
||||
public static <T> Predicate<T> isNull() {
|
||||
return ObjectPredicate.IS_NULL.withNarrowedType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if the object reference
|
||||
* being tested is not null.
|
||||
*/
|
||||
|
||||
public static <T> Predicate<T> notNull() {
|
||||
return ObjectPredicate.NOT_NULL.withNarrowedType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if the given predicate
|
||||
* evaluates to {@code false}.
|
||||
*/
|
||||
public static <T> Predicate<T> not(Predicate<T> predicate) {
|
||||
return new NotPredicate<T>(predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if each of its
|
||||
* components evaluates to {@code true}. The components are evaluated in
|
||||
* order, and evaluation will be "short-circuited" as soon as a false
|
||||
* predicate is found. It defensively copies the iterable passed in, so future
|
||||
* changes to it won't alter the behavior of this predicate. If {@code
|
||||
* components} is empty, the returned predicate will always evaluate to {@code
|
||||
* true}.
|
||||
*/
|
||||
// public static <T> Predicate<T> and(
|
||||
// Iterable<? extends Predicate<? super T>> components) {
|
||||
// return new AndPredicate<T>(defensiveCopy(components));
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if each of its
|
||||
* components evaluates to {@code true}. The components are evaluated in
|
||||
* order, and evaluation will be "short-circuited" as soon as a false
|
||||
* predicate is found. It defensively copies the array passed in, so future
|
||||
* changes to it won't alter the behavior of this predicate. If {@code
|
||||
* components} is empty, the returned predicate will always evaluate to {@code
|
||||
* true}.
|
||||
*/
|
||||
public static <T> Predicate<T> and(Predicate<? super T>... components) {
|
||||
return new AndPredicate<T>(defensiveCopy(components));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if both of its
|
||||
* components evaluate to {@code true}. The components are evaluated in
|
||||
* order, and evaluation will be "short-circuited" as soon as a false
|
||||
* predicate is found.
|
||||
*/
|
||||
public static <T> Predicate<T> and(Predicate<? super T> first,
|
||||
Predicate<? super T> second) {
|
||||
return new AndPredicate<T>(Predicates.<T>asList(
|
||||
first, second));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if any one of its
|
||||
* components evaluates to {@code true}. The components are evaluated in
|
||||
* order, and evaluation will be "short-circuited" as soon as a
|
||||
* true predicate is found. It defensively copies the iterable passed in, so
|
||||
* future changes to it won't alter the behavior of this predicate. If {@code
|
||||
* components} is empty, the returned predicate will always evaluate to {@code
|
||||
* false}.
|
||||
*/
|
||||
// public static <T> Predicate<T> or(
|
||||
// Iterable<? extends Predicate<? super T>> components) {
|
||||
// return new OrPredicate<T>(defensiveCopy(components));
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if any one of its
|
||||
* components evaluates to {@code true}. The components are evaluated in
|
||||
* order, and evaluation will be "short-circuited" as soon as a
|
||||
* true predicate is found. It defensively copies the array passed in, so
|
||||
* future changes to it won't alter the behavior of this predicate. If {@code
|
||||
* components} is empty, the returned predicate will always evaluate to {@code
|
||||
* false}.
|
||||
*/
|
||||
// public static <T> Predicate<T> or(Predicate<? super T>... components) {
|
||||
// return new OrPredicate<T>(defensiveCopy(components));
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if either of its
|
||||
* components evaluates to {@code true}. The components are evaluated in
|
||||
* order, and evaluation will be "short-circuited" as soon as a
|
||||
* true predicate is found.
|
||||
*/
|
||||
// public static <T> Predicate<T> or(
|
||||
// Predicate<? super T> first, Predicate<? super T> second) {
|
||||
// return new OrPredicate<T>(Predicates.<T>asList(
|
||||
// checkNotNull(first), checkNotNull(second)));
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if the object being
|
||||
* tested {@code equals()} the given target or both are null.
|
||||
*/
|
||||
public static <T> Predicate<T> equalTo(T target) {
|
||||
return (target == null)
|
||||
? Predicates.<T>isNull()
|
||||
: new IsEqualToPredicate<T>(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if the object being
|
||||
* tested is an instance of the given class. If the object being tested
|
||||
* is {@code null} this predicate evaluates to {@code false}.
|
||||
*
|
||||
* <p>If you want to filter an {@code Iterable} to narrow its type, consider
|
||||
* using {@link com.google.common.collect.Iterables#filter(Iterable, Class)}
|
||||
* in preference.
|
||||
*
|
||||
* <p><b>Warning:</b> contrary to the typical assumptions about predicates (as
|
||||
* documented at {@link Predicate#apply}), the returned predicate may not be
|
||||
* <i>consistent with equals</i>. For example, {@code
|
||||
* instanceOf(ArrayList.class)} will yield different results for the two equal
|
||||
* instances {@code Lists.newArrayList(1)} and {@code Arrays.asList(1)}.
|
||||
*/
|
||||
|
||||
public static Predicate<Object> instanceOf(Class<?> clazz) {
|
||||
return new InstanceOfPredicate(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if the class being
|
||||
* tested is assignable from the given class. The returned predicate
|
||||
* does not allow null inputs.
|
||||
*
|
||||
* @since 10.0
|
||||
*/
|
||||
//
|
||||
// @Beta
|
||||
// public static Predicate<Class<?>> assignableFrom(Class<?> clazz) {
|
||||
// return new AssignableFromPredicate(clazz);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if the object reference
|
||||
* being tested is a member of the given collection. It does not defensively
|
||||
* copy the collection passed in, so future changes to it will alter the
|
||||
* behavior of the predicate.
|
||||
*
|
||||
* <p>This method can technically accept any {@code Collection<?>}, but using
|
||||
* a typed collection helps prevent bugs. This approach doesn't block any
|
||||
* potential users since it is always possible to use {@code
|
||||
* Predicates.<Object>in()}.
|
||||
*
|
||||
* @param target the collection that may contain the function input
|
||||
*/
|
||||
public static <T> Predicate<T> in(Collection<? extends T> target) {
|
||||
return new InPredicate<T>(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the composition of a function and a predicate. For every {@code x},
|
||||
* the generated predicate returns {@code predicate(function(x))}.
|
||||
*
|
||||
* @return the composition of the provided function and predicate
|
||||
*/
|
||||
public static <A, B> Predicate<A> compose(
|
||||
Predicate<B> predicate, Function<A, ? extends B> function) {
|
||||
return new CompositionPredicate<A, B>(predicate, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if the
|
||||
* {@code CharSequence} being tested contains any match for the given
|
||||
* regular expression pattern. The test used is equivalent to
|
||||
* {@code Pattern.compile(pattern).matcher(arg).find()}
|
||||
*
|
||||
* @throws java.util.regex.PatternSyntaxException if the pattern is invalid
|
||||
* @since 3.0
|
||||
*/
|
||||
//
|
||||
// public static Predicate<CharSequence> containsPattern(String pattern) {
|
||||
// return new ContainsPatternFromStringPredicate(pattern);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns a predicate that evaluates to {@code true} if the
|
||||
* {@code CharSequence} being tested contains any match for the given
|
||||
* regular expression pattern. The test used is equivalent to
|
||||
* {@code pattern.matcher(arg).find()}
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
|
||||
// public static Predicate<CharSequence> contains(Pattern pattern) {
|
||||
// return new ContainsPatternPredicate(pattern);
|
||||
// }
|
||||
|
||||
// End public API, begin private implementation classes.
|
||||
|
||||
// Package private for GWT serialization.
|
||||
enum ObjectPredicate implements Predicate<Object> {
|
||||
/** @see Predicates#alwaysTrue() */
|
||||
ALWAYS_TRUE {
|
||||
@Override public boolean test(Object o) {
|
||||
return true;
|
||||
}
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.alwaysTrue()";
|
||||
// }
|
||||
},
|
||||
/** @see Predicates#alwaysFalse() */
|
||||
// ALWAYS_FALSE {
|
||||
// @Override public boolean test(Object o) {
|
||||
// return false;
|
||||
// }
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.alwaysFalse()";
|
||||
// }
|
||||
// },
|
||||
/** @see Predicates#isNull() */
|
||||
IS_NULL {
|
||||
@Override public boolean test(Object o) {
|
||||
return o == null;
|
||||
}
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.isNull()";
|
||||
// }
|
||||
},
|
||||
/** @see Predicates#notNull() */
|
||||
NOT_NULL {
|
||||
@Override public boolean test(Object o) {
|
||||
return o != null;
|
||||
}
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.notNull()";
|
||||
// }
|
||||
};
|
||||
|
||||
// safe contravariant cast
|
||||
<T> Predicate<T> withNarrowedType() {
|
||||
return (Predicate<T>) this;
|
||||
}
|
||||
}
|
||||
|
||||
/** @see Predicates#not(Predicate) */
|
||||
private static class NotPredicate<T> implements Predicate<T>, Serializable {
|
||||
final Predicate<T> predicate;
|
||||
|
||||
NotPredicate(Predicate<T> predicate) {
|
||||
this.predicate = predicate;
|
||||
}
|
||||
@Override
|
||||
public boolean test(T t) {
|
||||
return !predicate.test(t);
|
||||
}
|
||||
// @Override public int hashCode() {
|
||||
// return ~predicate.hashCode();
|
||||
// }
|
||||
// @Override public boolean equals(Object obj) {
|
||||
// if (obj instanceof NotPredicate) {
|
||||
// NotPredicate<?> that = (NotPredicate<?>) obj;
|
||||
// return predicate.equals(that.predicate);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.not(" + predicate.toString() + ")";
|
||||
// }
|
||||
// private static final long serialVersionUID = 0;
|
||||
}
|
||||
|
||||
// private static final Joiner COMMA_JOINER = Joiner.on(',');
|
||||
|
||||
/** @see Predicates#and(Iterable) */
|
||||
private static class AndPredicate<T> implements Predicate<T>, Serializable {
|
||||
private final List<? extends Predicate<? super T>> components;
|
||||
|
||||
private AndPredicate(List<? extends Predicate<? super T>> components) {
|
||||
this.components = components;
|
||||
}
|
||||
@Override
|
||||
public boolean test(T t) {
|
||||
// Avoid using the Iterator to avoid generating garbage (issue 820).
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
if (!components.get(i).test(t)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// @Override public int hashCode() {
|
||||
// // add a random number to avoid collisions with OrPredicate
|
||||
// return components.hashCode() + 0x12472c2c;
|
||||
// }
|
||||
// @Override public boolean equals(Object obj) {
|
||||
// if (obj instanceof AndPredicate) {
|
||||
// AndPredicate<?> that = (AndPredicate<?>) obj;
|
||||
// return components.equals(that.components);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.and(" + COMMA_JOINER.join(components) + ")";
|
||||
// }
|
||||
// private static final long serialVersionUID = 0;
|
||||
}
|
||||
|
||||
/** @see Predicates#or(Iterable) */
|
||||
// private static class OrPredicate<T> implements Predicate<T>, Serializable {
|
||||
// private final List<? extends Predicate<? super T>> components;
|
||||
//
|
||||
// private OrPredicate(List<? extends Predicate<? super T>> components) {
|
||||
// this.components = components;
|
||||
// }
|
||||
// @Override
|
||||
// public boolean test(T t) {
|
||||
// // Avoid using the Iterator to avoid generating garbage (issue 820).
|
||||
// for (int i = 0; i < components.size(); i++) {
|
||||
// if (components.get(i).test(t)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// @Override public int hashCode() {
|
||||
// // add a random number to avoid collisions with AndPredicate
|
||||
// return components.hashCode() + 0x053c91cf;
|
||||
// }
|
||||
// @Override public boolean equals(Object obj) {
|
||||
// if (obj instanceof OrPredicate) {
|
||||
// OrPredicate<?> that = (OrPredicate<?>) obj;
|
||||
// return components.equals(that.components);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.or(" + COMMA_JOINER.join(components) + ")";
|
||||
// }
|
||||
// private static final long serialVersionUID = 0;
|
||||
// }
|
||||
|
||||
/** @see Predicates#equalTo(Object) */
|
||||
private static class IsEqualToPredicate<T>
|
||||
implements Predicate<T>, Serializable {
|
||||
private final T target;
|
||||
|
||||
private IsEqualToPredicate(T target) {
|
||||
this.target = target;
|
||||
}
|
||||
@Override
|
||||
public boolean test(T t) {
|
||||
return target.equals(t);
|
||||
}
|
||||
// @Override public int hashCode() {
|
||||
// return target.hashCode();
|
||||
// }
|
||||
// @Override public boolean equals(Object obj) {
|
||||
// if (obj instanceof IsEqualToPredicate) {
|
||||
// IsEqualToPredicate<?> that = (IsEqualToPredicate<?>) obj;
|
||||
// return target.equals(that.target);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.equalTo(" + target + ")";
|
||||
// }
|
||||
// private static final long serialVersionUID = 0;
|
||||
}
|
||||
|
||||
/** @see Predicates#instanceOf(Class) */
|
||||
|
||||
private static class InstanceOfPredicate
|
||||
implements Predicate<Object>, Serializable {
|
||||
private final Class<?> clazz;
|
||||
|
||||
private InstanceOfPredicate(Class<?> clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
@Override
|
||||
public boolean test(Object o) {
|
||||
return clazz.isInstance(o);
|
||||
}
|
||||
// @Override public int hashCode() {
|
||||
// return clazz.hashCode();
|
||||
// }
|
||||
// @Override public boolean equals(Object obj) {
|
||||
// if (obj instanceof InstanceOfPredicate) {
|
||||
// InstanceOfPredicate that = (InstanceOfPredicate) obj;
|
||||
// return clazz == that.clazz;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.instanceOf(" + clazz.getName() + ")";
|
||||
// }
|
||||
// private static final long serialVersionUID = 0;
|
||||
}
|
||||
|
||||
/** @see Predicates#assignableFrom(Class) */
|
||||
|
||||
// private static class AssignableFromPredicate
|
||||
// implements Predicate<Class<?>>, Serializable {
|
||||
// private final Class<?> clazz;
|
||||
//
|
||||
// private AssignableFromPredicate(Class<?> clazz) {
|
||||
// this.clazz = checkNotNull(clazz);
|
||||
// }
|
||||
// @Override
|
||||
// public boolean test(Class<?> input) {
|
||||
// return clazz.isAssignableFrom(input);
|
||||
// }
|
||||
// @Override public int hashCode() {
|
||||
// return clazz.hashCode();
|
||||
// }
|
||||
// @Override public boolean equals(Object obj) {
|
||||
// if (obj instanceof AssignableFromPredicate) {
|
||||
// AssignableFromPredicate that = (AssignableFromPredicate) obj;
|
||||
// return clazz == that.clazz;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.assignableFrom(" + clazz.getName() + ")";
|
||||
// }
|
||||
// private static final long serialVersionUID = 0;
|
||||
// }
|
||||
|
||||
/** @see Predicates#in(Collection) */
|
||||
private static class InPredicate<T> implements Predicate<T>, Serializable {
|
||||
private final Collection<?> target;
|
||||
|
||||
private InPredicate(Collection<?> target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(T t) {
|
||||
try {
|
||||
return target.contains(t);
|
||||
} catch (NullPointerException e) {
|
||||
return false;
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// @Override public boolean equals(Object obj) {
|
||||
// if (obj instanceof InPredicate) {
|
||||
// InPredicate<?> that = (InPredicate<?>) obj;
|
||||
// return target.equals(that.target);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override public int hashCode() {
|
||||
// return target.hashCode();
|
||||
// }
|
||||
|
||||
// @Override public String toString() {
|
||||
// return "Predicates.in(" + target + ")";
|
||||
// }
|
||||
// private static final long serialVersionUID = 0;
|
||||
}
|
||||
|
||||
/** @see Predicates#compose(Predicate, Function) */
|
||||
private static class CompositionPredicate<A, B>
|
||||
implements Predicate<A>, Serializable {
|
||||
final Predicate<B> p;
|
||||
final Function<A, ? extends B> f;
|
||||
|
||||
private CompositionPredicate(Predicate<B> p, Function<A, ? extends B> f) {
|
||||
this.p = p;
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(A a) {
|
||||
return p.test(f.apply(a));
|
||||
}
|
||||
|
||||
// @Override public boolean equals(Object obj) {
|
||||
// if (obj instanceof CompositionPredicate) {
|
||||
// CompositionPredicate<?, ?> that = (CompositionPredicate<?, ?>) obj;
|
||||
// return f.equals(that.f) && p.equals(that.p);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override public int hashCode() {
|
||||
// return f.hashCode() ^ p.hashCode();
|
||||
// }
|
||||
|
||||
// @Override public String toString() {
|
||||
// return p.toString() + "(" + f.toString() + ")";
|
||||
// }
|
||||
//
|
||||
// private static final long serialVersionUID = 0;
|
||||
}
|
||||
|
||||
/** @see Predicates#contains(Pattern) */
|
||||
|
||||
// private static class ContainsPatternPredicate
|
||||
// implements Predicate<CharSequence>, Serializable {
|
||||
// final Pattern pattern;
|
||||
//
|
||||
// ContainsPatternPredicate(Pattern pattern) {
|
||||
// this.pattern = checkNotNull(pattern);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean test(CharSequence t) {
|
||||
// return pattern.matcher(t).find();
|
||||
// }
|
||||
//
|
||||
// @Override public int hashCode() {
|
||||
// // Pattern uses Object.hashCode, so we have to reach
|
||||
// // inside to build a hashCode consistent with equals.
|
||||
//
|
||||
// return Arrays.hashCode(new Object[] {pattern.pattern(), pattern.flags()});
|
||||
// }
|
||||
//
|
||||
// @Override public boolean equals(Object obj) {
|
||||
// if (obj instanceof ContainsPatternPredicate) {
|
||||
// ContainsPatternPredicate that = (ContainsPatternPredicate) obj;
|
||||
//
|
||||
// // Pattern uses Object (identity) equality, so we have to reach
|
||||
// // inside to compare individual fields.
|
||||
// return Objects.equal(pattern.pattern(), that.pattern.pattern())
|
||||
// && Objects.equal(pattern.flags(), that.pattern.flags());
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//// @Override public String toString() {
|
||||
//// String patternString = Objects.toStringHelper(pattern)
|
||||
//// .add("pattern", pattern.pattern())
|
||||
//// .add("pattern.flags", pattern.flags())
|
||||
//// .toString();
|
||||
//// return "Predicates.contains(" + patternString + ")";
|
||||
//// }
|
||||
//
|
||||
// private static final long serialVersionUID = 0;
|
||||
// }
|
||||
//
|
||||
// /** @see Predicates#containsPattern(String) */
|
||||
//
|
||||
// private static class ContainsPatternFromStringPredicate
|
||||
// extends ContainsPatternPredicate {
|
||||
//
|
||||
// ContainsPatternFromStringPredicate(String string) {
|
||||
// super(Pattern.compile(string));
|
||||
// }
|
||||
//
|
||||
//// @Override public String toString() {
|
||||
//// return "Predicates.containsPattern(" + pattern.pattern() + ")";
|
||||
//// }
|
||||
//
|
||||
// private static final long serialVersionUID = 0;
|
||||
// }
|
||||
|
||||
private static <T> List<Predicate<? super T>> asList(
|
||||
Predicate<? super T> first, Predicate<? super T> second) {
|
||||
// TODO(kevinb): understand why we still get a warning despite @SafeVarargs!
|
||||
return Arrays.<Predicate<? super T>>asList(first, second);
|
||||
}
|
||||
|
||||
private static <T> List<T> defensiveCopy(T... array) {
|
||||
return defensiveCopy(Arrays.asList(array));
|
||||
}
|
||||
|
||||
static <T> List<T> defensiveCopy(Iterable<T> iterable) {
|
||||
ArrayList<T> list = new ArrayList<T>();
|
||||
for (T element : iterable) {
|
||||
list.add(element);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
321
java/src/game/util/SkinConverter.java
Executable file
321
java/src/game/util/SkinConverter.java
Executable file
|
@ -0,0 +1,321 @@
|
|||
package game.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import game.log.Log;
|
||||
|
||||
public abstract class SkinConverter {
|
||||
private static BufferedImage convertSkin(BufferedImage image) {
|
||||
BufferedImage img = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics graphics = img.getGraphics();
|
||||
graphics.drawImage(image, 0, 0, null);
|
||||
graphics.drawImage(img, 24, 48, 20, 52, 4, 16, 8, 20, null);
|
||||
graphics.drawImage(img, 28, 48, 24, 52, 8, 16, 12, 20, null);
|
||||
graphics.drawImage(img, 20, 52, 16, 64, 8, 20, 12, 32, null);
|
||||
graphics.drawImage(img, 24, 52, 20, 64, 4, 20, 8, 32, null);
|
||||
graphics.drawImage(img, 28, 52, 24, 64, 0, 20, 4, 32, null);
|
||||
graphics.drawImage(img, 32, 52, 28, 64, 12, 20, 16, 32, null);
|
||||
graphics.drawImage(img, 40, 48, 36, 52, 44, 16, 48, 20, null);
|
||||
graphics.drawImage(img, 44, 48, 40, 52, 48, 16, 52, 20, null);
|
||||
graphics.drawImage(img, 36, 52, 32, 64, 48, 20, 52, 32, null);
|
||||
graphics.drawImage(img, 40, 52, 36, 64, 44, 20, 48, 32, null);
|
||||
graphics.drawImage(img, 44, 52, 40, 64, 40, 20, 44, 32, null);
|
||||
graphics.drawImage(img, 48, 52, 44, 64, 52, 20, 56, 32, null);
|
||||
graphics.dispose();
|
||||
return img;
|
||||
}
|
||||
|
||||
private static BufferedImage convertSlim(BufferedImage image) {
|
||||
BufferedImage img = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D graphics = img.createGraphics();
|
||||
graphics.drawImage(image, 0, 0, null);
|
||||
graphics.setBackground(new Color(0xffffffff, true));
|
||||
graphics.clearRect(47, 16, 9, 16);
|
||||
graphics.clearRect(37, 48, 11, 16);
|
||||
graphics.setBackground(new Color(0x00000000, true));
|
||||
graphics.clearRect(47, 32, 9, 16);
|
||||
graphics.clearRect(53, 48, 11, 16);
|
||||
|
||||
graphics.drawImage(image, 47, 16, 48, 20, 46, 16, 47, 20, null); //
|
||||
graphics.drawImage(image, 48, 16, 51, 20, 47, 16, 50, 20, null);
|
||||
graphics.drawImage(image, 51, 16, 52, 20, 49, 16, 50, 20, null); //
|
||||
graphics.drawImage(image, 47, 20, 48, 32, 46, 20, 47, 32, null); //
|
||||
graphics.drawImage(image, 48, 20, 52, 32, 47, 20, 51, 32, null);
|
||||
graphics.drawImage(image, 53, 20, 56, 32, 51, 20, 54, 32, null);
|
||||
graphics.drawImage(image, 52, 20, 53, 32, 51, 20, 52, 32, null); //
|
||||
|
||||
graphics.drawImage(image, 47, 32, 48, 36, 46, 32, 47, 36, null); //
|
||||
graphics.drawImage(image, 48, 32, 51, 36, 47, 32, 50, 36, null);
|
||||
graphics.drawImage(image, 51, 32, 52, 36, 49, 32, 50, 36, null); //
|
||||
graphics.drawImage(image, 47, 36, 48, 48, 46, 36, 47, 48, null); //
|
||||
graphics.drawImage(image, 48, 36, 52, 48, 47, 36, 51, 48, null);
|
||||
graphics.drawImage(image, 53, 36, 56, 48, 51, 36, 54, 48, null);
|
||||
graphics.drawImage(image, 52, 36, 53, 48, 51, 36, 52, 48, null); //
|
||||
|
||||
graphics.drawImage(image, 37, 48, 40, 52, 36, 48, 39, 52, null);
|
||||
graphics.drawImage(image, 41, 48, 44, 52, 39, 48, 42, 52, null);
|
||||
graphics.drawImage(image, 40, 48, 41, 52, 39, 48, 40, 52, null); //
|
||||
graphics.drawImage(image, 37, 52, 40, 64, 36, 52, 39, 64, null);
|
||||
graphics.drawImage(image, 40, 52, 44, 64, 39, 52, 43, 64, null);
|
||||
graphics.drawImage(image, 44, 52, 47, 64, 43, 52, 46, 64, null);
|
||||
graphics.drawImage(image, 47, 52, 48, 64, 45, 52, 46, 64, null); //
|
||||
|
||||
graphics.drawImage(image, 53, 48, 56, 52, 52, 48, 55, 52, null);
|
||||
graphics.drawImage(image, 57, 48, 60, 52, 55, 48, 58, 52, null);
|
||||
graphics.drawImage(image, 56, 48, 57, 52, 55, 48, 56, 52, null); //
|
||||
graphics.drawImage(image, 53, 52, 56, 64, 52, 52, 55, 64, null);
|
||||
graphics.drawImage(image, 56, 52, 60, 64, 55, 52, 59, 64, null);
|
||||
graphics.drawImage(image, 60, 52, 63, 64, 59, 52, 62, 64, null);
|
||||
graphics.drawImage(image, 63, 52, 64, 64, 61, 52, 62, 64, null); //
|
||||
|
||||
graphics.dispose();
|
||||
return img;
|
||||
}
|
||||
|
||||
private static void copyData(int[] img1, int[] img2, int xo, int yo, int w, int h, boolean blank, boolean alpha) {
|
||||
for(int y = yo; y < h+yo; y++) {
|
||||
for(int x = xo; x < w+xo; x++) {
|
||||
img2[y*64+x] = blank ? 0x00000000 : (img1[y*64+x] | (alpha ? 0x00000000 : 0xff000000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyData(int[] img1, int[] img2, int xo, int yo, int w, int h, int xd, int yd) {
|
||||
for(int y = 0; y < h; y++) {
|
||||
for(int x = 0; x < w; x++) {
|
||||
img2[(yd+y)*64+xd+x] = img1[(yo+y)*64+xo+x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int[] filterImage(int[] img1, int[] img2) {
|
||||
copyData(img1, img2, 0, 0, 8, 8, true, true);
|
||||
copyData(img1, img2, 8, 0, 16, 8, false, false);
|
||||
copyData(img1, img2, 24, 0, 8, 8, true, true);
|
||||
copyData(img1, img2, 0, 8, 32, 8, false, false);
|
||||
copyData(img1, img2, 32, 0, 8, 8, true, true);
|
||||
copyData(img1, img2, 40, 0, 16, 8, false, true);
|
||||
copyData(img1, img2, 56, 0, 8, 8, true, true);
|
||||
copyData(img1, img2, 32, 8, 32, 8, false, true);
|
||||
|
||||
copyData(img1, img2, 0, 16, 4, 4, true, true);
|
||||
copyData(img1, img2, 4, 16, 8, 4, false, false);
|
||||
copyData(img1, img2, 12, 16, 8, 4, true, true);
|
||||
copyData(img1, img2, 20, 16, 16, 4, false, false);
|
||||
copyData(img1, img2, 36, 16, 8, 4, true, true);
|
||||
copyData(img1, img2, 44, 16, 8, 4, false, false);
|
||||
copyData(img1, img2, 52, 16, 4, 4, true, true);
|
||||
copyData(img1, img2, 0, 20, 56, 12, false, false);
|
||||
copyData(img1, img2, 56, 16, 8, 32, true, true);
|
||||
|
||||
copyData(img1, img2, 0, 32, 4, 4, true, true);
|
||||
copyData(img1, img2, 4, 32, 8, 4, false, true);
|
||||
copyData(img1, img2, 12, 32, 8, 4, true, true);
|
||||
copyData(img1, img2, 20, 32, 16, 4, false, true);
|
||||
copyData(img1, img2, 36, 32, 8, 4, true, true);
|
||||
copyData(img1, img2, 44, 32, 8, 4, false, true);
|
||||
copyData(img1, img2, 52, 32, 4, 4, true, true);
|
||||
copyData(img1, img2, 0, 36, 56, 12, false, true);
|
||||
|
||||
copyData(img1, img2, 0, 48, 4, 4, true, true);
|
||||
copyData(img1, img2, 4, 48, 8, 4, false, true);
|
||||
copyData(img1, img2, 12, 48, 4, 4, true, true);
|
||||
copyData(img1, img2, 0, 52, 16, 12, false, true);
|
||||
copyData(img1, img2, 16, 48, 4, 4, true, true);
|
||||
copyData(img1, img2, 20, 48, 8, 4, false, false);
|
||||
copyData(img1, img2, 28, 48, 8, 4, true, true);
|
||||
copyData(img1, img2, 36, 48, 8, 4, false, false);
|
||||
copyData(img1, img2, 44, 48, 4, 4, true, true);
|
||||
copyData(img1, img2, 16, 52, 32, 12, false, false);
|
||||
copyData(img1, img2, 48, 48, 4, 4, true, true);
|
||||
copyData(img1, img2, 52, 48, 8, 4, false, true);
|
||||
copyData(img1, img2, 60, 48, 4, 4, true, true);
|
||||
copyData(img1, img2, 48, 52, 16, 12, false, true);
|
||||
|
||||
return img2;
|
||||
}
|
||||
|
||||
private static void relocateIntermediary(int[] img1, int[] img2) {
|
||||
copyData(img1, img2, 0, 0, 64, 64, 0, 0);
|
||||
|
||||
copyData(img1, img2, 4, 16, 8, 4, 20, 48);
|
||||
copyData(img1, img2, 44, 16, 8, 4, 4, 16);
|
||||
copyData(img1, img2, 0, 20, 16, 12, 16, 52);
|
||||
copyData(img1, img2, 40, 20, 16, 12, 0, 20);
|
||||
|
||||
copyData(img1, img2, 4, 32, 8, 4, 4, 48);
|
||||
copyData(img1, img2, 44, 32, 8, 4, 4, 32);
|
||||
copyData(img1, img2, 0, 36, 16, 12, 0, 52);
|
||||
copyData(img1, img2, 40, 36, 16, 12, 0, 36);
|
||||
|
||||
copyData(img1, img2, 4, 48, 8, 4, 52, 48);
|
||||
copyData(img1, img2, 20, 48, 8, 4, 36, 48);
|
||||
copyData(img1, img2, 36, 48, 8, 4, 44, 16);
|
||||
copyData(img1, img2, 52, 48, 8, 4, 44, 32);
|
||||
copyData(img1, img2, 0, 52, 16, 12, 48, 52);
|
||||
copyData(img1, img2, 16, 52, 16, 12, 32, 52);
|
||||
copyData(img1, img2, 32, 52, 16, 12, 40, 20);
|
||||
copyData(img1, img2, 48, 52, 16, 12, 40, 36);
|
||||
}
|
||||
|
||||
public static boolean convertSkin(File source, File dir, boolean slim) {
|
||||
BufferedImage img;
|
||||
try {
|
||||
img = ImageIO.read(source);
|
||||
}
|
||||
catch(IOException e) {
|
||||
Log.JNI.error(e, "Konnte kein Bild von " + source + " laden");
|
||||
return false;
|
||||
}
|
||||
if(img == null) {
|
||||
Log.JNI.warn("Konnte kein Bild von " + source + " laden");
|
||||
return false;
|
||||
}
|
||||
Log.JNI.info("Bild von " + source + " geladen");
|
||||
if(img.getWidth() == 64 && img.getHeight() == 32) {
|
||||
img = convertSkin(img);
|
||||
Log.JNI.info("Skin " + source + " konvertiert");
|
||||
}
|
||||
else if(img.getWidth() != 64 || img.getHeight() != 64) {
|
||||
Log.JNI.warn("Falsche Bildgröße von " + source + ": " + img.getWidth() + "x" + img.getHeight());
|
||||
return false;
|
||||
}
|
||||
String name = source.getName();
|
||||
int ext = name.lastIndexOf('.');
|
||||
if(ext >= 0)
|
||||
name = name.substring(0, ext);
|
||||
if(name.isEmpty())
|
||||
name = "skin";
|
||||
if(slim) {
|
||||
img = convertSlim(img);
|
||||
Log.JNI.info("Skin " + source + " von 'Slim' konvertiert");
|
||||
if(!name.startsWith("slim_"))
|
||||
name = "slim_" + name;
|
||||
}
|
||||
File file = new File(dir, name + ".png");
|
||||
int z = 1;
|
||||
while(file.exists()) {
|
||||
file = new File(dir, name + "_" + (++z) + ".png");
|
||||
}
|
||||
// Graphics2D g = img.createGraphics();
|
||||
// g.setBackground(new Color(0x7fff00ff, true));
|
||||
// g.clearRect(0, 0, 64, 64);
|
||||
int[] data = img.getRGB(0, 0, 64, 64, new int[64*64], 0, 64);
|
||||
int[] data2 = new int[data.length];
|
||||
relocateIntermediary(data, data2);
|
||||
data = data2;
|
||||
filterImage(data, data);
|
||||
img.setRGB(0, 0, 64, 64, data, 0, 64);
|
||||
try {
|
||||
ImageIO.write(img, "png", file);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.JNI.error(e, "Konnte Bild nicht speichern");
|
||||
return false;
|
||||
}
|
||||
Log.JNI.info("Skin " + source + " gespeichert als " + file.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// if(args.length < 1) {
|
||||
// System.err.println("Verwendung: SkinConverter [-s | -n | -i] <Skin-Datei | Ordner ...>");
|
||||
// System.exit(1);
|
||||
// }
|
||||
// int n = 0;
|
||||
// boolean slim = false;
|
||||
//// boolean intermediary = false;
|
||||
// for(String file : args) {
|
||||
// if(file.equals("-s")) {
|
||||
// slim = true;
|
||||
// continue;
|
||||
// }
|
||||
//// else if(file.equals("-i")) {
|
||||
//// intermediary = true;
|
||||
//// continue;
|
||||
//// }
|
||||
// else if(file.equals("-n")) {
|
||||
// slim = false;
|
||||
//// intermediary = false;
|
||||
// continue;
|
||||
// }
|
||||
// else if(new File(file).isDirectory()) {
|
||||
// String[] files = new File(file).list();
|
||||
// if(files != null && files.length > 0) {
|
||||
// for(int z = 0; z < files.length; z++) {
|
||||
// files[z] = file + File.separator + files[z];
|
||||
// }
|
||||
// if(slim) { // || intermediary) {
|
||||
// String[] files2 = new String[files.length + /* (slim && intermediary ? 2 : */ 1]; // )];
|
||||
// int pos = 0;
|
||||
// if(slim)
|
||||
// files2[pos++] = "-s";
|
||||
//// if(intermediary)
|
||||
//// files2[pos++] = "-i";
|
||||
// System.arraycopy(files, 0, files2, pos, files.length);
|
||||
// files = files2;
|
||||
// }
|
||||
// main(files);
|
||||
// }
|
||||
// continue;
|
||||
// }
|
||||
// else if(file.endsWith("-converted.png"))
|
||||
// continue;
|
||||
// String out = (file.endsWith(".png") ? file.substring(0, file.length() - 4) : file) + "-converted.png";
|
||||
// BufferedImage img;
|
||||
// try {
|
||||
// img = ImageIO.read(new File(file));
|
||||
// }
|
||||
// catch(Exception e) {
|
||||
// System.err.println("Konnte Bild '" + file + "' nicht laden");
|
||||
// e.printStackTrace();
|
||||
// continue;
|
||||
// }
|
||||
// if(img == null) {
|
||||
// System.err.println("Konnte Bild '" + file + "' nicht öffnen");
|
||||
// continue;
|
||||
// }
|
||||
// if(img.getWidth() == 64 && img.getHeight() == 32) {
|
||||
// img = convertSkin(img);
|
||||
// System.out.println("Skin '" + file + "' von 64x32 nach 64x64 konvertiert");
|
||||
// }
|
||||
// else if(img.getWidth() != 64 || img.getHeight() != 64) {
|
||||
// System.err.println("Falsche Bildgröße für '" + file + "': " + img.getWidth() + "x" + img.getHeight());
|
||||
// continue;
|
||||
// }
|
||||
// if(slim) {
|
||||
// img = convertSlim(img);
|
||||
// System.out.println("Skin '" + file + "' von 'Slim' nach 64x64/'Schlank' konvertiert");
|
||||
// }
|
||||
// int[] data = img.getRGB(0, 0, 64, 64, new int[64*64], 0, 64);
|
||||
//// if(intermediary) {
|
||||
// int[] data2 = new int[data.length];
|
||||
// relocateIntermediary(data, data2);
|
||||
// data = data2;
|
||||
//// }
|
||||
//// else {
|
||||
// filterImage(data, data);
|
||||
//// }
|
||||
// img.setRGB(0, 0, 64, 64, data, 0, 64);
|
||||
// try {
|
||||
// ImageIO.write(img, "png", new File(out));
|
||||
// }
|
||||
// catch(Exception e) {
|
||||
// System.err.println("Konnte Bild '" + out + "' nicht speichern");
|
||||
// e.printStackTrace();
|
||||
// continue;
|
||||
// }
|
||||
// System.out.println("Skin von '" + file + "' nach '" + out + "' konvertiert");
|
||||
// n++;
|
||||
// }
|
||||
// if(n > 0)
|
||||
// System.out.println(n + " Skins wurden konvertiert");
|
||||
// }
|
||||
}
|
414
java/src/game/util/Splashes.java
Normal file
414
java/src/game/util/Splashes.java
Normal file
|
@ -0,0 +1,414 @@
|
|||
package game.util;
|
||||
|
||||
public abstract class Splashes {
|
||||
public static final String[] SPLASHES = {
|
||||
"Aus der TV-Werbung!",
|
||||
"Toll!",
|
||||
"0% pur!",
|
||||
"Kann Nüsse enthalten!",
|
||||
"Besser als Crysis!",
|
||||
"Mehr Polygone!",
|
||||
"Sexy!",
|
||||
"Limitierte Edition!",
|
||||
"Blinkende Buchstaben!",
|
||||
"Erstellt von Notch!",
|
||||
"Es ist hier!",
|
||||
"Das Beste seiner Klasse!",
|
||||
"Es ist vollendet!",
|
||||
"Mehr oder weniger frei von Drachen!",
|
||||
"Aufregung!",
|
||||
"Weniger als -5 verkauft!",
|
||||
"Einzigartig!",
|
||||
"Einen Haufen Scheiße auf YouTube!",
|
||||
"Indev!",
|
||||
"Spinnen überall!",
|
||||
"Schau es dir an!",
|
||||
"Heilige Kuh, mann!",
|
||||
"Es ist ein Spiel!",
|
||||
"Hergestellt in Schweden!",
|
||||
"Benutzt LWJGL!",
|
||||
"Retikulierende Splinen!",
|
||||
"Meine Kraft!",
|
||||
"Hurraaa!",
|
||||
"Einzelspieler!",
|
||||
"Tastatur ist kompatibel!",
|
||||
"Undokumentiert!",
|
||||
"Barren!",
|
||||
"Explodierende Sonnen!",
|
||||
"Das ist ein Mond!",
|
||||
"l33t!",
|
||||
"Erschaffe!",
|
||||
"Überlebe!",
|
||||
"Verlies!",
|
||||
"Exklusiv!",
|
||||
"Die Knie der Biene!",
|
||||
"Weg mit O.P.P.!",
|
||||
"Mit Quellcode (mehr oder weniger)!",
|
||||
"Mit Klasse(n)!",
|
||||
"Wow!",
|
||||
"Immer noch nicht auf Steam - und das ist auch gut so!",
|
||||
"Oh, mann!",
|
||||
"Grauenvolle Community!",
|
||||
"Pixel!",
|
||||
"Teetsuuuuoooo!",
|
||||
"Kaaneeeedaaaa!",
|
||||
"Jetzt ohne Schwierigkeit!",
|
||||
"Verbessert!",
|
||||
"9% frei von Bugs!",
|
||||
"Schön!",
|
||||
"13 Kräuter und Gewürze!",
|
||||
"Fettfrei!",
|
||||
"Absolut keine Memes!",
|
||||
"Kostenlose Zähne!",
|
||||
"Fragen Sie Ihnen Arzt oder Apotheker!",
|
||||
"Alle Bergleute sind willkommen!",
|
||||
"Cloud-Computing!",
|
||||
"Legal in Finnland!",
|
||||
"Schwer zu beschreiben!",
|
||||
"Technisch gesehen gut!",
|
||||
"Bringe den Speck nach Hause!",
|
||||
"Indie!",
|
||||
"GOTY!",
|
||||
"Ceci n'est pas une title screen!",
|
||||
"Euklidisch!",
|
||||
"Jetzt in 3D!",
|
||||
"Bietet Inspiration!",
|
||||
"Herregud!",
|
||||
"Komplexe Zellvorgänge!",
|
||||
"Ja, Sir!",
|
||||
"Von Cowboys gespielt!",
|
||||
"OpenGL 1.5 oder höher!",
|
||||
"Tausende von Farben!",
|
||||
"Probiere es!",
|
||||
"Age of Wonders ist besser!",
|
||||
"Probiere die Pilzsuppe!",
|
||||
"Sensationell!",
|
||||
"Heiße Tamale, heiße heiße Tamale!",
|
||||
"Spiele ihn runter, Klavierkatze!",
|
||||
"Garantiert!",
|
||||
"Makroskopisch!",
|
||||
"Dann komm doch her!",
|
||||
"Zufälliger Text!",
|
||||
"Ruf deine Mutter an!",
|
||||
"Monster-Streitigkeiten!",
|
||||
"Von Melonen geliebt!",
|
||||
"Ultimative Edition!",
|
||||
"Merkwürdig!",
|
||||
"Du hast einen nagelneuen Schlüssel bekommen!",
|
||||
"Wasserfest!",
|
||||
"Nicht brennbar!",
|
||||
"Oha, du!",
|
||||
"Alles inklusive!",
|
||||
"Sag es deinen Freunden!",
|
||||
"NP ist nicht in P!",
|
||||
"Musik von C418 (DLC)!",
|
||||
"Viel zu oft live gestreamt!",
|
||||
"Heimgesucht!",
|
||||
"Polynomial!",
|
||||
"Terrestrisch!",
|
||||
"Alles ist voller Zerstörung!",
|
||||
"Voll mit Sternen, Planeten und Monden!",
|
||||
"Wissenschaftlich!",
|
||||
"Nicht so cool wie Spock!",
|
||||
"Trage nix bei und höre weg!",
|
||||
"Grabe niemals nach unten, wenn du keine Erze brauchst!",
|
||||
"Mache nie Pause!",
|
||||
"Nicht linear!",
|
||||
"Han hat zuerst geschossen!",
|
||||
"Schön dich zu sehen!",
|
||||
"Eimer mit Lava!",
|
||||
"Reite auf dem Schwein!",
|
||||
"Größer als die Erde!",
|
||||
"sqrt(-1)ch liebe dich!",
|
||||
"Phobos-Anomalie!",
|
||||
"Holz schlagen!",
|
||||
"Von Klippen fallen!",
|
||||
"0% Zucker!",
|
||||
"150% hyperbol!",
|
||||
"Synecdoche!",
|
||||
"Lasst uns tanzne!",
|
||||
"Geheeimes Freitags-Update!",
|
||||
"Referenz-Implementation!",
|
||||
"Frei mit zwei.. äähhh fünf Typen mit Essen!",
|
||||
"Küsse den Himmel!",
|
||||
"20 GOTO 10!",
|
||||
"Verlet-Intregration!",
|
||||
"Peter Griffin!",
|
||||
"Verteile die Erde gut!",
|
||||
"Cogito ergo sum!",
|
||||
"4815162342 Zeilen Quellcode (287228 am 30.7.)!",
|
||||
"Ein Skelett fiel heraus!",
|
||||
"Das Werk von Notch!",
|
||||
"Die Summe seiner Teile!",
|
||||
"BTAF war mal gut!",
|
||||
"Ich vermisse ADOM!",
|
||||
"umop-apisdn!",
|
||||
"GTX750Ti!",
|
||||
"Bringe mir Mentos und Cola!",
|
||||
"Finger-leckend!",
|
||||
"Thematisch!",
|
||||
"Pneumatisch!",
|
||||
"Erhaben!",
|
||||
"Achteckig!",
|
||||
"Une baguette!",
|
||||
"Gargamel spielt es!",
|
||||
"Rita ist der neue beste Hund!",
|
||||
"SWM für immer!",
|
||||
"Repräsentiert Edsbyn!",
|
||||
"Matt Damon!",
|
||||
"Supercalifragilisticexpialidocious!",
|
||||
"Vollende V's!",
|
||||
"Kuh-Werkzeuge!",
|
||||
"Doppelt gepuffert!",
|
||||
"Fan-Fiction!",
|
||||
"Flaxkikare!",
|
||||
"Jason! Jason! Jason!",
|
||||
"Heißer als die Sonne!",
|
||||
"Internet-Funktionalität!",
|
||||
"Autonom!",
|
||||
"Engagiere!",
|
||||
"Fantasie!",
|
||||
"DRR! DRR! DRR!",
|
||||
"Stoß es Wurzel runter!",
|
||||
"Regionale Ressourcen!",
|
||||
"Jaa, facepunch!",
|
||||
"Jaa, somethingawful!",
|
||||
"Jaa, /v/!",
|
||||
"Jaa, tigsource!",
|
||||
"Jaa, weinkraftforum!",
|
||||
"Jaa, worldofweinkraft!",
|
||||
"Buu, reddit!",
|
||||
"Jaa, 2pp!",
|
||||
"Goggle anllyticsed:DD :DDD:D!",
|
||||
"Unterstützt jetzt äöü!",
|
||||
"Gebt uns Gordon!",
|
||||
"Gib deinem Kellner Trinkgeld!",
|
||||
"Macht viel Spaß!",
|
||||
"12345 ist ein schlechtes Passwort!",
|
||||
"Stimme für Netz-Neutralität!",
|
||||
"Lebt in einer Ananas unter dem Meer!",
|
||||
"MAP11 hat zwei Namen!",
|
||||
"Allmächtig!",
|
||||
"Huch!",
|
||||
"...!",
|
||||
"Bienen, Bienen, Bienen, Bienen!",
|
||||
"Jag känner en bot!",
|
||||
"Dieser Text ist schwer bei der Standard-Auflösung zu lesen, aber auf 1080p ist es in Ordnung!",
|
||||
"Haha, LOL!",
|
||||
"Hampsterdance!",
|
||||
"Schalter und Erze!",
|
||||
"Menger-Schwamm!",
|
||||
"idspispopd!",
|
||||
"Eple (originale Version)!",
|
||||
"So frisch, so sauber!",
|
||||
"Schnell reagierende Portale!",
|
||||
"Probiere den Warp aus!",
|
||||
"Schaue nicht direkt auf die Bugs!",
|
||||
"Oh, ok, NPCs!",
|
||||
"Endlich mit Leitern!",
|
||||
"Gruselig!",
|
||||
"Spiele Minenkraft, schaue Topgear, bekomme Schwein!",
|
||||
"Darüber gewittert!",
|
||||
"Spring hoch, spring hoch, und komme runter!",
|
||||
"Joel ist klasse!",
|
||||
"Ein Rätsel, in einen Mythos verwoben!",
|
||||
"Riesige Landeszüge voll mit TNT!",
|
||||
"Willkommen zu deinem Ende! Muahahahahahaha!",
|
||||
"Bleib ein Bisschen, bleib für immer!",
|
||||
"Bleib ein Bisschen und höre zu!",
|
||||
"Behandlung für Ihren Hautausschlag!",
|
||||
"\"Autologisch\" ist!",
|
||||
"Informationen wollen frei sein!",
|
||||
"\"Fast nie\" ist ein interessantes Konzept!",
|
||||
"Eine Menge Wahrheitigkeit!",
|
||||
"Der TNT-Block ist ein Spion!",
|
||||
"Turing-vollständig!",
|
||||
"Es ist bahnbrechend!",
|
||||
"Lasst unsere Schlachten beginnen!",
|
||||
"Der Himmel ist die Grenze - oder auch nicht!",
|
||||
"Jeb hat tolle Haare!",
|
||||
"Ryan hat auch tolle Haare!",
|
||||
"Gelegentliches Spielen!",
|
||||
"Unbesiegt!",
|
||||
"Ein Bisschen wie Lemmings!",
|
||||
"Folge dem Zug, CJ!",
|
||||
"Macht von Synergie Verwendung!",
|
||||
"Diese Nachricht wird niemals als Splash-Text erscheinen, ist das nicht komisch?",
|
||||
"DungeonQuest ist unfair!",
|
||||
"0815!",
|
||||
"666!",
|
||||
"Geh zu den fernen Ländern und weiter!",
|
||||
"Tyrion würde es lieben!",
|
||||
"Probiere auch Stellaris!",
|
||||
"Probiere auch Garry's Mod!",
|
||||
"Probiere auch GZDoom!",
|
||||
"Probiere auch OpenTTD!",
|
||||
"Probiere auch Kaffee!",
|
||||
"Probiere auch Vodka!",
|
||||
"Probiere auch Tee!",
|
||||
"Probiere auch Wasser!",
|
||||
"Probiere auch Saft!",
|
||||
"Das ist super!",
|
||||
"Brot ist Schmerz!",
|
||||
"Lese mehr Bücher!",
|
||||
"Khaaaaaaaaan!",
|
||||
"Weniger süchtig machend als TV Tropes!",
|
||||
"Mehr süchtig machend als Limonade!",
|
||||
"Größer als eine Brotkiste!",
|
||||
"Millionen von Pfirsichen!",
|
||||
"Fnord!",
|
||||
"Dies ist meine echte Gestalt! Muahahahaha!",
|
||||
"Habe Dre vollkommen vergessen!",
|
||||
"Verschwende keine Zeit mit den Klonen!",
|
||||
"Kürbiskopf!",
|
||||
"Hobo humping slobo babe!",
|
||||
"Erstellt von Jeb!",
|
||||
"Hat kein Ende!",
|
||||
"Endlich vollständig!",
|
||||
"Voll mit Features!",
|
||||
"Stiefel mit dem Fell!",
|
||||
"Stop, hammertime!",
|
||||
"Testificates!",
|
||||
"Nicht konventionell!",
|
||||
"Homeomorphisch zu einer 3-Kugel!",
|
||||
"Vermeidet nicht doppelte Verneinung!",
|
||||
"Platziere ALL die Blöcke!",
|
||||
"Macht Walzen!",
|
||||
"Erfüllt Erwartungen!",
|
||||
"Spielen am PC seit 1873!",
|
||||
"Ghoughpteighbteau tchoghs!",
|
||||
"Déjà vu!",
|
||||
"Déjà vu!",
|
||||
"Hab deine Nase!",
|
||||
"Haley liebt Elan!",
|
||||
"Hat keine Angst vor der großen, schwarzen Fledermaus!",
|
||||
"Benutzt nicht das U-Wort!",
|
||||
"Nicht wirklich leicht!",
|
||||
"Bis nächsten Freitag oder so!",
|
||||
"Von den Straßen von Södermalm!",
|
||||
"150 BPM für 400000 Minuten!",
|
||||
"Technologisch!",
|
||||
"Funk Soul Bruder!",
|
||||
"Pumpa kungen!",
|
||||
"Hallo Japan!",
|
||||
"Hallo Korea!",
|
||||
"Hallo Wales!",
|
||||
"Hallo Polen!",
|
||||
"Hallo China!",
|
||||
"Hallo Russland!",
|
||||
"Hallo Griechenland!",
|
||||
"Mein Leben für Aiur!",
|
||||
"Lenny lenny = new Lenny(\"(°^°)\");",
|
||||
"Ich sehe dein Wortschatz hat sich verbessert!",
|
||||
"Wer hat es dort hin getan?",
|
||||
"Das kannst du nicht erklären! - Oder etwa doch??",
|
||||
"if not ok then return end",
|
||||
"Mehrfarbig!",
|
||||
"FUNKY LOL",
|
||||
"SOPA bedeutet LOSER in Schwedisch!",
|
||||
"Große Spitze Zähne!",
|
||||
"Mein Shizun bewacht das Tor!",
|
||||
"Mmmph, mmph!",
|
||||
"Füttere keine Avocados an Papageien!",
|
||||
"Schwerter für alle!",
|
||||
"Bitteee antworte meinem Tweet! (Nutzer wurde gebannt)",
|
||||
".party()!",
|
||||
"Nehme ihr Kissen!",
|
||||
"Lege diesen Keks weg!",
|
||||
"Extrem gruselig!",
|
||||
"Ich habe einen Vorschlag.",
|
||||
"Jetzt mit extra Sprengstoff!",
|
||||
"Nicht kompatibel zu Java 6!",
|
||||
"Oha.",
|
||||
"HURNERJSGER?",
|
||||
"Was'n los, Doc?",
|
||||
"Enthält jetzt 0 zufällige tägliche Katzen!",
|
||||
"Das ist Numberwang!",
|
||||
"((pls rt)) -- Der Vogel ist tot!",
|
||||
"Willst du meinem Server beitreten?",
|
||||
"Mach einen großen Zaun drum herum! Oder du wirst v-",
|
||||
"Lege eine Landmine drüber!",
|
||||
"Eines Tages, irgendwann in der Zukunft, wird mein Werk zitiert werden!",
|
||||
"Jetzt mit zusätzlichem Zeug!",
|
||||
"Zusätzliche Dinge!",
|
||||
"Hurra, Atombomben für alle!",
|
||||
"So süß, wie ein schöner Bon-Bon!",
|
||||
"Poppende Tags!",
|
||||
"Sehr einflussreich in seinem Kreis!",
|
||||
"Jetzt mit Mehrspieler!",
|
||||
"Stehe aus deinem Grab auf!",
|
||||
"Warnung! Ein großes Kampfschiff \"SHEN\" nähert sich schnell!",
|
||||
"Der blaue Krieger hat das Essen beschossen!",
|
||||
"Renn, Feigling! Ich hunger!",
|
||||
"Geschmack ohne Würze!",
|
||||
"Seltsam, aber nicht fremd!",
|
||||
"Härter als Diamanten, Reich wie Creme!",
|
||||
"Mach dich bereit zum Ruinieren!",
|
||||
"Mach dich bereit zum Experimentieren!",
|
||||
"Mach dich bereit zum Kollabieren!",
|
||||
"Mach dich bereit zum Explodieren!",
|
||||
"Mach dich bereit zum Implodieren!",
|
||||
"Mach dich bereit zum Implizieren!",
|
||||
"Es schwingt, es veräppelt!",
|
||||
"Fahre Straßen entlang für Gold!",
|
||||
"Nimm einen Schneebesen und haue ihn gegen eine Bratpfanne!",
|
||||
"Bau mir einen Tisch, einen funkigen Tisch!",
|
||||
"Nehm den Aufzug in die Hölle!",
|
||||
"Hör auf vernünftig zu sein, das hier ist das Internet!",
|
||||
"/give @a tnt 67108864 7",
|
||||
"Das ist gut für 3D Realms.",
|
||||
"Jeder Computer ist ein Laptop, wenn du tapfer genug bist!",
|
||||
"Mach es alles, jede Sache!",
|
||||
"Wo ist kein Licht, da kann Spinne!",
|
||||
"GNU Terry Pratchett",
|
||||
"Jetzt Java 8!",
|
||||
"MeinKraft!",
|
||||
"Immer noch zu viele Bugs!",
|
||||
"Wird nicht laggen!",
|
||||
"Er hat es ruiniert!",
|
||||
"Maus nicht kompatibel!",
|
||||
"OpenGL 2.0+ (definitiv nicht unterstützt)!",
|
||||
"Keine Segfaults (nicht) möglich!",
|
||||
"Keine Abstürze (un)möglich!",
|
||||
"Alpha!",
|
||||
"Enthält Bugs!",
|
||||
"Enthält Mäuse!",
|
||||
"Enthält Gewalt!",
|
||||
"Grabe immer nach unten >:)>!",
|
||||
"Weg mit O.O.P.!",
|
||||
"Du hattest eine. aufgabe.",
|
||||
"Spinnen können TNT1 A 0 sein!",
|
||||
"RTFM!",
|
||||
"Vorherrschaft des Imperiums!",
|
||||
"Vorherrschaft der Eldar!",
|
||||
"Vorherrschaft der Drukhari!",
|
||||
"Vorherrschaft der Necrons!",
|
||||
"Vorherrschaft der Orks!",
|
||||
"Jeder Laptop ist ein Tablet, wenn du tapfer genug bist!",
|
||||
"Jedes Handy ist ein Klapphandy, wenn du tapfer genug bist!",
|
||||
"Quadcores altern wie feiner Wein (außer mit JS)!",
|
||||
"Speicherzugriffsfehler (Speicherzug im Riff stehen geblieben)!",
|
||||
"Eingedeutscht (naja fast)!",
|
||||
"Ketzerei!",
|
||||
"WAAAGH!",
|
||||
"WAAAAGH!",
|
||||
"WAAAAAGH!",
|
||||
"WAAAAAAGH!",
|
||||
"WAAAAAAAGH!",
|
||||
"WAAAAAAAAGH!",
|
||||
"WAAAAAAAAAGH!",
|
||||
"WAAAAAAAAAAGH!",
|
||||
"X ist nix!",
|
||||
"Quadratisch, praktisch, gut!",
|
||||
"Rund, unpraktisch, schlecht!",
|
||||
"Verschreibungspflichtig!",
|
||||
"Grüne, radioaktive Blöcke!",
|
||||
"Blaue, nicht radioaktive Blöcke!",
|
||||
"Exterminatus!",
|
||||
"Nein! Doch! Ohh!",
|
||||
"Eimer mit Wasser!",
|
||||
"Hergestellt in Deutschland!",
|
||||
"Hergestellt in China!",
|
||||
"Jetzt mit Einzelspieler!"
|
||||
};
|
||||
}
|
30
java/src/game/util/Timing.java
Normal file
30
java/src/game/util/Timing.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package game.util;
|
||||
|
||||
public class Timing {
|
||||
public static long tmr_timer;
|
||||
public static long tmr_start;
|
||||
public static long tmr_current;
|
||||
public static long tmr_last;
|
||||
|
||||
public static long tmr_delta;
|
||||
public static long tmr_update;
|
||||
public static long tmr_frames;
|
||||
public static long tmr_iters;
|
||||
|
||||
public static long tick_torun;
|
||||
public static long tick_done;
|
||||
public static long tick_total;
|
||||
public static long tick_time;
|
||||
public static long tick_stime;
|
||||
public static long tick_ftime;
|
||||
|
||||
public static long tick_ttime;
|
||||
public static long tick_update;
|
||||
|
||||
public static double tick_fraction;
|
||||
public static float framerate;
|
||||
public static float tickrate;
|
||||
public static float fdelta;
|
||||
public static int tickTarget;
|
||||
public static int tickFrame;
|
||||
}
|
261
java/src/game/util/Util.java
Normal file
261
java/src/game/util/Util.java
Normal file
|
@ -0,0 +1,261 @@
|
|||
package game.util;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import game.log.Log;
|
||||
import game.properties.IStringSerializable;
|
||||
|
||||
public abstract class Util {
|
||||
public static String strip(String str, int offset, int len, char newl, char tab, char unk) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int pos = offset; pos < offset + len; pos++) {
|
||||
char c = str.charAt(pos);
|
||||
if(c == '\n') {
|
||||
if(newl == 0)
|
||||
return sb.toString();
|
||||
sb.append(newl);
|
||||
}
|
||||
else if((c == '\t') && tab != 0) {
|
||||
for(int z = 0; z < 4; z++)
|
||||
sb.append(tab);
|
||||
}
|
||||
else if(c == Log.CHR_UNK) {
|
||||
if(unk != 0)
|
||||
sb.append(unk);
|
||||
}
|
||||
else if(c >= Log.CHR_SPC && c <= 0xff) {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
uint utf_read(const char **ptr) {
|
||||
uint ch;
|
||||
byte utf;
|
||||
char c = *((*ptr)++);
|
||||
for(utf = 0; (utf < 6) && (c & (0x80 >> utf)); utf++) {
|
||||
;
|
||||
}
|
||||
if(utf == 1)
|
||||
return CHR_UNK;
|
||||
for(ch = ((!utf) || ((((uint)c) << 6) | (((**ptr) & 0x3f) & ~(0xff >> utf)))) ? (c & (0x7f >> utf)) : 0; utf > 1; utf--) {
|
||||
if(((c = **ptr) & 0xc0) == 0x80) {
|
||||
// if(ch) {
|
||||
ch <<= 6;
|
||||
ch |= c & 0x3f;
|
||||
// }
|
||||
}
|
||||
else {
|
||||
return c ? CHR_UNK : 0;
|
||||
}
|
||||
(*ptr)++;
|
||||
}
|
||||
// fprintf(stderr, "%d / %c\n", ch, ch);
|
||||
return (utf && !ch) ? CHR_UNK : ch;
|
||||
}
|
||||
|
||||
uint utf_readn(const char *ptr, int *pos) {
|
||||
const char *str = &ptr[*pos];
|
||||
uint ch = utf_read(&str);
|
||||
*pos = (int)(str-ptr);
|
||||
return ch;
|
||||
}
|
||||
|
||||
byte utf_write(char **ptr, int *len, uint ch) {
|
||||
uint test;
|
||||
uint mask = 0xffffff80;
|
||||
char utf;
|
||||
char c;
|
||||
if(ch & 0x80000000) {
|
||||
return 1;
|
||||
}
|
||||
for(utf = 0; ch & mask & ~(test = (0xffffffff << ((utf + 1) * 6 + (5 - utf)))); utf++) {
|
||||
mask &= test;
|
||||
}
|
||||
// fprintf(stderr, "%d\n", utf);
|
||||
if(utf + 1 >= (*len)) {
|
||||
return 0;
|
||||
}
|
||||
(*len) -= utf + 1;
|
||||
*((*ptr)++) = utf ? (~(0x7f >> utf) | (((uint)(ch >> (utf * 6))) & (0x3f >> utf))) : ch;
|
||||
for(--utf; utf >= 0; utf--) {
|
||||
*((*ptr)++) = 0x80 | (((uint)(ch >> (utf * 6))) & 0x3f);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
byte utf_rwriten(char *ptr, int *pos, int len, uint ch) {
|
||||
char *str = &ptr[*pos];
|
||||
len -= (*pos);
|
||||
byte res = utf_write(&str, &len, ch);
|
||||
*pos = (int)(str-ptr);
|
||||
return res;
|
||||
}
|
||||
|
||||
uint utf_rread(const char **ptr, const char *start) {
|
||||
const char *tp = *ptr;
|
||||
uint ch;
|
||||
char c;
|
||||
do {
|
||||
if(tp == start)
|
||||
return 0;
|
||||
tp--;
|
||||
} while(((c = (*tp)) & 0xc0) == 0x80);
|
||||
*ptr = tp;
|
||||
return (ch = utf_read(&tp)) ? ch : CHR_UNK;
|
||||
}
|
||||
|
||||
uint utf_rreadn(const char *ptr, int *pos) {
|
||||
const char *str = &ptr[*pos];
|
||||
uint ch = utf_rread(&str, ptr);
|
||||
*pos = (int)(str-ptr);
|
||||
return ch;
|
||||
}
|
||||
|
||||
int utf_len(const char *str) {
|
||||
int len;
|
||||
for(len = 0; utf_read(&str); len++) {
|
||||
;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
*/
|
||||
|
||||
public static int compareLower(String str1, String str2) {
|
||||
if(str2.length() > str1.length())
|
||||
return 0;
|
||||
for(int z = 0; z < str2.length(); z++) {
|
||||
if(Character.toLowerCase(str1.charAt(z)) != Character.toLowerCase(str2.charAt(z)))
|
||||
return 0;
|
||||
}
|
||||
return str2.length() == str1.length() ? 0x7fffffff : str2.length();
|
||||
}
|
||||
|
||||
public static Integer parseInt(String str, int base) {
|
||||
char c;
|
||||
boolean tbase = false;
|
||||
int digits = 0;
|
||||
long v = 0;
|
||||
long nbase = base != 0 ? (base < 0 ? -base : base) : 10;
|
||||
long nsign = 1;
|
||||
for(int pos = 0; pos < str.length(); pos++) {
|
||||
c = Character.toLowerCase(str.charAt(pos));
|
||||
if(pos == 0 && ((c == '+') || ((c == '-') && (base >= 0))))
|
||||
nsign = (c == '+') ? 1 : -1;
|
||||
else if(pos == 0 && c == '0') {
|
||||
tbase = true;
|
||||
digits++;
|
||||
}
|
||||
else if(tbase && pos == 1 && c == 'x') {
|
||||
nbase = 16;
|
||||
digits--;
|
||||
}
|
||||
else if(((nbase == 16) && (c >= 'a' && c <= 'f')) || (c >= '0' && c <= '9')) {
|
||||
v *= nbase;
|
||||
v += ((long)((c >= '0' && c <= '9') ? (c - '0') : (10 + (c - 'a'))));
|
||||
digits++;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
if(digits == 0)
|
||||
return null;
|
||||
v *= nsign;
|
||||
if((base < 0) ? (v < 0L || v > 0xffffffffL) : (v < -0x80000000L || v > 0x7fffffffL)) {
|
||||
return null;
|
||||
}
|
||||
return (int)((base < 0) ? (v & 0xffffffff) : (((v >> 32) & 0x80000000) | (v & 0x7fffffff)));
|
||||
}
|
||||
|
||||
public static <T extends Enum> T parseEnum(Class<T> clazz, String str) {
|
||||
boolean name = IStringSerializable.class.isAssignableFrom(clazz);
|
||||
T[] values = clazz.getEnumConstants();
|
||||
Integer value;
|
||||
if((value = parseInt(str, 0)) != null && (value >= 0) && (value < values.length)) {
|
||||
return values[value];
|
||||
}
|
||||
int comp;
|
||||
int max = 0;
|
||||
T best = null;
|
||||
for(int z = 0; z < values.length; z++) {
|
||||
if((comp = compareLower(name ? ((IStringSerializable)values[z]).getName() : values[z].toString(), str)) > max) {
|
||||
max = comp;
|
||||
best = values[z];
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
public static <T> T parseEnum(Class<T> base, String str, Class<? extends Enum> ... enums) {
|
||||
int comp;
|
||||
int max = 0;
|
||||
T best = null;
|
||||
for(Class<? extends Enum> clazz : enums) {
|
||||
if(!base.isAssignableFrom(clazz))
|
||||
throw new IllegalArgumentException("Klasse " + clazz.getSimpleName() + " ist nicht " + base.getSimpleName() + " untergeordnet");
|
||||
boolean name = IStringSerializable.class.isAssignableFrom(clazz);
|
||||
Enum<?>[] values = clazz.getEnumConstants();
|
||||
for(int z = 0; z < values.length; z++) {
|
||||
if((comp = compareLower(name ? ((IStringSerializable)values[z]).getName() : values[z].toString(), str)) > max) {
|
||||
max = comp;
|
||||
best = (T)values[z];
|
||||
}
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
public static <T> int indexOf(T[] array, T elem) {
|
||||
for(int z = 0; z < array.length; z++) {
|
||||
if(array[z] == elem)
|
||||
return z;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static <T> int indexOfChecked(T[] array, T elem) {
|
||||
for(int z = 0; z < array.length; z++) {
|
||||
if(array[z] == elem)
|
||||
return z;
|
||||
}
|
||||
throw new IllegalArgumentException("Objekt ist nicht in Array");
|
||||
}
|
||||
|
||||
public static Boolean parseBoolean(String str) {
|
||||
if("1".equals(str) || "true".equalsIgnoreCase(str) || "on".equalsIgnoreCase(str) || "yes".equalsIgnoreCase(str) || "y".equalsIgnoreCase(str))
|
||||
return true;
|
||||
else if("0".equals(str) || "false".equalsIgnoreCase(str) || "off".equalsIgnoreCase(str) || "no".equalsIgnoreCase(str) || "n".equalsIgnoreCase(str))
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> String buildLines(String separator, Function<T, String> func, Iterable<T> elems) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(T elem : elems) {
|
||||
if(sb.length() > 0)
|
||||
sb.append(separator);
|
||||
sb.append(func.apply(elem));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static <T> String buildLines(Function<T, String> func, Iterable<T> elems) {
|
||||
return buildLines("\n", func, elems);
|
||||
}
|
||||
|
||||
public static <T> String buildLines(String separator, Function<T, String> func, T ... elems) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(T elem : elems) {
|
||||
if(sb.length() > 0)
|
||||
sb.append(separator);
|
||||
sb.append(func.apply(elem));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static <T> String buildLines(Function<T, String> func, T ... elems) {
|
||||
return buildLines("\n", func, elems);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue