-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat: Add rename_profile()
to ModLoaderUserProfile
#352
base: development
Are you sure you want to change the base?
Conversation
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.
Thanks for your PR! Let me know if you have any questions or if something is unclear.
rename_profile()
to ModLoaderUserProfile
@KANAjetzt Thank you very much for your review, now I think I have corrected the changes the way you suggested. Question for "running modloader in godot" do I need to take the mod developer route to test it? |
For starters, you can create an empty Godot Project and follow the steps on this page. If you get this working, you can look into symlinking the That will allow you to edit the code inside Godot, where you will get some syntax errors to fix. If no compile errors show up anymore, you can look into the mod developer route and add the rename functionality to the example user profile UI mod. This would be ideal, but it might be a bit overwhelming if you've never used Godot. So feel free to just edit your code inside Godot to get the syntax error messages, and I will review your code again. |
Hi @KANAjetzt sorry that it took so long, i corrected some changes as I am able to get the syntax error now |
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.
Almost there - thanks for your work! 👍
As I said in the review, it's important to test things in practice. I added the rename feature to the example UI mod and found the mentioned issues.
addons/mod_loader/api/profile.gd
Outdated
return false | ||
|
||
# Rename user profile | ||
var profile_to_rename = ModLoaderStore.user_profiles[old_profile_name].duplicate(true) |
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.
var profile_to_rename = ModLoaderStore.user_profiles[old_profile_name].duplicate(true) | |
var profile_renamed := ModLoaderStore.user_profiles[old_profile_name].duplicate() as ModUserProfile |
I only figured this out because I implemented this function in the UserProfileUI mod - so its always a good idea to test your code in practice 😃
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 renamed it from profile_to_rename
-> profile_renamed
- I feel like this is more clear because it is the reference to the renamed profile.
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 also realized that we are duplicating a Resource here, and that comes with some caveats (here are the Docs).
I added the as ModUserProfile
to cast the type. Without that, it's just a generic Resource
, and set_profile(profile_renamed)
will not work. In addition, I had to change mod_user_profile.gd. As described in the docs, only exported properties are duplicated, so I added the two export
to the file:
export var name := ""
export var mod_list := {}
addons/mod_loader/api/profile.gd
Outdated
# Set it as the current profile | ||
if ModLoaderStore.current_user_profile == ModLoaderStore.user_profiles[old_profile_name]: | ||
ModLoaderStore.current_user_profile[new_profile_name] |
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.
# Set it as the current profile | |
if ModLoaderStore.current_user_profile == ModLoaderStore.user_profiles[old_profile_name]: | |
ModLoaderStore.current_user_profile[new_profile_name] | |
# Set it as the current profile if it was the current profile | |
if ModLoaderStore.current_user_profile.name == old_profile_name: | |
set_profile(profile_renamed) |
We can't check for ModLoaderStore.user_profiles[old_profile_name]
because it got erased a few lines above.
Thank you again :) I'm sorry I don't have the chance yet to really dive deep into it.. |
closes #287
Hi, for this change I modified and reference myself to method create_profile as @KANAjetzt in https://github.com/GodotModding/godot-mod-loader/blob/development/addons/mod_loader/api/profile.gd :)