Home > RGSS Script Reference > Window_Help
Window_Help
Inherits from: Window_Base
Description: This window is shown in a variety of situations, such as on the item, skill, and equip screens to show descriptions, and in battle to show actor and enemy names.
class Window_Help < Window_Base
# ------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
end
# ------------------------------------
def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
# ------------------------------------
def set_actor(actor)
if actor != @actor
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
draw_actor_hp(actor, 284, 0)
draw_actor_sp(actor, 460, 0)
@actor = actor
@text = nil
self.visible = true
end
end
# ------------------------------------
def set_enemy(enemy)
text = enemy.name
state_text = make_battler_state_text(enemy, 112, false)
if state_text != ""
text += " " + state_text
end
set_text(text, 1)
end
end
|
Text: The text in the help window.
Align: How the text is aligned within its bounding box (0 = Left-Justify, 1 = Center, 2 = Right-Justify).
Actor: The actor whose name and status will be drawn in the help window.
Initialize
Arguments: None
Local Variables: None
How it Works: The method initializes the window. The x and y coordinates of the window are both set to 0. The width is set to 640, and the height is set to 64. The bitmap is then set.
Set_Text
Arguments:
Text: The text to set in the help window.
Align: The alignment of the text (0 = Left-Justify, 1 = Center, 2 = Right-Justify).
Local Variables: None
How it Works: This method is the substitute for the "Refresh" method in most window classes. It sets the text and alignment of that text in the window. It first clears the contents of the window, then draws the text passed to this method at x coordinate 4 and y coordinate 0. The width of the text's bounding box is the width of the window, minus 40, and the height is 32. The values of @text, @align, and @actor are all set to nil in order to avoid any residual effects. The window is then made to be visible.
Set_Actor
Arguments:
Actor: The actor whose name and status will be shown in the help window.
Local Variables: None
How it Works: This method draws an actor's name and status in the help window. The window's contents are first cleared. Then, the actor's name, status, HP, and SP are drawn, in that order. Note that in this case, the width of the bounding boxes for the HP and SP values are the default value of 144, which is wide enough to allow the maximum values to be shown. The values of @actor and @text are cleared to avoid residual effects.
Set_Enemy
Arguments:
Enemy: The enemy whose name will be shown in the help window.
Local Variables:
Text: The text that will be drawn. This string is assembled by taking the enemy's name and adding any status text, if necessary.
How it Works: This method draws the name of an enemy and its status. First, the value of text is set to the name of the enemy. Then, the state_text = make_battler_state_text(enemy, 112, false) statement appends the enemy's status ailment text to that string. Note that because the final parameter is false, the word "Normal" won't be shown if the enemy has no status ailments. Finally, the set_text(text, 1) call shows the text in the window, centered.
|
|