adds ui for music settings

This commit is contained in:
duncathan 2020-03-02 23:52:39 -06:00
parent 46eb8dc016
commit 4426eb69ec
5 changed files with 81 additions and 4 deletions

View file

@ -178,6 +178,7 @@ function music:new()
self.betaEnabled = false
self.songs = songs
self.cues = cues
self.flavor = "Shuffle"
end
local _isValid = function(key, song, self)
@ -192,8 +193,14 @@ function music:getCues()
return self.cues
end
function music:shuffleMusic(tscFiles)
if self.flavor == "Shuffle" then self:_shuffle(tscFiles) end
if self.flavor == "Random" then self:_random(tscFiles) end
if self.flavor == "Chaos" then self:_chaos(tscFiles) end
end
-- SHUFFLE songs: every cue with a given song becomes the same, new song
function music:shuffle(tscFiles)
function music:_shuffle(tscFiles)
local shuffled = self:getShuffledSongs()
local idmap = _.map(self.songs, function (k,v)
@ -209,13 +216,22 @@ function music:shuffle(tscFiles)
end
-- RANDOMIZE songs: any cue can play any song
function music:randomize(tscFiles)
function music:_random(tscFiles)
for k,cue in pairs(self.cues) do
cue.songid = self:getShuffledSongs()[1].id
end
self:writeCues(tscFiles)
end
-- CHAOTICALLY RANDOMIZE songs: nearly any <CMU can play any song
function music:_chaos(tscFiles)
for k,cue in pairs(self.cues) do
for k,event in ipairs(cue.events) do
tscFiles[cue.map]:placeSongAtCue(self:getShuffledSongs()[1].id, event, cue.map, cue.default)
end
end
end
function music:writeCues(tscFiles)
for k,cue in pairs(self.cues) do
for k,event in ipairs(cue.events) do

View file

@ -46,6 +46,7 @@ function C:new()
self.obj = ""
self.sharecode = ""
self.mychar = ""
self.shuffleMusic = false
end
function C:setPath(path)
@ -70,9 +71,9 @@ function C:randomize()
self:_updateSharecode(seed)
local tscFiles = self:_createTscFiles(dirStage)
self:_shuffleItems(tscFiles)
self.music:randomize(tscFiles)
if self.shuffleMusic then self.music:shuffleMusic(tscFiles) end
self:_writeModifiedData(tscFiles)
self:_writePlaintext(tscFiles)

View file

@ -7,6 +7,7 @@ local C = Class:extend()
local layout = Luigi(require 'ui.main')
local settings = Luigi(require 'ui.settings')
local sequence = Luigi(require 'ui.sequence')
local music = Luigi(require 'ui.music')
local style = require 'ui.style'
local theme = require 'lib.luigi.theme.dark'
@ -14,10 +15,12 @@ local theme = require 'lib.luigi.theme.dark'
layout:setStyle(style)
settings:setStyle(style)
sequence:setStyle(style)
music:setStyle(style)
layout:setTheme(theme)
settings:setTheme(theme)
sequence:setTheme(theme)
music:setTheme(theme)
function C:setup()
self:loadPuppy(Settings.settings.puppy)
@ -106,6 +109,14 @@ layout.twitter.text = '(@shruuu and @duncathan_salt)'
layout.footer.text = 'Original randomizer:\r\nshru.itch.io/cave-story-randomizer'
music.panel.text = [[Shuffle: remap every song to a new song. For example, all instances of Mischievous Robot become Pulse. Songs may remap to themselves.
Random: remap every cue to a new song. For example, entering the Egg Corridor by any means plays Meltdown 2.
Chaos: remap every <CMU to a new song. For example, teleporting to the Egg Corridor plays Charge, but entering Egg Corridor from Cthulhu's Abode plays Run!
Beta music: include Wind Fortress, Halloween 2, People of the Root, Pier Walk, and Snoopy Cake in the potential songs. Only compatible with the included Doukutsu.exe - no other platforms.]]
layout.go:onPress(function()
Randomizer:new()
@ -129,6 +140,12 @@ layout.go:onPress(function()
Randomizer.worldGraph.dboosts.plantation.enabled = sequence.plantation.value
Randomizer.worldGraph.dboosts.rocket.enabled = sequence.rocket.value
Randomizer.shuffleMusic = settings.music.value
Randomizer.music.betaEnabled = music.beta.value
if music.shuffle.value then Randomizer.music.flavor = "Shuffle" end
if music.random.value then Randomizer.music.flavor = "Random" end
if music.chaos.value then Randomizer.music.flavor = "Chaos" end
C:setStatus(Randomizer:randomize())
layout.sharecode.text = "Copy Sharecode"
@ -153,6 +170,11 @@ settings.seqButton:onPress(function()
settings:hide()
end)
settings.musicButton:onPress(function()
music:show()
settings:hide()
end)
sequence.allOn:onPress(function()
Screen:loadSeqSettings(nil, _.map(Settings.settings.dboosts, function(k,v) return true end))
end)
@ -166,6 +188,11 @@ sequence.close:onPress(function()
settings:show()
end)
music.close:onPress(function()
music:hide()
settings:show()
end)
layout.sharecode:onPress(function()
if Randomizer.sharecode ~= "" then
love.system.setClipboardText(Randomizer.sharecode)

28
src/ui/music.lua Normal file
View file

@ -0,0 +1,28 @@
return { style = 'dialog',
{ style = 'dialogHead', text = 'Music Settings' },
{ 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 = 'Random', id = 'random', minheight = 27 },
{ type = 'radio', group = 'music', text = 'Chaos', id = 'chaos', minheight = 27 },
{ type = 'label', text = 'Other settings' },
{ type = 'check', id = 'beta', value = false, text = 'Enable beta music', minheight = 27 },
},
{
{
align = 'top center',
wrap = true,
id = 'panel',
width = 275,
scroll = true
},
{ height = 10 },
{ type = 'label', text = '[scroll for more]', align = 'center', width = 275, minheight = 27 }
}
},
{ style = 'dialogFoot',
{},
{ style = 'dialogButton', id = 'close', text = 'Close' }
}
}

View file

@ -21,6 +21,11 @@ return { style = 'dialog',
{ type = 'button', style = 'dialogButton', text = "Modify", id = 'seqButton', width = 70, align = 'center' },
{ width = false }
},
{ flow = 'x',
{ 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' },
},
{