cambridge/scene/tuning.lua

90 lines
3.1 KiB
Lua
Raw Normal View History

2020-12-18 20:28:30 -06:00
local TuningScene = Scene:extend()
TuningScene.title = "Tuning Settings"
require 'load.save'
require 'libs.simple-slider'
TuningScene.options = {
-- Serves as a reference for the options available in the menu. Format: {name in config, name as displayed if applicable, slider name}
{"das", "DAS", "dasSlider"},
{"arr", "ARR", "arrSlider"},
{"dcd", "DCD", "dcdSlider"},
}
local optioncount = #TuningScene.options
2020-12-18 20:28:30 -06:00
function TuningScene:new()
DiscordRPC:update({
2021-09-26 14:30:37 -05:00
details = "In settings",
2020-12-18 20:28:30 -06:00
state = "Changing tuning settings",
})
self.highlight = 1
2020-12-18 20:28:30 -06:00
2021-01-12 12:47:03 -06:00
self.dasSlider = newSlider(290, 225, 400, config.das, 0, 20, function(v) config.das = math.floor(v) end, {width=20, knob="circle", track="roundrect"})
self.arrSlider = newSlider(290, 300, 400, config.arr, 0, 6, function(v) config.arr = math.floor(v) end, {width=20, knob="circle", track="roundrect"})
self.dcdSlider = newSlider(290, 375, 400, config.dcd, 0, 6, function(v) config.dcd = math.floor(v) end, {width=20, knob="circle", track="roundrect"})
2020-12-18 20:28:30 -06:00
end
function TuningScene:update()
self.dasSlider:update()
self.arrSlider:update()
self.dcdSlider:update()
2020-12-18 20:28:30 -06:00
end
function TuningScene:render()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.draw(
backgrounds["game_config"],
0, 0, 0,
0.5, 0.5
)
love.graphics.setColor(1, 1, 1, 0.5)
love.graphics.rectangle("fill", 75, 98 + self.highlight * 75, 400, 33)
love.graphics.setColor(1, 1, 1, 1)
2020-12-18 20:28:30 -06:00
love.graphics.setFont(font_3x5_4)
love.graphics.print("TUNING SETTINGS", 80, 40)
love.graphics.setFont(font_3x5_2)
2020-12-18 22:17:53 -06:00
love.graphics.print("These settings will only apply to modes\nthat do not use their own tunings.", 80, 90)
2020-12-18 20:28:30 -06:00
love.graphics.setFont(font_3x5_3)
2020-12-18 22:17:53 -06:00
love.graphics.print("Delayed Auto-Shift (DAS): " .. math.floor(self.dasSlider:getValue()) .. "F", 80, 175)
love.graphics.print("Auto-Repeat Rate (ARR): " .. math.floor(self.arrSlider:getValue()) .. "F", 80, 250)
love.graphics.print("DAS Cut Delay (DCD): " .. math.floor(self.dcdSlider:getValue()) .. "F", 80, 325)
2020-12-18 20:28:30 -06:00
love.graphics.setColor(1, 1, 1, 0.75)
self.dasSlider:draw()
self.arrSlider:draw()
self.dcdSlider:draw()
2020-12-18 20:28:30 -06:00
end
function TuningScene:onInputPress(e)
if e.input == "menu_decide" or e.scancode == "return" then
playSE("mode_decide")
saveConfig()
2020-12-20 08:45:49 -06:00
scene = SettingsScene()
elseif e.input == "up" or e.scancode == "up" then
playSE("cursor")
self.highlight = Mod1(self.highlight-1, optioncount)
elseif e.input == "down" or e.scancode == "down" then
playSE("cursor")
self.highlight = Mod1(self.highlight+1, optioncount)
elseif e.input == "left" or e.scancode == "left" then
playSE("cursor")
sld = self[self.options[self.highlight][3]]
sld.value = math.max(sld.min, math.min(sld.max, (sld:getValue() - 1) / (sld.max - sld.min)))
elseif e.input == "right" or e.scancode == "right" then
playSE("cursor")
sld = self[self.options[self.highlight][3]]
sld.value = math.max(sld.min, math.min(sld.max, (sld:getValue() + 1) / (sld.max - sld.min)))
2020-12-18 20:28:30 -06:00
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
loadSave()
2020-12-20 08:45:49 -06:00
scene = SettingsScene()
2020-12-18 20:28:30 -06:00
end
end
return TuningScene