ironlung18

drawing.lua

Apr 21st, 2020 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.84 KB | None | 0 0
  1. Drawing = {}
  2.  
  3. function Drawing.drawLayout()
  4. gui.drawRectangle(
  5. GraphicConstants.SCREEN_WIDTH,
  6. 0,
  7. GraphicConstants.RIGHT_GAP - 1,
  8. GraphicConstants.UP_GAP + GraphicConstants.DOWN_GAP + GraphicConstants.SCREEN_HEIGHT - 1,
  9. GameSettings.gamecolor,
  10. 0x00000000
  11. )
  12. gui.drawRectangle(
  13. 0,
  14. GraphicConstants.SCREEN_HEIGHT + GraphicConstants.UP_GAP,
  15. GraphicConstants.SCREEN_WIDTH,
  16. GraphicConstants.DOWN_GAP - 1,
  17. GameSettings.gamecolor,
  18. 0x00000000
  19. )
  20. gui.drawRectangle(
  21. 0,
  22. 0,
  23. GraphicConstants.SCREEN_WIDTH,
  24. GraphicConstants.UP_GAP,
  25. GameSettings.gamecolor,
  26. GameSettings.gamecolor - 0x80000000
  27. )
  28. gui.drawText(
  29. GraphicConstants.SCREEN_WIDTH / 2 - ((string.len(GameSettings.gamename)+6) * 3),
  30. 3,
  31. "Game: " .. GameSettings.gamename,
  32. "white",
  33. 0x00000000,
  34. 10,
  35. "Lucida Console"
  36. )
  37. end
  38.  
  39. function Drawing.drawPokemonIcon(id, x, y, selectedPokemon)
  40. if id < 0 or id > 412 then
  41. id = 0
  42. end
  43. if selectedPokemon then
  44. gui.drawRectangle(x,y,36,36, GraphicConstants.SELECTEDCOLOR[1], GraphicConstants.SELECTEDCOLOR[2])
  45. else
  46. gui.drawRectangle(x,y,36,36, GraphicConstants.NONSELECTEDCOLOR, 0xFF222222)
  47. end
  48. gui.drawImage(DATA_FOLDER .. "/images/pokemon/" .. id .. ".gif", x+2, y+2, 32, 32)
  49. end
  50.  
  51. function Drawing.drawText(x, y, text, color)
  52. gui.drawText( x, y, text, color, null, 9, "Franklin Gothic Medium")
  53. end
  54.  
  55. function Drawing.drawTriangleRight(x, y, size, color)
  56. gui.drawRectangle(x, y, size, size, color)
  57. gui.drawPolygon({{4+x,4+y},{4+x,y+size-4},{x+size-4,y+size/2}}, color, color)
  58. end
  59. function Drawing.drawTriangleLeft(x, y, size, color)
  60. gui.drawRectangle(x, y, size, size, color)
  61. gui.drawPolygon({{x+size-4,4+y},{x+size-4,y+size-4},{4+x,y+size/2}}, color, color)
  62. end
  63.  
  64. function Drawing.drawGeneralInfo()
  65. local currng = Memory.readdword(GameSettings.rng)
  66. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 5, GraphicConstants.UP_GAP + GraphicConstants.SCREEN_HEIGHT + GraphicConstants.DOWN_GAP - 40, "RNG seed:")
  67. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 60, GraphicConstants.UP_GAP + GraphicConstants.SCREEN_HEIGHT + GraphicConstants.DOWN_GAP - 40, GameSettings.rngseed .. " (" .. Utils.tohex(GameSettings.rngseed) .. ")", "yellow")
  68. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 5, GraphicConstants.UP_GAP + GraphicConstants.SCREEN_HEIGHT + GraphicConstants.DOWN_GAP - 30, "RNG frame:")
  69. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 60, GraphicConstants.UP_GAP + GraphicConstants.SCREEN_HEIGHT + GraphicConstants.DOWN_GAP - 30, Utils.getRNGDistance(GameSettings.rngseed, currng), "yellow")
  70. end
  71.  
  72. function Drawing.drawPokemonView()
  73. Drawing.drawPokemonIcon(Program.selectedPokemon["pokemonID"], GraphicConstants.SCREEN_WIDTH + 5, 5)
  74. local colorbar = "white"
  75.  
  76. if Program.selectedPokemon["curHP"] / Program.selectedPokemon["maxHP"] <= 0.2 then
  77. colorbar = "red"
  78. elseif Program.selectedPokemon["curHP"] / Program.selectedPokemon["maxHP"] <= 0.5 then
  79. colorbar = "yellow"
  80. end
  81.  
  82. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 45, 7, PokemonData.name[Program.selectedPokemon["pokemonID"] + 1])
  83. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 45, 17, "HP:")
  84. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 60, 17, Program.selectedPokemon["curHP"] .. " / " .. Program.selectedPokemon["maxHP"], colorbar)
  85. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 45, 27, "Level: " .. Program.selectedPokemon["level"])
  86.  
  87. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 5, 43, "Item:")
  88. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 42, 43, PokemonData.item[Program.selectedPokemon["heldItem"] + 1], "yellow")
  89. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 5, 53, "PKRS:")
  90. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 42, 53, Program.selectedPokemon["pokerus"], "yellow")
  91. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 5, 63, "OT ID:")
  92. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 42, 63, Program.selectedPokemon["tid"], "yellow")
  93. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 75, 63, "OT SID:")
  94. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 112, 63, Program.selectedPokemon["sid"], "yellow")
  95.  
  96. gui.drawRectangle(GraphicConstants.SCREEN_WIDTH + 5, 75, GraphicConstants.RIGHT_GAP - 11, 85,0xFFAAAAAA, 0xFF222222)
  97.  
  98. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 60, 80, "Stat", "white")
  99. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 80, "IV", "white")
  100. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 120, 80, "EV", "white")
  101.  
  102. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 10, 95, "HP", Utils.getNatureColor("hp", Program.selectedPokemon["nature"]))
  103. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 10, 105, "Attack", Utils.getNatureColor("atk", Program.selectedPokemon["nature"]))
  104. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 10, 115, "Defense", Utils.getNatureColor("def", Program.selectedPokemon["nature"]))
  105. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 10, 125, "Sp. Atk", Utils.getNatureColor("spa", Program.selectedPokemon["nature"]))
  106. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 10, 135, "Sp. Def", Utils.getNatureColor("spd", Program.selectedPokemon["nature"]))
  107. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 10, 145, "Speed", Utils.getNatureColor("spe", Program.selectedPokemon["nature"]))
  108.  
  109. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 60, 95, Program.selectedPokemon["maxHP"], Utils.getNatureColor("hp", Program.selectedPokemon["nature"]))
  110. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 60, 105, Program.selectedPokemon["atk"], Utils.getNatureColor("atk", Program.selectedPokemon["nature"]))
  111. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 60, 115, Program.selectedPokemon["def"], Utils.getNatureColor("def", Program.selectedPokemon["nature"]))
  112. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 60, 125, Program.selectedPokemon["spa"], Utils.getNatureColor("spa", Program.selectedPokemon["nature"]))
  113. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 60, 135, Program.selectedPokemon["spd"], Utils.getNatureColor("spd", Program.selectedPokemon["nature"]))
  114. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 60, 145, Program.selectedPokemon["spe"], Utils.getNatureColor("spe", Program.selectedPokemon["nature"]))
  115.  
  116. local hpiv = Utils.getbits(Program.selectedPokemon["iv"], 0, 5)
  117. local atkiv = Utils.getbits(Program.selectedPokemon["iv"], 5, 5)
  118. local defiv = Utils.getbits(Program.selectedPokemon["iv"], 10, 5)
  119. local speiv = Utils.getbits(Program.selectedPokemon["iv"], 15, 5)
  120. local spaiv = Utils.getbits(Program.selectedPokemon["iv"], 20, 5)
  121. local spdiv = Utils.getbits(Program.selectedPokemon["iv"], 25, 5)
  122.  
  123. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 95, hpiv, Utils.getNatureColor("hp", Program.selectedPokemon["nature"]))
  124. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 105, atkiv, Utils.getNatureColor("atk", Program.selectedPokemon["nature"]))
  125. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 115, defiv, Utils.getNatureColor("def", Program.selectedPokemon["nature"]))
  126. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 125, spaiv, Utils.getNatureColor("spa", Program.selectedPokemon["nature"]))
  127. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 135, spdiv, Utils.getNatureColor("spd", Program.selectedPokemon["nature"]))
  128. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 145, speiv, Utils.getNatureColor("spe", Program.selectedPokemon["nature"]))
  129.  
  130. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 120, 95, Utils.getbits(Program.selectedPokemon["ev1"], 0, 8), Utils.getNatureColor("hp", Program.selectedPokemon["nature"]))
  131. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 120, 105, Utils.getbits(Program.selectedPokemon["ev1"], 8, 8), Utils.getNatureColor("atk", Program.selectedPokemon["nature"]))
  132. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 120, 115, Utils.getbits(Program.selectedPokemon["ev1"], 16, 8), Utils.getNatureColor("def", Program.selectedPokemon["nature"]))
  133. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 120, 125, Utils.getbits(Program.selectedPokemon["ev2"], 0, 8), Utils.getNatureColor("spa", Program.selectedPokemon["nature"]))
  134. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 120, 135, Utils.getbits(Program.selectedPokemon["ev2"], 8, 8), Utils.getNatureColor("spd", Program.selectedPokemon["nature"]))
  135. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 120, 145, Utils.getbits(Program.selectedPokemon["ev1"], 24, 8), Utils.getNatureColor("spe", Program.selectedPokemon["nature"]))
  136.  
  137. local hptype = math.floor(((hpiv%2 + 2*(atkiv%2) + 4*(defiv%2) + 8*(speiv%2) + 16*(spaiv%2) + 32*(spdiv%2))*15)/63)
  138. local hppower = math.floor(((Utils.getbits(hpiv,1,1) + 2*Utils.getbits(atkiv,1,1) + 4*Utils.getbits(defiv,1,1) + 8*Utils.getbits(speiv,1,1) + 16*Utils.getbits(spaiv,1,1) + 32*Utils.getbits(spdiv,1,1))*40)/63 + 30)
  139.  
  140. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 15, 162, "Nature:")
  141. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 80, 162, PokemonData.nature[Program.selectedPokemon["nature"] + 1], "yellow")
  142. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 15, 172, "Hidden Power:")
  143. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 80, 172, PokemonData.type[hptype + 1] .. " " .. hppower, "yellow")
  144.  
  145. gui.drawRectangle(GraphicConstants.SCREEN_WIDTH + 5, 185, GraphicConstants.RIGHT_GAP - 11, 65,0xFFAAAAAA, 0xFF222222)
  146.  
  147. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 10, 205, PokemonData.move[Program.selectedPokemon["move1"] + 1])
  148. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 10, 215, PokemonData.move[Program.selectedPokemon["move2"] + 1])
  149. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 10, 225, PokemonData.move[Program.selectedPokemon["move3"] + 1])
  150. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 10, 235, PokemonData.move[Program.selectedPokemon["move4"] + 1])
  151.  
  152. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 190, "PP")
  153. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 205, Utils.getbits(Program.selectedPokemon["pp"], 0, 8))
  154. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 215, Utils.getbits(Program.selectedPokemon["pp"], 8, 8))
  155. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 225, Utils.getbits(Program.selectedPokemon["pp"], 16, 8))
  156. Drawing.drawText(GraphicConstants.SCREEN_WIDTH + 90, 235, Utils.getbits(Program.selectedPokemon["pp"], 24, 8))
  157. end
  158.  
  159. function Drawing.drawMap()
  160. gui.drawImage(DATA_FOLDER .. "/images/map/" .. Map.file .. ".png", 1, GraphicConstants.UP_GAP + GraphicConstants.SCREEN_HEIGHT + 17, GraphicConstants.SCREEN_WIDTH - 1, 167)
  161. local position = {-7, GraphicConstants.UP_GAP + GraphicConstants.SCREEN_HEIGHT}
  162. local tilesize = 8
  163. local coords = Map.findCoords(Memory.readbyte(GameSettings.mapid))
  164.  
  165. local roameraddr = Memory.readdword(GameSettings.trainerpointer) + GameSettings.roamerpokemonoffset
  166. local roameravailable = Memory.readbyte(roameraddr + 19)
  167. local roamermapid = Memory.readbyte(GameSettings.mapbank + 7)
  168. if GameSettings.version == GameSettings.VERSIONS.FRLG then
  169. if roamermapid > 0x28 then
  170. roamermapid = roamermapid + 0x51
  171. else
  172. roamermapid = roamermapid + 0x52
  173. end
  174. end
  175. if roameravailable == 1 and roamermapid > 0 then
  176. local roamerid = Memory.readword(roameraddr + 8)
  177. local roamercoords = Map.findCoords(roamermapid)
  178. gui.drawImage(DATA_FOLDER .. "/images/pokemon/" .. roamerid .. ".gif", position[1] + (roamercoords[1] - 1)*8 - 8, position[2] + (roamercoords[2] - 1)*8 - 12, 32, 32)
  179. end
  180.  
  181. if Program.trainerInfo.gender >= 0 then
  182. local gender = 'girl'
  183. if Program.trainerInfo.gender == 0 then
  184. gender = 'boy'
  185. end
  186. if GameSettings.version == GameSettings.VERSIONS.E then
  187. gender = gender .. '-e'
  188. elseif GameSettings.version == GameSettings.VERSIONS.RS then
  189. gender = gender .. '-rs'
  190. else --frlg
  191. gender = gender .. '-frlg'
  192. end
  193. gui.drawImage(DATA_FOLDER .. "/images/player/" .. gender .. ".png", position[1] + (coords[1] - 1)*8, position[2] + (coords[2] - 1)*8, 16, 16)
  194. end
  195. gui.drawText(
  196. 2,
  197. GraphicConstants.UP_GAP + GraphicConstants.SCREEN_HEIGHT + 19,
  198. PokemonData.map[Memory.readbyte(GameSettings.mapid) + 1],
  199. "white",
  200. 0x00000000,
  201. 9,
  202. "Lucida Console"
  203. )
  204. end
  205.  
  206. function Drawing.drawButtons()
  207. for i = 1, table.getn(Buttons), 1 do
  208. if Buttons[i].visible() then
  209. if Buttons[i].type == ButtonType.singleButton then
  210. gui.drawRectangle(Buttons[i].box[1], Buttons[i].box[2], Buttons[i].box[3], Buttons[i].box[4], Buttons[i].backgroundcolor[1], Buttons[i].backgroundcolor[2])
  211. Drawing.drawText(Buttons[i].box[1] + 2, Buttons[i].box[2] + (Buttons[i].box[4] - 12) / 2 + 1, Buttons[i].text, Buttons[i].textcolor)
  212. elseif Buttons[i].type == ButtonType.horizontalMenu then
  213. local selecteditem = LayoutSettings.menus[Buttons[i].model].selecteditem
  214. local menuitems = LayoutSettings.menus[Buttons[i].model].items
  215. local itemcount = table.getn(menuitems)
  216. local itemwidth = Buttons[i].box[3] / itemcount
  217. for j = 1, itemcount, 1 do
  218. gui.drawRectangle((j-1) * itemwidth + Buttons[i].box[1], Buttons[i].box[2], itemwidth, Buttons[i].box[4], GraphicConstants.NONSELECTEDCOLOR)
  219. Drawing.drawText((j-1) * itemwidth + Buttons[i].box[1] + 2, Buttons[i].box[2] + (Buttons[i].box[4] - 12) / 2 + 1, menuitems[j], GraphicConstants.NONSELECTEDCOLOR)
  220. end
  221. gui.drawRectangle((selecteditem-1) * itemwidth + Buttons[i].box[1], Buttons[i].box[2], itemwidth, Buttons[i].box[4], GraphicConstants.SELECTEDCOLOR[1], GraphicConstants.SELECTEDCOLOR[2])
  222. Drawing.drawText((selecteditem-1) * itemwidth + Buttons[i].box[1] + 2, Buttons[i].box[2] + (Buttons[i].box[4] - 12) / 2 + 1, menuitems[selecteditem], GraphicConstants.SELECTEDCOLOR[1])
  223. elseif Buttons[i].type == ButtonType.horizontalMenuBar then
  224. local selecteditem = LayoutSettings.menus[Buttons[i].model].selecteditem
  225. local menuitems = LayoutSettings.menus[Buttons[i].model].items
  226. local itemcount = table.getn(menuitems)
  227. local itemwidth = (Buttons[i].box[3] - (Buttons[i].box[4] * 2)) / Buttons[i].visibleitems
  228. gui.drawRectangle(Buttons[i].box[1], Buttons[i].box[2], Buttons[i].box[4], Buttons[i].box[4], GraphicConstants.NONSELECTEDCOLOR)
  229. if Buttons[i].firstvisible > 1 then
  230. Drawing.drawTriangleLeft(Buttons[i].box[1], Buttons[i].box[2], Buttons[i].box[4], GraphicConstants.NONSELECTEDCOLOR)
  231. end
  232. gui.drawRectangle(Buttons[i].box[1] + Buttons[i].box[3] - Buttons[i].box[4], Buttons[i].box[2], Buttons[i].box[4], Buttons[i].box[4], GraphicConstants.NONSELECTEDCOLOR)
  233. if Buttons[i].firstvisible < itemcount - Buttons[i].visibleitems + 1 then
  234. Drawing.drawTriangleRight(Buttons[i].box[1] + Buttons[i].box[3] - Buttons[i].box[4], Buttons[i].box[2], Buttons[i].box[4], GraphicConstants.NONSELECTEDCOLOR)
  235. end
  236. for j = Buttons[i].firstvisible, Buttons[i].firstvisible + Buttons[i].visibleitems - 1, 1 do
  237. gui.drawRectangle((j-Buttons[i].firstvisible) * itemwidth + Buttons[i].box[1] + Buttons[i].box[4], Buttons[i].box[2], itemwidth, Buttons[i].box[4], GraphicConstants.NONSELECTEDCOLOR)
  238. Drawing.drawText((j-Buttons[i].firstvisible) * itemwidth + Buttons[i].box[1] + Buttons[i].box[4] + 2, Buttons[i].box[2] + (Buttons[i].box[4] - 12) / 2 + 1, menuitems[j], GraphicConstants.NONSELECTEDCOLOR)
  239. end
  240. local selecteditemposition = selecteditem - Buttons[i].firstvisible
  241. if selecteditemposition >= 0 and selecteditemposition < Buttons[i].visibleitems then
  242. gui.drawRectangle(selecteditemposition * itemwidth + Buttons[i].box[1] + Buttons[i].box[4], Buttons[i].box[2], itemwidth, Buttons[i].box[4], GraphicConstants.SELECTEDCOLOR[1], GraphicConstants.SELECTEDCOLOR[2])
  243. Drawing.drawText(selecteditemposition * itemwidth + Buttons[i].box[1] + Buttons[i].box[4] + 2, Buttons[i].box[2] + (Buttons[i].box[4] - 12) / 2 + 1, menuitems[selecteditem], GraphicConstants.SELECTEDCOLOR[1])
  244. end
  245. elseif Buttons[i].type == ButtonType.verticalMenu then
  246. local selecteditem = LayoutSettings.menus[Buttons[i].model].selecteditem
  247. local menuitems = LayoutSettings.menus[Buttons[i].model].items
  248. local itemcount = table.getn(menuitems)
  249. for j = 1, itemcount, 1 do
  250. gui.drawRectangle(Buttons[i].box_first[1], Buttons[i].box_first[2] + (j-1) * Buttons[i].box_first[4], Buttons[i].box_first[3], Buttons[i].box_first[4], GraphicConstants.NONSELECTEDCOLOR)
  251. local itemtext = menuitems[j]
  252. if LayoutSettings.menus[Buttons[i].model].accuracy and LayoutSettings.menus[Buttons[i].model].accuracy[j] ~= -1 then
  253. itemtext = menuitems[j] .. ' (' .. LayoutSettings.menus[Buttons[i].model].accuracy[j] .. '% acc.)'
  254. gui.drawRectangle(Buttons[i].box_first[1] + Buttons[i].box_first[3], Buttons[i].box_first[2] + (j-1) * Buttons[i].box_first[4], Buttons[i].box_first[4], Buttons[i].box_first[4], GraphicConstants.NONSELECTEDCOLOR)
  255. gui.drawRectangle(Buttons[i].box_first[1] + Buttons[i].box_first[3] + Buttons[i].box_first[4], Buttons[i].box_first[2] + (j-1) * Buttons[i].box_first[4], Buttons[i].box_first[4], Buttons[i].box_first[4], GraphicConstants.NONSELECTEDCOLOR)
  256. Drawing.drawText(Buttons[i].box_first[1] + Buttons[i].box_first[3] + 3, Buttons[i].box_first[2] + (j-1) * Buttons[i].box_first[4] + (Buttons[i].box_first[4] - 12) / 2 + 1, '-', GraphicConstants.NONSELECTEDCOLOR)
  257. Drawing.drawText(Buttons[i].box_first[1] + Buttons[i].box_first[3] + Buttons[i].box_first[4] + 3, Buttons[i].box_first[2] + (j-1) * Buttons[i].box_first[4] + (Buttons[i].box_first[4] - 12) / 2 + 1, '+', GraphicConstants.NONSELECTEDCOLOR)
  258. end
  259. Drawing.drawText(Buttons[i].box_first[1] + 2, Buttons[i].box_first[2] + (j-1) * Buttons[i].box_first[4] + (Buttons[i].box_first[4] - 12) / 2 + 1, itemtext, GraphicConstants.NONSELECTEDCOLOR)
  260. end
  261. gui.drawRectangle(Buttons[i].box_first[1], Buttons[i].box_first[2] + (selecteditem-1) * Buttons[i].box_first[4], Buttons[i].box_first[3], Buttons[i].box_first[4], GraphicConstants.SELECTEDCOLOR[1], GraphicConstants.SELECTEDCOLOR[2])
  262. local itemtext = menuitems[selecteditem]
  263. if LayoutSettings.menus[Buttons[i].model].accuracy and LayoutSettings.menus[Buttons[i].model].accuracy[selecteditem] ~= -1 then
  264. itemtext = menuitems[selecteditem] .. ' (' .. LayoutSettings.menus[Buttons[i].model].accuracy[selecteditem] .. '% acc.)'
  265. gui.drawRectangle(Buttons[i].box_first[1] + Buttons[i].box_first[3], Buttons[i].box_first[2] + (selecteditem-1) * Buttons[i].box_first[4], Buttons[i].box_first[4], Buttons[i].box_first[4], GraphicConstants.SELECTEDCOLOR[1], GraphicConstants.SELECTEDCOLOR[2])
  266. gui.drawRectangle(Buttons[i].box_first[1] + Buttons[i].box_first[3] + Buttons[i].box_first[4], Buttons[i].box_first[2] + (selecteditem-1) * Buttons[i].box_first[4], Buttons[i].box_first[4], Buttons[i].box_first[4], GraphicConstants.SELECTEDCOLOR[1], GraphicConstants.SELECTEDCOLOR[2])
  267. Drawing.drawText(Buttons[i].box_first[1] + Buttons[i].box_first[3] + 3, Buttons[i].box_first[2] + (selecteditem-1) * Buttons[i].box_first[4] + (Buttons[i].box_first[4] - 12) / 2 + 1, '-', GraphicConstants.SELECTEDCOLOR[1])
  268. Drawing.drawText(Buttons[i].box_first[1] + Buttons[i].box_first[3] + Buttons[i].box_first[4] + 3, Buttons[i].box_first[2] + (selecteditem-1) * Buttons[i].box_first[4] + (Buttons[i].box_first[4] - 12) / 2 + 1, '+', GraphicConstants.SELECTEDCOLOR[1])
  269. end
  270. Drawing.drawText(Buttons[i].box_first[1] + 2, Buttons[i].box_first[2] + (selecteditem-1) * Buttons[i].box_first[4] + (Buttons[i].box_first[4] - 12) / 2 + 1, itemtext, GraphicConstants.SELECTEDCOLOR[1])
  271. elseif Buttons[i].type == ButtonType.pokemonteamMenu then
  272. local team = Program.trainerPokemonTeam
  273. if Buttons[i].team == 2 then
  274. team = Program.enemyPokemonTeam
  275. end
  276. gui.drawText(Buttons[i].position[1] + 4, Buttons[i].position[2] - 13, Buttons[i].text, 'cyan', null, 10, 'Arial')
  277. for j = 1,6,1 do
  278. Drawing.drawPokemonIcon(team[j]['pkmID'], Buttons[i].position[1] + (j-1) * 39, Buttons[i].position[2], LayoutSettings.pokemonIndex.player == Buttons[i].team and LayoutSettings.pokemonIndex.slot == j)
  279. if team[j]['pkmID'] > 0 then
  280. local colorbar = 'white'
  281. if team[j]['curHP'] / team[j]['maxHP'] <= 0.2 then
  282. colorbar = 'red'
  283. elseif team[j]['curHP'] / team[j]['maxHP'] <= 0.2 then
  284. colorbar = 'yellow'
  285. end
  286. Drawing.drawText(Buttons[i].position[1] + (j-1) * 39, Buttons[i].position[2] + 36, "Lv. " .. team[j]['level'])
  287. Drawing.drawText(Buttons[i].position[1] + (j-1) * 39 - 1, Buttons[i].position[2] + 46, team[j]['curHP'] .. "/" .. team[j]['maxHP'], colorbar)
  288. end
  289. end
  290. elseif Buttons[i].type == ButtonType.rngViewButtons then
  291. local position = Buttons[i].position()
  292. gui.drawRectangle(position[1] + 15, position[2], Buttons[i].buttonsize, Buttons[i].buttonsize)
  293. gui.drawRectangle(position[1] + 50, position[2], Buttons[i].buttonsize, Buttons[i].buttonsize)
  294. gui.drawRectangle(position[1] + 50 + Buttons[i].buttonsize, position[2], Buttons[i].buttonsize, Buttons[i].buttonsize)
  295. Drawing.drawText(position[1] + 18, position[2] + 1, LayoutSettings.rng.modulo)
  296. Drawing.drawText(position[1] + 53, position[2] + 1, '-')
  297. Drawing.drawText(position[1] + 53 + Buttons[i].buttonsize, position[2] + 1, '+')
  298. elseif Buttons[i].type == ButtonType.encounterSlots then
  299. local encountermode = LayoutSettings.menus[Buttons[i].model].selecteditem
  300. if Program.map.encounters[encountermode].encrate > 0 then
  301. for j = 1, Program.map.encounters[encountermode].SLOTS, 1 do
  302. local levelstr = Program.map.encounters[encountermode].pokemon[j].minlevel
  303. if Program.map.encounters[encountermode].pokemon[j].minlevel ~= Program.map.encounters[encountermode].pokemon[j].maxlevel then
  304. local levelstr = levelstr .. '-' .. Program.map.encounters[encountermode].pokemon[j].maxlevel
  305. end
  306. if LayoutSettings.selectedslot[j] then
  307. gui.drawRectangle(Buttons[i].box_first[1], Buttons[i].box_first[2] + j * (Buttons[i].box_first[4] + 2), Buttons[i].box_first[4], Buttons[i].box_first[4], 'white', GraphicConstants.SLOTCOLORS[j])
  308. Drawing.drawText(Buttons[i].box_first[1] + 10, Buttons[i].box_first[2] - 2 + j * (Buttons[i].box_first[4] + 2), "Slot " .. j .. " (" .. Program.map.encounters[encountermode].RATES[j] .. "%):")
  309. Drawing.drawText(Buttons[i].box_first[1] + 61, Buttons[i].box_first[2] - 2 + j * (Buttons[i].box_first[4] + 2), PokemonData.name[Program.map.encounters[encountermode].pokemon[j].id + 1] .. " Lv. " .. levelstr)
  310. else
  311. gui.drawRectangle(Buttons[i].box_first[1], Buttons[i].box_first[2] + j * (Buttons[i].box_first[4] + 2), Buttons[i].box_first[4], Buttons[i].box_first[4], 'gray', GraphicConstants.SLOTCOLORS[j])
  312. Drawing.drawText(Buttons[i].box_first[1] + 10, Buttons[i].box_first[2] - 2 + j * (Buttons[i].box_first[4] + 2), "Slot " .. j .. " (" .. Program.map.encounters[encountermode].RATES[j] .. "%):", "gray")
  313. Drawing.drawText(Buttons[i].box_first[1] + 61, Buttons[i].box_first[2] - 2 + j * (Buttons[i].box_first[4] + 2), PokemonData.name[Program.map.encounters[encountermode].pokemon[j].id + 1] .. " Lv. " .. levelstr, "gray")
  314. end
  315. end
  316. else
  317. Drawing.drawText(Buttons[i].box_first[1] + 10, Buttons[i].box_first[2] + 7, 'No encounters')
  318. end
  319. elseif Buttons[i].type == ButtonType.pickupData then
  320. local pickupitem = PickupData[GameSettings.version].item
  321. local pickuprarity = PickupData[GameSettings.version].rarity
  322. if GameSettings.version == GameSettings.VERSIONS.E then
  323. pickupitem = pickupitem[LayoutSettings.menus.pickuplevel.selecteditem]
  324. end
  325. for j = 1, table.getn(pickupitem), 1 do
  326. if LayoutSettings.selectedslot[j] then
  327. gui.drawRectangle(Buttons[i].box_first[1], Buttons[i].box_first[2] + j * (Buttons[i].box_first[4] + 2), Buttons[i].box_first[4], Buttons[i].box_first[4], 'white', GraphicConstants.SLOTCOLORS[j])
  328. Drawing.drawText(Buttons[i].box_first[1] + 10, Buttons[i].box_first[2] - 2 + j * (Buttons[i].box_first[4] + 2), "(" .. pickuprarity[j] .. "%):")
  329. Drawing.drawText(Buttons[i].box_first[1] + 40, Buttons[i].box_first[2] - 2 + j * (Buttons[i].box_first[4] + 2), PokemonData.item[pickupitem[j] + 1])
  330. else
  331. gui.drawRectangle(Buttons[i].box_first[1], Buttons[i].box_first[2] + j * (Buttons[i].box_first[4] + 2), Buttons[i].box_first[4], Buttons[i].box_first[4], 'gray', GraphicConstants.SLOTCOLORS[j])
  332. Drawing.drawText(Buttons[i].box_first[1] + 10, Buttons[i].box_first[2] - 2 + j * (Buttons[i].box_first[4] + 2), "(" .. pickuprarity[j] .. "%):", 'gray')
  333. Drawing.drawText(Buttons[i].box_first[1] + 40, Buttons[i].box_first[2] - 2 + j * (Buttons[i].box_first[4] + 2), PokemonData.item[pickupitem[j] + 1], 'gray')
  334. end
  335. end
  336. elseif Buttons[i].type == ButtonType.catchData then
  337. local enabled = Buttons[i].enabled()
  338. local data = Buttons[i].data()
  339. for j = 1, table.getn(Buttons[i].text), 1 do
  340. local itemcolor = GraphicConstants.NONSELECTEDCOLOR
  341. if enabled[j] then
  342. itemcolor = 'white'
  343. end
  344. gui.drawRectangle(Buttons[i].box_first[1], Buttons[i].box_first[2] + j * Buttons[i].box_first[4], Buttons[i].box_first[3], Buttons[i].box_first[4], GraphicConstants.NONSELECTEDCOLOR)
  345. Drawing.drawText(Buttons[i].box_first[1] + 2 - 50, Buttons[i].box_first[2] + j * Buttons[i].box_first[4] + 1, Buttons[i].text[j], GraphicConstants.NONSELECTEDCOLOR)
  346. Drawing.drawText(Buttons[i].box_first[1] + 2, Buttons[i].box_first[2] + j * Buttons[i].box_first[4] + 1, data[j], itemcolor)
  347. end
  348. end
  349. end
  350. end
  351. end
  352.  
  353. function Drawing.drawCatchRate()
  354. Drawing.drawText(102, 306, 'RNG:', GraphicConstants.NONSELECTEDCOLOR)
  355. Drawing.drawText(102, 319, 'Catch rate:', GraphicConstants.NONSELECTEDCOLOR)
  356. Drawing.drawText(152, 306, Program.catchdata.rng .. " / 65536", GraphicConstants.SELECTEDCOLOR[1])
  357. Drawing.drawText(152, 319, (Program.catchdata.rate * 100) .. "%", GraphicConstants.SELECTEDCOLOR[1])
  358. end
  359.  
  360. function Drawing.drawRNGPanel()
  361. local position = {4, GraphicConstants.SCREEN_HEIGHT + GraphicConstants.UP_GAP * 2 + 20}
  362.  
  363. local textstart = position[2] + LayoutSettings.rng.rows * LayoutSettings.rng.squaresize + 20
  364. local distancelast = Utils.getRNGDistance(Program.rng.previous, Program.rng.current)
  365.  
  366. -- DRAW RNG GRID LAYOUT --
  367. local bglinecolor
  368. local borderlinecolor
  369. if distancelast <= LayoutSettings.rng.modulo then
  370. borderlinecolor = 'white'
  371. bglinecolor = 0xFF000000
  372. else
  373. borderlinecolor = 'red'
  374. bglinecolor = 0xFF555500
  375. end
  376. gui.drawRectangle(position[1], position[2], LayoutSettings.rng.columns * LayoutSettings.rng.squaresize + 2, LayoutSettings.rng.rows * LayoutSettings.rng.squaresize + 2, borderlinecolor, bglinecolor)
  377. for j = 0, LayoutSettings.rng.columns - 1, 1 do
  378. local clr = 0xFF606060
  379. if j % LayoutSettings.rng.modulo == 0 then
  380. clr = 0xFFB0B0B0
  381. end
  382. gui.drawRectangle(j*LayoutSettings.rng.squaresize + position[1] + 2, position[2] + 2, LayoutSettings.rng.squaresize - 2, LayoutSettings.rng.rows * LayoutSettings.rng.squaresize - 2, clr, clr)
  383. end
  384. for i = 0, LayoutSettings.rng.rows - 1, 2 do
  385. gui.drawRectangle(position[1]+1, i*LayoutSettings.rng.squaresize + position[2] + 1, LayoutSettings.rng.columns * LayoutSettings.rng.squaresize, LayoutSettings.rng.squaresize, bglinecolor)
  386. end
  387.  
  388. -- DRAW RNG SQUARES --
  389. for i = 1, LayoutSettings.rng.rows, 1 do
  390. for j = 1, LayoutSettings.rng.columns, 1 do
  391. if Program.rng.grid[i][j] ~= -1 then
  392. if Program.rng.grid[i][j] ~= -1 then
  393. gui.drawRectangle((j-1)*LayoutSettings.rng.squaresize + position[1] + 2, (i-1)*LayoutSettings.rng.squaresize + position[2] + 2, LayoutSettings.rng.squaresize - 2, LayoutSettings.rng.squaresize - 2, Program.rng.grid[i][j], Program.rng.grid[i][j])
  394. end
  395. end
  396. end
  397. end
  398.  
  399. Drawing.drawText(2, textstart, "RNG value:")
  400. Drawing.drawText(50, textstart, Utils.tohex(Program.rng.current), "yellow")
  401. Drawing.drawText(2, textstart + 10, "RNG prev:")
  402. Drawing.drawText(50, textstart + 10, Utils.tohex(Program.rng.previous), "yellow")
  403. Drawing.drawText(2, textstart + 20, "Dist. last:")
  404. Drawing.drawText(50, textstart + 20, distancelast, "yellow")
  405. Drawing.drawText(2, textstart + 30, "RNG frame:")
  406. Drawing.drawText(50, textstart + 30, Utils.getRNGDistance(GameSettings.rngseed, Program.rng.current), "yellow")
  407. end
Add Comment
Please, Sign In to add comment