1
1
extends WindowDialog
2
2
3
-
4
3
export (PackedScene ) var user_profile_section : PackedScene
5
4
export (String ) var text_select_profile := "Select Profile"
6
5
export (String ) var text_restart := "A game restart is required to apply the settings"
7
6
export (String ) var text_profile_create_error := "There was an error creating the profile - check logs"
7
+ export (String ) var text_profile_rename_error := "There was an error renaming the profile - check logs"
8
8
export (String ) var text_profile_select_error := "There was an error selecting the profile - check logs"
9
9
export (String ) var text_profile_delete_error := "There was an error deleting the profile - check logs"
10
10
export (String ) var text_mod_enable_error := "There was an error enabling the mod - check logs"
@@ -16,16 +16,22 @@ onready var label_select_profile: Label = $"%LabelSelectProfile"
16
16
onready var user_profile_sections := $ "% UserProfileSections"
17
17
onready var profile_select = $ "% ProfileSelect"
18
18
onready var popup_new_profile = $ "% PopupNewProfile"
19
+ onready var popup_rename_profile : WindowDialog = $ "% PopupRenameProfile"
19
20
onready var input_profile_name = $ "% InputProfileName"
20
21
onready var button_profile_name_submit = $ "% ButtonProfileNameSubmit"
21
22
onready var button_new_profile = $ "% ButtonNewProfile"
22
23
onready var info_text = $ "% InfoText"
24
+ onready var input_rename_profile_name : LineEdit = $ "% InputRenameProfileName"
25
+
26
+ var profile_selected : ModUserProfile
23
27
24
28
25
29
func _ready () -> void :
26
30
_populate_profile_select ()
27
31
_generate_user_profile_section ()
28
32
33
+ profile_selected = ModLoaderUserProfile .get_current ()
34
+
29
35
ModLoader .connect ("current_config_changed" , self , "_on_ModLoader_current_config_changed" )
30
36
31
37
@@ -61,8 +67,14 @@ func _populate_profile_select() -> void:
61
67
profile_select .clear ()
62
68
63
69
for user_profile in ModLoaderUserProfile .get_all_as_array ():
64
- var is_current_profile := true if ModLoaderUserProfile .get_current ().name == user_profile .name else false
65
- profile_select .add_item (user_profile .name + text_current_profile if is_current_profile else user_profile .name )
70
+ var is_current_profile := (
71
+ true
72
+ if ModLoaderUserProfile .get_current ().name == user_profile .name
73
+ else false
74
+ )
75
+ profile_select .add_item (
76
+ user_profile .name + text_current_profile if is_current_profile else user_profile .name
77
+ )
66
78
67
79
# Get the item index of the current profile
68
80
if is_current_profile :
@@ -95,20 +107,37 @@ func _on_ButtonDeleteProfile_pressed():
95
107
96
108
_update_ui ()
97
109
110
+ profile_selected = ModLoaderUserProfile .get_current ()
111
+
112
+
113
+ func _on_ButtonRename_pressed () -> void :
114
+ popup_rename_profile .popup_centered ()
98
115
99
- func _on_ButtonProfileNameSubmit_pressed () -> void :
100
- # Create new User Profile
101
- if not ModLoaderUserProfile .create_profile (input_profile_name .text ):
102
- # If there was an error creating the profile
103
- # Add error message to the info text label
104
- info_text .text = text_profile_create_error
105
- # And return early
106
- return
116
+
117
+ func _on_ButtonProfileNameSubmit_pressed (is_rename : bool ) -> void :
118
+ if is_rename :
119
+ var success := ModLoaderUserProfile .rename_profile (
120
+ profile_selected .name , input_rename_profile_name .text
121
+ )
122
+ if not success :
123
+ info_text .text = text_profile_rename_error
124
+ return
125
+ # Close popup
126
+ popup_rename_profile .hide ()
127
+ else :
128
+ # Create new User Profile
129
+ if not ModLoaderUserProfile .create_profile (input_profile_name .text ):
130
+ # If there was an error creating the profile
131
+ # Add error message to the info text label
132
+ info_text .text = text_profile_create_error
133
+ # And return early
134
+ return
135
+ # Close popup
136
+ popup_new_profile .hide ()
107
137
108
138
_update_ui ()
109
139
110
- # Close popup
111
- popup_new_profile .hide ()
140
+ profile_selected = ModLoaderUserProfile .get_current ()
112
141
113
142
114
143
func _on_ProfileSelect_item_selected (index : int ) -> void :
@@ -117,12 +146,14 @@ func _on_ProfileSelect_item_selected(index: int) -> void:
117
146
info_text .text = text_profile_select_error
118
147
return
119
148
149
+ profile_selected = user_profile
150
+
120
151
_update_ui ()
121
152
122
153
info_text .text = text_restart
123
154
124
155
125
- func _on_ModList_mod_is_active_changed (mod_id : String , is_active : bool ) -> void :
156
+ func _on_ModList_mod_is_active_changed (mod_id : String , is_active : bool ) -> void :
126
157
if is_active :
127
158
if not ModLoaderUserProfile .enable_mod (mod_id ):
128
159
info_text .text = text_mod_enable_error
0 commit comments