From d76b811fda398c3bfe408cdd0df0dd9cd8ccdec9 Mon Sep 17 00:00:00 2001 From: duncathan Date: Mon, 26 Jul 2021 21:03:50 -0600 Subject: [PATCH] adds options for random and custom mychars --- src/assets/icon/Custom.png | Bin 0 -> 227 bytes src/assets/icon/Random.png | Bin 0 -> 195 bytes src/randomizer.lua | 8 ++++++-- src/ui/draw.lua | 21 ++++++++++++++++++++- src/ui/music.lua | 4 +++- src/util.lua | 10 ++++++++++ 6 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 src/assets/icon/Custom.png create mode 100644 src/assets/icon/Random.png diff --git a/src/assets/icon/Custom.png b/src/assets/icon/Custom.png new file mode 100644 index 0000000000000000000000000000000000000000..6a3ef484764d8cda238146c3f074d954b18f49bb GIT binary patch literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCils0(?ST|Ns9FWQHEPTnD6>N`m}?|1&(@Zr}yvaTa()7BevL9RguSQ4OyK zpkRcji(`m||K2V`z5@mvM-KhBzsvM)LX*ge2Jx2j-h5Y@zcR;i88lWUs5`!mY2dtJ zCh~-nTfOn9zt4qUhnwop)ox6_+3=M$v7|}=VPo6`)wu`USrcWLCbDbZVRB8`=IRf$ OgTd3)&t;ucLK6TPsYqA= literal 0 HcmV?d00001 diff --git a/src/assets/icon/Random.png b/src/assets/icon/Random.png new file mode 100644 index 0000000000000000000000000000000000000000..5726c79fbde03cc4dbced960ab8e1d5ef11608b9 GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSK$uZf!>a)(7~$#S7!u+BcFIOR1_2({)&KvWO?~MiV5RVG zT9lOj&gon={-16hJ+sMvd%)F)@~=Kiuw?u>Gw1xAb?+8G*vIFxka_i<`;9N|IvlK) n?XX(!c<>_w!=1+a%pD>z%`)1i``Y+`b})Fl`njxgN@xNAdzVAn literal 0 HcmV?d00001 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