Advertisement
roninator2

Map Skill Menu

Nov 17th, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 34.61 KB | Gaming | 0 0
  1. # ╔═══════════════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Map Skill Menu                         ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                            ║                    ║
  4. # ╠═══════════════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                                     ║   Date Created     ║
  6. # ║                                               ╠════════════════════╣
  7. # ║ Call a skill menu on the map                  ║    11 Oct 2023     ║
  8. # ╚═══════════════════════════════════════════════╩════════════════════╝
  9. # ╔════════════════════════════════════════════════════════════════════╗
  10. # ║ Requires: nil                                                      ║
  11. # ║                                                                    ║
  12. # ╚════════════════════════════════════════════════════════════════════╝
  13. # ╔════════════════════════════════════════════════════════════════════╗
  14. # ║ Brief Description:                                                 ║
  15. # ║       Call Skill Scene on map without Main Menu                    ║
  16. # ╚════════════════════════════════════════════════════════════════════╝
  17. # ╔════════════════════════════════════════════════════════════════════╗
  18. # ║ Instructions:                                                      ║
  19. # ║                                                                    ║
  20. # ║  Change the values below to the desired configuration              ║
  21. # ║                                                                    ║
  22. # ║  The skills shown in the window are skills usable in the           ║
  23. # ║  menu, not battle skills                                           ║
  24. # ║                                                                    ║
  25. # ║  Call_Skill_Button -> Button pressed to call the menu              ║
  26. # ║                                                                    ║
  27. # ║  POSITION -> values are 0, 1, 2, 3                                 ║
  28. # ║              0 = Help window left side                             ║
  29. # ║              1 = Help window right side                            ║
  30. # ║              2 = Help window top                                   ║
  31. # ║              3 = Help window bottom                                ║
  32. # ║    All other windows move based on the Help window                 ║
  33. # ║                                                                    ║
  34. # ║  USE_NOTE -> allows using note tags in the skill notebox           ║
  35. # ║    If using the note tags they are to be used like this            ║
  36. # ║       <item text>                                                  ║
  37. # ║        write all your text here                                    ║
  38. # ║        and more text here                                          ║
  39. # ║        also supports icon codes \i[112]                            ║
  40. # ║       </item text>                                                 ║
  41. # ║    If not using item note tags then it will write the              ║
  42. # ║    default skill description                                       ║
  43. # ║                                                                    ║
  44. # ║  HELP_X and HELP_Y -> move the window away from the                ║
  45. # ║                       screen edge                                  ║
  46. # ║  HELP_LINES -> How many lines to have for the help window          ║
  47. # ║                                                                    ║
  48. # ║  STATUS_X and STATUS_Y ->  move the window away from the           ║
  49. # ║                            screen edge                             ║
  50. # ║  GRAPHICS_SPRITE -> use the walking sprite, or face                ║
  51. # ║  STATUS_ROWS -> How many lines to use for the status               ║
  52. # ║    window. Positoin 0 & 1 -> recommend 4                           ║
  53. # ║            Positoin 2 & 3 -> recommend 3                           ║
  54. # ║                                                                    ║
  55. # ║  COMMAND_X & COMMAND_Y -> move the window away from the            ║
  56. # ║                           screen edge                              ║
  57. # ║  COMMAND_COLUMNS -> How many commands to show in window            ║
  58. # ║   More commands in small window means they get squished            ║
  59. # ║                                                                    ║
  60. # ║  SKILL_X & SKILL_Y -> move the window away from the                ║
  61. # ║                       screen edge                                  ║
  62. # ║  FULL_WIDTH -> Ignore the X value and go full width                ║
  63. # ║  SKILL_COLUMNS -> How many skills columns to display               ║
  64. # ║                                                                    ║
  65. # ╚════════════════════════════════════════════════════════════════════╝
  66. # ╔════════════════════════════════════════════════════════════════════╗
  67. # ║ Updates:                                                           ║
  68. # ║ 1.00 - 11 Oct 2023 - Script finished                               ║
  69. # ║                                                                    ║
  70. # ╚════════════════════════════════════════════════════════════════════╝
  71. # ╔════════════════════════════════════════════════════════════════════╗
  72. # ║ Credits and Thanks:                                                ║
  73. # ║   Roninator2                                                       ║
  74. # ║   DP3 & Tsukihime for their code                                   ║
  75. # ║                                                                    ║
  76. # ╚════════════════════════════════════════════════════════════════════╝
  77. # ╔════════════════════════════════════════════════════════════════════╗
  78. # ║ Terms of use:                                                      ║
  79. # ║  Follow the original Authors terms of use where applicable         ║
  80. # ║    - When not made by me (Roninator2)                              ║
  81. # ║  Free for all uses in RPG Maker except nudity                      ║
  82. # ║  Anyone using this script in their project before these terms      ║
  83. # ║  were changed are allowed to use this script even if it conflicts  ║
  84. # ║  with these new terms. New terms effective 03 Apr 2024             ║
  85. # ║  No part of this code can be used with AI programs or tools        ║
  86. # ║  Credit must be given                                              ║
  87. # ╚════════════════════════════════════════════════════════════════════╝
  88.  
  89. module R2_MAP_SKILL_MENU
  90.   Call_Skill_Button = :Y
  91.     # :C = Z, :B = X, :A = SHIFT, :X = A, :Y = S, :Z = D, :L = Q, :R = W
  92.  
  93.   # ======================================================
  94.   POSITION = 3
  95.   # 0 = left, 1 = Right, 2 = top, 3 = bottom
  96.   # help window goes in the opposite side
  97.  
  98.   # ======================================================
  99.   # Help Window
  100.   USE_NOTE = true
  101.   # configure to use Note Box for Item Description or
  102.   # use description from the item itself.
  103.   # true = use note box tag
  104.   # false = use built in description box
  105.   HELP_X = 20
  106.   # position of where the Help window is positioned on X axis
  107.   # This will position the window away from the edge of the screen
  108.   HELP_Y = 20
  109.   # position of where the Help window is positioned on Y axis
  110.   # This will position the window away from the edge of the screen
  111.   HELP_LINES = 4
  112.   # The number of lines the help window will show. Sets the height
  113.   # position 0 & 1 -> recommend 15, position 2 & 3 -> recommend 4
  114.  
  115.   # ======================================================
  116.   # Status Window
  117.   STATUS_X = 20
  118.   # position of where the Status window is positioned on X axis
  119.   STATUS_Y = 20
  120.   # position of where the Status window is positioned on Y axis
  121.   GRAPHICS_SPRITE = false
  122.   # True will draw Sprite, false will draw face.
  123.   STATUS_ROWS = 3
  124.   # how many lines the status takes up.
  125.   # position 0 & 1 -> recommend 4, position 2 & 3 -> recommend 3
  126.  
  127.   # ======================================================
  128.   # Command Window
  129.   COMMAND_X = 20
  130.   # position of where the ommand window is positioned on X axis
  131.   COMMAND_Y = 20
  132.   # position of where the ommand window is positioned on Y axis
  133.   COMMAND_COLUMNS = 4
  134.   # position 0 & 1 -> recommend 1 or 2, position 2 & 3 -> recommend < 5
  135.  
  136.   # ======================================================
  137.   # Skill Window
  138.   SKILL_X = 20
  139.   # position of where the Skill window is positioned on X axis
  140.   SKILL_Y = 20
  141.   # position of where the Skill window is positioned on Y axis
  142.   FULL_WIDTH = false
  143.   # wether to span across the window width
  144.   SKILL_COLUMNS = 3
  145.   # number of columns in window
  146.   # position 0 & 1 -> recommend 1, position 2 & 3 -> recommend 2 or 3
  147. end
  148.  
  149. #==============================================================================
  150. # ** Window_Help
  151. #==============================================================================
  152.  
  153. class Window_SkillHelp < Window_Base
  154.   #--------------------------------------------------------------------------
  155.   # * Object Initialization
  156.   #--------------------------------------------------------------------------
  157.   def initialize(line_number = R2_MAP_SKILL_MENU::HELP_LINES)
  158.     @position = R2_MAP_SKILL_MENU::POSITION
  159.     super(R2_MAP_SKILL_MENU::HELP_X, R2_MAP_SKILL_MENU::HELP_Y, width, fitting_height(line_number))
  160.     adjust_help_position(@position)
  161.     @text_desc = []
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * Set Text
  165.   #--------------------------------------------------------------------------
  166.   def set_text(text)
  167.     @text_desc = []
  168.     if text != @text
  169.       @text = text
  170.       @text_desc.push("#{@text}")
  171.       refresh
  172.     end
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # * Clear
  176.   #--------------------------------------------------------------------------
  177.   def clear
  178.     contents.clear
  179.     @text_desc = []
  180.     set_text("")
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * Set Item
  184.   #     item : Skills and items etc.
  185.   #--------------------------------------------------------------------------
  186.   def set_item(item)
  187.     @text_desc = []
  188.     if R2_MAP_SKILL_MENU::USE_NOTE == true
  189.       @text_desc = []
  190.       return if item.nil?
  191.       results = item.note.scan(/<item[-_ ]*text>(.*?)<\/item[-_ ]*text>/imx)
  192.       results.each do |res|
  193.         res[0].strip.split("\r\n").each do |line|
  194.         @text_desc.push("#{line}")
  195.         end
  196.       end
  197.     else
  198.       set_text(item ? item.description : "")
  199.     end
  200.     refresh
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # * Refresh
  204.   #--------------------------------------------------------------------------
  205.   def refresh
  206.     contents.clear
  207.     @y = 0
  208.     @text_desc.each do |l|
  209.       draw_text_ex(0, @y, word_wrapping(l))
  210.       @y += line_height
  211.     end
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # * Calculate Width of Window Contents
  215.   #--------------------------------------------------------------------------
  216.   def width
  217.     case @position
  218.     when 0..1
  219.       Graphics.width / 2 - R2_MAP_SKILL_MENU::HELP_X
  220.     when 2..3
  221.       Graphics.width - R2_MAP_SKILL_MENU::HELP_X * 2
  222.     end
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # * Move Help Window
  226.   #--------------------------------------------------------------------------
  227.   def adjust_help_position(position)
  228.     case position
  229.     when 0
  230.       self.x = R2_MAP_SKILL_MENU::HELP_X
  231.       self.y = R2_MAP_SKILL_MENU::HELP_Y
  232.     when 1
  233.       self.x = Graphics.width / 2
  234.       self.y = R2_MAP_SKILL_MENU::HELP_Y
  235.     when 2
  236.       self.x = R2_MAP_SKILL_MENU::HELP_X
  237.       self.y = R2_MAP_SKILL_MENU::HELP_Y
  238.     when 3
  239.       self.x = R2_MAP_SKILL_MENU::HELP_X
  240.       self.y = Graphics.height - self.height - R2_MAP_SKILL_MENU::HELP_Y / 2
  241.     end
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # * Word Wrapping
  245.   #--------------------------------------------------------------------------
  246.   def word_wrapping(text, pos = 0)
  247.     # Current Text Position
  248.     current_text_position = 0    
  249.     for i in 0..(text.length - 1)
  250.       if text[i] == "\n"
  251.         current_text_position = 0
  252.         next
  253.       end
  254.       # Current Position += character width
  255.       current_text_position += contents.text_size(text[i]).width
  256.       # If Current Position > Window Width
  257.       if (pos + current_text_position) >= (contents.width)
  258.         # Then Format the Sentence to fit Line
  259.         current_element = i
  260.         while(text[current_element] != " ")
  261.           break if current_element == 0
  262.           current_element -= 1
  263.         end
  264.         temp_text = ""
  265.         for j in 0..(text.length - 1)
  266.           temp_text += text[j]
  267.           temp_text += "\n" if j == current_element
  268.           @y += line_height if j == current_element
  269.         end
  270.         text = temp_text
  271.         i = current_element
  272.         current_text_position = 0
  273.       end
  274.     end
  275.     return text
  276.   end
  277. end
  278.  
  279. #==============================================================================
  280. # ** Window_MapSkillStatus
  281. #==============================================================================
  282.  
  283. class Window_MapSkillStatus < Window_Base
  284.   #--------------------------------------------------------------------------
  285.   # * Object Initialization
  286.   #--------------------------------------------------------------------------
  287.   def initialize(x, y)
  288.     @position = R2_MAP_SKILL_MENU::POSITION
  289.     super(x, y, window_width, fitting_height(R2_MAP_SKILL_MENU::STATUS_ROWS))
  290.     adjust_status_position(@position)
  291.     @actor = nil
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # * Get Window Width
  295.   #--------------------------------------------------------------------------
  296.   def window_width
  297.     case @position
  298.     when 0..1
  299.       Graphics.width / 2 - R2_MAP_SKILL_MENU::STATUS_X
  300.     when 2..3
  301.       Graphics.width - R2_MAP_SKILL_MENU::STATUS_X * 2
  302.     end
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # * Move Status Window
  306.   #--------------------------------------------------------------------------
  307.   def adjust_status_position(position)
  308.     case position
  309.     when 0
  310.       self.x = Graphics.width / 2
  311.       self.y = R2_MAP_SKILL_MENU::STATUS_Y
  312.     when 1
  313.       self.x = R2_MAP_SKILL_MENU::STATUS_X
  314.       self.y = R2_MAP_SKILL_MENU::STATUS_Y
  315.     when 2
  316.       self.x = R2_MAP_SKILL_MENU::STATUS_X
  317.       self.y = Graphics.height - self.height - R2_MAP_SKILL_MENU::STATUS_Y
  318.     when 3
  319.       self.x = R2_MAP_SKILL_MENU::STATUS_X
  320.       self.y = R2_MAP_SKILL_MENU::STATUS_Y
  321.     end
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # * Actor Settings
  325.   #--------------------------------------------------------------------------
  326.   def actor=(actor)
  327.     return if @actor == actor
  328.     @actor = actor
  329.     refresh
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # * Refresh
  333.   #--------------------------------------------------------------------------
  334.   def refresh
  335.     contents.clear
  336.     return unless @actor
  337.     x = 0
  338.     draw_actor_graphic(@actor, 75, 50) if R2_MAP_SKILL_MENU::GRAPHICS_SPRITE
  339.     if @position == 2 || @position == 3
  340.       draw_actor_face(@actor, x, 0) if !R2_MAP_SKILL_MENU::GRAPHICS_SPRITE
  341.       x = 120
  342.     else
  343.       draw_actor_face(@actor, x, 0) if !R2_MAP_SKILL_MENU::GRAPHICS_SPRITE
  344.     end
  345.     draw_actor_name(@actor, x, 0)
  346.     draw_actor_level(@actor, x, line_height * 1)
  347.     draw_actor_icons(@actor, x, line_height * 2)
  348.     draw_actor_class(@actor, x + 100, 0)
  349.     draw_actor_hp(@actor, x + 100, line_height * 1)
  350.     draw_actor_mp(@actor, x + 100, line_height * 2)
  351.   end
  352. end # Window_MapSkillStatus
  353.  
  354. #==============================================================================
  355. # ** Window_MapSkillCommand
  356. #==============================================================================
  357.  
  358. class Window_MapSkillCommand < Window_HorzCommand
  359.   #--------------------------------------------------------------------------
  360.   # * Public Instance Variables
  361.   #--------------------------------------------------------------------------
  362.   attr_reader   :skill_window
  363.   #--------------------------------------------------------------------------
  364.   # * Object Initialization
  365.   #--------------------------------------------------------------------------
  366.   def initialize(x, y)
  367.     @position = R2_MAP_SKILL_MENU::POSITION
  368.     super(x, y)
  369.     adjust_command_position(@position)
  370.     @actor = nil
  371.   end
  372.   #--------------------------------------------------------------------------
  373.   # * Get Window Width
  374.   #--------------------------------------------------------------------------
  375.   def window_width
  376.     case @position
  377.     when 0..1
  378.       Graphics.width / 2 - R2_MAP_SKILL_MENU::COMMAND_X
  379.     when 2..3
  380.       Graphics.width - R2_MAP_SKILL_MENU::COMMAND_X * 2
  381.     end
  382.   end
  383.   #--------------------------------------------------------------------------
  384.   # * Move Command Window
  385.   #--------------------------------------------------------------------------
  386.   def adjust_command_position(position)
  387.     case position
  388.     when 0
  389.       self.x = Graphics.width / 2
  390.       self.y = R2_MAP_SKILL_MENU::COMMAND_Y + fitting_height(R2_MAP_SKILL_MENU::STATUS_ROWS)
  391.     when 1
  392.       self.x = R2_MAP_SKILL_MENU::COMMAND_X
  393.       self.y = R2_MAP_SKILL_MENU::COMMAND_Y + fitting_height(R2_MAP_SKILL_MENU::STATUS_ROWS)
  394.     when 2
  395.       self.x = R2_MAP_SKILL_MENU::COMMAND_X
  396.       self.y = Graphics.height - R2_MAP_SKILL_MENU::COMMAND_Y - fitting_height(R2_MAP_SKILL_MENU::STATUS_ROWS) - self.height
  397.     when 3
  398.       self.x = R2_MAP_SKILL_MENU::COMMAND_X
  399.       self.y = R2_MAP_SKILL_MENU::COMMAND_Y + fitting_height(R2_MAP_SKILL_MENU::STATUS_ROWS)
  400.     end
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # * Get Digit Count
  404.   #--------------------------------------------------------------------------
  405.   def col_max
  406.     return R2_MAP_SKILL_MENU::COMMAND_COLUMNS
  407.   end
  408.   #--------------------------------------------------------------------------
  409.   # * Set Actor
  410.   #--------------------------------------------------------------------------
  411.   def actor=(actor)
  412.     return if @actor == actor
  413.     @actor = actor
  414.     refresh
  415.     select_last
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # * Create Command List
  419.   #--------------------------------------------------------------------------
  420.   def make_command_list
  421.     return unless @actor
  422.     @actor.added_skill_types.sort.each do |stype_id|
  423.       name = $data_system.skill_types[stype_id]
  424.       add_command(name, :skill, true, stype_id)
  425.     end
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # * Frame Update
  429.   #--------------------------------------------------------------------------
  430.   def update
  431.     super
  432.     @skill_window.stype_id = current_ext if @skill_window
  433.   end
  434.   #--------------------------------------------------------------------------
  435.   # * Set Skill Window
  436.   #--------------------------------------------------------------------------
  437.   def skill_window=(skill_window)
  438.     @skill_window = skill_window
  439.     update
  440.   end
  441.   #--------------------------------------------------------------------------
  442.   # * Restore Previous Selection Position
  443.   #--------------------------------------------------------------------------
  444.   def select_last
  445.     skill = @actor.last_skill.object
  446.     if skill
  447.       select_ext(skill.stype_id)
  448.     else
  449.       select(0)
  450.     end
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # * Set Leading Digits
  454.   #--------------------------------------------------------------------------
  455.   def top_col=(col)
  456.     col = 0 if col < 0
  457.     col = item_max if col > item_max
  458.     self.ox = col * (item_width + spacing)
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # * Move Cursor Right # col_max >= 2 &&
  462.   #--------------------------------------------------------------------------
  463.   def cursor_right(wrap = false)
  464.     if (index < item_max - 1 || (wrap && horizontal?))
  465.       select((index + 1) % item_max)
  466.     end
  467.   end
  468.   #--------------------------------------------------------------------------
  469.   # * Move Cursor Left
  470.   #--------------------------------------------------------------------------
  471.   def cursor_left(wrap = false)
  472.     if (index > 0 || (wrap && horizontal?))
  473.       select((index - 1 + item_max) % item_max)
  474.     end
  475.   end
  476. end # Window_MapSkillCommand
  477.  
  478. #==============================================================================
  479. # ** Window_MapSkillList
  480. #==============================================================================
  481.  
  482. class Window_MapSkillList < Window_Selectable
  483.   #--------------------------------------------------------------------------
  484.   # * Object Initialization
  485.   #--------------------------------------------------------------------------
  486.   def initialize(x, y, width, height)
  487.     super
  488.     @actor = nil
  489.     @stype_id = 0
  490.     @data = []
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # * Set Actor
  494.   #--------------------------------------------------------------------------
  495.   def actor=(actor)
  496.     return if @actor == actor
  497.     @actor = actor
  498.     refresh
  499.     self.oy = 0
  500.   end
  501.   #--------------------------------------------------------------------------
  502.   # * Set Skill Type ID
  503.   #--------------------------------------------------------------------------
  504.   def stype_id=(stype_id)
  505.     return if @stype_id == stype_id
  506.     @stype_id = stype_id
  507.     refresh
  508.     self.oy = 0
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # * Get Digit Count
  512.   #--------------------------------------------------------------------------
  513.   def col_max
  514.     return R2_MAP_SKILL_MENU::SKILL_COLUMNS
  515.   end
  516.   #--------------------------------------------------------------------------
  517.   # * Get Number of Items
  518.   #--------------------------------------------------------------------------
  519.   def item_max
  520.     @data ? @data.size : 1
  521.   end
  522.   #--------------------------------------------------------------------------
  523.   # * Get Skill
  524.   #--------------------------------------------------------------------------
  525.   def item
  526.     @data && index >= 0 ? @data[index] : nil
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # * Get Activation State of Selection Item
  530.   #--------------------------------------------------------------------------
  531.   def current_item_enabled?
  532.     enable?(@data[index])
  533.   end
  534.   #--------------------------------------------------------------------------
  535.   # * Include in Skill List?
  536.   #--------------------------------------------------------------------------
  537.   def include?(item)
  538.     item && item.stype_id == @stype_id && item.menu_ok?
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # * Display Skill in Active State?
  542.   #--------------------------------------------------------------------------
  543.   def enable?(item)
  544.     @actor && @actor.usable?(item)
  545.   end
  546.   #--------------------------------------------------------------------------
  547.   # * Create Skill List
  548.   #--------------------------------------------------------------------------
  549.   def make_item_list
  550.     @data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
  551.   end
  552.   #--------------------------------------------------------------------------
  553.   # * Restore Previous Selection Position
  554.   #--------------------------------------------------------------------------
  555.   def select_last
  556.     select(@data.index(@actor.last_skill.object) || 0)
  557.   end
  558.   #--------------------------------------------------------------------------
  559.   # * Draw Item
  560.   #--------------------------------------------------------------------------
  561.   def draw_item(index)
  562.     skill = @data[index]
  563.     if skill
  564.       rect = item_rect(index)
  565.       rect.width -= 4
  566.       draw_item_name(skill, rect.x, rect.y, enable?(skill))
  567.       draw_skill_cost(rect, skill)
  568.     end
  569.   end
  570.   #--------------------------------------------------------------------------
  571.   # * Draw Skill Use Cost
  572.   #--------------------------------------------------------------------------
  573.   def draw_skill_cost(rect, skill)
  574.     if @actor.skill_tp_cost(skill) > 0
  575.       change_color(tp_cost_color, enable?(skill))
  576.       draw_text(rect, @actor.skill_tp_cost(skill), 2)
  577.     elsif @actor.skill_mp_cost(skill) > 0
  578.       change_color(mp_cost_color, enable?(skill))
  579.       draw_text(rect, @actor.skill_mp_cost(skill), 2)
  580.     end
  581.   end
  582.   #--------------------------------------------------------------------------
  583.   # * Update Help Text
  584.   #--------------------------------------------------------------------------
  585.   def update_help
  586.     @help_window.set_item(item)
  587.   end
  588.   #--------------------------------------------------------------------------
  589.   # * Refresh
  590.   #--------------------------------------------------------------------------
  591.   def refresh
  592.     make_item_list
  593.     create_contents
  594.     draw_all_items
  595.   end
  596. end # Window_MapSkillList
  597.  
  598. #==============================================================================
  599. # ** Scene_Map
  600. #==============================================================================
  601.  
  602. class Scene_Map < Scene_Base
  603.   #--------------------------------------------------------------------------
  604.   # * Update Scene Transition
  605.   #--------------------------------------------------------------------------
  606.   alias r2_update_call_skill_map_scene  update_scene
  607.   def update_scene
  608.     r2_update_call_skill_map_scene
  609.     update_call_skill_menu unless scene_changing?
  610.   end
  611.   #--------------------------------------------------------------------------
  612.   # * Determine if Menu is Called due to Cancel Button
  613.   #--------------------------------------------------------------------------
  614.   def update_call_skill_menu
  615.     if !$game_system.menu_disabled || !$game_map.interpreter.running?
  616.       if Input.trigger?(R2_MAP_SKILL_MENU::Call_Skill_Button) && !$game_player.moving?
  617.         call_skill_menu
  618.       end
  619.     end
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   # * Call Menu Screen
  623.   #--------------------------------------------------------------------------
  624.   def call_skill_menu
  625.     Sound.play_ok
  626.     SceneManager.call(Scene_Skill_Menu)
  627.   end
  628. end
  629.  
  630. #==============================================================================
  631. # ** Scene_Skill
  632. #==============================================================================
  633.  
  634. class Scene_Skill_Menu < Scene_ItemBase
  635.   #--------------------------------------------------------------------------
  636.   # * Start Processing
  637.   #--------------------------------------------------------------------------
  638.   def start
  639.     super
  640.     create_help_window
  641.     create_command_window
  642.     create_status_window
  643.     create_item_window
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # * Create Help Window
  647.   #--------------------------------------------------------------------------
  648.   def create_help_window
  649.     @help_window = Window_SkillHelp.new
  650.     @help_window.viewport = @viewport
  651.   end
  652.   #--------------------------------------------------------------------------
  653.   # * Create Command Window
  654.   #--------------------------------------------------------------------------
  655.   def create_command_window
  656.     @command_window = Window_MapSkillCommand.new(0, 0)
  657.     @command_window.viewport = @viewport
  658.     @command_window.help_window = @help_window
  659.     @command_window.actor = @actor
  660.     @command_window.set_handler(:skill,    method(:command_skill))
  661.     @command_window.set_handler(:cancel,   method(:return_scene))
  662.     @command_window.set_handler(:pagedown, method(:next_actor))
  663.     @command_window.set_handler(:pageup,   method(:prev_actor))
  664.   end
  665.   #--------------------------------------------------------------------------
  666.   # * Create Status Window
  667.   #--------------------------------------------------------------------------
  668.   def create_status_window
  669.     case R2_MAP_SKILL_MENU::POSITION
  670.     when 0
  671.       sx = Graphics.width / 2
  672.       sy = R2_MAP_SKILL_MENU::STATUS_Y
  673.     when 1
  674.       sx = 0
  675.       sy = R2_MAP_SKILL_MENU::STATUS_Y
  676.     when 2
  677.       sx = R2_MAP_SKILL_MENU::STATUS_X
  678.       sy = R2_MAP_SKILL_MENU::STATUS_Y
  679.     when 3
  680.       sx = R2_MAP_SKILL_MENU::STATUS_X
  681.       sy = R2_MAP_SKILL_MENU::STATUS_Y
  682.     end
  683.     @status_window = Window_MapSkillStatus.new(sx, sy)
  684.     @status_window.viewport = @viewport
  685.     @status_window.actor = @actor
  686.   end
  687.   #--------------------------------------------------------------------------
  688.   # * Create Item Window
  689.   #--------------------------------------------------------------------------
  690.   def create_item_window
  691.     wx = 0
  692.     ww = Graphics.width
  693.     case R2_MAP_SKILL_MENU::POSITION
  694.     when 0
  695.       wx = Graphics.width / 2
  696.       wy = @command_window.y + @command_window.height
  697.       ww = Graphics.width / 2 - R2_MAP_SKILL_MENU::SKILL_X unless R2_MAP_SKILL_MENU::FULL_WIDTH
  698.       wh = Graphics.height - wy - (R2_MAP_SKILL_MENU::SKILL_Y - 5)
  699.     when 1
  700.       wx = R2_MAP_SKILL_MENU::SKILL_X
  701.       wy = @command_window.y + @command_window.height
  702.       ww = Graphics.width / 2 - R2_MAP_SKILL_MENU::SKILL_X unless R2_MAP_SKILL_MENU::FULL_WIDTH
  703.       wh = Graphics.height - wy - (R2_MAP_SKILL_MENU::SKILL_Y - 5)
  704.     when 2
  705.       wx = R2_MAP_SKILL_MENU::SKILL_X unless R2_MAP_SKILL_MENU::FULL_WIDTH
  706.       wy = @help_window.y + @help_window.height
  707.       ww = Graphics.width - R2_MAP_SKILL_MENU::SKILL_X * 2 unless R2_MAP_SKILL_MENU::FULL_WIDTH
  708.       wh = Graphics.height - @status_window.height - @help_window.height - @command_window.height - R2_MAP_SKILL_MENU::SKILL_Y * 2
  709.     when 3
  710.       wx = R2_MAP_SKILL_MENU::SKILL_X unless R2_MAP_SKILL_MENU::FULL_WIDTH
  711.       wy = @status_window.y + @status_window.height + @command_window.height
  712.       ww = Graphics.width - R2_MAP_SKILL_MENU::SKILL_X * 2 unless R2_MAP_SKILL_MENU::FULL_WIDTH
  713.       wh = Graphics.height - @help_window.height - @status_window.height - @command_window.height - @status_window.y
  714.       wh -= (R2_MAP_SKILL_MENU::SKILL_Y - 10)
  715.     end
  716.     @item_window = Window_MapSkillList.new(wx, wy, ww, wh)
  717.     @item_window.actor = @actor
  718.     @item_window.viewport = @viewport
  719.     @item_window.help_window = @help_window
  720.     @item_window.set_handler(:ok,     method(:on_item_ok))
  721.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  722.     @command_window.skill_window = @item_window
  723.   end
  724.   #--------------------------------------------------------------------------
  725.   # * Get Skill's User
  726.   #--------------------------------------------------------------------------
  727.   def user
  728.     @actor
  729.   end
  730.   #--------------------------------------------------------------------------
  731.   # * [Skill] Command
  732.   #--------------------------------------------------------------------------
  733.   def command_skill
  734.     @item_window.activate
  735.     @item_window.select_last
  736.   end
  737.   #--------------------------------------------------------------------------
  738.   # * Item [OK]
  739.   #--------------------------------------------------------------------------
  740.   def on_item_ok
  741.     @actor.last_skill.object = item
  742.     determine_item
  743.   end
  744.   #--------------------------------------------------------------------------
  745.   # * Item [Cancel]
  746.   #--------------------------------------------------------------------------
  747.   def on_item_cancel
  748.     @help_window.clear
  749.     @item_window.unselect
  750.     @command_window.activate
  751.   end
  752.   #--------------------------------------------------------------------------
  753.   # * Play SE When Using Item
  754.   #--------------------------------------------------------------------------
  755.   def play_se_for_item
  756.     Sound.play_use_skill
  757.   end
  758.   #--------------------------------------------------------------------------
  759.   # * Use Item
  760.   #--------------------------------------------------------------------------
  761.   def use_item
  762.     super
  763.     @status_window.refresh
  764.     @item_window.refresh
  765.   end
  766.   #--------------------------------------------------------------------------
  767.   # * Change Actors
  768.   #--------------------------------------------------------------------------
  769.   def on_actor_change
  770.     @command_window.actor = @actor
  771.     @status_window.actor = @actor
  772.     @item_window.actor = @actor
  773.     @command_window.activate
  774.   end
  775. end
  776.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement