1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-26 07:03:22 +00:00

Enabled window.setText/BackgroundColour with no grey colours. Some small optimisations

This commit is contained in:
Daniel Ratcliffe 2017-05-07 17:19:21 +01:00 committed by GitHub
parent c10e1ba78c
commit ebb7d7a8d9

View File

@ -20,6 +20,7 @@ local tHex = {
local string_rep = string.rep
local string_sub = string.sub
local table_unpack = table.unpack
function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
@ -108,7 +109,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
local function updatePalette()
for k,v in pairs( tPalette ) do
parent.setPaletteColour( k, table.unpack( v ) )
parent.setPaletteColour( k, v[1], v[2], v[3] )
end
end
@ -269,11 +270,6 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
end
local function setTextColor( color )
if not parent.isColor() then
if color ~= colors.white and color ~= colors.black and color ~= colors.gray and color ~= colors.lightGray then
error( "Color not supported", 3 )
end
end
nTextColor = color
if bVisible then
updateCursorColor()
@ -289,34 +285,33 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
end
function window.setPaletteColour( colour, r, g, b )
local tCol
if type(colour) == "number" and type(r) == "number" and g == nil and b == nil then
tPalette[ colour ] = { colours.rgb8( r ) }
tCol = { colours.rgb8( r ) }
elseif type(colour) == "number" and type(r) == "number" and type(g) == "number" and type(b) == "number" then
local tCol = tPalette[ colour ]
tCol = tPalette[ colour ]
tCol[1] = r
tCol[2] = g
tCol[3] = b
else
error("Expected number, number, number, number")
end
if bVisible then
return parent.setPaletteColour( colour, table.unpack( tPalette[ colour ] ) )
return parent.setPaletteColour( colour, tCol[1], tCol[2], tCol[3] ) )
end
end
window.setPaletteColor = window.setPaletteColour
function window.getPaletteColour( colour )
return table.unpack( tPalette[ colour ] )
local tCol = tPalette[ colour ]
return tCol[1], tCol[2], tCol[3]
end
window.getPaletteColor = window.getPaletteColour
local function setBackgroundColor( color )
if not parent.isColor() then
if color ~= colors.white and color ~= colors.black and color ~= colors.gray and color ~= colors.lightGray then
error( "Color not supported", 3 )
end
end
nBackgroundColor = color
end