From 5b172e650c758a0b4d80973851ea20d28e4f0b1d Mon Sep 17 00:00:00 2001 From: duncathan Date: Tue, 3 Mar 2020 01:21:07 -0600 Subject: [PATCH] adds music settings to saved settings --- src/randomizer.lua | 3 +++ src/settings.lua | 28 +++++++++++++++++----------- src/ui/draw.lua | 9 +++++++++ src/ui/music.lua | 2 +- src/ui/settings.lua | 5 ++--- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/randomizer.lua b/src/randomizer.lua index 4965fd8..6fd46f2 100644 --- a/src/randomizer.lua +++ b/src/randomizer.lua @@ -323,6 +323,9 @@ function C:_updateSettings() Settings.settings.spawn = self.worldGraph.spawn Settings.settings.seqbreaks = self.worldGraph.seqbreak Settings.settings.dboosts = _.map(self.worldGraph.dboosts, function(k,v) return v.enabled end) + Settings.settings.musicShuffle = self.shuffleMusic + Settings.settings.musicBeta = self.music.betaEnabled + Settings.settings.musicFlavor = self.music.flavor Settings:update() end diff --git a/src/settings.lua b/src/settings.lua index d29dcb1..5dd6c51 100644 --- a/src/settings.lua +++ b/src/settings.lua @@ -31,7 +31,10 @@ function C:getDefaults() sisters = true, plantation = true, rocket = true - } + }, + musicShuffle = false, + musicBeta = false, + musicFlavor = "Shuffle" } end @@ -48,18 +51,21 @@ function C:serialize() return line .. "}" end - local line = "return {\r\n " - - line = line .. ("csdirectory = [[%s]],\r\n "):format(self.settings.csdirectory or "") - line = line .. ("puppy = %s,\r\n "):format(self.settings.puppy) - line = line .. ("obj = %q,\r\n "):format(self.settings.obj or "") - line = line .. ("mychar = %q,\r\n "):format(self.settings.mychar or "") - line = line .. ("spawn = %q,\r\n "):format(self.settings.spawn or "") + local line = "return {\r\n" + local tab = " " + line = line .. tab .. ("csdirectory = [[%s]],\r\n"):format(self.settings.csdirectory or "") + line = line .. tab .. ("puppy = %s,\r\n"):format(self.settings.puppy) + line = line .. tab .. ("obj = %q,\r\n"):format(self.settings.obj or "") + line = line .. tab .. ("mychar = %q,\r\n"):format(self.settings.mychar or "") + line = line .. tab .. ("spawn = %q,\r\n"):format(self.settings.spawn or "") local dboost = dboosts() - line = line .. ("seqbreaks = %s,\r\n "):format(self.settings.seqbreaks) - line = line .. ("dboosts = %s,\r\n "):format(dboost) + line = line .. tab .. ("seqbreaks = %s,\r\n"):format(self.settings.seqbreaks) + line = line .. tab .. ("dboosts = %s,\r\n"):format(dboost) + line = line .. tab .. ("musicShuffle = %s,\r\n"):format(self.settings.musicShuffle) + line = line .. tab .. ("musicBeta = %s,\r\n"):format(self.settings.musicBeta) + line = line .. tab .. ("musicFlavor = %q\r\n"):format(self.settings.musicFlavor) - return line .. "\r\n}" + return line .. "}" end function C:getSettings() diff --git a/src/ui/draw.lua b/src/ui/draw.lua index 9605783..b87125d 100644 --- a/src/ui/draw.lua +++ b/src/ui/draw.lua @@ -28,6 +28,7 @@ function C:setup() self:loadMyChar(Settings.settings.mychar) self:loadSpawn(Settings.settings.spawn) self:loadSeqSettings(Settings.settings.seqbreaks, Settings.settings.dboosts) + self:loadMusicSettings(Settings.settings.musicShuffle, Settings.settings.musicBeta, Settings.settings.musicFlavor) background = lg.newImage('assets/background.png') self:draw() @@ -103,6 +104,14 @@ function C:loadSeqSettings(breaks, seq) end end +function C:loadMusicSettings(shuffle, beta, flavor) + settings.music.value = shuffle + music.beta.value = beta + if flavor == "Shuffle" then music.shuffle.value = true end + if flavor == "Random" then music.random.value = true end + if flavor == "Chaos" then music.random.value = true end +end + layout.version.text = 'Cave Story Randomizer [Open Mode] v' .. VERSION layout.author.text = 'by shru and duncathan' layout.twitter.text = '(@shruuu and @duncathan_salt)' diff --git a/src/ui/music.lua b/src/ui/music.lua index 8955805..aab1254 100644 --- a/src/ui/music.lua +++ b/src/ui/music.lua @@ -3,7 +3,7 @@ return { style = 'dialog', { style = 'dialogBody', padding = 24, flow = 'x', { { type = 'label', text = 'Type of randomization' }, - { type = 'radio', group = 'music', text = 'Shuffle', id = 'shuffle', value = true, minheight = 27 }, + { type = 'radio', group = 'music', text = 'Shuffle', id = 'shuffle', minheight = 27 }, { type = 'radio', group = 'music', text = 'Random', id = 'random', minheight = 27 }, { type = 'radio', group = 'music', text = 'Chaos', id = 'chaos', minheight = 27 }, { type = 'label', text = 'Other settings' }, diff --git a/src/ui/settings.lua b/src/ui/settings.lua index 3643c8e..e1b2f1a 100644 --- a/src/ui/settings.lua +++ b/src/ui/settings.lua @@ -16,17 +16,16 @@ return { style = 'dialog', }, { type = 'label', text = 'Randomization Options', minheight = 32 }, { type = 'check', value = false, id = 'puppy', text = "Puppysanity", minheight = 27 }, - { flow = 'x', + { flow = 'x', height = 32, { type = 'check', value = false, id = 'seqbreak', text = "Sequence breaks", minheight = 32, width = 170}, { type = 'button', style = 'dialogButton', text = "Modify", id = 'seqButton', width = 70, align = 'center' }, { width = false } }, - { flow = 'x', + { flow = 'x', height = 32, { type = 'check', value = false, id = 'music', text = "Randomize music", minheight = 32, width = 170}, { type = 'button', style = 'dialogButton', text = "Modify", id = 'musicButton', width = 70, align = 'center' }, { width = false } }, - { height = 'auto' }, }, { { type = 'label', text = 'Objective', minheight = 32 },