Information:
I created an extended victory screen why because it looks more nicer
Details:
Author: Cell (Conmaster3)
Screenshot:
[Show/Hide] 3 shots



Demo:
Not needed
Extra information:
- I created this script by adding some stuff
- any questions and suggestions are welcome
Installation:
- Just place above main
Credits:
- Cell (Conmaster3)
The script:
[Show/Hide] the script
CODE
# Author : Cell
# How to use:
# Just place above main
#------------------------------------------------------------------------------
#==============================================================================
# ** Window_Gold_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Gold_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
MAX_LINE = 1 # Maximum number of lines
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(272, 0, 272, 60)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # WIndow opening flag
@closing = false # Window closing flag
@text = nil # Remaining text to be displayed
@contents_x = 0 # X coordinate for drawing next character
@contents_y = 0 # Y coordinate for drawing next character
@line_count = 0 # Line count drawn up until now
@wait_count = 0 # Wait count
@background = 0 # Background type
@position = 2 # Display position
@show_fast = false # Fast forward flag
@line_show_fast = false # Fast forward by line flag
@pause_skip = false # Input standby omission flag
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_show_fast
unless @opening or @closing # Window is not opening or closing
if @wait_count > 0 # Waiting within text
@wait_count -= 1
elsif self.pause # Waiting for text advancement
input_pause
elsif @text != nil # More text exists
update_message # Update message
elsif continue? # If continuing
start_message # Start message
open # Open window
$game_message.visible = true
else # If not continuing
close # Close window
$game_message.visible = @closing
end
end
end
#--------------------------------------------------------------------------
# * Update Fast Forward Flag
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C) and @wait_count < 2
@show_fast = true
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# * Determine if the Next Message Should be Displayed Continuously
#--------------------------------------------------------------------------
def continue?
return true if $game_message.num_input_variable_id > 0
return false if $game_message.texts.empty?
if self.openness > 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# * Start Message
#--------------------------------------------------------------------------
def start_message
@text = ""
for i in 0...$game_message.texts.size
@text += " " if i >= $game_message.choice_start
@text += $game_message.texts[i].clone + "\x00"
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty?
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# * New Line
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty?
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# * Convert Special Characters
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\\\/) { "\\" }
end
#--------------------------------------------------------------------------
# * Set Window Background and Position
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # Normal window
self.opacity = 255
else # Dim Background and Make it Transparent
self.opacity = 0
end
case @position
when 0 # Top
self.y = 0
@gold_window.y = 360
when 1 # Middle
self.y = 144
@gold_window.y = 0
when 2 # Bottom
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# * End Message
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# * Update Message
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # Get next text character
case c
when nil # There is no text that must be drawn
finish_message # Finish update
break
when "\x00" # New line
new_line
if @line_count >= MAX_LINE # If line count is maximum
unless @text.empty? # If there is more
self.pause = true # Insert number input
break
end
end
when "\x01" # \C[n] (text character color change)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x03" # \. (wait 1/4 second)
@wait_count = 15
break
when "\x04" # \| (wait 1 second)
@wait_count = 60
break
when "\x05" # \! (Wait for input)
self.pause = true
break
when "\x06" # \> (Fast display ON)
@line_show_fast = true
when "\x07" # \< (Fast display OFF)
@line_show_fast = false
when "\x08" # \^ (No wait for input)
@pause_skip = true
else # Normal text character
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# * End Message Update
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max > 0
start_choice
elsif $game_message.num_input_variable_id > 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# * Start Choices
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# * Text Advancement Input
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= MAX_LINE
else
terminate_message
end
end
end
end
#==============================================================================
# ** Window_BattleMessage
#------------------------------------------------------------------------------
# Message window displayed during battle. In addition to the normal message
# window functions, it also has a battle progress narration function.
#==============================================================================
class Window_ExtendedGoldMessage < Window_Gold_Message
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super
self.openness = 255
@lines = []
refresh
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Open Window (disabled)
#--------------------------------------------------------------------------
def open
end
#--------------------------------------------------------------------------
# * Close Window (disabled)
#--------------------------------------------------------------------------
def close
end
#--------------------------------------------------------------------------
# * Set Window Background and Position (disabled)
#--------------------------------------------------------------------------
def reset_window
end
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
def clear
@lines.clear
refresh
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def line_number
return @lines.size
end
#--------------------------------------------------------------------------
# * Go Back One Line
#--------------------------------------------------------------------------
def back_one
@lines.pop
refresh
end
#--------------------------------------------------------------------------
# * Return to Designated Line
# line_number : Line number
#--------------------------------------------------------------------------
def back_to(line_number)
while @lines.size > line_number
@lines.pop
end
refresh
end
#--------------------------------------------------------------------------
# * Add Text
# text : Text to be added
#--------------------------------------------------------------------------
def add_instant_text(text)
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Replace Text
# text : Text to be replaced
# Replaces the last line with different text.
#--------------------------------------------------------------------------
def replace_instant_text(text)
@lines.pop
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Get Text From Last Line
#--------------------------------------------------------------------------
def last_instant_text
return @lines[-1]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@lines.size
draw_line(i)
end
end
#--------------------------------------------------------------------------
# * Draw Line
# index : Line number
#--------------------------------------------------------------------------
def draw_line(index)
rect = Rect.new(0, 0, 0, 0)
rect.x += 4
rect.y += index * WLH
rect.width = contents.width - 8
rect.height = WLH
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.draw_text(rect, @lines[index])
end
end
#==============================================================================
# ** Window_Exp_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Exp_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
MAX_LINE = 1 # Maximum number of lines
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 272, 60)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # WIndow opening flag
@closing = false # Window closing flag
@text = nil # Remaining text to be displayed
@contents_x = 0 # X coordinate for drawing next character
@contents_y = 0 # Y coordinate for drawing next character
@line_count = 0 # Line count drawn up until now
@wait_count = 0 # Wait count
@background = 0 # Background type
@position = 2 # Display position
@show_fast = false # Fast forward flag
@line_show_fast = false # Fast forward by line flag
@pause_skip = false # Input standby omission flag
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_show_fast
unless @opening or @closing # Window is not opening or closing
if @wait_count > 0 # Waiting within text
@wait_count -= 1
elsif self.pause # Waiting for text advancement
input_pause
elsif @text != nil # More text exists
update_message # Update message
elsif continue? # If continuing
start_message # Start message
open # Open window
$game_message.visible = true
else # If not continuing
close # Close window
$game_message.visible = @closing
end
end
end
#--------------------------------------------------------------------------
# * Update Fast Forward Flag
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C) and @wait_count < 2
@show_fast = true
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# * Determine if the Next Message Should be Displayed Continuously
#--------------------------------------------------------------------------
def continue?
return true if $game_message.num_input_variable_id > 0
return false if $game_message.texts.empty?
if self.openness > 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# * Start Message
#--------------------------------------------------------------------------
def start_message
@text = ""
for i in 0...$game_message.texts.size
@text += " " if i >= $game_message.choice_start
@text += $game_message.texts[i].clone + "\x00"
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty?
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# * New Line
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty?
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# * Convert Special Characters
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\\\/) { "\\" }
end
#--------------------------------------------------------------------------
# * Set Window Background and Position
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # Normal window
self.opacity = 255
else # Dim Background and Make it Transparent
self.opacity = 0
end
case @position
when 0 # Top
self.y = 0
@gold_window.y = 360
when 1 # Middle
self.y = 144
@gold_window.y = 0
when 2 # Bottom
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# * End Message
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# * Update Message
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # Get next text character
case c
when nil # There is no text that must be drawn
finish_message # Finish update
break
when "\x00" # New line
new_line
if @line_count >= MAX_LINE # If line count is maximum
unless @text.empty? # If there is more
self.pause = true # Insert number input
break
end
end
when "\x01" # \C[n] (text character color change)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x03" # \. (wait 1/4 second)
@wait_count = 15
break
when "\x04" # \| (wait 1 second)
@wait_count = 60
break
when "\x05" # \! (Wait for input)
self.pause = true
break
when "\x06" # \> (Fast display ON)
@line_show_fast = true
when "\x07" # \< (Fast display OFF)
@line_show_fast = false
when "\x08" # \^ (No wait for input)
@pause_skip = true
else # Normal text character
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# * End Message Update
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max > 0
start_choice
elsif $game_message.num_input_variable_id > 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# * Start Choices
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# * Text Advancement Input
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= MAX_LINE
else
terminate_message
end
end
end
end
#==============================================================================
# ** Window_BattleMessage
#------------------------------------------------------------------------------
# Message window displayed during battle. In addition to the normal message
# window functions, it also has a battle progress narration function.
#==============================================================================
class Window_ExtendedExpMessage < Window_Exp_Message
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super
self.openness = 255
@lines = []
refresh
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Open Window (disabled)
#--------------------------------------------------------------------------
def open
end
#--------------------------------------------------------------------------
# * Close Window (disabled)
#--------------------------------------------------------------------------
def close
end
#--------------------------------------------------------------------------
# * Set Window Background and Position (disabled)
#--------------------------------------------------------------------------
def reset_window
end
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
def clear
@lines.clear
refresh
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def line_number
return @lines.size
end
#--------------------------------------------------------------------------
# * Go Back One Line
#--------------------------------------------------------------------------
def back_one
@lines.pop
refresh
end
#--------------------------------------------------------------------------
# * Return to Designated Line
# line_number : Line number
#--------------------------------------------------------------------------
def back_to(line_number)
while @lines.size > line_number
@lines.pop
end
refresh
end
#--------------------------------------------------------------------------
# * Add Text
# text : Text to be added
#--------------------------------------------------------------------------
def add_instant_text(text)
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Replace Text
# text : Text to be replaced
# Replaces the last line with different text.
#--------------------------------------------------------------------------
def replace_instant_text(text)
@lines.pop
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Get Text From Last Line
#--------------------------------------------------------------------------
def last_instant_text
return @lines[-1]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@lines.size
draw_line(i)
end
end
#--------------------------------------------------------------------------
# * Draw Line
# index : Line number
#--------------------------------------------------------------------------
def draw_line(index)
rect = Rect.new(0, 0, 0, 0)
rect.x += 4
rect.y += index * WLH
rect.width = contents.width - 8
rect.height = WLH
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.draw_text(rect, @lines[index])
end
end
#==============================================================================
# ** Window_Item_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Item_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
MAX_LINE = 15 # Maximum number of lines
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 60, 544, 356)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # WIndow opening flag
@closing = false # Window closing flag
@text = nil # Remaining text to be displayed
@contents_x = 0 # X coordinate for drawing next character
@contents_y = 0 # Y coordinate for drawing next character
@line_count = 0 # Line count drawn up until now
@wait_count = 0 # Wait count
@background = 0 # Background type
@position = 2 # Display position
@show_fast = false # Fast forward flag
@line_show_fast = false # Fast forward by line flag
@pause_skip = false # Input standby omission flag
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_show_fast
unless @opening or @closing # Window is not opening or closing
if @wait_count > 0 # Waiting within text
@wait_count -= 1
elsif self.pause # Waiting for text advancement
input_pause
elsif @text != nil # More text exists
update_message # Update message
elsif continue? # If continuing
start_message # Start message
open # Open window
$game_message.visible = true
else # If not continuing
close # Close window
$game_message.visible = @closing
end
end
end
#--------------------------------------------------------------------------
# * Update Fast Forward Flag
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C) and @wait_count < 2
@show_fast = true
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# * Determine if the Next Message Should be Displayed Continuously
#--------------------------------------------------------------------------
def continue?
return true if $game_message.num_input_variable_id > 0
return false if $game_message.texts.empty?
if self.openness > 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# * Start Message
#--------------------------------------------------------------------------
def start_message
@text = ""
for i in 0...$game_message.texts.size
@text += " " if i >= $game_message.choice_start
@text += $game_message.texts[i].clone + "\x00"
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty?
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# * New Line
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty?
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# * Convert Special Characters
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\\\/) { "\\" }
end
#--------------------------------------------------------------------------
# * Set Window Background and Position
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # Normal window
self.opacity = 255
else # Dim Background and Make it Transparent
self.opacity = 0
end
case @position
when 0 # Top
self.y = 0
@gold_window.y = 360
when 1 # Middle
self.y = 144
@gold_window.y = 0
when 2 # Bottom
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# * End Message
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# * Update Message
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # Get next text character
case c
when nil # There is no text that must be drawn
finish_message # Finish update
break
when "\x00" # New line
new_line
if @line_count >= MAX_LINE # If line count is maximum
unless @text.empty? # If there is more
self.pause = true # Insert number input
break
end
end
when "\x01" # \C[n] (text character color change)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x03" # \. (wait 1/4 second)
@wait_count = 15
break
when "\x04" # \| (wait 1 second)
@wait_count = 60
break
when "\x05" # \! (Wait for input)
self.pause = true
break
when "\x06" # \> (Fast display ON)
@line_show_fast = true
when "\x07" # \< (Fast display OFF)
@line_show_fast = false
when "\x08" # \^ (No wait for input)
@pause_skip = true
else # Normal text character
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# * End Message Update
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max > 0
start_choice
elsif $game_message.num_input_variable_id > 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# * Start Choices
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# * Text Advancement Input
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= MAX_LINE
else
terminate_message
end
end
end
end
#==============================================================================
# ** Window_BattleMessage
#------------------------------------------------------------------------------
# Message window displayed during battle. In addition to the normal message
# window functions, it also has a battle progress narration function.
#==============================================================================
class Window_ExtendedItemMessage < Window_Item_Message
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super
self.openness = 255
@lines = []
refresh
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Open Window (disabled)
#--------------------------------------------------------------------------
def open
end
#--------------------------------------------------------------------------
# * Close Window (disabled)
#--------------------------------------------------------------------------
def close
end
#--------------------------------------------------------------------------
# * Set Window Background and Position (disabled)
#--------------------------------------------------------------------------
def reset_window
end
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
def clear
@lines.clear
refresh
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def line_number
return @lines.size
end
#--------------------------------------------------------------------------
# * Go Back One Line
#--------------------------------------------------------------------------
def back_one
@lines.pop
refresh
end
#--------------------------------------------------------------------------
# * Return to Designated Line
# line_number : Line number
#--------------------------------------------------------------------------
def back_to(line_number)
while @lines.size > line_number
@lines.pop
end
refresh
end
#--------------------------------------------------------------------------
# * Add Text
# text : Text to be added
#--------------------------------------------------------------------------
def add_instant_text(text)
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Replace Text
# text : Text to be replaced
# Replaces the last line with different text.
#--------------------------------------------------------------------------
def replace_instant_text(text)
@lines.pop
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Get Text From Last Line
#--------------------------------------------------------------------------
def last_instant_text
return @lines[-1]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@lines.size
draw_line(i)
end
end
#--------------------------------------------------------------------------
# * Draw Line
# index : Line number
#--------------------------------------------------------------------------
def draw_line(index)
rect = Rect.new(0, 0, 0, 0)
rect.x += 4
rect.y += index * WLH
rect.width = contents.width - 8
rect.height = WLH
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.draw_text(rect, @lines[index])
end
end
#==============================================================================
# ** Window_Lvl_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Lvl_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
MAX_LINE = 12 # Maximum number of lines
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 60, 544, 356)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # WIndow opening flag
@closing = false # Window closing flag
@text = nil # Remaining text to be displayed
@contents_x = 0 # X coordinate for drawing next character
@contents_y = 0 # Y coordinate for drawing next character
@line_count = 0 # Line count drawn up until now
@wait_count = 0 # Wait count
@background = 0 # Background type
@position = 2 # Display position
@show_fast = false # Fast forward flag
@line_show_fast = false # Fast forward by line flag
@pause_skip = false # Input standby omission flag
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_show_fast
unless @opening or @closing # Window is not opening or closing
if @wait_count > 0 # Waiting within text
@wait_count -= 1
elsif self.pause # Waiting for text advancement
input_pause
elsif @text != nil # More text exists
update_message # Update message
elsif continue? # If continuing
start_message # Start message
open # Open window
$game_message.visible = true
else # If not continuing
close # Close window
$game_message.visible = @closing
end
end
end
#--------------------------------------------------------------------------
# * Update Fast Forward Flag
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C) and @wait_count < 2
@show_fast = true
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# * Determine if the Next Message Should be Displayed Continuously
#--------------------------------------------------------------------------
def continue?
return true if $game_message.num_input_variable_id > 0
return false if $game_message.texts.empty?
if self.openness > 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# * Start Message
#--------------------------------------------------------------------------
def start_message
@text = ""
for i in 0...$game_message.texts.size
@text += " " if i >= $game_message.choice_start
@text += $game_message.texts[i].clone + "\x00"
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty?
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# * New Line
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty?
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# * Convert Special Characters
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\\\/) { "\\" }
end
#--------------------------------------------------------------------------
# * Set Window Background and Position
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # Normal window
self.opacity = 255
else # Dim Background and Make it Transparent
self.opacity = 0
end
case @position
when 0 # Top
self.y = 0
@gold_window.y = 360
when 1 # Middle
self.y = 144
@gold_window.y = 0
when 2 # Bottom
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# * End Message
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# * Update Message
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # Get next text character
case c
when nil # There is no text that must be drawn
finish_message # Finish update
break
when "\x00" # New line
new_line
if @line_count >= MAX_LINE # If line count is maximum
unless @text.empty? # If there is more
self.pause = true # Insert number input
break
end
end
when "\x01" # \C[n] (text character color change)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x03" # \. (wait 1/4 second)
@wait_count = 15
break
when "\x04" # \| (wait 1 second)
@wait_count = 60
break
when "\x05" # \! (Wait for input)
self.pause = true
break
when "\x06" # \> (Fast display ON)
@line_show_fast = true
when "\x07" # \< (Fast display OFF)
@line_show_fast = false
when "\x08" # \^ (No wait for input)
@pause_skip = true
else # Normal text character
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# * End Message Update
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max > 0
start_choice
elsif $game_message.num_input_variable_id > 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# * Start Choices
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# * Text Advancement Input
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= MAX_LINE
else
terminate_message
end
end
end
end
#==============================================================================
# ** Window_BattleMessage
#------------------------------------------------------------------------------
# Message window displayed during battle. In addition to the normal message
# window functions, it also has a battle progress narration function.
#==============================================================================
class Window_ExtendedLvlMessage < Window_Lvl_Message
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super
self.openness = 255
@lines = []
refresh
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Open Window (disabled)
#--------------------------------------------------------------------------
def open
end
#--------------------------------------------------------------------------
# * Close Window (disabled)
#--------------------------------------------------------------------------
def close
end
#--------------------------------------------------------------------------
# * Set Window Background and Position (disabled)
#--------------------------------------------------------------------------
def reset_window
end
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
def clear
@lines.clear
refresh
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def line_number
return @lines.size
end
#--------------------------------------------------------------------------
# * Go Back One Line
#--------------------------------------------------------------------------
def back_one
@lines.pop
refresh
end
#--------------------------------------------------------------------------
# * Return to Designated Line
# line_number : Line number
#--------------------------------------------------------------------------
def back_to(line_number)
while @lines.size > line_number
@lines.pop
end
refresh
end
#--------------------------------------------------------------------------
# * Add Text
# text : Text to be added
#--------------------------------------------------------------------------
def add_instant_text(text)
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Replace Text
# text : Text to be replaced
# Replaces the last line with different text.
#--------------------------------------------------------------------------
def replace_instant_text(text)
@lines.pop
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Get Text From Last Line
#--------------------------------------------------------------------------
def last_instant_text
return @lines[-1]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@lines.size
draw_line(i)
end
end
#--------------------------------------------------------------------------
# * Draw Line
# index : Line number
#--------------------------------------------------------------------------
def draw_line(index)
rect = Rect.new(0, 0, 0, 0)
rect.x += 4
rect.y += index * WLH
rect.width = contents.width - 8
rect.height = WLH
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.draw_text(rect, @lines[index])
end
end
#==============================================================================
# ** Vocab Customizes for the extended victory screen
#------------------------------------------------------------------------------
# This module defines terms and messages. It defines some data as constant
# variables. Terms in the database are obtained from $data_system.
#==============================================================================
module Vocab
# Display when there are multiple members
PartyName = ""
# Battle Ending Messages
Victory = "Victorious!"
Defeat = "You are defeated."
ObtainExp = "EXP: %s!"
ObtainGold = "Gold: %s!"
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Battle
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
@victory_gold = Window_ExtendedGoldMessage.new
@victory_exp = Window_ExtendedExpMessage.new
@victory_item = Window_ExtendedItemMessage.new
@victory_lvl = Window_ExtendedLvlMessage.new
@victory_gold.visible = false
@victory_exp.visible = false
@victory_item.visible = false
@victory_lvl.visible = false
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
@victory_gold.dispose
@victory_exp.dispose
@victory_item.dispose
@victory_lvl.dispose
end
#--------------------------------------------------------------------------
# * Basic Update Processing
# main : Call from main update method
#--------------------------------------------------------------------------
def update_basic_gold(main = false)
Graphics.update unless main # Update game screen
Input.update unless main # Update input information
$game_system.update # Update timer
$game_troop.update # Update enemy group
@spriteset.update # Update sprite set
@victory_gold.update
end
def update_basic_exp(main = false)
Graphics.update unless main # Update game screen
Input.update unless main # Update input information
$game_system.update # Update timer
$game_troop.update # Update enemy group
@spriteset.update # Update sprite set
@victory_exp.update
end
def update_basic_item(main = false)
Graphics.update unless main # Update game screen
Input.update unless main # Update input information
$game_system.update # Update timer
$game_troop.update # Update enemy group
@spriteset.update # Update sprite set
@victory_item.update
end
def update_basic_lvl(main = false)
Graphics.update unless main # Update game screen
Input.update unless main # Update input information
$game_system.update # Update timer
$game_troop.update # Update enemy group
@spriteset.update # Update sprite set
@victory_lvl.update
end
#--------------------------------------------------------------------------
# * Wait Until Message Display has Finished
#--------------------------------------------------------------------------
def wait_for_gold
@victory_gold.update
while $game_message.visible
update_basic_gold
end
end
def wait_for_exp
@victory_exp.update
while $game_message.visible
update_basic_exp
end
end
def wait_for_item
@victory_item.update
while $game_message.visible
update_basic_item
end
end
def wait_for_lvl
@victory_lvl.update
while $game_message.visible
update_basic_lvl
end
end
#--------------------------------------------------------------------------
# * Victory Processing
#--------------------------------------------------------------------------
def process_victory
@info_viewport.visible = false
@message_window.visible = true
RPG::BGM.stop
$game_system.battle_end_me.play
unless $BTEST
$game_temp.map_bgm.play
$game_temp.map_bgs.play
end
display_victory
display_exp
display_gold
display_level_up
display_drop_items
battle_end(0)
end
#--------------------------------------------------------------------------
# * Display Gained Experience and Gold
#--------------------------------------------------------------------------
def display_victory
text = sprintf(Vocab::Victory, $game_party.name)
$game_message.texts.push('\|' + text)
wait_for_message
@message_window.visible = false
end
def display_exp
@victory_gold.visible = true
@victory_exp.visible = true
@victory_lvl.visible = true
exp = $game_troop.exp_total
if exp > 0
text = sprintf(Vocab::ObtainExp, exp)
$game_message.texts.push('\.' + text)
end
wait_for_exp
end
def display_gold
gold = $game_troop.gold_total
$game_party.gain_gold(gold)
if gold > 0
text = sprintf(Vocab::ObtainGold, gold, Vocab::gold)
$game_message.texts.push('\.' + text)
end
wait_for_gold
end
#--------------------------------------------------------------------------
# * Display Gained Drop Items
#--------------------------------------------------------------------------
def display_drop_items
@victory_item.visible = true
drop_items = $game_troop.make_drop_items
for item in drop_items
$game_party.gain_item(item, 1)
text = sprintf(Vocab::ObtainItem, item.name)
$game_message.texts.push(text)
end
wait_for_item
end
#--------------------------------------------------------------------------
# * Display Level Up
#--------------------------------------------------------------------------
def display_level_up
exp = $game_troop.exp_total
for actor in $game_party.existing_members
last_level = actor.level
last_skills = actor.skills
actor.gain_exp(exp, true)
end
wait_for_lvl
@victory_lvl.visible = false
end
end
# How to use:
# Just place above main
#------------------------------------------------------------------------------
#==============================================================================
# ** Window_Gold_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Gold_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
MAX_LINE = 1 # Maximum number of lines
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(272, 0, 272, 60)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # WIndow opening flag
@closing = false # Window closing flag
@text = nil # Remaining text to be displayed
@contents_x = 0 # X coordinate for drawing next character
@contents_y = 0 # Y coordinate for drawing next character
@line_count = 0 # Line count drawn up until now
@wait_count = 0 # Wait count
@background = 0 # Background type
@position = 2 # Display position
@show_fast = false # Fast forward flag
@line_show_fast = false # Fast forward by line flag
@pause_skip = false # Input standby omission flag
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_show_fast
unless @opening or @closing # Window is not opening or closing
if @wait_count > 0 # Waiting within text
@wait_count -= 1
elsif self.pause # Waiting for text advancement
input_pause
elsif @text != nil # More text exists
update_message # Update message
elsif continue? # If continuing
start_message # Start message
open # Open window
$game_message.visible = true
else # If not continuing
close # Close window
$game_message.visible = @closing
end
end
end
#--------------------------------------------------------------------------
# * Update Fast Forward Flag
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C) and @wait_count < 2
@show_fast = true
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# * Determine if the Next Message Should be Displayed Continuously
#--------------------------------------------------------------------------
def continue?
return true if $game_message.num_input_variable_id > 0
return false if $game_message.texts.empty?
if self.openness > 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# * Start Message
#--------------------------------------------------------------------------
def start_message
@text = ""
for i in 0...$game_message.texts.size
@text += " " if i >= $game_message.choice_start
@text += $game_message.texts[i].clone + "\x00"
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty?
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# * New Line
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty?
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# * Convert Special Characters
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\\\/) { "\\" }
end
#--------------------------------------------------------------------------
# * Set Window Background and Position
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # Normal window
self.opacity = 255
else # Dim Background and Make it Transparent
self.opacity = 0
end
case @position
when 0 # Top
self.y = 0
@gold_window.y = 360
when 1 # Middle
self.y = 144
@gold_window.y = 0
when 2 # Bottom
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# * End Message
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# * Update Message
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # Get next text character
case c
when nil # There is no text that must be drawn
finish_message # Finish update
break
when "\x00" # New line
new_line
if @line_count >= MAX_LINE # If line count is maximum
unless @text.empty? # If there is more
self.pause = true # Insert number input
break
end
end
when "\x01" # \C[n] (text character color change)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x03" # \. (wait 1/4 second)
@wait_count = 15
break
when "\x04" # \| (wait 1 second)
@wait_count = 60
break
when "\x05" # \! (Wait for input)
self.pause = true
break
when "\x06" # \> (Fast display ON)
@line_show_fast = true
when "\x07" # \< (Fast display OFF)
@line_show_fast = false
when "\x08" # \^ (No wait for input)
@pause_skip = true
else # Normal text character
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# * End Message Update
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max > 0
start_choice
elsif $game_message.num_input_variable_id > 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# * Start Choices
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# * Text Advancement Input
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= MAX_LINE
else
terminate_message
end
end
end
end
#==============================================================================
# ** Window_BattleMessage
#------------------------------------------------------------------------------
# Message window displayed during battle. In addition to the normal message
# window functions, it also has a battle progress narration function.
#==============================================================================
class Window_ExtendedGoldMessage < Window_Gold_Message
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super
self.openness = 255
@lines = []
refresh
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Open Window (disabled)
#--------------------------------------------------------------------------
def open
end
#--------------------------------------------------------------------------
# * Close Window (disabled)
#--------------------------------------------------------------------------
def close
end
#--------------------------------------------------------------------------
# * Set Window Background and Position (disabled)
#--------------------------------------------------------------------------
def reset_window
end
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
def clear
@lines.clear
refresh
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def line_number
return @lines.size
end
#--------------------------------------------------------------------------
# * Go Back One Line
#--------------------------------------------------------------------------
def back_one
@lines.pop
refresh
end
#--------------------------------------------------------------------------
# * Return to Designated Line
# line_number : Line number
#--------------------------------------------------------------------------
def back_to(line_number)
while @lines.size > line_number
@lines.pop
end
refresh
end
#--------------------------------------------------------------------------
# * Add Text
# text : Text to be added
#--------------------------------------------------------------------------
def add_instant_text(text)
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Replace Text
# text : Text to be replaced
# Replaces the last line with different text.
#--------------------------------------------------------------------------
def replace_instant_text(text)
@lines.pop
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Get Text From Last Line
#--------------------------------------------------------------------------
def last_instant_text
return @lines[-1]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@lines.size
draw_line(i)
end
end
#--------------------------------------------------------------------------
# * Draw Line
# index : Line number
#--------------------------------------------------------------------------
def draw_line(index)
rect = Rect.new(0, 0, 0, 0)
rect.x += 4
rect.y += index * WLH
rect.width = contents.width - 8
rect.height = WLH
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.draw_text(rect, @lines[index])
end
end
#==============================================================================
# ** Window_Exp_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Exp_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
MAX_LINE = 1 # Maximum number of lines
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 272, 60)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # WIndow opening flag
@closing = false # Window closing flag
@text = nil # Remaining text to be displayed
@contents_x = 0 # X coordinate for drawing next character
@contents_y = 0 # Y coordinate for drawing next character
@line_count = 0 # Line count drawn up until now
@wait_count = 0 # Wait count
@background = 0 # Background type
@position = 2 # Display position
@show_fast = false # Fast forward flag
@line_show_fast = false # Fast forward by line flag
@pause_skip = false # Input standby omission flag
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_show_fast
unless @opening or @closing # Window is not opening or closing
if @wait_count > 0 # Waiting within text
@wait_count -= 1
elsif self.pause # Waiting for text advancement
input_pause
elsif @text != nil # More text exists
update_message # Update message
elsif continue? # If continuing
start_message # Start message
open # Open window
$game_message.visible = true
else # If not continuing
close # Close window
$game_message.visible = @closing
end
end
end
#--------------------------------------------------------------------------
# * Update Fast Forward Flag
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C) and @wait_count < 2
@show_fast = true
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# * Determine if the Next Message Should be Displayed Continuously
#--------------------------------------------------------------------------
def continue?
return true if $game_message.num_input_variable_id > 0
return false if $game_message.texts.empty?
if self.openness > 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# * Start Message
#--------------------------------------------------------------------------
def start_message
@text = ""
for i in 0...$game_message.texts.size
@text += " " if i >= $game_message.choice_start
@text += $game_message.texts[i].clone + "\x00"
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty?
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# * New Line
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty?
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# * Convert Special Characters
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\\\/) { "\\" }
end
#--------------------------------------------------------------------------
# * Set Window Background and Position
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # Normal window
self.opacity = 255
else # Dim Background and Make it Transparent
self.opacity = 0
end
case @position
when 0 # Top
self.y = 0
@gold_window.y = 360
when 1 # Middle
self.y = 144
@gold_window.y = 0
when 2 # Bottom
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# * End Message
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# * Update Message
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # Get next text character
case c
when nil # There is no text that must be drawn
finish_message # Finish update
break
when "\x00" # New line
new_line
if @line_count >= MAX_LINE # If line count is maximum
unless @text.empty? # If there is more
self.pause = true # Insert number input
break
end
end
when "\x01" # \C[n] (text character color change)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x03" # \. (wait 1/4 second)
@wait_count = 15
break
when "\x04" # \| (wait 1 second)
@wait_count = 60
break
when "\x05" # \! (Wait for input)
self.pause = true
break
when "\x06" # \> (Fast display ON)
@line_show_fast = true
when "\x07" # \< (Fast display OFF)
@line_show_fast = false
when "\x08" # \^ (No wait for input)
@pause_skip = true
else # Normal text character
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# * End Message Update
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max > 0
start_choice
elsif $game_message.num_input_variable_id > 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# * Start Choices
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# * Text Advancement Input
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= MAX_LINE
else
terminate_message
end
end
end
end
#==============================================================================
# ** Window_BattleMessage
#------------------------------------------------------------------------------
# Message window displayed during battle. In addition to the normal message
# window functions, it also has a battle progress narration function.
#==============================================================================
class Window_ExtendedExpMessage < Window_Exp_Message
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super
self.openness = 255
@lines = []
refresh
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Open Window (disabled)
#--------------------------------------------------------------------------
def open
end
#--------------------------------------------------------------------------
# * Close Window (disabled)
#--------------------------------------------------------------------------
def close
end
#--------------------------------------------------------------------------
# * Set Window Background and Position (disabled)
#--------------------------------------------------------------------------
def reset_window
end
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
def clear
@lines.clear
refresh
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def line_number
return @lines.size
end
#--------------------------------------------------------------------------
# * Go Back One Line
#--------------------------------------------------------------------------
def back_one
@lines.pop
refresh
end
#--------------------------------------------------------------------------
# * Return to Designated Line
# line_number : Line number
#--------------------------------------------------------------------------
def back_to(line_number)
while @lines.size > line_number
@lines.pop
end
refresh
end
#--------------------------------------------------------------------------
# * Add Text
# text : Text to be added
#--------------------------------------------------------------------------
def add_instant_text(text)
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Replace Text
# text : Text to be replaced
# Replaces the last line with different text.
#--------------------------------------------------------------------------
def replace_instant_text(text)
@lines.pop
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Get Text From Last Line
#--------------------------------------------------------------------------
def last_instant_text
return @lines[-1]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@lines.size
draw_line(i)
end
end
#--------------------------------------------------------------------------
# * Draw Line
# index : Line number
#--------------------------------------------------------------------------
def draw_line(index)
rect = Rect.new(0, 0, 0, 0)
rect.x += 4
rect.y += index * WLH
rect.width = contents.width - 8
rect.height = WLH
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.draw_text(rect, @lines[index])
end
end
#==============================================================================
# ** Window_Item_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Item_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
MAX_LINE = 15 # Maximum number of lines
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 60, 544, 356)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # WIndow opening flag
@closing = false # Window closing flag
@text = nil # Remaining text to be displayed
@contents_x = 0 # X coordinate for drawing next character
@contents_y = 0 # Y coordinate for drawing next character
@line_count = 0 # Line count drawn up until now
@wait_count = 0 # Wait count
@background = 0 # Background type
@position = 2 # Display position
@show_fast = false # Fast forward flag
@line_show_fast = false # Fast forward by line flag
@pause_skip = false # Input standby omission flag
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_show_fast
unless @opening or @closing # Window is not opening or closing
if @wait_count > 0 # Waiting within text
@wait_count -= 1
elsif self.pause # Waiting for text advancement
input_pause
elsif @text != nil # More text exists
update_message # Update message
elsif continue? # If continuing
start_message # Start message
open # Open window
$game_message.visible = true
else # If not continuing
close # Close window
$game_message.visible = @closing
end
end
end
#--------------------------------------------------------------------------
# * Update Fast Forward Flag
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C) and @wait_count < 2
@show_fast = true
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# * Determine if the Next Message Should be Displayed Continuously
#--------------------------------------------------------------------------
def continue?
return true if $game_message.num_input_variable_id > 0
return false if $game_message.texts.empty?
if self.openness > 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# * Start Message
#--------------------------------------------------------------------------
def start_message
@text = ""
for i in 0...$game_message.texts.size
@text += " " if i >= $game_message.choice_start
@text += $game_message.texts[i].clone + "\x00"
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty?
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# * New Line
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty?
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# * Convert Special Characters
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\\\/) { "\\" }
end
#--------------------------------------------------------------------------
# * Set Window Background and Position
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # Normal window
self.opacity = 255
else # Dim Background and Make it Transparent
self.opacity = 0
end
case @position
when 0 # Top
self.y = 0
@gold_window.y = 360
when 1 # Middle
self.y = 144
@gold_window.y = 0
when 2 # Bottom
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# * End Message
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# * Update Message
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # Get next text character
case c
when nil # There is no text that must be drawn
finish_message # Finish update
break
when "\x00" # New line
new_line
if @line_count >= MAX_LINE # If line count is maximum
unless @text.empty? # If there is more
self.pause = true # Insert number input
break
end
end
when "\x01" # \C[n] (text character color change)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x03" # \. (wait 1/4 second)
@wait_count = 15
break
when "\x04" # \| (wait 1 second)
@wait_count = 60
break
when "\x05" # \! (Wait for input)
self.pause = true
break
when "\x06" # \> (Fast display ON)
@line_show_fast = true
when "\x07" # \< (Fast display OFF)
@line_show_fast = false
when "\x08" # \^ (No wait for input)
@pause_skip = true
else # Normal text character
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# * End Message Update
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max > 0
start_choice
elsif $game_message.num_input_variable_id > 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# * Start Choices
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# * Text Advancement Input
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= MAX_LINE
else
terminate_message
end
end
end
end
#==============================================================================
# ** Window_BattleMessage
#------------------------------------------------------------------------------
# Message window displayed during battle. In addition to the normal message
# window functions, it also has a battle progress narration function.
#==============================================================================
class Window_ExtendedItemMessage < Window_Item_Message
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super
self.openness = 255
@lines = []
refresh
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Open Window (disabled)
#--------------------------------------------------------------------------
def open
end
#--------------------------------------------------------------------------
# * Close Window (disabled)
#--------------------------------------------------------------------------
def close
end
#--------------------------------------------------------------------------
# * Set Window Background and Position (disabled)
#--------------------------------------------------------------------------
def reset_window
end
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
def clear
@lines.clear
refresh
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def line_number
return @lines.size
end
#--------------------------------------------------------------------------
# * Go Back One Line
#--------------------------------------------------------------------------
def back_one
@lines.pop
refresh
end
#--------------------------------------------------------------------------
# * Return to Designated Line
# line_number : Line number
#--------------------------------------------------------------------------
def back_to(line_number)
while @lines.size > line_number
@lines.pop
end
refresh
end
#--------------------------------------------------------------------------
# * Add Text
# text : Text to be added
#--------------------------------------------------------------------------
def add_instant_text(text)
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Replace Text
# text : Text to be replaced
# Replaces the last line with different text.
#--------------------------------------------------------------------------
def replace_instant_text(text)
@lines.pop
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Get Text From Last Line
#--------------------------------------------------------------------------
def last_instant_text
return @lines[-1]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@lines.size
draw_line(i)
end
end
#--------------------------------------------------------------------------
# * Draw Line
# index : Line number
#--------------------------------------------------------------------------
def draw_line(index)
rect = Rect.new(0, 0, 0, 0)
rect.x += 4
rect.y += index * WLH
rect.width = contents.width - 8
rect.height = WLH
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.draw_text(rect, @lines[index])
end
end
#==============================================================================
# ** Window_Lvl_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Lvl_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
MAX_LINE = 12 # Maximum number of lines
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 60, 544, 356)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # WIndow opening flag
@closing = false # Window closing flag
@text = nil # Remaining text to be displayed
@contents_x = 0 # X coordinate for drawing next character
@contents_y = 0 # Y coordinate for drawing next character
@line_count = 0 # Line count drawn up until now
@wait_count = 0 # Wait count
@background = 0 # Background type
@position = 2 # Display position
@show_fast = false # Fast forward flag
@line_show_fast = false # Fast forward by line flag
@pause_skip = false # Input standby omission flag
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_show_fast
unless @opening or @closing # Window is not opening or closing
if @wait_count > 0 # Waiting within text
@wait_count -= 1
elsif self.pause # Waiting for text advancement
input_pause
elsif @text != nil # More text exists
update_message # Update message
elsif continue? # If continuing
start_message # Start message
open # Open window
$game_message.visible = true
else # If not continuing
close # Close window
$game_message.visible = @closing
end
end
end
#--------------------------------------------------------------------------
# * Update Fast Forward Flag
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C) and @wait_count < 2
@show_fast = true
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# * Determine if the Next Message Should be Displayed Continuously
#--------------------------------------------------------------------------
def continue?
return true if $game_message.num_input_variable_id > 0
return false if $game_message.texts.empty?
if self.openness > 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# * Start Message
#--------------------------------------------------------------------------
def start_message
@text = ""
for i in 0...$game_message.texts.size
@text += " " if i >= $game_message.choice_start
@text += $game_message.texts[i].clone + "\x00"
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty?
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# * New Line
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty?
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# * Convert Special Characters
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\\\/) { "\\" }
end
#--------------------------------------------------------------------------
# * Set Window Background and Position
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # Normal window
self.opacity = 255
else # Dim Background and Make it Transparent
self.opacity = 0
end
case @position
when 0 # Top
self.y = 0
@gold_window.y = 360
when 1 # Middle
self.y = 144
@gold_window.y = 0
when 2 # Bottom
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# * End Message
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# * Update Message
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # Get next text character
case c
when nil # There is no text that must be drawn
finish_message # Finish update
break
when "\x00" # New line
new_line
if @line_count >= MAX_LINE # If line count is maximum
unless @text.empty? # If there is more
self.pause = true # Insert number input
break
end
end
when "\x01" # \C[n] (text character color change)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x03" # \. (wait 1/4 second)
@wait_count = 15
break
when "\x04" # \| (wait 1 second)
@wait_count = 60
break
when "\x05" # \! (Wait for input)
self.pause = true
break
when "\x06" # \> (Fast display ON)
@line_show_fast = true
when "\x07" # \< (Fast display OFF)
@line_show_fast = false
when "\x08" # \^ (No wait for input)
@pause_skip = true
else # Normal text character
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# * End Message Update
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max > 0
start_choice
elsif $game_message.num_input_variable_id > 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# * Start Choices
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# * Text Advancement Input
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= MAX_LINE
else
terminate_message
end
end
end
end
#==============================================================================
# ** Window_BattleMessage
#------------------------------------------------------------------------------
# Message window displayed during battle. In addition to the normal message
# window functions, it also has a battle progress narration function.
#==============================================================================
class Window_ExtendedLvlMessage < Window_Lvl_Message
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super
self.openness = 255
@lines = []
refresh
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Open Window (disabled)
#--------------------------------------------------------------------------
def open
end
#--------------------------------------------------------------------------
# * Close Window (disabled)
#--------------------------------------------------------------------------
def close
end
#--------------------------------------------------------------------------
# * Set Window Background and Position (disabled)
#--------------------------------------------------------------------------
def reset_window
end
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
def clear
@lines.clear
refresh
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def line_number
return @lines.size
end
#--------------------------------------------------------------------------
# * Go Back One Line
#--------------------------------------------------------------------------
def back_one
@lines.pop
refresh
end
#--------------------------------------------------------------------------
# * Return to Designated Line
# line_number : Line number
#--------------------------------------------------------------------------
def back_to(line_number)
while @lines.size > line_number
@lines.pop
end
refresh
end
#--------------------------------------------------------------------------
# * Add Text
# text : Text to be added
#--------------------------------------------------------------------------
def add_instant_text(text)
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Replace Text
# text : Text to be replaced
# Replaces the last line with different text.
#--------------------------------------------------------------------------
def replace_instant_text(text)
@lines.pop
@lines.push(text)
refresh
end
#--------------------------------------------------------------------------
# * Get Text From Last Line
#--------------------------------------------------------------------------
def last_instant_text
return @lines[-1]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@lines.size
draw_line(i)
end
end
#--------------------------------------------------------------------------
# * Draw Line
# index : Line number
#--------------------------------------------------------------------------
def draw_line(index)
rect = Rect.new(0, 0, 0, 0)
rect.x += 4
rect.y += index * WLH
rect.width = contents.width - 8
rect.height = WLH
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.draw_text(rect, @lines[index])
end
end
#==============================================================================
# ** Vocab Customizes for the extended victory screen
#------------------------------------------------------------------------------
# This module defines terms and messages. It defines some data as constant
# variables. Terms in the database are obtained from $data_system.
#==============================================================================
module Vocab
# Display when there are multiple members
PartyName = ""
# Battle Ending Messages
Victory = "Victorious!"
Defeat = "You are defeated."
ObtainExp = "EXP: %s!"
ObtainGold = "Gold: %s!"
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Battle
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
@victory_gold = Window_ExtendedGoldMessage.new
@victory_exp = Window_ExtendedExpMessage.new
@victory_item = Window_ExtendedItemMessage.new
@victory_lvl = Window_ExtendedLvlMessage.new
@victory_gold.visible = false
@victory_exp.visible = false
@victory_item.visible = false
@victory_lvl.visible = false
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
@victory_gold.dispose
@victory_exp.dispose
@victory_item.dispose
@victory_lvl.dispose
end
#--------------------------------------------------------------------------
# * Basic Update Processing
# main : Call from main update method
#--------------------------------------------------------------------------
def update_basic_gold(main = false)
Graphics.update unless main # Update game screen
Input.update unless main # Update input information
$game_system.update # Update timer
$game_troop.update # Update enemy group
@spriteset.update # Update sprite set
@victory_gold.update
end
def update_basic_exp(main = false)
Graphics.update unless main # Update game screen
Input.update unless main # Update input information
$game_system.update # Update timer
$game_troop.update # Update enemy group
@spriteset.update # Update sprite set
@victory_exp.update
end
def update_basic_item(main = false)
Graphics.update unless main # Update game screen
Input.update unless main # Update input information
$game_system.update # Update timer
$game_troop.update # Update enemy group
@spriteset.update # Update sprite set
@victory_item.update
end
def update_basic_lvl(main = false)
Graphics.update unless main # Update game screen
Input.update unless main # Update input information
$game_system.update # Update timer
$game_troop.update # Update enemy group
@spriteset.update # Update sprite set
@victory_lvl.update
end
#--------------------------------------------------------------------------
# * Wait Until Message Display has Finished
#--------------------------------------------------------------------------
def wait_for_gold
@victory_gold.update
while $game_message.visible
update_basic_gold
end
end
def wait_for_exp
@victory_exp.update
while $game_message.visible
update_basic_exp
end
end
def wait_for_item
@victory_item.update
while $game_message.visible
update_basic_item
end
end
def wait_for_lvl
@victory_lvl.update
while $game_message.visible
update_basic_lvl
end
end
#--------------------------------------------------------------------------
# * Victory Processing
#--------------------------------------------------------------------------
def process_victory
@info_viewport.visible = false
@message_window.visible = true
RPG::BGM.stop
$game_system.battle_end_me.play
unless $BTEST
$game_temp.map_bgm.play
$game_temp.map_bgs.play
end
display_victory
display_exp
display_gold
display_level_up
display_drop_items
battle_end(0)
end
#--------------------------------------------------------------------------
# * Display Gained Experience and Gold
#--------------------------------------------------------------------------
def display_victory
text = sprintf(Vocab::Victory, $game_party.name)
$game_message.texts.push('\|' + text)
wait_for_message
@message_window.visible = false
end
def display_exp
@victory_gold.visible = true
@victory_exp.visible = true
@victory_lvl.visible = true
exp = $game_troop.exp_total
if exp > 0
text = sprintf(Vocab::ObtainExp, exp)
$game_message.texts.push('\.' + text)
end
wait_for_exp
end
def display_gold
gold = $game_troop.gold_total
$game_party.gain_gold(gold)
if gold > 0
text = sprintf(Vocab::ObtainGold, gold, Vocab::gold)
$game_message.texts.push('\.' + text)
end
wait_for_gold
end
#--------------------------------------------------------------------------
# * Display Gained Drop Items
#--------------------------------------------------------------------------
def display_drop_items
@victory_item.visible = true
drop_items = $game_troop.make_drop_items
for item in drop_items
$game_party.gain_item(item, 1)
text = sprintf(Vocab::ObtainItem, item.name)
$game_message.texts.push(text)
end
wait_for_item
end
#--------------------------------------------------------------------------
# * Display Level Up
#--------------------------------------------------------------------------
def display_level_up
exp = $game_troop.exp_total
for actor in $game_party.existing_members
last_level = actor.level
last_skills = actor.skills
actor.gain_exp(exp, true)
end
wait_for_lvl
@victory_lvl.visible = false
end
end
Good luck with you new Victory Screen
Greetzz, Cell(Conmaster3)
PS: Free to use for non commercial production if you credit me... if you want to use it for commercial production please contact me

