-
Notifications
You must be signed in to change notification settings - Fork 29
Implement in game menu for loading mods #512
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
base: master
Are you sure you want to change the base?
Conversation
#define loaded_mods game_manager.get_mod_manager().get_loaded_mods() | ||
if (std::find(loaded_mods.begin(), loaded_mods.end(), &mod) != loaded_mods.end()) { | ||
mod_info_dictionary[mod_info_loaded_key] = true; | ||
} else { | ||
mod_info_dictionary[mod_info_loaded_key] = false; | ||
} | ||
#undef loaded_mods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use macros for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just store it in a local variable.
When using methods to get a value, do not assume the method returns the exact same value each invocation.
Also the method might be costly.
} | ||
|
||
ERR_FAIL_COND_V_MSG(!game_manager.set_roots(roots, replace), FAILED, "Failed to set dataloader roots!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the error macro?
|
||
if (!game_manager.load_mod_descriptors()) { | ||
UtilityFunctions::push_error("Failed to load mod descriptors!"); | ||
err = FAILED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best to return failed here. No point continuing with a broken state.
Also this can be done using ERR_FAIL_COND_V_MSG(!game_manager.load_mod_descriptors(), FAILED, "Failed to load mod descriptors!");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could be better to load the base game if mods are broken or unavailable rather than crashing the whole game. Open to doing it either way, that was my thought process.
|
||
if (!game_manager.load_mods(roots, replace_paths, converted_mods)) { | ||
UtilityFunctions::push_error("Failed to load mods!"); | ||
err = FAILED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as comment L667, better to return here and use error macro.
err = FAILED; | ||
} | ||
|
||
auto add_message = std::bind_front(&LoadLocalisation::add_message, LoadLocalisation::get_singleton()); | ||
if (!game_manager.load_definitions(add_message)) { | ||
UtilityFunctions::push_error("Failed to load defines!"); | ||
err = FAILED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you update the above 2 cases, please also update this for consistency.
func _ready(): | ||
mod_info = GameSingleton.get_mod_info() | ||
var mod_status_file := ConfigFile.new() | ||
mod_status_file.load("user://mods.cfg") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like ModMenu & MainMenu sharing this magic string.
Shouldn't this be part of mod manager or some class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file generally feels like a lot of logic and very little UI.
Consider using a cpp class similar to the BudgetMenu to do the logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define "user://mods.cfg" once instead of thrice.
Implements an in game menu that allows for the selection and loading of available mods.