#============================================================================== # ■ Window Resize Toggle (F5) - Auto-Center + Size Filtering #------------------------------------------------------------------------------ # Cycles through safe window sizes, skipping any that would exceed the screen. # Auto-centers the window and nudges it upward to avoid overlapping the taskbar. #============================================================================== module WindowScaler # Define fixed window sizes [width, height] SIZES = [ [544, 416], # 1.0x native [816, 624], # 1.5x [1088, 832], # 2.0x [1343, 1027], # 2.3x [1632, 1248], # 3.0x [1819, 1391], # ~3.4x ] TASKBAR_OFFSET = 20 # Move window upward to avoid taskbar end class << Graphics alias resize_update update def update resize_update WindowResize.update end end module WindowResize @index = 0 def self.update if Input.trigger?(:F5) screen_width = Win32API.new('user32', 'GetSystemMetrics', ['I'], 'I').call(0) screen_height = Win32API.new('user32', 'GetSystemMetrics', ['I'], 'I').call(1) # Try all sizes once, skipping any that are too large tried = 0 while tried < WindowScaler::SIZES.size @index = (@index + 1) % WindowScaler::SIZES.size width, height = WindowScaler::SIZES[@index] if width <= screen_width && height <= screen_height apply_size(width, height, screen_width, screen_height) break end tried += 1 end end end def self.apply_size(width, height, screen_width, screen_height) # Center the window with vertical offset to avoid taskbar x = [(screen_width - width) / 2, 0].max y = [(screen_height - height) / 2 - WindowScaler::TASKBAR_OFFSET, 0].max hwnd = Win32API.new('user32', 'FindWindowA', ['P', 'P'], 'L').call("RGSS Player", nil) move_window = Win32API.new('user32', 'MoveWindow', %w(L L L L L L), 'L') move_window.call(hwnd, x, y, width, height, 1) end end