mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Enabled window.setText/BackgroundColour with no grey colours. Some small optimisations
This commit is contained in:
		| @@ -20,6 +20,7 @@ local tHex = { | |||||||
|  |  | ||||||
| local string_rep = string.rep | local string_rep = string.rep | ||||||
| local string_sub = string.sub | local string_sub = string.sub | ||||||
|  | local table_unpack = table.unpack | ||||||
|  |  | ||||||
| function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) | function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) | ||||||
|  |  | ||||||
| @@ -108,7 +109,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) | |||||||
|  |  | ||||||
|     local function updatePalette() |     local function updatePalette() | ||||||
|         for k,v in pairs( tPalette ) do |         for k,v in pairs( tPalette ) do | ||||||
|             parent.setPaletteColour( k, table.unpack( v ) ) |             parent.setPaletteColour( k, v[1], v[2], v[3] ) | ||||||
|         end |         end | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -269,11 +270,6 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) | |||||||
|     end |     end | ||||||
|  |  | ||||||
|     local function setTextColor( color ) |     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 |         nTextColor = color | ||||||
|         if bVisible then |         if bVisible then | ||||||
|             updateCursorColor() |             updateCursorColor() | ||||||
| @@ -289,34 +285,33 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) | |||||||
|     end |     end | ||||||
|  |  | ||||||
|     function window.setPaletteColour( colour, r, g, b ) |     function window.setPaletteColour( colour, r, g, b ) | ||||||
|  |         local tCol | ||||||
|         if type(colour) == "number" and type(r) == "number" and g == nil and b == nil then |         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 |         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[1] = r | ||||||
|             tCol[2] = g |             tCol[2] = g | ||||||
|             tCol[3] = b |             tCol[3] = b | ||||||
|  |         else | ||||||
|  |             error("Expected number, number, number, number") | ||||||
|         end |         end | ||||||
|  |  | ||||||
|         if bVisible then |         if bVisible then | ||||||
|             return parent.setPaletteColour( colour, table.unpack( tPalette[ colour ] ) ) |             return parent.setPaletteColour( colour, tCol[1], tCol[2], tCol[3] ) ) | ||||||
|         end |         end | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     window.setPaletteColor = window.setPaletteColour |     window.setPaletteColor = window.setPaletteColour | ||||||
|  |  | ||||||
|     function window.getPaletteColour( colour ) |     function window.getPaletteColour( colour ) | ||||||
|         return table.unpack( tPalette[ colour ] ) |         local tCol = tPalette[ colour ] | ||||||
|  |         return tCol[1], tCol[2], tCol[3] | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     window.getPaletteColor = window.getPaletteColour |     window.getPaletteColor = window.getPaletteColour | ||||||
|  |  | ||||||
|     local function setBackgroundColor( color ) |     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 |         nBackgroundColor = color | ||||||
|     end |     end | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Daniel Ratcliffe
					Daniel Ratcliffe