Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.78 KB | None | 0 0
  1. #==============================================================================
  2. # XaiL System - Menu Delux
  3. # Author: Nicke
  4. # Created: 20/11/2012
  5. # Edited: 08/02/2013
  6. # Version: 1.1b
  7. #==============================================================================
  8. # Instructions
  9. # -----------------------------------------------------------------------------
  10. # To install this script, open up your script editor and copy/paste this script
  11. # to an open slot below ? Materials but above ? Main. Remember to save.
  12. #==============================================================================
  13. # Requires: XS - Core Script.
  14. #==============================================================================
  15. #
  16. # This script changes the way the menu scene works. Not compatible with
  17. # XS - Menu or XS - Icon Menu.
  18. #
  19. # Instructions are in the settings module below. Make sure you read through
  20. # everything so you understand each section.
  21. #
  22. # *** Only for RPG Maker VX Ace. ***
  23. #==============================================================================
  24. ($imported ||= {})["XAIL-XS-MENU_DELUX"] = true
  25.  
  26. module XAIL
  27. module MENU_DELUX
  28. #--------------------------------------------------------------------------#
  29. # * Settings
  30. #--------------------------------------------------------------------------#
  31. # FONT:
  32. # FONT = [name, size, color, bold, shadow]
  33. FONT = [["Calibri", "Verdana"], 18, Color.new(255,255,255), true, true]
  34.  
  35. # PLAYTIME_ICON:
  36. # Set playtime window icon.
  37. # PLAYTIME_ICON = icon_id
  38. PLAYTIME_ICON = 0
  39.  
  40. # MENU_ALIGNMENT:
  41. # MENU_ALIGNMENT = 0 (left), 1 (center), 2 (right)
  42. MENU_ALIGNMENT = 0 # Default: 2.
  43.  
  44. # MENU_SKIN:
  45. # The windowskin to use for the windows.
  46. # Set to nil to disable.
  47. # MENU_SKIN = string
  48. MENU_SKIN = nil
  49.  
  50. # MENU_LIST:
  51. # name, icon_index and custom are optional.
  52. # If name is empty it will use the corresponding symbol as name instead.
  53. # To make a command a common event you need to set custom to the common event
  54. # id you want to run as seen below.
  55. # symbol => [name, description, icon_index, enabled, personal, custom]
  56. MENU_LIST = {
  57. :item => ["Инвентарь", "Вещи вашего персонажа.", 2249, true, false],
  58. :equip => ["Экипировка", "Экипировка вашего персонажа.", 4010, true, true],
  59. :skill => ["Умения", "Умения вашего персонажа.", 1247, true, true],
  60. :status => ["Герой", "Информация о вашем герое.", 6403, true, true],
  61. :save => ["Сохранение", "Сохраняет ваш прогресс.", 617, true, false],
  62. :load => ["Загрузка", "Загрузите сохраненные ранее записи.", 618, true, false, Scene_Load],
  63. :game_end => ["Выход", "Выход из игры.", 192, true, false],
  64. } # Don't remove this line!
  65.  
  66. # MENU_SAVE = true/false
  67. # Override enabled option for save (so you can change it ingame).
  68. MENU_SAVE = true
  69.  
  70. # If MENU_CUSTOM is true you will have to add the commands yourself
  71. # ingame, which can be useful for certain quest related stuff or if you
  72. # want to enable/disable menu commands.
  73. # To add/remove a command ingame follow these instructions:
  74. #
  75. # In a script call do like this:
  76. # menu_scene(key, type)
  77. # menu_scene(:item,:add) # To add item to menu list.
  78. # menu_scene(:item,:del) # To remove item from menu list.
  79. #
  80. # In a conditional branch you can check if a menu command is
  81. # enabled/disabled:
  82. # menu_active?(key)
  83. # menu_active?(:item) # Check if item is enabled.
  84. # !menu_active?(:item) # Check if item is disabled.
  85. #
  86. # To set a id to be enabled do like this:
  87. # menu_active(:skill, true) # Set menu skill to be enabled.
  88. #
  89. # To add/remove all available menu commands use one of the
  90. # following methods in a script call:
  91. # menu_add_all
  92. # menu_del_all
  93. #
  94. # MENU_CUSTOM = true/false
  95. MENU_CUSTOM = false
  96.  
  97. # The text to be displayed if no menu items is available.
  98. # Only used if MENU_CUSTOM is true.
  99. # MENU_EMPTY = string
  100. EMPTY = "Menu is not available at this point..."
  101.  
  102. # MENU_MUSIC:
  103. # Set the music to be played at the menu scene.
  104. # This is optional.
  105. # MUSIC = true/false
  106. MUSIC = true
  107. # MUSIC_BGM = [name, volume, pitch]
  108. MUSIC_BGM = ["", 70, 100]
  109. # MUSIC_BGS = [name, volume, pitch]
  110. MUSIC_BGS = ["", 50, 100]
  111.  
  112. # ANIM_LIST:
  113. # A list of animation images.
  114. # name => [z, zoom_x, zoom_y, blend_type, opacity]
  115. ANIM_LIST = {
  116. "Menu_Fog1" => [1, 1.2, 1.2, 1, 125],
  117. "Menu_Fog2" => [1, 1.8, 1.8, 1, 155]
  118. } # Don't remove this line!
  119.  
  120. # BACKGROUND:
  121. # name => [x, y, z, opacity]
  122. BACKGROUND = {
  123. #"" => [0, 0, 200, 255]
  124. } # Don't remove this line!
  125.  
  126. # Show vocab for HP, MP and TP.
  127. # BAR_VOCAB = true/false
  128. BAR_VOCAB = false
  129.  
  130. # BAR_COLOR = rgba(255,255,255,255)
  131. # Set the color of the gauges.
  132. BAR_HP = [Color.new(255,25,25,32), Color.new(255,150,150)]
  133. BAR_MP = [Color.new(25,25,255,32), Color.new(150,150,255)]
  134. BAR_TP = [Color.new(25,255,25,32), Color.new(150,255,150)]
  135.  
  136. # DETAILS:
  137. # Setup details here. (Recommended to use the default ones since you will
  138. # need a bit RGSS knowledge to add more.)
  139. def self.details
  140. ["#{Vocab::currency_unit}: #{$game_party.gold}",
  141. "Шаги: #{$game_party.steps}",
  142. "Предметов в инвентаре: #{$game_party.all_items.size}",
  143. "Локация: #{$data_mapinfos[$game_map.map_id].name}",
  144. ]
  145.  
  146.  
  147. end
  148.  
  149. # DETAILS_ICONS:
  150. # DETAILS_ICONS[id] = icon_id
  151. # Set the details icon_id. (optional)
  152. # Should be in the same order as details.
  153. # Use nil to disable a icon.
  154. DETAILS_ICONS = []
  155. DETAILS_ICONS[0] = 962 # GOLD
  156. DETAILS_ICONS[1] = 4447 # STEPS
  157. DETAILS_ICONS[2] = 2249 # ITEMS
  158. DETAILS_ICONS[3] = 1225 # MAP
  159.  
  160.  
  161. # Transition, nil to use default.
  162. # TRANSITION [speed, transition, opacity]
  163. TRANSITION = nil
  164.  
  165. end
  166. end
  167. # *** Don't edit below unless you know what you are doing. ***
  168. #==============================================================================#
  169. # ** Error Handler
  170. #==============================================================================#
  171. unless $imported["XAIL-XS-CORE"]
  172. # // Error handler when XS - Core is not installed.
  173. msg = "The script %s requires the latest version of XS - Core in order to function properly."
  174. name = "XS - Menu Delux"
  175. msgbox(sprintf(msg, name))
  176. exit
  177. end
  178. #==============================================================================#
  179. # ** Game_System
  180. #==============================================================================#
  181. class Game_System
  182.  
  183. attr_accessor :menu_list
  184.  
  185. alias xail_menu_delux_gm_sys_initialize initialize
  186. def initialize(*args, &block)
  187. # // Method to initialize game system.
  188. xail_menu_delux_gm_sys_initialize(*args, &block)
  189. @menu_list = {}
  190. end
  191.  
  192. def get_menu
  193. # // Method to get the menu list.
  194. XAIL::MENU_DELUX::MENU_CUSTOM ? @menu_list : XAIL::MENU_DELUX::MENU_LIST
  195. end
  196.  
  197. end
  198. #==============================================================================#
  199. # ** Game_Interpreter
  200. #==============================================================================#
  201. class Game_Interpreter
  202.  
  203. def menu_scene(key, type = :add)
  204. # // Method to add/remove a menu item to the list.
  205. case type
  206. when :add # // Add menu id.
  207. unless $game_system.menu_list.include?(XAIL::MENU_DELUX::MENU_LIST[key])
  208. $game_system.menu_list[key] = XAIL::MENU_DELUX::MENU_LIST[key]
  209. end unless XAIL::MENU_DELUX::MENU_LIST[key].nil?
  210. when :del # // Remove menu id.
  211. unless XAIL::MENU_DELUX::MENU_LIST[key].nil?
  212. $game_system.menu_list.delete(key)
  213. end
  214. end
  215. end
  216.  
  217. def menu_active?(key)
  218. # // Method to check if menu key is enabled.
  219. # This will return nil if menu item not added in the list.
  220. return $game_system.menu_list[key][3] rescue nil
  221. end
  222.  
  223. def menu_active(key, enabled)
  224. # // Method to enable id.
  225. $game_system.menu_list[key][3] = enabled
  226. end
  227.  
  228. def menu_add_all
  229. # // Method to add all available menu items.
  230. XAIL::MENU_DELUX::MENU_LIST.each_key {|key| menu_scene(key) }
  231. end
  232.  
  233. def menu_del_all
  234. # // Method to remove all available menu items.
  235. XAIL::MENU_DELUX::MENU_LIST.each_key {|key| menu_scene(key, :del) }
  236. end
  237.  
  238. end
  239. #==============================================================================
  240. # ** Window_MenuCommand
  241. #==============================================================================
  242. class Window_MenuCommand < Window_Command
  243.  
  244. def window_width
  245. # // Method to return the width of the window.
  246. return Graphics.width / 4
  247. end
  248.  
  249. def window_height
  250. # // Method to return the height of the window.
  251. return Graphics.height
  252. end
  253.  
  254. def alignment
  255. # // Method to return the alignment.
  256. return XAIL::MENU_DELUX::MENU_ALIGNMENT
  257. end
  258.  
  259. def menu_color(color, enabled = true)
  260. # // Method to set the color and alpha if not enabled.
  261. contents.font.color.set(color)
  262. contents.font.color.alpha = Colors::AlphaMenu unless enabled
  263. end
  264.  
  265. def item_rect_for_text(index)
  266. # // Method to draw item rect for text.
  267. rect = item_rect(index)
  268. rect.x += 25
  269. draw_line_ex(rect.x - 4, rect.y + 9, Color.new(255,255,255), Color.new(0,0,0,128))
  270. draw_icon(XAIL::MENU_DELUX::MENU_LIST.values[index][2], -2, rect.y) unless XAIL::MENU_DELUX::MENU_LIST.values[index][2].nil?
  271. rect
  272. end
  273.  
  274. def draw_item(index)
  275. # // Method to draw the command item.
  276. contents.font.name = XAIL::MENU_DELUX::FONT[0]
  277. contents.font.size = XAIL::MENU_DELUX::FONT[1]
  278. # // Save enable option.
  279. XAIL::MENU_DELUX::MENU_LIST[:save][3] = save_enabled if XAIL::MENU_DELUX::MENU_SAVE
  280. # // Default enable option.
  281. menu_color(XAIL::MENU_DELUX::FONT[2], menu_enabled?(index))
  282. # // Font settings
  283. contents.font.bold = XAIL::MENU_DELUX::FONT[3]
  284. contents.font.shadow = XAIL::MENU_DELUX::FONT[4]
  285. draw_text(item_rect_for_text(index), command_name(index), alignment)
  286. reset_font_settings
  287. end
  288.  
  289. def menu_enabled?(index)
  290. # // Method to check if menu item is enabled.
  291. return $game_system.get_menu.values[index][3]
  292. end
  293.  
  294. def make_command_list
  295. # // Method to add the commands.
  296. $game_system.get_menu.each {|key, value|
  297. name = value[0] == "" ? key.id2name.capitalize : value[0]
  298. XAIL::MENU_DELUX::MENU_LIST[:save][3] = save_enabled if XAIL::MENU_DELUX::MENU_SAVE
  299. add_command(name, key, value[3], value[5].nil? ? nil : value[5])
  300. }
  301. end
  302.  
  303. end
  304. #==============================================================================
  305. # ** Window_MenuStatus
  306. #==============================================================================
  307. class Window_MenuStatus < Window_Selectable
  308.  
  309. def initialize(x, y)
  310. # // Method to initialize the window.
  311. super(x, y, window_width, window_height)
  312. self.arrows_visible = false
  313. @pending_index = -1
  314. refresh
  315. end
  316.  
  317. def window_width
  318. # // Method to determine window width.
  319. return Graphics.width / 2.4
  320. end
  321.  
  322. def col_max
  323. # // Method to determine col max.
  324. return 2
  325. end
  326.  
  327. def spacing
  328. # // Method to determine spacing.
  329. return 6 if Graphics.width == 544 # For standard resolution.
  330. return 44 # For high resolution.
  331. end
  332.  
  333. def item_width
  334. # // Method to determine item width.
  335. return 98
  336. end
  337.  
  338. def item_height
  339. # // Method to determine item height.
  340. return 128
  341. end
  342.  
  343. def refresh
  344. # // Method to refresh the window.
  345. super
  346. # // Only display cursor arrow if more or equal to 5 party members.
  347. if $game_party.all_members.size >= 5
  348. self.arrows_visible = true
  349. end
  350. end
  351.  
  352. def draw_item(index)
  353. # // Method to draw item.
  354. actor = $game_party.members[index]
  355. rect = item_rect(index)
  356. # // Face
  357. draw_actor_face(actor, rect.x + 1, rect.y + 1, true)
  358. # // Name
  359. draw_font_text(actor.name, rect.x + 4, rect.y, rect.width, 0, XAIL::MENU_DELUX::FONT[0], 20, XAIL::MENU_DELUX::FONT[2])
  360. # // Level
  361. lvl = "#{Vocab::level_a}: #{actor.level}"
  362. draw_font_text(lvl, rect.x + 4, rect.y + 64, rect.width, 0, XAIL::MENU_DELUX::FONT[0], 18, XAIL::MENU_DELUX::FONT[2])
  363. # // Class
  364. # // Check if Yanfly Class System is installed.
  365. if $imported["YEA-ClassSystem"]
  366. actor_class = actor.subclass.nil? ? actor.class.name : "#{actor.class.name} [#{actor.subclass.name}]"
  367. else
  368. actor_class = actor.class.name
  369. end
  370. draw_font_text(actor_class, rect.x - 4, rect.y + 76, rect.width, 2, XAIL::MENU_DELUX::FONT[0], 16, XAIL::MENU_DELUX::FONT[2])
  371. # // Stats
  372. draw_menu_stats(actor, :hp, rect.x, rect.y + 90, XAIL::MENU_DELUX::BAR_HP[0], XAIL::MENU_DELUX::BAR_HP[1], rect.width - 2)
  373. draw_menu_stats(actor, :mp, rect.x, rect.y + 100, XAIL::MENU_DELUX::BAR_MP[0], XAIL::MENU_DELUX::BAR_MP[1], rect.width - 2)
  374.  
  375.  
  376. end
  377.  
  378. def draw_menu_stats(actor, stat, x, y, color1, color2, width)
  379. # // Method to draw actor hp & mp.
  380. case stat
  381. when :hp
  382. rate = actor.hp_rate ; vocab = Vocab::hp_a ; values = [actor.hp, actor.mhp]
  383. when :mp
  384. rate = actor.mp_rate ; vocab = Vocab::mp_a ; values = [actor.mp, actor.mmp]
  385. when :tp
  386. rate = actor.tp_rate ; vocab = Vocab::tp_a ; values = [actor.tp, actor.max_tp]
  387.  
  388. end
  389. contents.font.name = XAIL::MENU_DELUX::FONT[0]
  390. contents.font.size = 14 # // Override font size.
  391. contents.font.color = XAIL::MENU_DELUX::FONT[2]
  392. contents.font.bold = XAIL::MENU_DELUX::FONT[3]
  393. contents.font.shadow = XAIL::MENU_DELUX::FONT[4]
  394. # // Draw guage.
  395. draw_gauge_ex(x, y - 8, width, 8, rate, color1, color2)
  396. # // Draw stats.
  397. draw_text(x + 2, y, width, line_height, values[0], 0)
  398. draw_text(x + 1, y, width, line_height, values[1], 2)
  399. # // Draw vocab.
  400. draw_text(x, y, width, line_height, vocab, 1) if XAIL::MENU_DELUX::BAR_VOCAB
  401. reset_font_settings
  402. end
  403.  
  404. end
  405. #==============================================================================
  406. # ** Window_Menu_Details
  407. #==============================================================================
  408. class Window_Menu_Details < Window_Base
  409.  
  410. def initialize(x, y)
  411. # // Method to initialize.
  412. super(x, y, window_width, window_height)
  413. @leader = $game_party.leader
  414. refresh
  415. end
  416.  
  417. def window_width
  418. # // Method to determine window width.
  419. return Graphics.width / 3
  420. end
  421.  
  422. def window_height
  423. # // Method to determine window height.
  424. return Graphics.height
  425. end
  426.  
  427. def refresh
  428. # // Method to refresh the window.
  429. contents.clear
  430. # // Draw details.
  431. y = -10
  432. XAIL::MENU_DELUX.details.each_index {|i|
  433. draw_line_ex(0, y += 24, Color.new(255,255,255,32), Color.new(0,0,0,64))
  434. draw_font_text(XAIL::MENU_DELUX.details[i], -4, line_height * i + 4, contents_width, 2, XAIL::MENU_DELUX::FONT[0], 16, XAIL::MENU_DELUX::FONT[2])
  435. }
  436. # // Draw icons.
  437. draw_icons(XAIL::MENU_DELUX::DETAILS_ICONS, :vertical, 2, line_height * 0 + 2)
  438. end
  439.  
  440. def update
  441. # // Method to update details window.
  442. super
  443. if @leader != $game_party.leader
  444. @leader = $game_party.leader
  445. refresh
  446. end
  447. end
  448.  
  449. end
  450. #==============================================================================
  451. # ** Window_Menu_Playtime
  452. #==============================================================================
  453. class Window_Menu_Playtime < Window_Base
  454.  
  455. def initialize(x, y)
  456. # // Method to initialize.
  457. super(x, y, 120, fitting_height(1))
  458. @playtime = $game_system.playtime_s
  459. refresh
  460. end
  461.  
  462. def refresh
  463. # // Method to refresh the window.
  464. contents.clear
  465. # // Draw icon.
  466. draw_icon(XAIL::MENU_DELUX::PLAYTIME_ICON, 4, 0)
  467. # // Draw playtime.
  468. # draw_font_text(@playtime, 0, 6, contents_width, 2, XAIL::MENU_DELUX::FONT[0], 22, XAIL::MENU_DELUX::FONT[2])
  469. end
  470.  
  471. def update
  472. # // Method to update the window.
  473. super
  474. @playtime = $game_system.playtime_s
  475. refresh
  476. end
  477.  
  478. end
  479. #==============================================================================#
  480. # ** Window_Menu_Help
  481. #==============================================================================#
  482. class Window_Menu_Help < Window_Help
  483.  
  484. attr_accessor :index
  485.  
  486. alias xail_icon_menu_winhelp_init initialize
  487. def initialize(*args, &block)
  488. # // Method to initialize help window.
  489. xail_icon_menu_winhelp_init(*args, &block)
  490. @index = 0
  491. end
  492.  
  493. def set_text(text, enabled)
  494. # // Method to set a new help text.
  495. if text != @text
  496. menu_color(XAIL::MENU_DELUX::FONT[2], enabled)
  497. @text = text
  498. refresh
  499. end
  500. end
  501.  
  502. def refresh
  503. # // Refresh help contents.
  504. contents.clear
  505. draw_help_text
  506. end
  507.  
  508. def draw_help_text
  509. # // Method to draw the help text.
  510. contents.font.name = XAIL::MENU_DELUX::FONT[0]
  511. contents.font.size = XAIL::MENU_DELUX::FONT[1]
  512. menu_color(XAIL::MENU_DELUX::FONT[2], menu_enabled?(@index))
  513. contents.font.bold = XAIL::MENU_DELUX::FONT[3]
  514. contents.font.shadow = XAIL::MENU_DELUX::FONT[4]
  515. # // Draw title and description for the menu.
  516. draw_line_ex(0, 14, Color.new(255,255,255), Color.new(0,0,0,128))
  517. draw_text_ex_no_reset(0, 0, @text)
  518. reset_font_settings
  519. end
  520.  
  521. def menu_enabled?(index)
  522. # // Method to check if menu item is enabled.
  523. return $game_system.get_menu.values[index][3]
  524. end
  525.  
  526. def menu_color(color, enabled = true)
  527. # // Method to set the color and alpha if not enabled.
  528. contents.font.color.set(color)
  529. contents.font.color.alpha = 150 unless enabled
  530. end
  531.  
  532. end
  533. #==============================================================================#
  534. # ** Scene_MenuBase
  535. #==============================================================================#
  536. class Scene_MenuBase < Scene_Base
  537.  
  538. def start
  539. # // Method to start the scene.
  540. super
  541. @actor = $game_party.menu_actor
  542. if SceneManager.scene_is?(Scene_Menu)
  543. @backgrounds = []
  544. @animations = []
  545. create_menu_backgrounds
  546. create_menu_animations
  547. end
  548. end
  549.  
  550. def create_menu_backgrounds
  551. # // Method to create custom background(s).
  552. XAIL::MENU_DELUX::BACKGROUND.each {|key, value| @backgrounds << [Sprite.new, key] }
  553. @backgrounds.each {|i|
  554. i[0].bitmap = Cache.system(i[1])
  555. i[0].x = XAIL::MENU_DELUX::BACKGROUND[i[1]][0]
  556. i[0].y = XAIL::MENU_DELUX::BACKGROUND[i[1]][1]
  557. i[0].z = XAIL::MENU_DELUX::BACKGROUND[i[1]][2]
  558. i[0].opacity = XAIL::MENU_DELUX::BACKGROUND[i[1]][3]
  559. }
  560. end
  561.  
  562. def create_menu_animations
  563. # // Method to create custom animation(s).
  564. # name => [z, zoom_x, zoom_y, blend_type, opacity]
  565. XAIL::MENU_DELUX::ANIM_LIST.each {|key, value| @animations.push << [Plane.new, key] }
  566. @animations.each {|i|
  567. i[0].bitmap = Cache.system(i[1])
  568. i[0].z = XAIL::MENU_DELUX::ANIM_LIST[i[1]][0]
  569. i[0].zoom_x = XAIL::MENU_DELUX::ANIM_LIST[i[1]][1]
  570. i[0].zoom_y = XAIL::MENU_DELUX::ANIM_LIST[i[1]][2]
  571. i[0].blend_type = XAIL::MENU_DELUX::ANIM_LIST[i[1]][3]
  572. i[0].opacity = XAIL::MENU_DELUX::ANIM_LIST[i[1]][4]
  573. }
  574. end
  575.  
  576. alias xail_upd_menubase_delux_upd update
  577. def update(*args, &block)
  578. # // Method for updating the scene.
  579. xail_upd_menubase_delux_upd(*args, &block)
  580. if SceneManager.scene_is?(Scene_Menu)
  581. for i in 0...@animations.size
  582. @animations[i][0].ox += 1.2 - i
  583. @animations[i][0].oy -= 0.6 + i
  584. end unless scene_changing?
  585. delay?(1)
  586. end
  587. end
  588.  
  589. def delay?(amount)
  590. # // Method to delay.
  591. amount.times do
  592. update_basic
  593. end
  594. end
  595.  
  596. alias xail_menubase_delux_transition perform_transition
  597. def perform_transition(*args, &block)
  598. # // Method to create the transition.
  599. return if $game_system.get_menu.empty?
  600. if XAIL::MENU_DELUX::TRANSITION.nil?
  601. xail_menubase_delux_transition(*args, &block)
  602. else
  603. Graphics.transition(XAIL::MENU_DELUX::TRANSITION[0],XAIL::MENU_DELUX::TRANSITION[1],XAIL::MENU_DELUX::TRANSITION[2])
  604. end
  605. end
  606.  
  607. def dispose_sprites
  608. # // Method to dispose sprites.
  609. @backgrounds.each {|i| i[0].dispose unless i[0].nil? ; i[0] = nil } rescue nil
  610. @animations.each {|i| i[0].dispose unless i[0].nil? ; i[0] = nil } rescue nil
  611. end
  612.  
  613. def terminate
  614. # // Method to terminate.
  615. super
  616. dispose_sprites unless SceneManager.scene_is?(Scene_Menu)
  617. end
  618.  
  619. end
  620. #==============================================================================#
  621. # ** Scene_Menu
  622. #==============================================================================#
  623. class Scene_Menu < Scene_MenuBase
  624.  
  625. def start
  626. super
  627. # // Method to start the scene.
  628. # // Return if menu empty.
  629. return command_map if $game_system.get_menu.empty?
  630. # // Create windows.
  631. create_menu_command_window
  632. create_menu_status_window
  633. create_menu_details_window
  634. create_menu_playtime_window
  635. create_menu_help_window
  636. # // Set help text to first menu command.
  637. help_update(@command_window.index)
  638. # // Play music if enabled.
  639. play_menu_music if XAIL::MENU_DELUX::MUSIC
  640. end
  641.  
  642. def create_menu_command_window
  643. # // Method to create the command window.
  644. @command_window = Window_MenuCommand.new
  645. @command_window.windowskin = Cache.system(XAIL::MENU_DELUX::MENU_SKIN) unless XAIL::MENU_DELUX::MENU_SKIN.nil?
  646. @command_window.back_opacity = 96
  647. $game_system.get_menu.each {|key, value|
  648. unless value[5].nil?
  649. @command_window.set_handler(key, method(:command_custom))
  650. else
  651. if value[4]
  652. @command_window.set_handler(key, method(:command_personal))
  653. else
  654. @command_window.set_handler(key, method("command_#{key}".to_sym))
  655. end
  656. end
  657. }
  658. @command_window.set_handler(:cancel, method(:return_scene))
  659. end
  660.  
  661. def create_menu_status_window
  662. # // Method to create the status window.
  663. @status_window = Window_MenuStatus.new(0, 0)
  664. @status_window.height = Graphics.height - 72
  665. @status_window.x = @command_window.width
  666. @status_window.back_opacity = 96
  667. end
  668.  
  669. def create_menu_details_window
  670. # // Method to create the details window.
  671. @details_window = Window_Menu_Details.new(0, 0)
  672. @details_window.x = Graphics.width - @details_window.width
  673. @details_window.back_opacity = 96
  674. end
  675.  
  676. def create_menu_playtime_window
  677. # // Method to create the playtime window.
  678. @playtime_window = Window_Menu_Playtime.new(0, 0)
  679. @playtime_window.x = Graphics.width - @playtime_window.width
  680. @playtime_window.y = Graphics.height - @playtime_window.height - 26
  681. @playtime_window.opacity = 0
  682. @playtime_window.z = 201
  683. end
  684.  
  685. def create_menu_help_window
  686. # // Method to create the help window.
  687. @help_window = Window_Menu_Help.new(2)
  688. @help_window.viewport = @viewport
  689. @help_window.windowskin = Cache.system(XAIL::MENU_DELUX::MENU_SKIN) unless XAIL::MENU_DELUX::MENU_SKIN.nil?
  690. @help_window.index = @command_window.index
  691. @help_window.y = Graphics.height - @help_window.height
  692. @help_window.back_opacity = 255
  693. @help_window.z = 200
  694. end
  695.  
  696. def play_menu_music
  697. # // Method to play menu music.
  698. @last_bgm = RPG::BGM.last
  699. @last_bgs = RPG::BGS.last
  700. bgm = XAIL::MENU_DELUX::MUSIC_BGM
  701. bgs = XAIL::MENU_DELUX::MUSIC_BGS
  702. Sound.play(bgm[0], bgm[1], bgm[2], :bgm)
  703. Sound.play(bgs[0], bgs[1], bgs[2], :bgs)
  704. end
  705.  
  706. alias xail_upd_menu_delux_upd update
  707. def update(*args, &block)
  708. # // Method for updating the scene.
  709. xail_upd_menu_delux_upd(*args, &block)
  710. old_index = @help_window.index
  711. help_update(@command_window.index) if old_index != @command_window.index
  712. end
  713.  
  714. def help_update(index)
  715. # // If index changes update help window text.
  716. list = XAIL::MENU_DELUX::MENU_LIST
  717. icon = list.values[index][2].nil? ? "" : list.values[index][2]
  718. name = list.values[index][0] == "" ? list.keys[index].id2name.capitalize : list.values[index][0]
  719. if icon == "" ; title = name ; else ; title = '\i[' + icon.to_s + ']' + name ; end
  720. desc = '\c[0]' + list.values[index][1]
  721. text = "#{title}\n#{desc}"
  722. enabled = list.values[index][3]
  723. @help_window.index = index
  724. @help_window.set_text(text, enabled)
  725. end
  726.  
  727. def on_personal_ok
  728. # // Method override on personal ok.
  729. scene = "Scene_#{@command_window.current_symbol.to_s.capitalize}".to_class
  730. SceneManager.call(scene)
  731. end
  732.  
  733. def command_custom
  734. # // Method to call a custom command. (Don't remove)
  735. if @command_window.current_ext.is_a?(Integer)
  736. $game_temp.reserve_common_event(@command_window.current_ext)
  737. return command_map
  738. end
  739. SceneManager.call(@command_window.current_ext)
  740. end
  741.  
  742. def command_map
  743. # // command_map (Don't remove)
  744. if $game_system.get_menu.empty?
  745. Sound.play_buzzer
  746. $game_message.texts << XAIL::MENU_DELUX::EMPTY
  747. end
  748. SceneManager.call(Scene_Map)
  749. end
  750.  
  751. def pre_terminate
  752. # // Method to pre terminate scene menu.
  753. # // Play last bgm and bgs if menu music is enabled.
  754. if XAIL::MENU_DELUX::MUSIC
  755. @last_bgm.replay rescue nil
  756. @last_bgs.replay rescue nil
  757. end
  758. end
  759.  
  760. end # END OF FILE
  761.  
  762. #=*==========================================================================*=#
  763. # ** END OF FILE
  764. #=*======================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement