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.

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