2019-05-22 22:57:34 -05:00
|
|
|
local ModeSelectScene = Scene:extend()
|
|
|
|
|
|
|
|
ModeSelectScene.title = "Game Start"
|
|
|
|
|
|
|
|
current_mode = 1
|
|
|
|
current_ruleset = 1
|
|
|
|
|
|
|
|
function ModeSelectScene:new()
|
2021-09-16 13:54:49 -05:00
|
|
|
-- 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
|
|
|
|
|
2019-05-22 22:57:34 -05:00
|
|
|
self.menu_state = {
|
|
|
|
mode = current_mode,
|
|
|
|
ruleset = current_ruleset,
|
|
|
|
select = "mode",
|
|
|
|
}
|
2021-09-30 22:07:03 -05:00
|
|
|
self.secret_inputs = {}
|
2021-09-16 13:54:49 -05:00
|
|
|
self.das = 0
|
2020-10-10 20:17:48 -05:00
|
|
|
DiscordRPC:update({
|
2020-11-06 19:49:44 -06:00
|
|
|
details = "In menus",
|
|
|
|
state = "Choosing a mode",
|
2021-09-26 14:30:37 -05:00
|
|
|
largeImageKey = "ingame-000"
|
2020-11-06 19:49:44 -06:00
|
|
|
})
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function ModeSelectScene:update()
|
2020-12-20 14:08:53 -06:00
|
|
|
switchBGM(nil) -- experimental
|
2021-09-16 13:54:49 -05:00
|
|
|
|
|
|
|
if self.das_up or self.das_down then
|
|
|
|
self.das = self.das + 1
|
|
|
|
else
|
|
|
|
self.das = 0
|
|
|
|
end
|
|
|
|
|
2021-09-16 17:05:38 -05:00
|
|
|
if self.das >= 15 then
|
2021-09-16 13:54:49 -05:00
|
|
|
self:changeOption(self.das_up and -1 or 1)
|
2021-09-16 17:05:38 -05:00
|
|
|
self.das = self.das - 4
|
2021-09-16 13:54:49 -05:00
|
|
|
end
|
2021-09-26 21:26:52 -05:00
|
|
|
|
|
|
|
DiscordRPC:update({
|
|
|
|
details = "In menus",
|
|
|
|
state = "Choosing a " .. self.menu_state.select,
|
|
|
|
largeImageKey = "ingame-000"
|
|
|
|
})
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function ModeSelectScene:render()
|
|
|
|
love.graphics.draw(
|
|
|
|
backgrounds[0],
|
|
|
|
0, 0, 0,
|
|
|
|
0.5, 0.5
|
|
|
|
)
|
2020-12-05 15:56:12 -06:00
|
|
|
|
2021-09-16 13:54:49 -05:00
|
|
|
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
|
|
|
|
|
2019-05-22 22:57:34 -05:00
|
|
|
if self.menu_state.select == "mode" then
|
|
|
|
love.graphics.setColor(1, 1, 1, 0.5)
|
|
|
|
elseif self.menu_state.select == "ruleset" then
|
|
|
|
love.graphics.setColor(1, 1, 1, 0.25)
|
|
|
|
end
|
2020-11-02 21:47:58 -06:00
|
|
|
love.graphics.rectangle("fill", 20, 258, 240, 22)
|
2019-05-22 22:57:34 -05:00
|
|
|
|
|
|
|
if self.menu_state.select == "mode" then
|
|
|
|
love.graphics.setColor(1, 1, 1, 0.25)
|
|
|
|
elseif self.menu_state.select == "ruleset" then
|
|
|
|
love.graphics.setColor(1, 1, 1, 0.5)
|
|
|
|
end
|
2020-11-02 21:47:58 -06:00
|
|
|
love.graphics.rectangle("fill", 340, 258, 200, 22)
|
2020-10-09 16:50:05 -05:00
|
|
|
|
2019-05-22 22:57:34 -05:00
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
|
|
|
|
love.graphics.setFont(font_3x5_2)
|
|
|
|
for idx, mode in pairs(game_modes) do
|
2020-11-02 21:47:58 -06:00
|
|
|
if(idx >= self.menu_state.mode-9 and idx <= self.menu_state.mode+9) then
|
|
|
|
love.graphics.printf(mode.name, 40, (260 - 20*(self.menu_state.mode)) + 20 * idx, 200, "left")
|
|
|
|
end
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
for idx, ruleset in pairs(rulesets) do
|
2020-11-02 21:47:58 -06:00
|
|
|
if(idx >= self.menu_state.ruleset-9 and idx <= self.menu_state.ruleset+9) then
|
|
|
|
love.graphics.printf(ruleset.name, 360, (260 - 20*(self.menu_state.ruleset)) + 20 * idx, 160, "left")
|
|
|
|
end
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-08 14:55:06 -06:00
|
|
|
function ModeSelectScene:onInputPress(e)
|
2021-09-16 13:54:49 -05:00
|
|
|
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
|
2021-10-21 19:52:42 -05:00
|
|
|
elseif e.input == "menu_decide" or e.scancode == "return" then
|
2019-05-22 22:57:34 -05:00
|
|
|
current_mode = self.menu_state.mode
|
|
|
|
current_ruleset = self.menu_state.ruleset
|
|
|
|
config.current_mode = current_mode
|
|
|
|
config.current_ruleset = current_ruleset
|
2020-10-09 16:50:05 -05:00
|
|
|
playSE("mode_decide")
|
2019-05-22 22:57:34 -05:00
|
|
|
saveConfig()
|
2021-09-16 13:54:49 -05:00
|
|
|
scene = GameScene(
|
|
|
|
game_modes[self.menu_state.mode],
|
|
|
|
rulesets[self.menu_state.ruleset],
|
|
|
|
self.secret_inputs
|
|
|
|
)
|
2021-10-21 19:52:42 -05:00
|
|
|
elseif e.input == "up" or e.scancode == "up" then
|
2019-05-22 22:57:34 -05:00
|
|
|
self:changeOption(-1)
|
2021-09-16 13:54:49 -05:00
|
|
|
self.das_up = true
|
|
|
|
self.das_down = nil
|
2021-10-21 19:52:42 -05:00
|
|
|
elseif e.input == "down" or e.scancode == "down" then
|
2019-05-22 22:57:34 -05:00
|
|
|
self:changeOption(1)
|
2021-09-16 13:54:49 -05:00
|
|
|
self.das_down = true
|
|
|
|
self.das_up = nil
|
2021-10-21 19:52:42 -05:00
|
|
|
elseif e.input == "left" or e.input == "right" or e.scancode == "left" or e.scancode == "right" then
|
2019-05-22 22:57:34 -05:00
|
|
|
self:switchSelect()
|
2021-10-21 19:52:42 -05:00
|
|
|
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
2020-11-06 19:49:44 -06:00
|
|
|
scene = TitleScene()
|
2021-01-08 12:59:42 -06:00
|
|
|
elseif e.input then
|
2021-01-05 20:59:50 -06:00
|
|
|
self.secret_inputs[e.input] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function ModeSelectScene:onInputRelease(e)
|
2021-10-21 19:52:42 -05:00
|
|
|
if e.input == "up" or e.scancode == "up" then
|
2021-09-16 13:54:49 -05:00
|
|
|
self.das_up = nil
|
2021-10-21 19:52:42 -05:00
|
|
|
elseif e.input == "down" or e.scancode == "down" then
|
2021-09-16 13:54:49 -05:00
|
|
|
self.das_down = nil
|
2021-09-30 22:07:03 -05:00
|
|
|
elseif e.input then
|
|
|
|
self.secret_inputs[e.input] = false
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function ModeSelectScene:changeOption(rel)
|
|
|
|
if self.menu_state.select == "mode" then
|
|
|
|
self:changeMode(rel)
|
|
|
|
elseif self.menu_state.select == "ruleset" then
|
|
|
|
self:changeRuleset(rel)
|
|
|
|
end
|
2021-09-16 13:54:49 -05:00
|
|
|
playSE("cursor")
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
2021-09-16 13:54:49 -05:00
|
|
|
function ModeSelectScene:switchSelect()
|
2019-05-22 22:57:34 -05:00
|
|
|
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
|
2021-09-16 13:54:49 -05:00
|
|
|
playSE("cursor_lr")
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function ModeSelectScene:changeMode(rel)
|
|
|
|
local len = table.getn(game_modes)
|
2021-09-16 13:54:49 -05:00
|
|
|
self.menu_state.mode = Mod1(self.menu_state.mode + rel, len)
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function ModeSelectScene:changeRuleset(rel)
|
|
|
|
local len = table.getn(rulesets)
|
2021-09-16 13:54:49 -05:00
|
|
|
self.menu_state.ruleset = Mod1(self.menu_state.ruleset + rel, len)
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
return ModeSelectScene
|