Submit Your Article Guild Wars 2 Forum RPG Maker VX.com
 
RPG Maker
 

 Username:
 Password:
   Not a member? Register!



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.

Code


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

Properties


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.

Methods


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. 
Syntax
@
@@
$
alias
[array index]
attr_accessor
attr_reader
attr_writer
class
def
do
ensure
for
if
[iterator]
key => value
new
next
nil
redo
require
return
rescue
self
super
undef
unless
until
while
yield

Classes
Arrow_Actor
Arrow_Base
Arrow_Enemy
Game_Actor
Game_Actors
Game_BattleAct
Game_Battler
Game_Character
Game_Common
Game_Enemy
Game_Event
Game_Map
Game_Party
Game_Picture
Game_Player
Game_Screen
Game_SlfSwitch
Game_Switches
Game_System
Game_Troop
Game_Variables
Interpreter
Scene_Debug
Scene_End
Scene_Equip
Scene_File
Scene_Gameover
Scene_Item
Scene_Load
Scene_Map
Scene_Menu
Scene_Name
Scene_Save
Scene_Shop
Scene_Skill
Scene_Status
Scene_Title
Sprite_Battler
Sprite_Character
Sprite_Picture
Sprite_Timer
Spriteset_Battle
Spriteset_Map
Window_Base
Window_Battleresult
Window_Battlestatus
Window_Command
Window_DebugLeft
Window_DebugRight
Window_EquipItem
Window_EquipLeft
Window_EquipRight
Window_Gold
Window_Help
Window_InputNumb
Window_Item
Window_MenuStatus
Window_Message
Window_NameEdit
Window_NameInput
Window_PartyCom
Window_PlayTime
Window_SaveFile
Window_Selectable
Window_ShopBuy
Window_ShopCom
Window_ShopNum
Window_ShopSell
Window_ShopStatus
Window_Skill
Window_SkillStatus
Window_Status
Window_Steps
Window_Target

Other
Class Hierarchy
Global Variables


RPG RPG Revolution
RPG RPG Revolution is your #1 stop for game development and console RPG games, as well as those created by people like you. Link to us to support us, so we may grow to be better website community for you.

RPG RPG Revolution is an Privacy Policy and Legal