Hmm, stopping the screen slide was easier than I thought. I just made sure that @sw_shake was always zero before the script could be started again ('return if @sw_shake != 0') and that seems to work fine. I shoved version 1.1 into a parallel process and it didn't budge after an extended period of time. I also cleaned up some of the @szEval code and made it smaller, although I still think there must be an easier way to do what I did.
However, checking for full screen is still a bit of a problem. I don't think it would be reliable to check for a certain screen size, as people may alter theirs with resolution modifying scripts. What I'm probably going to have to do is check the game window size versus the monitor window size, and if they overlap then the game is full screen. I've been scouring for an easy solution within the RPGVX data structures, looking for a flag that declares that full screen is enabled, but it doesn't look like there is one. You'd think that there would be ... ah well.
Thanks for the feedback so far!
EDIT : Here's a work-around script, but it feels kind of dirty how I'm determining full screen. Basically comparing GetWindowLong information beside each other instead of checking for a specific window style. I updated the code in the original post.
EDIT II : Here is the code that I tried using before, and it seems to me that it would be better for me to narrow down which window styles (WS_STYLE) are being changed rather than just comparing one GetWindowLong number against the other. I commented in where I was running into problems. All of the available window styles are listed here :
Normal Window Styles :
http://msdn.microsoft.com/en-us/library/ms632600%28v=vs.85%29.aspxExtended Window Styles :
http://msdn.microsoft.com/en-us/library/ff700543(v=vs.85).aspxclass Ex_FSCheck
# Changing GWL_EXSTYLE to -20 enables checking for extended window styles
@GWL_STYLE = -16
@WS_CAPTION = 0x00C00000
@WS_VISIBLE = 0x10000000
@WS_DISABLED = 0x08000000
@WS_MAXIMIZEBOX = 0x10000
@WS_MINIMIZEBOX = 0x20000
@WS_POPUP = 0x80000000
@WS_EX_MDICHILD = 0x00000040
@WS_EX_COMPOSITED = 0x02000000
def self.AcquireGameWindowLong(nIndex = @GWL_STYLE)
get_long = Win32API.new('user32.dll', 'GetWindowLongA', ['L', 'I'], 'l')
window_hwnd = self.AcquireGameWindow
wnd_tmp = get_long.call(window_hwnd, nIndex)
# Is this how I would check these two against each other?
# This -always- returns true. Even if I use @WS_DISABLED, and I know the window certainly isn't disabled.
if wnd_tmp && @WS_POPUP == @WS_POPUP
return true
else
return false
end
end
def self.AcquireGameWindow
window_title = GetPrivateProfileString("Game", "Title", "", "./Game.ini")
return FindWindow("RGSS Player", window_title)
end
def self.FindWindow(window_class, window_title)
find_window = Win32API.new('user32.dll', 'FindWindowA', ['P', 'P'], 'l')
return find_window.call(window_class, window_title)
end
def self.GetPrivateProfileString(ini_section, ini_key, default_val, ini_file)
get_string = Win32API.new('kernel32.dll', 'GetPrivateProfileStringA', ['P', 'P', 'P', 'P', 'L', 'P'], 'l')
sz_buffer = "\0" * (256 + 1)
get_string.call(ini_section, ini_key, default_val, sz_buffer, 256, ini_file)
return sz_buffer.delete!("\0")
end
end
EDIT III : I found another way to check for full screen, but I feel that it's also a bit flimsy. Well, either way I have lined out works fine, but I'm sure that there are better ways of going about doing it ...
EDIT IV : Alright, narrowed it down a little further. Close enough, I think.
class Ex_FSCheck
#===============================================================================
# Full Screen Check
#===============================================================================
# Author : Exhydra
# Version : 1.5
# Last Updated : 07/14/2011
#===============================================================================
#--------------------------------------------------------------------------
# ? Windows API Declarations [ Windows API ]
#--------------------------------------------------------------------------
@getCurrentThreadId = Win32API.new('kernel32', 'GetCurrentThreadId' , [''] , 'L')
@getWindowRect = Win32API.new('user32', 'GetWindowRect' , ['L', 'P'] , 'L')
@getWindowThreadProcessId = Win32API.new('user32', 'GetWindowThreadProcessId', ['L', 'P'] , 'L')
@getClientRect = Win32API.new('user32', 'GetClientRect' , ['L', 'P'] , 'L')
@findWindowEx = Win32API.new('user32', 'FindWindowEx' , ['L', 'L', 'P', 'P'] , 'L')
#--------------------------------------------------------------------------
# ? Acquire Game Window [ Windows API ]
#--------------------------------------------------------------------------
def self.AcquireGameWindow
procID = [0].pack('L')
threadID = @getCurrentThreadId.call
nextWindow = 0
begin
nextWindow = @findWindowEx.call(0, nextWindow, "RGSS Player", 0)
if nextWindow
wndThreadID = @getWindowThreadProcessId.call(nextWindow, procID)
if wndThreadID == threadID
return nextWindow
end
end
end until nextWindow == 0
raise "ERROR : RGSS player window not found!"
return 0
end
#--------------------------------------------------------------------------
# ? Acquire Game Window Rect [ Windows API ]
#--------------------------------------------------------------------------
def self.AcquireGameWindowRect
aRect = [0,0,0,0].pack('L4')
wHwnd = self.AcquireGameWindow
@getWindowRect.call(wHwnd, aRect)
l, t, r, b = aRect.unpack('L4')
return l, t, r, b
end
#--------------------------------------------------------------------------
# ? Acquire Client Screen Rect [ Windows API ]
#--------------------------------------------------------------------------
def self.AcquireClientScreenRect
aScreen = [0,0,0,0].pack('L4')
wHwnd = self.AcquireGameWindow
@getClientRect.call(wHwnd, aScreen)
l, t, r ,b = aScreen.unpack('L4')
return l, t, r, b
end
#--------------------------------------------------------------------------
# ? Check Full Screen [ Windows API ]
#--------------------------------------------------------------------------
def self.CheckFullScreen
aRect = self.AcquireGameWindowRect
aScreen = self.AcquireClientScreenRect
if aRect[0] <= aScreen[0] and
aRect[1] <= aScreen[1] and
aRect[2] >= aScreen[2] and
aRect[3] >= aScreen[3]
return true
else
return false
end
end
end