#==============================================================================
# 〓 套装 〓 <显示> Author : 芯☆淡茹水
#==============================================================================
# 套装说明窗口
#==============================================================================
class Suit_Help < Sprite
#--------------------------------------------------------------------------
attr_reader :actor_index, :suit_id
#--------------------------------------------------------------------------
# 初始化
#--------------------------------------------------------------------------
def initialize(actor_index)
super()
@actor_index = actor_index
@suit_id = 0
@contents = Sprite.new
@help_width = XdRs_Suit::Help_Width
hide
end
#--------------------------------------------------------------------------
# 释放
#--------------------------------------------------------------------------
def dispose
dispose_bitmap
@contents.dispose
super
end
#--------------------------------------------------------------------------
# 释放位图
#--------------------------------------------------------------------------
def dispose_bitmap
@contents.bitmap && @contents.bitmap.dispose
self.bitmap && self.bitmap.dispose
end
#--------------------------------------------------------------------------
# 隐藏
#--------------------------------------------------------------------------
def hide; self.visible = @contents.visible = false; end
#--------------------------------------------------------------------------
# 显示
#--------------------------------------------------------------------------
def show; self.visible = @contents.visible = true; end
#--------------------------------------------------------------------------
# 角色实例
#--------------------------------------------------------------------------
def actor; return $game_party.actors[@actor_index]; end
#--------------------------------------------------------------------------
# 设置角色索引
#--------------------------------------------------------------------------
def set_actor(index);@actor_index != index && refresh(index, @suit_id);end
#--------------------------------------------------------------------------
# 设置套装ID
#--------------------------------------------------------------------------
def set_suit_id(id); @suit_id != id && refresh(@actor_index, id); end
#--------------------------------------------------------------------------
# 设置位置
#--------------------------------------------------------------------------
def set_place(x, y)
gw = XdRs_Suit::Graphics_Width
gh = XdRs_Suit::Graphics_Height
x = self.bitmap ? [[0, x].max, gw - self.bitmap.width].min : x
y = self.bitmap ? [[0, y].max, gh - self.bitmap.height].min : y
self.x = @contents.x = x
self.y = @contents.y = y
self.z = 998; @contents.z = 999
end
#--------------------------------------------------------------------------
# 刷新
#--------------------------------------------------------------------------
def refresh(index, id)
hide
@actor_index = index
@suit_id = id
return if !actor || @suit_id == 0
setup_effects
recreate_image
draw_all
show
end
#--------------------------------------------------------------------------
# 设置套装效果
#--------------------------------------------------------------------------
def setup_effects
@effect = Suit_Effect.new(@suit_id, actor.suit_num(@suit_id))
@all_equips = XdRs_Suit.suits(@suit_id)
@words = []
(@all_equips.size-1).times{|i| @words.push(@effect.words(i))}
@words = @words.find_all{|w| w != ""}
@all_equips = XdRs_Suit.suits(@suit_id)
end
#--------------------------------------------------------------------------
# 重新生成图像
#--------------------------------------------------------------------------
def recreate_image
dispose_bitmap
height = height_count
self.bitmap = Bitmap.new(@help_width, height)
@contents.bitmap = Bitmap.new(@help_width, height)
@contents.bitmap.font.bold = true
end
#--------------------------------------------------------------------------
# 高度计算
#--------------------------------------------------------------------------
def height_count
height = 100
@words.each do |w|
height += [w.size, 1].max * 22 + 22
end
return height + @all_equips.size * 22
end
#--------------------------------------------------------------------------
# 设置文字颜色
#--------------------------------------------------------------------------
def set_font_color(color)
@contents.bitmap.font.color = color
end
#--------------------------------------------------------------------------
# 描绘文字
#--------------------------------------------------------------------------
def draw_text(x, y, w, h, text, a=0)
last_color = @contents.bitmap.font.color.clone
ow = XdRs_Suit.out_line_width
set_font_color(Color.new(0,0,0,160))
@contents.bitmap.draw_text(x+ow, y, w, h, text, a)
@contents.bitmap.draw_text(x-ow, y, w, h, text, a)
@contents.bitmap.draw_text(x, y+ow, w, h, text, a)
@contents.bitmap.draw_text(x, y-ow, w, h, text, a)
@contents.bitmap.draw_text(x+ow, y+ow, w, h, text, a)
@contents.bitmap.draw_text(x-ow, y-ow, w, h, text, a)
set_font_color(last_color)
@contents.bitmap.draw_text(x, y, w, h, text, a)
end
#--------------------------------------------------------------------------
# 描绘所有内容
#--------------------------------------------------------------------------
def draw_all
draw_bg
draw_words
end
#--------------------------------------------------------------------------
# 描绘背景
#--------------------------------------------------------------------------
def draw_bg
color = XdRs_Suit.get_color(0)
color.alpha = 10
x = y = 0; w = self.bitmap.width; h = self.bitmap.height
5.times do |i|
self.bitmap.fill_rect(x,y,w,h,color)
color.alpha += 30
x+=1;y+=1;w-=2;h-=2
end
self.bitmap.fill_rect(5,7,@help_width-10,30,XdRs_Suit.get_color(3))
end
#--------------------------------------------------------------------------
# 描绘效果语言文本
#--------------------------------------------------------------------------
def draw_words
return if !actor || @suit_id == 0 || !@contents.bitmap
@contents.bitmap.clear
y = 10
@contents.bitmap.font.size = 20
set_font_color(XdRs_Suit.get_color(1))
text = XdRs_Suit::Tit_Word.gsub("\name", @effect.name)
draw_text(0, y, @help_width, 24, text, 1)
y += 28
set_font_color(XdRs_Suit.get_color(3))
@contents.bitmap.font.size = 16
draw_text(0, y, @help_width, 20, XdRs_Suit.suit_num_text(@suit_id, actor), 1)
y += 24
size = @all_equips.size - 1
size.times{|i| y = draw_stage(i, y)}
y += 10
@all_equips.size.times do |i|
draw_equip(@all_equips[i], y+i*22)
end
end
#--------------------------------------------------------------------------
# 检查角色件数阶段是否激活效果
#--------------------------------------------------------------------------
def is_act?(num, n)
return (num - 2 - n) >= 0
end
#--------------------------------------------------------------------------
# 描绘件数阶段效果
#--------------------------------------------------------------------------
def draw_stage(index, y)
num = actor.suit_num(@suit_id)
set_font_color(XdRs_Suit.get_color(is_act?(num, index) ? 2 : 4))
a = ["天书坎","天书坤","天书震","天书巽","天书中宫""天书乾"][index]
draw_text(0, y, @help_width, 20, a, 1)
# draw_text(0, y, @help_width, 20, "装备 #{index+2} 件", 1)
y += 22
word = @words[index]
if (word.size == 0)
set_font_color(XdRs_Suit.get_color(4))
draw_text(0, y, @help_width, 20, "(无)", 1)
y += 20
else
set_font_color(XdRs_Suit.get_color(is_act?(num, index) ? 3 : 4))
word.each do |e|
e == "" && next
draw_text(0, y, @help_width, 20, e, 1)
y += 20
end
end
return y + 10
end
#--------------------------------------------------------------------------
# 描绘装备
#--------------------------------------------------------------------------
def draw_equip(equip, y)
set_font_color(XdRs_Suit.get_color(actor.is_equiped?(equip) ? 3 : 4))
cw = @contents.bitmap.text_size(equip.name).width + 4
x = (@help_width - cw - 24) / 2
bitmap = RPG::Cache.icon(equip.icon_name)
size = XdRs_Suit::Icon_Size
rect1 = Rect.new(x, y, 20, 20)
rect2 = Rect.new(0, 0, size, size)
@contents.bitmap.stretch_blt(rect1, bitmap, rect2)
draw_text(x+24, y+3, cw, 20, equip.name)
end
end
#==============================================================================
class Scene_Equip
#--------------------------------------------------------------------------
# 更改主程序
#--------------------------------------------------------------------------
alias xdrs_suit_main main
def main
@suit_help = Suit_Help.new(@actor_index)
xdrs_suit_main
@suit_help.dispose
end
#--------------------------------------------------------------------------
# 更改刷新
#--------------------------------------------------------------------------
alias xdrs_suit_update update
def update
update_suit_help
xdrs_suit_update
end
#--------------------------------------------------------------------------
# 刷新套装说明窗口
#--------------------------------------------------------------------------
def update_suit_help
@suit_help.set_actor(@actor.index)
if @right_window.active
equip = @right_window.item
elsif @item_window.active
equip = @item_window.item
end
@suit_help.set_suit_id(XdRs_Suit.suit_id(equip))
update_place
end
#--------------------------------------------------------------------------
# 刷新套装说明窗口位置
#--------------------------------------------------------------------------
def update_place
return unless @suit_help.visible
if @right_window.active
x = @right_window.x - XdRs_Suit::Help_Width
y = @right_window.index * 32 + @right_window.y
elsif @item_window.active
index = @item_window.index
x = @item_window.x + (index+1) % 2 * @item_window.width / 2
y = @item_window.y + index / 2 * 32
end
@suit_help.set_place(x, y)
end
#--------------------------------------------------------------------------
# 更改刷新项目
#--------------------------------------------------------------------------
alias xdrs_suit_update_item update_item
def update_item
xdrs_suit_update_item
Input.trigger?(Input::C) && @suit_help.draw_words
end
end