class Window_Help2 < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(-16, -16, 640, 480)
self.windowskin = RPG::Cache.windowskin("nil")
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 220
self.z = 400
end
#--------------------------------------------------------------------------
# ● 设置文本
# text : 窗口显示的字符串
# align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐)
#--------------------------------------------------------------------------
def set_text(text, y = nil,align = 0)
self.visible = true
self.contents.clear
self.contents.font.color = Color.new(64,70,124,255)
@text = text.clone
x = y = 0
begin
last_text = @text.clone
@text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until @text == last_text
@text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
@text.gsub!(/\\\\/) { "\000" }
@text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
@text.gsub!(/\\[Nn]/) { "\002" }
@text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
while ((c = @text.slice!(/./m)) != nil)
if c == "\000"
c = "\\"
end
if c == "\001"
@text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
next
end
if c == "\002"
y += 1
x = 0
next
end
if c == "\003"
@text.sub!(/\[([0-9]+)\]/, "")
t = RPG::Cache.icon("item_#{$1}")
self.contents.blt(-40, 0, t, t.rect)
t.dispose
next
end
self.contents.draw_text(205 + x, 32 * y+32, 40, 32, c)
x += self.contents.text_size(c).width
end
end
end
#------------------------------技能·帮助----------------------------------
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
# 特技及物品的说明、角色的状态显示的窗口。
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(-16, -16, 640, 480)
self.windowskin = RPG::Cache.windowskin("nil")
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 220
self.z = 400
end
#--------------------------------------------------------------------------
# ● 设置文本
# text : 窗口显示的字符串
# align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐)
#--------------------------------------------------------------------------
def set_text(text, y = nil,align = 0)
self.visible = true
self.contents.clear
self.contents.font.color = Color.new(64,70,124,255)
@text = text.clone
x = y = 0
begin
last_text = @text.clone
@text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until @text == last_text
@text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
@text.gsub!(/\\\\/) { "\000" }
@text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
@text.gsub!(/\\[Nn]/) { "\002" }
@text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
while ((c = @text.slice!(/./m)) != nil)
if c == "\000"
c = "\\"
end
if c == "\001"
@text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
next
end
if c == "\002"
y += 1
x = 0
next
end
if c == "\003"
@text.sub!(/\[([0-9]+)\]/, "")
t = RPG::Cache.icon("skill_#{$1}")
self.contents.blt(0, 15, t, t.rect)
t.dispose
next
end
self.contents.draw_text(176 + x, 32 * y+32, 40, 32, c)
x += self.contents.text_size(c).width
end
end
5.
for i in 0...$game_party.actors.size
x = i * 160
y = 25
actor = $game_party.actors
@actor = actor
testname = @actor.name.to_s
#=========================================
bitmap=Bitmap.new("Graphics/menu/status/#{testname}_a")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
#=========================================
draw_actor_hp(actor, x + 23, y + 58)
draw_actor_sp(actor, x + 20, y + 72)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置 -1 为全选、-2 以下为单独选择 (使用者自身)
if @index <= -2
self.cursor_rect.set(@index*160, 50, 150, 76)
elsif @index == -1
self.cursor_rect.set(0, 50, @item_max * 155, 76)
else
self.cursor_rect.set(@index*160, 50, 150, 76)
end
end
def dispose
super
end
end
6.
#=============================================================
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.back_opacity = 160
end
# 战斗中的情况下将窗口移至中央并将其半透明化
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加报务
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items)
end
end
# 在战斗中以外添加武器、防具
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons)
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
end
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = Color.new(64,70,124,255)
else
self.contents.font.color = Color.new(224,96,112,255)
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
opacity = self.contents.font.color == normal_color ? 255 : 128.
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 180, y, 16, 32, "X", 1)
self.contents.draw_text(x + 200, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
9.
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(30, 150, 595, 240)
#==============================
self.windowskin = RPG::Cache.windowskin("choose")
@backsp1 = Sprite.new
@backsp1.bitmap = Bitmap.new("Graphics/menu/底板.png")
@backsp1.z = 99
@backsp2 = Sprite.new
@backsp2.bitmap = Bitmap.new("Graphics/menu/物品.png")
@backsp2.x = 15
@backsp2.y = 115
@backsp2.z = 101
#=============================================================
@help2 = Sprite.new
@help2.bitmap = Bitmap.new("Graphics/menu/帮助窗口使用.png")
@help2.x = 15
@help2.y = -20
@help2.z = 100
#==============================
@column_max = 2
refresh
self.index = 0
# 战斗中的情况下将窗口移至中央并将其半透明化
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加报务
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items)
end
end
# 在战斗中以外添加武器、防具
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons)
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
end
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = Color.new(64,70,124,255)
else
self.contents.font.color = Color.new(224,96,112,255)
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = i * 160
y = 25
actor = $game_party.actors
@actor = actor
testname = @actor.name.to_s
#-------------------------------------------------------------------
bitmap = Bitmap.new("Graphics/menu/Status/#{testname}"+"_a")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
#-------------------------------------------------------------------
draw_actor_hp(actor, x + 23, y + 58)
draw_actor_sp(actor, x + 20, y + 72)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index*160, 50, 150, 76)
end
end
end
13.
class Scene_Item
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
$game_party.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@item_window.draw_item(@item_window.index)
end
# 切换到地图画面
#if $game_temp.common_event_id == 107
#$game_temp.common_event_id = 0
#$game_system.map_interpreter.setup($data_common_events[107].list, 0)
#end
$scene = Scene_Menu_Item.new(1)
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (目标窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_target
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 由于物品用完而不能使用的场合
unless $game_party.item_can_use?(@item.id)
# 再次生成物品窗口的内容
@item_window.refresh
end
# 删除目标窗口
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 如果物品用完的情况下
if $game_party.item_number(@item.id) == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 目标是全体的情况下
if @target_window.index == -1
# 对同伴全体应用物品使用效果
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# 目标是单体的情况下
if @target_window.index >= 0
# 对目标角色应用物品的使用效果
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# 使用物品的情况下
if used
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
$game_party.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@item_window.draw_item(@item_window.index)
end
# 再生成目标窗口的内容
@target_window.refresh
# 全灭的情况下
if $game_party.all_dead?
# 切换到游戏结束画面
$scene = Scene_Gameover.new
return
end
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
$game_system.map_interpreter.setup($data_common_events[@item.common_event_id].list, 0)
# 预约调用公共事件
#$game_temp.common_event_id = @item.common_event_id
# 切换到地图画面
#if $game_temp.common_event_id == 107
#$game_temp.common_event_id = 0
#$game_system.map_interpreter.setup($data_common_events[107].list, 0)
#end
$scene = Scene_Map.new
return
end
end
# 无法使用物品的情况下
unless used
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
18.