Home > RGSS Script Reference > Scene_Debug
Scene_Debug
Inherits from: None
Description: This is the class that handles the debug screen when you press F9 during a test play.
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)
@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
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
end
# ------------------------------------
def update
@right_window.mode = @left_window.mode
@right_window.top_id = @left_window.top_id
@left_window.update
@right_window.update
$game_temp.debug_top_row = @left_window.top_row
$game_temp.debug_index = @left_window.index
if @left_window.active
update_left
return
end
if @right_window.active
update_right
return
end
end
# ------------------------------------
def update_left
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
if @left_window.mode == 0
text1 = "C (Enter) : ON / OFF"
@help_window.contents.draw_text(4, 0, 406, 32, text1)
else
text1 = "? : -1 ? : +1"
text2 = "L (Pageup) : -10"
text3 = "R (Pagedown) : +10"
@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
end
# ------------------------------------
def update_right
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@left_window.active = true
@right_window.active = false
@right_window.index = -1
@help_window.contents.clear
return
end
current_id = @right_window.top_id + @right_window.index
if @right_window.mode == 0
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_switches[current_id] = (not $game_switches[current_id])
@right_window.refresh
return
end
end
if @right_window.mode == 1
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
$game_variables[current_id] += 1
@right_window.refresh
return
end
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
$game_variables[current_id] -= 1
@right_window.refresh
return
end
if Input.repeat?(Input::R)
$game_system.se_play($data_system.cursor_se)
$game_variables[current_id] += 10
@right_window.refresh
return
end
if Input.repeat?(Input::L)
$game_system.se_play($data_system.cursor_se)
$game_variables[current_id] -= 10
@right_window.refresh
return
end
end
end
end
|
Left_Window: A Window_DebugLeft object that defines the left debug window, which lets you choose a switch or variable group to edit.
Right_Window: A Window_DebugRight object that defines the right debug window, which lets you choose a specific switch or variable to edit..
Help_Window: This is the window that shows the instructions for how to use the debug window. Note that because of its irregular shape, this window is a Window_Base object rather than a Window_Help object.
Main
Arguments: None
Local Variables: None
How it Works: This is the main method for this class. The first part of the method initializes the three window objects. A couple of points here. The @left_window.top_row value is needed because the left window can scroll if there are a large number of switches and/or variables in the game. This value keeps track of the top row of the window. This, combined with @left_window.index allows the engine to determine which switch or variable group to display regardless of the window's scroll position. The next part of the method is the main loop common to pretty much all of the "Scene" classes. It updates the graphics, checks the input, and updates the windows. The last part of the method disposes of the object's contents once the user has exited the debug menu.
Update
Arguments: None
Local Variables: None
How it Works: This is the frame update method for this class. First, the "mode" of the two windows are equalized. The "mode" of the two windows describes whether the window are in switch editing mode or variable editing mode. It then updates both the left and right windows. The local variables for the debug window are then loaded into the global variables so that they can be stored for purposes of cursor memory from debug session to debug session. Then, depending on which window is active at present, the method calls a sub-method to do further processing.
Update_Left
Arguments: None
Local Variables: None
How it Works: This method updates the left window by responding to user input. If the current input is "B" (cancel), then the cancel sound effect is played and a new $Scene_Map object is created and the player returns to the map. If the current input is "C" (decision), then it checks to see what the current mode of the left window is. If the mode is 0 (switch mode), then the help window is loaded with the instruction text for changing switches. If the mode is 1 (variable mode), then the help window is loaded with the instruction text for changing variables. Then, the @left_window.active = false and @right_window.active = true statements transfer control to the right-hand window.
Update_Right
Arguments: None
Local Variables:
Current_ID: The current switch or variable ID selected. Created by adding the top index of the window and current index of the selection pointer.
How it Works: This method updates the state of the right-hand debug window in response to user input. If the input trigger is "B" (cancel), the cancel sound effect is played, control is transferred back to the left-hand window, and the help window is blanked out. If the window has not been cancelled, then the value of current_id is set to the current switch or variable ID selected. If the input is "C" (decision) and the window mode is 0 (switch editing mode), then it plays the decision sound effect and changes the value of the switch to its opposite. The "C" key does nothing in variable-editing mode. If the input is "RIGHT", then the value of the variable at current_id is incremented. If the input is "LEFT" and the window mode is 1 (variable-editing mode), then the value of the variable at current_id is decremented. If the value of the variable is "R", then the value of the variable is increased by 10. If the input is "L", then the value of the variable is decreased by 10.
|
|