• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Full screen for Essentials

Luka S.J.

Jealous Croatian
1,270
Posts
15
Years
  • This script creates a custom method to enter the RMXP window into full screen. The full screen functionality of the default RGSS player leaves it capped at the 640 x 480 resolution. This is fine for the standard Essentials resolution, but those of you who wish to use a larger game screen resolution will have your screen cut off when entering the default RGSS player full screen (Alt+Enter).

    This script will only scale the game window in integers, meaning that depending on your display resolution, the entire screen will probably not get filled. This is to prevent pixel loss, and quality distortion. If the game screen is smaller than your display resolution, it will get automatically centered.

    Paste the following directly above PSystem_System.
    Code:
    #===============================================================================
    # ** Essentials full screen
    # by Luka S.J.
    #-------------------------------------------------------------------------------
    # Enters your game into a new full screen mode
    # Size depends on your display's resolution, as the game will only resize
    # itself if the resize factor is an integer. Screen is resized and then
    # centered on the display
    #===============================================================================
    DISABLERMXPFULL = true # Disables the old Alt+Enter full screen
    # If you're using the new full screen option, make sure to leave this
    # constant as true, because RMXP's full screen will mess up this new method
    if DISABLERMXPFULL
      regHotKey = Win32API.new('user32', 'RegisterHotKey', 'LIII', 'I')
      regHotKey.call(0, 1, 1, 0x0D)
    end
    #-------------------------------------------------------------------------------
    #  Win32API functions that get rid of the window border, resize the window
    #  to fit the screen, and reposition it
    #-------------------------------------------------------------------------------
    class Win32API
      def Win32API.focusWindow
        window = Win32API.new('user32', 'ShowWindow', 'LL' ,'L')
        hWnd = pbFindRgssWindow
        window.call(hWnd, 9)
      end
      
      def Win32API.fillScreen
        setWindowLong = Win32API.new('user32', 'SetWindowLong', 'LLL', 'L')
        setWindowPos = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
        metrics = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
        hWnd =  pbFindRgssWindow
        width = metrics.call(0)
        height = metrics.call(1)
        setWindowLong.call(hWnd, -16, 0x00000000)
        setWindowPos.call(hWnd, 0, 0, 0, width, height, 0)
        Win32API.focusWindow
        return [width,height]
      end
      
      def Win32API.restoreScreen    
        setWindowLong = Win32API.new('user32', 'SetWindowLong', 'LLL', 'L')
        setWindowPos = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
        metrics = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
        hWnd =  pbFindRgssWindow
        width = DEFAULTSCREENWIDTH*$ResizeFactor
        height = DEFAULTSCREENHEIGHT*$ResizeFactor
        x = (metrics.call(0)-width)/2
        y = (metrics.call(1)-height)/2
        setWindowLong.call(hWnd, -16, 0x14CA0000)
        setWindowPos.call(hWnd, 0, x, y, width+6, height+29, 0)
        Win32API.focusWindow
        return [width,height]
      end
      
      def Win32API.SetWindowPos(w,h); return; end
    end
    #-------------------------------------------------------------------------------
    #  Viewport fix for the LocationWindow class
    #-------------------------------------------------------------------------------
    class LocationWindow
      alias initialize_org initialize
      def initialize(name)
        initialize_org(name)
        @window.viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
      end
    end
    #-------------------------------------------------------------------------------
    #  Pokegear fix
    #-------------------------------------------------------------------------------
    class Scene_Pokegear
      alias main_org main
      def main
        $trick = true
        main_org
        $trick = false
      end
    end
    
    class Window_CommandPokemon
      alias initialize_org initialize
      def initialize(*args)
        initialize_org(*args)
        self.visible = false if $trick
      end
    end
    #-------------------------------------------------------------------------------
    #  Fixes default transitions capping at 640 x 480
    #-------------------------------------------------------------------------------
    module Graphics
      class << self
        alias transition_org transition
      end
      
      def self.transition(duration = 8, *args)
        if duration > 0
          transition_org(0)
          bmp = self.snap_to_bitmap
          viewport = Viewport.new(0, 0, self.width, self.height)
          sprite = Sprite.new(viewport)
          sprite.bitmap = bmp
          fade = 255 / duration
          duration.times { sprite.opacity -= fade ; update }
          [sprite, sprite.bitmap].each {|obj| obj.dispose }
        end
        transition_org(0)
     end
    end  
    #-------------------------------------------------------------------------------
    #  Additional options to the menu to enter full screen and quit game
    #-------------------------------------------------------------------------------
    class PokemonMenu_Scene
      alias pbShowCommands_org pbShowCommands
      def pbShowCommands(commands)
        commands.insert(commands.length-1,"Quit Game") if $PokemonSystem.screensize==3 && !commands.include?("Quit Game")
        ret=pbShowCommands_org(commands)
        if ret==(commands.index("Quit Game"))
          raise SystemExit.new
        end
        if ret==(commands.index("Fullscreen"))
          configureScreen
        end
        return ret
      end
    end
    #-------------------------------------------------------------------------------
    #  Disables screen resizing in the options menu
    #-------------------------------------------------------------------------------
    class EnumOption
      alias initialize_org initialize
      def initialize(name,options,getProc,setProc)
        initialize_org(name,options,getProc,setProc)
        if name=="Screen Size"
          @values=[_INTL("Small"),_INTL("Med"),_INTL("Large"),_INTL("Full")]
          @getProc=proc { $PokemonSystem.screensize }
          @setProc=proc {|value|
            oldvalue=$PokemonSystem.screensize
            if value < 3
              configureDefaultScreen(value)
              if value!=oldvalue
                ObjectSpace.each_object(TilemapLoader){|o| next if o.disposed?; o.updateClass }
              end
            elsif value==3
              $PokemonSystem.screensize = value
              configureFullScreen
              if value!=oldvalue
                ObjectSpace.each_object(TilemapLoader){|o| next if o.disposed?; o.updateClass }
              end
            end
          }
        end
        
      end
    end
    
    alias pbSetResizeFactor_full pbSetResizeFactor
    def pbSetResizeFactor(dummy=nil)
      value = $PokemonSystem.screensize
      if value < 3
        configureDefaultScreen(value)
      else
        configureFullScreen
      end
    end
    #-------------------------------------------------------------------------------
    #  Method to call and enter full screen
    #-------------------------------------------------------------------------------
    def configureFullScreen
      params = Win32API.fillScreen
      factor_x = params[0]/DEFAULTSCREENWIDTH
      factor_y = params[1]/DEFAULTSCREENHEIGHT
      factor = [factor_x,factor_y].min
      remain = params[0]%DEFAULTSCREENWIDTH
      offset_x = (remain>0) ? (params[0]-DEFAULTSCREENWIDTH*factor)/factor*0.5 : 0
      offset_y = (remain>0) ? (params[1]-DEFAULTSCREENHEIGHT*factor)/factor*0.5 : 0
      $ResizeOffsetX = offset_x
      $ResizeOffsetY = offset_y
      ObjectSpace.each_object(Viewport){|o|
        begin
          next if o.rect.nil?
          ox = o.rect.x-$ResizeOffsetX
          oy = o.rect.y-$ResizeOffsetY
          o.rect.x = ox+offset_x
          o.rect.y = oy+offset_y
          rescue RGSSError
        end
      }
      pbSetResizeFactor_full(factor)
    end
    
    def configureDefaultScreen(value)
      $ResizeOffsetX=0
      $ResizeOffsetY=0
      if $PokemonSystem.screensize==3
        ObjectSpace.each_object(Viewport){|o|
          begin
            next if o.rect.nil?
            ox = o.rect.x-$ResizeOffsetX
            oy = o.rect.y-$ResizeOffsetY
            o.rect.x = ox
            o.rect.y = oy
            rescue RGSSError
          end
        }
      end
      $PokemonSystem.screensize=value
      pbSetResizeFactor_full([0.5,1.0,2.0][value])
      Win32API.restoreScreen
    end

    Go to 'Thread Tools > Show Printable Version' when pasting the script into your project to avoid any potential code breaks on the site.
    Hope you find this useful.
     
    Last edited:

    Savordez

    It's time to end fangames.
    115
    Posts
    10
    Years
  • The new screen size option is displayed, but I can't actually change to full screen. I suppose this is because I've modified the options with FL's Controls Screen and some new options of my own?
     

    Luka S.J.

    Jealous Croatian
    1,270
    Posts
    15
    Years
  • No, I've just disabled in-game screen size adjusting...for now. I haven't written a function to revert back to the original yet. I still need to think of the optimal method of doing so.

    Use auto fullscreen for now.
     

    Luka S.J.

    Jealous Croatian
    1,270
    Posts
    15
    Years
  • I have updated the script to add a new entry to the "Screen Size" option in the Options screen. There is just one bug with it. If you change the screensize, everything is fine. But if you change the screensize (from large to full and the other way around) multiple times in row, the offset for the currently loaded scenes will be messed up. This fixes itself next time you open the same scene (such as menu and option).

    [S-HIGHLIGHT][EDIT][/S-HIGHLIGHT]
    Fixed a pretty major bug that crashes your system after saving in full screen. Delete the old script and paste the new one directly above PSystem_System to fix this.
     
    Last edited:

    oldsnake90

    Creator Pokemon Glacial Freeze
    61
    Posts
    14
    Years
  • I keep getting "line 132: SyntaxError occured" error message i posted it directly above PSystem_System.
    Edit Fixed it
     
    1
    Posts
    8
    Years
    • Seen Aug 9, 2016
    Where can i find PSystem_System? I don't now in wich script I have to copy that!
    Please help me out.
     
    2
    Posts
    8
    Years
    • Seen Oct 27, 2015
    I keep getting "line 132: SyntaxError occured" error message i posted it directly above PSystem_System.
    Edit Fixed it
    Can you explain how do you fix it?
    Thank you in advance

    It works for me there was a syntaxis error in the line 120. That badly points to line 132. I'm not really sure but the scripts works.
    Line 120 Before => if ret==(commands.index("Fullscreen configureScreen
    Line 120 later => if ret==(commands.index("Fullscreen configureScreen"))
     
    Last edited:
    1,224
    Posts
    10
    Years
  • Can you explain how do you fix it?
    Thank you in advance

    It works for me there was a syntaxis error in the line 120. That badly points to line 132. I'm not really sure but the scripts works.
    Line 120 Before => if ret==(commands.index("Fullscreen configureScreen
    Line 120 later => if ret==(commands.index("Fullscreen configureScreen"))

    Thread Tools > Show Printable Version
     
    10
    Posts
    8
    Years
    • Seen Apr 27, 2016
    Thanks! this script is awesome,but... battle transitions are disappeared, how can i re introduce them?
     

    Luka S.J.

    Jealous Croatian
    1,270
    Posts
    15
    Years
  • Thanks! this script is awesome,but... battle transitions are disappeared, how can i re introduce them?

    I don't know, I haven't looked into it (or noticed it) since I've been using the battle transitions from EBS. This script is pointless though, since it comes with v16 now. I'd recommend upgrading to that if you want the full screen functionality. Maruno fixed the transitions issue with it.
     
    79
    Posts
    8
    Years
    • Seen Jan 17, 2017
    How can I change it to work with Kleins Bw Kit?
    Im using v.15.1 thats why Im asking...
     
    Back
    Top