class Scene_MenuBase < Scene_Base
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize
super
@last_index = 0 if @last_index == nil
end
end
class Window_MenuCommand < Window_Command
#----------------------------------------------------------------------------
# * 重命名方法
#----------------------------------------------------------------------------
alias nir item_rect
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize
@command_icon_index = [260, 96, 170, 16, 280, 375, 12]
super(0, 0)
end
#----------------------------------------------------------------------------
# * 描绘选项
#----------------------------------------------------------------------------
def draw_item(index)
rect = item_rect_for_text(index)
draw_icon(@command_icon_index[index], rect.x, rect.y, command_enabled?(index))
self.contents.font.color.alpha = (command_enabled?(index) ? 255 : 160)
self.contents.draw_text(rect.x + 24, rect.y, rect.width - 24, rect.height, command_name(index))
end
#----------------------------------------------------------------------------
# * 获取项目的描绘矩形
#----------------------------------------------------------------------------
def item_rect(index)
return Rect.new
end
#----------------------------------------------------------------------------
# * 获取项目的绘制矩形(内容用)
#----------------------------------------------------------------------------
def item_rect_for_text(index)
rect = nir(index)
rect.x += 4
rect.width -= 8
rect
end
end
class Window_NewMenuStatus < Window_Command
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize
super(160, 0)
end
#----------------------------------------------------------------------------
# * 获取窗口的宽度
#----------------------------------------------------------------------------
def window_width
return 384
end
#----------------------------------------------------------------------------
# * 获取窗口的高度
#----------------------------------------------------------------------------
def window_height
return 416
end
#----------------------------------------------------------------------------
# * 更新内容
#----------------------------------------------------------------------------
def refresh
super
draw_actor_status
end
#----------------------------------------------------------------------------
# * 生成指令列表
#----------------------------------------------------------------------------
def make_command_list
for actor in $game_party.members
s = "a[#{actor.id}]"
add_command(actor.name, s.to_sym, !actor.death_state?, actor.id)
end
end
#----------------------------------------------------------------------------
# * 描绘选项
#----------------------------------------------------------------------------
def draw_item(index)
rect = item_rect_for_text(index)
b = Bitmap.new(rect.width, rect.height)
cn = $game_actors[@list[index][:ext]].character_name
ci = $game_actors[@list[index][:ext]].character_index
cb = Cache.character(cn)
if cn[0] == "[ DISCUZ_CODE_2547 ]quot"
cr = Rect.new
cr.x = cb.width / 3
cr.width = cb.width / 3
cr.height = cb.height / 4
else
cr = Rect.new
cr.x = ci % 4 * (cb.width / 4) + cb.width / 12
cr.y = ci / 4 * (cb.height / 2)
cr.width = cb.width / 12
cr.height = cb.height / 8
end
b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr)
unless command_enabled?(index)
for y in 0...b.height
for x in 0...b.width
next if b.get_pixel(x, y).alpha == 0
c = b.get_pixel(x, y)
m = (c.red + c.green + c.blue) / 3
b.set_pixel(x, y, Color.new(m, m, m, c.alpha))
end
end
end
self.contents.blt(rect.x, rect.y, b, b.rect)
b.dispose
cb.dispose
end
#----------------------------------------------------------------------------
# * 获取项目的绘制矩形
#----------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = self.contents.width / 4
rect.height = 48
rect.x = (index < 4 ? index * rect.width : (index - 4) * rect.width)
rect.y = (index < 4 ? 0 : self.contents.height - rect.height)
return rect
end
#----------------------------------------------------------------------------
# * 描绘角色的状态
#----------------------------------------------------------------------------
def draw_actor_status
actor = $game_actors[@list[@index][:ext]]
y = item_rect_for_text(0).height + 5
h = self.contents.height - 2 * (item_rect_for_text(0).height + 5)
self.contents.clear_rect(Rect.new(0, y, self.contents.width, h))
draw_actor_face(actor, 0, y)
draw_actor_name(actor, 0, y)
draw_actor_level(actor, 96, y)
draw_actor_nickname(actor, 168, y)
draw_actor_hp(actor, 96, y + line_height, self.contents.width - 96)
draw_actor_mp(actor, 96, y + 2 * line_height, self.contents.width - 96)
draw_actor_icons(actor, 96, y + 3 * line_height)
for i in 0...6
draw_actor_param(actor, 0, y + (4 + i) * line_height, i)
end
for i in 0...5
draw_item_name(actor.equips[i], self.contents.width / 2, y + (4 + i) * line_height) if actor.equips[i] != nil
end
end
#----------------------------------------------------------------------------
# * 选择项目
#----------------------------------------------------------------------------
def select(index)
super
draw_actor_status
end
end
class Window_NewGold < Window_Base
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize
super(0, 368, 160, 48)
refresh
end
#----------------------------------------------------------------------------
# * 描绘内容
#----------------------------------------------------------------------------
def refresh
draw_icon(262, 0, 0)
draw_currency_value($game_party.gold, Vocab::currency_unit, 28, 0, self.contents.width-32)
end
end
class Scene_Menu < Scene_MenuBase
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize
super
@select_actor = []
end
#----------------------------------------------------------------------------
# * 开始处理
#----------------------------------------------------------------------------
def start
super
create_frame_sprite
create_menu_window
create_menustatus_command
create_gold_window
create_select_sprite
end
#----------------------------------------------------------------------------
# * 更新画面
#----------------------------------------------------------------------------
def update
super
@select_sprite.y = 12 + @menu_command.index * 24 + (@select_sprite.bitmap.height - 24) / 2
@frame_sprite.update
@select_sprite.update
end
#----------------------------------------------------------------------------
# * 释放画面
#----------------------------------------------------------------------------
def terminate
super
@frame_sprite.dispose
@select_sprite.dispose
end
#----------------------------------------------------------------------------
# * 创建边框精灵
#----------------------------------------------------------------------------
def create_frame_sprite
@frame_sprite = Sprite.new
@frame_sprite.bitmap = Cache.system("素材1")
end
#----------------------------------------------------------------------------
# * 创建选择精灵
#----------------------------------------------------------------------------
def create_select_sprite
@select_sprite = Sprite.new
@select_sprite.bitmap = Cache.system("素材2")
@select_sprite.x = 148
@select_sprite.y = 12 + @menu_command.index * 24 + (@select_sprite.bitmap.height - 24) / 2
end
#----------------------------------------------------------------------------
# * 创建菜单选项
#----------------------------------------------------------------------------
def create_menu_window
@menu_command = Window_MenuCommand.new
@menu_command.set_handler(:item, method(:item_ok))
@menu_command.set_handler(:skill, method(:command_personal))
@menu_command.set_handler(:equip, method(:command_personal))
@menu_command.set_handler(:status, method(:command_personal))
@menu_command.set_handler(:formation, method(:command_personal))
@menu_command.set_handler(:save, method(:save_ok))
@menu_command.set_handler(:game_end, method(:game_end_ok))
@menu_command.set_handler(:cancel, method(:return_scene))
@menu_command.select(@last_index)
@menu_command.opacity = 0
end
#----------------------------------------------------------------------------
# * 创建人物状态选单
#----------------------------------------------------------------------------
def create_menustatus_command
@menustatus_command = Window_NewMenuStatus.new
@menustatus_command.set_handler(:ok , method(:status_ok))
@menustatus_command.set_handler(:cancel, method(:status_cancel))
@menustatus_command.active = false
@menustatus_command.opacity = 0
end
#----------------------------------------------------------------------------
# * 创建金钱窗口
#----------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_NewGold.new
@gold_window.opacity = 0
end
#----------------------------------------------------------------------------
# * "物品"选项确定
#----------------------------------------------------------------------------
def item_ok
SceneManager.call(Scene_Item)
@last_index = @menu_command.index
end
#----------------------------------------------------------------------------
# * "技能""装备""状态""整队"选项确定
#----------------------------------------------------------------------------
def command_personal
@menu_command.active = false
@menustatus_command.active = true
@last_index = @menu_command.index
end
#----------------------------------------------------------------------------
# * "存档"选项确定
#----------------------------------------------------------------------------
def save_ok
SceneManager.call(Scene_Save)
@last_index = @menu_command.index
end
#----------------------------------------------------------------------------
# * "结束游戏"选项确定
#----------------------------------------------------------------------------
def game_end_ok
SceneManager.call(Scene_End)
@last_index = @menu_command.index
end
#----------------------------------------------------------------------------
# * 状态窗口确定
#----------------------------------------------------------------------------
def status_ok
$game_party.menu_actor = $game_actors[@menustatus_command.current_ext]
case @menu_command.current_symbol
when :skill
SceneManager.call(Scene_Skill)
when :equip
SceneManager.call(Scene_Equip)
when :status
SceneManager.call(Scene_Status)
when :formation
case @select_actor.size
when 0
@select_actor[0] = @menustatus_command.index
@menustatus_command.active = true
when 1
@select_actor[1] = @menustatus_command.index
$game_party.swap_order(@select_actor[0], @select_actor[1])
@select_actor = []
@menustatus_command.refresh
@menu_command.active = true
end
end
end
#----------------------------------------------------------------------------
# * 状态窗口取消
#----------------------------------------------------------------------------
def status_cancel
@menu_command.active = true
@menustatus_command.active = false
end
end