SHARE
TWEET

Toru Higuruma - Profile Scroll

neutale May 22nd, 2020 1,540 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # ■ Profile Scroll RGSS3 v2.0          MIT License; see git.io/tic
  3. #------------------------------------------------------------------------------
  4. # Supports profiles with more than 3 lines
  5. # (you can use \n for making next line)
  6. # and enables scrolling up and down.
  7. #==============================================================================
  8.  
  9. class Window_Description < Window_Selectable
  10.   #--------------------------------------------------------------------------
  11.   # ● Object initialization
  12.   #--------------------------------------------------------------------------
  13.   def initialize(x, y, width)
  14.     super(x, y, width, window_height)
  15.     self.opacity = 0
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● Window height
  19.   #--------------------------------------------------------------------------
  20.   def window_height
  21.     fitting_height(visible_line_number)
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # ● Number of rows displayed
  25.   #--------------------------------------------------------------------------
  26.   def visible_line_number
  27.     return 2
  28.   end
  29.   #--------------------------------------------------------------------------
  30.   # ● Actor settings
  31.   #--------------------------------------------------------------------------
  32.   def actor=(actor)
  33.     return if @actor == actor
  34.     @actor = actor
  35.     refresh
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● Maximum item
  39.   #--------------------------------------------------------------------------
  40.   def item_max
  41.     @actor ? @actor.description.gsub(/\\n/i, "\r\n").lines.count : 0
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● Refresh
  45.   #--------------------------------------------------------------------------
  46.   def refresh
  47.     create_contents
  48.     draw_description
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● Draw description
  52.   #--------------------------------------------------------------------------
  53.   def draw_description
  54.     draw_text_ex(4, 0, @actor.description.gsub(/\\n/i, "\r\n"))
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ● Update
  58.   #--------------------------------------------------------------------------
  59.   def update
  60.     super
  61.     process_scroll
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● Process scroll
  65.   #--------------------------------------------------------------------------
  66.   def process_scroll
  67.     row = top_row
  68.     row -= 1 if Input.repeat?(:UP)   && row > 0
  69.     row += 1 if Input.repeat?(:DOWN) && row < item_max - visible_line_number
  70.     Sound.play_cursor if row != top_row
  71.     self.top_row = row
  72.   end
  73. end
  74. #------------------------------------------------------------------------------
  75. class Window_Status
  76.   #--------------------------------------------------------------------------
  77.   # ● Release [alias]
  78.   #--------------------------------------------------------------------------
  79.   alias toruic_dispose dispose
  80.   def dispose
  81.     @description_window.dispose unless disposed?
  82.     toruic_dispose
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● Frame update [alias]
  86.   #--------------------------------------------------------------------------
  87.   alias toruic_update update
  88.   def update
  89.     toruic_update
  90.     @description_window.update
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● Draw description [*redefined*]
  94.   #--------------------------------------------------------------------------
  95.   def draw_description(x, y)
  96.     @description_window ||= Window_Description.new(x - 4, y, width - (x - 4))
  97.     @description_window.actor = @actor
  98.   end
  99. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top