# デバッグウインドウ強化スクリプト v1.00 by tonbi # # ・できること # # このスクリプトを使用することで、テストプレイ時にF9押して出てくる # デバッグウインドウの機能を強化します。 # 具体的には、アイテム、武器、防具、所持金、歩数、タイマーの操作機能追加。 # さらに、変数の操作の操作性向上(僕的には(w) # # # ・使い方 # # このスクリプトを、Seane_Debug より下、Main より上に新規セッション作って # そこに貼り付けてください。 # # #============================================================================== # ■ Window_Selectable_tonbi6 # キー押し時の動作変更版 #============================================================================== class Window_Selectable_tonbi6 < Window_Base #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :index # カーソル位置 attr_reader :help_window # ヘルプウィンドウ #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 # width : ウィンドウの幅 # height : ウィンドウの高さ #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) @item_max = 1 @column_max = 1 @index = -1 end #-------------------------------------------------------------------------- # ● カーソル位置の設定 # index : 新しいカーソル位置 #-------------------------------------------------------------------------- def index=(index) @index = index # ヘルプテキストを更新 (update_help は継承先で定義される) if self.active and @help_window != nil update_help end # カーソルの矩形を更新 update_cursor_rect end #-------------------------------------------------------------------------- # ● 行数の取得 #-------------------------------------------------------------------------- def row_max # 項目数と列数から行数を算出 return (@item_max + @column_max - 1) / @column_max end #-------------------------------------------------------------------------- # ● 先頭の行の取得 #-------------------------------------------------------------------------- def top_row # ウィンドウ内容の転送元 Y 座標を、1 行の高さ 32 で割る return self.oy / 32 end #-------------------------------------------------------------------------- # ● 先頭の行の設定 # row : 先頭に表示する行 #-------------------------------------------------------------------------- def top_row=(row) # row が 0 未満の場合は 0 に修正 if row < 0 row = 0 end # row が row_max - 1 超の場合は row_max - 1 に修正 if row > row_max - 1 row = row_max - 1 end # row に 1 行の高さ 32 を掛け、ウィンドウ内容の転送元 Y 座標とする self.oy = row * 32 end #-------------------------------------------------------------------------- # ● 1 ページに表示できる行数の取得 #-------------------------------------------------------------------------- def page_row_max # ウィンドウの高さから、フレームの高さ 32 を引き、1 行の高さ 32 で割る return (self.height - 32) / 32 end #-------------------------------------------------------------------------- # ● 1 ページに表示できる項目数の取得 #-------------------------------------------------------------------------- def page_item_max # 行数 page_row_max に 列数 @column_max を掛ける return page_row_max * @column_max end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの設定 # help_window : 新しいヘルプウィンドウ #-------------------------------------------------------------------------- def help_window=(help_window) @help_window = help_window # ヘルプテキストを更新 (update_help は継承先で定義される) if self.active and @help_window != nil update_help end end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect # カーソル位置が 0 未満の場合 if @index < 0 self.cursor_rect.empty return end # 現在の行を取得 row = @index / @column_max # 現在の行が、表示されている先頭の行より前の場合 if row < self.top_row # 現在の行が先頭になるようにスクロール self.top_row = row end # 現在の行が、表示されている最後尾の行より後ろの場合 if row > self.top_row + (self.page_row_max - 1) # 現在の行が最後尾になるようにスクロール self.top_row = row - (self.page_row_max - 1) end # カーソルの幅を計算 cursor_width = self.width / @column_max - 32 # カーソルの座標を計算 x = @index % @column_max * (cursor_width + 32) y = @index / @column_max * 32 - self.oy # カーソルの矩形を更新 self.cursor_rect.set(x, y, cursor_width, 32) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # カーソルの移動が可能な状態の場合 if self.active and @item_max > 0 and @index >= 0 # 方向ボタンの下が押された場合 if Input.repeat?(Input::DOWN) # 列数が 1 かつ 方向ボタンの下の押下状態がリピートでない場合か、 # またはカーソル位置が(項目数 - 列数)より前の場合 if (@column_max == 1 and Input.trigger?(Input::DOWN)) or @index < @item_max - @column_max # カーソルを下に移動 $game_system.se_play($data_system.cursor_se) @index = (@index + @column_max) % @item_max end end # 方向ボタンの上が押された場合 if Input.repeat?(Input::UP) # 列数が 1 かつ 方向ボタンの上の押下状態がリピートでない場合か、 # またはカーソル位置が列数より後ろの場合 if (@column_max == 1 and Input.trigger?(Input::UP)) or @index >= @column_max # カーソルを上に移動 $game_system.se_play($data_system.cursor_se) @index = (@index - @column_max + @item_max) % @item_max end end # 方向ボタンの右が押された場合(変更) if Input.repeat?(Input::RIGHT) # 表示されている最後尾の行が、データ上の最後の行よりも前の場合 if self.top_row + (self.page_row_max - 1) < (self.row_max - 1) # カーソルを 1 ページ後ろに移動 $game_system.se_play($data_system.cursor_se) @index = [@index + self.page_item_max, @item_max - 1].min self.top_row += self.page_row_max end end # 方向ボタンの左が押された場合(変更) if Input.repeat?(Input::LEFT) # 表示されている先頭の行が 0 より後ろの場合 if self.top_row > 0 # カーソルを 1 ページ前に移動 $game_system.se_play($data_system.cursor_se) @index = [@index - self.page_item_max, 0].max self.top_row -= self.page_row_max end end end # ヘルプテキストを更新 (update_help は継承先で定義される) if self.active and @help_window != nil update_help end # カーソルの矩形を更新 update_cursor_rect end end #============================================================================== # ■ Window_DebugLeft #------------------------------------------------------------------------------ #  デバッグ画面で、スイッチや変数のブロックを指定するウィンドウです。 #============================================================================== class Window_DebugLeft < Window_Selectable_tonbi6 attr_accessor :textlist attr_accessor :textcnt attr_accessor :helptext #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 192, 480) self.index = 0 @textlist = [] @textcnt = 0 @helptext = "表示中・・・しばらくお持ちください" refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end # いろんなデータの必要ページ数取得 @switch_max = ($data_system.switches.size - 1 + 9) / 10 @variable_max = ($data_system.variables.size - 1 + 9) / 10 @items_max = ($data_items.size - 1 + 9) / 10 @weapons_max = ($data_weapons.size - 1 + 9) / 10 @armors_max = ($data_armors.size - 1 + 9) / 10 @systems_max = 1 @item_max = @switch_max + @variable_max + @items_max @item_max += @weapons_max + @armors_max + @systems_max self.contents = Bitmap.new(width - 32, @item_max * 32) # 項目リストに項目追加 for i in 0...@switch_max @textlist.push(sprintf("スイッチ [%04d-%04d]", i*10+1, i*10+10)) end for i in 0...@variable_max @textlist.push(sprintf("変数 [%04d-%04d]", i*10+1, i*10+10)) end for i in 0...@items_max @textlist.push(sprintf("道具 [%03d-%03d]", i*10+1, i*10+10)) end for i in 0...@weapons_max @textlist.push(sprintf("武器 [%03d-%03d]", i*10+1, i*10+10)) end for i in 0...@armors_max @textlist.push(sprintf("防具 [%03d-%03d]", i*10+1, i*10+10)) end for i in 0...@systems_max @textlist.push(sprintf("その他", i*10+1, i*10+10)) end # 15個だけ項目描画 draw_next(15) end #-------------------------------------------------------------------------- # ● アップデート #-------------------------------------------------------------------------- def update reverse = draw_next(1) super return reverse end #-------------------------------------------------------------------------- # ● 項目描画を進める #-------------------------------------------------------------------------- def draw_next(cnt) for i in 0...cnt if @textcnt < @item_max self.contents.draw_text(4, @textcnt * 32, 152, 32,@textlist[@textcnt]) @textcnt += 1 if @textcnt == @item_max @helptext = "" # 終わった瞬間だけ true を返す return true end end end return false end #-------------------------------------------------------------------------- # ● モードの取得 #-------------------------------------------------------------------------- def mode if self.index < list_indent(1) return 0 # スイッチ elsif self.index < list_indent(2) return 1 # 変数 elsif self.index < list_indent(3) return 2 # アイテム elsif self.index < list_indent(4) return 3 # 武器 elsif self.index < list_indent(5) return 4 # 防具 elsif self.index < list_indent(6) return 5 # その他 end end #-------------------------------------------------------------------------- # ● 先頭に表示する ID の取得 #-------------------------------------------------------------------------- def top_id return (self.index - list_indent(self.mode)) * 10 + 1 end #-------------------------------------------------------------------------- # ● 指定種類までの合計 #-------------------------------------------------------------------------- def list_indent(id) if id >= 0 stat = 0 end if id >= 1 stat += @switch_max end if id >= 2 stat += @variable_max end if id >= 3 stat += @items_max end if id >= 4 stat += @weapons_max end if id >= 5 stat += @armors_max end if id >= 6 stat += @systems_max end return stat end end #============================================================================== # ■ Window_DebugRight #------------------------------------------------------------------------------ #  デバッグ画面で、スイッチや変数を個別に表示するウィンドウです。 #============================================================================== class Window_DebugRight < Window_Selectable #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :mode # モード (0:スイッチ、1:変数) attr_reader :top_id # 先頭に表示する ID #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(192, 0, 448, 352) self.contents = Bitmap.new(width - 32, height - 32) self.index = -1 self.active = false @item_max = 10 @mode = 0 @top_id = 1 refresh end #-------------------------------------------------------------------------- # ● リフレッシュ(リスト作成) #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0..9 case @mode when 0 name = $data_system.switches[@top_id+i] status = $game_switches[@top_id+i] ? "[ON]" : "[OFF]" when 1 name = $data_system.variables[@top_id+i] status = $game_variables[@top_id+i].to_s when 2 if $data_items[@top_id+i] != nil name = $data_items[@top_id+i].name else name = nil end status = $game_party.item_number(@top_id+i).to_s when 3 if $data_weapons[@top_id+i] != nil name = $data_weapons[@top_id+i].name else name = nil end status = $game_party.weapon_number(@top_id+i).to_s when 4 if $data_armors[@top_id+i] != nil name = $data_armors[@top_id+i].name else name = nil end status = $game_party.armor_number(@top_id+i).to_s when 5 case i when 0 name = "所持金" status = $game_party.gold.to_s when 1 name = "歩数" status = $game_party.steps.to_s when 2 name = "タイマー" status = $game_system.timer.to_s else name = nil status = '' end end if name == nil name = '' end id_text = sprintf("%04d:", @top_id+i) width = self.contents.text_size(id_text).width self.contents.draw_text(4, i * 32, width, 32, id_text) self.contents.draw_text(12 + width, i * 32, 296 - width, 32, name) self.contents.draw_text(312, i * 32, 100, 32, status, 2) end 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 end #============================================================================== # ■ Scene_Debug #------------------------------------------------------------------------------ #  デバッグ画面の処理を行うクラスです。 #============================================================================== class Scene_Debug #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # ウィンドウを作成 @left_window = Window_DebugLeft.new @right_window = Window_DebugRight.new @help_window = Window_Base.new(192, 352, 448, 128) @help_window.contents = Bitmap.new(406, 96) # 数値入力ウインドウ作成 >> 隠す @input_window = Window_InputNumber_tonbi6.new(8) @input_window.visible = false @input_window.opacity = 255 # 前回選択されていた項目を復帰 @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 # ヘルプを表示 @help_window.contents.clear text1 = "左[前ページ] 右[次ページ]" text2 = "L[前の項目] R[次の項目]" text3 = @left_window.helptext @help_window.contents.draw_text(4, 0, 406, 32, text1) @help_window.contents.draw_text(4, 32, 406, 32, text2) @help_window.contents.draw_text(4, 64, 406, 32, text3) # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # マップをリフレッシュ $game_map.refresh # トランジション準備 Graphics.freeze # ウィンドウを解放 @left_window.dispose @right_window.dispose @help_window.dispose @input_window.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ウィンドウを更新 @right_window.mode = @left_window.mode @right_window.top_id = @left_window.top_id if @left_window.update if @left_window.active @help_window.contents.clear text1 = "左[前ページ] 右[次ページ]" text2 = "L[前の項目] R[次の項目]" text3 = @left_window.helptext @help_window.contents.draw_text(4, 0, 406, 32, text1) @help_window.contents.draw_text(4, 32, 406, 32, text2) @help_window.contents.draw_text(4, 64, 406, 32, text3) end end @right_window.update # 選択中の項目を記憶 $game_temp.debug_top_row = @left_window.top_row $game_temp.debug_index = @left_window.index # レフトウィンドウがアクティブの場合: update_left を呼ぶ if @left_window.active update_left return end # ライトウィンドウがアクティブの場合: update_right を呼ぶ if @right_window.active update_right return end # インプットウィンドウがアクティブの場合: update_input を呼ぶ if @input_window.active update_input return end end #-------------------------------------------------------------------------- # ● フレーム更新 (レフトウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_left # 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) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # ヘルプを表示 if @left_window.mode == 0 @help_window.contents.clear text1 = "C (Enter) : ON / OFF" @help_window.contents.draw_text(4, 0, 406, 32, text1) else @help_window.contents.clear text1 = "決定(C) : 直接入力" text2 = "Lボタン : 最小値" text3 = "Rボタン : 最大値" @help_window.contents.draw_text(4, 0, 406, 32, text1) @help_window.contents.draw_text(4, 32, 406, 32, text2) @help_window.contents.draw_text(4, 64, 406, 32, text3) end # ライトウィンドウをアクティブ化 @left_window.active = false @right_window.active = true @right_window.index = 0 return end if Input.trigger?(Input::L) # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) @left_window.index = @left_window.list_indent((@left_window.mode-1+6)%6) return end if Input.trigger?(Input::R) # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) @left_window.index = @left_window.list_indent((@left_window.mode+1+6)%6) return end end #-------------------------------------------------------------------------- # ● フレーム更新 (ライトウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_right # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # レフトウィンドウをアクティブ化 @left_window.active = true @right_window.active = false @right_window.index = -1 # ヘルプを再表示 @help_window.contents.clear text1 = "左[前ページ] 右[次ページ]" text2 = "L[前の項目] R[次の項目]" text3 = @left_window.helptext @help_window.contents.draw_text(4, 0, 406, 32, text1) @help_window.contents.draw_text(4, 32, 406, 32, text2) @help_window.contents.draw_text(4, 64, 406, 32, text3) return end # 選択されているスイッチ / 変数の ID を取得 current_id = @right_window.top_id + @right_window.index # スイッチの場合 case @right_window.mode when 0 # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # ON / OFF を反転 $game_switches[current_id] = (not $game_switches[current_id]) @right_window.refresh return end else if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) setnumber = nil case @right_window.mode when 1 setnumber = $game_variables[current_id] needlabel = true digits_max = 9 when 2 setnumber = $game_party.item_number(current_id) needlabel = false digits_max = 2 when 3 setnumber = $game_party.weapon_number(current_id) needlabel = false digits_max = 2 when 4 setnumber = $game_party.armor_number(current_id) needlabel = false digits_max = 2 when 5 case current_id when 1 setnumber = $game_party.gold needlabel = false digits_max = 7 when 2 setnumber = $game_party.steps needlabel = false digits_max = 7 when 3 setnumber = $game_system.timer needlabel = false digits_max = 7 end end if setnumber != nil # インプットウインドウをアクティブにする @input_window.dispose @input_window = Window_InputNumber_tonbi6.new(digits_max,needlabel) @input_window.y = @right_window.index * 32 @input_window.x = 640 -16- @input_window.width @input_window.number = setnumber @input_window.active = true @input_window.visible = true @right_window.active = false end elsif Input.trigger?(Input::L) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 最大まで増やす setstat(@right_window.mode,current_id,-999999999) @right_window.refresh elsif Input.trigger?(Input::R) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 最小まで減らす setstat(@right_window.mode,current_id,999999999) @right_window.refresh end end end #-------------------------------------------------------------------------- # ● フレーム更新 (インプットウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_input @input_window.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # ライトウィンドウをアクティブ化 @right_window.active = true @input_window.active = false @input_window.visible = false return end # 選択されている ID を取得 current_id = @right_window.top_id + @right_window.index # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 値の取得 updown_number = @input_window.number setstat(@right_window.mode,current_id,updown_number) @right_window.refresh @right_window.active = true @input_window.active = false @input_window.visible = false return end end #-------------------------------------------------------------------------- # ● 各種データ増減 #-------------------------------------------------------------------------- def setstat(mode,current_id,updown_number) case mode when 1 # 変数を 増減 $game_variables[current_id] = 0 $game_variables[current_id] += updown_number # 上限チェック if $game_variables[current_id] > 99999999 $game_variables[current_id] = 99999999 end # 下限チェック if $game_variables[current_id] < -99999999 $game_variables[current_id] = -99999999 end when 2 # アイテムを増減 $game_party.gain_item(current_id,-99999999) $game_party.gain_item(current_id,updown_number) when 3 # 武器を増減 $game_party.gain_weapon(current_id,-99999999) $game_party.gain_weapon(current_id,updown_number) when 4 # 防具を増減 $game_party.gain_armor(current_id,-99999999) $game_party.gain_armor(current_id,updown_number) when 5 case current_id when 1 $game_party.gain_gold($game_party.gold*-1) $game_party.gain_gold(updown_number) when 2 $game_party.steps = [[0,updown_number].max,9999999].min when 3 $game_system.timer = [[0,updown_number].max,9999999].min end end end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party attr_accessor :steps # 歩数(外部操作可能に) end #============================================================================== # ■ Window_InputNumber_tonbi6 #------------------------------------------------------------------------------ #  符号サポート版 #============================================================================== class Window_InputNumber_tonbi6 < Window_Base attr_accessor :index # 選択位置 attr_accessor :digits_max # 桁数 attr_accessor :needlabel # 符号使用フラグ #-------------------------------------------------------------------------- # ● オブジェクト初期化 # digits_max : 桁数 #-------------------------------------------------------------------------- def initialize(digits_max,needlabel = false) @digits_max = digits_max @number = 0 # 数字の幅からカーソルの幅を計算 (0〜9 は等幅と仮定) dummy_bitmap = Bitmap.new(32, 32) @cursor_width = dummy_bitmap.text_size("0").width + 8 dummy_bitmap.dispose super(0, 0, @cursor_width * @digits_max + 32, 64) self.contents = Bitmap.new(width - 32, height - 32) self.z += 9999 self.opacity = 255 @index = digits_max-1 @needlabel = needlabel @label = true refresh update_cursor_rect end #-------------------------------------------------------------------------- # ● 数値の取得 #-------------------------------------------------------------------------- def number if @needlabel == true if @label == false @number *= -1 end end return @number end #-------------------------------------------------------------------------- # ● 数値の設定 # number : 新しい数値 #-------------------------------------------------------------------------- def number=(number) if @needlabel == true @label = true if number < 0 number *= -1 @label = false end @number = [[number, 0].max, 10 ** (@digits_max-1) - 1].min else @number = [[number, 0].max, 10 ** @digits_max - 1].min end refresh end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect self.cursor_rect.set(@index * @cursor_width, 0, @cursor_width, 32) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # 方向ボタンの上か下が押された場合 if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN) $game_system.se_play($data_system.cursor_se) if @index == 0 and @needlabel == true if @label == false @label = true else @label =false end else # 現在の位の数字を取得し、いったん 0 にする place = 10 ** (@digits_max - 1 - @index) n = @number / place % 10 @number -= n * place # 上なら +1、下なら -1 n = (n + 1) % 10 if Input.repeat?(Input::UP) n = (n + 9) % 10 if Input.repeat?(Input::DOWN) # 現在の位の数字を再設定 @number += n * place end refresh end # カーソル右 if Input.repeat?(Input::RIGHT) if @digits_max >= 2 $game_system.se_play($data_system.cursor_se) @index = (@index + 1) % @digits_max end end # カーソル左 if Input.repeat?(Input::LEFT) if @digits_max >= 2 $game_system.se_play($data_system.cursor_se) @index = (@index + @digits_max - 1) % @digits_max end end update_cursor_rect end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.color = normal_color s = sprintf("%0*d", @digits_max, @number) for i in 0...@digits_max if i == 0 and @needlabel == true if @label == false self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, "-") else self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, "+") end else self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1]) end end end end