2020-10-10 18:42:56 -05:00
|
|
|
local ConfigScene = Scene:extend()
|
|
|
|
|
|
|
|
ConfigScene.title = "Game Settings"
|
|
|
|
|
|
|
|
require 'load.save'
|
2020-12-20 08:45:49 -06:00
|
|
|
require 'libs.simple-slider'
|
2020-10-10 18:42:56 -05:00
|
|
|
|
|
|
|
ConfigScene.options = {
|
2020-11-08 15:19:01 -06:00
|
|
|
-- this serves as reference to what the options' values mean i guess?
|
2020-12-22 13:43:59 -06:00
|
|
|
-- Format: {name in config, displayed name, uses slider?, options OR slider name}
|
|
|
|
{"manlock", "Manual Locking", false, {"Per ruleset", "Per gamemode", "Harddrop", "Softdrop"}},
|
|
|
|
{"piece_colour", "Piece Colours", false, {"Per ruleset", "Arika", "TTC"}},
|
|
|
|
{"world_reverse", "A Button Rotation", false, {"Left", "Auto", "Right"}},
|
2021-02-08 22:23:50 -06:00
|
|
|
{"spawn_positions", "Spawn Positions", false, {"Per ruleset", "In field", "Out of field"}},
|
2020-12-22 13:43:59 -06:00
|
|
|
{"display_gamemode", "Display Gamemode", false, {"On", "Off"}},
|
|
|
|
{"das_last_key", "DAS Switch", false, {"Default", "Instant"}},
|
|
|
|
{"smooth_movement", "Smooth Piece Drop", false, {"On", "Off"}},
|
|
|
|
{"synchroes_allowed", "Synchroes", false, {"Per ruleset", "On", "Off"}},
|
|
|
|
{"diagonal_input", "Diagonal Input", false, {"On", "Off"}},
|
2021-01-06 15:06:17 -06:00
|
|
|
{"buffer_lock", "Buffer Lock Inputs", false, {"On", "Off"}},
|
2020-12-22 13:43:59 -06:00
|
|
|
{"sfx_volume", "SFX", true, "sfxSlider"},
|
|
|
|
{"bgm_volume", "BGM", true, "bgmSlider"},
|
2020-10-10 18:42:56 -05:00
|
|
|
}
|
|
|
|
local optioncount = #ConfigScene.options
|
|
|
|
|
|
|
|
function ConfigScene:new()
|
|
|
|
-- load current config
|
|
|
|
self.config = config.input
|
|
|
|
self.highlight = 1
|
2020-11-06 19:49:44 -06:00
|
|
|
|
2020-10-10 20:17:48 -05:00
|
|
|
DiscordRPC:update({
|
2020-11-06 19:49:44 -06:00
|
|
|
details = "In menus",
|
|
|
|
state = "Changing game settings",
|
|
|
|
})
|
2020-12-20 08:45:49 -06:00
|
|
|
|
2021-01-12 12:47:03 -06:00
|
|
|
self.sfxSlider = newSlider(165, 400, 225, config.sfx_volume * 100, 0, 100, function(v) config.sfx_volume = v / 100 end, {width=20, knob="circle", track="roundrect"})
|
|
|
|
self.bgmSlider = newSlider(465, 400, 225, config.bgm_volume * 100, 0, 100, function(v) config.bgm_volume = v / 100 end, {width=20, knob="circle", track="roundrect"})
|
2020-10-10 18:42:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function ConfigScene:update()
|
2020-12-02 20:09:52 -06:00
|
|
|
config["das_last_key"] = config.gamesettings.das_last_key == 2
|
2020-12-20 08:45:49 -06:00
|
|
|
self.sfxSlider:update()
|
2020-12-20 14:26:32 -06:00
|
|
|
self.bgmSlider:update()
|
2020-10-10 18:42:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function ConfigScene:render()
|
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
love.graphics.draw(
|
|
|
|
backgrounds["game_config"],
|
|
|
|
0, 0, 0,
|
|
|
|
0.5, 0.5
|
|
|
|
)
|
2020-12-20 14:26:32 -06:00
|
|
|
|
2020-10-10 18:42:56 -05:00
|
|
|
love.graphics.setFont(font_3x5_4)
|
2020-11-06 19:49:44 -06:00
|
|
|
love.graphics.print("GAME SETTINGS", 80, 40)
|
|
|
|
|
2020-12-22 13:43:59 -06:00
|
|
|
--Lazy check to see if we're on the SFX or BGM slider. Probably will need to be rewritten if more options get added.
|
2020-10-10 18:42:56 -05:00
|
|
|
love.graphics.setColor(1, 1, 1, 0.5)
|
2020-12-22 13:43:59 -06:00
|
|
|
if not ConfigScene.options[self.highlight][3] then
|
2021-01-06 15:06:17 -06:00
|
|
|
love.graphics.rectangle("fill", 25, 98 + self.highlight * 20, 170, 22)
|
2020-12-22 13:43:59 -06:00
|
|
|
else
|
2021-01-12 12:47:03 -06:00
|
|
|
love.graphics.rectangle("fill", 65 + (1+self.highlight-#self.options) * 300, 342, 215, 33)
|
2020-12-22 13:43:59 -06:00
|
|
|
end
|
2020-11-06 19:49:44 -06:00
|
|
|
|
2020-10-10 18:42:56 -05:00
|
|
|
love.graphics.setFont(font_3x5_2)
|
|
|
|
for i, option in ipairs(ConfigScene.options) do
|
2020-12-22 13:43:59 -06:00
|
|
|
if not option[3] then
|
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
love.graphics.printf(option[2], 40, 100 + i * 20, 150, "left")
|
|
|
|
for j, setting in ipairs(option[4]) do
|
|
|
|
love.graphics.setColor(1, 1, 1, config.gamesettings[option[1]] == j and 1 or 0.5)
|
|
|
|
love.graphics.printf(setting, 100 + 110 * j, 100 + i * 20, 100, "center")
|
|
|
|
end
|
2020-11-06 19:49:44 -06:00
|
|
|
end
|
2020-10-10 18:42:56 -05:00
|
|
|
end
|
2020-12-20 14:26:32 -06:00
|
|
|
|
2020-12-22 13:43:59 -06:00
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
love.graphics.setFont(font_3x5_3)
|
2021-01-12 12:47:03 -06:00
|
|
|
love.graphics.print("SFX Volume: " .. math.floor(self.sfxSlider:getValue()) .. "%", 75, 345)
|
|
|
|
love.graphics.print("BGM Volume: " .. math.floor(self.bgmSlider:getValue()) .. "%", 375, 345)
|
2020-12-22 13:43:59 -06:00
|
|
|
|
2020-12-20 08:45:49 -06:00
|
|
|
love.graphics.setColor(1, 1, 1, 0.75)
|
|
|
|
self.sfxSlider:draw()
|
2020-12-20 14:26:32 -06:00
|
|
|
self.bgmSlider:draw()
|
2020-10-10 18:42:56 -05:00
|
|
|
end
|
|
|
|
|
2020-11-08 14:55:06 -06:00
|
|
|
function ConfigScene:onInputPress(e)
|
2020-11-10 20:26:19 -06:00
|
|
|
if e.input == "menu_decide" or e.scancode == "return" then
|
2020-10-10 18:42:56 -05:00
|
|
|
playSE("mode_decide")
|
|
|
|
saveConfig()
|
2020-12-20 08:45:49 -06:00
|
|
|
scene = SettingsScene()
|
2020-11-10 19:08:34 -06:00
|
|
|
elseif e.input == "up" or e.scancode == "up" then
|
2020-10-10 18:42:56 -05:00
|
|
|
playSE("cursor")
|
|
|
|
self.highlight = Mod1(self.highlight-1, optioncount)
|
2020-11-10 19:08:34 -06:00
|
|
|
elseif e.input == "down" or e.scancode == "down" then
|
2020-10-10 18:42:56 -05:00
|
|
|
playSE("cursor")
|
|
|
|
self.highlight = Mod1(self.highlight+1, optioncount)
|
2020-11-10 19:08:34 -06:00
|
|
|
elseif e.input == "left" or e.scancode == "left" then
|
2020-12-22 13:43:59 -06:00
|
|
|
if not self.options[self.highlight][3] then
|
|
|
|
playSE("cursor_lr")
|
|
|
|
local option = ConfigScene.options[self.highlight]
|
|
|
|
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]-1, #option[4])
|
|
|
|
else
|
|
|
|
playSE("cursor")
|
|
|
|
sld = self[self.options[self.highlight][4]]
|
|
|
|
sld.value = math.max(sld.min, math.min(sld.max, (sld:getValue() - 3) / (sld.max - sld.min)))
|
|
|
|
end
|
2020-11-10 19:08:34 -06:00
|
|
|
elseif e.input == "right" or e.scancode == "right" then
|
2020-12-22 13:43:59 -06:00
|
|
|
if not self.options[self.highlight][3] then
|
|
|
|
playSE("cursor_lr")
|
|
|
|
local option = ConfigScene.options[self.highlight]
|
|
|
|
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]+1, #option[4])
|
|
|
|
else
|
|
|
|
playSE("cursor")
|
|
|
|
sld = self[self.options[self.highlight][4]]
|
|
|
|
sld.value = math.max(sld.min, math.min(sld.max, (sld:getValue() + 3) / (sld.max - sld.min)))--math.max(0, (math.floor(sld:getValue())+2)/(sld.max-sld.min))
|
|
|
|
end
|
2020-11-10 20:26:19 -06:00
|
|
|
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
2020-11-06 19:49:44 -06:00
|
|
|
loadSave()
|
2020-12-20 08:45:49 -06:00
|
|
|
scene = SettingsScene()
|
2020-10-10 18:42:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return ConfigScene
|