diff --git a/src/assets/icon/Custom.png b/src/assets/icon/Custom.png new file mode 100644 index 0000000..6a3ef48 Binary files /dev/null and b/src/assets/icon/Custom.png differ diff --git a/src/assets/icon/Random.png b/src/assets/icon/Random.png new file mode 100644 index 0000000..5726c79 Binary files /dev/null and b/src/assets/icon/Random.png differ diff --git a/src/randomizer.lua b/src/randomizer.lua index d145179..e1fa630 100644 --- a/src/randomizer.lua +++ b/src/randomizer.lua @@ -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() diff --git a/src/ui/draw.lua b/src/ui/draw.lua index 4fa5996..80e69fa 100644 --- a/src/ui/draw.lua +++ b/src/ui/draw.lua @@ -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 diff --git a/src/ui/music.lua b/src/ui/music.lua index 026aa1a..0128fae 100644 --- a/src/ui/music.lua +++ b/src/ui/music.lua @@ -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, }, diff --git a/src/util.lua b/src/util.lua index 03ff064..81b0470 100644 --- a/src/util.lua +++ b/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