Refonte pour utiliser le systeme de GUI #112

Merged
kazhnuz merged 102 commits from feat/gui into master 2022-01-06 19:15:16 +01:00
7 changed files with 10 additions and 12 deletions
Showing only changes of commit 36b4d16939 - Show all commits

View file

@ -1,12 +1,12 @@
local Parent = require "birb.modules.gui.elements.drawable" local Parent = require "birb.modules.gui.elements.drawable"
local AssetElement = Parent:extend() 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 gui = self:getGui()
local asset = gui.scene.assets[assetType][assetName] local asset = gui.scene.assets[assetType][assetName]
assert(asset ~= nil, assetName .. ' (' .. assetType .. ") doesn't exist") 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 end
function AssetElement:draw() function AssetElement:draw()

View file

@ -1,14 +1,13 @@
local Parent = require "birb.modules.gui.elements.parent" local Parent = require "birb.modules.gui.elements.parent"
local CanvasElement = Parent:extend() 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() self:initCanvas()
CanvasElement.super.new(self, name, x, y, w, h) CanvasElement.super.new(self, name, x, y, w, h)
self.r = r or 0 self.r = r or 0
self.sx, self.sy = sx or 1, sy or 1 self.sx, self.sy = sx or 1, sy or 1
self.ox, self.oy = self:parseOrigin(ox, w), self:parseOrigin(oy, h) self.ox, self.oy = self:parseOrigin(ox, w), self:parseOrigin(oy, h)
self.opacity = opacity or 1 self.opacity = opacity or 1
self.depth = depth or 0
end end
function CanvasElement:initCanvas() function CanvasElement:initCanvas()

View file

@ -28,6 +28,7 @@ function CompositeElement:update(dt)
childElement.x = self.x + child.relx childElement.x = self.x + child.relx
childElement.y = self.y + child.rely childElement.y = self.y + child.rely
childElement.isVisible = self.isVisible childElement.isVisible = self.isVisible
childElement.depth = self.depth
end end
end end

View file

@ -1,8 +1,8 @@
local Parent = require "birb.modules.gui.elements.variable" local Parent = require "birb.modules.gui.elements.variable"
local CounterElement = Parent:extend() local CounterElement = Parent:extend()
function CounterElement:new(name, fontName, object, varName, nbrs, 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, depth) CounterElement.super.new(self, name, fontName, object, varName, x, y, align)
self.nbrs = nbrs or 0 self.nbrs = nbrs or 0
end end

View file

@ -1,7 +1,7 @@
local Parent = require "birb.modules.gui.elements.parent" local Parent = require "birb.modules.gui.elements.parent"
local DrawableElement = Parent:extend() 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 self.drawable = drawable
local w, h = self.drawable:getDimensions() 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.sx, self.sy = sx or 1, sy or 1
self.ox, self.oy = self:parseOrigin(ox, w), self:parseOrigin(oy, h) self.ox, self.oy = self:parseOrigin(ox, w), self:parseOrigin(oy, h)
self.opacity = opacity or 1 self.opacity = opacity or 1
self.depth = depth or 0
end end
function DrawableElement:parseOrigin(origin, size) function DrawableElement:parseOrigin(origin, size)

View file

@ -1,14 +1,13 @@
local Parent = require "birb.modules.gui.elements.parent" local Parent = require "birb.modules.gui.elements.parent"
local TextElement = Parent:extend() 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 self.text = text
local gui = self:getGui() local gui = self:getGui()
self.font = gui.scene.assets.fonts[fontName] self.font = gui.scene.assets.fonts[fontName]
TextElement.super.new(self, name, x, y, 1, 1) TextElement.super.new(self, name, x, y, 1, 1)
self.align = align self.align = align
self.depth = depth or 0
end end
function TextElement:getText() function TextElement:getText()

View file

@ -1,8 +1,8 @@
local Parent = require "birb.modules.gui.elements.text" local Parent = require "birb.modules.gui.elements.text"
local VariableElement = Parent:extend() local VariableElement = Parent:extend()
function VariableElement:new(name, fontName, object, varName, x, y, align, depth) function VariableElement:new(name, fontName, object, varName, x, y, align)
VariableElement.super.new(self, name, fontName, "", x, y, align, depth) VariableElement.super.new(self, name, fontName, "", x, y, align)
self.object = object self.object = object
self.variable = varName self.variable = varName
end end