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

On small resolutions the runner takes more space than available #657

Open
nepo-dev opened this issue Aug 30, 2024 · 3 comments
Open

On small resolutions the runner takes more space than available #657

nepo-dev opened this issue Aug 30, 2024 · 3 comments

Comments

@nepo-dev
Copy link
Contributor

nepo-dev commented Aug 30, 2024

Versions

  • Godot: 4.3.1
  • GUT: 9.2.1
  • OS: Linux

The Bug

On small resolutions the runner takes more space than available in the screen. As a result, it appears cropped like this:
image

I'm working on a game with a resolution of 384x216. I would expect the window gets resized correctly and I can see all of it. Like this:
image

Steps To Reproduce

  1. In Godot, create a new project and a test
  2. In Godot, open Project > Project Settings > Display > Window
  3. Set Viewport Width to 384 and Viewport Height to 216.
  4. (Optionally, in GUT's settings, make sure Exit on Finish and Exit on Success are disabled)
@bitwes
Copy link
Owner

bitwes commented Aug 31, 2024

I could probably decrease custom_minimum_size.x on the normal gui (or add the min size logic from the script below). That doesn't really help you out that much though, since it would still be off screen. Maybe exposing the NormalGui and CompactGui nodes to GutHookScript would be the most versatile approach. This would allow you to do whatever you wanted to the gui nodes in a pre-hook script.

Here's a pre-run hook script that accesses some "private" variables to get to the normal gui and then alter it to fit on the screen. Try this out, and let me know if it solves the issue for you. If so, then making it easier to get to these gui nodes in a hook script is probably the best approach.

I usually put my hook scripts in res://test/resources. You need to add this in your .gutconfig and/or configure it in the editor as the pre-hook script.

image
extends GutHookScript

func run():
	var runner = gut.get_node("/root/GutRunner")
	var win_size = gut.get_viewport().get_visible_rect().size
	var norm_gui = runner._gui._normal_gui
	var min_size = Vector2(
		min(win_size.x, norm_gui.custom_minimum_size.x),
		min(win_size.y, norm_gui.custom_minimum_size.y)
	)
	norm_gui.custom_minimum_size = min_size
	norm_gui.size = min_size
	norm_gui.align_right()

@bitwes
Copy link
Owner

bitwes commented Aug 31, 2024

Or maybe I should just add that minimum size logic to _ready in the normal GUI.

@nepo-dev
Copy link
Contributor Author

nepo-dev commented Sep 1, 2024

Oh, I hadn't even seen the hooks section in the documentation 🤦 I'm so sorry! I'll close the PR
That worked like a charm, thank you so much!

If so, then making it easier to get to these gui nodes in a hook script is probably the best approach.

I completely agree! Do you have an idea of how do you want it to look like?

It might be a bad idea, but maybe there could be a singleton that stores references to the current runner and its GUI nodes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants