gui and text drawing, gui misc
This commit is contained in:
parent
c906760bd4
commit
4ec8affe85
37 changed files with 799 additions and 646 deletions
|
@ -2,6 +2,8 @@ package game.color;
|
|||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import game.util.Util;
|
||||
|
||||
public enum TextColor {
|
||||
NULL(0x00),
|
||||
RESET(0x01),
|
||||
|
@ -48,13 +50,15 @@ public enum TextColor {
|
|||
|
||||
private static final Pattern STRIP_PATTERN = Pattern.compile("[\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000b\u000c\r\u000e\u000f"
|
||||
+ "\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f]");
|
||||
|
||||
|
||||
private static final int[] COLORS = new int[32];
|
||||
private static final int[] SHADOW = new int[32];
|
||||
|
||||
private final String format;
|
||||
public final char code;
|
||||
public final int color;
|
||||
|
||||
public final int shadow;
|
||||
|
||||
public static String stripCodes(String text) {
|
||||
return text == null ? null : STRIP_PATTERN.matcher(text).replaceAll("");
|
||||
}
|
||||
|
@ -62,6 +66,10 @@ public enum TextColor {
|
|||
public static int getColor(char code) {
|
||||
return code < COLORS.length ? COLORS[code] : 0x000000;
|
||||
}
|
||||
|
||||
public static int getShadow(char code) {
|
||||
return code < SHADOW.length ? SHADOW[code] : 0x000000;
|
||||
}
|
||||
|
||||
private TextColor(int code) {
|
||||
this(code, 0x000000);
|
||||
|
@ -70,6 +78,7 @@ public enum TextColor {
|
|||
private TextColor(int code, int color) {
|
||||
this.format = Character.toString(this.code = (char)code);
|
||||
this.color = color;
|
||||
this.shadow = Util.mixColor(Util.mixColor(this.color, 0x000000), 0x000000);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -78,8 +87,10 @@ public enum TextColor {
|
|||
|
||||
static {
|
||||
for(TextColor color : values()) {
|
||||
if(color.code < COLORS.length)
|
||||
if(color.code < COLORS.length) {
|
||||
COLORS[color.code] = color.color;
|
||||
SHADOW[color.code] = color.shadow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue