From 36b4d16939678277ea1d46d4eee528350dac9fad Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Tue, 31 Aug 2021 10:56:43 +0200 Subject: [PATCH] improvement: let the screen handle opacity --- sonic-radiance.love/birb/modules/gui/elements/assets.lua | 4 ++-- sonic-radiance.love/birb/modules/gui/elements/canvas.lua | 3 +-- sonic-radiance.love/birb/modules/gui/elements/composite.lua | 1 + sonic-radiance.love/birb/modules/gui/elements/counter.lua | 4 ++-- sonic-radiance.love/birb/modules/gui/elements/drawable.lua | 3 +-- sonic-radiance.love/birb/modules/gui/elements/text.lua | 3 +-- sonic-radiance.love/birb/modules/gui/elements/variable.lua | 4 ++-- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/sonic-radiance.love/birb/modules/gui/elements/assets.lua b/sonic-radiance.love/birb/modules/gui/elements/assets.lua index 2e05410..95990c0 100644 --- a/sonic-radiance.love/birb/modules/gui/elements/assets.lua +++ b/sonic-radiance.love/birb/modules/gui/elements/assets.lua @@ -1,12 +1,12 @@ local Parent = require "birb.modules.gui.elements.drawable" local AssetElement = Parent:extend() -function AssetElement:new(name, assetType, assetName, x, y,r,sx,sy,ox,oy, opacity, depth) +function AssetElement:new(name, assetType, assetName, x, y,r,sx,sy,ox,oy, opacity) local gui = self:getGui() local asset = gui.scene.assets[assetType][assetName] assert(asset ~= nil, assetName .. ' (' .. assetType .. ") doesn't exist") - AssetElement.super.new(self, name, asset, x, y,r,sx,sy,ox,oy, opacity, depth) + AssetElement.super.new(self, name, asset, x, y,r,sx,sy,ox,oy, opacity) end function AssetElement:draw() diff --git a/sonic-radiance.love/birb/modules/gui/elements/canvas.lua b/sonic-radiance.love/birb/modules/gui/elements/canvas.lua index 62a6949..f3b043c 100644 --- a/sonic-radiance.love/birb/modules/gui/elements/canvas.lua +++ b/sonic-radiance.love/birb/modules/gui/elements/canvas.lua @@ -1,14 +1,13 @@ local Parent = require "birb.modules.gui.elements.parent" local CanvasElement = Parent:extend() -function CanvasElement:new(name, x, y, w, h, r,sx,sy,ox,oy, opacity, depth) +function CanvasElement:new(name, x, y, w, h, r,sx,sy,ox,oy, opacity) self:initCanvas() CanvasElement.super.new(self, name, x, y, w, h) self.r = r or 0 self.sx, self.sy = sx or 1, sy or 1 self.ox, self.oy = self:parseOrigin(ox, w), self:parseOrigin(oy, h) self.opacity = opacity or 1 - self.depth = depth or 0 end function CanvasElement:initCanvas() diff --git a/sonic-radiance.love/birb/modules/gui/elements/composite.lua b/sonic-radiance.love/birb/modules/gui/elements/composite.lua index 8c42561..92c072b 100644 --- a/sonic-radiance.love/birb/modules/gui/elements/composite.lua +++ b/sonic-radiance.love/birb/modules/gui/elements/composite.lua @@ -28,6 +28,7 @@ function CompositeElement:update(dt) childElement.x = self.x + child.relx childElement.y = self.y + child.rely childElement.isVisible = self.isVisible + childElement.depth = self.depth end end diff --git a/sonic-radiance.love/birb/modules/gui/elements/counter.lua b/sonic-radiance.love/birb/modules/gui/elements/counter.lua index fc13296..2730996 100644 --- a/sonic-radiance.love/birb/modules/gui/elements/counter.lua +++ b/sonic-radiance.love/birb/modules/gui/elements/counter.lua @@ -1,8 +1,8 @@ local Parent = require "birb.modules.gui.elements.variable" local CounterElement = Parent:extend() -function CounterElement:new(name, fontName, object, varName, nbrs, x, y, align, depth) - CounterElement.super.new(self, name, fontName, object, varName, x, y, align, depth) +function CounterElement:new(name, fontName, object, varName, nbrs, x, y, align) + CounterElement.super.new(self, name, fontName, object, varName, x, y, align) self.nbrs = nbrs or 0 end diff --git a/sonic-radiance.love/birb/modules/gui/elements/drawable.lua b/sonic-radiance.love/birb/modules/gui/elements/drawable.lua index 76c1031..7027c52 100644 --- a/sonic-radiance.love/birb/modules/gui/elements/drawable.lua +++ b/sonic-radiance.love/birb/modules/gui/elements/drawable.lua @@ -1,7 +1,7 @@ local Parent = require "birb.modules.gui.elements.parent" local DrawableElement = Parent:extend() -function DrawableElement:new(name, drawable, x, y,r,sx,sy,ox,oy, opacity, depth) +function DrawableElement:new(name, drawable, x, y,r,sx,sy,ox,oy, opacity) self.drawable = drawable local w, h = self.drawable:getDimensions() @@ -10,7 +10,6 @@ function DrawableElement:new(name, drawable, x, y,r,sx,sy,ox,oy, opacity, depth) self.sx, self.sy = sx or 1, sy or 1 self.ox, self.oy = self:parseOrigin(ox, w), self:parseOrigin(oy, h) self.opacity = opacity or 1 - self.depth = depth or 0 end function DrawableElement:parseOrigin(origin, size) diff --git a/sonic-radiance.love/birb/modules/gui/elements/text.lua b/sonic-radiance.love/birb/modules/gui/elements/text.lua index ebd4ffa..c5f9871 100644 --- a/sonic-radiance.love/birb/modules/gui/elements/text.lua +++ b/sonic-radiance.love/birb/modules/gui/elements/text.lua @@ -1,14 +1,13 @@ local Parent = require "birb.modules.gui.elements.parent" local TextElement = Parent:extend() -function TextElement:new(name, fontName, text, x, y, align, depth) +function TextElement:new(name, fontName, text, x, y, align) self.text = text local gui = self:getGui() self.font = gui.scene.assets.fonts[fontName] TextElement.super.new(self, name, x, y, 1, 1) self.align = align - self.depth = depth or 0 end function TextElement:getText() diff --git a/sonic-radiance.love/birb/modules/gui/elements/variable.lua b/sonic-radiance.love/birb/modules/gui/elements/variable.lua index 7716230..32a95b4 100644 --- a/sonic-radiance.love/birb/modules/gui/elements/variable.lua +++ b/sonic-radiance.love/birb/modules/gui/elements/variable.lua @@ -1,8 +1,8 @@ local Parent = require "birb.modules.gui.elements.text" local VariableElement = Parent:extend() -function VariableElement:new(name, fontName, object, varName, x, y, align, depth) - VariableElement.super.new(self, name, fontName, "", x, y, align, depth) +function VariableElement:new(name, fontName, object, varName, x, y, align) + VariableElement.super.new(self, name, fontName, "", x, y, align) self.object = object self.variable = varName end