From 0e1b712adcbb1f4c2a2c44658efb64ea82463230 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Wed, 10 Jul 2019 19:02:46 -0600 Subject: [PATCH] ntf transparency --- sys/modules/opus/nft.lua | 7 ++++--- sys/modules/opus/ui.lua | 8 +++++--- sys/modules/opus/ui/components/NftImage.lua | 5 ++++- sys/modules/opus/util.lua | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sys/modules/opus/nft.lua b/sys/modules/opus/nft.lua index f6d5468..52d5c6c 100644 --- a/sys/modules/opus/nft.lua +++ b/sys/modules/opus/nft.lua @@ -50,9 +50,10 @@ function NFT.parse(imageText) currFG = getColourOf(nextChar) fgNext = false else - if nextChar ~= " " and currFG == nil then - currFG = _G.colors.white - end + --if nextChar ~= " " and currFG == nil then + -- any color not in range is considered transparent + -- currFG = _G.colors.white + --end image.bg[num][writeIndex] = currBG image.fg[num][writeIndex] = currFG image.text[num][writeIndex] = nextChar diff --git a/sys/modules/opus/ui.lua b/sys/modules/opus/ui.lua index 5f2245e..0acfb16 100644 --- a/sys/modules/opus/ui.lua +++ b/sys/modules/opus/ui.lua @@ -912,10 +912,12 @@ function UI.Window:emit(event) end end +function UI.Window:getProperty(property) + return self[property] or self.parent and self.parent:getProperty(property) +end + function UI.Window:find(uid) - if self.children then - return Util.find(self.children, 'uid', uid) - end + return self.children and Util.find(self.children, 'uid', uid) end function UI.Window:eventHandler() diff --git a/sys/modules/opus/ui/components/NftImage.lua b/sys/modules/opus/ui/components/NftImage.lua index 3457711..4d295d7 100644 --- a/sys/modules/opus/ui/components/NftImage.lua +++ b/sys/modules/opus/ui/components/NftImage.lua @@ -17,9 +17,12 @@ end function UI.NftImage:draw() if self.image then + -- due to blittle, the background and foreground transparent + -- color is the same as the background color + local bg = self:getProperty('backgroundColor') for y = 1, self.image.height do for x = 1, #self.image.text[y] do - self:write(x, y, self.image.text[y][x], self.image.bg[y][x], self.image.fg[y][x]) + self:write(x, y, self.image.text[y][x], self.image.bg[y][x], self.image.fg[y][x] or bg) end end else diff --git a/sys/modules/opus/util.lua b/sys/modules/opus/util.lua index e670857..2c8e097 100644 --- a/sys/modules/opus/util.lua +++ b/sys/modules/opus/util.lua @@ -412,8 +412,8 @@ function Util.first(t, order) end --[[ File functions ]]-- -function Util.readFile(fname) - local f = fs.open(fname, "r") +function Util.readFile(fname, flags) + local f = fs.open(fname, flags or "r") if f then local t = f.readAll() f.close()