Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AGS 4: Add GUI.ScaleX, ScaleY and SetScale(x,y) #2426

Draft
wants to merge 4 commits into
base: ags4
Choose a base branch
from

Conversation

ivan-mogilko
Copy link
Contributor

@ivan-mogilko ivan-mogilko commented May 11, 2024

Implements script API for GUI scaling. Set as draft for now, in case API receives any criticism.

Adds:

  • GUI.ScaleX,
  • GUI.ScaleY,
  • GUI.SetScale(x,y),
  • GUI.GUIToScreenPoint(int guix, int guiy, bool clipToGUI),
  • ScreenToGUIPoint(int screenx, int screeny, bool clipToGUI)

All scale values are set in floats, and used as direct scaling factors, which means that

final_width = gui.Width * gui.ScaleX;
final_height = gui.Height * gui.ScaleY;

Scaled object's image shifts relative to object's "origin". In case of GUI that's top-left corner. If user wants to have scaling relative to GUI's center, they will have to adjust X,Y position as well.

Negative values are allowed and result in mirrored image. That's not "intentional", it just works this way... If this seems redundant, it's easy to force to strictly positive values.
Scale value 0 is allowed and means that the object is not drawn at all.

Note that visual results depend on number of factors, including game resolution, gui size, scaling.
"Render sprites at screen resolution" makes dramatic change in both upscale and downscale quality.

ISSUES

Scaling rotated GUI has unexpected results, where either origin or pivot point is being shifted around (scaled?), resulting in GUI visibly moving around while being scaled as well.
Either this is a problem with GUI's pivot not being the same location as origin, or a wrong order of transforms again...
A care has to be taken, make sure that any fixes to this won't break other types of objects that have different combinations of default origin/pivot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ags 4 related to the ags4 development context: script api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant