thiago_d_d

Super Menu

Jan 15th, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 18.77 KB | None | 0 0
  1. #===============================================================================
  2. #  http://thiagodd.blogspot.com.br
  3. # [TSDA] Super Menu
  4. #   by thiago_d_d - por fazer o script
  5. #
  6. # -----------------------------------------------------------------------------
  7. # * Features
  8. # -----------------------------------------------------------------------------
  9. #  + No options limits(you can add custom options, easily)
  10. #  + Custom BGs.
  11. #  + These options can be activated by switches.
  12. #  + Changes the Equipments,Habilities,etc options by one option only.
  13. #  + New status menu.
  14. #
  15. # -----------------------------------------------------------------------------
  16. # * Install
  17. # -----------------------------------------------------------------------------
  18. #  Put this script in the aditional scripts section.
  19. #
  20. # -----------------------------------------------------------------------------
  21. # * Configuration
  22. # -----------------------------------------------------------------------------
  23. #  ----To add new options
  24. #  Add an line in this format to the end of this script
  25. #    $game_menu.add_option(name,code,switch_id)
  26. #       in the place of name put the option name
  27. #       --
  28. #       in the place of code put the code that will be executed when the option is
  29. #       activated
  30. #       --
  31. #       in the place of switch_id put the switch id that will activate/deactivate
  32. #       the option, or put nil if you don't want to use switches.
  33. #
  34. #  ----Example
  35. #    $game_menu.add_option("Monsters","$scene = Bestiary.new",nil)
  36. #
  37. #  OBS: The commands order depends on the order you put these lines.
  38. #===============================================================================
  39. module TSDA
  40.   #Background
  41.   #This can be "Black", so there is no BG
  42.   #This can be "Map", so the BG will be the map
  43.   #This can be an image name, so the BG will be custom
  44.   MENU_BACK = "Map"
  45.   #Windows Opacity
  46.   WINDOWH_OPACITY = 200
  47. end
  48. # Vocabulary
  49. module Vocab
  50.   PlayTime = "Tempo de jogo"
  51.   Steps = "Passos"
  52.   Chars = "Heróis"
  53.   Atrib = "Atributos"
  54.   Exper = "Experiência"
  55.   Equipm = "Equipamentos"
  56. end
  57. #-------------------------------------------------------------------------------
  58. class Game_Option
  59.   attr_reader    :name
  60.   attr_reader    :code
  61.   attr_reader    :switch
  62.   #-----------------------------------------------------------------------------
  63.   def initialize(option_name,option_code,switch_id)
  64.     @name = option_name
  65.     @code = option_code
  66.     @switch = switch_id
  67.   end
  68. end
  69. #-------------------------------------------------------------------------------
  70. class Game_Menu
  71.   attr_reader    :options
  72.   attr_accessor  :last_index
  73.   #-----------------------------------------------------------------------------
  74.   def initialize
  75.     @options = []
  76.     @last_index = 0
  77.   end
  78.   #-----------------------------------------------------------------------------
  79.   def add_option(option_name,option_code,switch_id)
  80.     option = Game_Option.new(option_name,option_code,switch_id)
  81.     @options.push(option)
  82.   end
  83. end
  84. $game_menu = Game_Menu.new
  85. #-------------------------------------------------------------------------------
  86. class Scene_Menu < Scene_Base
  87.   def initialize(menu_index=nil)
  88.     @menu_index = $game_menu.last_index
  89.     $game_menu.last_index = 0
  90.   end
  91.   def create_menu_background
  92.     if TSDA::MENU_BACK == "Map"
  93.       @menuback_sprite = Spriteset_Map.new
  94.     elsif TSDA::MENU_BACK != "Black"
  95.       @menuback_sprite = Sprite.new
  96.       @menuback_sprite.bitmap = RPG::Cache.picture(TSDA::MENU_BACK)
  97.     end
  98.     update_menu_background
  99.   end
  100.   def dispose_menu_background
  101.     if @menuback_sprite != nil
  102.       @menuback_sprite.dispose
  103.     end
  104.   end
  105.   def update_menu_background
  106.     if @menuback_sprite != nil
  107.       @menuback_sprite.update
  108.     end
  109.   end
  110.   #-----------------------------------------------------------------------------
  111.   def start
  112.     super
  113.     create_menu_background
  114.     @command_window = Window_MenuCommand.new
  115.     @command_window.index = @menu_index
  116.     @command_window.opacity = TSDA::WINDOWH_OPACITY
  117.     @command_window.back_opacity = TSDA::WINDOWH_OPACITY
  118.     @time_window = Window_PlayTime.new
  119.     @time_window.opacity = TSDA::WINDOWH_OPACITY
  120.     @time_window.back_opacity = TSDA::WINDOWH_OPACITY
  121.     @steps_window = Window_Steps.new
  122.     @steps_window.opacity = TSDA::WINDOWH_OPACITY
  123.     @steps_window.back_opacity = TSDA::WINDOWH_OPACITY
  124.     @gold_window = Window_Gold.new(0,184)
  125.     @gold_window.opacity = TSDA::WINDOWH_OPACITY
  126.     @gold_window.back_opacity = TSDA::WINDOWH_OPACITY
  127.     @status_window = Window_MenuStatus.new(160, 0)
  128.     @status_window.opacity = TSDA::WINDOWH_OPACITY
  129.     @status_window.back_opacity = TSDA::WINDOWH_OPACITY
  130.   end
  131.   #-----------------------------------------------------------------------------
  132.   def terminate
  133.     super
  134.     dispose_menu_background
  135.     @command_window.dispose
  136.     @time_window.dispose
  137.     @steps_window.dispose
  138.     @gold_window.dispose
  139.     @status_window.dispose
  140.   end
  141.   #-----------------------------------------------------------------------------
  142.   def update
  143.     super
  144.     update_menu_background
  145.     @command_window.update
  146.     @time_window.update
  147.     @steps_window.update
  148.     @gold_window.update
  149.     @status_window.update
  150.     if @command_window.active
  151.       update_command_selection
  152.     elsif @status_window.active
  153.       update_actor_selection
  154.     end
  155.   end
  156.   #-----------------------------------------------------------------------------
  157.   def update_command_selection
  158.     if Input.trigger?(Input::B)
  159.       Sound.play_cancel
  160.       $scene = Scene_Map.new
  161.     elsif Input.trigger?(Input::C)
  162.       if $game_party.members.size == 0 and @command_window.index < 4
  163.         Sound.play_buzzer
  164.         return
  165.       elsif $game_system.save_disabled and @command_window.index == 4
  166.         Sound.play_buzzer
  167.         return
  168.       end
  169.       case @command_window.index
  170.       when 0
  171.         Sound.play_decision
  172.         $scene = Scene_Item.new
  173.         $game_menu.last_index = 0
  174.         return
  175.       when 1
  176.         Sound.play_decision
  177.         start_actor_selection
  178.         return
  179.       when 2
  180.         Sound.play_decision
  181.         $scene = Scene_File.new(true, false, false)
  182.         $game_menu.last_index = 2
  183.         return
  184.       end
  185.       options_number = $game_menu.options.size
  186.       if @command_window.index == 3 + options_number
  187.         Sound.play_decision
  188.         $scene = Scene_End.new
  189.         $game_menu.last_index = 3 + options_number
  190.         return
  191.       end
  192.       selected_index = 3 - @command_window.index
  193.       option = $game_menu.options[selected_index]
  194.       if option.switch != nil
  195.         switch = $game_switches[option.switch]
  196.         unless switch
  197.           Sound.play_buzzer
  198.           return
  199.         end
  200.       end
  201.       Sound.play_decision
  202.       $game_menu.last_index = @command_window.index
  203.       eval(option.code)
  204.     end
  205.   end
  206.   #-----------------------------------------------------------------------------
  207.   def update_actor_selection
  208.     if Input.trigger?(Input::B)
  209.       Sound.play_cancel
  210.       end_actor_selection
  211.     elsif Input.trigger?(Input::C)
  212.       $game_party.last_actor_index = @status_window.index
  213.       Sound.play_decision
  214.       $game_menu.last_index = 1
  215.       $scene = Scene_Chars.new(@status_window.index)
  216.     end
  217.   end
  218. end
  219. #-------------------------------------------------------------------------------
  220. class Window_Base
  221.   def disabled_color
  222.     return Color.new(normal_color.red,normal_color.green,normal_color.blue,128)
  223.   end
  224.   #-----------------------------------------------------------------------------
  225.   def orange_color
  226.     return Color.new(255,126,0)
  227.   end
  228. end
  229. #-------------------------------------------------------------------------------
  230. class Window_MenuCommand < Window_Selectable
  231.   def initialize
  232.     super(0,240,160,176)
  233.     @index = 0
  234.     refresh
  235.   end
  236.   #-----------------------------------------------------------------------------
  237.   def refresh
  238.     s1 = Vocab::item
  239.     s2 = Vocab::Chars
  240.     s3 = Vocab::save
  241.     ends = Vocab::game_end
  242.     @item_max = 4 + $game_menu.options.size
  243.     create_contents
  244.     if $game_party.members.size == 0
  245.       self.contents.font.color = disabled_color
  246.     else
  247.       self.contents.font.color = normal_color
  248.     end
  249.     self.contents.draw_text(item_rect(0),s1)
  250.     self.contents.draw_text(item_rect(1),s2)
  251.     if $game_system.save_disabled
  252.       self.contents.font.color = disabled_color
  253.     else
  254.       self.contents.font.color = normal_color
  255.     end
  256.     self.contents.draw_text(item_rect(2),s3)
  257.     item_count = 0
  258.     for i in $game_menu.options
  259.       if i.switch != nil
  260.         if $game_switches[i.switch]
  261.           self.contents.font.color = normal_color
  262.         else
  263.           self.contents.font.color = disabled_color
  264.         end
  265.       else
  266.         self.contents.font.color = normal_color
  267.       end
  268.       self.contents.draw_text(item_rect(3 + item_count),i.name)
  269.       item_count += 1
  270.     end
  271.     self.contents.font.color = normal_color
  272.     self.contents.draw_text(item_rect(3 + item_count),ends)
  273.   end
  274. end
  275. #-------------------------------------------------------------------------------
  276. class Game_Map
  277.   alias hyper_menu_initialize initialize
  278.   def initialize
  279.     hyper_menu_initialize
  280.     @map_infos = load_data("Data/MapInfos.rvdata")
  281.   end
  282.   #-----------------------------------------------------------------------------
  283.   def map_name
  284.     return @map_infos[@map_id].name
  285.   end
  286. end
  287. #-------------------------------------------------------------------------------
  288. class Window_PlayTime < Window_Base
  289.   def initialize
  290.     super(0,0,160,104)
  291.     refresh
  292.   end
  293.   #-----------------------------------------------------------------------------
  294.   def update
  295.     super
  296.     if Graphics.frame_count / Graphics.frame_rate != @total_sec
  297.       refresh
  298.     end
  299.   end
  300.   #-----------------------------------------------------------------------------
  301.   def refresh
  302.     self.contents.clear
  303.     self.contents.font.color = orange_color
  304.     self.contents.draw_text(0,0,128,WLH,$game_map.map_name,1)
  305.     self.contents.font.color = system_color
  306.     self.contents.draw_text(0, WLH, 128, WLH, Vocab::PlayTime,1)
  307.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  308.     hour = @total_sec / 60 / 60
  309.     min = @total_sec / 60 % 60
  310.     sec = @total_sec % 60
  311.     text = sprintf("%02d:%02d:%02d", hour, min, sec)
  312.     self.contents.font.color = normal_color
  313.     self.contents.draw_text(0, WLH * 2, 128, WLH, text, 1)
  314.   end
  315. end
  316. #-------------------------------------------------------------------------------
  317. class Window_Steps < Window_Base
  318.   def initialize
  319.     super(0, 104, 160, 80)
  320.     refresh
  321.   end
  322.   #-----------------------------------------------------------------------------
  323.   def refresh
  324.     self.contents.clear
  325.     self.contents.font.color = system_color
  326.     self.contents.draw_text(0, 0, 128, WLH, Vocab::Steps,1)
  327.     self.contents.font.color = normal_color
  328.     self.contents.draw_text(0, WLH, 128, WLH, $game_party.steps.to_s, 1)
  329.   end
  330. end
  331. #-------------------------------------------------------------------------------
  332. class Scene_Chars < Scene_Base
  333.   def initialize(actor_index = 0,menu_index = 0)
  334.     @actor_index = actor_index
  335.     @menu_index = menu_index
  336.   end
  337.   def create_menu_background
  338.     if TSDA::MENU_BACK == "Map"
  339.       @menuback_sprite = Spriteset_Map.new
  340.     elsif TSDA::MENU_BACK != "Black"
  341.       @menuback_sprite = Sprite.new
  342.       @menuback_sprite.bitmap = RPG::Cache.picture(TSDA::MENU_BACK)
  343.     end
  344.     update_menu_background
  345.   end
  346.   def dispose_menu_background
  347.     if @menuback_sprite != nil
  348.       @menuback_sprite.dispose
  349.     end
  350.   end
  351.   def update_menu_background
  352.     if @menuback_sprite != nil
  353.       @menuback_sprite.update
  354.     end
  355.   end
  356.   #-----------------------------------------------------------------------------
  357.   def start
  358.     super
  359.     create_menu_background
  360.     actor = $game_party.members[@actor_index]
  361.     @status_window = Window_StatusMenu.new(0,0,544,164,actor)
  362.     @status_window.opacity = TSDA::WINDOWH_OPACITY
  363.     @status_window.back_opacity = TSDA::WINDOWH_OPACITY
  364.     @exp_window = Window_ExpStatus.new(0,244,212,172,actor)
  365.     @exp_window.opacity = TSDA::WINDOWH_OPACITY
  366.     @exp_window.back_opacity = TSDA::WINDOWH_OPACITY
  367.     @equip_window = Window_EquipHab.new(212,164,332,252,actor)
  368.     @equip_window.opacity = TSDA::WINDOWH_OPACITY
  369.     @equip_window.back_opacity = TSDA::WINDOWH_OPACITY
  370.     s1 = Vocab::skill
  371.     s2 = Vocab::equip
  372.     @command_window = Window_Command.new(212, [s1,s2])
  373.     @command_window.y = 164
  374.     @command_window.index = @menu_index
  375.     @command_window.opacity = TSDA::WINDOWH_OPACITY
  376.     @command_window.back_opacity = TSDA::WINDOWH_OPACITY
  377.   end
  378.   #-----------------------------------------------------------------------------
  379.   def terminate
  380.     super
  381.     dispose_menu_background
  382.     @status_window.dispose
  383.     @command_window.dispose
  384.     @exp_window.dispose
  385.     @equip_window.dispose
  386.   end
  387.   #-----------------------------------------------------------------------------
  388.   def update
  389.     update_menu_background
  390.     @status_window.update
  391.     @command_window.update
  392.     @exp_window.update
  393.     @equip_window.update
  394.     if Input.trigger?(Input::B)
  395.       Sound.play_cancel
  396.       return_scene
  397.     elsif Input.trigger?(Input::R)
  398.       Sound.play_cursor
  399.       next_actor
  400.     elsif Input.trigger?(Input::L)
  401.       Sound.play_cursor
  402.       prev_actor
  403.     elsif Input.trigger?(Input::C)
  404.       if @command_window.index == 1
  405.         Sound.play_decision
  406.         $scene = Scene_Equip.new(@actor_index)
  407.       else
  408.         Sound.play_decision
  409.         $scene = Scene_Skill.new(@actor_index)
  410.       end
  411.     end
  412.     super
  413.   end
  414.   #-----------------------------------------------------------------------------
  415.   def return_scene
  416.     $scene = Scene_Menu.new(3)
  417.   end
  418.   #-----------------------------------------------------------------------------
  419.   def next_actor
  420.     @actor_index += 1
  421.     @actor_index %= $game_party.members.size
  422.     $scene = Scene_Chars.new(@actor_index)
  423.   end
  424.   #-----------------------------------------------------------------------------
  425.   def prev_actor
  426.     @actor_index += $game_party.members.size - 1
  427.     @actor_index %= $game_party.members.size
  428.     $scene = Scene_Chars.new(@actor_index)
  429.   end
  430. end
  431. #-------------------------------------------------------------------------------
  432. class Scene_Skill
  433.   def return_scene
  434.     $scene = Scene_Chars.new(@actor_index,0)
  435.   end
  436. end
  437. #-------------------------------------------------------------------------------
  438. class Scene_Equip
  439.   def return_scene
  440.     $scene = Scene_Chars.new(@actor_index,1)
  441.   end
  442. end
  443. #-------------------------------------------------------------------------------
  444. class Window_MenuStatus_Base < Window_Base
  445.   def initialize(x,y,width,height,actor)
  446.     super(x,y,width,height)
  447.     @actor = actor
  448.     refresh
  449.   end
  450.   #-----------------------------------------------------------------------------
  451.   def refresh
  452.     self.contents.clear
  453.   end
  454.   #-----------------------------------------------------------------------------
  455.   def draw_basic_info(x, y)
  456.     draw_actor_level(@actor, x, y + WLH * 0)
  457.     draw_actor_state(@actor, x, y + WLH * 1)
  458.     draw_actor_hp(@actor, x, y + WLH * 2)
  459.     draw_actor_mp(@actor, x, y + WLH * 3)
  460.   end
  461.   #-----------------------------------------------------------------------------
  462.   def draw_parameters(x, y)
  463.     draw_actor_parameter(@actor, x, y + WLH * 0, 0)
  464.     draw_actor_parameter(@actor, x, y + WLH * 1, 1)
  465.     draw_actor_parameter(@actor, x, y + WLH * 2, 2)
  466.     draw_actor_parameter(@actor, x, y + WLH * 3, 3)
  467.   end
  468.   #-----------------------------------------------------------------------------
  469.   def draw_exp_info(x, y)
  470.     s1 = @actor.exp_s
  471.     s2 = @actor.next_rest_exp_s
  472.     s_next = sprintf(Vocab::ExpNext, Vocab::level)
  473.     self.contents.font.color = system_color
  474.     self.contents.draw_text(x, y + WLH * 0, 180, WLH, Vocab::ExpTotal)
  475.     self.contents.draw_text(x, y + WLH * 2, 180, WLH, s_next)
  476.     self.contents.font.color = normal_color
  477.     self.contents.draw_text(x, y + WLH * 1, 180, WLH, s1, 2)
  478.     self.contents.draw_text(x, y + WLH * 3, 180, WLH, s2, 2)
  479.   end
  480.   #-----------------------------------------------------------------------------
  481.   def draw_equipments(x, y)
  482.     @data = []
  483.     for item in @actor.equips do @data.push(item) end
  484.     @item_max = @data.size
  485.     self.contents.font.color = system_color
  486.     if @actor.two_swords_style
  487.       self.contents.draw_text(4, y, 92, WLH, Vocab::weapon1)
  488.       self.contents.draw_text(4, y + WLH * 1, 92, WLH, Vocab::weapon2)
  489.     else
  490.       self.contents.draw_text(4, y, 92, WLH, Vocab::weapon)
  491.       self.contents.draw_text(4, y + WLH * 1, 92, WLH, Vocab::armor1)
  492.     end
  493.     self.contents.draw_text(4, y + WLH * 2, 92, WLH, Vocab::armor2)
  494.     self.contents.draw_text(4, y + WLH * 3, 92, WLH, Vocab::armor3)
  495.     self.contents.draw_text(4, y + WLH * 4, 92, WLH, Vocab::armor4)
  496.     draw_item_name(@data[0], 100, y)
  497.     draw_item_name(@data[1], 100, y + WLH * 1)
  498.     draw_item_name(@data[2], 100, y + WLH * 2)
  499.     draw_item_name(@data[3], 100, y + WLH * 3)
  500.     draw_item_name(@data[4], 100, y + WLH * 4)
  501.   end
  502. end
  503. #-------------------------------------------------------------------------------
  504. class Window_StatusMenu < Window_MenuStatus_Base
  505.   def refresh
  506.     super
  507.     draw_actor_name(@actor, 4, 0)
  508.     draw_actor_class(@actor, 128, 0)
  509.     draw_actor_face(@actor, 8, 32)
  510.     draw_basic_info(128, 32)
  511.     self.contents.font.color = orange_color
  512.     self.contents.draw_text(280,0,128,WLH,Vocab::Atrib)
  513.     draw_parameters(280,WLH)
  514.   end
  515. end
  516. #-------------------------------------------------------------------------------
  517. class Window_ExpStatus < Window_MenuStatus_Base
  518.   def refresh
  519.     super
  520.     self.contents.font.color = orange_color
  521.     self.contents.draw_text(0,0,180,WLH,Vocab::Exper,1)
  522.     draw_exp_info(0,WLH * 2)
  523.   end
  524. end
  525. #-------------------------------------------------------------------------------
  526. class Window_EquipHab < Window_MenuStatus_Base
  527.   def refresh
  528.     super
  529.     self.contents.font.color = orange_color
  530.     self.contents.draw_text(0,0,300,WLH,Vocab::Equipm,1)
  531.     draw_equipments(0,WLH * 2)
  532.   end
  533. end
  534. #-------------------------------------------------------------------------------
  535. class Scene_Title
  536.   alias hyper_menu_command_new_game command_new_game
  537.   def command_new_game
  538.     hyper_menu_command_new_game
  539.     $game_menu.last_index = 0
  540.   end
  541. end
  542. #-------------------------------------------------------------------------------
  543. class Scene_File
  544.   alias hyper_menu_read_save_data read_save_data
  545.   def read_save_data(file)
  546.     hyper_menu_read_save_data(file)
  547.     $game_menu.last_index = 0
  548.   end
  549. end
  550. #===============================================================================
  551. # Add here your options
  552. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment