03-03-2008, 06:36 AM
Resolution
by Selwyn
by Selwyn
INTRODUCTION
Selwyn @ RMXP.Org Mon Jun 19, 2006 Wrote:Important : This is mainly
designed for scripter!
okay, this will allow you want to make your game in a resolution of 800 by
600, or greater if you so desire.
what you need :
The Display DLL, download it in your game folder (it has to be named
Display.dll) and the following script
SCRIPT
The Script
Code:
#==============================================================================
# ? Resolution
#------------------------------------------------------------------------------
# created by Selwyn
# selwyn@rmxp.ch
#
# released on the 19th of June 2006
#
# allows to change the game window's resolution to 800 by 600.
#==============================================================================
module Resolution
#--------------------------------------------------------------------------
# ? instance variables
#--------------------------------------------------------------------------
attr_reader :state
#--------------------------------------------------------------------------
# ? initialize
#--------------------------------------------------------------------------
def initialize
title = "\0" * 256
Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L').call("Game", "Title", "", title, 256, ".\\Game.ini")
title.delete!("\0")
@set_resolution = Win32API.new('Display.dll', 'SetResolution', 'III', 'I')
@set_window_long = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
@set_window_pos = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
@gsm = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
@gcr = Win32API.new('user32', 'GetClientRect', 'LP', 'I')
@kbe = Win32API.new('user32', 'keybd_event', 'LLLL', '')
@gaks = Win32API.new('user32', 'GetAsyncKeyState', 'L', 'I')
@window = Win32API.new('user32', 'FindWindow', 'PP', 'I').call("RGSS Player", title)
@default_size = size
if size[0] < 800 or size[1] < 600
print("A minimum screen resolution of [800 by 600] is required in order to play #{title}")
exit
end
@state = "default"
self.default
end
#--------------------------------------------------------------------------
# ? fullscreen
#--------------------------------------------------------------------------
def fullscreen
@default_size = size
@set_window_long.call(@window, -16, 0x14000000)
@set_window_pos.call(@window, -1, 0, 0, 802, 602, 64)
@set_resolution.call(800, 600, 4)
@state = "fullscreen"
end
#--------------------------------------------------------------------------
# ? default
#--------------------------------------------------------------------------
def default
x = @default_size[0] / 2 - 403
y = @default_size[1] / 2 - 316
@set_window_long.call(@window, -16, 0x14CA0000)
@set_window_pos.call(@window, 0, x, y, 808, 627, 0)
@set_resolution.call(@default_size[0], @default_size[1], 0)
@state = "default"
end
#--------------------------------------------------------------------------
# ? trigger?(key)
#--------------------------------------------------------------------------
def trigger?(key)
return @gaks.call(key) & 0x01 == 1
end
#--------------------------------------------------------------------------
# ? private
#--------------------------------------------------------------------------
private :fullscreen
private :default
private :trigger?
#--------------------------------------------------------------------------
# ? size
#--------------------------------------------------------------------------
def size
width = @gsm.call(0)
height = @gsm.call(1)
return width, height
end
#--------------------------------------------------------------------------
# ? change
#--------------------------------------------------------------------------
def change
if @state == "default"
self.fullscreen
else
self.default
end
end
#--------------------------------------------------------------------------
# ? update
#--------------------------------------------------------------------------
def update
if trigger?(121) # F10
self.change
end
if Input.trigger?(Input::ALT) or Input.press?(Input::ALT)
@kbe.call(18, 0, 2, 0)
end
end
#--------------------------------------------------------------------------
# ? module functions
#--------------------------------------------------------------------------
module_function :initialize
module_function :fullscreen
module_function :default
module_function :trigger?
module_function :size
module_function :change
module_function :update
end
Or an edit by DerVVulfman:
The Script
Code:
#==============================================================================
# ** Resolution Revised
#------------------------------------------------------------------------------
# Original version by Selwyn (June 19, 2006)
# Revisions by DerVVulfman (February 18, 2014)
#
# The original version allowed you to change the resolution to 800x600.
# The revision allows that, or a resolution of 1024x768.
#
#
# To Use:
# ========
# Place a copy of the display.dll in your project's root directory.
# Paste this script into your project.
# Place the following call into 'Main' before the Graphics.freeze command:
# Resolution.initialize
# Insert the following into the loop of each update method for every scene
# command, so it overrides the default ALT+ENTER fullscreen toggle system:
# Resolution.update
#
# To choose your Resolution, go and edit the RES value, currently 0 or 1.
#
# NOTE: Other resolutions may now be possible.
#
#==============================================================================
module Resolution
#--------------------------------------------------------------------------
# * Resolution Choices
#--------------------------------------------------------------------------
RES = 0 # Set your preferred resolution with RES. 0=800x600, 1=1024x768
# These store the resolutions
RES_WD = [800, 1024]
RES_HT = [600, 768]
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :state
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
title = "\0" * 256
Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L').call("Game", "Title", "", title, 256, ".\\Game.ini")
title.delete!("\0")
@set_resolution = Win32API.new('Display.dll', 'SetResolution', 'III', 'I')
@set_window_long = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
@set_window_pos = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
@gsm = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
@gcr = Win32API.new('user32', 'GetClientRect', 'LP', 'I')
@kbe = Win32API.new('user32', 'keybd_event', 'LLLL', '')
@gaks = Win32API.new('user32', 'GetAsyncKeyState', 'L', 'I')
@window = Win32API.new('user32', 'FindWindow', 'PP', 'I').call("RGSS Player", title)
@default_size = size
# Set Warning
if size[0] < RES_WD[RES] or size[1] < RES_HT[RES]
print("A minimum screen resolution of [" + RES_WD[RES].to_s + " by " +
RES_HT[RES].to_s + "] is required in order to play #{title}" )
exit
end
# Set State Flag
@state = "default"
# Set to Default Window
self.default
end
#--------------------------------------------------------------------------
# * Set Fullscreen Mode
#--------------------------------------------------------------------------
def fullscreen
@default_size = size
@set_window_long.call(@window, -16, 0x14000000)
@set_window_pos.call(@window, -1, 0, 0, RES_WD[RES]+2, RES_HT[RES]+2, 64)
# Set State Flag
@set_resolution.call(RES_WD[RES], RES_HT[RES], 4)
@state = "fullscreen"
end
#--------------------------------------------------------------------------
# * Set Windowed Mode
#--------------------------------------------------------------------------
def default
# Define center
x = @default_size[0] / 2 - ((RES_WD[RES]/2)+3)
y = @default_size[1] / 2 - ((RES_HT[RES]/2)+16)
# Ensure original Window size
@set_resolution.call(@default_size[0], @default_size[1], 0)
# Position Window in Center
@set_window_long.call(@window, -16, 0x14CA0000)
@set_window_pos.call(@window, 0, x, y, RES_WD[RES]+8, RES_HT[RES]+27, 0)
# Set State Flag
@state = "default"
end
#--------------------------------------------------------------------------
# * Trigger?
# key : keycode
#--------------------------------------------------------------------------
def trigger?(key)
return @gaks.call(key) & 0x01 == 1
end
#--------------------------------------------------------------------------
# * Obtain original window size
#--------------------------------------------------------------------------
def size
width = @gsm.call(0)
height = @gsm.call(1)
return width, height
end
#--------------------------------------------------------------------------
# * Change between screen modes
#--------------------------------------------------------------------------
def change
if @state == "default"
self.fullscreen
else
self.default
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Change window if F10 is pressed
self.change if trigger?(121)
# Prevent ALT key from changing window state
if Input.trigger?(Input::ALT) or Input.press?(Input::ALT)
@kbe.call(18, 0, 2, 0)
end
end
#--------------------------------------------------------------------------
# * Private Instance Variables
#--------------------------------------------------------------------------
private :fullscreen
private :default
private :trigger?
#--------------------------------------------------------------------------
# * Defined Module Functions
#--------------------------------------------------------------------------
module_function :initialize
module_function :fullscreen
module_function :default
module_function :trigger?
module_function :size
module_function :change
module_function :update
end
Required .Dll Resource
Display.zip (Size: 4.6 KB / Downloads: 40)
HOW TO USE
how to use it :
in main, before 'begin', put the following line :
Code:
Resolution.initialize
and in each Scene_
put
Code:
Resolution.update
two negative points:
- the ALT key doesn't work anymore,
- F10 is used to switch in full-screen mode.
TERMS AND CONDITIONS
Give credit, enjoy!