local ConfigScene = SCENE:extend() ConfigScene.title = "Input Config" local menu_screens = { KeyConfigScene, StickConfigScene, TouchConfigScene } local buttonList function ConfigScene:new(first_time) buttonList = { BUTTON.new{ text = "1", font = FONT_big, x = 75, y = 160, w = 40, h = 40, codeWhenReleased = function() if self.menu_state ~= 1 then self.menu_state = 1 else SCENE = KeyConfigScene() end end }, BUTTON.new{ text = "2", font = FONT_big, x = 75, y = 200, w = 40, h = 40, codeWhenReleased = function() if self.menu_state ~= 2 then self.menu_state = 2 else SCENE = StickConfigScene() end end }, BUTTON.new{ text = "3", font = FONT_big, x = 75, y = 240, w = 40, h = 40, codeWhenReleased = function() if self.menu_state ~= 3 then self.menu_state = 3 else SCENE = TouchConfigScene() end end } } self.menu_state = 1 if first_time then self.first_time = true else self.first_time = false end end function ConfigScene:update() end function ConfigScene:render() MainBackground() if not self.first_time then drawText("Which controls do you want to configure?", 80, 70, 1000) else drawText("Thanks for playing Tromi!", 80, 40, 1000) drawText("Please begin by configuring your controls:", 80, 70, 1000) end love.graphics.setColor(1, 1, 1, 0.5) love.graphics.rectangle("fill", 75, 120 + 40 * self.menu_state, 300, 40) love.graphics.setColor(1, 1, 1, 1) for i, screen in pairs(menu_screens) do drawText(screen.title, 130, 130 + 40 * i, 300, "left") end BUTTON.draw(buttonList) end function ConfigScene:changeOption(rel) local len = #menu_screens self.menu_state = (self.menu_state + len + rel - 1) % len + 1 end function ConfigScene:onInputMove(e) if e.type == "mouse" then BUTTON.checkHovering(buttonList, e.x, e.y) end end function ConfigScene:onInputPress(e) if e.type == "touch" or e.type == "mouse" then BUTTON.press(buttonList, e.x, e.y, e.id) elseif e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then SCENE = menu_screens[self.menu_state]() elseif e.input == "up" or e.scancode == "up" then self:changeOption(-1) elseif e.input == "down" or e.scancode == "down" then self:changeOption(1) elseif not SETTINGS.firstTime and ( e.input == "menu_back" or e.input == "rotate_right" or e.scancode == "backspace" or e.scancode == "delete" ) then SCENE = TitleScene() end end function ConfigScene:onInputRelease(e) if e.type == "touch" or e.type == "mouse" then BUTTON.release(buttonList, e.x, e.y, e.id) end end return ConfigScene