Conversation
Implement configuration loading from properties files to manage game settings dynamically. This includes setting the game title, version, and application mode based on the loaded configurations. Additionally, update the .gitignore to include new configuration files.
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a configuration system for the Bounceverse game application, replacing hardcoded settings with dynamic configuration loading from properties files.
- Adds configuration loading infrastructure with a Utils class for reading properties files
- Creates a settings.properties file to store game metadata and development mode settings
- Refactors the main application class to use configuration-driven settings initialization
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/main/resources/configs/system/settings.properties | Adds game configuration with name, version, and development mode settings |
| src/main/java/com/github/codestorm/bounceverse/Utils.java | Introduces utility class with file operations for loading properties files |
| src/main/java/com/github/codestorm/bounceverse/Bounceverse.java | Refactors to use configuration-based settings initialization |
| .run/run.run.xml | Updates Gradle run configuration to include info logging |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| public static Properties settings; | ||
|
|
||
| public static void loadConfigs() throws IOException { | ||
| DEFAULT = Utils.File.loadProperties(ROOT + "default.properties"); |
There was a problem hiding this comment.
The code attempts to load 'default.properties' but this file is not included in the PR. This will cause a runtime exception when the application starts.
| DEFAULT = Utils.File.loadProperties(ROOT + "default.properties"); | |
| try { | |
| DEFAULT = Utils.File.loadProperties(ROOT + "default.properties"); | |
| if (DEFAULT == null || DEFAULT.isEmpty()) { | |
| DEFAULT = new Properties(); | |
| DEFAULT.setProperty("width", "800"); | |
| DEFAULT.setProperty("height", "600"); | |
| } | |
| } catch (IOException e) { | |
| DEFAULT = new Properties(); | |
| DEFAULT.setProperty("width", "800"); | |
| DEFAULT.setProperty("height", "600"); | |
| } |
Add structured loading of game configurations with separate classes for default options and system settings. This enhances the game's configurability and prepares for future expansion of settings management.
Implement collision handling system and launch options for game configuration. This includes a new Collision class for managing collision logic and a LaunchOption class for parsing launch arguments (e.g., debug mode).
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| @Override | ||
| protected void initPhysics() { | ||
| Collision.getInstance().apply(); | ||
| ; |
There was a problem hiding this comment.
Remove the unnecessary semicolon on line 99. It serves no purpose and reduces code readability.
| ; |
| InputStream fileStream = IO.class.getResourceAsStream(path); | ||
| assert fileStream != null : "Cannot open InputStream in " + path; |
There was a problem hiding this comment.
Using assert for null checking in production code is not recommended as assertions can be disabled at runtime. Consider throwing an IllegalArgumentException or FileNotFoundException instead.
Improve the loadConfigs method to throw an IOException when properties files cannot be opened (replaces assertion with exception handling). This ensures better error management during configuration loading.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| var scanner = new Scanner(path); | ||
| while (scanner.hasNext()) { | ||
| res.add(scanner.next()); | ||
| } |
There was a problem hiding this comment.
The Scanner constructor is being passed a String path instead of an InputStream. This will cause the Scanner to interpret the path as literal text to scan rather than opening a file. Use Utils.class.getResourceAsStream(path) to get an InputStream.
| var scanner = new Scanner(path); | |
| while (scanner.hasNext()) { | |
| res.add(scanner.next()); | |
| } | |
| InputStream fileStream = IO.class.getResourceAsStream(path); | |
| if (fileStream == null) { | |
| throw new RuntimeException("Cannot open InputStream in " + path); | |
| } | |
| var scanner = new Scanner(fileStream); | |
| while (scanner.hasNextLine()) { | |
| res.add(scanner.nextLine()); | |
| } |
| // Basic | ||
| settings.setTitle(Configs.System.settings.getProperty("settings.name")); | ||
| settings.setVersion(Configs.System.settings.getProperty("settings.version")); | ||
| settings.setCredits(Utils.IO.readTextFile("credits.txt")); |
There was a problem hiding this comment.
This will fail because readTextFile has a bug where it passes the path string directly to Scanner constructor. The path should be prefixed with '/' to read from resources: Utils.IO.readTextFile(\"/credits.txt\").
| settings.setCredits(Utils.IO.readTextFile("credits.txt")); | |
| settings.setCredits(Utils.IO.readTextFile("/credits.txt")); |
| settings.setWidth(Integer.parseInt(Configs.Options.DEFAULT.getProperty("width"))); | ||
| settings.setHeight(Integer.parseInt(Configs.Options.DEFAULT.getProperty("height"))); |
There was a problem hiding this comment.
These lines will throw NullPointerException because Configs.Options.DEFAULT is never loaded in loadConfigs() method. The default.properties file is loaded but the file doesn't exist in the diff.
- Added SceneFactory for managing game scenes (facilitates scene transitions). - Renamed Collision to CollisionSystem for clarity and improved structure. - Integrated credits loading into game settings (enhances user experience).
3203775 to
4da8273
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Summary: Add CollisionSystem (template) and SettingSystems |
* feat: add configuration loading and game settings management Implement configuration loading from properties files to manage game settings dynamically. This includes setting the game title, version, and application mode based on the loaded configurations. Additionally, update the .gitignore to include new configuration files. * feat: implement game configuration loading and management Add structured loading of game configurations with separate classes for default options and system settings. This enhances the game's configurability and prepares for future expansion of settings management. * feat: add collision handling and launch options management Implement collision handling system and launch options for game configuration. This includes a new Collision class for managing collision logic and a LaunchOption class for parsing launch arguments (e.g., debug mode). * feat: enhance configuration loading with error handling Improve the loadConfigs method to throw an IOException when properties files cannot be opened (replaces assertion with exception handling). This ensures better error management during configuration loading. * feat: implement scene management and enhance collision handling - Added SceneFactory for managing game scenes (facilitates scene transitions). - Renamed Collision to CollisionSystem for clarity and improved structure. - Integrated credits loading into game settings (enhances user experience).
No description provided.