Advertisement
roninator2

Kid Friendly Basic Quest - Actor Select

Dec 13th, 2024
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.30 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: KFBQ Actor Select Subwindow  ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║   Hide window for selection         ║    09 Mar 2023     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Instructions:                                            ║
  11. # ║                                                          ║
  12. # ║  For KFBQ system hide the Actor_Status menu              ║
  13. # ║  when selecting an actor when using an item or spell     ║
  14. # ╚══════════════════════════════════════════════════════════╝
  15. # ╔══════════════════════════════════════════════════════════╗
  16. # ║ Terms of use:                                            ║
  17. # ║ Free for all uses in RPG Maker - Except nudity           ║
  18. # ╚══════════════════════════════════════════════════════════╝
  19.  
  20. #==============================================================================
  21. # ** Window_MenuStatus
  22. #==============================================================================
  23. class Window_MenuStatus < Window_Selectable
  24.   #--------------------------------------------------------------------------
  25.   # * Public Instance Variables
  26.   #--------------------------------------------------------------------------
  27.   attr_reader   :pending_index            # Pending position (for formation)
  28.   #--------------------------------------------------------------------------
  29.   # * Object Initialization
  30.   #--------------------------------------------------------------------------
  31.   def initialize(x, y)
  32.     super(x, y, window_width, window_height)
  33.     @pending_index = -1
  34.     self.back_opacity = 0
  35.     self.contents_opacity = 255
  36.     refresh
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # * Get Window Width
  40.   #--------------------------------------------------------------------------
  41.   def window_width
  42.     Graphics.width
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # * Get Window Height
  46.   #--------------------------------------------------------------------------
  47.   def window_height
  48.     100
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # * Column Maximum
  52.   #--------------------------------------------------------------------------
  53.   def col_max
  54.     2
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # * Get Number of Items
  58.   #--------------------------------------------------------------------------
  59.   def item_max
  60.     $game_party.members.size
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # * Get Item Height
  64.   #--------------------------------------------------------------------------
  65.   def item_height
  66.     (height - standard_padding * 2)
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # * Get Item Width
  70.   #--------------------------------------------------------------------------
  71.   def item_width
  72.     window_width / col_max - spacing
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # * Item Rect
  76.   #--------------------------------------------------------------------------
  77.   def item_rect(index)
  78.     rect = Rect.new
  79.     rect.width = item_width
  80.     rect.height = item_height
  81.     rect.x = index % col_max * (item_width + spacing)
  82.     rect.y = index / col_max * item_height
  83.     rect
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # * Draw Item
  87.   #--------------------------------------------------------------------------
  88.   def draw_item(index)
  89.     actor = $game_party.members[index]
  90.     enabled = $game_party.battle_members.include?(actor)
  91.     rect = item_rect(index)
  92.     draw_item_background(index)
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # * Draw Background for Item
  96.   #--------------------------------------------------------------------------
  97.   def draw_item_background(index)
  98.     if index == @pending_index
  99.       contents.fill_rect(item_rect(index), pending_color)
  100.     end
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # * Processing When OK Button Is Pressed
  104.   #--------------------------------------------------------------------------
  105.   def process_ok
  106.     super
  107.     $game_party.menu_actor = $game_party.members[index]
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # * Restore Previous Selection Position
  111.   #--------------------------------------------------------------------------
  112.   def select_last
  113.     select($game_party.menu_actor.index || 0)
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # * Pending Colour
  117.   #--------------------------------------------------------------------------
  118.   def pending_color
  119.     windowskin.get_pixel(116, 100)
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # * Set Pending Position (for Formation)
  123.   #--------------------------------------------------------------------------
  124.   def pending_index=(index)
  125.     last_pending_index = @pending_index
  126.     @pending_index = index
  127.     redraw_item(@pending_index)
  128.     redraw_item(last_pending_index)
  129.   end
  130. end
  131.  
  132. #==============================================================================
  133. # ** Window_MenuActor
  134. #==============================================================================
  135. class Window_MenuActor < Window_MenuStatus
  136.   #--------------------------------------------------------------------------
  137.   # * Object Initialization
  138.   #--------------------------------------------------------------------------
  139.   def initialize
  140.     super(0, Graphics.height - 100)
  141.     self.visible = false
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # * Processing When OK Button Is Pressed
  145.   #--------------------------------------------------------------------------
  146.   def process_ok
  147.     $game_party.target_actor = $game_party.members[index] unless @cursor_all
  148.     call_ok_handler
  149.     @spell_count_window.refresh if @spell_count_window
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # * Processing When OK Button Is Pressed
  153.   #--------------------------------------------------------------------------
  154.   def spell_count=(window)
  155.     @spell_count_window = window
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # * Restore Previous Selection Position
  159.   #--------------------------------------------------------------------------
  160.   def select_last
  161.     select($game_party.target_actor.index || 0)
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * Set Position of Cursor for Item
  165.   #--------------------------------------------------------------------------
  166.   def select_for_item(item)
  167.     @cursor_fix = item.for_user?
  168.     @cursor_all = item.for_all?
  169.     if @cursor_fix
  170.       select($game_party.menu_actor.index)
  171.     elsif @cursor_all
  172.       select(0)
  173.     else
  174.       select_last
  175.     end
  176.   end
  177. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement