mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 12:10:30 +00:00
Add getColour/setColour to the window api
This commit is contained in:
parent
56c9dec687
commit
b0f0d8fd71
@ -25,7 +25,7 @@ public class Terminal
|
|||||||
private TextBuffer m_textColour[];
|
private TextBuffer m_textColour[];
|
||||||
private TextBuffer m_backgroundColour[];
|
private TextBuffer m_backgroundColour[];
|
||||||
|
|
||||||
private Palette m_palette;
|
private final Palette m_palette;
|
||||||
|
|
||||||
private boolean m_changed;
|
private boolean m_changed;
|
||||||
|
|
||||||
|
@ -82,8 +82,7 @@ public class Palette
|
|||||||
{
|
{
|
||||||
if(i >= 0 && i < colours.length )
|
if(i >= 0 && i < colours.length )
|
||||||
{
|
{
|
||||||
Colour c = Colour.values()[ i ];
|
setColour( i, Colour.values()[ i ] );
|
||||||
colours[i] = new PaletteColour( c.getR(), c.getG(), c.getB() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
|||||||
local nTextColor = colors.white
|
local nTextColor = colors.white
|
||||||
local nBackgroundColor = colors.black
|
local nBackgroundColor = colors.black
|
||||||
local tLines = {}
|
local tLines = {}
|
||||||
|
local tPalette = {}
|
||||||
do
|
do
|
||||||
local sEmptyText = sEmptySpaceLine
|
local sEmptyText = sEmptySpaceLine
|
||||||
local sEmptyTextColor = tEmptyColorLines[ nTextColor ]
|
local sEmptyTextColor = tEmptyColorLines[ nTextColor ]
|
||||||
@ -68,6 +69,11 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
|||||||
backgroundColor = sEmptyBackgroundColor,
|
backgroundColor = sEmptyBackgroundColor,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i=0,15 do
|
||||||
|
local c = 2 ^ i
|
||||||
|
tPalette[c] = table.pack( parent.getColour( c ) )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Helper functions
|
-- Helper functions
|
||||||
@ -88,6 +94,12 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
|||||||
parent.setTextColor( nTextColor )
|
parent.setTextColor( nTextColor )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function updatePalette()
|
||||||
|
for k,v in pairs(tPalette) do
|
||||||
|
parent.setColour( k, table.unpack( v ) )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function redrawLine( n )
|
local function redrawLine( n )
|
||||||
local tLine = tLines[ n ]
|
local tLine = tLines[ n ]
|
||||||
parent.setCursorPos( nX, nY + n - 1 )
|
parent.setCursorPos( nX, nY + n - 1 )
|
||||||
@ -276,6 +288,21 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
|||||||
setTextColor( color )
|
setTextColor( color )
|
||||||
end
|
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 )
|
local function setBackgroundColor( color )
|
||||||
if not parent.isColor() then
|
if not parent.isColor() then
|
||||||
if color ~= colors.white and color ~= colors.black and color ~= colors.gray and color ~= colors.lightGray then
|
if color ~= colors.white and color ~= colors.black and color ~= colors.gray and color ~= colors.lightGray then
|
||||||
|
Loading…
Reference in New Issue
Block a user