#==============================================================================
# ■ Debug拓展VX版
# 作者IamI
#------------------------------------------------------------------------------
# 这个脚本的功能是:拓展Debug窗口的功能。
# 功能一:在Debug窗口当中添加“E”一条,允许修改事件的独立开关。
# 功能二:在Debug窗口按下shift键,将存档于一号档位。
# 功能三:在Debug窗口显示伪·FPS。并不是很准确。
# 功能四:允许在独立开关中做一些邪恶的事情。范例内效果很明显。
# 怨念:此脚本只是本人练习VX用,没想到这样一个脚本我也能磨蹭几个小时= =
# 啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊我退化了吗……
#==============================================================================
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
# 追加定义,取得地图ID
#==============================================================================
class Game_Map
attr_reader :map_id
end
#==============================================================================
# ■ Game_Event
#------------------------------------------------------------------------------
# 追加定义,开放Event。
#==============================================================================
class Game_Event
attr_reader :event
end
#==============================================================================
# ■ Game_SelfSwitches
#------------------------------------------------------------------------------
# 追加定义。使独立开关能够保存其他类型的值
#==============================================================================
NULLSTR = "Nil[OFF]"
class Game_SelfSwitches
#--------------------------------------------------------------------------
# ● 获取自我开关
# key : 键
#--------------------------------------------------------------------------
def [](key)
if @data[key] == nil
if key[2] == "A" or key[2] == "B" or key[2] == "C" or key[2] == "D"
return false
else
return NULLSTR
end
end
return @data[key]
end
end
#==============================================================================
# ■ Window_FPS
#------------------------------------------------------------------------------
# 伪·FPS计算窗
#==============================================================================
class Window_FPS < Window_Base
def initialize
super(424,366,120,50)
@time = Time.now
@fs = 0
@fps = 60
refresh
end
def update
@fs += 1
nt = Time.now
tc = (nt - @time)
if tc >= 1
@fps = @fs
@fs = 0
@time = nt
refresh
end
end
def refresh
self.contents.clear
self.contents.draw_text(self.contents.rect,"伪FPS:" + @fps.to_s)
end
end
#==============================================================================
# ■ Window_DebugLeft
#------------------------------------------------------------------------------
# 调试画面、指定开关及变量块的窗口。
#==============================================================================
class Window_DebugLeft < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对象
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 176, 416)
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
@switch_max = ($data_system.switches.size - 1 + 9) / 10
@variable_max = ($data_system.variables.size - 1 + 9) / 10
@item_max = @switch_max + @variable_max + $game_map.events.values.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
if index < @switch_max
n = index * 10
text = sprintf("S [%04d-%04d]", n+1, n+10)
elsif index < @variable_max + @switch_max
n = (index - @switch_max) * 10
text = sprintf("V [%04d-%04d]", n+1, n+10)
else
n = (index - @switch_max - @variable_max)
text = "E " + $game_map.events.values[n].event.name
end
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.draw_text(rect, text)
end
#--------------------------------------------------------------------------
# ● 获取模式
#--------------------------------------------------------------------------
def mode
if self.index < @switch_max
return 0
elsif self.index < @switch_max + @variable_max
return 1
else
return 2
end
end
#--------------------------------------------------------------------------
# ● 获取开头显示部分的 ID
#--------------------------------------------------------------------------
def top_id
if self.index < @switch_max
return self.index * 10 + 1
elsif self.index < @switch_max + @variable_max
return (self.index - @switch_max) * 10 + 1
else
return self.index - @switch_max - @variable_max
end
end
end
#==============================================================================
# ■ Window_DebugRight
#------------------------------------------------------------------------------
# 调试画面、单独显示开关以及变量的窗口。
#==============================================================================
class Window_DebugRight < Window_Selectable
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :mode # 模式 (0:开关、1:变量)
attr_reader :top_id # 最前显示部分的 ID
#--------------------------------------------------------------------------
# ● 初始化对象
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 368, 10 * WLH + 32)
self.index = -1
self.active = false
@item_max = 10
@mode = 0
@top_id = 1
@hash = {0 => "A",1 => "B",2 => "C",3 => "D",4 => "E",5 => "F",6 => "G",7 => "H",8 => "I",9 => "J"}
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
current_id = @top_id + index
id_text = sprintf("%04d:", current_id)
if @mode == 2
id_text = ""
end
id_width = self.contents.text_size(id_text).width
############################################
color = false
############################################
if @mode == 0
name = $data_system.switches[current_id]
status = $game_switches[current_id] ? "[ON]" : "[OFF]"
elsif @mode == 1
name = $data_system.variables[current_id]
status = $game_variables[current_id]
else
name = "独立开关" + @hash[index].to_s
status = $game_self_switches[[$game_map.map_id,@top_id + 1,@hash[index]]]
if status.is_a?(TrueClass) or status.is_a?(FalseClass)
status = status ? "[ON]" : "[OFF]"
else
unless status == NULLSTR
############
color = true
############
status = "[" + status.type.to_s + ":" + status.inspect + "]"
end
end
end
if name == nil
name = ""
end
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
if color == false
self.contents.font.color = normal_color
else
self.contents.font.color = system_color
end
self.contents.draw_text(rect, id_text)
rect.x += id_width
rect.width -= id_width + 60
self.contents.draw_text(rect, name)
rect.width += 60
self.contents.draw_text(rect, status, 2)
end
#--------------------------------------------------------------------------
# ● 设置模式
# id : 新模式
#--------------------------------------------------------------------------
def mode=(mode)
if @mode != mode
@mode = mode
refresh
end
end
#--------------------------------------------------------------------------
# ● 设置最先显示的 ID
# id : 新的 ID
#--------------------------------------------------------------------------
def top_id=(id)
if @top_id != id
@top_id = id
refresh
end
end
#--------------------------------------------------------------------------
# ● 囧方法,取得独立开关的三个数值,我实在懒得去逐个逐个算了……
#--------------------------------------------------------------------------
def tvt
return $game_map.map_id,@top_id + 1,@hash[self.index]
end
end
#==============================================================================
# ■ Scene_Debug
#------------------------------------------------------------------------------
# 处理调试画面的类。
#==============================================================================
class Scene_Debug < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_menu_background
@left_window = Window_DebugLeft.new(0, 0)
@right_window = Window_DebugRight.new(176, 0)
@help_window = Window_Base.new(176, 272, 368, 144)
@left_window.top_row = $game_temp.debug_top_row
@left_window.index = $game_temp.debug_index
@right_window.mode = @left_window.mode
@right_window.top_id = @left_window.top_id
@hash = {0 => "A",1 => "B",2 => "C",3 => "D",4 => "E",5 => "F",6 => "G",7 => "H",8 => "I",9 => "J"}
@fps_shower = Window_FPS.new
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
$game_map.refresh
@left_window.dispose
@right_window.dispose
@help_window.dispose
@fps_shower.dispose
$game_map.need_refresh = true
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_menu_background
@right_window.mode = @left_window.mode
@right_window.top_id = @left_window.top_id
@left_window.update
@right_window.update
@fps_shower.update
$game_temp.debug_top_row = @left_window.top_row
$game_temp.debug_index = @left_window.index
if @left_window.active
update_left_input
elsif @right_window.active
update_right_input
end
if Input.trigger?(Input::SHIFT)
Sound.play_decision
file = File.open("Save1.rvdata", "wb")
write_save_data(file)
file.close
wlh = 24
@help_window.contents.clear
@help_window.contents.draw_text(4, wlh * 0, 336, wlh, "已保存于一号档。")
end
end
#--------------------------------------------------------------------------
# ● 更新左侧窗口的输入
#--------------------------------------------------------------------------
def update_left_input
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
return
elsif Input.trigger?(Input::C)
Sound.play_decision
wlh = 24
if @left_window.mode == 0
text1 = "C (Enter) : ON / OFF"
@help_window.contents.draw_text(4, 0, 336, wlh, text1)
elsif @left_window.mode == 1
text1 = "← (Left) : -1"
text2 = "→ (Right) : +1"
text3 = "L (Pageup) : -10"
text4 = "R (Pagedown) : +10"
@help_window.contents.clear_rect(4, wlh * 0, 336, wlh)
@help_window.contents.draw_text(4, wlh * 0, 336, wlh, text1)
@help_window.contents.draw_text(4, wlh * 1, 336, wlh, text2)
@help_window.contents.draw_text(4, wlh * 2, 336, wlh, text3)
@help_window.contents.draw_text(4, wlh * 3, 336, wlh, text4)
else
text1 = "C (Enter) : ON / OFF"
@help_window.contents.draw_text(4, 0, 336, wlh, text1)
end
@left_window.active = false
@right_window.active = true
@right_window.index = 0
end
end
#--------------------------------------------------------------------------
# ● 更新右侧窗口的输入
#--------------------------------------------------------------------------
def update_right_input
if Input.trigger?(Input::B)
Sound.play_cancel
@left_window.active = true
@right_window.active = false
@right_window.index = -1
@help_window.contents.clear
else
current_id = @right_window.top_id + @right_window.index
if @right_window.mode == 0
if Input.trigger?(Input::C)
Sound.play_decision
$game_switches[current_id] = (not $game_switches[current_id])
@right_window.refresh
end
elsif @right_window.mode == 1
last_value = $game_variables[current_id]
if Input.repeat?(Input::RIGHT)
$game_variables[current_id] += 1
elsif Input.repeat?(Input::LEFT)
$game_variables[current_id] -= 1
elsif Input.repeat?(Input::R)
$game_variables[current_id] += 10
elsif Input.repeat?(Input::L)
$game_variables[current_id] -= 10
end
if $game_variables[current_id] > 99999999
$game_variables[current_id] = 99999999
elsif $game_variables[current_id] < -99999999
$game_variables[current_id] = -99999999
end
if $game_variables[current_id] != last_value
Sound.play_cursor
@right_window.draw_item(@right_window.index)
end
elsif @right_window.mode == 2
if Input.trigger?(Input::C)
Sound.play_decision
$game_self_switches[@right_window.tvt] = (not $game_self_switches[@right_window.tvt])
@right_window.refresh
end
end
end
end
#--------------------------------------------------------------------------
# ● 写入存档数据
# file : 写入文件用对象 (已经打开)
#--------------------------------------------------------------------------
def write_save_data(file)
characters = []
for actor in $game_party.members
characters.push([actor.character_name, actor.character_index])
end
$game_system.save_count += 1
$game_system.version_id = $data_system.version_id
@last_bgm = RPG::BGM::last
@last_bgs = RPG::BGS::last
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
Marshal.dump(@last_bgm, file)
Marshal.dump(@last_bgs, file)
Marshal.dump($game_system, file)
Marshal.dump($game_message, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
end