Advertisement
MrTrivel

MrTS_Expanded_Actor_Menu

Jun 6th, 2014
1,395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.77 KB | None | 0 0
  1. # )--------------------------------------------------(
  2. # )--     Author:     Mr Trivel                    --(
  3. # )--     Name:       Expanded Actor Menu          --(
  4. # )--     Created:    2014-06-06                   --(
  5. # )--     Version:    1.12a                        --(
  6. # )--------------------------------------------------(
  7. # )--     Requires:   None                         --(
  8. # )--------------------------------------------------(
  9. # )--             Description                      --(
  10. # )--  Sets up status window so it displays only   --(
  11. # )--  a single actor data. Browse through other   --(
  12. # )--  actors by using LEFT and RIGHT buttons.     --(
  13. # )--------------------------------------------------(
  14. # )--             Instructions                     --(
  15. # )--             Plug & Play                      --(
  16. # )--------------------------------------------------(
  17. # )--             LICENSE INFO                     --(
  18. # )--http://mrtrivelvx.wordpress.com/terms-of-use/ --(
  19. # )--------------------------------------------------(
  20.  
  21. module MrTS
  22.   module Vocab
  23.    
  24.     # )--------------------------------------------------(
  25.     # )--  Ex-parameter names, feel free to customize  --(
  26.     # )--  Ex-params of index 3, 7, 8 & 9 are not drawn--(
  27.     # )--------------------------------------------------(
  28.     XPARAMS = [ "Hit",
  29.                 "Evasion",
  30.                 "Critical",
  31.                 "CEV", #not drawn by default
  32.                 "Mag Evasion",
  33.                 "Mag Reflect",
  34.                 "Counter",
  35.                 "HRG", #not drawn by default
  36.                 "MRG", #not drawn by default
  37.                 "TRG" ]#not drawn by default
  38.   end
  39.   module Data
  40.     # )---------------------------------------------(
  41.     # )--  Ex-parameter indexes that are ignored  --(
  42.     # )---------------------------------------------(
  43.     # )--  WARNING: If you have less than 4, it   --(
  44.     # )--  will draw them over equipment.         --(
  45.     # )---------------------------------------------(
  46.     IGNORE = [3, 7, 8, 9]
  47.   end
  48. end
  49.  
  50. $imported = {} if $imported.nil?
  51. $imported["MrTS_Expanded_Actor_Menu"] = true
  52.  
  53.  
  54. #)-------------------------(
  55. #)--  Class: Scene_Menu  --(
  56. #)-------------------------(
  57. class Scene_Menu < Scene_MenuBase
  58.  
  59.   # )--------------------------------(
  60.   # )--  Overwrite Method: update  --(
  61.   # )--------------------------------(
  62.   def update
  63.     super
  64.    
  65.     if Input.trigger?(:RIGHT)
  66.      
  67.       if !@in_item_menu
  68.         next_actor
  69.         set_actor_all_a
  70.       end
  71.      
  72.     elsif Input.trigger?(:LEFT)
  73.      
  74.       if !@in_item_menu
  75.         prev_actor
  76.         set_actor_all_a
  77.       end
  78.      
  79.     end
  80.   end
  81.  
  82.   # )-----------------------------------(
  83.   # )--  New Method: set_actor_all_a  --(
  84.   # )-----------------------------------(  
  85.   def set_actor_all_a
  86.     @equipment_window.actor = $game_party.menu_actor
  87.     @status_window.actor = $game_party.menu_actor
  88.     @item_list_window.actor = $game_party.menu_actor
  89.   end
  90.  
  91.   # )---------------------------------------(
  92.   # )--  Alias To: create_command_window  --(
  93.   # )---------------------------------------(
  94.   alias mrts_sm_start start
  95.   def start
  96.     mrts_sm_start
  97.     create_equipment_window
  98.     create_item_list_window
  99.     @in_item_menu = false
  100.     set_actor_all_a
  101.   end
  102.  
  103.   # )-------------------------------------------(
  104.   # )--  New Method: create_item_list_window  --(
  105.   # )-------------------------------------------(
  106.   def create_item_list_window
  107.     @item_list_window = MrTS_Status_Item_List.new(@command_window.width)
  108.     @item_list_window.openness = 0
  109.     @item_list_window.status_window = @status_window
  110.     @item_list_window.set_handler(:ok,       method(:ok_item))
  111.     @item_list_window.set_handler(:cancel,   method(:back_item))
  112.   end
  113.  
  114.   # )---------------------------(
  115.   # )--  New Method: ok_item  --(
  116.   # )---------------------------(
  117.   def ok_item
  118.     Sound.play_equip
  119.     @actor.change_equip(@equipment_window.index, @item_list_window.item)
  120.     @equipment_window.activate
  121.     @equipment_window.refresh
  122.     @item_list_window.close
  123.     @item_list_window.unselect
  124.     @status_window.refresh
  125.     @status_window.set_temp_actor(nil)
  126.     @in_item_menu = false
  127.   end
  128.  
  129.   # )-----------------------------(
  130.   # )--  New Method: back_item  --(
  131.   # )-----------------------------(
  132.   def back_item
  133.     @equipment_window.activate
  134.     @item_list_window.close
  135.     @in_item_menu = false
  136.   end
  137.  
  138.   # )-------------------------------------------(
  139.   # )--  New Method: create_equipment_window  --(
  140.   # )-------------------------------------------(
  141.   def create_equipment_window
  142.     @equipment_window = MrTS_Equipment_Window.new(@command_window.width)
  143.     @equipment_window.status_window = @status_window
  144.     @equipment_window.opacity = 0
  145.     @equipment_window.set_handler(:ok,        method(:ok_equip))
  146.     @equipment_window.set_handler(:cancel,    method(:back_equip))
  147.   end
  148.  
  149.   # )----------------------------(
  150.   # )--  New Method: ok_equip  --(
  151.   # )----------------------------(
  152.   def ok_equip
  153.     index = @equipment_window.index
  154.     if @actor.equip_change_ok?(index)
  155.       @item_list_window.slot_id = index
  156.       @item_list_window.refresh
  157.       @item_list_window.open
  158.       @item_list_window.activate
  159.       @item_list_window.select(0)
  160.       @in_item_menu = true
  161.     else
  162.       Sound.play_buzzer
  163.       @equipment_window.activate
  164.     end
  165.   end
  166.  
  167.   # )------------------------------(
  168.   # )--  New Method: back_equip  --(
  169.   # )------------------------------(
  170.   def back_equip
  171.     @command_window.activate
  172.     @equipment_window.unselect
  173.   end
  174.  
  175.   # )-----------------------------------------------(
  176.   # )--  Overwrite Method: create_command_window  --(
  177.   # )-----------------------------------------------(
  178.   def create_command_window
  179.     @command_window = Window_MenuCommand.new
  180.     @command_window.set_handler(:item,      method(:command_item))
  181.     @command_window.set_handler(:skill,     method(:command_skill))
  182.     @command_window.set_handler(:equip,     method(:command_equip))
  183.     @command_window.set_handler(:save,      method(:command_save))
  184.     @command_window.set_handler(:game_end,  method(:command_game_end))
  185.     @command_window.set_handler(:cancel,    method(:return_scene))
  186.   end
  187.  
  188.   # )---------------------------------(
  189.   # )--  New Method: command_skill  --(
  190.   # )---------------------------------(
  191.   def command_skill
  192.     SceneManager.call(Scene_Skill)
  193.   end
  194.  
  195.   # )---------------------------------(
  196.   # )--  New Method: command_equip  --(
  197.   # )---------------------------------(
  198.   def command_equip
  199.     @equipment_window.activate
  200.     @equipment_window.select(0)
  201.   end
  202.  
  203.   # )----------------------------------------------(
  204.   # )--  Overwrite Method: create_status_window  --(
  205.   # )----------------------------------------------(
  206.   def create_status_window
  207.     @status_window = MrTS_Window_Solo_Status.new(@command_window.width, 0)
  208.   end
  209. end
  210.  
  211.  
  212. #)------------------------------------(
  213. #)--  Class: MrTS_Status_Item_List  --(
  214. #)------------------------------------(
  215. class MrTS_Status_Item_List < Window_EquipItem
  216.  
  217.   attr_reader :status_window
  218.  
  219.   # )--------------------------(
  220.   # )--  Method: initialize  --(
  221.   # )--------------------------(
  222.   def initialize(width)
  223.     super(width, 96 + line_height*7, Graphics.width-width, fitting_height(5))
  224.     @actor = $game_party.leader
  225.     @slot_id = 0
  226.     @status_window = status_window
  227.     refresh
  228.   end
  229.  
  230.   # )------------------------------(
  231.   # )--  Method: status_window=  --(
  232.   # )------------------------------(
  233.   def status_window=(status_window)
  234.     @status_window = status_window
  235.   end
  236.  
  237.   # )-----------------------(
  238.   # )--  Method: col_max  --(
  239.   # )-----------------------(
  240.   def col_max
  241.     return 1
  242.   end
  243.  
  244.   # )--------------------------------(
  245.   # )--  Method: call_update_help  --(
  246.   # )--------------------------------(
  247.   def call_update_help
  248.     update_help
  249.   end
  250.  
  251.   # )---------------------------(
  252.   # )--  Method: update_help  --(
  253.   # )---------------------------(
  254.   def update_help
  255.     if @actor && @status_window
  256.       temp_actor = Marshal.load(Marshal.dump(@actor))
  257.       temp_actor.force_change_equip(@slot_id, item)
  258.       status_window.set_temp_actor(temp_actor)
  259.     end
  260.   end
  261.  
  262.  
  263. end
  264.  
  265.  
  266. #)------------------------------------(
  267. #)--  Class: MrTS_Equipment_Window  --(
  268. #)------------------------------------(
  269. class MrTS_Equipment_Window < Window_EquipSlot
  270.  
  271.   attr_reader :status_window
  272.  
  273.   # )------------------------------------(
  274.   # )--  Overwrite Method: initialize  --(
  275.   # )------------------------------------(
  276.   def initialize(x)
  277.     super(x, 96 + line_height*7, Graphics.width-160)
  278.     @actor = $game_party.leader
  279.     create_contents
  280.     refresh
  281.   end
  282.  
  283.   # )------------------------------------------(
  284.   # )--  Overwrite Method: call_update_help  --(
  285.   # )------------------------------------------(
  286.   def call_update_help
  287.     update_help
  288.   end
  289.  
  290.   # )-------------------------------------(
  291.   # )--  Overwrite Method: update_help  --(
  292.   # )-------------------------------------(
  293.   def update_help
  294.     status_window.set_temp_actor(nil) if @status_window
  295.   end
  296. end
  297.  
  298.  
  299. #)--------------------------------------(
  300. #)--  Class: MrTS_Window_Solo_Status  --(
  301. #)--------------------------------------(
  302. class MrTS_Window_Solo_Status < Window_Base
  303.  
  304.   # )--------------------------(
  305.   # )--  Method: initialize  --(
  306.   # )--------------------------(
  307.   def initialize(x, y)
  308.     super(x, y, window_width, window_height)
  309.     @pending_index = -1
  310.     @temp_actor = nil
  311.     @actor = $game_party.leader
  312.     refresh
  313.   end
  314.  
  315.   # )----------------------------(
  316.   # )--  Method: window_width  --(
  317.   # )----------------------------(
  318.   def window_width
  319.     Graphics.width - 160
  320.   end
  321.  
  322.   # )-----------------------------(
  323.   # )--  Method: window_height  --(
  324.   # )-----------------------------(
  325.   def window_height
  326.     Graphics.height
  327.   end
  328.  
  329.   # )--------------------------------(
  330.   # )--  Method: draw_actor_param  --(
  331.   # )--------------------------------(
  332.   def draw_actor_param(actor, x, y, param_id, color = normal_color)
  333.     change_color(system_color)
  334.     draw_text(x, y, 120, line_height, Vocab::param(param_id))
  335.     change_color(color)
  336.     draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2)
  337.     change_color(normal_color)
  338.   end
  339.  
  340.   # )-----------------------------(
  341.   # )--  Method: draw_actor_hp  --(
  342.   # )-----------------------------(
  343.   def draw_actor_hp(actor, x, y, width = 124, color = normal_color)
  344.     draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  345.     change_color(system_color)
  346.     draw_text(x, y, 30, line_height, Vocab::hp_a)
  347.     draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
  348.       hp_color(actor), color)
  349.     end
  350.    
  351.   # )-----------------------------(
  352.   # )--  Method: draw_actor_mp  --(
  353.   # )-----------------------------(
  354.   def draw_actor_mp(actor, x, y, width = 124, color = normal_color)
  355.     draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
  356.     change_color(system_color)
  357.     draw_text(x, y, 30, line_height, Vocab::mp_a)
  358.     draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
  359.       mp_color(actor), color)
  360.   end
  361.  
  362.   # )-----------------------(
  363.   # )--  Method: refresh  --(
  364.   # )-----------------------(
  365.   def refresh
  366.     contents.clear
  367.     create_contents
  368.    
  369.     temp_color = normal_color
  370.    
  371.     draw_actor_face(@actor, 0, 0)
  372.     draw_actor_level(@actor, 96, 0)
  373.     draw_actor_name(@actor, 96, line_height)
  374.     draw_actor_class(@actor, 96, line_height*2)
  375.     if !$imported["MrTS_Thirst"]
  376.       draw_actor_xp(@actor, contents.width-160, line_height*2, 160)
  377.     elsif $imported["MrTS_Thirst"]
  378.       draw_thirst_gauge(@actor, contents.width-160, line_height*2, 160)
  379.     end    
  380.    
  381.     if @temp_actor == nil
  382.       draw_actor_hp(@actor, contents.width-160, 0, 160)
  383.       draw_actor_mp(@actor, contents.width-160, line_height, 160)
  384.     else
  385.       temp_color = param_change_color(@temp_actor.param(0)-@actor.param(0))
  386.       draw_actor_hp(@temp_actor, contents.width-160, 0, 160, temp_color)
  387.      
  388.       temp_color = param_change_color(@temp_actor.param(1)-@actor.param(1))
  389.       draw_actor_mp(@temp_actor, contents.width-160, line_height, 160, temp_color)
  390.     end
  391.    
  392.     #params
  393.     6.times do |i|
  394.       contents.gradient_fill_rect(-3, 96+line_height*i, 159, line_height-10, text_color(15), text_color(19))
  395.       dy = 96 + line_height * i
  396.      
  397.       if @temp_actor == nil
  398.         draw_actor_param(@actor, 0, dy, i + 2)
  399.       else
  400.         temp_color = param_change_color(@temp_actor.param(i+2)-@actor.param(i+2))
  401.         draw_actor_param(@temp_actor, 0, 96 + line_height * (i), i+2, temp_color)
  402.       end
  403.     end
  404.    
  405.     #xparams
  406.     skipped = 0
  407.     ignore = MrTS::Data::IGNORE #ignore these xparams
  408.     10.times do |i|
  409.       if !ignore.include?(i)
  410.         if @temp_actor == nil
  411.           draw_actor_xparam(@actor, contents.width-156, 96 + line_height * (i - skipped), i)
  412.         else
  413.           temp_color = param_change_color(@temp_actor.xparam(i)-@actor.xparam(i))
  414.           draw_actor_xparam(@temp_actor, contents.width-156, 96 + line_height * (i - skipped), i, temp_color)
  415.         end
  416.        
  417.       else
  418.         skipped += 1
  419.       end
  420.     end
  421.   end # of refresh
  422.  
  423.   # )---------------------------------(
  424.   # )--  Method: draw_actor_xparam  --(
  425.   # )---------------------------------(
  426.   def draw_actor_xparam(actor, x, y, param_id, color = normal_color)
  427.     contents.gradient_fill_rect(x-3, y, 159, line_height-10, text_color(15), text_color(19))
  428.     change_color(system_color)
  429.     draw_text(x, y, 120, line_height, MrTS::Vocab::XPARAMS[param_id])
  430.     change_color(color)
  431.     draw_text(x + 120 - 36, y, 72, line_height, (actor.xparam(param_id)*100).to_i.to_s + "%", 2)
  432.   end
  433.  
  434.   # )-----------------------------(
  435.   # )--  Method: draw_actor_xp  --(
  436.   # )-----------------------------(
  437.   def draw_actor_xp(actor, x, y, width = 124)
  438.     float = 1.0 * (actor.exp - actor.current_level_exp) / (actor.next_level_exp - actor.current_level_exp)
  439.     draw_gauge(x, y, width, float, text_color(28), text_color(29))
  440.     change_color(system_color)
  441.     draw_text(x, y, 30, line_height, "EXP")
  442.     change_color(normal_color)
  443.     draw_text(x + width - 140, y, (140-12)/2, line_height, actor.exp - actor.current_level_exp, 2)
  444.     draw_text(x+ width - 140/2, y, 12, line_height, "/", 2)
  445.     draw_text(x+ width - (140-12)/2, y, (140-12)/2, line_height, actor.next_level_exp - actor.current_level_exp, 2)
  446.   end
  447.  
  448.   # )------------------------------(
  449.   # )--  Method: set_temp_actor  --(
  450.   # )------------------------------(
  451.   def set_temp_actor(temp_actor)
  452.     return if @temp_actor == temp_actor
  453.     @temp_actor = temp_actor
  454.     refresh
  455.   end
  456.  
  457.   # )----------------------(
  458.   # )--  Method: actor=  --(
  459.   # )----------------------(
  460.   def actor=(actor)
  461.     return if @actor == actor
  462.     @actor = actor
  463.     refresh
  464.   end
  465.  
  466. end
  467.  
  468.  
  469. # )---------------------------------(
  470. # )--  Class: Window_MenuCommand  --(
  471. # )---------------------------------(
  472. class Window_MenuCommand < Window_Command
  473.  
  474.   # )-------------------------------------------(
  475.   # )--  Overwrite Method: make_command_list  --(
  476.   # )-------------------------------------------(
  477.   def make_command_list
  478.     add_main_commands
  479.     add_original_commands
  480.     add_save_command
  481.     add_game_end_command
  482.   end
  483.  
  484.   # )-------------------------------------------(
  485.   # )--  Overwrite Method: add_main_commands  --(
  486.   # )-------------------------------------------(
  487.   def add_main_commands
  488.     add_command(Vocab::item,   :item,   main_commands_enabled)
  489.     add_command(Vocab::skill,  :skill,  main_commands_enabled)
  490.     add_command(Vocab::equip,  :equip,  main_commands_enabled)
  491.   end
  492. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement