Disable Fullscreen

Disable Fullscreen
Version: 2.00


Introduction

It's simple really, if the player presses Alt+Enter to enter fullscreen, this script will boot them back to windowed mode.

Screenshots

Are you kidding me?

Demo

there is no demo, it's just a super simple script. There may be a demo later, if there is enough demand for one.

Script

script Show
#==============================================================================
# ** Disable Fullscreen
#------------------------------------------------------------------------------
# Draycos Goldaryn
# Version 2.00
# 9/1/07
# SDK Version : 2.0 - Parts 1, 2, 3
#==============================================================================
#----------------------------------------------------------------------------
# SDK detection
#----------------------------------------------------------------------------
begin
  SDK_AUTO_DETECT = SDK::Version
rescue
  SDK_AUTO_DETECT = nil
end

#----------------------------------------------------------------------------
# Begin SDK Emulation
#----------------------------------------------------------------------------
unless SDK_AUTO_DETECT !=nil
  module SDK
    def self.enabled?(script)
      return true if script == 'Disable Fullscreen'
    end
  end
 
#----------------------------------------------------------------------------
# End SDK Emulation
#----------------------------------------------------------------------------
else
SDK.log('Disable Fullscreen','Draycos Goldaryn', 2.00, '9-1-07')
SDK.check_requirements(2.0, [2, 3])
end

#----------------------------------------------------------------------------
# Begin SDK Enabled Check
#----------------------------------------------------------------------------
if SDK.enabled?('Disable Fullscreen')

#----------------------------------------------------------------------------
# Disable Fullscreen
#   - will return to windowed mode if it detects fullscreen mode.
#----------------------------------------------------------------------------
module Disable_Fullscreen
  GSM    = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
  KBE    = Win32API.new('user32','keybd_event','%w(l,l,l,l)','')

  def self.resolution
    width = GSM.call(0)
    height = GSM.call(1)
    return width, height
  end

  def self.alt_enter
    KBE.call(18,0,0,0)
    KBE.call(13,0,0,0)
    KBE.call(18,0,2,0)
    KBE.call(13,0,2,0)
  end

  def self.update
    if resolution[0] == 640
      alt_enter
      Graphics.update
      sleep(1)
      Graphics.update
      sleep(1)
      Graphics.update
      sleep(1)
    end
  end
end

unless SDK_AUTO_DETECT == nil
#----------------------------------------------------------------------------
# SDK::Scene_Base
#   - adds methods to all scenes
#----------------------------------------------------------------------------
class SDK::Scene_Base
  alias_method(:draycos_disablefullscreen_scenebase_update, :update)
  def update
    Disable_Fullscreen.update
    draycos_disablefullscreen_scenebase_update
  end
end

else 
#----------------------------------------------------------------------------
# module Input
#   - is updated in every scene
#----------------------------------------------------------------------------
module Input
  class << self
    alias_method(:draycos_disablefullscreen_input_update,:update)
    def update
      draycos_disablefullscreen_input_update
      Disable_Fullscreen.update
    end
  end
end

end
#----------------------------------------------------------------------------
# End SDK Enabled Test
#----------------------------------------------------------------------------
end
Expand to see the code.


Instructions

simple, just place this script above Main and below the SDK if you have it.

FAQ

Does this work?
Yes, of course it does.

Can you make it non-SDK?
This script will work with or without the SDK. It is completely plug-n-play.

I want it to disable windowed mode instead of fullscreen. How do I do this?
Simple, just replace if resolution[0] == 640 with unless resolution[0] == 640.



Compatibility

If using the SDK, it requires version 2.0+ and parts 1-3.
It can now work without the SDK as well.
It should be compatible with everything. If you have any scripts which overwrite SDK::Scene_Base.update, place them above this script.

Credits and Thanks

Thanks to Xilef for requesting this and SoundSpawn for showing me how to do this (even if he doesn't know he did.). And to DerVVulfman and Yeyinde for showing how to edit Input.Update.

Terms and Conditions

Free to use in any game, including commercial games, just credit Draycos Goldaryn.
This is nice, but i think you should make one that makes it so the game is in auto-fullscreen, and disables alt+enter from going back to windowed.
That is an easy edit, just replace:
if resolution[0] == 640
Expand to see the code.

with
unless resolution[0] == 640
Expand to see the code.
Aha...that seems to work! Thanks, this is pretty handy.
Bump!

Updated to version 2.00

It now works with or without the SDK.
ooh I like this especially now with non sdk support, *nabs*
I must be doing something wrong because I started a fresh Non-SDK project and pasted it between Scene_Debug and Main like instructed and ...

Not only does [Alt]+[Enter] still bring up fullscreen mode, but subsequent [Alt] presses toggles between the two as long as no other input has been sent.

Granted, this is on a friend's Pentium 3 laptop with RMXP v 1.02 English (duh)... but it is happening.

Damn....
You are a genius. clever, I've been searching for this code forever.
(sorry for bumping a old topic, but I can't tell how happy I am.)
[QUOTE=pokemin]You are a genius. clever, I've been searching for this code forever.
(sorry for bumping a old topic, but I can't tell how happy I am.)[/QUOTE]

Well... I missed this one, so thanks. The moderators however might have another view...

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=27369