Allow Fullscreen but not screen resize

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
franfox
Prole
Posts: 11
Joined: Fri Feb 09, 2018 3:48 pm

Allow Fullscreen but not screen resize

Post by franfox »

Hello,

I'm wondering if there's any way to achieve that based on this example:

1 I want to show the game in a windowed mode at some resolution (640, 640)
2 Don't allow the player resize the window with mouse drag.
3 Allow the player to enter full screen with the OS maximize window button.

I'm using this,

Code: Select all

love.window.setMode(640,640,{resizable = true, highdpi = true})
and points 1 and 3 are Ok but I can't achieve the 2. Thanks!
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Allow Fullscreen but not screen resize

Post by pgimeno »

Applications typically don't use the OS maximize button to go fullscreen, and I don't even know if it's possible (probably not). You can provide a menu function and a shortcut key, and if you really must, you can even provide a GUI button to maximize it (see how YouTube does it for an example). A popular shortcut key is F11.

The idea would be to unset 'resizable' and set or unset 'fullscreen'.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Allow Fullscreen but not screen resize

Post by grump »

Also, how would the user exit fullscreen mode when the window buttons aren't there anymore? You still need a button or keyboard shortcut for that.
User avatar
franfox
Prole
Posts: 11
Joined: Fri Feb 09, 2018 3:48 pm

Re: Allow Fullscreen but not screen resize

Post by franfox »

Pgimeno, I understand, gracies! Allowing the user to control the resolution by a custom menu is the best option, isn't? Then I assume there is no simple way to achieve the 3 points I mentioned, am I right?

Grump, sure I should provide an ESC shortcut for exit game. Thanks
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Allow Fullscreen but not screen resize

Post by zorg »

The 1st point is fine, although you should specify fullscreen = false as well in the flags table you pass to setMode;
Set resizable to false to achieve your 2nd point if you don't want people resizing your game through dragging the window's edge;
For the 3rd, forget about the maximize button triggering full-screen, that's not why that exists.

(in short, you can only achieve the first 2... although, if 0.11 will detect you pressing the maximize button, then maybe then, you could make it go fullscreen then...)

If you're adamant, you could do a borderless window, and draw your own window borders and top-buttons and whatever you want inside your app by yourself, but that does have some minor issues, like you might not be able to move the window with your mouse on certain OS-es.

If you only want to support -specific- window sizes, like having a base size, and integral zoom levels (1x, 2x, 3x, 4x, etc.) then you could set resizable to true, but also define the love.resize callback function, and add in code that detect the nearest zoom level that would match the size the user adjusted the window to, then setMode with that value.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
franfox
Prole
Posts: 11
Joined: Fri Feb 09, 2018 3:48 pm

Re: Allow Fullscreen but not screen resize

Post by franfox »

Thanks Zorg, I think your last advice could fit if it's simple to code. I'll take a look into
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Allow Fullscreen but not screen resize

Post by raidho36 »

If you intend on allowing fullscreen, which resizes the window to whatever dimensions the screen currently has, you might as well allow window resizing.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Allow Fullscreen but not screen resize

Post by Jasoco »

On macOS, the green Zoom button (The Mac equivalent to maximize) does put Löve into fullscreen if you enable it. It just changes the resolution of the window to the screen resolution. The benefit to this is that it also gets its own Space which you can switch between at will rather than taking over the screen completely and requiring you to exit the game or minimize it to get to other apps.

Windows doesn't do this I don't think. Maximize just resizes the window to the full screen but still keeps the titlebar and taskbar.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Allow Fullscreen but not screen resize

Post by zorg »

It also depends on the fullscreen mode (desktop or exclusive); older games used the latter type, but nowadays, it's better to use desktop fullscreen.

By the way, raidho is right in that the player's full-screen resolution may be anything, so allowing your game to switch to that needs to be handled in one of many specific ways; centering the graphics or stretching them, whether aspect-correctly or not (i.e. by the same amount on both axes, and the amount is either the smaller value that you need to stretch by to fit one axis and not have things be outside the screen, or the larger if you don't mind some parts of the screen not being shown)

Then again, as i said above, if you're going for a pixel-perfect look or something, then your only choice still is integral zooming, to keep things pixel perfect; that means both manual resizing and full-screen mode would need to display at supported resolutions as well. (w.r.t. full-screen, it could be made to be 1 size (supported full-screen size) bigger than the desired one, and just move the graphics to the center, as i said above)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests