mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 12:39:01 -06:00
Refactored settings menus
This commit is contained in:
parent
130c2ea403
commit
87b88f4b42
@ -28,13 +28,13 @@ sounds = {
|
|||||||
|
|
||||||
function playSE(sound, subsound)
|
function playSE(sound, subsound)
|
||||||
if subsound == nil then
|
if subsound == nil then
|
||||||
sounds[sound]:setVolume(0.5)
|
sounds[sound]:setVolume(config.sfx_volume)
|
||||||
if sounds[sound]:isPlaying() then
|
if sounds[sound]:isPlaying() then
|
||||||
sounds[sound]:stop()
|
sounds[sound]:stop()
|
||||||
end
|
end
|
||||||
sounds[sound]:play()
|
sounds[sound]:play()
|
||||||
else
|
else
|
||||||
sounds[sound][subsound]:setVolume(0.6)
|
sounds[sound][subsound]:setVolume(config.sfx_volume)
|
||||||
if sounds[sound][subsound]:isPlaying() then
|
if sounds[sound][subsound]:isPlaying() then
|
||||||
sounds[sound][subsound]:stop()
|
sounds[sound][subsound]:stop()
|
||||||
end
|
end
|
||||||
@ -44,13 +44,13 @@ end
|
|||||||
|
|
||||||
function playSEOnce(sound, subsound)
|
function playSEOnce(sound, subsound)
|
||||||
if subsound == nil then
|
if subsound == nil then
|
||||||
sounds[sound]:setVolume(0.5)
|
sounds[sound]:setVolume(config.sfx_volume)
|
||||||
if sounds[sound]:isPlaying() then
|
if sounds[sound]:isPlaying() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
sounds[sound]:play()
|
sounds[sound]:play()
|
||||||
else
|
else
|
||||||
sounds[sound][subsound]:setVolume(0.5)
|
sounds[sound][subsound]:setVolume(config.sfx_volume)
|
||||||
if sounds[sound][subsound]:isPlaying() then
|
if sounds[sound][subsound]:isPlaying() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
11
main.lua
11
main.lua
@ -9,17 +9,18 @@ function love.load()
|
|||||||
require "load.save"
|
require "load.save"
|
||||||
loadSave()
|
loadSave()
|
||||||
require "scene"
|
require "scene"
|
||||||
config["side_next"] = false
|
--config["side_next"] = false
|
||||||
config["reverse_rotate"] = true
|
--config["reverse_rotate"] = true
|
||||||
config["fullscreen"] = false
|
config["fullscreen"] = false
|
||||||
|
|
||||||
love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true});
|
love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true});
|
||||||
|
|
||||||
if config.secret == nil then config.secret = false
|
|
||||||
elseif config.secret == true then playSE("welcome") end
|
|
||||||
|
|
||||||
if not config.das then config.das = 10 end
|
if not config.das then config.das = 10 end
|
||||||
if not config.arr then config.arr = 2 end
|
if not config.arr then config.arr = 2 end
|
||||||
|
if not config.sfx_volume then config.sfx_volume = 0.5 end
|
||||||
|
|
||||||
|
if config.secret == nil then config.secret = false
|
||||||
|
elseif config.secret == true then playSE("welcome") end
|
||||||
|
|
||||||
if not config.gamesettings then
|
if not config.gamesettings then
|
||||||
config.gamesettings = {}
|
config.gamesettings = {}
|
||||||
|
@ -14,4 +14,5 @@ ModeSelectScene = require "scene.mode_select"
|
|||||||
InputConfigScene = require "scene.input_config"
|
InputConfigScene = require "scene.input_config"
|
||||||
GameConfigScene = require "scene.game_config"
|
GameConfigScene = require "scene.game_config"
|
||||||
TuningScene = require "scene.tuning"
|
TuningScene = require "scene.tuning"
|
||||||
|
SettingsScene = require "scene.settings"
|
||||||
TitleScene = require "scene.title"
|
TitleScene = require "scene.title"
|
||||||
|
@ -3,14 +3,14 @@ local ConfigScene = Scene:extend()
|
|||||||
ConfigScene.title = "Game Settings"
|
ConfigScene.title = "Game Settings"
|
||||||
|
|
||||||
require 'load.save'
|
require 'load.save'
|
||||||
|
require 'libs.simple-slider'
|
||||||
|
|
||||||
ConfigScene.options = {
|
ConfigScene.options = {
|
||||||
-- this serves as reference to what the options' values mean i guess?
|
-- this serves as reference to what the options' values mean i guess?
|
||||||
{"manlock", "Manual locking",{"Per ruleset","Per gamemode","Harddrop", "Softdrop"}},
|
{"manlock", "Manual Locking",{"Per ruleset","Per gamemode","Harddrop", "Softdrop"}},
|
||||||
{"piece_colour", "Piece Colours", {"Per ruleset","Arika" ,"TTC"}},
|
{"piece_colour", "Piece Colours", {"Per ruleset","Arika" ,"TTC"}},
|
||||||
{"world_reverse","A Button Rotation", {"Left" ,"Auto" ,"Right"}},
|
{"world_reverse","A Button Rotation", {"Left" ,"Auto" ,"Right"}},
|
||||||
{"display_gamemode", "Display Gamemode", {"On", "Off"}},
|
{"display_gamemode", "Display Gamemode", {"On", "Off"}},
|
||||||
{"next_se", "Next Piece SFX", {"On", "Off"}},
|
|
||||||
{"das_last_key", "DAS Switch", {"Default", "Instant"}},
|
{"das_last_key", "DAS Switch", {"Default", "Instant"}},
|
||||||
{"smooth_movement", "Smooth Piece Drop", {"On", "Off"}},
|
{"smooth_movement", "Smooth Piece Drop", {"On", "Off"}},
|
||||||
{"synchroes_allowed", "Synchroes", {"Per ruleset", "On", "Off"}},
|
{"synchroes_allowed", "Synchroes", {"Per ruleset", "On", "Off"}},
|
||||||
@ -27,10 +27,13 @@ function ConfigScene:new()
|
|||||||
details = "In menus",
|
details = "In menus",
|
||||||
state = "Changing game settings",
|
state = "Changing game settings",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
self.sfxSlider = newSlider(290, 375, 400, config.sfx_volume * 100, 0, 100, function(v) config.sfx_volume = v / 100 end, {width=20})
|
||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:update()
|
function ConfigScene:update()
|
||||||
config["das_last_key"] = config.gamesettings.das_last_key == 2
|
config["das_last_key"] = config.gamesettings.das_last_key == 2
|
||||||
|
self.sfxSlider:update()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:render()
|
function ConfigScene:render()
|
||||||
@ -40,6 +43,9 @@ function ConfigScene:render()
|
|||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
0.5, 0.5
|
0.5, 0.5
|
||||||
)
|
)
|
||||||
|
|
||||||
|
love.graphics.setFont(font_3x5_3)
|
||||||
|
love.graphics.print("Master Volume: " .. math.floor(self.sfxSlider:getValue()) .. "%", 80, 325)
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_4)
|
love.graphics.setFont(font_3x5_4)
|
||||||
love.graphics.print("GAME SETTINGS", 80, 40)
|
love.graphics.print("GAME SETTINGS", 80, 40)
|
||||||
@ -56,13 +62,16 @@ function ConfigScene:render()
|
|||||||
love.graphics.printf(setting, 100 + 110 * j, 100 + i * 20, 100, "center")
|
love.graphics.printf(setting, 100 + 110 * j, 100 + i * 20, 100, "center")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
love.graphics.setColor(1, 1, 1, 0.75)
|
||||||
|
self.sfxSlider:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:onInputPress(e)
|
function ConfigScene:onInputPress(e)
|
||||||
if e.input == "menu_decide" or e.scancode == "return" then
|
if e.input == "menu_decide" or e.scancode == "return" then
|
||||||
playSE("mode_decide")
|
playSE("mode_decide")
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = TitleScene()
|
scene = SettingsScene()
|
||||||
elseif e.input == "up" or e.scancode == "up" then
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
playSE("cursor")
|
playSE("cursor")
|
||||||
self.highlight = Mod1(self.highlight-1, optioncount)
|
self.highlight = Mod1(self.highlight-1, optioncount)
|
||||||
@ -79,7 +88,7 @@ function ConfigScene:onInputPress(e)
|
|||||||
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]+1, #option[3])
|
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]+1, #option[3])
|
||||||
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
||||||
loadSave()
|
loadSave()
|
||||||
scene = TitleScene()
|
scene = SettingsScene()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ function ConfigScene:onInputPress(e)
|
|||||||
-- function keys, escape, and tab are reserved and can't be remapped
|
-- function keys, escape, and tab are reserved and can't be remapped
|
||||||
if e.scancode == "escape" and config.input then
|
if e.scancode == "escape" and config.input then
|
||||||
-- cancel only if there was an input config already
|
-- cancel only if there was an input config already
|
||||||
scene = TitleScene()
|
scene = SettingsScene()
|
||||||
elseif self.input_state > table.getn(configurable_inputs) then
|
elseif self.input_state > table.getn(configurable_inputs) then
|
||||||
if e.scancode == "return" then
|
if e.scancode == "return" then
|
||||||
-- save new input, then load next scene
|
-- save new input, then load next scene
|
||||||
|
65
scene/settings.lua
Normal file
65
scene/settings.lua
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
local SettingsScene = Scene:extend()
|
||||||
|
|
||||||
|
SettingsScene.title = "Settings"
|
||||||
|
|
||||||
|
local menu_screens = {
|
||||||
|
InputConfigScene,
|
||||||
|
GameConfigScene,
|
||||||
|
TuningScene
|
||||||
|
}
|
||||||
|
|
||||||
|
function SettingsScene:new()
|
||||||
|
self.menu_state = 1
|
||||||
|
DiscordRPC:update({
|
||||||
|
details = "In menus",
|
||||||
|
state = "Changing settings",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
function SettingsScene:update() end
|
||||||
|
|
||||||
|
function SettingsScene:render()
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
love.graphics.draw(
|
||||||
|
backgrounds["game_config"],
|
||||||
|
0, 0, 0,
|
||||||
|
0.5, 0.5
|
||||||
|
)
|
||||||
|
|
||||||
|
love.graphics.setFont(font_3x5_4)
|
||||||
|
love.graphics.print("SETTINGS", 80, 40)
|
||||||
|
|
||||||
|
love.graphics.setFont(font_3x5_2)
|
||||||
|
love.graphics.print("Here, you can change some settings that change\nthe look and feel of the game.", 80, 90)
|
||||||
|
|
||||||
|
love.graphics.setColor(1, 1, 1, 0.5)
|
||||||
|
love.graphics.rectangle("fill", 75, 118 + 50 * self.menu_state, 200, 33)
|
||||||
|
|
||||||
|
love.graphics.setFont(font_3x5_3)
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
for i, screen in pairs(menu_screens) do
|
||||||
|
love.graphics.printf(screen.title, 80, 120 + 50 * i, 200, "left")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function SettingsScene:changeOption(rel)
|
||||||
|
local len = table.getn(menu_screens)
|
||||||
|
self.menu_state = (self.menu_state + len + rel - 1) % len + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function SettingsScene:onInputPress(e)
|
||||||
|
if e.input == "menu_decide" or e.scancode == "return" then
|
||||||
|
playSE("main_decide")
|
||||||
|
scene = menu_screens[self.menu_state]()
|
||||||
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
|
self:changeOption(-1)
|
||||||
|
playSE("cursor")
|
||||||
|
elseif e.input == "down" or e.scancode == "down" then
|
||||||
|
self:changeOption(1)
|
||||||
|
playSE("cursor")
|
||||||
|
elseif e.input == "menu_back" or e.scancode == "backspace" or e.scancode == "delete" then
|
||||||
|
scene = TitleScene()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return SettingsScene
|
@ -5,9 +5,7 @@ TitleScene.restart_message = false
|
|||||||
|
|
||||||
local main_menu_screens = {
|
local main_menu_screens = {
|
||||||
ModeSelectScene,
|
ModeSelectScene,
|
||||||
InputConfigScene,
|
SettingsScene,
|
||||||
GameConfigScene,
|
|
||||||
TuningScene,
|
|
||||||
ExitScene,
|
ExitScene,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,10 +47,10 @@ function TuningScene:onInputPress(e)
|
|||||||
if e.input == "menu_decide" or e.scancode == "return" then
|
if e.input == "menu_decide" or e.scancode == "return" then
|
||||||
playSE("mode_decide")
|
playSE("mode_decide")
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = TitleScene()
|
scene = SettingsScene()
|
||||||
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
||||||
loadSave()
|
loadSave()
|
||||||
scene = TitleScene()
|
scene = SettingsScene()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user