Advertisement
Guest User

doorstuck adjustable fullscreen script 1.1

a guest
Feb 21st, 2015
820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.73 KB | None | 0 0
  1. #doorstuck adjustable fullscreen 1.1
  2.  
  3. class AdjustableResizer
  4.  
  5.   CreateWindowEx            = Win32API.new('user32'  , 'CreateWindowEx'           , 'ippiiiiiiiii', 'i')
  6.   GetDC                     = Win32API.new('user32'  , 'GetDC'                    , 'i'           , 'i')
  7.   GetSystemMetrics          = Win32API.new('user32'  , 'GetSystemMetrics'         , 'i'           , 'i')
  8.   FillRect                  = Win32API.new('user32'  , 'FillRect'                 , 'ipi'         , 'i')
  9.   FindWindow                = Win32API.new('user32'  , 'FindWindow'               , 'pp'          , 'i')
  10.   ReleaseDC                 = Win32API.new('user32'  , 'ReleaseDC'                , 'ii'          , 'i')
  11.   SetWindowLong             = Win32API.new('user32'  , 'SetWindowLong'            , 'iii'         , 'i')
  12.   SetWindowPos              = Win32API.new('user32'  , 'SetWindowPos'             , 'iiiiiii'     , 'i')
  13.   ShowWindow                = Win32API.new('user32'  , 'ShowWindow'               , 'ii'          , 'i')
  14.   UpdateWindow              = Win32API.new('user32'  , 'UpdateWindow'             , 'i'           , 'i')
  15.   GetWindowRect             = Win32API.new('user32'  , 'GetWindowRect'            , 'ip'          , 'i')
  16.   CreateSolidBrush          = Win32API.new('gdi32'   , 'CreateSolidBrush'         , 'i'           , 'i')
  17.   DeleteObject              = Win32API.new('gdi32'   , 'DeleteObject'             , 'i'           , 'i')
  18.  
  19.   def initialize()
  20.     @defaultRpgMakerX = 544
  21.     @defaultRpgMakerY = 416
  22.    
  23.     @screenRect = Rect.new(0, 0, GetSystemMetrics.call(0), GetSystemMetrics.call(1))
  24.  
  25.     #universal constant
  26.     @rpgMakerX = 640
  27.     #height that we would render if rpg maker would render non 32 tiles
  28.     wishfulY = @rpgMakerX * @screenRect.height / @screenRect.width
  29.  
  30.     #divide by 32 and multiply by 32 to get the actual number of pixels that
  31.     #could be rendered by RPG maker without glitches
  32.     @rpgMakerY = (wishfulY / 32) * 32
  33.  
  34.     rpgMakerRaimander = wishfulY - @rpgMakerY
  35.  
  36.     #now we need to calculate the actual screen margin from top and bottom
  37.     actualScreenMargin = @screenRect.height * rpgMakerRaimander / wishfulY
  38.     @mainHeight = @screenRect.height - actualScreenMargin
  39.     @upperMargin = actualScreenMargin / 2
  40.  
  41.     #draw black background on all the screen
  42.     @BackgroundHandler = CreateWindowEx.call(0x08000008, 'Static', '', 0x80000000, 0, 0, 0, 0, 0, 0, 0, 0)
  43.     @mainWindowHandler = FindWindow.call('RGSS Player', 0)
  44.    
  45.     windowRectPointer = [0, 0, 0, 0].pack('l4')
  46.     GetWindowRect.call(@mainWindowHandler, windowRectPointer)
  47.     @originalWindowRect = windowRectPointer.unpack('l4')
  48.   end
  49.  
  50.   def backToWindowed
  51.     Graphics.resize_screen(@defaultRpgMakerX, @defaultRpgMakerY)
  52.     SetWindowLong.call(@mainWindowHandler, -16, 0x14CA0000)
  53.     SetWindowPos.call(@mainWindowHandler, -1, @originalWindowRect[0], @originalWindowRect[1], @originalWindowRect[2] - @originalWindowRect[0], @originalWindowRect[3] - @originalWindowRect[1], 0)
  54.     ShowWindow.call(@BackgroundHandler, 0)
  55.   end
  56.  
  57.   def adjustableFullscreen
  58.     Graphics.resize_screen(@rpgMakerX, @rpgMakerY)
  59.     paintBackground()
  60.     SetWindowLong.call(@mainWindowHandler, -16, 0x14000000)
  61.     SetWindowPos.call(@mainWindowHandler, -1, 0, @upperMargin, @screenRect.width, @mainHeight, 0)
  62.   end
  63.  
  64.   def paintBackground
  65.     ShowWindow.call(@BackgroundHandler, 3)
  66.     UpdateWindow.call(@BackgroundHandler)
  67.     dc    = GetDC.call(@BackgroundHandler)
  68.     rect  = [0, 0, @screenRect.width, @screenRect.height].pack('l4')
  69.     brush = CreateSolidBrush.call(0)
  70.     FillRect.call(dc, rect, brush)
  71.     ReleaseDC.call(@BackgroundHandler, dc)
  72.     DeleteObject.call(brush)
  73.   end
  74.  
  75. end
  76.  
  77. resizer = AdjustableResizer.new()
  78. resizer.adjustableFullscreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement