@@ -2,42 +2,59 @@ extends WindowDialog
2
2
3
3
4
4
export (PackedScene ) var user_profile_section : PackedScene
5
+ export (String ) var text_select_profile := "Select Profile"
5
6
export (String ) var text_restart := "A game restart is required to apply the settings"
6
7
export (String ) var text_profile_create_error := "There was an error creating the profile - check logs"
7
8
export (String ) var text_profile_select_error := "There was an error selecting the profile - check logs"
8
9
export (String ) var text_profile_delete_error := "There was an error deleting the profile - check logs"
9
10
export (String ) var text_mod_enable_error := "There was an error enabling the mod - check logs"
10
11
export (String ) var text_mod_disable_error := "There was an error disabling the mod - check logs"
12
+ export (String ) var text_mod_current_config_change_error := "There was an error changing the config - check logs"
11
13
export (String ) var text_current_profile := " (Current Profile)"
12
14
15
+ onready var label_select_profile : Label = $ "% LabelSelectProfile"
13
16
onready var user_profile_sections := $ "% UserProfileSections"
14
17
onready var profile_select = $ "% ProfileSelect"
15
18
onready var popup_new_profile = $ "% PopupNewProfile"
16
19
onready var input_profile_name = $ "% InputProfileName"
17
20
onready var button_profile_name_submit = $ "% ButtonProfileNameSubmit"
18
21
onready var button_new_profile = $ "% ButtonNewProfile"
19
- onready var mod_list = $ "% ModList"
20
22
onready var info_text = $ "% InfoText"
21
23
22
24
23
25
func _ready () -> void :
24
26
_populate_profile_select ()
25
27
_generate_user_profile_section ()
26
28
29
+ ModLoader .connect ("current_config_changed" , self , "_on_ModLoader_current_config_changed" )
30
+
27
31
28
32
func _input (event ) -> void :
29
33
if event is InputEventKey :
30
34
if event .pressed and event .scancode == KEY_U :
31
35
popup_centered () if not visible else hide ()
32
36
33
37
38
+ func apply_config (config : ModConfig ) -> void :
39
+ label_select_profile .text = config .data .select_profile_text
40
+
41
+ var material_settings : Dictionary = config .data .material_settings
42
+
43
+ material .set_shader_param ("animate" , material_settings .animate )
44
+ material .set_shader_param ("square_scale" , material_settings .square_scale )
45
+ material .set_shader_param ("blur_amount" , material_settings .blur_amount )
46
+ material .set_shader_param ("mix_amount" , material_settings .mix_amount )
47
+ material .set_shader_param ("color_over" , Color (material_settings .color ))
48
+
49
+
34
50
func _update_ui () -> void :
35
51
# Update the profile select list
36
52
_populate_profile_select ()
37
53
38
54
# Update the Setting list
39
55
_generate_user_profile_section ()
40
56
57
+
41
58
func _populate_profile_select () -> void :
42
59
var index_current_profile : int
43
60
@@ -56,8 +73,9 @@ func _populate_profile_select() -> void:
56
73
57
74
58
75
func _generate_user_profile_section () -> void :
59
- mod_list .clear_mod_list ()
60
- mod_list .generate_mod_list (ModLoaderUserProfile .get_current ())
76
+ for section in user_profile_sections .get_children ():
77
+ section .clear_grid ()
78
+ section .generate_grid (ModLoaderUserProfile .get_current ())
61
79
62
80
63
81
func _on_ButtonNewProfile_pressed () -> void :
@@ -67,7 +85,7 @@ func _on_ButtonNewProfile_pressed() -> void:
67
85
func _on_ButtonDeleteProfile_pressed ():
68
86
var profile_to_delete := ModLoaderStore .current_user_profile
69
87
# Switch to default profile
70
- if not ModLoaderUserProfile .set_profile ("default" ):
88
+ if not ModLoaderUserProfile .set_profile (ModLoaderConfig . DEFAULT_CONFIG_NAME ):
71
89
info_text .text = text_profile_select_error
72
90
return
73
91
# Delete the profile
@@ -93,7 +111,17 @@ func _on_ButtonProfileNameSubmit_pressed() -> void:
93
111
popup_new_profile .hide ()
94
112
95
113
96
- func _mod_is_active_changed (mod_id : String , is_active : bool ) -> void :
114
+ func _on_ProfileSelect_item_selected (index : int ) -> void :
115
+ if not ModLoaderUserProfile .set_profile (profile_select .get_item_text (index )):
116
+ info_text .text = text_profile_select_error
117
+ return
118
+
119
+ _update_ui ()
120
+
121
+ info_text .text = text_restart
122
+
123
+
124
+ func _on_ModList_mod_is_active_changed (mod_id : String , is_active : bool ) -> void :
97
125
if is_active :
98
126
if not ModLoaderUserProfile .enable_mod (mod_id ):
99
127
info_text .text = text_mod_enable_error
@@ -106,11 +134,14 @@ func _mod_is_active_changed(mod_id: String, is_active: bool) -> void:
106
134
info_text .text = text_restart
107
135
108
136
109
- func _on_ProfileSelect_item_selected (index : int ) -> void :
110
- if not ModLoaderUserProfile .set_profile (profile_select .get_item_text (index )):
111
- info_text .text = text_profile_select_error
112
- return
137
+ func _on_ModList_mod_current_config_changed (mod_id : String , current_config_name : String ):
138
+ var config := ModLoaderConfig .get_config (mod_id , current_config_name )
113
139
114
- _update_ui ()
140
+ if not config :
141
+ info_text .text = text_mod_current_config_change_error
115
142
116
- info_text .text = text_restart
143
+ ModLoaderConfig .set_current_config (config )
144
+
145
+
146
+ func _on_ModLoader_current_config_changed (config : ModConfig ) -> void :
147
+ _update_ui ()
0 commit comments