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.

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