Improved error messages + nwm opacity/resizing
This commit is contained in:
@@ -12,31 +12,32 @@ local device = _G.device
|
||||
|
||||
local Glasses = { }
|
||||
|
||||
local palette = {
|
||||
['0'] = 0xF0F0F000,
|
||||
['1'] = 0xF2B23300,
|
||||
['2'] = 0xE57FD800,
|
||||
['3'] = 0x99B2F200,
|
||||
['4'] = 0xDEDE6C00,
|
||||
['5'] = 0x7FCC1900,
|
||||
['6'] = 0xF2B2CC00,
|
||||
['7'] = 0x4C4C4C00,
|
||||
['8'] = 0x99999900,
|
||||
['9'] = 0x4C99B200,
|
||||
['a'] = 0xB266E500,
|
||||
['b'] = 0x3366CC00,
|
||||
['c'] = 0x7F664C00,
|
||||
['d'] = 0x57A64E00,
|
||||
['e'] = 0xCC4C4C00,
|
||||
['f'] = 0x19191900,
|
||||
}
|
||||
|
||||
function Glasses.getPalette(opacity)
|
||||
local pal = {
|
||||
['0'] = 0xF0F0F000,
|
||||
['1'] = 0xF2B23300,
|
||||
['2'] = 0xE57FD800,
|
||||
['3'] = 0x99B2F200,
|
||||
['4'] = 0xDEDE6C00,
|
||||
['5'] = 0x7FCC1900,
|
||||
['6'] = 0xF2B2CC00,
|
||||
['7'] = 0x4C4C4C00,
|
||||
['8'] = 0x99999900,
|
||||
['9'] = 0x4C99B200,
|
||||
['a'] = 0xB266E500,
|
||||
['b'] = 0x3366CC00,
|
||||
['c'] = 0x7F664C00,
|
||||
['d'] = 0x57A64E00,
|
||||
['e'] = 0xCC4C4C00,
|
||||
['f'] = 0x19191900,
|
||||
}
|
||||
if opacity then
|
||||
for k,v in pairs(pal) do
|
||||
pal[k] = v + opacity
|
||||
for k,v in pairs(palette) do
|
||||
palette[k] = v + opacity
|
||||
end
|
||||
end
|
||||
return pal
|
||||
return palette
|
||||
end
|
||||
|
||||
function Glasses.create(args)
|
||||
@@ -54,7 +55,7 @@ function Glasses.create(args)
|
||||
local canvas = glasses.canvas()
|
||||
local _, cy = 1, 1
|
||||
local lines = { }
|
||||
local pal = Glasses.getPalette(opts.opacity)
|
||||
local pal = palette -- Glasses.getPalette(opts.opacity)
|
||||
|
||||
local pos = { x = opts.x * xs, y = opts.y * ys }
|
||||
|
||||
@@ -83,9 +84,11 @@ function Glasses.create(args)
|
||||
blit = function(text, fg, bg)
|
||||
for x = 1, #text do
|
||||
local ln = lines[cy]
|
||||
ln.bg[x].setColor(pal[bg:sub(x, x)])
|
||||
ln.text[x].setColor(pal[fg:sub(x, x)])
|
||||
ln.text[x].setText(text:sub(x, x))
|
||||
if ln and x <= opts.width then
|
||||
ln.bg[x].setColor(pal[bg:sub(x, x)] + opts.opacity)
|
||||
ln.text[x].setColor(pal[fg:sub(x, x)] + opts.opacity)
|
||||
ln.text[x].setText(text:sub(x, x))
|
||||
end
|
||||
end
|
||||
end,
|
||||
setCursorPos = function(_, y)
|
||||
@@ -110,6 +113,13 @@ function Glasses.create(args)
|
||||
function gterm.getTextScale()
|
||||
return opts.scale
|
||||
end
|
||||
function gterm.getOpacity()
|
||||
return opts.opacity
|
||||
end
|
||||
function gterm.setOpacity(opacity)
|
||||
opts.opacity = opacity
|
||||
gterm.redraw()
|
||||
end
|
||||
function gterm.move(x, y)
|
||||
if opts.x ~= x or opts.y ~= y then
|
||||
opts.x, opts.y = x, y
|
||||
@@ -117,10 +127,21 @@ function Glasses.create(args)
|
||||
group.setPosition(pos.x, pos.y)
|
||||
end
|
||||
end
|
||||
function gterm.reposition2(x, y, w, h)
|
||||
opts.x, opts.y = x, y
|
||||
opts.width, opts.height = w, h
|
||||
pos = { x = opts.x * xs, y = opts.y * ys }
|
||||
local g = canvas.addGroup(pos)
|
||||
init(g)
|
||||
group.remove()
|
||||
group = g
|
||||
gterm.reposition(1, 1, w, h)
|
||||
gterm.redraw()
|
||||
end
|
||||
|
||||
gterm.name = opts.name
|
||||
gterm.side = opts.name
|
||||
gterm.type = 'glasses'
|
||||
--gterm.name = opts.name
|
||||
--gterm.side = opts.name
|
||||
--gterm.type = 'glasses'
|
||||
|
||||
return gterm
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user