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
2 changed files with 58 additions and 0 deletions
Showing only changes of commit 205028718a - Show all commits

View file

@ -0,0 +1,52 @@
local CanvasElement = require "birb.modules.gui.elements.parent"
local ActionPrompt = CanvasElement:extend()
function ActionPrompt:new()
self.text = ""
ActionPrompt.super.new(self, "actionPrompt", 0, 0, 424, 240)
self.depth = -2
self.opacity = 0
self.isShown = false
end
function ActionPrompt:setText(text)
if (utils.string.isEmpty(text)) then
self:hide()
else
self.text = text
self:show()
end
end
function ActionPrompt:hide()
if (self.isShown) then
self.tweens.tweens = {}
self:newTween(0.0, 0.6, {opacity = 0}, "outExpo")
end
self.isShown = false
end
function ActionPrompt:show()
if (not self.isShown) then
self.tweens.tweens = {}
self:newTween(0.0, 0.6, {opacity = 1}, "outExpo")
end
self.isShown = true
end
function ActionPrompt:draw()
if (not utils.string.isEmpty(self.text)) then
local w = self.assets.fonts["small"]:getWidth(self.text) + 16
love.graphics.setColor(0,0,0,0.5 * self.opacity)
local x, y = 424 - w/2 - 4, 240 - 20
love.graphics.rectangle("fill", x - w/2, y + 1, w, 15, 8, 8)
love.graphics.setColor(1, 1, 1, self.opacity)
self.assets.fonts["small"]:setColor(1, 1, 1, self.opacity)
self.assets.fonts["small"]:draw(self.text, x, y, -1, "center")
self.assets.fonts["small"]:setColor(1, 1, 1, 1)
utils.graphics.resetColor()
end
end
return ActionPrompt

View file

@ -3,6 +3,7 @@ local RadianceScene = BirbScene:extend()
local Overlay = require "game.modules.gui.overlay"
local MessageQueue = require "game.modules.messagequeue"
local ActionPrompt = require "game.modules.gui.actionPrompt"
function RadianceScene:new(haveBorder, showVersion)
RadianceScene.super.new(self)
@ -18,6 +19,7 @@ function RadianceScene:new(haveBorder, showVersion)
Overlay(haveBorder, showVersion)
MessageQueue(self)
ActionPrompt()
end
function RadianceScene:hideOverlay()
@ -28,6 +30,10 @@ function RadianceScene:showMessage(message)
self.gui.elements["messageQueue"]:addMessage(message)
end
function RadianceScene:setPrompt(message)
self.gui.elements["actionPrompt"]:setText(message)
end
function RadianceScene:showOverlay(darken)
self.gui:showScreen("overlay")
if (darken) then