Project1
标题:
F9调试窗口加强
[打印本页]
作者:
IamI
时间:
2008-8-29 18:48
标题:
F9调试窗口加强
昨天晚上闲来无事,拿VX来研究,发现功能果然比XP强大(除了画风以外……)
练习脚本的时候就写了这么个东西,恩,就是这样,
截图:
功能4条:
功能一:在Debug窗口当中添加“E”一条,允许修改事件的独立开关。
功能二:在Debug窗口按下shift键,将存档于一号档位。
功能三:在Debug窗口显示伪·FPS。并不是很准确。
功能四:允许在独立开关中做一些邪恶的事情。范例内效果很明显
范例:
http://rpg.blue/upload_program/files/Debugging_100434961.rar
脚本:
#==============================================================================
# ■ 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
复制代码
恩,附带练习正则表达式的时候对话加强脚本一只:
#==============================================================================
# ■ 信息显示Orz版
#------------------------------------------------------------------------------
# 功能很简单,实现更简单
# \B 加粗开始
# \b 加粗中断
# \I 倾斜开始
# \i 倾斜中断
# \S 阴影开始
# \s 阴影中断
# \oC[r,g,b] 将颜色设成RGB。
#==============================================================================
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
# 显示文章的信息窗口。
#==============================================================================
class Window_Message
#--------------------------------------------------------------------------
# ● 特殊文字变换
#--------------------------------------------------------------------------
alias oooooorz_convert_special_characters convert_special_characters
def convert_special_characters
oooooorz_convert_special_characters
@text.gsub!(/\\B/) { "\x09" }
@text.gsub!(/\\b/) { "\x10" }
@text.gsub!(/\\I/) { "\x11" }
@text.gsub!(/\\i/) { "\x12" }
@text.gsub!(/\\S/) { "\x13" }
@text.gsub!(/\\s/) { "\x14" }
#@text.gsub!(/\\oC\[([0-255]+)\,([0-255]+)\,([0-255]+)\/i]) { "\x15[#{$1},#{$2},#{$3}]"}
@text.gsub!(/\\oC\[([0-9]+)\,([0-9]+)\,([0-9]+)\]/i) { "\x15[#{$1},#{$2},#{$3}]" }
end
#--------------------------------------------------------------------------
# ● 更新消息
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # 获取下一条文字
case c
when nil # 没有可以显示的文字
finish_message # 更新结束
break
when "\x00" # 换行
new_line
if @line_count >= MAX_LINE # 行数为最大时
unless @text.empty? # 如果还有增加则继续
self.pause = true # 等待输入
break
end
end
when "\x01" # \C[n] (更改文字色)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x02" # \G (显示所持金)
@gold_window.refresh
@gold_window.open
when "\x03" # \. (等待 1/4 秒)
@wait_count = 15
break
when "\x04" # \| (等待 1 秒)
@wait_count = 60
break
when "\x05" # \! (等待输入)
self.pause = true
break
when "\x06" # \> (瞬间显示 ON)
@line_show_fast = true
when "\x07" # \< (瞬间显示 OFF)
@line_show_fast = false
when "\x08" # \^ (不等待输入)
@pause_skip = true
##############################################
when "\x09"
self.contents.font.bold = true
when "\x10"
self.contents.font.bold = false
when "\x11"
self.contents.font.italic = true
when "\x12"
self.contents.font.italic = false
when "\x13"
self.contents.font.shadow = true
when "\x14"
self.contents.font.shadow = false
when "\x15" # \C[n] (更改文字色)
@text.sub!(/\[([0-9]+)\,([0-9]+)\,([0-9]+)\]/, "")
contents.font.color = Color.new($1.to_i,$2.to_i,$3.to_i)
next
##############################################
else # 普通文字
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
end
复制代码
就是这样……
作者:
越前リョーマ
时间:
2008-8-29 20:09
竟然到J了…… = =
作者:
trentswd
时间:
2008-8-29 21:06
好奇独立开关后面几个东西怎么各种数据类型都有了OTZ
好物……膜拜……收走
作者:
火鸡三毛老大
时间:
2008-8-29 21:33
汗……
DEBUG还显示FPS干什么……
直接按F2即可……
作者:
IamI
时间:
2008-8-29 21:37
以下引用
火鸡三毛老大于2008-8-29 13:33:33
的发言:
汗……
DEBUG还显示FPS干什么……
直接按F2即可……
这……这……本来写上去只是为了检验上次yangff计算FPS的方法是不是准……结论是……不准{/ll}
这渣去掉很方便的。
作者:
木葬枫
时间:
2009-1-3 19:08
发布完毕 VIP + 2
发布地址:http://rpg.blue/web/htm/news1233.htm
作者:
DeathKing
时间:
2009-7-26 14:28
有了调试独立开关的东西……这的确是个强物。
同意4#,F2王道
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1