Skip to content

Commit dfa01bb

Browse files
committed
feat: 🚧 add current_config selection
1 parent ccf3b23 commit dfa01bb

File tree

8 files changed

+126
-42
lines changed

8 files changed

+126
-42
lines changed

root/mods-unpacked/GodotModding-UserProfile/content/ModList.gd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ extends MarginContainer
44
signal mod_is_active_changed(mod_id, is_active)
55

66
export(PackedScene) var mod_list_mod
7+
export(String) var section_name := "" setget _set_section_name
78

8-
var section_name := "" setget _set_section_name
9-
10-
onready var user_profile_name := $"%SectionName"
11-
onready var mod_list = $"%ModList"
9+
onready var label_section_name := $"%SectionName"
10+
onready var mod_list = $"%ModLists"
1211

1312

1413
func _set_section_name(new_name: String) -> void:
1514
section_name = new_name
16-
user_profile_name.text = new_name
15+
if label_section_name:
16+
label_section_name.text = new_name
1717

1818

1919
func generate_mod_list(user_profile: ModLoaderUserProfile.Profile) -> void:
@@ -23,7 +23,7 @@ func generate_mod_list(user_profile: ModLoaderUserProfile.Profile) -> void:
2323
new_mod_list_mod.connect("is_active_toggled", self, "_on_mod_is_active_toggled")
2424
mod_list.add_child(new_mod_list_mod)
2525
new_mod_list_mod.mod_id = mod_id
26-
new_mod_list_mod.is_active = user_profile.mod_list[mod_id]
26+
new_mod_list_mod.is_active = user_profile.mod_list[mod_id].is_active
2727

2828
if ModLoaderStore.mod_data.has(mod_id):
2929
var mod: ModData = ModLoaderStore.mod_data[mod_id]

root/mods-unpacked/GodotModding-UserProfile/content/ModList.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ margin_bottom = 19.0
2626
custom_fonts/font = ExtResource( 3 )
2727
text = "Active Mods"
2828

29-
[node name="ModList" type="VBoxContainer" parent="VBoxContainer"]
29+
[node name="ModLists" type="VBoxContainer" parent="VBoxContainer"]
3030
unique_name_in_owner = true
3131
margin_top = 23.0
3232
margin_right = 1880.0

root/mods-unpacked/GodotModding-UserProfile/content/ModListMod.gd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ signal is_active_toggled(mod_id, is_active)
55

66
export(Color) var color_error = Color.indianred
77
export(Color) var color_mandatory = Color.darkgray
8+
enum CONTROL_TYPES { ACTIVE_TOGGLE, CONFIG_SELECTION }
9+
export(CONTROL_TYPES) var current_control_type
810

911
var mod_id := "" setget _set_mod_id
1012
var is_active: bool setget _set_is_active
1113
var is_disabled := false setget _set_is_disabled
1214

1315
onready var mod_id_label = $"%ModID"
1416
onready var check_box = $"%CheckBox"
17+
onready var config_selection = $"%ConfigSelection"
1518

1619

1720
func set_error_color() -> void:
@@ -29,6 +32,13 @@ func _set_label_color(color: Color) -> void:
2932
func _set_mod_id(new_mod_id: String) -> void:
3033
mod_id = new_mod_id
3134
mod_id_label.text = new_mod_id
35+
populate_current_config_selection(new_mod_id)
36+
37+
38+
func populate_current_config_selection(mod_id: String) -> void:
39+
var configs := ModLoaderConfig.get_mod_configs(mod_id)
40+
for config in configs:
41+
config_selection.add_item(config.name)
3242

3343

3444
func _set_is_active(new_is_active: bool) -> void:
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
[gd_scene load_steps=3 format=2]
22

3-
[ext_resource path="res://mods-unpacked/GodotModding-UserProfile/content/ModListMod.gd" type="Script" id=1]
43
[ext_resource path="res://mods-unpacked/GodotModding-UserProfile/assets/fonts/text.tres" type="DynamicFont" id=2]
4+
[ext_resource path="res://mods-unpacked/GodotModding-UserProfile/content/ModListMod.gd" type="Script" id=3]
55

66
[node name="ModListMod" type="HBoxContainer"]
77
margin_right = 1880.0
88
size_flags_horizontal = 3
9-
script = ExtResource( 1 )
9+
script = ExtResource( 3 )
1010
color_mandatory = Color( 0.521569, 0.521569, 0.521569, 1 )
1111

1212
[node name="ModID" type="Label" parent="."]
1313
unique_name_in_owner = true
14-
margin_top = 3.0
1514
margin_right = 938.0
16-
margin_bottom = 20.0
15+
margin_bottom = 17.0
1716
size_flags_horizontal = 3
1817
custom_colors/font_color = Color( 0.741176, 0.741176, 0.741176, 1 )
1918
custom_fonts/font = ExtResource( 2 )
2019
text = "%MODNAME%"
2120

22-
[node name="CheckBox" type="CheckBox" parent="."]
23-
unique_name_in_owner = true
21+
[node name="ControlType" type="Control" parent="."]
2422
margin_left = 942.0
2523
margin_right = 1880.0
26-
margin_bottom = 24.0
24+
margin_bottom = 17.0
2725
size_flags_horizontal = 3
2826

29-
[connection signal="pressed" from="CheckBox" to="." method="_on_CheckBox_pressed"]
30-
[connection signal="toggled" from="CheckBox" to="." method="_on_CheckBox_toggled"]
27+
[node name="ConfigSelection" type="OptionButton" parent="ControlType"]
28+
unique_name_in_owner = true
29+
margin_left = 926.0
30+
margin_right = 955.0
31+
margin_bottom = 20.0
32+
33+
[node name="CheckBox" type="CheckBox" parent="ControlType"]
34+
unique_name_in_owner = true
35+
margin_left = 617.0
36+
margin_right = 1230.0
37+
margin_bottom = 24.0
38+
size_flags_horizontal = 3

root/mods-unpacked/GodotModding-UserProfile/content/UserProfiles.gd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ func _populate_profile_select() -> void:
5656

5757

5858
func _generate_user_profile_section() -> void:
59-
mod_list.clear_mod_list()
60-
mod_list.generate_mod_list(ModLoaderUserProfile.get_current())
59+
for section in user_profile_sections.get_children():
60+
section.section_name = section.section_name
61+
section.clear_mod_list()
62+
section.generate_mod_list(ModLoaderUserProfile.get_current())
6163

6264

6365
func _on_ButtonNewProfile_pressed() -> void:

root/mods-unpacked/GodotModding-UserProfile/content/UserProfiles.tscn

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ shader_param/animate = false
1313
shader_param/square_scale = 0.1
1414
shader_param/blur_amount = 5.061
1515
shader_param/mix_amount = 0.705
16-
shader_param/color_over = null
16+
shader_param/color_over = Color( 0, 0, 0, 1 )
1717

1818
[sub_resource type="ImageTexture" id=4]
1919

@@ -131,6 +131,19 @@ margin_left = 0.0
131131
margin_top = 0.0
132132
margin_right = 460.0
133133
margin_bottom = 43.0
134+
section_name = "Active Mods"
135+
136+
[node name="VBoxContainer" parent="MarginContainer/VBoxContainer/ProfileSettings/ScrollContainer/VBoxContainer/UserProfileSections/ModList" index="0"]
137+
margin_right = 460.0
138+
margin_bottom = 33.0
139+
140+
[node name="ModList2" parent="MarginContainer/VBoxContainer/ProfileSettings/ScrollContainer/VBoxContainer/UserProfileSections" instance=ExtResource( 3 )]
141+
unique_name_in_owner = true
142+
margin_left = 0.0
143+
margin_top = 0.0
144+
margin_right = 460.0
145+
margin_bottom = 43.0
146+
section_name = "Mod Configs"
134147

135148
[node name="InfoText" type="Label" parent="MarginContainer/VBoxContainer"]
136149
unique_name_in_owner = true
@@ -203,5 +216,6 @@ text = "OK"
203216
[connection signal="item_selected" from="MarginContainer/VBoxContainer/ProfileSelection/ProfileSelect" to="." method="_on_ProfileSelect_item_selected"]
204217
[connection signal="pressed" from="MarginContainer/VBoxContainer/ProfileSelection/ButtonNewProfile" to="." method="_on_ButtonNewProfile_pressed"]
205218
[connection signal="pressed" from="MarginContainer/VBoxContainer/ProfileSelection/ButtonDeleteProfile" to="." method="_on_ButtonDeleteProfile_pressed"]
206-
[connection signal="mod_is_active_changed" from="MarginContainer/VBoxContainer/ProfileSettings/ScrollContainer/VBoxContainer/UserProfileSections/ModList" to="." method="_mod_is_active_changed"]
207219
[connection signal="pressed" from="PopupNewProfile/MarginContainer/VBoxContainer/VBoxContainer/ButtonProfileNameSubmit" to="." method="_on_ButtonProfileNameSubmit_pressed"]
220+
221+
[editable path="MarginContainer/VBoxContainer/ProfileSettings/ScrollContainer/VBoxContainer/UserProfileSections/ModList"]

root/mods-unpacked/GodotModding-UserProfile/manifest.json

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,75 @@
44
"version_number": "0.1.0",
55
"description": "Example Mod for User Profiles",
66
"website_url": "https://github.com/GodotModding",
7-
"dependencies": [
8-
9-
],
7+
"dependencies": [],
108
"extra": {
119
"godot": {
1210
"authors": [
1311
"GodotModding"
1412
],
15-
"optional_dependencies": [
16-
17-
],
18-
"compatible_game_version": [
19-
20-
],
13+
"optional_dependencies": [],
14+
"compatible_game_version": [],
2115
"compatible_mod_loader_version": [
2216
"6.0.0"
2317
],
24-
"incompatibilities": [
25-
26-
],
27-
"load_before": [
28-
29-
],
30-
"tags": [
31-
32-
],
33-
"config_defaults": {
34-
18+
"incompatibilities": [],
19+
"load_before": [],
20+
"tags": [],
21+
"config_schema": {
22+
"title": "Config",
23+
"description": "Config for this Mod",
24+
"type": "object",
25+
"properties": {
26+
"material_settings": {
27+
"title": "Material Settings",
28+
"type": "object",
29+
"properties": {
30+
"square_scale": {
31+
"type": "number",
32+
"title": "Square Scale",
33+
"minimum": 0.0,
34+
"maximum": 0.3,
35+
"multipleOf": 0.001,
36+
"default": 0.1
37+
},
38+
"animate": {
39+
"type": "boolean",
40+
"title": "Animate",
41+
"default": false
42+
},
43+
"bluer_amount": {
44+
"type": "number",
45+
"title": "Bluer Amount",
46+
"minimum": 0.0,
47+
"maximum": 10.0,
48+
"multipleOf": 0.1,
49+
"default": 5.1
50+
},
51+
"mix_amount": {
52+
"type": "number",
53+
"title": "Mix Amount",
54+
"minimum": 0.0,
55+
"maximum": 1.0,
56+
"multipleOf": 0.01,
57+
"default": 0.71
58+
},
59+
"color": {
60+
"type": "array",
61+
"title": "Color Over",
62+
"prefixItems": [
63+
{ "type": "number", "minimum": 0, "maximum": 255 },
64+
{ "type": "number", "minimum": 0, "maximum": 255 },
65+
{ "type": "number", "minimum": 0, "maximum": 255 },
66+
{ "type": "number", "minimum": 0, "maximum": 255 }
67+
],
68+
"items": false,
69+
"minItems": 3,
70+
"maxItems": 4,
71+
"default": [0, 0, 0, 255]
72+
}
73+
}
74+
}
75+
}
3576
},
3677
"description_rich": "",
3778
"image": null

root/mods-unpacked/GodotModding-UserProfile/mod_main.gd

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ var translations_dir_path := ""
1010

1111

1212
func _init(modLoader = ModLoader) -> void:
13-
ModLoaderUtils.log_info("Init", GodotModding_User_Profile_LOG_NAME)
14-
mod_dir_path = modLoader.UNPACKED_DIR.plus_file(GodotModding_User_Profile_MOD_DIR)
13+
ModLoaderLog.info("Init", GodotModding_User_Profile_LOG_NAME)
14+
mod_dir_path = ModLoaderMod.get_unpacked_dir().plus_file(GodotModding_User_Profile_MOD_DIR)
1515

1616
# Add extensions
1717
install_script_extensions(modLoader)
@@ -31,3 +31,12 @@ func add_translations(modLoader) -> void:
3131
func _ready():
3232
var user_profile_dialog = load("res://mods-unpacked/GodotModding-UserProfile/content/UserProfiles.tscn").instance()
3333
get_tree().root.call_deferred("add_child", user_profile_dialog)
34+
35+
# handle_config()
36+
37+
38+
func handle_config() -> void:
39+
# Get the mod config
40+
var config := ModLoaderConfig.get_current_config(GodotModding_User_Profile_MOD_DIR)
41+
print(JSON.print(config, '\t'))
42+

0 commit comments

Comments
 (0)