Skip to content

Refactor: LegacyApplication optimization + javadoc #2489

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

capdevon
Copy link
Contributor

@capdevon capdevon commented Jun 12, 2025

This PR introduces getter and setter methods for the paused state in the LegacyApplication class. This allows external control and querying of the application's paused status, enhancing flexibility for game state management.

Code Refinements: Minor optimizations and robustness improvements have been implemented.

Enhancing the Javadoc documentation across the entire class.

Add helper methods:

  • initializeInputDevice()
  • destroyInputDevice()

capdevon added 2 commits June 12, 2025 11:50
This PR introduces getter and setter methods for the `paused` state in the `LegacyApplication` class. This allows external control and querying of the application's paused status, enhancing flexibility for game state management, especially when the application loses/gains focus.

Code Refinements: Minor optimizations and robustness improvements have been implemented.

Enhancing the Javadoc documentation across the entire class.
@yaRnMcDonuts yaRnMcDonuts added this to the v3.9.0 milestone Jun 13, 2025
@capdevon capdevon changed the title Add isPaused() and setPaused() methods to LegacyApplication Feat LegacyApplication: add isPaused() and setPaused() methods Jun 13, 2025
@yaRnMcDonuts
Copy link
Member

yaRnMcDonuts commented Jun 16, 2025

I'm inclined to approve this;

However, I am wondering if there would actually be much use case for calling this setPause(true) method on the whole app, since it looks like this internal "pause" variable was originally meant to only be used for pausing the entire app when setPauseOnLostFocus() is set true. I think this is more of an internal pause variable specifically for freeing up resources and pausing absolutely everything when the game is minimized, and I don't know if there would be any actual way to set it back to false manually. Because if setting this true does indeed pause absolutely everything (including input) then there would be no possible way for the app to listen for input to change it back to false.

I like the idea of having a publicly accessible boolean for pausing the update loop, but if this pause variable also pauses menus and input, then I think a different separate pause variable should be added to pause just the update loop, and that way it isn't also being tied in with the setPauseOnLostFocus() functionality that also toggles the pause variable internally when the app is minimized and refocused. This would mean that a user who set pause true manually wouldn't be able to minimize and refocus or it would automatically unpause. So I think a new public pauseUpdateLoop variable would be the best way to do this, so that way it is entirely separated from setPauseOnLostFocus()

@capdevon
Copy link
Contributor Author

capdevon commented Jun 16, 2025

Hi @yaRnMcDonuts ,
You're right. I usually set the LegacyApplication.speed to almost zero to pause the game. This way, all the moving objects, animations, and physics are almost motionless while the InputManager continues to receive input. I assumed that I could use the pause variable in the same way. However, as you pointed out, this approach does not work. Since using the speed variable is very subjective and may not suit everyone, it's best to remove the isPaused() and setPaused() methods. That way, programmers can decide the best way to pause the scene for debugging purposes. I am modifying the title of the PR so that this change deals almost exclusively with Javadoc, rather than adding new functionality.

Thanks for the feedback

@capdevon capdevon changed the title Feat LegacyApplication: add isPaused() and setPaused() methods Refactor: LegacyApplication optimization + javadoc Jun 16, 2025
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

Successfully merging this pull request may close these issues.

2 participants