Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # RSM's VX&ACE FULLSCREEN & SCALE v1.0
- # Compatible with RPG Maker VX and RPG Maker VX Ace
- # (In RPG Maker XP, it works only thr fullscreen toggle!)
- #_______________________________________________________________________________
- # Description | Puts the game in fullscreen or in a given scale only by
- # | pressing a key, with automatic corrected scale considering
- # | window borders. Similar effect from RPG Maker 2000/2003.
- # | Supports adjustable game window scale and custom keys to
- # | toggle fullscreen and scaled screen mode.
- #________________|______________________________________________________________
- # Usage | Plug and Play! (But got some optional adjusts)
- #________________|______________________________________________________________
- # Specifications | Difficulty to Use:
- # | * (meh easy)
- # | Scripting Difficulty:
- # | * * * ¾ (required advanced API knowledge)
- # | Compatibility:
- # | * * * * (probably highly compatible)
- # | New Methods:
- # | - Graphics.fullscreen?
- # | - Graphics.toggle_fullscreen
- # | - Graphics.scaled?
- # | Overwritten Methods:
- # | - (none)
- # | Aliased Methods:
- # | - Graphics.update
- #________________|______________________________________________________________
- # Special Thanks | Game_guy, OriginalWij, Mechacrash, Kylock
- #________________|______________________________________________________________
- #===============================================================================
- #==============================================================================
- # ** Configurables
- #------------------------------------------------------------------------------
- module Configurables
- # SCREEN OPTIONS
- # Game screen width (adjustable resolution mode)
- Resized_Width = (Graphics.width * 2)
- # Game screen height (adjustable resolution mode)
- Resized_Height = (Graphics.height * 2)
- # KEY OPTIONS
- # Key to toggle scaled screen mode
- Resize_Key = Input::F5
- # Key to toggle fullscreen mode
- Fullscreen_Key = Input::F6
- end
- #==============================================================================
- # ** Graphics
- #------------------------------------------------------------------------------
- class << Graphics
- include Configurables
- #--------------------------------------------------------------------------
- # * Aliasing the graphics update to track the keys we want
- #--------------------------------------------------------------------------
- alias rsm_fullscreen_scale_update update
- def Graphics.update
- rsm_fullscreen_scale_update
- toggle_fullscreen if Input.trigger?(Resize_Key)
- if Input.trigger?(Fullscreen_Key)
- scaled? ? __scale_window__(Graphics.width , Graphics.height)
- : __scale_window__(Resized_Width, Resized_Height)
- end
- end
- #--------------------------------------------------------------------------
- # * use some clever API to find if we're on fullscreen resolution
- #--------------------------------------------------------------------------
- def Graphics.fullscreen?
- screen_size = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
- screen_width = screen_size.call(0); screen_height = screen_size.call(1)
- (screen_width == 640 && screen_height == 480)
- end
- #--------------------------------------------------------------------------
- # * It will toggle de fullscreen mode on and off.
- #--------------------------------------------------------------------------
- def Graphics.toggle_fullscreen
- keybd = Win32API.new 'user32.dll', 'keybd_event', ['i', 'i', 'l', 'l'], 'v'
- keybd.call(0xA4, 0, 0, 0)
- keybd.call(13, 0, 0, 0)
- keybd.call(13, 0, 2, 0)
- keybd.call(0xA4, 0, 2, 0)
- end
- #--------------------------------------------------------------------------
- # * Check whether our graphics were previously scaled or not
- #--------------------------------------------------------------------------
- def Graphics.scaled?
- rect = [0, 0, 0, 0].pack('l4')
- find = Win32API.new('user32', 'FindWindowEx', ['l','l','p','p'], 'i')
- window = find.call(0, 0, "RGSS Player", 0)
- Win32API.new('user32', 'GetClientRect', %w(l p), 'i').call(window, rect)
- width, height = rect.unpack('l4')[2..3]
- (width != Graphics.width && height != Graphics.height)
- end
- #--------------------------------------------------------------------------
- # * Internal use. Function to do the hard job of scaling the window
- #--------------------------------------------------------------------------
- def Graphics.__scale_window__(width, height)
- unless fullscreen?
- size = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
- move = Win32API.new('user32', 'MoveWindow', ['l','i','i','i','i','l'], 'l')
- find = Win32API.new('user32', 'FindWindowEx', ['l','l','p','p'], 'i')
- window = find.call(0, 0, "RGSS Player", 0)
- window_w = size.call(0)
- window_h = size.call(1)
- border = __border__
- move.call(window, (window_w - width + border[0]) / 2,
- (window_h - height + border[1]) / 2,
- width + border[0], height + border[1], 1)
- end
- end
- #--------------------------------------------------------------------------
- # * Internal use. Detect difference between user area and total window
- #--------------------------------------------------------------------------
- def Graphics.__border__
- rect = [0, 0, 0, 0].pack('l4'); rect2 = [0, 0, 0, 0].pack('l4')
- find = Win32API.new('user32', 'FindWindowEx', ['l','l','p','p'], 'i')
- window = find.call(0, 0, "RGSS Player", 0)
- Win32API.new('user32', 'GetClientRect', %w(l p), 'i').call(window, rect)
- Win32API.new('user32', 'GetWindowRect', %w(l p), 'i').call(window, rect2)
- width, height = rect.unpack('l4') [2..3]
- x, y, x2, y2 = rect2.unpack('l4') [0..3]
- w2 = x2 - x; h2 = y2- y
- [w2 - width, h2 - height]
- end
- end
- #-------------------------------------------------------------------------------
- # * THE END - That's all, folks!
- #-------------------------------------------------------------------------------
- #===============================================================================
Add Comment
Please, Sign In to add comment