Final changes to text drawing system to make it appear correctly
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
e5dd00cff8
commit
636aac9bfc
@ -16,7 +16,7 @@ public class DrawLoop {
|
||||
|
||||
for (int y=0;y<RabiClone.BASE_HEIGHT;y++) {
|
||||
for (int x=0;x<RabiClone.BASE_WIDTH;x++) {
|
||||
p[y*RabiClone.BASE_WIDTH+x]=0;//RGB
|
||||
p[y*RabiClone.BASE_WIDTH+x]=(byte)PaletteColor.DARK_ORCHID.ordinal();//RGB
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,14 +40,16 @@ public class DrawLoop {
|
||||
int xOffset=0;
|
||||
PaletteColor currentCol = col;
|
||||
for (int i=0;i<finalS.length();i++) {
|
||||
if (finalS.charAt(i)=='\u001a'&&i<finalS.length()-1) {
|
||||
if (finalS.charAt(i)==(char)26&&i<finalS.length()-1) {
|
||||
byte nextCol=Byte.parseByte(finalS.substring(i+1, finalS.indexOf(' ',i+1)));
|
||||
if (nextCol>=PaletteColor.values().length||nextCol<0) {
|
||||
throw new ArrayIndexOutOfBoundsException("Chosen color %"+nextCol+" is not in range (Min:0, Max: "+(PaletteColor.values().length-1)+")");
|
||||
} else {
|
||||
currentCol=PaletteColor.values()[nextCol];
|
||||
}
|
||||
finalS=finalS.replaceFirst(Pattern.quote("\u001a"+nextCol+" "),"");
|
||||
int oldLength = finalS.length();
|
||||
finalS=finalS.replaceFirst(Pattern.quote(Character.valueOf((char)26)+Byte.toString(nextCol)+" "),"");
|
||||
i--;
|
||||
} else
|
||||
if (finalS.charAt(i)=='\n') {
|
||||
xOffset+=(charCount+1)*f.getGlyphWidth();
|
||||
|
@ -37,7 +37,7 @@ public enum PaletteColor {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "\u001a"+ordinal()+" ";
|
||||
return Character.valueOf((char)26)+Integer.toString(ordinal())+" ";
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user