#==============================================================================
# ■ Window_Command
#------------------------------------------------------------------------------
# 带有指令选择的窗口
#==============================================================================
############################################
# ● 除“选项命令”的文字外,其他“默认窗口”的文字居中
############################################
class Window_Command < Window_Selectable
def alignment
return 1
end
end
#==============================================================================
# ■ Window_ChoiceList
#------------------------------------------------------------------------------
# 此窗口使用于事件指令中的“显示选项”的功能。
#==============================================================================
############################################
# ● “选项命令”窗口的居中,“选项命令”宽度的修正
#来源 http://rm.66rpg.com/thread-233548-1-1.html
############################################
class Window_ChoiceList < Window_Command
# ● 更新窗口的位置
def update_placement
self.width = [max_choice_width + 12, 96].max + padding * 2
self.width = [width, Graphics.width].min
self.height = fitting_height($game_message.choices.size)
self.x = (Graphics.width - width) / 2 #选项窗口居中
if @message_window.y >= Graphics.height / 2
self.y = @message_window.y - height
else
self.y = @message_window.y + @message_window.height
end
end
# ● 获取选项的最大宽度,此处修"正控制符"对宽度的影响
def max_choice_width
$game_message.choices.collect {|s| pro_ex(s) }.max
end
def pro_ex(str)
s = convert_escape_characters(str)
pos = {:x => 0, :y => -Graphics.height, :new_x => 0, :height => calc_line_height(s)}
process_character(s.slice!(0, 1), s, pos) until s.empty?
pos[:x]
end
############################################
# ● 选项文字居中显示,一但使用此脚本,控制符就无法使用了
# 来源 http://rm.66rpg.com/forum.php?mod=viewthread&tid=386040
############################################
#~ def draw_item(index)
#~ rect = item_rect_for_text(index)
#~ draw_text(rect.x, rect.y, contents.width, line_height, command_name(index), 1)
#~ end
#~ def draw_item(index)
#~ rect = item_rect_for_text(index)
#~ draw_text_ex(rect.x, rect.y, command_name(index))
#~ end
end
#==============================================================================
# ■ Window_MenuCommand
#------------------------------------------------------------------------------
# 菜单画面中显示指令的窗口
#==============================================================================
############################################
# ● esc菜单中,去掉save与整队
############################################
class Window_MenuCommand < Window_Command
def make_command_list
add_main_commands
#~ add_formation_command # 整队命令 的字段
add_original_commands
#~ add_save_command # save 的字段
add_game_end_command
end
end
#==============================================================================
# ■ Vocab
#------------------------------------------------------------------------------
# 定义了用语和信息。将部分资料定义为常量。用语部分来自于 $data_system
#==============================================================================
############################################
# ● 重写 self.game_end 的显示名称
############################################
module Vocab
def self.game_end
return "系统"
end
end
#==============================================================================
# ■ Window_GameEnd
#------------------------------------------------------------------------------
# 游戏结束画面中,选择“返回标题/退出游戏”的窗口,现已改为【系统设置】
#==============================================================================
class Window_GameEnd < Window_Command
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
add_command(Vocab::save, :save, save_enabled) # 增加 存档命令
add_command(Vocab::continue, :continue, continue_enabled) # 增加 继续游戏
add_command(Vocab::to_title, :to_title)
add_command(Vocab::shutdown, :shutdown)
add_command(Vocab::cancel, :cancel)
end
#--------------------------------------------------------------------------
# ● 获取存档的有效状态
#--------------------------------------------------------------------------
############################################
# ● 这在原 Window_GameEnd类 中是没有的,
# 检查save命令是否有效,若无效,则灰色显示
############################################
def save_enabled
!$game_system.save_disabled
end
#--------------------------------------------------------------------------
# ● 获取“继续游戏”选项是否有效
#--------------------------------------------------------------------------
def continue_enabled
DataManager.save_file_exists?
end
end
#==============================================================================
# ■ Scene_End
#------------------------------------------------------------------------------
# 结束游戏画面
#==============================================================================
class Scene_End < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 生成指令窗口
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_GameEnd.new
@command_window.set_handler(:save, method(:command_save))#存档
@command_window.set_handler(:continue, method(:command_continue))#读档
@command_window.set_handler(:to_title, method(:command_to_title))
@command_window.set_handler(:shutdown, method(:command_shutdown))
@command_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# ● 指令“存档”
#--------------------------------------------------------------------------
############################################
# ● save 的功能部分
############################################
def command_save
SceneManager.call(Scene_Save)
end
#--------------------------------------------------------------------------
# ● 指令“继续游戏”
#--------------------------------------------------------------------------
def command_continue
close_command_window
SceneManager.call(Scene_Load)
end
#--------------------------------------------------------------------------
# ● 指令“返回”
#--------------------------------------------------------------------------
############################################
# ● 使用两个【SceneManager.return】
# 避免由【读档界面】回到游戏场景点击多次取消
############################################
def return_scene
close_command_window
SceneManager.return
SceneManager.return
end
end