#==============================================================================
# ■ Profile Scroll RGSS3 v2.0 MIT License; see git.io/tic
#------------------------------------------------------------------------------
# Supports profiles with more than 3 lines
# (you can use \n for making next line)
# and enables scrolling up and down.
#==============================================================================
class Window_Description < Window_Selectable
#--------------------------------------------------------------------------
# ● Object initialization
#--------------------------------------------------------------------------
def initialize(x, y, width)
super(x, y, width, window_height)
self.opacity = 0
end
#--------------------------------------------------------------------------
# ● Window height
#--------------------------------------------------------------------------
def window_height
fitting_height(visible_line_number)
end
#--------------------------------------------------------------------------
# ● Number of rows displayed
#--------------------------------------------------------------------------
def visible_line_number
return 2
end
#--------------------------------------------------------------------------
# ● Actor settings
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● Maximum item
#--------------------------------------------------------------------------
def item_max
@actor ? @actor.description.gsub(/\\n/i, "\r\n").lines.count : 0
end
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
def refresh
create_contents
draw_description
end
#--------------------------------------------------------------------------
# ● Draw description
#--------------------------------------------------------------------------
def draw_description
draw_text_ex(4, 0, @actor.description.gsub(/\\n/i, "\r\n"))
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
super
process_scroll
end
#--------------------------------------------------------------------------
# ● Process scroll
#--------------------------------------------------------------------------
def process_scroll
row = top_row
row -= 1 if Input.repeat?(:UP) && row > 0
row += 1 if Input.repeat?(:DOWN) && row < item_max - visible_line_number
Sound.play_cursor if row != top_row
self.top_row = row
end
end
#------------------------------------------------------------------------------
class Window_Status
#--------------------------------------------------------------------------
# ● Release [alias]
#--------------------------------------------------------------------------
alias toruic_dispose dispose
def dispose
@description_window.dispose unless disposed?
toruic_dispose
end
#--------------------------------------------------------------------------
# ● Frame update [alias]
#--------------------------------------------------------------------------
alias toruic_update update
def update
toruic_update
@description_window.update
end
#--------------------------------------------------------------------------
# ● Draw description [*redefined*]
#--------------------------------------------------------------------------
def draw_description(x, y)
@description_window ||= Window_Description.new(x - 4, y, width - (x - 4))
@description_window.actor = @actor
end
end