class Window_MenuList < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# width : 窗口的宽
# commands : 命令字符串序列
#--------------------------------------------------------------------------
def initialize(width, commands)
# 由命令的个数计算出窗口的高
super(0, 0, 480, 96)
@item_max = commands.size
@commands = [ITEM, SKILL, EQUIP, STATUS, SAVE, EXIT]
self.contents = Bitmap.new(width - 32, 64)
refresh
self.index = 0
@column_max = 3
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
# color : 文字色
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
if index >= 0 && index <= 2
rect = Rect.new(160 * index + 4, 0, self.contents.width - 8, 32)
elsif index >= 3 && index <= 5
rect = Rect.new(160 * (index - 3) + 4, 32, self.contents.width - 8, 32)
end
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index])
end
#--------------------------------------------------------------------------
# ● 项目无效化
# index : 项目编号
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化目标 #actor_id: 角色编号 (0号为第一个角色,依此类推)
#--------------------------------------------------------------------------
def initialize(actor_id)
super(0, 0, 160, 384)
@actor_id = actor_id
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = 1
actor = $game_party.actors[@actor_id]
#------------------------------------------------------------------------
# ★ 头像调用
#------------------------------------------------------------------------
if actor.id < 10
testname = "Actor00"+actor.id.to_s
elsif actor.id >= 10 && actor.id < 100
testname = "Actor0"+ actor.id.to_s
elsif actor.id >= 100 && actor.id <= 999
testname = "Actor" + actor.id.to_s
end
bitmap = Bitmap.new("Graphics/Heads/#{testname}")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(14, y + 10, bitmap, src_rect)
draw_actor_name(actor, 22, 115)
HP(actor, 0, 200)
MP(actor, 0, 214)
draw_actor_hp(actor, 0, 180)
draw_actor_sp(actor, 0, 227)
EXP(actor, 0, 238, 96)
draw_actor_exp(actor, 10, 270)
draw_actor_level(actor, 36, 315)
#$game_party.actors.size
#for i in 0...$game_party.actors.size
#x = 64
#y = 116
#actor = $game_party.actors[@actor_id]
#draw_actor_graphic(actor, x - 40, y + 80)
#draw_actor_name(actor, x, y)
draw_actor_class(actor, 22,115 + 32)#x + 144, y)
#draw_actor_level(actor, x, y + 32)
#draw_actor_state(actor, 22, 180)#x + 90, y + 32)
#draw_actor_exp(actor, x, y + 64)
#draw_actor_hp(actor, x + 236, y + 32)
#draw_actor_sp(actor, x + 236, y + 64)
#end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, self.height - 32)
end
end
end
class Scene_Menu
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
@status_index = 0
@spriteset = Spriteset_Map.new
# 生成命令窗口
s1 = ITEM
s2 = SKILL
s3 = EQUIP
s4 = STATUS
s5 = SAVE
s6 = EXIT
@command_window = Window_MenuList.new(480, [s1, s2, s3, s4, s5, s6])
@command_window.index = @menu_index
@command_window.opacity = 160
#@command_window.height = 196
# 同伴人数为 0 的情况下
if $game_party.actors.size == 0
# 物品、特技、装备、状态无效化
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# 禁止存档的情况下
if $game_system.save_disabled
# 存档无效
@command_window.disable_item(4)
end
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 0
@gold_window.opacity = 160
# 生成状态窗口
@status_window = []
for i in 0...$game_party.actors.size
@status_window = Window_MenuStatus.new(i)
@status_window.x = 160 * i
@status_window.y = 96
@status_window.opacity = 160
end
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果切换画面就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
@gold_window.dispose
for i in 0...$game_party.actors.size
@status_window.dispose
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@command_window.update
@gold_window.update
#@status_window.update
for i in 0...$game_party.actors.size
@status_window.update
end
if $cancel
@command_window.active = false
@status_window[$index].active = true
@status_window[$index].index = 0
@status_index = $index
$cancel = false
end
# 命令窗口被激活的情况下: 调用 update_command
if @command_window.active
update_command
return
end
# 状态窗口被激活的情况下: 调用 update_status
if @status_window[@status_index]#@status_window[0].active || @status_window[1].active || @status_window[2].active || @status_window[3].active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (命令窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换的地图画面
$scene = Scene_Map.new
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 同伴人数为 0、存档、游戏结束以外的场合
if $game_party.actors.size == 0 and @command_window.index < 4
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 命令窗口的光标位置分支
case @command_window.index
when 0 # 物品
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到物品画面
$scene = Scene_Item.new
when 1 # 特技
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window[0].active = true
@status_window[0].index = 0
when 2 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window[0].active = true
@status_window[0].index = 0
when 3 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window[0].active = true
@status_window[0].index = 0
when 4 # 存档
# 禁止存档的情况下
if $game_system.save_disabled
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到存档画面
$scene = Scene_Save.new
when 5 # 游戏结束
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到游戏结束画面
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (状态窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_status
#p @status_index
#for i in 0..3
# p @status_window.active
#end
for i in 0...$game_party.actors.size
@status_window.update
end
if Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
if @status_index == 0
@status_index = $game_party.actors.size - 1
else
@status_index -= 1
end
end
if Input.trigger?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
if @status_index == $game_party.actors.size - 1
@status_index = 0
else
@status_index += 1
end
end
case @status_index
when 0
@status_window[0].active = true
@status_window[0].index = 0
if $game_party.actors.size >= 2
@status_window[1].active = false
@status_window[1].index = -1
if $game_party.actors.size >= 3
@status_window[2].active = false
@status_window[2].index = -1
if $game_party.actors.size >= 4
@status_window[3].active = false
@status_window[3].index = -1
end
end
end
when 1
@status_window[0].active = false
@status_window[0].index = -1
if $game_party.actors.size >= 2
@status_window[1].active = true
@status_window[1].index = 0
if $game_party.actors.size >= 3
@status_window[2].active = false
@status_window[2].index = -1
if $game_party.actors.size >= 4
@status_window[3].active = false
@status_window[3].index = -1
end
end
end
when 2
@status_window[0].active = false
@status_window[0].index = -1
if $game_party.actors.size >= 2
@status_window[1].active = false
@status_window[1].index = -1
if $game_party.actors.size >= 3
@status_window[2].active = true
@status_window[2].index = 0
if $game_party.actors.size >= 4
@status_window[3].active = false
@status_window[3].index = -1
end
end
end
@status_window[0].active = false
@status_window[0].index = -1
@status_window[1].active = false
@status_window[1].index = -1
@status_window[2].active = true
@status_window[2].index = 0
@status_window[3].active = false
@status_window[3].index = -1
when 3
@status_window[0].active = false
@status_window[0].index = -1
if $game_party.actors.size >= 2
@status_window[1].active = false
@status_window[1].index = -1
if $game_party.actors.size >= 3
@status_window[2].active = false
@status_window[2].index = -1
if $game_party.actors.size >= 4
@status_window[3].active = true
@status_window[3].index = 0
end
end
end
end
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 激活命令窗口
@command_window.active = true
@status_window[@status_index].active = false
@status_window[@status_index].index = -1
@status_index = 0
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口的光标位置分支
case @command_window.index
when 1 # 特技
# 本角色的行动限制在 2 以上的情况下
if $game_party.actors[@status_index].restriction >= 2
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到特技画面
$scene = Scene_Skill.new(@status_index)#window.index)
when 2 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换的装备画面
$scene = Scene_Equip.new(@status_index)#@status_window.index)
when 3 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到状态画面
$scene = Scene_Status.new(@status_index)#@status_window.index)
end
return
end
end
end
class Scene_Skill
def update_skill
# 按下 B 键的情况下
$cancel = true
$index = @actor_index
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(1)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取特技窗口现在选择的特技的数据
@skill = @skill_window.skill
# 不能使用的情况下
if @skill == nil or not @actor.skill_can_use?(@skill.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 效果范围是我方的情况下
if @skill.scope >= 3
# 激活目标窗口
@skill_window.active = false
@target_window.x = (@skill_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 设置效果范围 (单体/全体) 的对应光标位置
if @skill.scope == 4 || @skill.scope == 6
@target_window.index = -1
elsif @skill.scope == 7
@target_window.index = @actor_index - 10
else
@target_window.index = 0
end
# 效果在我方以外的情况下
else
# 公共事件 ID 有效的情况下
if @skill.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @skill.common_event_id
# 演奏特技使用时的 SE
$game_system.se_play(@skill.menu_se)
# 消耗 SP
@actor.sp -= @skill.sp_cost
# 再生成各窗口的内容
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
return
end
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的特技画面
$scene = Scene_Skill.new(@actor_index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的特技画面
$scene = Scene_Skill.new(@actor_index)
return
end
end
end
class Scene_Equip
def update_right
# 按下 B 键的情况下
if Input.trigger?(Input::B)
$cancel = true
$index = @actor_index
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(2)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 固定装备的情况下
if @actor.equip_fix?(@right_window.index)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活物品窗口
@right_window.active = false
@item_window.active = true
@item_window.index = 0
return
end
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的装备画面
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的装备画面
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
end
end
class Scene_Status
def update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
$cancel = true
$index = @actor_index
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(3)
return
end
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的状态画面
$scene = Scene_Status.new(@actor_index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的状态画面
$scene = Scene_Status.new(@actor_index)
return
end
end
end
[/pre]