add Prompt
This commit is contained in:
35
main.lua
35
main.lua
@@ -62,6 +62,18 @@ function love.load()
|
||||
--love.audio.play(music.placeholder)
|
||||
end
|
||||
|
||||
function love.textinput(text)
|
||||
if Prompt.active_prompt then
|
||||
Prompt.active_prompt:textinput(text)
|
||||
end
|
||||
end
|
||||
|
||||
function love.keypressed(...)
|
||||
if Prompt.active_prompt then
|
||||
Prompt.active_prompt:keypressed(...)
|
||||
end
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
-- audio update
|
||||
love.audio.update()
|
||||
@@ -84,16 +96,31 @@ function love.update(dt)
|
||||
end
|
||||
logWrite("Second "..secs..": "..memoryUsage.." kB")
|
||||
end
|
||||
|
||||
if Prompt.active_prompt then
|
||||
Prompt.active_prompt:update()
|
||||
return
|
||||
end
|
||||
|
||||
if love.keyboard.isDown("f7") then
|
||||
local test_prompt = Prompt:new({
|
||||
name = "test prompt",
|
||||
func = function(prompt)
|
||||
print("test prompt got input: "..prompt.input)
|
||||
end,
|
||||
})
|
||||
test_prompt:activate()
|
||||
end
|
||||
|
||||
--keypressed
|
||||
if Keybind:CheckPressed(Keybind.menu.pause) then
|
||||
if do_pause then
|
||||
if do_pause then
|
||||
do_pause = false
|
||||
else
|
||||
menu_type = "pause"
|
||||
MenuInit(menu_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--MenuStep
|
||||
if menu_type ~= nil then MenuStep(menu_type) end
|
||||
@@ -133,6 +160,10 @@ function love.draw()
|
||||
love.graphics.print(game.scale,10,40)
|
||||
|
||||
if DemoRecording or DemoPlayback then Demo:draw() end
|
||||
|
||||
if Prompt.active_prompt then
|
||||
Prompt.active_prompt:draw()
|
||||
end
|
||||
|
||||
frameDebugFlush()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user