Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- #
- # Pacman Advanced Creative (PAC) Engine - Debug Scene
- # 13/6/2011
- # Type: Scene/Menu
- # Installation: Hashes.
- # Level: Average, Difficult
- #
- #===============================================================================
- #
- # Description:
- # RPG Maker VX comes with a debug menu that activates when you press F9 and are
- # in test mode. It gives you a list of switches and variables that you can
- # alter. This enhanced debug scene will give you a clearer overview of the
- # switches and variables in your game, and will give you power to activate a
- # common event with a quick shortcut.
- #
- #===============================================================================
- #
- # Instructions:
- # INSTALLATION
- # Paste above main, below materials in the script editor (F11). Remember to
- # save upon exiting. Compatible with, but not dependent on, all other PAC
- # scripts. *NOTE* Do not press common event shortcuts you are not using if you
- # are using PAC Lag Reduction. It will throw you a nasty syntax error.
- # USAGE
- # To enter the debug scene, press F9 when in test mode. To activate
- # predetermined common events in test mode, press SHIFT, CRTL or ALT and the
- # designated F5-F9 button.
- # CONFIGURATION
- # Detailed instructions on the setup of the script begin at line 39.
- #
- #===============================================================================
- module PAC
- module MENU
- #===============================================================================
- # Define common event shortcuts to launch during test play mode and pressing
- # the right shortcut combination here.
- #===============================================================================
- ALT ={ # When pressing ALT and:
- :f5 => 2, # F5, this common event will run.
- :f6 => 32, # F6, this common event will run.
- :f7 => 33, # F7, this common event will run.
- :f8 => 34, # F8, this common event will run.
- :f9 => 35, # F9, this common event will run.
- } # No touchy.
- CTRL ={ # When pressing CTRL and:
- :f5 => 36, # F5, this common event will run.
- :f6 => 37, # F6, this common event will run.
- :f7 => 38, # F7, this common event will run.
- :f8 => 39, # F8, this common event will run.
- :f9 => 40, # F9, this common event will run.
- } # No touchy.
- SHIFT ={ # When pressing SHIFT and:
- :f5 => 41, # F5, this common event will run.
- :f6 => 42, # F6, this common event will run.
- :f7 => 43, # F7, this common event will run.
- :f8 => 44, # F8, this common event will run.
- :f9 => 45, # F9, this common event will run.
- } # No touchy.
- #===============================================================================
- # The following adjust debug menu data. There's pretty much no reason to edit
- # this stuff, but just to see if you can...
- #===============================================================================
- DEBUG_NAME = "Debug" # The name of the option if used with PAC Main Menu.
- COMMANDS =[ # The commands and the order they appear in the debug scene.
- :switches, # Switches command,
- :variables, # Variables command.
- ] # No touchy.
- VOCAB ={ # The words displayed in the commands.
- :switches => "Switches", # Word for switches,
- :variables => "Variables",# Word for variables.
- } # No touchy.
- #===============================================================================
- # STOP EDITING.
- #===============================================================================
- end # MENU
- end # PAC
- #==============================================================================
- # ** Scene_Map
- #------------------------------------------------------------------------------
- # This class performs the map screen processing.
- #==============================================================================
- class Scene_Map < Scene_Base
- #--------------------------------------------------------------------------
- # * Update Call Debug
- #--------------------------------------------------------------------------
- def update_call_debug
- return unless $TEST
- if Input.trigger?(Input::F5)
- if Input.press?(Input::ALT)
- $game_temp.common_event_id = PAC::MENU::ALT[:f5]
- elsif Input.press?(Input::CTRL)
- $game_temp.common_event_id = PAC::MENU::CTRL[:f5]
- elsif Input.press?(Input::SHIFT)
- $game_temp.common_event_id = PAC::MENU::SHIFT[:f5]
- end
- elsif Input.trigger?(Input::F6)
- if Input.press?(Input::ALT)
- $game_temp.common_event_id = PAC::MENU::ALT[:f6]
- elsif Input.press?(Input::CTRL)
- $game_temp.common_event_id = PAC::MENU::CTRL[:f6]
- elsif Input.press?(Input::SHIFT)
- $game_temp.common_event_id = PAC::MENU::SHIFT[:f6]
- end
- elsif Input.trigger?(Input::F7)
- if Input.press?(Input::ALT)
- $game_temp.common_event_id = PAC::MENU::ALT[:f7]
- elsif Input.press?(Input::CTRL)
- $game_temp.common_event_id = PAC::MENU::CTRL[:f7]
- elsif Input.press?(Input::SHIFT)
- $game_temp.common_event_id = PAC::MENU::SHIFT[:f7]
- end
- elsif Input.trigger?(Input::F8)
- if Input.press?(Input::ALT)
- $game_temp.common_event_id = PAC::MENU::ALT[:f8]
- elsif Input.press?(Input::CTRL)
- $game_temp.common_event_id = PAC::MENU::CTRL[:f8]
- elsif Input.press?(Input::SHIFT)
- $game_temp.common_event_id = PAC::MENU::SHIFT[:f8]
- end
- elsif Input.trigger?(Input::F9)
- if Input.press?(Input::ALT)
- $game_temp.common_event_id = PAC::MENU::ALT[:f9]
- elsif Input.press?(Input::CTRL)
- $game_temp.common_event_id = PAC::MENU::CTRL[:f9]
- elsif Input.press?(Input::SHIFT)
- $game_temp.common_event_id = PAC::MENU::SHIFT[:f9]
- else
- Sound.play_decision
- $game_temp.next_scene = "debug"
- end
- end
- end
- end
- #==============================================================================
- # ** Window_DebugSwitches
- #------------------------------------------------------------------------------
- # This window is used to display switches in the debug screen.
- #==============================================================================
- class Window_DebugSwitches < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(page, info_window)
- super(160, 0, Graphics.width - 160, 272)
- self.index = 0
- @info_window = info_window
- refresh(page)
- end
- #--------------------------------------------------------------------------
- # * Switch
- #--------------------------------------------------------------------------
- def switch
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # * Update Info Window
- #--------------------------------------------------------------------------
- def update_info_window
- @info_window.contents.clear
- sw = @info_window.width - 32
- value1 = @page*10+1
- value2 = [@page*10+10, $data_system.variables.size-1].min
- text1 = sprintf("Switches %d to %d", value1, value2)
- text2 = "Press L or Left to page backward."
- text3 = "Press R or Right to page forward."
- text4 = "Press Z to toggle switch."
- @info_window.contents.draw_text(0, WLH*0, sw, WLH, text1, 1)
- @info_window.contents.draw_text(0, WLH*1+8, sw, WLH, text2, 1)
- @info_window.contents.draw_text(0, WLH*2+8, sw, WLH, text3, 1)
- @info_window.contents.draw_text(0, WLH*3+8, sw, WLH, text4, 1)
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh(page)
- @data = []; @page = page
- update_info_window
- for i in (@page*10+1)..(@page*10+10); @data.push(i); end
- @item_max = @data.size
- create_contents
- for i in 0..(@item_max-1)
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- self.contents.font.color = normal_color
- switch_id = @data[index]
- rect.x += 4
- rect.width -= 8
- if switch_id > $data_system.switches.size-1
- self.contents.font.color.alpha = 128
- self.contents.draw_text(rect.x, rect.y, rect.width, WLH, "N/A")
- return
- end
- name = $data_system.switches[switch_id]
- self.contents.font.color.alpha = name == "" ? 128 : 255
- if $game_switches[switch_id]
- if name == ""
- self.contents.font.color = knockout_color
- name = "ATTENTION"
- else
- self.contents.font.color = crisis_color
- end
- end
- name = "Undefined" if name == ""
- text = sprintf("S%04d:%s", switch_id, name)
- value = $game_switches[switch_id] ? "[ON]" : "[OFF]"
- self.contents.draw_text(rect.x, rect.y, rect.width, WLH, text, 0)
- self.contents.draw_text(rect.x, rect.y, rect.width, WLH, value, 2)
- end
- end
- #==============================================================================
- # ** Window_DebugVariables
- #------------------------------------------------------------------------------
- # This window is used to display variables in the debug screen.
- #==============================================================================
- class Window_DebugVariables < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(page, info_window)
- super(160, 0, Graphics.width - 160, 272)
- self.index = 0
- @info_window = info_window
- refresh(page)
- end
- #--------------------------------------------------------------------------
- # * Variable
- #--------------------------------------------------------------------------
- def variable
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # * Update Info Window
- #--------------------------------------------------------------------------
- def update_info_window
- @info_window.contents.clear
- sw = @info_window.width - 32
- value1 = @page*10+1
- value2 = [@page*10+10, $data_system.switches.size-1].min
- text1 = sprintf("Variables %d to %d", value1, value2)
- text2 = "Press L or Left to page backward."
- text3 = "Press R or Right to page forward."
- text4 = "Press Z to modify variable."
- @info_window.contents.draw_text(0, WLH*0, sw, WLH, text1, 1)
- @info_window.contents.draw_text(0, WLH*1+8, sw, WLH, text2, 1)
- @info_window.contents.draw_text(0, WLH*2+8, sw, WLH, text3, 1)
- @info_window.contents.draw_text(0, WLH*3+8, sw, WLH, text4, 1)
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh(page)
- @data = []; @page = page
- update_info_window
- for i in (@page*10+1)..(@page*10+10); @data.push(i); end
- @item_max = @data.size
- create_contents
- for i in 0..(@item_max-1)
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- self.contents.font.color = normal_color
- variable_id = @data[index]
- rect.x += 4
- rect.width -= 8
- if variable_id > $data_system.variables.size-1
- self.contents.font.color.alpha = 128
- self.contents.draw_text(rect.x, rect.y, rect.width, WLH, "N/A")
- return
- end
- name = $data_system.variables[variable_id]
- self.contents.font.color.alpha = name == "" ? 128 : 255
- if $game_variables[variable_id] != 0
- if name == ""
- self.contents.font.color = knockout_color
- name = "ATTENTION"
- else
- self.contents.font.color = crisis_color
- end
- end
- name = "Undefined" if name == ""
- text = sprintf("V%04d:%s", variable_id, name)
- value = $game_variables[variable_id]
- self.contents.draw_text(rect.x, rect.y, rect.width, WLH, text, 0)
- self.contents.draw_text(rect.x, rect.y, rect.width, WLH, value, 2)
- end
- end
- #==============================================================================
- # ** Window_DebugInput
- #------------------------------------------------------------------------------
- # This window is used to display input in the debug screen.
- #==============================================================================
- class Window_DebugInput < Window_Selectable
- #--------------------------------------------------------------------------
- # Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :value
- attr_accessor :host_window
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(host_window)
- dw = Graphics.width*3/4
- dx = (Graphics.width-dw)/2
- dh = WLH*2+32
- dy = (Graphics.height-dh)/2
- super(dx, dy, dw, dh)
- self.back_opacity = 255
- @spacing = 0
- @host_window = host_window
- if @host_window.is_a?(Window_DebugVariables)
- @column_max = @item_max = 9
- @text = $data_system.variables[@host_window.variable]
- @text = "Undefined" if @text == ""
- @text = sprintf("V%04d:%s", @host_window.variable, @text)
- @value = $game_variables[@host_window.variable]
- @max_value = 99999999
- @min_value = -99999999
- self.index = 8
- else; return
- end
- self.contents.clear
- draw_input_title
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- if @host_window.is_a?(Window_DebugVariables)
- for i in 0..(@item_max-1); draw_variable(i); end
- end
- end
- #--------------------------------------------------------------------------
- # * Value
- #--------------------------------------------------------------------------
- def value=(value)
- @value = value
- @value = [[@value, @max_value].min, @min_value].max
- end
- #--------------------------------------------------------------------------
- # * Draw Input Title
- #--------------------------------------------------------------------------
- def draw_input_title
- self.contents.draw_text(0, 0, self.width-32, WLH, @text, 1)
- end
- #--------------------------------------------------------------------------
- # * Draw Variable
- #--------------------------------------------------------------------------
- def draw_variable(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- if index == 0
- text = @value >= 0 ? "+" : "-"
- else
- text = @value.abs % 10**(@column_max-index)/(10**(@column_max-1-index))
- end
- self.contents.draw_text(rect.x, rect.y, rect.width, WLH, text, 1)
- end
- #--------------------------------------------------------------------------
- # * Item Rect
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 24, WLH)
- rect.x = (self.contents.width-32-24*@column_max)/2+index*24+12
- rect.y = index / @column_max * WLH + WLH
- return rect
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def update
- if Input.trigger?(Input::RIGHT) and @index == @column_max -1
- Sound.play_cursor
- @index = 0
- elsif Input.trigger?(Input::LEFT) and @index == 0
- Sound.play_cursor
- @index = @column_max -1
- else
- super
- end
- end
- end
- #==============================================================================
- # ** Scene_Debug
- #------------------------------------------------------------------------------
- # This class performs debug screen processing.
- #==============================================================================
- class Scene_Debug < Scene_Base
- #--------------------------------------------------------------------------
- # * Start
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- create_command_window
- @dummy_window = Window_Base.new(160, 0, Graphics.width -
- @command_window.width, Graphics.height)
- end
- #--------------------------------------------------------------------------
- # * Terminate
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @command_window.dispose if @command_window != nil
- @dummy_window.dispose if @dummy_window != nil
- $game_map.refresh
- end
- #--------------------------------------------------------------------------
- # * Create Command Window
- #--------------------------------------------------------------------------
- def create_command_window
- commands = []; @data = []
- for command in PAC::MENU::COMMANDS
- @data.push(command)
- commands.push(PAC::MENU::VOCAB[command])
- end
- @command_window = Window_Command.new(160, commands)
- @command_window.height = Graphics.height
- @var_page = @switch_page = 0
- end
- #--------------------------------------------------------------------------
- # * Return Scene
- #--------------------------------------------------------------------------
- def return_scene
- if $game_temp.in_battle
- $scene = Scene_Battle.new
- else
- $scene = Scene_Map.new
- end
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- if @command_window.active
- update_command_selection
- elsif @switch_window != nil and @switch_window.active
- update_switch_selection
- elsif @variable_window != nil and @variable_window.active
- update_variable_selection
- elsif @input_window != nil and @input_window.active
- update_input_window
- end
- end
- #--------------------------------------------------------------------------
- # * Update Command Selection
- #--------------------------------------------------------------------------
- def update_command_selection
- @command_window.update
- if Input.trigger?(Input::B) or Input.trigger?(Input::F9)
- Sound.play_cancel
- return_scene
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- case @data[@command_window.index]
- when :switches
- @command_window.active = false
- @dummy_window.visible = false
- @info_window = Window_Base.new(160, 272, Graphics.width-160,
- Graphics.height-272)
- @switch_window = Window_DebugSwitches.new(@switch_page, @info_window)
- when :variables
- @command_window.active = false
- @dummy_window.visible = false
- @info_window = Window_Base.new(160, 272, Graphics.width-160,
- Graphics.height-272)
- @variable_window = Window_DebugVariables.new(@var_page, @info_window)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Update Switch Selection
- #--------------------------------------------------------------------------
- def update_switch_selection
- @switch_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @command_window.active = true
- @dummy_window.visible = true
- @switch_window.dispose
- @switch_window = nil
- @info_window.dispose
- @info_window = nil
- elsif Input.repeat?(Input::R) or Input.repeat?(Input::RIGHT)
- Sound.play_cursor
- @switch_page += 1
- @switch_page = 0 if @switch_page+1 > ($data_system.switches.size-1+9)/10
- @switch_window.refresh(@switch_page)
- elsif Input.repeat?(Input::L) or Input.repeat?(Input::LEFT)
- Sound.play_cursor
- @switch_page -= 1
- @switch_page = ($data_system.switches.size-1+9)/10-1 if @switch_page < 0
- @switch_window.refresh(@switch_page)
- elsif Input.trigger?(Input::C)
- switch = @switch_window.switch
- if switch > $data_system.switches.size-1
- Sound.play_buzzer
- return
- end
- Sound.play_decision
- $game_switches[switch] = !$game_switches[switch]
- @switch_window.refresh(@switch_page)
- end
- end
- #--------------------------------------------------------------------------
- # * Update Variable Selection
- #--------------------------------------------------------------------------
- def update_variable_selection
- @variable_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @command_window.active = true
- @dummy_window.visible = true
- @variable_window.dispose
- @variable_window = nil
- @info_window.dispose
- @info_window = nil
- elsif Input.repeat?(Input::R) or Input.repeat?(Input::RIGHT)
- Sound.play_cursor
- @var_page += 1
- @var_page = 0 if @var_page+1 > ($data_system.variables.size-1+9)/10
- @variable_window.refresh(@var_page)
- elsif Input.repeat?(Input::L) or Input.repeat?(Input::LEFT)
- Sound.play_cursor
- @var_page -= 1
- @var_page = ($data_system.switches.size-1+9)/10-1 if @var_page < 0
- @variable_window.refresh(@var_page)
- elsif Input.trigger?(Input::C)
- variable = @variable_window.variable
- if variable > $data_system.variables.size-1
- Sound.play_buzzer
- return
- end
- Sound.play_decision
- @input_window = Window_DebugInput.new(@variable_window)
- @variable_window.active = false
- end
- end
- #--------------------------------------------------------------------------
- # * Update Input Window
- #--------------------------------------------------------------------------
- def update_input_window
- @input_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @input_window.host_window.active = true
- @input_window.dispose
- @input_window = nil
- elsif Input.repeat?(Input::UP)
- Sound.play_cursor
- if @input_window.index == 0
- @input_window.value *= -1
- else
- value = 10**(8-@input_window.index)
- @input_window.value += value
- end
- @input_window.refresh
- elsif Input.repeat?(Input::DOWN)
- Sound.play_cursor
- if @input_window.index == 0
- @input_window.value *= -1
- else
- value = 10**(8-@input_window.index)
- @input_window.value -= value
- end
- @input_window.refresh
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- if @input_window.host_window.is_a?(Window_DebugVariables)
- $game_variables[@variable_window.variable] = @input_window.value
- @variable_window.draw_item(@variable_window.index)
- end
- @input_window.host_window.active = true
- @input_window.dispose
- @input_window = nil
- end
- end
- end
- $imported = {} if $imported == nil
- $imported["PAC_DebugScene"] = true
- #===============================================================================
- #
- # END OF SCRIPT
- #
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement