mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 15:59:02 -06:00
Cleaned up love.load
This commit is contained in:
parent
7b7a255bf8
commit
ab445ff699
@ -13,7 +13,31 @@ function loadFromFile(filename)
|
|||||||
return save_data[1]
|
return save_data[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function initConfig()
|
||||||
|
if not config.das then config.das = 10 end
|
||||||
|
if not config.arr then config.arr = 2 end
|
||||||
|
if not config.dcd then config.dcd = 0 end
|
||||||
|
if not config.sfx_volume then config.sfx_volume = 0.5 end
|
||||||
|
if not config.bgm_volume then config.bgm_volume = 0.5 end
|
||||||
|
|
||||||
|
if config.fullscreen == nil then config.fullscreen = false end
|
||||||
|
if config.secret == nil then config.secret = false end
|
||||||
|
|
||||||
|
if not config.gamesettings then config.gamesettings = {} end
|
||||||
|
for _, option in ipairs(GameConfigScene.options) do
|
||||||
|
if not config.gamesettings[option[1]] then
|
||||||
|
config.gamesettings[option[1]] = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not config.input then
|
||||||
|
scene = KeyConfigScene()
|
||||||
|
else
|
||||||
|
if config.current_mode then current_mode = config.current_mode end
|
||||||
|
if config.current_ruleset then current_ruleset = config.current_ruleset end
|
||||||
|
scene = TitleScene()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function saveConfig()
|
function saveConfig()
|
||||||
binser.writeFile('config.sav', config)
|
binser.writeFile('config.sav', config)
|
||||||
|
34
main.lua
34
main.lua
@ -23,35 +23,16 @@ function love.load()
|
|||||||
GLOBAL_CANVAS = love.graphics.newCanvas()
|
GLOBAL_CANVAS = love.graphics.newCanvas()
|
||||||
|
|
||||||
-- init config
|
-- init config
|
||||||
if config.fullscreen == nil then config.fullscreen = false
|
initConfig()
|
||||||
elseif config.fullscreen == true then
|
|
||||||
love.window.setFullscreen(config["fullscreen"])
|
|
||||||
end
|
|
||||||
|
|
||||||
if not config.das then config.das = 10 end
|
love.window.setFullscreen(config["fullscreen"])
|
||||||
if not config.arr then config.arr = 2 end
|
if config.secret then playSE("welcome") end
|
||||||
if not config.dcd then config.dcd = 0 end
|
|
||||||
if not config.sfx_volume then config.sfx_volume = 0.5 end
|
|
||||||
if not config.bgm_volume then config.bgm_volume = 0.5 end
|
|
||||||
|
|
||||||
if config.secret == nil then config.secret = false
|
-- import custom modules
|
||||||
elseif config.secret == true then playSE("welcome") end
|
initModules()
|
||||||
|
end
|
||||||
if not config.gamesettings then config.gamesettings = {} end
|
|
||||||
for _, option in ipairs(GameConfigScene.options) do
|
|
||||||
if not config.gamesettings[option[1]] then
|
|
||||||
config.gamesettings[option[1]] = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not config.input then
|
|
||||||
scene = KeyConfigScene()
|
|
||||||
else
|
|
||||||
if config.current_mode then current_mode = config.current_mode end
|
|
||||||
if config.current_ruleset then current_ruleset = config.current_ruleset end
|
|
||||||
scene = TitleScene()
|
|
||||||
end
|
|
||||||
|
|
||||||
|
function initModules()
|
||||||
game_modes = {}
|
game_modes = {}
|
||||||
mode_list = love.filesystem.getDirectoryItems("tetris/modes")
|
mode_list = love.filesystem.getDirectoryItems("tetris/modes")
|
||||||
for i=1,#mode_list do
|
for i=1,#mode_list do
|
||||||
@ -72,7 +53,6 @@ function love.load()
|
|||||||
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
||||||
table.sort(rulesets, function(a,b)
|
table.sort(rulesets, function(a,b)
|
||||||
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local TARGET_FPS = 60
|
local TARGET_FPS = 60
|
||||||
|
Loading…
Reference in New Issue
Block a user