Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Comments

Implements User Settings#23

Merged
thnhmai06 merged 1 commit intodevfrom
feat/user-settings
Nov 4, 2025
Merged

Implements User Settings#23
thnhmai06 merged 1 commit intodevfrom
feat/user-settings

Conversation

@thnhmai06
Copy link
Member

No description provided.

Add AppEventSystem for managing application events, including loading and saving user settings. Introduce GameSettingsManager and UserSettingsManager for handling game and user-specific settings. Refactor LaunchOptions for better command-line argument parsing.
@thnhmai06 thnhmai06 requested a review from Copilot November 4, 2025 02:23
@thnhmai06 thnhmai06 merged commit 779354c into dev Nov 4, 2025
11 checks passed
@thnhmai06 thnhmai06 deleted the feat/user-settings branch November 4, 2025 02:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the settings management system by separating concerns into distinct managers and introducing new data structures. The refactoring improves code organization by splitting monolithic classes into specialized managers for game settings, user settings, and launch options.

Key changes:

  • Split SettingsManager into GameSettingsManager and UserSettingsManager with clearly separated responsibilities
  • Refactored LaunchOptions from a static utility class into a record-based pattern with LaunchOptionsManager
  • Introduced new record types (LaunchOptions, UserSettings) for better data modeling
  • Added AppEventSystem to handle application lifecycle events (startup/shutdown)
  • Updated default window dimensions from properties file (1024x768) vs hardcoded in UserSettings (1280x960)

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
settings.properties Added logic.width and logic.height properties for game window dimensions
UserSettings.java New record class representing user settings with Video and Audio nested classes
LaunchOptions.java New record representing launch options with debug flag
AppEventSystem.java New system for managing application lifecycle events (load/save user settings)
UserSettingsManager.java New manager for loading/saving user settings from TOML files
LaunchOptionsManager.java Refactored from LaunchOptions class to use record-based pattern
GameSettingsManager.java Refactored from SettingsManager to focus on game initialization settings
UserSetting.java Deleted - replaced by UserSettings.java and UserSettingsManager.java
SettingsManager.java Deleted - split into GameSettingsManager and UserSettingsManager
Bounceverse.java Updated to use new manager classes and added onPreInit lifecycle hook

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/**
*
*
* <h1>${@link LaunchOptions}</h1>
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Javadoc syntax error: '${@link LaunchOptions}' should be '{@link LaunchOptions}' (remove the '$' character).

Suggested change
* <h1>${@link LaunchOptions}</h1>
* <h1>{@link LaunchOptions}</h1>

Copilot uses AI. Check for mistakes.
}

/**
* Lây settings trong game.
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'Lây' to 'Lấy'.

Suggested change
* Lây settings trong game.
* Lấy settings trong game.

Copilot uses AI. Check for mistakes.
}

/** Setting về Hình ảnh. */
public static final class Video {
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The default dimensions in UserSettings (1280x960) differ from the logic dimensions in settings.properties (1024x768). This inconsistency could cause confusion. Consider using the same default values or documenting why they differ. The GameSettingsManager uses the properties file values for logical game dimensions, while UserSettings uses these values for the window size, but the relationship between these two sets of dimensions is unclear.

Suggested change
public static final class Video {
public static final class Video {
/**
* Default window width and height for the game.
* These values (1280x960) represent the initial window size for the user.
* Note: The logical game dimensions (used for internal game logic and rendering)
* are set to 1024x768 in settings.properties. The window size is larger to allow
* for UI scaling, better user experience, or display of additional elements.
* If you change these values, ensure the relationship with logical dimensions is clear.
*/

Copilot uses AI. Check for mistakes.
settings.setApplicationMode(
Boolean.parseBoolean(gameSettings.getProperty("general.devMode"))
? ApplicationMode.DEVELOPER
: (LaunchOptionsManager.getOptions().debug())
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Potential NullPointerException if LaunchOptionsManager.getOptions() returns null. This can occur if GameSettingsManager.loadTo() is called before LaunchOptionsManager.load() is invoked. Although the documentation mentions this requirement, consider adding a null check or initializing with a default LaunchOptions value to make the code more robust.

Suggested change
: (LaunchOptionsManager.getOptions().debug())
: (LaunchOptionsManager.getOptions() != null && LaunchOptionsManager.getOptions().debug())

Copilot uses AI. Check for mistakes.
Comment on lines +50 to +52
* <p><b>Chú ý: Cần loadTo {@link GameSettingsManager#loadTo(GameSettings)} trước khi tải.</b>
*
* @param settings Setting muốn loadTo
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The documentation states 'Cần loadTo {@link GameSettingsManager#loadTo(GameSettings)} trước khi tải' (Need to loadTo GameSettingsManager#loadTo before loading), which appears to be a copy-paste error. The method name 'loadTo' is used as a verb here but should probably just be 'load'. The comment should clarify that GameSettingsManager.loadTo() needs to be called before UserSettingsManager.load() can be used, not that something needs to be 'loadTo'.

Suggested change
* <p><b>Chú ý: Cần loadTo {@link GameSettingsManager#loadTo(GameSettings)} trước khi tải.</b>
*
* @param settings Setting muốn loadTo
* <p><b>Chú ý: Phải gọi {@link GameSettingsManager#loadTo(GameSettings)} trước khi tải user settings bằng phương thức này.</b>
*
* @param settings Setting người dùng cần tải

Copilot uses AI. Check for mistakes.
*
* <p><b>Chú ý: Cần loadTo {@link GameSettingsManager#loadTo(GameSettings)} trước khi tải.</b>
*
* @param settings Setting muốn loadTo
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Similar to the previous issue, '@param settings Setting muốn loadTo' uses 'loadTo' as a verb. It should be '@param settings Setting muốn load' or '@param settings Setting muốn tải' for consistency with the method's purpose.

Suggested change
* @param settings Setting muốn loadTo
* @param settings Setting muốn load

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +46
settings.setWidth(Integer.parseInt(gameSettings.getProperty("logic.width")));
settings.setHeight(Integer.parseInt(gameSettings.getProperty("logic.height")));
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Potential uncaught 'java.lang.NumberFormatException'.

Suggested change
settings.setWidth(Integer.parseInt(gameSettings.getProperty("logic.width")));
settings.setHeight(Integer.parseInt(gameSettings.getProperty("logic.height")));
try {
settings.setWidth(Integer.parseInt(gameSettings.getProperty("logic.width")));
} catch (NumberFormatException e) {
System.err.println("Invalid value for logic.width: " + gameSettings.getProperty("logic.width") + ". Using default width 800.");
settings.setWidth(800);
}
try {
settings.setHeight(Integer.parseInt(gameSettings.getProperty("logic.height")));
} catch (NumberFormatException e) {
System.err.println("Invalid value for logic.height: " + gameSettings.getProperty("logic.height") + ". Using default height 600.");
settings.setHeight(600);
}

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +46
settings.setWidth(Integer.parseInt(gameSettings.getProperty("logic.width")));
settings.setHeight(Integer.parseInt(gameSettings.getProperty("logic.height")));
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Potential uncaught 'java.lang.NumberFormatException'.

Suggested change
settings.setWidth(Integer.parseInt(gameSettings.getProperty("logic.width")));
settings.setHeight(Integer.parseInt(gameSettings.getProperty("logic.height")));
try {
settings.setWidth(Integer.parseInt(gameSettings.getProperty("logic.width")));
} catch (NumberFormatException e) {
System.err.println("Invalid value for logic.width: " + gameSettings.getProperty("logic.width") + ". Using default width 800.");
settings.setWidth(800);
}
try {
settings.setHeight(Integer.parseInt(gameSettings.getProperty("logic.height")));
} catch (NumberFormatException e) {
System.err.println("Invalid value for logic.height: " + gameSettings.getProperty("logic.height") + ". Using default height 600.");
settings.setHeight(600);
}

Copilot uses AI. Check for mistakes.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant