diff --git a/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java b/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java index c214505d7..9e6d80268 100644 --- a/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java +++ b/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java @@ -55,10 +55,9 @@ public final class FixedWidthFontRenderer return (float) ((rgb[0] + rgb[1] + rgb[2]) / 3); } - private static int getColour( char c ) + private static int getColour( char c, Colour def ) { - int i = "0123456789abcdef".indexOf( c ); - return i < 0 ? 0 : 15 - i; + return 15 - Terminal.getColour( c, def ); } private static void drawChar( BufferBuilder buffer, float x, float y, int index, float r, float g, float b ) @@ -92,7 +91,7 @@ public final class FixedWidthFontRenderer private static void drawQuad( BufferBuilder buffer, float x, float y, float width, float height, Palette palette, boolean greyscale, char colourIndex ) { - double[] colour = palette.getColour( getColour( colourIndex ) ); + double[] colour = palette.getColour( getColour( colourIndex, Colour.Black ) ); float r, g, b; if( greyscale ) { @@ -160,7 +159,7 @@ public final class FixedWidthFontRenderer for( int i = 0; i < text.length(); i++ ) { - double[] colour = palette.getColour( getColour( textColour.charAt( i ) ) ); + double[] colour = palette.getColour( getColour( textColour.charAt( i ), Colour.White ) ); float r, g, b; if( greyscale ) { diff --git a/src/main/java/dan200/computercraft/core/terminal/Terminal.java b/src/main/java/dan200/computercraft/core/terminal/Terminal.java index 2e6ac273d..bbe2e1551 100644 --- a/src/main/java/dan200/computercraft/core/terminal/Terminal.java +++ b/src/main/java/dan200/computercraft/core/terminal/Terminal.java @@ -5,6 +5,7 @@ */ package dan200.computercraft.core.terminal; +import dan200.computercraft.shared.util.Colour; import dan200.computercraft.shared.util.Palette; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; @@ -342,7 +343,10 @@ public class Terminal for( int x = 0; x < m_width; x++ ) { buffer.writeByte( text.charAt( x ) & 0xFF ); - buffer.writeByte( colourIndex( backColour.charAt( x ) ) << 4 | colourIndex( textColour.charAt( x ) ) ); + buffer.writeByte( getColour( + backColour.charAt( x ), Colour.Black ) << 4 | + getColour( textColour.charAt( x ), Colour.White ) + ); } } @@ -428,10 +432,10 @@ public class Terminal setChanged(); } - private static int colourIndex( char c ) + public static int getColour( char c, Colour def ) { if( c >= '0' && c <= '9' ) return c - '0'; if( c >= 'a' && c <= 'f' ) return c - 'a' + 10; - return 0; + return 15 - def.ordinal(); } }