mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-11-10 00:45:15 +00:00
can now import sharecodes
This commit is contained in:
parent
d7969ecd65
commit
f8f994b4ae
|
@ -151,8 +151,6 @@ function C:_shuffleItems(tscFiles)
|
|||
-- place the bomb on MALCO for bad end
|
||||
if self.obj == "objBadEnd" then
|
||||
self.worldGraph:getMALCO()[1]:setItem(self.itemDeck:getByKey("bomb"))
|
||||
else
|
||||
logWarning(self.obj)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,11 @@ function C:loadSettings(puppy, obj, seed)
|
|||
settings.best.value = true
|
||||
end
|
||||
|
||||
if seed ~= nil then
|
||||
settings.customseed.value = seed or ""
|
||||
settings.seedselect.value = true
|
||||
settings.seedrandom.value = false
|
||||
end
|
||||
end
|
||||
|
||||
layout.version.text = 'Cave Story Randomizer [Open Mode] v' .. VERSION
|
||||
|
@ -58,7 +62,7 @@ layout.go:onPress(function()
|
|||
|
||||
if Randomizer:ready() then
|
||||
if settings.seedselect.value and settings.customseed.value ~= "" then
|
||||
Randomizer.customseed = settings.customseed.value
|
||||
Randomizer.customseed = settings.customseed.value:gsub("^%s*(.-)%s*$", "%1") -- trim any leading/trailing whitespace
|
||||
end
|
||||
|
||||
if settings.bad.value then
|
||||
|
@ -88,6 +92,7 @@ end)
|
|||
settings.closeButton:onPress(function()
|
||||
settings:hide()
|
||||
layout:show()
|
||||
settings.sharecode.value = ""
|
||||
end)
|
||||
|
||||
layout.sharecode:onPress(function()
|
||||
|
@ -104,6 +109,28 @@ settings.customseed:onChange(function()
|
|||
settings.seedcount.text = ("%s/20"):format(#settings.customseed.value)
|
||||
end)
|
||||
|
||||
settings.importshare:onPress(function()
|
||||
local success, seed, sharesettings = pcall(function()
|
||||
local packed = love.data.decode("data", "base64", settings.sharecode.value)
|
||||
local seed, settings = love.data.unpack("sB", packed)
|
||||
return seed, settings
|
||||
end)
|
||||
|
||||
if success then
|
||||
settings.importshare.text = "Sharecode Imported"
|
||||
local pup = bit.band(sharesettings, 4) ~= 0
|
||||
local obj = bit.band(sharesettings, 3)
|
||||
seed = seed:gsub("^%s*(.-)%s*$", "%1") -- trim any leading or trailing whitespace
|
||||
Screen:loadSettings(pup, obj, seed)
|
||||
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()
|
||||
|
|
|
@ -1,24 +1,31 @@
|
|||
return { style = 'dialog',
|
||||
{ style = 'dialogHead', text = 'Settings' },
|
||||
{ style = 'dialogBody', padding = 24, flow = 'x',
|
||||
{ style = 'dialogBody', padding = 24,
|
||||
{ flow = 'x', minheight = 260,
|
||||
{
|
||||
{ type = 'label', text = 'Seed' },
|
||||
{ type = 'label', text = 'Seed', minheight = 32 },
|
||||
{
|
||||
{ type = 'radio', group = 'seed', text = 'Use random seed', value = true },
|
||||
{ flow = 'y', { type = 'radio', group = 'seed', text = 'Use custom seed', id = 'seedselect'}, {{ type = 'text', id = 'customseed', width = 200}, flow = 'x', { type = 'label', id = 'seedcount' }}, {height = false} }
|
||||
{ type = 'radio', group = 'seed', text = 'Use random seed', value = true, id = 'seedrandom', minheight = 27 },
|
||||
{ flow = 'y', { type = 'radio', group = 'seed', text = 'Use custom seed', id = 'seedselect', minheight = 27 }, {{ type = 'text', id = 'customseed', width = 200, minheight = 32}, flow = 'x', { type = 'label', id = 'seedcount' }} }
|
||||
},
|
||||
{ type = 'label', text = 'Randomization Options' },
|
||||
{ type = 'check', value = false, id = 'puppy', text = "Puppysanity"},
|
||||
{ height = false },
|
||||
{ type = 'label', text = 'Randomization Options', minheight = 32 },
|
||||
{ type = 'check', value = false, id = 'puppy', text = "Puppysanity", minheight = 27 },
|
||||
{ height = 64 },
|
||||
},
|
||||
{
|
||||
{ type = 'label', text = 'Objective' },
|
||||
{ type = 'radio', group = 'objective', text = 'Bad ending', id = 'bad' },
|
||||
{ type = 'radio', group = 'objective', text = 'Normal ending', id = 'norm'},
|
||||
{ type = 'radio', group = 'objective', text = 'Best ending', id = 'best', value = true },
|
||||
{ type = 'radio', group = 'objective', text = 'All bosses', id = 'boss' },
|
||||
{ type = 'label', text = 'Objective', minheight = 32 },
|
||||
{ type = 'radio', group = 'objective', text = 'Bad ending', id = 'bad', minheight = 27 },
|
||||
{ type = 'radio', group = 'objective', text = 'Normal ending', id = 'norm', minheight = 27 },
|
||||
{ type = 'radio', group = 'objective', text = 'Best ending', id = 'best', value = true, minheight = 27 },
|
||||
{ type = 'radio', group = 'objective', text = 'All bosses', id = 'boss', minheight = 27 },
|
||||
},
|
||||
},
|
||||
{
|
||||
flow = 'x',
|
||||
{ type = 'text', id = 'sharecode', width = 350 },
|
||||
{ type = 'button', style = 'dialogButton', text = "Import Sharecode", id = 'importshare', width = 180 }
|
||||
}
|
||||
},
|
||||
{ style = 'dialogFoot',
|
||||
{},
|
||||
{ style = 'dialogButton', id = 'closeButton', text = 'Close' }
|
||||
|
|
Loading…
Reference in a new issue