local Luigi = require 'lib.luigi.layout' local background 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' 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) self:loadObjective(Settings.settings.obj) self:loadMyChar(Settings.settings.mychar) self:loadSpawn(Settings.settings.spawn) self:loadSeqSettings(Settings.settings.seqbreaks, Settings.settings.dboosts) background = lg.newImage('assets/background.png') self:draw() layout:show() end function C:loadPuppy(puppy) settings.puppy.value = puppy end function C:loadObjective(obj) if obj == "objBadEnd" or obj == 1 then settings.objective.index = 1 elseif obj == "objNormalEnd" or obj == 2 then settings.objective.index = 2 elseif obj == "objAllBosses" or obj == 3 then settings.objective.index = 4 else settings.objective.index = 3 end settings.objective.value = "override" end function C:loadSeed(seed) if seed ~= nil then settings.customseed.value = seed or "" settings.seedselect.value = true settings.seedrandom.value = false end end function C:loadMyChar(mychar) if mychar == "assets/myChar/Quote.bmp" then settings.mychar.index = 1 elseif mychar == "assets/myChar/Curly.bmp" then settings.mychar.index = 2 elseif mychar == "assets/myChar/Sue.bmp" then settings.mychar.index = 3 elseif mychar == "assets/myChar/Toroko.bmp" then settings.mychar.index = 4 elseif mychar == "assets/myChar/King.bmp" then settings.mychar.index = 5 elseif mychar == "assets/myChar/Kanpachi.bmp" then settings.mychar.index = 6 elseif mychar == "assets/myChar/Frog.bmp" then settings.mychar.index = 7 end settings.mychar.value = "override" end function C:loadSpawn(spawn) if spawn == "Start Point" or spawn == 0 then settings.spawn.index = 1 elseif spawn == "Arthur's House" or spawn == 1 then settings.spawn.index = 2 elseif spawn == "Camp" or spawn == 2 then settings.spawn.index = 3 end settings.spawn.value = "override" end function C:loadSeqSettings(breaks, seq) if breaks then settings.seqbreak.value = breaks end if breaks or breaks == nil then sequence.cthulhu.value = seq.cthulhu sequence.chaco.value = seq.chaco sequence.paxChaco.value = seq.paxChaco sequence.flightlessHut.value = seq.flightlessHut sequence.camp.value = seq.camp sequence.sisters.value = seq.sisters sequence.plantation.value = seq.plantation sequence.rocket.value = seq.rocket 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)' 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 20 then settings.customseed.value = settings.customseed.value:sub(1, 20) end settings.seedcount.text = ("%s/20"):format(#settings.customseed.value) end) settings.importshare:onPress(function() local success, seed, sharesettings, seq = pcall(function() local packed = love.data.decode("data", "base64", settings.sharecode.value) local seed, settings, seq = love.data.unpack("sBB", packed) assert(#seed == 20) return seed, settings, seq end) if success then settings.importshare.text = "Sharecode Imported" Screen:loadPuppy(bit.band(sharesettings, 1) ~= 0) -- settings & 0b00000001 Screen:loadObjective(bit.brshift(bit.band(sharesettings, 14), 1)) -- (settings & 0b00001110) >> 1 Screen:loadSpawn(bit.brshift(bit.band(sharesettings, 112), 4)) -- (settings & 0b01110000) >> 4 Screen:loadSeed(seed:gsub("^%s*(.-)%s*$", "%1")) -- trim any leading or trailing whitespace Screen:loadSeqSettings(bit.band(sharesettings, 128) ~= 0, { -- (settings & 0b10000000) cthulhu = bit.band(seq, 1) ~= 0, chaco = bit.band(seq, 2) ~= 0, paxChaco = bit.band(seq, 4) ~= 0, flightlessHut = bit.band(seq, 8) ~= 0, camp = bit.band(seq, 16) ~= 0, sisters = bit.band(seq, 32) ~= 0, plantation = bit.band(seq, 64) ~= 0, rocket = bit.band(seq, 128) ~= 0 }) else settings.importshare.text = "Invalid Sharecode!" end end) settings.sharecode:onChange(function() settings.importshare.text = "Import Sharecode" end) function C:draw() lg.draw(background, 0, 0) --layout:show() end function C:setStatus(text) layout.status.text = text end return C