diff --git a/scene/mode_select.lua b/scene/mode_select.lua index f4d4c7d..d82b176 100755 --- a/scene/mode_select.lua +++ b/scene/mode_select.lua @@ -6,6 +6,22 @@ current_mode = 1 current_ruleset = 1 function ModeSelectScene:new() + -- reload custom modules + initModules() + if table.getn(game_modes) == 0 or table.getn(rulesets) == 0 then + self.display_warning = true + current_mode = 1 + current_ruleset = 1 + else + self.display_warning = false + if current_mode > table.getn(game_modes) then + current_mode = 1 + end + if current_ruleset > table.getn(rulesets) then + current_ruleset = 1 + end + end + self.menu_state = { mode = current_mode, ruleset = current_ruleset, @@ -19,6 +35,7 @@ function ModeSelectScene:new() rotate_180 = false, hold = false, } + self.das = 0 DiscordRPC:update({ details = "In menus", state = "Choosing a mode", @@ -27,6 +44,17 @@ end function ModeSelectScene:update() switchBGM(nil) -- experimental + + if self.das_up or self.das_down then + self.das = self.das + 1 + else + self.das = 0 + end + + if self.das >= 24 then + self:changeOption(self.das_up and -1 or 1) + self.das = self.das * 0.75 + end end function ModeSelectScene:render() @@ -36,6 +64,23 @@ function ModeSelectScene:render() 0.5, 0.5 ) + love.graphics.draw(misc_graphics["select_mode"], 20, 40) + + if self.display_warning then + love.graphics.setFont(font_3x5_3) + love.graphics.printf( + "You have no modes or rulesets.", + 80, 200, 480, "center" + ) + love.graphics.setFont(font_3x5_2) + love.graphics.printf( + "Come back to this menu after getting more modes or rulesets. " .. + "Press any button to return to the main menu.", + 80, 250, 480, "center" + ) + return + end + if self.menu_state.select == "mode" then love.graphics.setColor(1, 1, 1, 0.5) elseif self.menu_state.select == "ruleset" then @@ -52,8 +97,6 @@ function ModeSelectScene:render() love.graphics.setColor(1, 1, 1, 1) - love.graphics.draw(misc_graphics["select_mode"], 20, 40) - love.graphics.setFont(font_3x5_2) for idx, mode in pairs(game_modes) do if(idx >= self.menu_state.mode-9 and idx <= self.menu_state.mode+9) then @@ -68,23 +111,37 @@ function ModeSelectScene:render() end function ModeSelectScene:onInputPress(e) - if e.input == "menu_decide" or e.scancode == "return" then + if self.display_warning and e.input then + scene = TitleScene() + elseif e.type == "wheel" then + if e.x % 2 == 1 then + self:switchSelect() + end + if e.y ~= 0 then + self:changeOption(-e.y) + end + elseif e.input == "menu_decide" or e.scancode == "return" then current_mode = self.menu_state.mode current_ruleset = self.menu_state.ruleset config.current_mode = current_mode config.current_ruleset = current_ruleset playSE("mode_decide") saveConfig() - scene = GameScene(game_modes[self.menu_state.mode], rulesets[self.menu_state.ruleset], self.secret_inputs) + scene = GameScene( + game_modes[self.menu_state.mode], + rulesets[self.menu_state.ruleset], + self.secret_inputs + ) elseif e.input == "up" or e.scancode == "up" then self:changeOption(-1) - playSE("cursor") + self.das_up = true + self.das_down = nil elseif e.input == "down" or e.scancode == "down" then self:changeOption(1) - playSE("cursor") + self.das_down = true + self.das_up = nil elseif e.input == "left" or e.input == "right" or e.scancode == "left" or e.scancode == "right" then self:switchSelect() - playSE("cursor_lr") elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then scene = TitleScene() elseif e.input then @@ -95,6 +152,10 @@ end function ModeSelectScene:onInputRelease(e) if e.input == "hold" or (e.input and string.sub(e.input, 1, 7) == "rotate_") then self.secret_inputs[e.input] = false + elseif e.input == "up" or e.scancode == "up" then + self.das_up = nil + elseif e.input == "down" or e.scancode == "down" then + self.das_down = nil end end @@ -104,24 +165,26 @@ function ModeSelectScene:changeOption(rel) elseif self.menu_state.select == "ruleset" then self:changeRuleset(rel) end + playSE("cursor") end -function ModeSelectScene:switchSelect(rel) +function ModeSelectScene:switchSelect() if self.menu_state.select == "mode" then self.menu_state.select = "ruleset" elseif self.menu_state.select == "ruleset" then self.menu_state.select = "mode" end + playSE("cursor_lr") end function ModeSelectScene:changeMode(rel) local len = table.getn(game_modes) - self.menu_state.mode = (self.menu_state.mode + len + rel - 1) % len + 1 + self.menu_state.mode = Mod1(self.menu_state.mode + rel, len) end function ModeSelectScene:changeRuleset(rel) local len = table.getn(rulesets) - self.menu_state.ruleset = (self.menu_state.ruleset + len + rel - 1) % len + 1 + self.menu_state.ruleset = Mod1(self.menu_state.ruleset + rel, len) end return ModeSelectScene