From a5e1dad5fc05bf37d540d0aa9428bbe67debeff2 Mon Sep 17 00:00:00 2001 From: Daniel Ratcliffe Date: Sun, 7 May 2017 17:22:49 +0100 Subject: [PATCH] Enabled term.setText/BackgroundColour with non grey colours on greyscale monitors As rendering is greyscale now, this is fine. --- .../dan200/computercraft/core/apis/TermAPI.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/dan200/computercraft/core/apis/TermAPI.java b/src/main/java/dan200/computercraft/core/apis/TermAPI.java index 84b904fd2..3d4b53e0d 100644 --- a/src/main/java/dan200/computercraft/core/apis/TermAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/TermAPI.java @@ -81,7 +81,7 @@ public class TermAPI implements ILuaAPI }; } - public static int parseColour( Object[] args, boolean _enableColours ) throws LuaException + public static int parseColour( Object[] args ) throws LuaException { if( args.length < 1 || args[0] == null || !(args[0] instanceof Double) ) { @@ -97,10 +97,6 @@ public class TermAPI implements ILuaAPI { throw new LuaException( "Colour out of range" ); } - if( !_enableColours && (colour != 0 && colour != 15 && colour != 7 && colour != 8) ) - { - throw new LuaException( "Colour not supported" ); - } return colour; } @@ -230,7 +226,7 @@ public class TermAPI implements ILuaAPI case 9: { // setTextColour/setTextColor - int colour = parseColour( args, m_environment.isColour() ); + int colour = parseColour( args ); synchronized( m_terminal ) { m_terminal.setTextColour( colour ); @@ -241,7 +237,7 @@ public class TermAPI implements ILuaAPI case 11: { // setBackgroundColour/setBackgroundColor - int colour = parseColour( args, m_environment.isColour() ); + int colour = parseColour( args ); synchronized( m_terminal ) { m_terminal.setBackgroundColour( colour ); @@ -295,7 +291,7 @@ public class TermAPI implements ILuaAPI // setPaletteColour/setPaletteColor if(args.length == 2 && args[0] instanceof Double && args[1] instanceof Double) { - int colour = 15 - parseColour( args, true ); + int colour = 15 - parseColour( args ); int hex = ((Double)args[1]).intValue(); float[] rgb = Palette.decodeRGB8( hex ); setColour( m_terminal, colour, rgb[0], rgb[1], rgb[2] ); @@ -304,7 +300,7 @@ public class TermAPI implements ILuaAPI if(args.length >= 4 && args[0] instanceof Double && args[1] instanceof Double && args[2] instanceof Double && args[3] instanceof Double) { - int colour = 15 - parseColour( args, true ); + int colour = 15 - parseColour( args ); float r = ((Double)args[1]).floatValue(); float g = ((Double)args[2]).floatValue(); float b = ((Double)args[3]).floatValue(); @@ -323,8 +319,7 @@ public class TermAPI implements ILuaAPI throw new LuaException( "Expected number" ); } - int colour = 15 - parseColour( args, m_environment.isColour() ); - + int colour = 15 - parseColour( args ); synchronized( m_terminal ) { if ( m_terminal.getPalette() != null )