function drawMenu(menu) local font = love.graphics.getFont() love.graphics.setFont(LocaleFont) -- 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 PauseResume:getVariable() == true then PauseResume = nil PauseOptions = nil PauseExit = nil exitMenu() elseif PauseExit:getVariable() == true then love.event.quit() end end function stepMenuDialog() if DialogContainer.value >= DialogContainer.target_value then DialogContainer = 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 = DialogSequence.Example end initMenuDialog(parameter) end end function initMenuDialog(parameter) DialogContainer = interfaceDialog:new() DialogContainer:loadSequence(parameter) end function initMenuPauseScreen() local buttonStandard = {width = 200, height = 30, separation = 10} -- elements PauseResume = InterfaceButton:new( game.width/2, game.height/2-buttonStandard.height-buttonStandard.separation, buttonStandard.width, buttonStandard.height, {false,true}, 1, { text = Locale.ui.pause_screen_resume, color = {0,0,0.5}, color2 = {1,1,1} } ) PauseOptions = InterfaceButton:new( game.width/2, game.height/2, buttonStandard.width, buttonStandard.height, {false,true}, 1, { text = Locale.ui.pause_screen_options, color = {0,0,0.5}, color2 = {1,1,1} } ) PauseExit = InterfaceButton:new( game.width/2, game.height/2+buttonStandard.height+buttonStandard.separation, buttonStandard.width, buttonStandard.height, {false,true}, 1, { text = Locale.ui.pause_screen_exit, color = {0,0,0.5}, color2 = {1,1,1} } ) end