function MenuDraw(menu) -- Set scale to 1 love.graphics.scale(0.5,0.5) if menu == "pauseMenu" then -- 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) -- Reset scale end for _, element in pairs(UIElement) do element:Draw() end love.graphics.scale(2,2) end function MenuStep(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 == "pauseMenu" then if PauseResume:getVariable() == true then MenuExit(menu,0) do_pause = false elseif PauseExit:getVariable() == true then love.event.quit() end else for name, dialogbox in pairs(dialogboxes) do if name == menu then if dialogbox.object:getVariable() then MenuExit(dialogbox.exit[1],dialogbox.exit[2]) end end end end end function MenuExit(from,to) for _, element in pairs(UIElement) do element = nil end UIElement = {} if from == "pauseMenu" then PauseResume = nil PauseOptions = nil PauseExit = nil else for name, dialogbox in pairs(dialogboxes) do if name == menu then dialogbox.object = nil end end end menuPage = to or nil end function MenuInit(menu) local buttonStandard = {width = 200, height = 30, separation = 10} -- main menu if menu == "pauseMenu" then -- 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} } ) else for name, dialogbox in pairs(dialogboxes) do if name == menu then dialogbox.object = interfaceDialog:New(dialogbox.style) end end end end UIElement = {} require "data/scripts/ui/button" require "data/scripts/ui/dialog" require "data/scripts/ui/dialogboxes"