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
5 changed files with 29 additions and 44 deletions
Showing only changes of commit 3c8a3ed312 - Show all commits

View file

@ -31,7 +31,6 @@ function ChoregraphySystem:new(action, choregraphy, subChoregraphy)
end
function ChoregraphySystem:update(dt)
self:updateQte(dt)
self:updateSteps(dt)
self.tweens:update(dt)
self:updateSubChoregraphies(dt)
@ -49,9 +48,4 @@ function ChoregraphySystem:endChoregraphy()
self.fighter.turnSystem:applyDeath()
end
function ChoregraphySystem:draw()
self:drawQte()
self:drawSubChoregraphies()
end
return ChoregraphySystem

View file

@ -1,18 +1,23 @@
local QteParent = Object:extend()
local GuiElements = require "birb.modules.gui.elements.parent"
local QteParent = GuiElements:extend()
local TweenManager = require "birb.classes.time"
local Prompts = require "scenes.battlesystem.choregraphy.qte.prompts"
function QteParent:new(choregraphySystem, arguments)
self.choregraphy = choregraphySystem
self.arguments = arguments
self.tweens = TweenManager(self)
self.isBlocking = nil
self.prompts = Prompts(self)
self.timer = 0
self.timerActive = false
self.isSuccess = false
self.tag = ""
QteParent.super.new(self, "qte", -1, -1, 1, 1)
self:start()
self.isStarted = true
self:getFocus()
end
function QteParent:setTag(tag)
@ -60,18 +65,13 @@ function QteParent:setOrigin(origin)
end
end
function QteParent:updateQte(dt, isActive)
if (not self.isStarted) then
self:start()
self.isStarted = true
else
self:update(dt)
self.tweens:update(dt)
self.prompts:update(dt)
if (isActive) then
self:verifyPrompts()
end
end
function QteParent:updateElement(dt)
QteParent.super.updateElement(self, dt)
self.prompts:update(dt)
end
function QteParent:keypressed(key)
self:verifyPrompts(key)
end
function QteParent:timerResponse(timer)
@ -87,6 +87,7 @@ function QteParent:timerResponse(timer)
self.prompts.defaultTimerValue = 0
elseif (timer == "endQte") then
self.choregraphy:removeQte()
self:destroy()
end
end
@ -97,8 +98,8 @@ function QteParent:finish(success)
self:endQte()
end
function QteParent:verifyPrompts()
local promptResult = self.prompts:verifyPrompts()
function QteParent:verifyPrompts(key)
local promptResult = self.prompts:verifyPrompts(key)
if (promptResult == 1) then
self:promptSuccess()
elseif (promptResult == -1) then

View file

@ -69,24 +69,21 @@ function Button:update(dt, isFirst)
love.graphics.arc("fill", CANVAS_SIZE/2, CANVAS_SIZE/2, BTN_SIZE/2, 0 - (math.pi/2), ((math.pi*2*self.prompt:getTimer()) - (math.pi/2)), 16)
love.graphics.setStencilTest()
love.graphics.setCanvas()
utils.graphics.resetColor()
end
end
function Button:verifyPrompts(sourceKeys, removeWhenPressed)
function Button:verifyPrompts(key, removeWhenPressed)
local mustBeRemoved = false
local keyValue = 0
self.lum = 1
for i, key in ipairs(keys) do
if (sourceKeys[key].isPressed) then
if (key == self.key) then
keyValue = 1
self.lum = 0.8
table.insert(self.circles, ButtonCircle())
else
keyValue = -1
self.isFailed = true
end
end
if (key == self.key) then
keyValue = 1
self.lum = 0.8
table.insert(self.circles, ButtonCircle())
else
keyValue = -1
self.isFailed = true
end
if (removeWhenPressed and keyValue == 1) then
self.number = self.number - 1

View file

@ -31,11 +31,10 @@ function QtePrompts:update(dt)
end
end
function QtePrompts:verifyPrompts()
function QtePrompts:verifyPrompts(key)
local buttonValue, mustBeRemoved = 0, false
if (self.list[self.current] ~= nil) then
local keys = self.scene.sources[1].keys
buttonValue, mustBeRemoved = self.list[self.current]:verifyPrompts(keys, self.removeWhenPressed)
buttonValue, mustBeRemoved = self.list[self.current]:verifyPrompts(key, self.removeWhenPressed)
if (not self.canPress and buttonValue == 1) then
buttonValue = -1
end

View file

@ -53,10 +53,4 @@ function ActionParent:finishAction()
self.fighter:finishAction()
end
function ActionParent:draw()
if (self.choregraphy ~= nil) then
self.choregraphy:draw()
end
end
return ActionParent