1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-13 11:40:29 +00:00

Add getColour/setColour to the window api

This commit is contained in:
Lignum 2017-05-05 16:14:13 +02:00
parent 56c9dec687
commit b0f0d8fd71
No known key found for this signature in database
GPG Key ID: 0889206F5A8A700D
3 changed files with 29 additions and 3 deletions

View File

@ -25,7 +25,7 @@ public class Terminal
private TextBuffer m_textColour[];
private TextBuffer m_backgroundColour[];
private Palette m_palette;
private final Palette m_palette;
private boolean m_changed;

View File

@ -82,8 +82,7 @@ public class Palette
{
if(i >= 0 && i < colours.length )
{
Colour c = Colour.values()[ i ];
colours[i] = new PaletteColour( c.getR(), c.getG(), c.getB() );
setColour( i, Colour.values()[ i ] );
}
}

View File

@ -57,6 +57,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
local nTextColor = colors.white
local nBackgroundColor = colors.black
local tLines = {}
local tPalette = {}
do
local sEmptyText = sEmptySpaceLine
local sEmptyTextColor = tEmptyColorLines[ nTextColor ]
@ -68,6 +69,11 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
backgroundColor = sEmptyBackgroundColor,
}
end
for i=0,15 do
local c = 2 ^ i
tPalette[c] = table.pack( parent.getColour( c ) )
end
end
-- Helper functions
@ -87,6 +93,12 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
local function updateCursorColor()
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 ]
@ -276,6 +288,21 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
setTextColor( color )
end
function window.setColour( colour, r, g, b )
local tCol = tPalette[ colour ]
tCol[1] = r
tCol[2] = g
tCol[3] = b
end
window.setColor = window.setColour
function window.getColour( colour )
return table.unpack( tPalette[ colour ] )
end
window.getColor = window.getColour
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