Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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