|
|
|
|
Reply From: |
avencherus |
3.2 UPDATE
As of version 3.2 from this commit onward methods have been added to clamp the window min and max sizes, which would be the best answer to this.
From mrtnfchs comment below, the methods are the following:
OS.min_window_size = Vector2(min_x, min_y)
OS.max_window_size = Vector2(max_x, max_y)
OLD EXAMPLE
In older versions a less than ideal way of accomplishing it would be to clamp the dimensions based on when the root viewport is being resized. (It is hacky and some flickering occurs.)
Relies on this method to manually update to the new sizes: OS — Godot Engine (latest) documentation in English
var minX = 300
var minY = 300
func _ready():
get_node("/root").connect("size_changed", self, "resize")
func resize():
var currentSize = OS.get_window_size()
if(currentSize.x < minX):
OS.set_window_size(Vector2(minX, currentSize.y))
if(currentSize.y < minY):
OS.set_window_size(Vector2(currentSize.x, minY))
Incidentally I actually did try to implement this mode, but I decided it looked bad enough to not justify it and just made the window non-resizable. Thanks anyway!
Brandon Hustus | 2016-10-15 01:15
You’re welcome.
Yeah it’s certainly not pretty. From what I can tell it wasn’t an intentional behavior. I couldn’t find anything in their OS code on the windows side that exposes any functionality into GD Script for it.
There does exist in windows API such functionality.
MINMAXINFO (winuser.h) - Win32 apps | Microsoft Learn
You would have to compile your own module or modify the source and create a new method in the OS interface and implement it, which is probably far more work than settling with something like a modal window.
avencherus | 2016-10-15 09:07
Use OS.min_window_size = Vector2(minx,miny)
and OS.max_window_size = Vector2(maxx,maxy)
mrtnfchs | 2020-03-31 23:17
Thank you mrtnfchs. Your comment should be an answer so that I could mark it as “Best Answer”.
cgeadas | 2020-07-18 17:15