2021-04-25 16:28:31 +02:00
|
|
|
local QtePrompts = Object:extend()
|
2021-08-15 16:34:36 +02:00
|
|
|
local Button = require "scenes.battlesystem.choregraphy.qte.prompts.button"
|
2021-04-25 16:28:31 +02:00
|
|
|
|
|
|
|
QtePrompts.BEGINTIME = 0.2
|
|
|
|
|
|
|
|
function QtePrompts:new(qte)
|
|
|
|
self.qte = qte
|
|
|
|
self.canPress = true
|
|
|
|
self.removeWhenPressed = true
|
|
|
|
self.assets = qte.choregraphy.assets
|
|
|
|
self.scene = core.scenemanager.currentScene
|
|
|
|
self.current = 1
|
2021-05-08 18:39:40 +02:00
|
|
|
self.defaultTimerValue = 1
|
2021-04-25 16:28:31 +02:00
|
|
|
|
|
|
|
self.list = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
function QtePrompts:add(key, number)
|
|
|
|
table.insert(self.list, Button(self, key, number, QtePrompts.BEGINTIME))
|
|
|
|
end
|
|
|
|
|
|
|
|
function QtePrompts:getTimer()
|
2021-05-08 18:39:40 +02:00
|
|
|
local defaultValue = self.defaultTimerValue
|
2021-04-25 16:28:31 +02:00
|
|
|
local _, _, timerValue = self.qte:getTimerInfo()
|
|
|
|
return timerValue or defaultValue
|
|
|
|
end
|
|
|
|
|
|
|
|
function QtePrompts:update(dt)
|
|
|
|
for i, button in ipairs(self.list) do
|
|
|
|
button:update(dt, (i == self.current))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function QtePrompts:verifyPrompts()
|
|
|
|
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)
|
|
|
|
if (not self.canPress and buttonValue == 1) then
|
|
|
|
buttonValue = -1
|
|
|
|
end
|
|
|
|
if (mustBeRemoved) then
|
2021-05-08 18:39:40 +02:00
|
|
|
self.list[self.current]:finish(true)
|
2021-04-25 16:28:31 +02:00
|
|
|
self.current = self.current + 1
|
|
|
|
end
|
|
|
|
end
|
2021-05-08 18:39:40 +02:00
|
|
|
for i, button in ipairs(self.list) do
|
|
|
|
if (buttonValue == -1 and (i ~= self.current)) then
|
|
|
|
button:finish(false)
|
|
|
|
end
|
|
|
|
end
|
2021-04-25 16:28:31 +02:00
|
|
|
return buttonValue
|
|
|
|
end
|
|
|
|
|
|
|
|
function QtePrompts:isOver()
|
|
|
|
return (self.current > #self.list)
|
|
|
|
end
|
|
|
|
|
|
|
|
function QtePrompts:draw(x, y)
|
|
|
|
local SIZE = 20
|
|
|
|
for i, button in ipairs(self.list) do
|
|
|
|
button:draw(x + (SIZE*(i-1)) - ((SIZE/2)*(#self.list-1)), y, (i == self.current))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return QtePrompts
|