[FEATURE REQUEST] - Add ability to scale GUI(s) and mouse sprites during runtime

Started by Gal Shemesh, Wed 03/07/2024 12:25:34

Previous topic - Next topic

Gal Shemesh

In AGS 4.0 there's a very nice feature that allows scaling of GUI elements during runtime - meaning that a GUI can be created in a 1:1 aspect ratio and then presented in 2:1 for example wen the game runs for an AGI style look, the same as when setting a room to 160x200 and then make it scale twice as wide to fill a 320x200 resolution, using the viewport scaling option.

Also, since Mouse cursors behave the same as GUI(s) in terms of lack of scaling options in the current build, it would be nice if we could also affect the mouse cursor sprites so they too could be scaled on runtime.

Crimson Wizard

I don't quite understand this topic, if this is about scaling GUIs, then this feature is already implemented in the latest AGS 4 build.

Scaling cursor graphic is as trivial as creating a resized dynamic sprite and setting to cursor.

There's also an idea of scaling full game image with certain ratio, as I mentioned in another thread here -
https://www.adventuregamestudio.co.uk/forums/editor-development/feature-request-agi-21-aspect-ratio-support/msg636663194/#msg636663194
- engine has to support whole "GUI layer" transformation and/or whole Game screen transformation.

Snarky

Quote from: Crimson Wizard on Wed 03/07/2024 13:07:59Scaling cursor graphic is as trivial as creating a resized dynamic sprite and setting to cursor.

There are a few wrinkles with this, if you want a "general" solution that "just works":

-There's no way to know the cursor's hotspot coordinates (the cursor pixel that acts as the "point" of interaction; e.g. in the LucasArts crosshair it's the center of the sprite), so when scaling up the cursor you have to just know what it should be and manually set it
-You can have animated cursors, and in that case you need to replace the sprites in the view. (Possible to do, but adds complication; also, if for some reason you reuse the view for something else, e.g. an in-game manual, that will also be affected.)
-If you're using a module that changes the mouse graphics, it won't respect the rescaling

Gal Shemesh

So the only thing I can think of at this time is to having an object for presenting the mouse sprite in any of the rooms (since we can't have global objects), and then to have the mouse pointer without any sprite set to it and to just make the object follow the mouse X and Y position in the repeatedly_execute_always(). Though, now when I think of it, the object couldn't go with the mouse beyond the borders of the room... So no I guess.

Crimson Wizard

Quote from: Gal Shemesh on Wed 03/07/2024 13:57:46So the only thing I can think of at this time is to having an object for presenting the mouse sprite in any of the rooms (since we can't have global objects)

Cursor may be represented by a GUI or screen overlay, which are global objects.

Gal Shemesh

Quote from: Crimson WizardCursor may be represented by a GUI or screen overlay, which are global objects.

Right, a GUI element for a mouse could be very handy. Though currently we cannot resize it like in AGS 4.0. So I guess that only a screen overlay will do.

Snarky

Quote from: Gal Shemesh on Wed 03/07/2024 13:57:46So the only thing I can think of at this time is to having an object for presenting the mouse sprite in any of the rooms (since we can't have global objects)

I still think the easiest way is the no-code solution of simply importing a sprite that has been scaled up for the cursor graphic. In most games the number of cursor sprites is very limited, so this is quick to do and won't make any appreciable difference to game size.

I question whether there is any actual need for engine support here.

Gal Shemesh

Quote from: Snarky on Wed 03/07/2024 14:18:34I question whether there is any actual need for engine support here.
Mainly to prevent any sub-pixel appearance when the sprites are shown one over the other, like a mouse cursor sprite on a room area. If you have the room that is shown in 2:2 aspect ratio in runtime, but on the other hand you use a mouse cursor which its sprite was imported as 2:2, this will cause sub-pixel appearance, as the pixels size of the room and the mouse are not the same. So pixels can show in between each other when you move the mouse cursor. See image below for an example of a 1:1 room and a 2:2 mouse cursor.


Crimson Wizard

Quote from: Gal Shemesh on Wed 03/07/2024 14:35:14Mainly to prevent any sub-pixel appearance when the sprites are shown one over the other, like a mouse cursor sprite on a room area.

This cannot be fixed by scaling a graphic. This may be only fixed by forcing the cursor movement to the same resolution as the room.

Same is related to GUI. Scaled or not, but if their position is in different coordinate resolution than the underlying room, there may be "subpixel" issues.

Snarky

Yeah, what CW said. That's not an issue of scaling the mouse cursor graphic, but "scaling" the mouse coordinates. I think I mentioned to you on Discord that to avoid this, you'll have to snap the mouse coordinates to the closest multiple of the scaling factor.

SMF spam blocked by CleanTalk