Advertisement
Archeia

Debug Extension (Luna Engine Version)

Nov 11th, 2014
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 52.20 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Debug Extension v1.01
  4. # -- Last Updated: 2012.01.05
  5. # -- Level: Easy, Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-DebugExtension"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.01.05 - Script no longer conflicts with conditional Key presses.
  17. # 2012.01.04 - Started Script and Finished.
  18. #
  19. #==============================================================================
  20. # ▼ Introduction
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # While the RPG Maker VX Ace debug menu gets the basics done, this script will
  23. # add on even more functionality. This script provides an extended debug menu,
  24. # common event shortcuts that can be ran from a few key presses, and even an
  25. # input console to manually insert code and run it.
  26. #
  27. #==============================================================================
  28. # ▼ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  32. #
  33. # -----------------------------------------------------------------------------
  34. # Debug Shortcuts - Only during $TEST and $BTEST mode
  35. # -----------------------------------------------------------------------------
  36. # Alt   + F5-F9 - Common Event Debug Shortcut
  37. # Ctrl  + F5-F9 - Common Event Debug Shortcut
  38. # Shift + F5-F9 - Common Event Debug Shortcut
  39. # F9 on the map - Open Debug Menu.
  40. #
  41. # F10 anywhere - Opens up the Debug Entry Window.
  42. #   Here, you may enter in a piece of code and the script itself will run it
  43. #   using the current scene as its host. So long as the code doesn't contain
  44. #   any syntax errors, it'll run right immediately. Idea by OriginalWij.
  45. #
  46. #==============================================================================
  47. # ▼ Compatibility
  48. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  49. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  50. # it will run with RPG Maker VX without adjusting.
  51. #
  52. #==============================================================================
  53.  
  54. module YEA
  55.   module DEBUG
  56.    
  57.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  58.     # - Common Event Shortcut Settings -
  59.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  60.     # Here, you can define common event shortcuts to launch during test play
  61.     # mode and pressing the right shortcut combination. If you do not wish to
  62.     # use a particular shortcut key, set it to 0.
  63.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  64.     # Common event shortcuts when holding down ALT and pressing an F5-F9 key.
  65.     ALT ={ # Only works during test play mode.
  66.       :F5 => 0,
  67.       :F6 => 0,
  68.       :F7 => 0,
  69.       :F8 => 0,
  70.       :F9 => 0,
  71.     } # Do not remove this.
  72.    
  73.     # Common event shortcuts when holding down CTRL and pressing an F5-F9 key.
  74.     CTRL ={ # Only works during test play mode.
  75.       :F5 => 0,
  76.       :F6 => 0,
  77.       :F7 => 0,
  78.       :F8 => 0,
  79.       :F9 => 0,
  80.     } # Do not remove this.
  81.    
  82.     # Common event shortcuts when holding down SHIFT and pressing an F5-F9 key.
  83.     SHIFT ={ # Only works during test play mode.
  84.       :F5 => 0,
  85.       :F6 => 0,
  86.       :F7 => 0,
  87.       :F8 => 0,
  88.       :F9 => 0,
  89.     } # Do not remove this.
  90.    
  91.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  92.     # - Debug Menu Settings -
  93.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  94.     # The following adjusts debug menu data. There's no real need to edit
  95.     # anything here unless you feel like it. Here's what the commands do:
  96.     #   :switches     Adjust switches like default.
  97.     #   :variables    Adjust variables like default.
  98.     #   :battle       Enter the selected battle.
  99.     #   :events       Call common events from menu.
  100.     #   :items        Adjust item quantities.
  101.     #   :weapons      Adjust weapon quantities.
  102.     #   :armours      Adjust armour quantities.
  103.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  104.     # Command window layout for the debug menu. Determines order and which
  105.     # commands will be shown in the command window.
  106.     COMMANDS =[
  107.       [ :switches,  "Switches"],
  108.       [:variables, "Variables"],
  109.       [   :battle,    "Battle"],
  110.       [   :events,    "Events"],
  111.       [    :items,     "Items"],
  112.       [  :weapons,   "Weapons"],
  113.       [  :armours,   "Armours"],
  114.     ] # Do not remove this.
  115.    
  116.   end # DEBUG
  117. end # YEA
  118.  
  119. #==============================================================================
  120. # ▼ Editting anything past this point may potentially result in causing
  121. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  122. # halitosis so edit at your own risk.
  123. #==============================================================================
  124.  
  125. #==============================================================================
  126. # ■ Numeric
  127. #==============================================================================
  128.  
  129. class Numeric
  130.  
  131.   #--------------------------------------------------------------------------
  132.   # new method: group_digits
  133.   #--------------------------------------------------------------------------
  134.   unless $imported["YEA-CoreEngine"]
  135.   def group; return self.to_s; end
  136.   end # $imported["YEA-CoreEngine"]
  137.    
  138. end # Numeric
  139.  
  140. #==============================================================================
  141. # ■ Input
  142. #==============================================================================
  143.  
  144. module Input
  145.  
  146.   #--------------------------------------------------------------------------
  147.   # constants - Created by OriginalWij and Yanfly
  148.   #--------------------------------------------------------------------------
  149.   DEFAULT = [:DOWN, :LEFT, :RIGHT, :UP, :A, :B, :C, :X, :Y, :Z, :L, :R,
  150.     :SHIFT, :CTRL, :ALT, :F5, :F6, :F7, :F8, :F9]
  151.  
  152.   LETTERS = {}
  153.   LETTERS['A'] = 65; LETTERS['B'] = 66; LETTERS['C'] = 67; LETTERS['D'] = 68
  154.   LETTERS['E'] = 69; LETTERS['F'] = 70; LETTERS['G'] = 71; LETTERS['H'] = 72
  155.   LETTERS['I'] = 73; LETTERS['J'] = 74; LETTERS['K'] = 75; LETTERS['L'] = 76
  156.   LETTERS['M'] = 77; LETTERS['N'] = 78; LETTERS['O'] = 79; LETTERS['P'] = 80
  157.   LETTERS['Q'] = 81; LETTERS['R'] = 82; LETTERS['S'] = 83; LETTERS['T'] = 84
  158.   LETTERS['U'] = 85; LETTERS['V'] = 86; LETTERS['W'] = 87; LETTERS['X'] = 88
  159.   LETTERS['Y'] = 89; LETTERS['Z'] = 90
  160.  
  161.   NUMBERS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
  162.   NUMPAD = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
  163.  
  164.   BACK   = 138; ENTER  = 143; SPACE  = 32;  SCOLON = 186; ESC    = 157
  165.   QUOTE  = 222; EQUALS = 187; COMMA  = 188; USCORE = 189; PERIOD = 190
  166.   SLASH  = 191; LBRACE = 219; RBRACE = 221; BSLASH = 220; TILDE  = 192
  167.   F10    = 121; F11    = 122; CAPS   = 20;  NMUL   = 106; NPLUS  = 107
  168.   NSEP   = 108; NMINUS = 109; NDECI  = 110; NDIV   = 111;
  169.  
  170.   Extras = [USCORE, EQUALS, LBRACE, RBRACE, BSLASH, SCOLON, QUOTE, COMMA,
  171.    PERIOD, SLASH, NMUL, NPLUS, NSEP, NMINUS, NDECI, NDIV]
  172.  
  173.   #--------------------------------------------------------------------------
  174.   # initial module settings - Created by OriginalWij and Yanfly
  175.   #--------------------------------------------------------------------------
  176.   GetKeyState = Win32API.new("user32", "GetAsyncKeyState", "i", "i")
  177.   GetCapState = Win32API.new("user32", "GetKeyState", "i", "i")
  178.   KeyRepeatCounter = {}
  179.  
  180.   module_function
  181.   #--------------------------------------------------------------------------
  182.   # alias method: update - Created by OriginalWij
  183.   #--------------------------------------------------------------------------
  184.   class <<self; alias input_update_debug update; end
  185.   def self.update
  186.     input_update_debug
  187.     for key in KeyRepeatCounter.keys
  188.       if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  189.         KeyRepeatCounter[key] += 1
  190.       else
  191.         KeyRepeatCounter.delete(key)
  192.       end
  193.     end
  194.   end
  195.  
  196.   #--------------------------------------------------------------------------
  197.   # alias method: press? - Created by OriginalWij
  198.   #--------------------------------------------------------------------------
  199.   class <<self; alias input_press_debug press?; end
  200.   def self.press?(key)
  201.     return input_press_debug(key) if default_key?(key)
  202.     adjusted_key = adjust_key(key)
  203.     return true unless KeyRepeatCounter[adjusted_key].nil?
  204.     return key_pressed?(adjusted_key)
  205.   end
  206.  
  207.   #--------------------------------------------------------------------------
  208.   # alias method: trigger? - Created by OriginalWij
  209.   #--------------------------------------------------------------------------
  210.   class <<self; alias input_trigger_debug trigger?; end
  211.   def self.trigger?(key)
  212.     return input_trigger_debug(key) if default_key?(key)
  213.     adjusted_key = adjust_key(key)
  214.     count = KeyRepeatCounter[adjusted_key]
  215.     return ((count == 0) || (count.nil? ? key_pressed?(adjusted_key) : false))
  216.   end
  217.  
  218.   #--------------------------------------------------------------------------
  219.   # alias method: repeat? - Created by OriginalWij
  220.   #--------------------------------------------------------------------------
  221.   class <<self; alias input_repeat_debug repeat?; end
  222.   def self.repeat?(key)
  223.     return input_repeat_debug(key) if default_key?(key)
  224.     adjusted_key = adjust_key(key)
  225.     count = KeyRepeatCounter[adjusted_key]
  226.     return true if count == 0
  227.     if count.nil?
  228.       return key_pressed?(adjusted_key)
  229.     else
  230.       return (count >= 23 && (count - 23) % 6 == 0)
  231.     end
  232.   end
  233.  
  234.   #--------------------------------------------------------------------------
  235.   # new method: default_key? - Created by Yanfly
  236.   #--------------------------------------------------------------------------
  237.   def self.default_key?(key)
  238.     return true if key.is_a?(Integer) && key < 30
  239.     return DEFAULT.include?(key)
  240.   end
  241.  
  242.   #--------------------------------------------------------------------------
  243.   # new method: adjust_key - Created by OriginalWij
  244.   #--------------------------------------------------------------------------
  245.   def self.adjust_key(key)
  246.     key -= 130 if key.between?(130, 158)
  247.     return key
  248.   end
  249.  
  250.   #--------------------------------------------------------------------------
  251.   # new method: key_pressed? - Created by OriginalWij
  252.   #--------------------------------------------------------------------------
  253.   def self.key_pressed?(key)
  254.     if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  255.       KeyRepeatCounter[key] = 0
  256.       return true
  257.     end
  258.     return false
  259.   end
  260.  
  261.   #--------------------------------------------------------------------------
  262.   # new method: typing? - Created by Yanfly
  263.   #--------------------------------------------------------------------------
  264.   def self.typing?
  265.     return true if repeat?(SPACE)
  266.     for i in 'A'..'Z'
  267.       return true if repeat?(LETTERS[i])
  268.     end
  269.     for i in 0...NUMBERS.size
  270.       return true if repeat?(NUMBERS[i])
  271.       return true if repeat?(NUMPAD[i])
  272.     end
  273.     for key in Extras
  274.       return true if repeat?(key)
  275.     end
  276.     return false
  277.   end
  278.  
  279.   #--------------------------------------------------------------------------
  280.   # new method: key_type - Created by Yanfly
  281.   #--------------------------------------------------------------------------
  282.   def self.key_type
  283.     return " " if repeat?(SPACE)
  284.     for i in 'A'..'Z'
  285.       next unless repeat?(LETTERS[i])
  286.       return upcase? ? i.upcase : i.downcase
  287.     end
  288.     for i in 0...NUMBERS.size
  289.       return i.to_s if repeat?(NUMPAD[i])
  290.       if !press?(SHIFT)
  291.         return i.to_s if repeat?(NUMBERS[i])
  292.       elsif repeat?(NUMBERS[i])
  293.         case i
  294.         when 1; return "!"
  295.         when 2; return "@"
  296.         when 3; return "#"
  297.         when 4; return "$"
  298.         when 5; return "%"
  299.         when 6; return "^"
  300.         when 7; return "&"
  301.         when 8; return "*"
  302.         when 9; return "("
  303.         when 0; return ")"
  304.         end
  305.       end
  306.     end
  307.     for key in Extras
  308.       next unless repeat?(key)
  309.       case key
  310.       when USCORE; return press?(SHIFT) ? "_" : "-"
  311.       when EQUALS; return press?(SHIFT) ? "+" : "="
  312.       when LBRACE; return press?(SHIFT) ? "{" : "["
  313.       when RBRACE; return press?(SHIFT) ? "}" : "]"
  314.       when BSLASH; return press?(SHIFT) ? "|" : "\\"
  315.       when SCOLON; return press?(SHIFT) ? ":" : ";"
  316.       when QUOTE;  return press?(SHIFT) ? '"' : "'"
  317.       when COMMA;  return press?(SHIFT) ? "<" : ","
  318.       when PERIOD; return press?(SHIFT) ? ">" : "."
  319.       when SLASH;  return press?(SHIFT) ? "?" : "/"
  320.       when NMUL;   return "*"
  321.       when NPLUS;  return "+"
  322.       when NSEP;   return ","
  323.       when NMINUS; return "-"
  324.       when NDECI;  return "."
  325.       when NDIV;   return "/"
  326.       end
  327.     end
  328.     return ""
  329.   end
  330.  
  331.   #--------------------------------------------------------------------------
  332.   # new method: upcase? - Created by Yanfly
  333.   #--------------------------------------------------------------------------
  334.   def self.upcase?
  335.     return !press?(SHIFT) if GetCapState.call(CAPS) == 1
  336.     return true if press?(SHIFT)
  337.     return false
  338.   end
  339.  
  340. end # Input
  341.  
  342. #==============================================================================
  343. # ■ SceneManager
  344. #==============================================================================
  345.  
  346. module SceneManager
  347.  
  348.   #--------------------------------------------------------------------------
  349.   # new method: self.force_recall
  350.   #--------------------------------------------------------------------------
  351.   def self.force_recall(scene_class)
  352.     @scene = scene_class
  353.   end
  354.  
  355. end # SceneManager
  356.  
  357. #==============================================================================
  358. # ■ Sprite_DebugMap
  359. #==============================================================================
  360.  
  361. class Sprite_DebugMap < Sprite_Base
  362.  
  363.   #--------------------------------------------------------------------------
  364.   # initialize
  365.   #--------------------------------------------------------------------------
  366.   def initialize(viewport, map_window)
  367.     super(viewport)
  368.     @map_window = map_window
  369.     self.visible = false
  370.     create_bitmap
  371.   end
  372.  
  373.   #--------------------------------------------------------------------------
  374.   # dispose
  375.   #--------------------------------------------------------------------------
  376.   def dispose
  377.     self.bitmap.dispose unless self.bitmap.nil?
  378.     super
  379.   end
  380.  
  381.   #--------------------------------------------------------------------------
  382.   # create_bitmap
  383.   #--------------------------------------------------------------------------
  384.   def create_bitmap
  385.     bitmap = Bitmap.new(32, 32)
  386.     bitmap.fill_rect(0, 0, 32, 32, Color.new(  0,   0,   0))
  387.     bitmap.fill_rect(1, 1, 30, 30, Color.new(255, 255,   0))
  388.     bitmap.fill_rect(2, 2, 28, 28, Color.new(  0,   0,   0))
  389.     bitmap.clear_rect(Rect.new(3, 3, 26, 26))
  390.     self.bitmap = bitmap
  391.   end
  392.  
  393.   #--------------------------------------------------------------------------
  394.   # update
  395.   #--------------------------------------------------------------------------
  396.   def update
  397.     super
  398.     self.tone = Tone.new(255, 0, 0, 0) if @map_window.active
  399.     self.tone = Tone.new(0, 0, 0, 0) unless @map_window.active
  400.   end
  401.  
  402. end # Sprite_DebugMap
  403.  
  404. #==============================================================================
  405. # ■ Scene_Base
  406. #==============================================================================
  407.  
  408. class Scene_Base
  409.  
  410.   #--------------------------------------------------------------------------
  411.   # alias method: update_basic
  412.   #--------------------------------------------------------------------------
  413.   alias scene_base_update_debug update
  414.   def update
  415.     scene_base_update_debug
  416.     trigger_debug_window_entry
  417.   end
  418.  
  419.   #--------------------------------------------------------------------------
  420.   # new method: trigger_debug_window_entry
  421.   #--------------------------------------------------------------------------
  422.   def trigger_debug_window_entry
  423.     return unless $TEST || $BTEST
  424.     if Input.trigger?(Input::F10)
  425.       Sound.play_ok
  426.       process_debug_window_entry
  427.     end
  428.   end
  429.  
  430.   #--------------------------------------------------------------------------
  431.   # new method: process_debug_window_entry
  432.   #--------------------------------------------------------------------------
  433.   def process_debug_window_entry
  434.     Graphics.freeze
  435.     viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  436.     viewport.z = 8000
  437.     @debug_entry_window = Window_DebugEntry.new
  438.     @debug_entry_window.viewport = viewport
  439.     Graphics.transition(4)
  440.     #---
  441.     update_debug_window_entry
  442.     #---
  443.     Graphics.freeze
  444.     @debug_entry_window.dispose
  445.     @debug_entry_window = nil
  446.     viewport.dispose
  447.     Graphics.transition(4)
  448.   end
  449.  
  450.   #--------------------------------------------------------------------------
  451.   # new method: update_debug_window_entry
  452.   #--------------------------------------------------------------------------
  453.   def update_debug_window_entry
  454.     loop do
  455.       Graphics.update
  456.       Input.update
  457.       @debug_entry_window.update
  458.       if Input.trigger?(Input::ESC)
  459.         Sound.play_cancel
  460.         if @debug_entry_window.text.size > 0
  461.           @debug_entry_window.text = ""
  462.         else
  463.           break
  464.         end
  465.       elsif Input.trigger?(Input::F10)
  466.         Sound.play_cancel
  467.         break
  468.       elsif Input.trigger?(Input::ENTER)
  469.         code = @debug_entry_window.text
  470.         begin
  471.           eval(code)
  472.           Sound.play_ok
  473.           break
  474.         rescue Exception => ex
  475.           Sound.play_buzzer
  476.         end
  477.       end
  478.     end
  479.   end
  480.  
  481. end # Scene_Base
  482.  
  483. #==============================================================================
  484. # ■ Scene_Map
  485. #==============================================================================
  486.  
  487. class Scene_Map < Scene_Base
  488.  
  489.   #--------------------------------------------------------------------------
  490.   # alias method: update_call_debug
  491.   #--------------------------------------------------------------------------
  492.   alias scene_map_update_call_debug_debug update_call_debug
  493.   def update_call_debug
  494.     return unless $TEST
  495.     if Input.press?(:ALT)
  496.       for key in YEA::DEBUG::ALT
  497.         next unless Input.trigger?(key[0])
  498.         next if key[1] <= 0
  499.         $game_temp.reserve_common_event(key[1])
  500.       end
  501.     elsif Input.press?(:CTRL)
  502.       for key in YEA::DEBUG::CTRL
  503.         next unless Input.trigger?(key[0])
  504.         next if key[1] <= 0
  505.         $game_temp.reserve_common_event(key[1])
  506.       end
  507.     elsif Input.press?(:SHIFT)
  508.       for key in YEA::DEBUG::SHIFT
  509.         next unless Input.trigger?(key[0])
  510.         next if key[1] <= 0
  511.         $game_temp.reserve_common_event(key[1])
  512.       end
  513.     else
  514.       scene_map_update_call_debug_debug
  515.     end
  516.   end
  517.  
  518. end # Scene_Map
  519.  
  520. #==============================================================================
  521. # ■ Scene_Battle
  522. #==============================================================================
  523.  
  524. class Scene_Battle < Scene_Base
  525.  
  526.   #--------------------------------------------------------------------------
  527.   # alias method: update_basic
  528.   #--------------------------------------------------------------------------
  529.   alias scene_battle_update_basic_debug update_basic
  530.   def update_basic
  531.     scene_battle_update_basic_debug
  532.     update_debug_input if $BTEST || $TEST
  533.   end
  534.  
  535.   #--------------------------------------------------------------------------
  536.   # new method: update_debug_input
  537.   #--------------------------------------------------------------------------
  538.   def update_debug_input
  539.     return unless Input.trigger?(:F9)
  540.     Graphics.freeze
  541.     @info_viewport.visible = false
  542.     SceneManager.snapshot_for_background
  543.     #---
  544.     SceneManager.call(Scene_Debug)
  545.     SceneManager.scene.main
  546.     SceneManager.force_recall(self)
  547.     #---
  548.     @info_viewport.visible = true
  549.     @status_window.refresh
  550.     perform_transition
  551.   end
  552.  
  553. end # Scene_Battle
  554.  
  555. #==============================================================================
  556. # ■ Window_DebugEntry
  557. #==============================================================================
  558.  
  559. class Window_DebugEntry < Window_Base
  560.  
  561.   #--------------------------------------------------------------------------
  562.   # public instance variables
  563.   #--------------------------------------------------------------------------
  564.   attr_accessor :text
  565.  
  566.   #--------------------------------------------------------------------------
  567.   # initialize
  568.   #--------------------------------------------------------------------------
  569.   def initialize
  570.     dx = -standard_padding
  571.     dy = Graphics.height - fitting_height(1) + standard_padding
  572.     dw = Graphics.width + standard_padding * 2
  573.     dh = fitting_height(1)
  574.     super(dx, dy, dw, dh)
  575.     contents.font.name = ["VL Gothic", "Courier New"]
  576.     contents.font.bold = false
  577.     contents.font.italic = false
  578.     contents.font.shadow = false
  579.     contents.font.outline = false
  580.     contents.font.size = 20
  581.     contents.font.color = Color.new(192, 192, 192)
  582.     self.opacity = 0
  583.     @text = ""
  584.     @rect = Rect.new(4, 0, 8192, 24)
  585.     refresh
  586.   end
  587.  
  588.   #--------------------------------------------------------------------------
  589.   # refresh
  590.   #--------------------------------------------------------------------------
  591.   def refresh
  592.     contents.clear
  593.     cw = contents.width
  594.     contents.fill_rect(0, 0, cw, line_height, Color.new(192, 192, 192))
  595.     contents.fill_rect(1, 1, contents.width-2, line_height-2, Color.new(0, 0, 0))
  596.     if @blink
  597.       contents.draw_text(@rect, @text + "▂", 0)
  598.     else
  599.       contents.draw_text(@rect, @text, 0)
  600.     end
  601.   end
  602.  
  603.   #--------------------------------------------------------------------------
  604.   # update
  605.   #--------------------------------------------------------------------------
  606.   def update
  607.     super
  608.     @blink = !@blink if (Graphics.frame_count % 30 == 0)
  609.     maximum = 256
  610.     if Input.typing? && @text.size <= maximum
  611.       @text += Input.key_type
  612.     elsif Input.repeat?(Input::BACK) && @text.size > 0
  613.       @text[@text.size - 1] = ""
  614.     end
  615.     refresh
  616.   end
  617.  
  618. end # Window_DebugEntry
  619.  
  620. #==============================================================================
  621. # ■ Window_DebugCommand
  622. #==============================================================================
  623.  
  624. class Window_DebugCommand < Window_Command
  625.  
  626.   #--------------------------------------------------------------------------
  627.   # initialize
  628.   #--------------------------------------------------------------------------
  629.   def initialize; super(0, 0); end
  630.  
  631.   #--------------------------------------------------------------------------
  632.   # window_width
  633.   #--------------------------------------------------------------------------
  634.   def window_width; return 160; end
  635.  
  636.   #--------------------------------------------------------------------------
  637.   # window_height
  638.   #--------------------------------------------------------------------------
  639.   def window_height; return Graphics.height; end
  640.  
  641.   #--------------------------------------------------------------------------
  642.   # make_command_list
  643.   #--------------------------------------------------------------------------
  644.   def make_command_list
  645.     for command in YEA::DEBUG::COMMANDS
  646.       case command[0]
  647.       when :battle
  648.         next if $game_party.in_battle
  649.       end
  650.       add_command(command[1], command[0])
  651.     end
  652.   end
  653.  
  654. end # Window_DebugCommand
  655.  
  656. #==============================================================================
  657. # ■ Window_DebugSwitch
  658. #==============================================================================
  659.  
  660. class Window_DebugSwitch < Window_Command
  661.  
  662.   #--------------------------------------------------------------------------
  663.   # initialize
  664.   #-------------------------------------------------------------------------
  665.   def initialize
  666.     super(160, 0)
  667.     deactivate
  668.     hide
  669.     refresh
  670.   end
  671.  
  672.   #--------------------------------------------------------------------------
  673.   # window_width
  674.   #--------------------------------------------------------------------------
  675.   def window_width; return Graphics.width - 160; end
  676.  
  677.   #--------------------------------------------------------------------------
  678.   # window_height
  679.   #--------------------------------------------------------------------------
  680.   def window_height; return Graphics.height - 120; end
  681.  
  682.   #--------------------------------------------------------------------------
  683.   # make_command_list
  684.   #--------------------------------------------------------------------------
  685.   def make_command_list
  686.     for i in 1...$data_system.switches.size
  687.       name = $data_system.switches[i]
  688.       text = sprintf("S%04d:%s", i, name)
  689.       add_command(text, :switch, true, i)
  690.     end
  691.   end
  692.  
  693.   #--------------------------------------------------------------------------
  694.   # draw_item
  695.   #--------------------------------------------------------------------------
  696.   def draw_item(index)
  697.     contents.clear_rect(item_rect_for_text(index))
  698.     change_switch_colour(index)
  699.     name = command_name(index)
  700.     id = @list[index][:ext]
  701.     if $game_switches[id] && $data_system.switches[id] == ""
  702.       name = sprintf("S%04d:%s", id, "ATTENTION!")
  703.     end
  704.     draw_text(item_rect_for_text(index), name, 0)
  705.     text = $game_switches[id] ? "[ON]" : "[OFF]"
  706.     draw_text(item_rect_for_text(index), text, 2)
  707.   end
  708.  
  709.   #--------------------------------------------------------------------------
  710.   # change_switch_colour
  711.   #--------------------------------------------------------------------------
  712.   def change_switch_colour(index)
  713.     id = @list[index][:ext]
  714.     enabled = $data_system.switches[id] != ""
  715.     colour = $game_switches[id] ? crisis_color : normal_color
  716.     if $game_switches[id] && $data_system.switches[id] == ""
  717.       colour = knockout_color
  718.       enabled = true
  719.     end
  720.     change_color(colour, enabled)
  721.   end
  722.  
  723. end # Window_DebugSwitch
  724.  
  725. #==============================================================================
  726. # ■ Window_DebugVariable
  727. #==============================================================================
  728.  
  729. class Window_DebugVariable < Window_Command
  730.  
  731.   #--------------------------------------------------------------------------
  732.   # initialize
  733.   #-------------------------------------------------------------------------
  734.   def initialize
  735.     super(160, 0)
  736.     deactivate
  737.     hide
  738.     refresh
  739.   end
  740.  
  741.   #--------------------------------------------------------------------------
  742.   # window_width
  743.   #--------------------------------------------------------------------------
  744.   def window_width; return Graphics.width - 160; end
  745.  
  746.   #--------------------------------------------------------------------------
  747.   # window_height
  748.   #--------------------------------------------------------------------------
  749.   def window_height; return Graphics.height - 120; end
  750.  
  751.   #--------------------------------------------------------------------------
  752.   # make_command_list
  753.   #--------------------------------------------------------------------------
  754.   def make_command_list
  755.     for i in 1...$data_system.variables.size
  756.       name = $data_system.variables[i]
  757.       text = sprintf("V%04d:%s", i, name)
  758.       add_command(text, :variable, true, i)
  759.     end
  760.   end
  761.  
  762.   #--------------------------------------------------------------------------
  763.   # draw_item
  764.   #--------------------------------------------------------------------------
  765.   def draw_item(index)
  766.     contents.clear_rect(item_rect_for_text(index))
  767.     change_variable_colour(index)
  768.     name = command_name(index)
  769.     id = @list[index][:ext]
  770.     if $game_variables[id] != 0 && $data_system.variables[id] == ""
  771.       name = sprintf("V%04d:%s", id, "ATTENTION!")
  772.     end
  773.     draw_text(item_rect_for_text(index), name, 0)
  774.     text = $game_variables[id]
  775.     text = text.group if text.is_a?(Integer)
  776.     draw_text(item_rect_for_text(index), text, 2)
  777.   end
  778.  
  779.   #--------------------------------------------------------------------------
  780.   # change_switch_colour
  781.   #--------------------------------------------------------------------------
  782.   def change_variable_colour(index)
  783.     id = @list[index][:ext]
  784.     enabled = $data_system.variables[id] != ""
  785.     colour = $game_variables[id] != 0 ? crisis_color : normal_color
  786.     if $game_variables[id] != 0 && $data_system.variables[id] == ""
  787.       colour = knockout_color
  788.       enabled = true
  789.     end
  790.     change_color(colour, enabled)
  791.   end
  792.  
  793. end # Window_DebugVariable
  794.  
  795. #==============================================================================
  796. # ■ Window_DebugInput
  797. #==============================================================================
  798.  
  799. class Window_DebugInput < Window_Selectable
  800.  
  801.   #--------------------------------------------------------------------------
  802.   # public instance variables
  803.   #--------------------------------------------------------------------------
  804.   attr_accessor :value
  805.  
  806.   #--------------------------------------------------------------------------
  807.   # initialize
  808.   #--------------------------------------------------------------------------
  809.   def initialize
  810.     dw = Graphics.width * 3 / 4
  811.     dh = fitting_height(2)
  812.     dx = (Graphics.width - dw) / 2
  813.     dy = (Graphics.height - dh) / 2
  814.     super(dx, dy, dw, dh)
  815.     self.back_opacity = 255
  816.     self.openness = 0
  817.     @max_value =  99999999
  818.     @min_value = -99999999
  819.   end
  820.  
  821.   #--------------------------------------------------------------------------
  822.   # col_max
  823.   #--------------------------------------------------------------------------
  824.   def col_max; return 9; end
  825.  
  826.   #--------------------------------------------------------------------------
  827.   # item_max
  828.   #--------------------------------------------------------------------------
  829.   def item_max; return 9; end
  830.  
  831.   #--------------------------------------------------------------------------
  832.   # horizontal?
  833.   #--------------------------------------------------------------------------
  834.   def horizontal?; return true; end
  835.  
  836.   #--------------------------------------------------------------------------
  837.   # reveal
  838.   #--------------------------------------------------------------------------
  839.   def reveal(variable)
  840.     @variable = variable
  841.     @value = $game_variables[variable]
  842.     @value = 0 unless @value.is_a?(Integer)
  843.     open
  844.     refresh
  845.     activate
  846.     select(8)
  847.   end
  848.  
  849.   #--------------------------------------------------------------------------
  850.   # refresh
  851.   #--------------------------------------------------------------------------
  852.   def refresh
  853.     super
  854.     draw_variable_name
  855.   end
  856.  
  857.   #--------------------------------------------------------------------------
  858.   # draw_variable_name
  859.   #--------------------------------------------------------------------------
  860.   def draw_variable_name
  861.     name = $data_system.variables[@variable]
  862.     name = "ATTENTION" if name == ""
  863.     text = sprintf("V%04d:%s", @variable, name)
  864.     draw_text(4, 0, contents.width-8, line_height, text, 1)
  865.   end
  866.  
  867.   #--------------------------------------------------------------------------
  868.   # item_rect
  869.   #--------------------------------------------------------------------------
  870.   def item_rect(index)
  871.     rect = Rect.new(0, line_height, 24, line_height)
  872.     rect.x = (contents.width-32-24*col_max)/2+index*24+12
  873.     return rect
  874.   end
  875.  
  876.   #--------------------------------------------------------------------------
  877.   # draw_item
  878.   #--------------------------------------------------------------------------
  879.   def draw_item(index)
  880.     rect = item_rect(index)
  881.     contents.clear_rect(rect)
  882.     if index == 0
  883.       text = @value >= 0 ? "+" : "-"
  884.     else
  885.       text = @value.abs % 10**(col_max-index)/(10**(col_max-1-index))
  886.     end
  887.     contents.draw_text(rect.x, rect.y, rect.width, line_height, text, 1)
  888.   end
  889.  
  890.   #--------------------------------------------------------------------------
  891.   # cursor_down
  892.   #--------------------------------------------------------------------------
  893.   def cursor_down(wrap = false)
  894.     Sound.play_cursor
  895.     @value = index == 0 ? @value * -1 : @value - 10**(col_max-1 - index)
  896.     @value = [[@value, @max_value].min, @min_value].max
  897.     draw_all_items
  898.   end
  899.  
  900.   #--------------------------------------------------------------------------
  901.   # cursor_up
  902.   #--------------------------------------------------------------------------
  903.   def cursor_up(wrap = false)
  904.     Sound.play_cursor
  905.     @value = index == 0 ? @value * -1 : @value + 10**(col_max-1 - index)
  906.     @value = [[@value, @max_value].min, @min_value].max
  907.     draw_all_items
  908.   end
  909.  
  910. end # Window_DebugInput
  911.  
  912. #==============================================================================
  913. # ■ Window_DebugBattle
  914. #==============================================================================
  915.  
  916. class Window_DebugBattle < Window_Command
  917.  
  918.   #--------------------------------------------------------------------------
  919.   # initialize
  920.   #-------------------------------------------------------------------------
  921.   def initialize
  922.     super(160, 0)
  923.     deactivate
  924.     hide
  925.     refresh
  926.   end
  927.  
  928.   #--------------------------------------------------------------------------
  929.   # window_width
  930.   #--------------------------------------------------------------------------
  931.   def window_width; return Graphics.width - 160; end
  932.  
  933.   #--------------------------------------------------------------------------
  934.   # window_height
  935.   #--------------------------------------------------------------------------
  936.   def window_height; return Graphics.height - 120; end
  937.  
  938.   #--------------------------------------------------------------------------
  939.   # make_command_list
  940.   #--------------------------------------------------------------------------
  941.   def make_command_list
  942.     for i in 1...$data_troops.size
  943.       name = $data_troops[i].name
  944.       text = sprintf("B%03d:%s", i, name)
  945.       add_command(text, :battle, true, i)
  946.     end
  947.   end
  948.  
  949.   #--------------------------------------------------------------------------
  950.   # draw_item
  951.   #--------------------------------------------------------------------------
  952.   def draw_item(index)
  953.     contents.clear_rect(item_rect_for_text(index))
  954.     name = command_name(index)
  955.     draw_text(item_rect_for_text(index), name, 0)
  956.   end
  957.  
  958. end # Window_DebugBattle
  959.  
  960. #==============================================================================
  961. # ■ Window_DebugCommonEvent
  962. #==============================================================================
  963.  
  964. class Window_DebugCommonEvent < Window_Command
  965.  
  966.   #--------------------------------------------------------------------------
  967.   # initialize
  968.   #-------------------------------------------------------------------------
  969.   def initialize
  970.     super(160, 0)
  971.     deactivate
  972.     hide
  973.     refresh
  974.   end
  975.  
  976.   #--------------------------------------------------------------------------
  977.   # window_width
  978.   #--------------------------------------------------------------------------
  979.   def window_width; return Graphics.width - 160; end
  980.  
  981.   #--------------------------------------------------------------------------
  982.   # window_height
  983.   #--------------------------------------------------------------------------
  984.   def window_height; return Graphics.height - 120; end
  985.  
  986.   #--------------------------------------------------------------------------
  987.   # make_command_list
  988.   #--------------------------------------------------------------------------
  989.   def make_command_list
  990.     for i in 1...$data_common_events.size
  991.       name = $data_common_events[i].name
  992.       text = sprintf("E%03d:%s", i, name)
  993.       add_command(text, :event, true, i)
  994.     end
  995.   end
  996.  
  997.   #--------------------------------------------------------------------------
  998.   # draw_item
  999.   #--------------------------------------------------------------------------
  1000.   def draw_item(index)
  1001.     contents.clear_rect(item_rect_for_text(index))
  1002.     name = command_name(index)
  1003.     draw_text(item_rect_for_text(index), name, 0)
  1004.   end
  1005.  
  1006. end # Window_DebugCommonEvent
  1007.  
  1008. #==============================================================================
  1009. # ■ Window_DebugItem
  1010. #==============================================================================
  1011.  
  1012. class Window_DebugItem < Window_Command
  1013.  
  1014.   #--------------------------------------------------------------------------
  1015.   # initialize
  1016.   #-------------------------------------------------------------------------
  1017.   def initialize
  1018.     super(160, 0)
  1019.     deactivate
  1020.     hide
  1021.   end
  1022.  
  1023.   #--------------------------------------------------------------------------
  1024.   # window_width
  1025.   #--------------------------------------------------------------------------
  1026.   def window_width; return Graphics.width - 160; end
  1027.  
  1028.   #--------------------------------------------------------------------------
  1029.   # window_height
  1030.   #--------------------------------------------------------------------------
  1031.   def window_height; return Graphics.height - 120; end
  1032.  
  1033.   #--------------------------------------------------------------------------
  1034.   # set_type
  1035.   #--------------------------------------------------------------------------
  1036.   def set_type(type)
  1037.     @type = type
  1038.     refresh
  1039.     select(0)
  1040.   end
  1041.  
  1042.   #--------------------------------------------------------------------------
  1043.   # make_command_list
  1044.   #--------------------------------------------------------------------------
  1045.   def make_command_list
  1046.     case @type
  1047.     when :items
  1048.       group = $data_items
  1049.       fmt = "I%03d:"
  1050.     when :weapons
  1051.       group = $data_weapons
  1052.       fmt = "W%03d:"
  1053.     else
  1054.       group = $data_armors
  1055.       fmt = "A%03d:"
  1056.     end
  1057.     for i in 1...group.size
  1058.       text = sprintf(fmt, i)
  1059.       add_command(text, :item, true, group[i])
  1060.     end
  1061.   end
  1062.  
  1063.   #--------------------------------------------------------------------------
  1064.   # draw_item
  1065.   #--------------------------------------------------------------------------
  1066.   def draw_item(index)
  1067.     contents.clear_rect(item_rect_for_text(index))
  1068.     rect = item_rect_for_text(index)
  1069.     item = @list[index][:ext]
  1070.     name = item.name
  1071.     change_color(normal_color, $game_party.item_number(item) > 0)
  1072.     if $game_party.item_number(item) > 0 && item.name == ""
  1073.       change_color(knockout_color)
  1074.       name = "ATTENTION!"
  1075.     end
  1076.     draw_text(rect, command_name(index))
  1077.     rect.x += text_size(command_name(index)).width
  1078.     rect.width -= text_size(command_name(index)).width
  1079.     draw_icon(item.icon_index, rect.x, rect.y, $game_party.item_number(item) > 0)
  1080.     rect.x += 24
  1081.     rect.width -= 24
  1082.     draw_text(rect, name)
  1083.     text = sprintf("×%s", $game_party.item_number(item).group)
  1084.     draw_text(rect, text, 2)
  1085.   end
  1086.  
  1087.   #--------------------------------------------------------------------------
  1088.   # cursor_right
  1089.   #--------------------------------------------------------------------------
  1090.   def cursor_right(wrap = false)
  1091.     Sound.play_cursor
  1092.     $game_party.gain_item(current_ext, Input.press?(:SHIFT) ? 10 : 1)
  1093.     $game_party.gain_item(current_ext, Input.press?(:CTRL) ? 99 : 0)
  1094.     draw_item(index)
  1095.   end
  1096.  
  1097.   #--------------------------------------------------------------------------
  1098.   # cursor_left
  1099.   #--------------------------------------------------------------------------
  1100.   def cursor_left(wrap = false)
  1101.     Sound.play_cursor
  1102.     $game_party.lose_item(current_ext, Input.press?(:SHIFT) ? 10 : 1)
  1103.     $game_party.lose_item(current_ext, Input.press?(:CTRL) ? 99 : 0)
  1104.     draw_item(index)
  1105.   end
  1106.  
  1107. end # Window_DebugItem
  1108.  
  1109. #==============================================================================
  1110. # ■ Scene_Debug
  1111. #==============================================================================
  1112.  
  1113. class Scene_Debug < Scene_MenuBase
  1114.  
  1115.   #--------------------------------------------------------------------------
  1116.   # overwrite method: start
  1117.   #--------------------------------------------------------------------------
  1118.   def start
  1119.     super
  1120.     create_all_windows
  1121.   end
  1122.  
  1123.   #--------------------------------------------------------------------------
  1124.   # new method: update
  1125.   #--------------------------------------------------------------------------
  1126.   def update
  1127.     super
  1128.     return_scene if Input.trigger?(:F9)
  1129.   end
  1130.  
  1131.   #--------------------------------------------------------------------------
  1132.   # new method: create_all_windows
  1133.   #--------------------------------------------------------------------------
  1134.   def create_all_windows
  1135.     create_command_window
  1136.     create_help_window
  1137.     create_dummy_window
  1138.     create_switch_window
  1139.     create_variable_window
  1140.     create_battle_windows
  1141.     create_common_event_windows
  1142.     create_item_windows
  1143.   end
  1144.  
  1145.   #--------------------------------------------------------------------------
  1146.   # new method: create_command_window
  1147.   #--------------------------------------------------------------------------
  1148.   def create_command_window
  1149.     @command_window = Window_DebugCommand.new
  1150.     @command_window.set_handler(:cancel, method(:return_scene))
  1151.     @command_window.set_handler(:switches, method(:command_switches))
  1152.     @command_window.set_handler(:variables, method(:command_variables))
  1153.     @command_window.set_handler(:battle, method(:command_battle))
  1154.     @command_window.set_handler(:events, method(:command_common_event))
  1155.     @command_window.set_handler(:items, method(:command_items))
  1156.     @command_window.set_handler(:weapons, method(:command_items))
  1157.     @command_window.set_handler(:armours, method(:command_items))
  1158.   end
  1159.  
  1160.   #--------------------------------------------------------------------------
  1161.   # new method: create_help_window
  1162.   #--------------------------------------------------------------------------
  1163.   def create_help_window
  1164.     wx = @command_window.width
  1165.     wy = Graphics.height - 120
  1166.     ww = Graphics.width - wx
  1167.     wh = 120
  1168.     @help_window = Window_Base.new(wx, wy, ww, wh)
  1169.   end
  1170.  
  1171.   #--------------------------------------------------------------------------
  1172.   # new method: create_dummy_window
  1173.   #--------------------------------------------------------------------------
  1174.   def create_dummy_window
  1175.     wx = @command_window.width
  1176.     ww = Graphics.width - wx
  1177.     wh = Graphics.height - @help_window.height
  1178.     @dummy_window = Window_Base.new(wx, 0, ww, wh)
  1179.   end
  1180.  
  1181.   #--------------------------------------------------------------------------
  1182.   # new method: create_switch_window
  1183.   #--------------------------------------------------------------------------
  1184.   def create_switch_window
  1185.     @switch_window = Window_DebugSwitch.new
  1186.     @switch_window.set_handler(:ok, method(:on_switch_ok))
  1187.     @switch_window.set_handler(:cancel, method(:on_switch_cancel))
  1188.   end
  1189.  
  1190.   #--------------------------------------------------------------------------
  1191.   # new method: command_switches
  1192.   #--------------------------------------------------------------------------
  1193.   def command_switches
  1194.     @dummy_window.hide
  1195.     @switch_window.show
  1196.     @switch_window.activate
  1197.     refresh_help_window
  1198.   end
  1199.  
  1200.   #--------------------------------------------------------------------------
  1201.   # new method: on_switch_ok
  1202.   #--------------------------------------------------------------------------
  1203.   def on_switch_ok
  1204.     @switch_window.activate
  1205.     switch_id = @switch_window.current_ext
  1206.     $game_switches[switch_id] = !$game_switches[switch_id]
  1207.     @switch_window.draw_item(@switch_window.index)
  1208.   end
  1209.  
  1210.   #--------------------------------------------------------------------------
  1211.   # new method: on_switch_cancel
  1212.   #--------------------------------------------------------------------------
  1213.   def on_switch_cancel
  1214.     @dummy_window.show
  1215.     @switch_window.hide
  1216.     @command_window.activate
  1217.     refresh_help_window
  1218.   end
  1219.  
  1220.   #--------------------------------------------------------------------------
  1221.   # new method: create_variable_window
  1222.   #--------------------------------------------------------------------------
  1223.   def create_variable_window
  1224.     @variable_window = Window_DebugVariable.new
  1225.     @variable_window.set_handler(:ok, method(:on_variable_ok))
  1226.     @variable_window.set_handler(:cancel, method(:on_variable_cancel))
  1227.     @input_window = Window_DebugInput.new
  1228.     @input_window.set_handler(:ok, method(:on_input_ok))
  1229.     @input_window.set_handler(:cancel, method(:on_input_cancel))
  1230.   end
  1231.  
  1232.   #--------------------------------------------------------------------------
  1233.   # new method: command_variables
  1234.   #--------------------------------------------------------------------------
  1235.   def command_variables
  1236.     @dummy_window.hide
  1237.     @variable_window.show
  1238.     @variable_window.activate
  1239.     refresh_help_window
  1240.   end
  1241.  
  1242.   #--------------------------------------------------------------------------
  1243.   # new method: on_variable_ok
  1244.   #--------------------------------------------------------------------------
  1245.   def on_variable_ok
  1246.     @input_window.reveal(@variable_window.current_ext)
  1247.   end
  1248.  
  1249.   #--------------------------------------------------------------------------
  1250.   # new method: on_variable_cancel
  1251.   #--------------------------------------------------------------------------
  1252.   def on_variable_cancel
  1253.     @dummy_window.show
  1254.     @variable_window.hide
  1255.     @command_window.activate
  1256.     refresh_help_window
  1257.   end
  1258.  
  1259.   #--------------------------------------------------------------------------
  1260.   # new method: on_input_ok
  1261.   #--------------------------------------------------------------------------
  1262.   def on_input_ok
  1263.     $game_variables[@variable_window.current_ext] = @input_window.value
  1264.     @input_window.close
  1265.     @input_window.deactivate
  1266.     @variable_window.activate
  1267.     @variable_window.draw_item(@variable_window.index)
  1268.   end
  1269.  
  1270.   #--------------------------------------------------------------------------
  1271.   # new method: on_input_cancel
  1272.   #--------------------------------------------------------------------------
  1273.   def on_input_cancel
  1274.     @input_window.close
  1275.     @input_window.deactivate
  1276.     @variable_window.activate
  1277.   end
  1278.  
  1279.   #--------------------------------------------------------------------------
  1280.   # new method: create_battle_windows
  1281.   #--------------------------------------------------------------------------
  1282.   def create_battle_windows
  1283.     @battle_window = Window_DebugBattle.new
  1284.     @battle_window.set_handler(:ok, method(:on_battle_ok))
  1285.     @battle_window.set_handler(:cancel, method(:on_battle_cancel))
  1286.   end
  1287.  
  1288.   #--------------------------------------------------------------------------
  1289.   # new method: command_battle
  1290.   #--------------------------------------------------------------------------
  1291.   def command_battle
  1292.     @dummy_window.hide
  1293.     @battle_window.show
  1294.     @battle_window.activate
  1295.     refresh_help_window
  1296.   end
  1297.  
  1298.   #--------------------------------------------------------------------------
  1299.   # new method: on_battle_ok
  1300.   #--------------------------------------------------------------------------
  1301.   def on_battle_ok
  1302.     troop_id = @battle_window.current_ext
  1303.     BattleManager.setup(troop_id)
  1304.     BattleManager.on_encounter
  1305.     SceneManager.call(Scene_Battle)
  1306.     BattleManager.save_bgm_and_bgs
  1307.     BattleManager.play_battle_bgm
  1308.     Sound.play_battle_start
  1309.   end
  1310.  
  1311.   #--------------------------------------------------------------------------
  1312.   # new method: on_battle_cancel
  1313.   #--------------------------------------------------------------------------
  1314.   def on_battle_cancel
  1315.     @dummy_window.show
  1316.     @battle_window.hide
  1317.     @command_window.activate
  1318.     refresh_help_window
  1319.   end
  1320.  
  1321.   #--------------------------------------------------------------------------
  1322.   # new method: create_common_event_windows
  1323.   #--------------------------------------------------------------------------
  1324.   def create_common_event_windows
  1325.     @event_window = Window_DebugCommonEvent.new
  1326.     @event_window.set_handler(:ok, method(:on_event_ok))
  1327.     @event_window.set_handler(:cancel, method(:on_event_cancel))
  1328.   end
  1329.  
  1330.   #--------------------------------------------------------------------------
  1331.   # new method: command_common_event
  1332.   #--------------------------------------------------------------------------
  1333.   def command_common_event
  1334.     @dummy_window.hide
  1335.     @event_window.show
  1336.     @event_window.activate
  1337.     refresh_help_window
  1338.   end
  1339.  
  1340.   #--------------------------------------------------------------------------
  1341.   # new method: on_event_ok
  1342.   #--------------------------------------------------------------------------
  1343.   def on_event_ok
  1344.     event_id = @event_window.current_ext
  1345.     $game_temp.reserve_common_event(event_id)
  1346.     return_scene
  1347.   end
  1348.  
  1349.   #--------------------------------------------------------------------------
  1350.   # new method: on_event_cancel
  1351.   #--------------------------------------------------------------------------
  1352.   def on_event_cancel
  1353.     @dummy_window.show
  1354.     @event_window.hide
  1355.     @command_window.activate
  1356.     refresh_help_window
  1357.   end
  1358.  
  1359.   #--------------------------------------------------------------------------
  1360.   # new method: create_item_windows
  1361.   #--------------------------------------------------------------------------
  1362.   def create_item_windows
  1363.     @item_window = Window_DebugItem.new
  1364.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  1365.   end
  1366.  
  1367.   #--------------------------------------------------------------------------
  1368.   # new method: command_items
  1369.   #--------------------------------------------------------------------------
  1370.   def command_items
  1371.     @dummy_window.hide
  1372.     @item_window.show
  1373.     @item_window.activate
  1374.     @item_window.set_type(@command_window.current_symbol)
  1375.     refresh_help_window
  1376.   end
  1377.  
  1378.   #--------------------------------------------------------------------------
  1379.   # new method: on_item_cancel
  1380.   #--------------------------------------------------------------------------
  1381.   def on_item_cancel
  1382.     @dummy_window.show
  1383.     @item_window.hide
  1384.     @command_window.activate
  1385.     refresh_help_window
  1386.   end
  1387.  
  1388.   #--------------------------------------------------------------------------
  1389.   # new method: refresh_help_window
  1390.   #--------------------------------------------------------------------------
  1391.   def refresh_help_window
  1392.     if @command_window.active
  1393.       text  = ""
  1394.     else
  1395.       case @command_window.current_symbol
  1396.       when :switches
  1397.         text  = "Adjust switches.\n"
  1398.         text += "Press Z to toggle switch.\n"
  1399.         text += "Yellow switches are on and named.\n"
  1400.         text += "Red switches are on but are unnamed."
  1401.       when :variables
  1402.         text  = "Adjust variables.\n"
  1403.         text += "Press Z to modify variable.\n"
  1404.         text += "Yellow aren't 0 and named.\n"
  1405.         text += "Red aren't 0 and are unnamed."
  1406.       when :battle
  1407.         text  = "Test Battles.\n"
  1408.         text += "Select a battle and press Z.\n"
  1409.         text += "These battles are all found\n"
  1410.         text += "within the database."
  1411.       when :events
  1412.         text  = "Test Common Events.\n"
  1413.         text += "Select an event and press Z.\n"
  1414.         text += "You will automatically be taken\n"
  1415.         text += "to previous scene to run event."
  1416.       when :items
  1417.         text  = "Adjust items.\n"
  1418.         text += "Press Left/Right to lose/gain.\n"
  1419.         text += "Hold SHIFT for increments of 10.\n"
  1420.         text += "Hold CTRL for increments of 100."
  1421.       when :weapons
  1422.         text  = "Adjust weapons.\n"
  1423.         text += "Press Left/Right to lose/gain.\n"
  1424.         text += "Hold SHIFT for increments of 10.\n"
  1425.         text += "Hold CTRL for increments of 100."
  1426.       when :armours
  1427.         text  = "Adjust armours.\n"
  1428.         text += "Press Left/Right to lose/gain.\n"
  1429.         text += "Hold SHIFT for increments of 10.\n"
  1430.         text += "Hold CTRL for increments of 100."
  1431.       else
  1432.         text  = ""
  1433.       end
  1434.     end
  1435.     @help_window.contents.clear
  1436.     @help_window.draw_text_ex(4, 0, text)
  1437.   end
  1438.  
  1439. end # Scene_Debug
  1440.  
  1441. #==============================================================================
  1442. #
  1443. # ▼ End of File
  1444. #
  1445. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement