window resolution fix

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 Spoiler
#==============================================================================
# â–  Resolution
#------------------------------------------------------------------------------
#  created by Selwyn
#  [email hidden]
#
#  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
Expand to see the code.


how to use it :

in main, before 'begin', put the following line :

Resolution.initialize
Expand to see the code.


and in each Scene_
put Resolution.update right after Input.update


two negative points:
- the ALT key doesn't work anymore,
- F10 is used to switch in full-screen mode.

Give credit, enjoy!
Howdy,

First off don’t you mean Resolution.initialize and Resolution.update
Once you fix that little bug its very nice.

Take Care,
Near
What Near said :S, Looking over the script I did not see any Module or Scene called screen.


Anyway,

Thing 1 Spoiler
WHY oh WHY are ALL module function seperatly being module functioned?
Instead of:
module_function :something_here
module_function :something_here
Expand to see the code.


Can just place after module Resolution:

module_function
Expand to see the code.


Thing 2 Spoiler
Instead of setting the Alt key to down if it is pressed, couldn't that just be changed to two if statements :S? Or would that cause to trigger fullscreen before it could be set to down. If not, you could make input f10 back to ALT+ENTER... oh well, if it was like I sa, you would have done it that way...


Thing 3 Spoiler
oh and: - F10 is used to switch in full-screen mode.
Is not really a negetive point :P


The script is much much better then all old resolution scripts.

Good Job Squall :)
@near : errr, yeah the 'Screen' thing was a typo, I fixed it now.

@me:
1) yeah I could defined them all on one line. It's just that I prefer having them on separeted lines.

2) actually I tried to make it so that if ALT and ENTER were pressed, change the window to fullscreen 800*600 and set the ALT key down. It just didn't worked.
Tought so you did.

Anyway, it is way too bad that the fade viewport is still 640x480
Hey nice script but one question

The script makes the window bigger but the picture is still small on the top left corner? how could I fix this, thx in advance!
The *picute :S?

You can make the Map bigger by setting bigger viewports.
But this script is mainly for scripters, not for people who think it is fun to just change the resoltion (no offense)
Howdy,

It is not the viewport that affects the map size per say. It is the Tilmap class that is limited to a maximum of 640x480. to have a large map displayed with this larger window you need to build a new Tilemap class.

Take Care,
Near
Actually, doing that not changing the viewports would NOT make it biige. Have to change both :O
[QUOTE=Zerg]Hey nice script but one question

The script makes the window bigger but the picture is still small on the top left corner? how could I fix this, thx in advance![/QUOTE]
I believe he means pictures like the title one. Of course, if you have higher resolution, you´ll need a bigger pic. I haven´t tested if it works, though...

The only drawback I faced Squall, is that if I set the game to full screen, it goes back to 640x480.
It doesent do that here.
@Alael : as Me said this script prevent the window from returning to a res of 640*480 what the older/other scripts wouldn't.

and I think zerg was talking about the whole game.
and to answer that, there's not just a 'fix' because it's not a problem.
Remember that this script is intended for people who are experienced and knowledgeable about RGSS.
Exactly.. Now.. If I just where able to get the Graphics class' code...
Hey there, I tried this script instead the old one I were using, and I did get an error about can't locate the Display.dll, I do have the file inside my game folder and I even tried copy the file to windows/system32 (same place where the user32.dll file is at), but same error

So I opened the .dll file with wordpad and saw this inside:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /hosted/Display.dll was not found on this server.</p>
</body></html>
Expand to see the code.


So I assume file is corrupted and tried dowlaod several times but file always end up on this way, and so I assume this isn't the real file :)

So, anywhere else I can try get it??
Dude, you necroposted a 8 month old topic.
And if you cannot find a script or whatever.
Use the Lost Scripts.
"Dude, you necroposted a 8 month old topic.
And if you cannot find a script or whatever.
Use the Lost Scripts."

well dude, I see this script author very but VERY active on this forums, so I did necroposted here, because I can stil see this topic unlocked, and also avaliable on the forums script thread, so I thought maybe he either alreayd had made a newer version or just had moved the file to somewhere else
actually, my server's down, that is why you can't download the file.

I am currently fixing all my posts and moving my files to another temporary server.
It'll be fixed in a few hours. I'll edit this post when it's okay.

also, you can't get it anywhere else because I made that DLL.
where is the Display.dll ?

[QUOTE=Selwyn;159652]actually, my server's down, that is why you can't download the file.

I'll currently fixing all my posts and moving my files to another temporary server.
It'll be fixed in a few hours. I'll edit this post when it's okay.

also, you can't get it anywhere else because I made that DLL.[/QUOTE]

:*) oke :thumb:
Thank you for the reply :)

EDIT: if you need some temporary place for place the files, I can make you an FTP account on my server, until you decide a definitive place :) )
Here's the dll: http://www.megaupload.com/?d=JE5PXBIX
ok, got the file finaly (dam megaupload lol), and it works GREAT :), so good work man
Wouldn't it be nice to fix some of the hard-coded values in RMXP? Then this script and the DLL could be used to full potential. I heard about this through the grape-vine, and decided to come look at it myself. If we could retrieve the default classes and tinker with them, it would be so lovely to implement this script. But the way it is now...

I shall download and use. Is it illegal to decrypt and modify the RGSS dll? I want the power to change resolution, but the Graphics module is stuck with 640x480 resolution on screen transitions, and the viewport is stuck with a 640x480 limit as well. It would be great if these limits did not exist.
I suppose it's illegal, however rewriting the hidden classes in a DLL could work.

But this isn't intented only for making the resolution bigger, you can make it smaller too.
It's not ilegal, it is ilegal to modify/decompress/reverse engine or others to the rmxp program, but not to the game. I have tried to decompress the RGSS dll, but I can't decompress it... I don't know what method of compresion it has. There are some decrypted RGSS dll, that are about 1.50 mb, but they are not decompressed.
I have a question for you. I'm trying to get a script to work fullscreen, I have managed this using your script here, but the problem is the game itself is still small and only plays in the top left hand corner[with the rest of the screen black].

I Have tried starting the game out in Fullscreen then using the script, but it tells me I have to run the game on a 800 x 600 resolution. My computer runs on a 1024 x 768 resolution at the moment. How do I fix that?

Is there a way to make the whole game play fullscreen? I know the traditional way and the way without the Resolution script, but I kinda need the resolution script to make the other script fullscreen.

The other script I'm talking about is here: [URL=http://www.rmxp.org/forums/showthread.php?t=8118]
Other script needs to be Fullscreen[/URL]

Thank you in advance,
Firestalker
Quote:
@gcr             = Win32API.new('user32', 'GetClientRect', 'LP', 'I')
Expand to see the code.

I don't see this used anywhere in the script. What exactly does it do, and how would one use it? I don't quite understand fully how Ruby (let alone RGSS) uses windows API. It doesn't make much since to me.
Um well I wanted to use this but that link for the file is broken.
http://rapidshare.com/files/41794454/Display.dll
Oh, nm. I thought this was to fix the full screen resolution. I have a problem where there is a little bit that gets cut off when I do it in full screen...is there anything to fix that? Or is it something wrong with my computer or something?
To everyone who was wondering how to make the map display across all of the screen, this will help.

In the Tilemap rewrite, change the line

layer.bitmap = Bitmap.new(map.width * 32, map.height * 32)

by changing the 32s to something else (48, perhaps?) it will show more or less of the map. I haven't got the time to ensure that this works flawlessly, so be careful and remember how to change it back if something goes horribly wrong. This also hasn't been tested with anything like in game menus or transitions yet!

You may also need to edit the viewport size in Spriteset_Map from 640 and 480 to whatever you want. I don't know if it'll work right if you don't.

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