Advertisement
luistop12

Custom Menu

Apr 22nd, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.40 KB | None | 0 0
  1. #----------------------------------------------------------------
  2. # SCENE_MENU
  3. #----------------------------------------------------------------
  4. # Creado por: Jão
  5. # Versión: 1.0
  6. # Agradecimientos: DarkChocobo
  7. #
  8. # Modifica el menú del juego. Sustitúyelo por este.
  9. #----------------------------------------------------------------
  10.  
  11. class Scene_Menu < Scene_Base
  12.  
  13. def initialize(menu_index = 0)
  14. @menu_index = menu_index
  15. end
  16.  
  17. def start
  18. super
  19. create_menu_background
  20. create_command_window
  21. @gold_window = Window_Gold.new(0, 360)
  22. @status_window = Window_MenuStatus.new(0, 56)
  23. @window_local = Window_Local.new(120,360)
  24. @time = Window_Time.new(360,360)
  25. end
  26.  
  27. def terminate
  28. super
  29. dispose_menu_background
  30. @command_window.dispose
  31. @gold_window.dispose
  32. @status_window.dispose
  33. @window_local.dispose
  34. @time.dispose
  35. end
  36.  
  37. def update
  38. super
  39. update_menu_background
  40. @command_window.update
  41. @gold_window.update
  42. @status_window.update
  43. @window_local.update
  44. @time.update
  45. if @command_window.active
  46. update_command_selection
  47. elsif @status_window.active
  48. update_actor_selection
  49. end
  50. end
  51.  
  52. def create_command_window
  53. s1 = Vocab::item
  54. s2 = Vocab::save
  55. s3 = Vocab::game_end
  56. @command_window = Window_Command.new(544, [s1, s2, s3],3)
  57. @command_window.index = @menu_index
  58. if $game_party.members.size == 0
  59. @command_window.draw_item(0, false)
  60. @command_window.draw_item(2, false)
  61. end
  62. if $game_system.save_disabled
  63. @command_window.draw_item(1, false)
  64. end
  65. end
  66.  
  67. def update_command_selection
  68. if Input.trigger?(Input::B)
  69. Sound.play_cancel
  70. $scene = Scene_Map.new
  71. elsif Input.trigger?(Input::C)
  72. if $game_party.members.size == 0 and @command_window.index < 4
  73. Sound.play_buzzer
  74. return
  75. elsif $game_system.save_disabled and @command_window.index == 1
  76. Sound.play_buzzer
  77. return
  78. end
  79. Sound.play_decision
  80. case @command_window.index
  81. when 0
  82. $scene = Scene_Item.new
  83. when 1
  84. $scene = Scene_File.new(true, false, false)
  85. when 2
  86. $scene = Scene_End.new
  87. end
  88. end
  89. end
  90.  
  91. def start_actor_selection
  92. @command_window.active = false
  93. @status_window.active = true
  94. if $game_party.last_actor_index < @status_window.item_max
  95. @status_window.index = $game_party.last_actor_index
  96. else
  97. @status_window.index = 0
  98. end
  99. end
  100.  
  101. def end_actor_selection
  102. @command_window.active = true
  103. @status_window.active = false
  104. @status_window.index = -1
  105. end
  106.  
  107. def update_actor_selection
  108. if Input.trigger?(Input::B)
  109. Sound.play_cancel
  110. end_actor_selection
  111. elsif Input.trigger?(Input::C)
  112. $game_party.last_actor_index = @status_window.index
  113. Sound.play_decision
  114. case @command_window.index
  115. when 1
  116.  
  117. when 2
  118.  
  119. when 3
  120.  
  121. end
  122. end
  123. end
  124. end
  125.  
  126. class Window_MenuStatus < Window_Selectable
  127. def initialize(x, y)
  128. super(x, y, 544, 304)
  129. @column_max = 2
  130. refresh
  131. self.active = false
  132. self.index = -1
  133. end
  134. def refresh
  135. self.contents.clear
  136. @item_max = $game_party.members.size
  137. for actor in $game_party.members
  138. x = actor.index % @column_max * self.width/2 + 96
  139. y = actor.index / @column_max * 96 + WLH / 2
  140. draw_actor_face(actor, x - 96, y, 92)
  141. draw_actor_name(actor, x, y)
  142. draw_actor_graphic(actor, x , y + WLH * 4)
  143. # draw_actor_level(actor, x + 80, y)
  144. # draw_actor_state(actor, x, y + WLH * 3)
  145. draw_actor_hp(actor, x , y + WLH * 1)
  146. # draw_actor_mp(actor, x , y + WLH * 2)
  147. end
  148. end
  149. def update_cursor
  150. case @index
  151. when -1
  152. self.cursor_rect.empty
  153. when 0, 1, 2, 3
  154. self.cursor_rect.set(@index % @column_max * self.width/2 - 4, index / @column_max * 96 + WLH / 2 - 4, self.width / 2 - 32 +4, 96+4)
  155. else
  156. self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
  157. end
  158. end
  159. end
  160.  
  161. class Game_Map
  162. attr_reader :map_id
  163. def namemap
  164. $name_map = load_data("Data/MapInfos.rvdata")
  165. $name_map[@map_id].name
  166. end
  167. end
  168.  
  169. class Window_Local < Window_Base
  170. def initialize(x,y)
  171. super(x, y, 240, WLH + 32)
  172. refresh
  173. end
  174. def refresh
  175. self.contents.clear
  176. self.contents.font.color = system_color
  177. self.contents.draw_text(-2, -5, 200, 32, "indiegames.esy.es")
  178. self.contents.font.color = normal_color
  179. #self.contents.draw_text(59, -5, 210, 32, $game_map.namemap.to_s)
  180. end
  181. end
  182.  
  183. class Window_Gold < Window_Base
  184.  
  185. def initialize(x, y)
  186. super(x, y, 120, WLH + 32)
  187. refresh
  188. end
  189.  
  190. def refresh
  191. self.contents.clear
  192. draw_currency_value($game_party.gold, 4, 0, 80)
  193. end
  194. end
  195.  
  196. class Window_Time < Window_Base
  197. def initialize(x, y)
  198. super(x, y, 184, WLH + 32)
  199. refresh
  200. end
  201. def refresh
  202. self.contents.clear
  203. self.contents.font.color = system_color
  204. self.contents.draw_text(0, -5, 200, 32, "Tiempo:")
  205. @total_sec = Graphics.frame_count / Graphics.frame_rate
  206. hour = @total_sec / 60 / 60
  207. min = @total_sec / 60 % 60
  208. sec = @total_sec % 60
  209. text = sprintf("%02d:%02d:%02d", hour, min, sec)
  210. self.contents.font.color = normal_color
  211. self.contents.draw_text(67, -5, 200, 32, text)
  212. end
  213. def update
  214. super
  215. if Graphics.frame_count / Graphics.frame_rate != @total_sec
  216. refresh
  217. end
  218. end
  219. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement