Advertisement
FlipelyFlip

FFS - Change Fullscreen

Dec 19th, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.83 KB | None | 0 0
  1. class << Graphics
  2. public
  3.   def fullscreen_mode
  4.     return if vx_fullscreen?
  5.     initialize_fullscreen_rects
  6.     show_back
  7.     hide_borders
  8.     @fullscreen = true
  9.     self.ratio += 0 # refresh window size
  10.   end
  11.   def toggle_fullscreen
  12.     if fullscreen?
  13.       windowed_mode
  14.     else
  15.       fullscreen_mode
  16.       Window_Resize.f
  17.     end
  18.   end
  19.   def update
  20.     toggle_fullscreen if Input.alt_enter_trigger?
  21.     toggle_fullscreen if Input.trigger?(Input::F5)
  22.     toggle_ratio      if Input.trigger?(Input::F6)
  23.     zeus_fullscreen_update
  24.   end
  25.   def ratio=(r)
  26.     return if vx_fullscreen?
  27.     initialize_fullscreen_rects
  28.     r = 0 if r < 0
  29.     if @fullscreen
  30.       @fullscreen_ratio = r
  31.       w_max, h_max = @fullscreen_rect.width, @fullscreen_rect.height
  32.     else
  33.       @windowed_ratio = r
  34.       w_max = @workarea_rect.width  - @borders_size.width
  35.       h_max = @workarea_rect.height - @borders_size.height
  36.     end
  37.     if r == 0
  38.       w, h = w_max, w_max * height / width
  39.       h, w = h_max, h_max * width / height if h > h_max
  40.     else
  41.       w, h = width * r, height * r
  42.       return self.ratio = 0 if w > w_max or h > h_max
  43.     end
  44.     index = Mewgles_SystemOptionsEdit::resolution_index
  45.     w = Mewgles_SystemOptionsEdit::RESOLUTIONS[index][1]
  46.     h = Mewgles_SystemOptionsEdit::RESOLUTIONS[index][2]
  47.     resize_window(w, h)
  48.     save_fullscreen_settings
  49.   end
  50. end
  51.  
  52. module Input
  53.   VK_LALT = 0xA4
  54.   VK_RETURN = 0x0D
  55.  
  56.   GetAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  57.  
  58.   def self.alt_enter_trigger?
  59.     (GetAsyncKeyState.call(VK_LALT) & 0x8001) != 0 && (GetAsyncKeyState.call(VK_RETURN) & 0x0001) != 0
  60.   end
  61.  
  62.   def self.alt_trigger?
  63.     (GetAsyncKeyState.call(VK_LALT) & 0x8001) != 0
  64.   end
  65.  
  66.   def self.enter_trigger?
  67.     (GetAsyncKeyState.call(VK_RETURN) & 0x0001) != 0
  68.   end
  69. end
  70.  
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement