Skip to content

Conversation

DexterFstone
Copy link

@DexterFstone DexterFstone requested review from a team as code owners June 8, 2025 06:30
@AdriaandeJongh
Copy link
Contributor

Love this functionality! But the UX of this needs work – because if the user wants to slow down a lot to see a specific thing in slow motion and then resume normally, it needs a LOT of clicks with this interface.

Perhaps a dropdown (probably), a small slider, or a small field where one can enter a percentage.

@DexterFstone
Copy link
Author

Perhaps a dropdown (probably)

image

@AdriaandeJongh
Copy link
Contributor

Cool! Without the << and >> buttons, I think the UX is a lot better.

@DexterFstone
Copy link
Author

DexterFstone commented Jun 8, 2025

Cool! Without the << and >> buttons, I think the UX is a lot better.

Do you think the speed reset button is needed?

2025-06-08.05-49-17.mp4

@AdriaandeJongh
Copy link
Contributor

Arguably it would be great to be able to reset to 1.0x using a little reset button (like the one used to reset variables to their default in the inspector!), but we wouldn’t want the bar to grow or shrink in width. maybe there’s a clean solution to this?

@DexterFstone
Copy link
Author

maybe there’s a clean solution to this?

I have two solutions, the first is to reset the value by right-clicking on the menu button, the second is to add a button to reset it, when the value is one, the button is not hidden and only disabled.

@AdriaandeJongh
Copy link
Contributor

as right clicking is hidden, the button is probably a better idea?

@YeldhamDev
Copy link
Member

The current implementation changes several values directly. Instead, they should override those temporarily (and add up to those that have been changed in the game itself) and go back to their original values once done.

@YeldhamDev
Copy link
Member

Let me give you a example:

  • The user's game overrides the game speed (set_time_scale()) manually for some gameplay reason. Lets say a value of 1.2.
  • With the current implementation of your PR, the current value set by the user is erased in favor of the one chosen in the UI.
  • The correct implementation would be to temporally override it, and to also add up to it. So if the user picks 0.5 in the UI, it will still remember that the original ingame value was 1.2, and change the speed internally to 0.6. And setting it in the UI back to 1, will set it back to 1.2.

This is how it's done for the mouse mode behavior as well.

@Calinou
Copy link
Member

Calinou commented Jun 9, 2025

Cool! Without the << and >> buttons, I think the UX is a lot better.

The reason I wanted those buttons is to have keyboard shortcuts for them, but we can replace it with a toggle that enables the speed override instead. This means you could toggle between slow motion and full speed, or full speed and fast-forward. It would use remember the last selected speed to toggle back to every time you press the shortcut (on startup, it'd default to 2×).

Emulators generally have a key you can press (or hold, like in Dolphin) to enable turbo mode. They sometimes have a separate slow motion key though (as well as frame advance).

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 0732f18 to dd5849c Compare June 10, 2025 04:39
@DexterFstone DexterFstone requested a review from a team as a code owner June 10, 2025 04:39
@DexterFstone
Copy link
Author

Let me give you a example:

  • The user's game overrides the game speed (set_time_scale()) manually for some gameplay reason. Lets say a value of 1.2.
  • With the current implementation of your PR, the current value set by the user is erased in favor of the one chosen in the UI.
  • The correct implementation would be to temporally override it, and to also add up to it. So if the user picks 0.5 in the UI, it will still remember that the original ingame value was 1.2, and change the speed internally to 0.6. And setting it in the UI back to 1, will set it back to 1.2.

This is how it's done for the mouse mode behavior as well.

I updated the code so that time_scale can be changed both by code and the UI at the same time.
Should I do this for physics_ticks_per_second and max_physics_steps_per_frame as well?

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from dd5849c to 6083546 Compare June 10, 2025 06:58
@YeldhamDev
Copy link
Member

Should I do this for physics_ticks_per_second and max_physics_steps_per_frame as well?

They can also be changed by the user, so yes.

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 6083546 to b46b8c2 Compare June 11, 2025 08:31
@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from b46b8c2 to addc7bc Compare June 11, 2025 09:34
@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from addc7bc to b233c0c Compare June 11, 2025 09:57
@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from b233c0c to 9bb5cb0 Compare June 11, 2025 10:32
@DexterFstone
Copy link
Author

2025-06-11.05-48-48.mp4

There's a problem, don't I?

@DexterFstone
Copy link
Author

Will it also effective for movie writer?

I haven't tested yet, but this should be effecte.

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 2e6004a to fd6292e Compare July 9, 2025 06:18
@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from fd6292e to 9754672 Compare July 10, 2025 17:03
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected (including with run-time time speed controls coming from the project itself, using godotengine/godot-demo-projects#1234). Great work 🙂

I've made some review comments that improve the display of the time speed control to look like this:

image

Notice the Unicode multiplication symbol and rounding being improved to show the correct game speed for the slowest setting.

@DexterFstone
Copy link
Author

Tested locally, it works as expected (including with run-time time speed controls coming from the project itself, using godotengine/godot-demo-projects#1234). Great work 🙂

I've made some review comments that improve the display of the time speed control to look like this:

image Notice the Unicode multiplication symbol and rounding being improved to show the correct game speed for the slowest setting.

Do I need to set a minimum size because different size values will cause the controls to move?

@Calinou
Copy link
Member

Calinou commented Aug 6, 2025

Do I need to set a minimum size because different size values will cause the controls to move?

Yes, it's a good idea to increase the minimum width of the MenuButton to cater for its longest possible string 0.0625×.

Alternatively, you could display speeds lower than 1× as fractions to be shorter, e.g. 1/16×.

@DexterFstone
Copy link
Author

Alternatively, you could display speeds lower than 1× as fractions to be shorter, e.g. 1/16×.

it's not appear well for 0.75

@Calinou
Copy link
Member

Calinou commented Aug 6, 2025

it's not appear well for 0.75

You could display that one as 3/4× 🙂

@DexterFstone
Copy link
Author

You could display that one as 3/4× 🙂

Yeah I know, but I mean inside for loop to do math stuff

@llama-nl
Copy link

llama-nl commented Aug 7, 2025

I have a suggestion :
It would be great to add a slider to control the speed, along with an option in editor settings to choose which one to use.

@DexterFstone
Copy link
Author

I have a suggestion : It would be great to add a slider to control the speed, along with an option in editor settings to choose which one to use.

I tested the slider previously; the UI became weird.

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from c32d907 to 4fa91bd Compare August 19, 2025 07:42
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great now 🙂

image

@arkology
Copy link
Contributor

Works great now 🙂

image

BTW, could we detect width of the widest label before drawing it and set custom minimum size to this value? Setting custom minimum size to some specific value may work not very well if, for example, font size is set to very small or big value

@Calinou
Copy link
Member

Calinou commented Aug 19, 2025

BTW, could we detect width of the widest label before drawing it and set custom minimum size to this value? Setting custom minimum size to some specific value may work not very well if, for example, font size is set to very small or big value

Yes, this can be done using TextLine::get_line_width() on the longest string (1/16×).

@arkology
Copy link
Contributor

There is also get_minimum_size_for_text_and_icon(), maybe this could be used.

@arkology
Copy link
Contributor

arkology commented Aug 20, 2025

Ok, looks like I found a solution.
@DexterFstone please try to place the following code into NOTIFICATION_THEME_CHANGED and NOTIFICATION_POST_ENTER_TREE:

	float min_size = 0;
	for (String lbl : time_scale_label) {
		min_size = MAX(speed_state_button->get_minimum_size_for_text_and_icon(vformat(U"%s×", lbl), Ref<Texture2D>()).x, min_size);
	}
	speed_state_button->set_custom_minimum_size(Vector2(min_size, 0));

With this you don't need unreliable speed_state_button->set_custom_minimum_size(Vector2(48, 0) * EDSCALE);

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 4fa91bd to 1e5a271 Compare August 21, 2025 09:39
@DexterFstone
Copy link
Author

Ok, looks like I found a solution. @DexterFstone please try to place the following code into NOTIFICATION_THEME_CHANGED and NOTIFICATION_POST_ENTER_TREE:

	float min_size = 0;
	for (String lbl : time_scale_label) {
		min_size = MAX(speed_state_button->get_minimum_size_for_text_and_icon(vformat(U"%s×", lbl), Ref<Texture2D>()).x, min_size);
	}
	speed_state_button->set_custom_minimum_size(Vector2(min_size, 0));

With this you don't need unreliable speed_state_button->set_custom_minimum_size(Vector2(48, 0) * EDSCALE);

Done

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

Successfully merging this pull request may close these issues.

Add slow motion and fast-forward controls to the embedded game window
10 participants