Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

HBGames

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

Code:
#==============================================================================
# ** 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

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.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top