#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if !@show
return
else
self.visible = true
if @face_graphic != ""
@face.opacity = 255
end
if $game_system.comic_enabled and @message_event != -1
@comic.opacity = 255
end
if @name != ""
@name_window.visible = true
if $game_system.name_window
@name_window.dummy_window.visible = true
end
end
if @input_number_window != nil
@input_number_window.contents_opacity = 255
end
reset_window
end
if (@contents_showing and $game_system.message_event != -1 and @shake == 0) or $game_system.animated_faces
reset_window(false)
end
if $game_system.shake != 0 # shake the window
if @ascending
if @target_x != self.x
self.x += 1
else
@ascending = false
@target_x = self.x - ($game_system.shake * 2)
end
else
if @target_x != self.x
self.x -= 1
else
@ascending = true
@target_x = self.x + ($game_system.shake * 2)
end
end
end
if @wait > 0
@wait -= 1
if @wait == 0
terminate_message
return
end
end
# If fade in
if @fade_in
self.contents_opacity += 24
if @face_graphic != ""
@face.opacity += 24
end
if $game_system.comic_enabled and @message_event != -1
@comic.opacity += 24
end
if @name != ""
@name_window.visible = true
end
if @input_number_window != nil
@input_number_window.contents_opacity += 24
end
if self.contents_opacity == 255
@fade_in = false
end
return
end
# write the text
if @text != nil and @text != ""
speed = $game_system.write_speed
if $game_system.text_skip
if $game_system.skip_mode == WRITE_FASTER and Input.press?(Input::C)
# the player is holding the action button, write faster
speed /= 3
elsif $game_system.skip_mode == WRITE_ALL and @write_all
# the player pressed the action button, write all the text
while (c = @text.slice!(/./m)) != nil
write_char(c)
end
return
end
end
while @ignore
c = @text.slice!(/./m)
if c != nil
write_char(c)
end
end
if @pause_time > 0
@pause_time -= 1
return
end
if Graphics.frame_count - @count >= speed
if $game_system.sound_effect != ""
Audio.se_play("Audio/SE/" + $game_system.sound_effect, 80, 100)
end
@count = Graphics.frame_count
c = @text.slice!(/./m)
if c != nil
write_char(c)
end
end
return
end
@done = true
# If inputting number
if @input_number_window != nil
@input_number_window.update
# Confirm
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_variables[$game_temp.num_input_variable_id] =
@input_number_window.number
$game_map.need_refresh = true
# Dispose of number input window
@input_number_window.dispose
@input_number_window = nil
terminate_message
end
return
end
if @wait != 0
return
end
# If message is being displayed and contents are all written
if @contents_showing
# if choice
if $game_temp.choice_max > 0
if !@choice_window.active
@choice_window.visible = true
@choice_window.active = true
@choice_window.index = 0
end
@choice_window.update
else
# If choice isn't being displayed, show pause sign
self.pause = true
end
return
end
end
#--------------------------------------------------------------------------
# * Process and write the given character
#--------------------------------------------------------------------------
def write_char(c)
if c == "\000"
# Return to original text
c = "\\"
end
# If \C[n]
if c == "\001"
# Change text color
@text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
# go to next text
return
end
# If \G
if c == "\002"
# Make gold window
if @gold_window == nil
@gold_window = Window_Gold.new
@gold_window.x = 560 - @gold_window.width
if $game_temp.in_battle
@gold_window.y = 192
else
@gold_window.y = self.y >= 128 ? 32 : 384
end
@gold_window.opacity = self.opacity
@gold_window.back_opacity = self.back_opacity
end
# go to next text
return
end
# If \skip
if c == "\003"
# toggle text skipping
#$game_system.text_skip = !$game_system.text_skip
# go to next text
return
end
# If \b
if c == "\004"
# toggle bold
self.contents.font.bold = !self.contents.font.bold
# go to next text
return
end
# If \i
if c == "\005"
# toggle italics
self.contents.font.italic = !self.contents.font.italic
# go to next text
return
end
# If \s
if c == "\006"
# toggle shadow
#$game_system.shadowed_text = !$game_system.shadowed_text
# go to next text
return
end
# If \font
if c == "\007"
# change font
@text.sub!(/\[(.*?)\]/, "")
font = $1.to_s
@font = font
if font == ""
self.contents.font.name = Font.default_name
else
self.contents.font.name = font
end
# go to next text
return
end
# If \p[n]
if c == "\010"
@text.sub!(/\[([0-9]+)\]/, "")
@pause_time = $1.to_i
# go to next text
return
end
# If \w[n]
if c == "\011"
@text.sub!(/\[([0-9]+)\]/, "")
@wait = $1.to_i
# go to next text
return
end
# If \ws[n]
if c == "\013"
@text.sub!(/\[([0-9]+)\]/, "")
$game_system.write_speed = $1.to_i
# go to next text
return
end
# If \oa[n]
if c == "\014"
@text.sub!(/\[([0-9]+)\]/, "")
index = $1.to_i
@text.sub!(" ", "")
item = $data_armors[index]
# draw the icon
icon = RPG::Cache.icon(item.icon_name)
self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
@x += 24
# go to next text
return
end
# If \oi[n]
if c == "\015"
@text.sub!(/\[([0-9]+)\]/, "")
index = $1.to_i
@text.sub!(" ", "")
item = $data_items[index]
# draw the icon
icon = RPG::Cache.icon(item.icon_name)
self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
@x += 24
# go to next text
return
end
# If \os[n]
if c == "\016"
@text.sub!(/\[([0-9]+)\]/, "")
index = $1.to_i
@text.sub!(" ", "")
item = $data_skills[index]
# draw the icon
icon = RPG::Cache.icon(item.icon_name)
self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
@x += 24
# go to next text
return
end
# If \ow[n]
if c == "\017"
@text.sub!(/\[([0-9]+)\]/, "")
index = $1.to_i
@text.sub!(" ", "")
item = $data_weapons[index]
# draw the icon
icon = RPG::Cache.icon(item.icon_name)
self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
@x += 24
# go to next text
return
end
# If \tc
if c == "\020"
# center justify
@text_justification = CENTER
get_x_value
# go to next text
return
end
# If \tl
if c == "\021"
# left justify
@text_justification = LEFT
get_x_value
# go to next text
return
end
# If \tr
if c == "\022"
# right justify
@text_justification = RIGHT
get_x_value
# go to next text
return
end
# If \ignr
if c == "\023"
# set ignore flage
@ignore = true
# go to next text
return
end
# if \c (hex color)
if c == "\026"
# convert hex color to RGB
@text.sub!(/\[([0123456789abcdef]+)\]/, "")
hex_code = $1.to_s
red = ("0x" + hex_code.slice(0..1)).hex
blue = ("0x" + hex_code.slice(2..3)).hex
green = ("0x" + hex_code.slice(4..5)).hex
self.contents.font.color = Color.new(red, blue, green)
return
end
# If new line text
if c == "\n"
# Add 1 to y
if !@ignore
@y += 1
end
if @text != ""
get_x_value
end
@ignore = false
# go to next text
return
end
if @ignore
return
end
# Draw text
line = self.contents.text_size("dj").height
if $game_system.shadowed_text
old_color = self.contents.font.color.clone
self.contents.font.color = $game_system.shadow_color
self.contents.draw_text(6 + @x, line * @y + 2, 40, 32, c)
self.contents.font.color = old_color
end
self.contents.draw_text(4 + @x, line * @y, 40, 32, c)
# Add x to drawn text width
@x += self.contents.text_size(c).width
end
def get_x_value
# text justification - offset for first line
if @text_justification == CENTER
# get the length of the current line
w = self.contents.text_size(@text.split("\n")[0]).width
@x = (self.width - w - 48) / 2
elsif @text_justification == RIGHT
# get the length of the current line
w = self.contents.text_size(@text.split("\n")[0]).width
@x = self.width - w - 48
else # left
if @face_graphic == ""
@x = 0
else
@x = @face_offset
end
end
end
end
#==============================================================================
# ** Window_InputNumber
#------------------------------------------------------------------------------
# This window is for inputting numbers, and is used within the
# message window.
#==============================================================================
class Window_InputNumber < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# digits_max : digit count
#--------------------------------------------------------------------------
def initialize(digits_max)
@digits_max = digits_max
@number = 0
# Calculate cursor width from number width (0-9 equal width and postulate)
dummy_bitmap = Bitmap.new(32, 32)
@cursor_width = dummy_bitmap.text_size("0").width + 8
dummy_bitmap.dispose
super(0, 0, @cursor_width * @digits_max + 32, 64)
self.contents = Bitmap.new(width - 32, height - 32)
if $game_system.font == ""
self.contents.font.name = Font.default_name
else
self.contents.font.name = $game_system.font
end
self.z += 9999
self.opacity = $game_system.opacity
self.back_opacity = $game_system.back_opacity
@index = 0
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if $game_system.font_color.nil?
self.contents.font.color = normal_color
else
self.contents.font.color = $game_system.font_color
end
if $game_system.windowskin != ""
self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
else
self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
end
s = sprintf("%0*d", @digits_max, @number)
for i in 0...@digits_max
# Draw text
if $game_system.shadowed_text
old_color = self.contents.font.color.clone
self.contents.font.color = $game_system.shadow_color
self.contents.draw_text(i * @cursor_width + 6, 2, 32, 32, s[i,1])
self.contents.font.color = old_color
end
self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1])
end
end
end