#==============================================================================
# ** Window_BattleResult
#------------------------------------------------------------------------------
# This window displays amount of gold and EXP acquired at the end of a battle.
#==============================================================================
class Window_BattleResult < Window_Base
SPEEDS = {"instant" => 32, "faster" => 16, "fast" => 8,
"slow" => 4, "slower" => 2, "slowest" => 1}
#--------------------------------------------------------------------------
# * Object Initialization
# exp : EXP
# gold : amount of gold
# treasures : treasures
#--------------------------------------------------------------------------
def initialize(exp, gold, treasures, level_flags)
@exp = exp
@gold = gold
@treasures = treasures
@level_flags = level_flags
super(80, 0, 480, 256)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 255
self.visible = false
@index = 0
@wait_count = LufiaII_Result::WAIT_COUNT
@data = []
setup_text
self.contents = Bitmap.new(width - 32, @data.size * 32)
end
def setup_text
# Gain exp
exp_text = LufiaII_Result::GET_EXP_TEXT.dup
exp_text.gsub!(/\[exp\]/, "#{@exp}")
exp_text.gsub!(/\[words\]/, LufiaII_Result::WORDS_EXP)
@data.push(exp_text)
# Gain gold
gold_text = LufiaII_Result::GET_GOLD_TEXT.dup
gold_text.gsub!(/\[gold\]/, "#{@gold}")
gold_text.gsub!(/\[words\]/, $data_system.words.gold)
@data.push(gold_text)
# Gain Treasures
for i in 0...@treasures.size
item_text = LufiaII_Result::GET_ITEM_TEXT.dup
item_text.gsub!(/\[icon\]/, "\001[#{i}]")
item_text.gsub!(/\[name\]/, "#{@treasures[i].name}")
@data.push(item_text)
end
# Blank Line
@data.push("")
# Actor Stuff
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
level_text = LufiaII_Result::NEXT_LEVEL_TEXT.dup
level_text.gsub!(/\[name\]/, "#{actor.name}")
level_text.gsub!(/\[amount\]/, "#{actor.next_exp - actor.now_exp}")
if @level_flags[i][0] == false
@data.push(level_text)
else
levelup_text = LufiaII_Result::LEVEL_UP_TEXT.dup
levelup_text.gsub!(/\[name\]/, actor.name)
levelup_text.gsub!(/\[level\]/, "#{actor.level}")
@data.push(levelup_text)
skills = $data_classes[actor.class_id].learn_skills(actor.level)
actor.hp = actor.maxhp
actor.sp = actor.maxsp
for j in 0...skills.size
skill_learn_text = LufiaII_Result::GET_SKILL_TEXT.dup
skill_learn_text.gsub!(/\[icon\]/, "\003|#{skills[j]}|")
skill_learn_text.gsub!(/\[name\]/, $data_skills[skills[j]].name)
@data.push(skill_learn_text)
end
for j in 0...LufiaII_Result::STATS.size
stat_text = LufiaII_Result::STAT_UP_TEXT.dup
stat_text.gsub!(/\[stat\]/, LufiaII_Result::STAT_NAMES[j])
amount = actor.stat_change(j, @level_flags[actor.index][1])
stat_text.gsub!(/\[amount\]/, "#{amount}")
@data.push(stat_text)
end
@data.push(level_text)
@data.push("") if i != $game_party.actors.size - 1
end
end
@data.push("")
cgold_text = LufiaII_Result::GOLD_TEXT.dup
cgold_text.gsub!(/\[gold\]/, "#{$game_party.gold}")
cgold_text.gsub!(/\[words\]/, $data_system.words.gold)
@data.push(cgold_text)
end
def update
if @scrolling
@scroll_time -= 1
self.oy += SPEEDS[LufiaII_Result::SCROLL_SPEED.downcase]
@scrolling = false if @scroll_time == 0
return
end
if LufiaII_Result::WAIT_COUNT != nil
@wait_count -= 1
if @wait_count == 0
@wait_count = LufiaII_Result::WAIT_COUNT
if @data.size - 1 >= @index
refresh
@index += 1
@scrolling = true if @index > 7
@scroll_time = 32 / SPEEDS[LufiaII_Result::SCROLL_SPEED.downcase] if @scrolling
else
dispose
end
return
end
end
if LufiaII_Result::PUSH_BUTTON and Input.trigger?(Input::C)
@wait_count = LufiaII_Result::WAIT_COUNT
if @data.size - 1 >= @index
refresh
@index += 1
@scrolling = true if @index > 7
@scroll_time = 32 / SPEEDS[LufiaII_Result::SCROLL_SPEED.downcase] if @scrolling
else
dispose
end
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
x = 0
text = @data[@index]
text.gsub!(/\[right\]/, "\002")
text = text.split("\002")
return if text == []
for string in text[0].split(/\001|\003|\s/)
if string.sub!(/\[([0-9]+)\]/, "") != nil
index = $1.to_i
bitmap = RPG::Cache.icon(@treasures[index].icon_name)
rect = bitmap.rect
self.contents.blt(x, @index * 32, bitmap, rect)
x += bitmap.width
elsif string.sub!(/\|([0-9]+)\|/, "") != nil
skill_id = $1.to_i
bitmap = RPG::Cache.icon($data_skills[skill_id].icon_name)
rect = bitmap.rect
self.contents.blt(x, @index * 32, bitmap, rect)
x += bitmap.width
else
self.contents.draw_text_outline(x, @index * 32, width - 32, 32, string)
x += contents.text_size(string).width
end
x += contents.text_size(" ").width
end
if text[1] != nil
self.contents.draw_text_outline(0, @index * 32, width - 32, 32, text[1], 2)
end
end
end