The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Mitsarugi on March 15, 2012, 08:59:56 PM

Title: [RMVX] Full screen with resolution detection
Post by: Mitsarugi on March 15, 2012, 08:59:56 PM
i was looking for a script that displays the game in full screen and i found a lot of them , but i would like it to have a special feature that lets the script check the screens resolution, i found this http://www.ruby-forum.com/topic/92264 topic but i don't understand how that works, could someone help me or make this for me please?

EDIT:
i also found this one that already has the hight done but not the width , i would like it to find the width  by itself too.
# Fullscreen++ v1.0 by Zeus81
# Description :
#   Permet d'avoir un mode plein écran plus intelligent qui utilise un maximum
#   de la surface de l'écran tout en gardant le bon ratio.
#   Alt+Entreé utilise toujours l'ancien mode plein.
#   Pour utiliser ce nouveau mode plein écran appuyez sur F5.
#   Pour faire démarrer le jeu automatiquement en plein écran voir ligne 14.
# Méthodes :
#   Graphics.fullscreen?     : pour savoir si on est en mode plein écran ou pas.
#   Graphics.fullscreen_mode : passe en mode plein écran.
#   Graphics.windowed_mode   : passe en mode fenêtré.
#   Graphics.toggle_mode     : passe d'un mode à l'autre.
class << Graphics
  fullscreen_start = false # 'true' pour démarrer en plein écran sinon 'false'
 
  FindWindow       = Win32API.new('user32', 'FindWindow'      , 'pp'          , 'l')
  CreateWindowEx   = Win32API.new('user32', 'CreateWindowEx'  , 'lpplllllllll', 'l')
  UpdateWindow     = Win32API.new('user32', 'UpdateWindow'    , 'l'           , 'l')
  ShowWindow       = Win32API.new('user32', 'ShowWindow'      , 'll'          , 'l')
  SetWindowLong    = Win32API.new('user32', 'SetWindowLong'   , 'lll'         , 'l')
  SetWindowPos     = Win32API.new('user32', 'SetWindowPos'    , 'lllllll'     , 'l')
  GetSystemMetrics = Win32API.new('user32', 'GetSystemMetrics', 'l'           , 'l')
  GetDC            = Win32API.new('user32', 'GetDC'           , 'l'           , 'l')
  FillRect         = Win32API.new('user32', 'FillRect'        , 'lpl'         , 'l')
  CreateSolidBrush = Win32API.new('gdi32' , 'CreateSolidBrush', 'l'           , 'l')
  if first_start = !method_defined?(:zeus81_fullscreen_update)
    @@MainWindow = FindWindow.call('RGSS Player', 0)
    @@BackWindow = CreateWindowEx.call(0x08000008, 'Static', '', 0x80000000, 0, 0, 0, 0, 0, 0, 0, 0)
    @@FillRectArgs = [GetDC.call(@@BackWindow), [0,0,0xFFFF,0xFFFF].pack('L4'), CreateSolidBrush.call(0)]
    @@fullscreen = false
    alias zeus81_fullscreen_resize_screen resize_screen
    alias zeus81_fullscreen_update        update
  end
  def update
    zeus81_fullscreen_update
    toggle_mode if Input.trigger?(Input::F5)
  end
  def resize_screen(width, height)
    zeus81_fullscreen_resize_screen(width, height)
    fullscreen_mode if fullscreen?
  end
  def fullscreen?() @@fullscreen end
  def toggle_mode() fullscreen? ? windowed_mode : fullscreen_mode end
  def fullscreen_mode
    client_w, client_h = GetSystemMetrics.call(0), GetSystemMetrics.call(1)
    w, h = client_w, client_w * height / width
    h, w = client_h, client_h * width / height if h > client_h
    ShowWindow.call(@@BackWindow, 3)
    UpdateWindow.call(@@BackWindow)
    FillRect.call(*@@FillRectArgs)
    SetWindowPos.call(@@MainWindow, -1, (client_w-w)/2, (client_h-h)/2, w, h, 0)
    SetWindowLong.call(@@MainWindow, -16, 0x14000000)
    @@fullscreen = true
  end
  def windowed_mode
    client_w, client_h = GetSystemMetrics.call(0), GetSystemMetrics.call(1)
    w = width + (GetSystemMetrics.call(5)+2)*2
    h = height + (GetSystemMetrics.call(6)+2)*2 + GetSystemMetrics.call(4)
    ShowWindow.call(@@BackWindow, 0)
    SetWindowPos.call(@@MainWindow, -2, (client_w-w)/2, (client_h-h)/2, w, h, 0)
    SetWindowLong.call(@@MainWindow, -16, 0x14CA0000)
    @@fullscreen = false
  end
  Graphics.fullscreen_mode if first_start and fullscreen_start
end
Title: Re: [RMVX] Full screen with resolution detection
Post by: Zeriab on March 20, 2012, 08:13:44 AM
I don't really understand. Wherever height is dealt with width is also dealt with either on the same line or the line above.

Either way GetSystemMetrics is the interesting one. Extract just those parts of the script and play around with them to see how they can be used to get what you want.

*hugs*
Title: Re: [RMVX] Full screen with resolution detection
Post by: EvilM00s on March 20, 2012, 01:22:18 PM
Zeriab doesn't tell you what to think, he tells you how to think. Love it!

When you get this script to work, please update; it sounds really groovy, Mitsarugi :)