You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
12 KiB

  1. mainMenu = Class{}
  2. function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, location)
  3. if (gameState == 'editor')
  4. then
  5. ev_button_width = VIRTUAL_WIDTH * (1/72)
  6. ev_BUTTON_HEIGHT = VIRTUAL_WIDTH * (1/72)
  7. local margin = 16
  8. local hot = false
  9. local cursor_y = 0
  10. blockinput = false
  11. local total_height = (ev_BUTTON_HEIGHT + margin) * #buttons
  12. for i, button in ipairs(buttons) do
  13. button.last = button.now
  14. ev_bx = (VIRTUAL_WIDTH*0.05) - (ev_button_width * 0.5)
  15. ev_by = (VIRTUAL_HEIGHT * 0.1) - (total_height * 0.5) + cursor_y
  16. local color = {255, 255, 255, 255}
  17. local mx, my = love.mouse.getPosition()
  18. mx = mx
  19. my = my
  20. mx = mx * DIFFERENCE_X
  21. my = my * DIFFERENCE_Y
  22. hot = (mx > ev_bx and mx < ev_bx + ev_button_width and my > ev_by and my < ev_by + ev_BUTTON_HEIGHT) and i
  23. if (hot == i) then
  24. blockinput = blockinput or true
  25. color = {10, 10, 0, 255}
  26. end
  27. button.now = love.keyboard.mouseWasReleased()
  28. if button.now and not button.last and hot == i then
  29. love.keyboard.mouseisReleased = false
  30. love.graphics.setColor(0,0,0,1)
  31. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  32. sounds['wallhit']:play()
  33. button.fn()
  34. end
  35. love.graphics.setColor(unpack(color))
  36. love.graphics.rectangle("fill", ev_bx,ev_by, ev_button_width, ev_BUTTON_HEIGHT)
  37. love.graphics.setColor(0, 0, 0, 255)
  38. local textW = smallfont:getWidth(button.text)
  39. local textH = smallfont:getHeight(button.text)
  40. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH*0.05 - textW*0.5, ev_by*0.9+textH*0.01)
  41. love.graphics.setColor(255, 255, 255, 255)
  42. cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin)
  43. end
  44. else
  45. if location == 'middle' then
  46. locationx = (VIRTUAL_WIDTH * 0.5)
  47. locationy = (VIRTUAL_HEIGHT* 0.5)
  48. elseif location == 'right' then
  49. locationx = (VIRTUAL_WIDTH * 0.8)
  50. locationy = (VIRTUAL_HEIGHT* 0.5)
  51. elseif location == 'control' then
  52. locationx = (VIRTUAL_WIDTH * 0.2)
  53. locationy = (VIRTUAL_HEIGHT* 0.5)
  54. elseif location == "android" then
  55. locationx = (VIRTUAL_WIDTH * 0.5)
  56. locationy = (10)
  57. end
  58. local ev_button_width = VIRTUAL_WIDTH * (1/3)
  59. local ev_BUTTON_HEIGHT = 50
  60. if location == "android" then
  61. ev_button_width = 30
  62. ev_BUTTON_HEIGHT = 30
  63. end
  64. local margin = 16
  65. local hot = false
  66. local cursor_y = 0
  67. local total_height = (ev_BUTTON_HEIGHT + margin) * #buttons
  68. local ev_bx, ev_by
  69. for i, button in ipairs(buttons) do
  70. button.last = button.now
  71. if (location == 'control') then
  72. if string.sub(button.text, 1, 1) == '2' then
  73. ev_bx = (VIRTUAL_WIDTH*0.2) - (ev_button_width * 0.5)
  74. ev_by = locationy - (total_height * 0.5) + cursor_y
  75. elseif string.sub(button.text, 1, 1) == '1' then
  76. ev_bx = (VIRTUAL_WIDTH*0.8) - (ev_button_width * 0.5)
  77. ev_by = locationy - (total_height * 0.5) + cursor_y
  78. else
  79. ev_bx = (VIRTUAL_WIDTH*0.5) - (ev_button_width * 0.5)
  80. ev_by = locationy - (total_height * 0.5) + cursor_y
  81. end
  82. elseif button.text == 'NUCLEAR MODE' and easternum < 11 then
  83. ev_bx = -400
  84. ev_by = -400
  85. else
  86. ev_bx = locationx - (ev_button_width * 0.5)
  87. ev_by = locationy - (total_height * 0.5) + cursor_y
  88. end
  89. if (button.text == 'Play') and location == 'playercount' then color = {0/255, 255/255, 0/255, 255} else
  90. color = {10, 10, 0, 255}
  91. end
  92. local color = {255, 255, 255, 255}
  93. if (button.text == 'NUCLEAR MODE' and easternum > 10) then
  94. color = {0,0,0,1}
  95. else
  96. color = {1,1,1,1}
  97. end
  98. local mx, my = love.mouse.getPosition()
  99. mx = mx
  100. my = my
  101. local mx = mx * DIFFERENCE_X
  102. local my = my * DIFFERENCE_Y
  103. local hot = (mx > ev_bx and mx < ev_bx + ev_button_width and my > ev_by and my < ev_by + ev_BUTTON_HEIGHT) and i
  104. if (hot == i) then
  105. color = {10, 10, 0, 255}
  106. end
  107. --print(love.keyboard.mouseisReleased)
  108. button.now = love.keyboard.mouseisReleased
  109. if location == "android" then
  110. button.now = love.mouse.isDown(1)
  111. end
  112. if button.now and hot == i then
  113. love.keyboard.mouseisReleased = false
  114. love.graphics.setColor(0,0,0,1)
  115. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  116. sounds['wallhit']:play()
  117. button.fn()
  118. end
  119. love.graphics.setColor(unpack(color))
  120. love.graphics.rectangle("fill", ev_bx,ev_by, ev_button_width, ev_BUTTON_HEIGHT)
  121. love.graphics.setColor(0, 0, 0, 255)
  122. local textW = smallfont:getWidth(button.text)
  123. local textH = smallfont:getHeight(button.text)
  124. if (location == 'control') then
  125. if danger == button.text or danger2 == button.text then
  126. love.graphics.setColor(1,0,0,1)
  127. else
  128. love.graphics.setColor(0,0,0,1)
  129. end
  130. if (button.text == "1up") then
  131. love.graphics.print("P1 UP: " .. string.upper(p1control.up), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
  132. elseif button.text == '2up' then
  133. love.graphics.print("P2 UP: " .. string.upper(p2control.up), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
  134. elseif button.text == '1down' then
  135. love.graphics.print("P1 DOWN: " .. string.upper(p1control.down), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
  136. elseif button.text == '2down' then
  137. love.graphics.print("P2 DOWN: " .. string.upper(p2control.down), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
  138. elseif button.text == '1special' then
  139. love.graphics.print("P1 SPECIAL: " .. string.upper(p1control.super), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
  140. elseif button.text == '2special' then
  141. love.graphics.print("P2 SPECIAL: " .. string.upper(p2control.super), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
  142. elseif button.text == '1ct' then
  143. love.graphics.print("P1 COUNTER: " .. string.upper(p1control.counter), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
  144. elseif button.text == '2ct' then
  145. love.graphics.print("P2 COUNTER: " .. string.upper(p2control.counter), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
  146. else
  147. love.graphics.print(button.text, smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
  148. end
  149. cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin)
  150. else
  151. if (button.text == '1v1') then
  152. love.graphics.print(playertext, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5)
  153. elseif button.text == 'snc' then
  154. if (nuckemodactive == 1) then
  155. love.graphics.setColor(1,0,0,1)
  156. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.7, ev_by+textH*0.5)
  157. love.graphics.setColor(1,1,1,1)
  158. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.7, ev_by+textH*0.5)
  159. love.graphics.setColor(0,0,0,1)
  160. else
  161. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH*0.45 - textW*0.5, ev_by+textH*0.5)
  162. end
  163. elseif (button.text == 'ballCount') then
  164. love.graphics.print("Ball Count: " .. maxBalls, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.7, ev_by+textH*0.5)
  165. elseif (button.text == "Ball Speed: ") then
  166. if (nuckemodactive == 1) then
  167. love.graphics.setColor(1,0,0,1)
  168. love.graphics.print("shaitan machina", smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, ev_by+textH*0.5)
  169. love.graphics.setColor(1,1,1,1)
  170. love.graphics.print("shaitan machina", smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, ev_by+textH*0.5)
  171. love.graphics.setColor(0,0,0,1)
  172. else
  173. love.graphics.print(button.text .. ballSet, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.6, ev_by+textH*0.5)
  174. end
  175. elseif button.text == 'ptw' then
  176. love.graphics.print("Points to Win: " .. ptw, smallfont,VIRTUAL_WIDTH*0.5 - textW * 2.8, ev_by+textH*0.5)
  177. elseif (button.text == 'Silverblade') then
  178. love.graphics.print("Difficulty: " .. prtext, smallfont, VIRTUAL_WIDTH*0.5 - textW , ev_by+textH*0.5)
  179. else
  180. love.graphics.print(button.text, smallfont, locationx - textW*0.5, ev_by+textH*0.5)
  181. end
  182. love.graphics.setColor(255, 255, 255, 255)
  183. cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin)
  184. end
  185. end
  186. end
  187. end
  188. function mainMenu:addButton(text, fn)
  189. return {
  190. text = text,
  191. fn = fn,
  192. now = false,
  193. last = false
  194. }
  195. end
  196. function menuButtons()
  197. local button_width = VIRTUAL_WIDTH * (1/3)
  198. local BUTTON_HEIGHT = 50
  199. local margin = 16
  200. local hot = false
  201. local cursor_y = 0
  202. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  203. for i, button in ipairs(buttons) do
  204. button.last = button.now
  205. local bx = (VIRTUAL_WIDTH*0.5) - (button_width * 0.5)
  206. local by = (VIRTUAL_HEIGHT * 0.8) - (total_height * 0.5) + cursor_y
  207. local color = {255, 255, 255, 255}
  208. local mx, my = love.mouse.getPosition()
  209. mx = mx
  210. my = my
  211. mx = mx * DIFFERENCE_X
  212. my = my * DIFFERENCE_Y
  213. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  214. if (hot == i) then
  215. color = {10, 10, 0, 255}
  216. end
  217. button.now = love.keyboard.mouseWasReleased()
  218. if button.now and not button.last and hot == i then
  219. love.keyboard.mouseisReleased = false
  220. love.graphics.setColor(0,0,0,1)
  221. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  222. sounds['wallhit']:play()
  223. button.fn()
  224. end
  225. love.graphics.setColor(unpack(color))
  226. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  227. love.graphics.setColor(0, 0, 0, 255)
  228. local textW = smallfont:getWidth(button.text)
  229. local textH = smallfont:getHeight(button.text)
  230. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5)
  231. love.graphics.setColor(255, 255, 255, 255)
  232. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  233. end
  234. end