mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2025-03-21 09:29:19 +00:00
adds options for random and custom mychars
This commit is contained in:
parent
bbfa4e5661
commit
d76b811fda
BIN
src/assets/icon/Custom.png
Normal file
BIN
src/assets/icon/Custom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 227 B |
BIN
src/assets/icon/Random.png
Normal file
BIN
src/assets/icon/Random.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 195 B |
|
@ -349,8 +349,12 @@ end
|
|||
|
||||
function C:_copyMyChar()
|
||||
local path = self:_getWritePath() .. '/MyChar.bmp'
|
||||
local data = lf.read(self.mychar)
|
||||
U.writeFile(path, data)
|
||||
if self.mychar then
|
||||
local data = lf.read(self.mychar)
|
||||
U.writeFile(path, data)
|
||||
else
|
||||
U.eraseFile(path)
|
||||
end
|
||||
end
|
||||
|
||||
function C:_generateHash()
|
||||
|
|
|
@ -112,6 +112,21 @@ function C:loadMyChar(mychar)
|
|||
mc.value = "override"
|
||||
end
|
||||
|
||||
function C.numToMyChar(num)
|
||||
local mychars = {
|
||||
"assets/myChar/Quote.bmp",
|
||||
"assets/myChar/Curly.bmp",
|
||||
"assets/myChar/Sue.bmp",
|
||||
"assets/myChar/Toroko.bmp",
|
||||
"assets/myChar/King.bmp",
|
||||
"assets/myChar/Chaco.bmp",
|
||||
"assets/myChar/Kanpachi.bmp",
|
||||
"assets/myChar/Misery.bmp",
|
||||
"assets/myChar/Frog.bmp",
|
||||
}
|
||||
return mychars[num]
|
||||
end
|
||||
|
||||
function C:loadSpawn(spawn)
|
||||
if spawn == "Start Point" or spawn == 0 then
|
||||
settings.spawn.index = 1
|
||||
|
@ -196,7 +211,11 @@ layout.go:onPress(function()
|
|||
|
||||
Randomizer.obj = settings.objective.value
|
||||
Randomizer.puppy = settings.puppy.value
|
||||
Randomizer.mychar = music.mychar.value
|
||||
if music.mychar.value == "random" then
|
||||
Randomizer.mychar = Screen.numToMyChar(love.math.random(9))
|
||||
else
|
||||
Randomizer.mychar = music.mychar.value
|
||||
end
|
||||
Randomizer.worldGraph.spawn = settings.spawn.value
|
||||
|
||||
Randomizer.worldGraph.seqbreak = settings.seqbreak.value
|
||||
|
|
|
@ -50,7 +50,9 @@ return { style = 'dialog',
|
|||
{ text = " Chaco", value = "assets/myChar/Chaco.bmp", icon = "assets/icon/Chaco.png" },
|
||||
{ text = " Kanpachi", value = "assets/myChar/Kanpachi.bmp", icon = "assets/icon/Kanpachi.png" },
|
||||
{ text = " Misery", value = "assets/myChar/Misery.bmp", icon = "assets/icon/Misery.png" },
|
||||
{ text = " Frog", value = "assets/myChar/Frog.bmp", icon = "assets/icon/Frog.png" }
|
||||
{ text = " Frog", value = "assets/myChar/Frog.bmp", icon = "assets/icon/Frog.png" },
|
||||
{ text = " Random", value = "random", icon = "assets/icon/Random.png", status = "Choose a random sprite each time you randomize." },
|
||||
{ text = " Custom", value = false, icon = "assets/icon/Custom.png", status = "Use your own mychar.bmp! Place it in the main data folder." },
|
||||
},
|
||||
{ type = 'sash' },
|
||||
{ type = 'status', wrap = true, height = false, },
|
||||
|
|
10
src/util.lua
10
src/util.lua
|
@ -15,4 +15,14 @@ function U.writeFile(path, data)
|
|||
file:close()
|
||||
end
|
||||
|
||||
function U.eraseFile(path)
|
||||
logDebug('erasing file: ' .. path)
|
||||
|
||||
local file, err = io.open(path, 'r')
|
||||
if file ~= nil then
|
||||
io.close(file)
|
||||
os.remove(path)
|
||||
end
|
||||
end
|
||||
|
||||
return U
|
||||
|
|
Loading…
Reference in a new issue