Advertisement
neutale

DebugWindowShortcut

Jan 15th, 2019
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.53 KB | None | 0 0
  1. #===============================================================================
  2. # 2018/07/04 kido0617
  3. # http://kido0617.github.io/
  4. # Public Domain
  5. # Please use freely, credit not necessary
  6. # Website: http://kido0617.github.io/rpgmaker/2018-07-05-debug-shortcut-vxace
  7. # Ver.1.0
  8. #-------------------------------------------------------------------------------
  9.  
  10. class Scene_Debug < Scene_MenuBase
  11.  
  12.   KEYS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 83, 86, 8]
  13.   DOWN_STATE_MASK   = (0x8 << 0x04)
  14.   @@GetKeyState = Win32API.new('user32','GetKeyState',['L'],'L')
  15.  
  16.   alias my_debug_start start
  17.   def start
  18.     my_debug_start
  19.     @keyPressed = {}
  20.     KEYS.each do |key|
  21.       @keyPressed[key] = false
  22.     end
  23.     @short_cut = ''
  24.     @str_num = ''
  25.   end
  26.  
  27.   def update
  28.     super
  29.     KEYS.each do |key|
  30.         on = @@GetKeyState.call(key) & DOWN_STATE_MASK == DOWN_STATE_MASK
  31.         if !@keyPressed[key] && on
  32.           trigger(key)
  33.         end
  34.         @keyPressed[key] = on
  35.     end
  36.   end
  37.  
  38.   def trigger(key)
  39.     if key == 83 #S
  40.       @short_cut = 'S'
  41.       @str_num = ''
  42.       jump()
  43.     elsif key == 86 #V
  44.       @short_cut = 'V'
  45.       @str_num = ''
  46.       jump()
  47.     elsif key == 8 #backspace
  48.       return if @str_num.length == 0
  49.       @str_num = @str_num.slice(0, @str_num.length - 1)
  50.       jump()
  51.     else
  52.       return if @str_num.length == 0 && key == 48 #Null 0
  53.       @str_num += (key - 48).to_s
  54.       jump()
  55.     end
  56.   end
  57.  
  58.   def jump()
  59.     return if @short_cut == nil
  60.     switchMax = ($data_system.switches.size - 1 + 9) / 10
  61.     rangeIndex = @short_cut == 'S' ? 0 : switchMax;
  62.     if @str_num != ''
  63.       num = @str_num.to_i;
  64.       if (@short_cut =='S' && num > $data_system.switches.size - 1) || (@short_cut =='V' && num > $data_system.variables.size - 1)
  65.          Sound.play_buzzer
  66.          num = @short_cut == 'S' ?  $data_system.switches.size - 1 : $data_system.variables.size - 1
  67.       end
  68.       rangeIndex += ((num - 1) / 10).floor;
  69.       @left_window.select(rangeIndex);
  70.       @left_window.deactivate();
  71.       @right_window.activate();
  72.       @right_window.select((num -1) % 10);
  73.     else
  74.       @left_window.select(rangeIndex);
  75.       @left_window.activate();
  76.       @right_window.deactivate();
  77.     end
  78.     refresh_help_window()
  79.   end
  80.  
  81.   alias my_refresh_help_window refresh_help_window
  82.   def refresh_help_window
  83.     @debug_help_window.contents.clear
  84.     my_refresh_help_window
  85.     str = @short_cut + @str_num;
  86.     @debug_help_window.draw_text_ex(270, @debug_help_window.line_height() * 4, str)
  87.   end
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement