From bfa5f6ec9caa1274a6ff6c6118154be31b1f1a00 Mon Sep 17 00:00:00 2001 From: Lignum Date: Fri, 5 May 2017 20:23:57 +0200 Subject: [PATCH] Make palettes work properly with the window API --- .../assets/computercraft/lua/rom/apis/window | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/window b/src/main/resources/assets/computercraft/lua/rom/apis/window index f5bffe76a..bd5c61945 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/window +++ b/src/main/resources/assets/computercraft/lua/rom/apis/window @@ -94,12 +94,6 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) parent.setTextColor( nTextColor ) end - local function updatePalette() - for k,v in pairs(tPalette) do - parent.setColour( k, table.unpack( v ) ) - end - end - local function redrawLine( n ) local tLine = tLines[ n ] parent.setCursorPos( nX, nY + n - 1 ) @@ -112,6 +106,12 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) end end + local function updatePalette() + for k,v in pairs(tPalette) do + parent.setColour( k, table.unpack( v ) ) + end + end + local function internalBlit( sText, sTextColor, sBackgroundColor ) local nStart = nCursorX local nEnd = nStart + #sText - 1 @@ -293,6 +293,10 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) tCol[1] = r tCol[2] = g tCol[3] = b + + if bVisible then + return updatePalette() + end end window.setColor = window.setColour @@ -380,10 +384,10 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) function window.redraw() if bVisible then redraw() + updatePalette() updateCursorBlink() updateCursorColor() updateCursorPos() - updatePalette() end end