Advertisement
ForeverZer0

[RMXP][RMVX] Console Debug

May 21st, 2011
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.27 KB | None | 0 0
  1. if true
  2.  
  3.   # This will format the console screen a lottle better since it uses word wrap.
  4.   # Set condition to false abive to disable.
  5.  
  6.   alias zer0_console_inspect puts
  7.  
  8.   def puts(*args)
  9.    
  10.     inspected = args.collect {|arg| arg.inspect.gsub(',') { "\n" } }
  11.  
  12.     zer0_console_inspect(*inspected)
  13.  
  14.   end
  15. end
  16.  
  17. if $DEBUG || $TEST
  18.   # Create a console object and redirect standard output to it.
  19.   Win32API.new('kernel32', 'AllocConsole', 'V', 'L').call
  20.   $stdout.reopen('CONOUT$')
  21.   # Find the game title.
  22.   ini = Win32API.new('kernel32','GetPrivateProfileString','PPPPLP', 'L')
  23.   title = "\0" * 256
  24.   ini.call('Game', 'Title', '', title, 256, '.\\Game.ini')
  25.   title.delete!("\0")
  26.   # Set the game window as the top-most window.
  27.   hwnd = Win32API.new('user32', 'FindWindowA', 'PP', 'L').call('RGSS Player', title)  
  28.   Win32API.new('user32', 'SetForegroundWindow', 'L', 'L').call(hwnd)
  29.   # Set the title of the console debug window'
  30.   Win32API.new('kernel32','SetConsoleTitleA','P','S').call("#{title} :  Debug Console")
  31.   dim = [32, 32, 256, 480]
  32.   console = Win32API.new('kernel32', 'GetConsoleWindow', 'V', 'L').call
  33.   swp = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
  34.   swp.call(console, 0, dim[0], dim[1], dim[2] + 6, dim[3] + 26, -1)
  35.  
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement