now there are spawn objects! now entity spawns are loaded from level! now entity spawns are saved to level!
147 lines
3.0 KiB
Lua
147 lines
3.0 KiB
Lua
function drawMenu(menu)
|
|
local font = love.graphics.getFont()
|
|
love.graphics.setFont(locale_font)
|
|
|
|
-- reset scale
|
|
love.graphics.setScale()
|
|
|
|
if menu == "pause" then
|
|
drawMenuPauseScreen()
|
|
elseif menu == "dialog" then
|
|
drawMenuDialog()
|
|
end
|
|
|
|
for _, element in pairs(UIElement) do
|
|
element:draw()
|
|
end
|
|
|
|
love.graphics.setFont(font)
|
|
end
|
|
|
|
function drawMenuPauseScreen()
|
|
-- Parameters
|
|
local pauseWidth = 640
|
|
local pauseHeight = 480
|
|
local pauseX = (game.width/2)-(pauseWidth/2)
|
|
local pauseY = (game.height/2)-(pauseHeight/2)
|
|
local mouse_x, mouse_y = love.mouse.getPosition()
|
|
-- Base items
|
|
love.graphics.setColor(0,0,0,0.3)
|
|
love.graphics.rectangle("fill", 0, 0, game.width, game.height)
|
|
love.graphics.setColor(1,1,1,1)
|
|
love.graphics.rectangle("fill", pauseX, pauseY, pauseWidth, pauseHeight)
|
|
end
|
|
|
|
function drawMenuDialog()
|
|
end
|
|
|
|
function stepMenu(menu)
|
|
-- first get mouse
|
|
local mouse_x, mouse_y = love.mouse.getPosition()
|
|
for _, element in pairs(UIElement) do
|
|
if element.type == "Button" then
|
|
element:checkMouse(mouse_x, mouse_y)
|
|
elseif element.type == "Dialog" then
|
|
element:checkConfirm()
|
|
end
|
|
end
|
|
if menu == 0 then
|
|
elseif menu == "pause" then
|
|
stepMenuPauseScreen()
|
|
elseif menu == "dialog" then
|
|
stepMenuDialog()
|
|
end
|
|
end
|
|
|
|
function stepMenuPauseScreen()
|
|
if pause_resume:getVariable() == true then
|
|
pause_resume = nil
|
|
pause_options = nil
|
|
pause_exit = nil
|
|
exitMenu()
|
|
elseif pause_exit:getVariable() == true then
|
|
love.event.quit()
|
|
end
|
|
end
|
|
|
|
function stepMenuDialog()
|
|
if dialog_container.value >= dialog_container.target_value then
|
|
dialog_container = nil
|
|
exitMenu()
|
|
end
|
|
end
|
|
|
|
function clearMenu()
|
|
for _, element in pairs(UIElement) do
|
|
element = nil
|
|
end
|
|
UIElement = {}
|
|
end
|
|
|
|
function exitMenu(to)
|
|
clearMenu()
|
|
local to = to or "no"
|
|
menu_type = to
|
|
end
|
|
|
|
function initMenu(menu,parameter)
|
|
-- main menu
|
|
if menu == "pause" then
|
|
initMenuPauseScreen()
|
|
elseif menu == "dialog" then
|
|
if parameter == nil then
|
|
parameter = dialog_sequence.Example
|
|
end
|
|
initMenuDialog(parameter)
|
|
end
|
|
end
|
|
|
|
function initMenuDialog(parameter)
|
|
dialog_container = InterfaceDialog:new()
|
|
dialog_container:loadSequence(parameter)
|
|
end
|
|
|
|
function initMenuPauseScreen()
|
|
local button_standard = {width = 200, height = 30, separation = 10}
|
|
-- elements
|
|
pause_resume = InterfaceButton:new(
|
|
game.width/2,
|
|
game.height/2-button_standard.height-button_standard.separation,
|
|
button_standard.width,
|
|
button_standard.height,
|
|
{false,true},
|
|
1,
|
|
{
|
|
text = locale.ui.pause_screen_resume,
|
|
color = {0,0,0.5},
|
|
color2 = {1,1,1}
|
|
}
|
|
)
|
|
pause_options = InterfaceButton:new(
|
|
game.width/2,
|
|
game.height/2,
|
|
button_standard.width,
|
|
button_standard.height,
|
|
{false,true},
|
|
1,
|
|
{
|
|
text = locale.ui.pause_screen_options,
|
|
color = {0,0,0.5},
|
|
color2 = {1,1,1}
|
|
}
|
|
)
|
|
pause_exit = InterfaceButton:new(
|
|
game.width/2,
|
|
game.height/2+button_standard.height+button_standard.separation,
|
|
button_standard.width,
|
|
button_standard.height,
|
|
{false,true},
|
|
1,
|
|
{
|
|
text = locale.ui.pause_screen_exit,
|
|
color = {0,0,0.5},
|
|
color2 = {1,1,1}
|
|
}
|
|
)
|
|
end
|