Skip to content

Commit 9ef9311

Browse files
committed
feat: 🚀 init
1 parent 8af6d0b commit 9ef9311

File tree

12 files changed

+662
-0
lines changed

12 files changed

+662
-0
lines changed
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[gd_resource type="DynamicFont" load_steps=2 format=2]
2+
3+
[ext_resource path="res://mods-unpacked/KANA-UserProfile/assets/fonts/CascadiaCode.ttf" type="DynamicFontData" id=1]
4+
5+
[resource]
6+
font_data = ExtResource( 1 )
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[gd_resource type="DynamicFont" load_steps=2 format=2]
2+
3+
[ext_resource path="res://mods-unpacked/KANA-UserProfile/assets/fonts/CascadiaCode.ttf" type="DynamicFontData" id=1]
4+
5+
[resource]
6+
size = 14
7+
outline_color = Color( 0.847059, 0.847059, 0.847059, 1 )
8+
font_data = ExtResource( 1 )
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
[gd_resource type="Shader" format=2]
2+
3+
[resource]
4+
code = "// https://godotshaders.com/shader/simple-blur-mixed-with-a-color/
5+
// https://gist.github.com/rohanrhu/11ffd387e1cc228d15bcea56fad4f593
6+
7+
shader_type canvas_item;
8+
9+
uniform float radius: hint_range(0., 1.) = 1;
10+
uniform bool animate = false;
11+
uniform float square_scale: hint_range(0., 1.) = 0.1;
12+
uniform float blur_amount : hint_range(-2.0, 10.0);
13+
uniform float mix_amount : hint_range(0.0, 1.0);
14+
uniform vec4 color_over : hint_color;
15+
16+
void fragment() {
17+
float sc = square_scale + square_scale/2.;
18+
float r = square_scale + (1. - radius) * (square_scale/2.);
19+
20+
float scax = 1. - square_scale;
21+
22+
float dx;
23+
float dy;
24+
float d;
25+
float a;
26+
27+
vec4 blurred = textureLod(SCREEN_TEXTURE, SCREEN_UV, blur_amount);
28+
vec4 fin = mix(blurred, color_over, mix_amount);
29+
COLOR = fin;
30+
31+
if (UV.x < square_scale && UV.y > scax) {
32+
dx = square_scale - UV.x;
33+
dy = scax - UV.y;
34+
d = sqrt(pow(dx, 2.) + pow(dy, 2.));
35+
a = asin(d);
36+
37+
if (a > r) {
38+
if (!animate) {
39+
COLOR.a = 0.;
40+
} else if (a > sc * sin(3.14 * fract(TIME))) {
41+
COLOR.a = 0.;
42+
}
43+
}
44+
}
45+
46+
if (UV.x < square_scale && UV.y < square_scale) {
47+
dx = square_scale - UV.x;
48+
dy = square_scale - UV.y;
49+
d = sqrt(pow(dx, 2.) + pow(dy, 2.));
50+
a = asin(d);
51+
52+
if (a > r) {
53+
if (!animate) {
54+
COLOR.a = 0.;
55+
} else if (a > sc * sin(3.14 * fract(TIME))) {
56+
COLOR.a = 0.;
57+
}
58+
}
59+
}
60+
61+
if (UV.x > scax && UV.y < square_scale) {
62+
dx = scax - UV.x;
63+
dy = square_scale - UV.y;
64+
d = sqrt(pow(dx, 2.) + pow(dy, 2.));
65+
a = asin(d);
66+
67+
if (a > r) {
68+
if (!animate) {
69+
COLOR.a = 0.;
70+
} else if (a > sc * sin(3.14 * fract(TIME))) {
71+
COLOR.a = 0.;
72+
}
73+
}
74+
}
75+
76+
if (UV.x > scax && UV.y > scax) {
77+
dx = scax - UV.x;
78+
dy = scax - UV.y;
79+
d = sqrt(pow(dx, 2.) + pow(dy, 2.));
80+
a = asin(d);
81+
82+
if (a > r) {
83+
if (!animate) {
84+
COLOR.a = 0.;
85+
} else if (a > sc * sin(3.14 * fract(TIME))) {
86+
COLOR.a = 0.;
87+
}
88+
}
89+
}
90+
}
91+
"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
extends MarginContainer
2+
3+
4+
signal mod_is_active_changed(mod_id, is_active)
5+
6+
export(PackedScene) var mod_list_mod
7+
8+
var section_name := "" setget _set_section_name
9+
10+
onready var user_profile_name := $"%SectionName"
11+
onready var mod_list = $"%ModList"
12+
13+
14+
func _set_section_name(new_name: String) -> void:
15+
section_name = new_name
16+
user_profile_name.text = new_name
17+
18+
19+
func generate_mod_list(user_profile: ModLoaderUserProfile.Profile) -> void:
20+
for mod_id in user_profile.mod_list.keys():
21+
var new_mod_list_mod: HBoxContainer = mod_list_mod.instance()
22+
23+
new_mod_list_mod.connect("is_active_toggled", self, "_on_mod_is_active_toggled")
24+
mod_list.add_child(new_mod_list_mod)
25+
new_mod_list_mod.mod_id = mod_id
26+
new_mod_list_mod.is_active = user_profile.mod_list[mod_id]
27+
28+
if ModLoaderStore.mod_data.has(mod_id):
29+
var mod: ModData = ModLoaderStore.mod_data[mod_id]
30+
31+
# Check if mod is locked
32+
if mod.is_locked:
33+
# Disable the checkbox if it is
34+
new_mod_list_mod.is_disabled = true
35+
new_mod_list_mod.set_mandatory_color()
36+
37+
# Check if the mod is loadable
38+
if not mod.is_loadable:
39+
new_mod_list_mod.set_error_color()
40+
41+
42+
func clear_mod_list() -> void:
43+
for child in mod_list.get_children():
44+
mod_list.remove_child(child)
45+
child.free()
46+
47+
func _on_mod_is_active_toggled(mod_id: String, is_active: bool) -> void:
48+
emit_signal("mod_is_active_changed", mod_id, is_active)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[gd_scene load_steps=4 format=2]
2+
3+
[ext_resource path="res://mods-unpacked/KANA-UserProfile/content/ModList.gd" type="Script" id=1]
4+
[ext_resource path="res://mods-unpacked/KANA-UserProfile/content/ModListMod.tscn" type="PackedScene" id=2]
5+
[ext_resource path="res://mods-unpacked/KANA-UserProfile/assets/fonts/Heading.tres" type="DynamicFont" id=3]
6+
7+
[node name="ModList" type="MarginContainer"]
8+
margin_left = 20.0
9+
margin_top = 20.0
10+
margin_right = 1900.0
11+
margin_bottom = 1060.0
12+
custom_constants/margin_top = 10
13+
custom_constants/margin_bottom = 10
14+
script = ExtResource( 1 )
15+
mod_list_mod = ExtResource( 2 )
16+
17+
[node name="VBoxContainer" type="VBoxContainer" parent="."]
18+
margin_top = 10.0
19+
margin_right = 1880.0
20+
margin_bottom = 1030.0
21+
22+
[node name="SectionName" type="Label" parent="VBoxContainer"]
23+
unique_name_in_owner = true
24+
margin_right = 1880.0
25+
margin_bottom = 19.0
26+
custom_fonts/font = ExtResource( 3 )
27+
text = "Active Mods"
28+
29+
[node name="ModList" type="VBoxContainer" parent="VBoxContainer"]
30+
unique_name_in_owner = true
31+
margin_top = 23.0
32+
margin_right = 1880.0
33+
margin_bottom = 23.0
34+
size_flags_horizontal = 3
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
extends HBoxContainer
2+
3+
4+
signal is_active_toggled(mod_id, is_active)
5+
6+
export(Color) var color_error = Color.indianred
7+
export(Color) var color_mandatory = Color.darkgray
8+
9+
var mod_id := "" setget _set_mod_id
10+
var is_active: bool setget _set_is_active
11+
var is_disabled := false setget _set_is_disabled
12+
13+
onready var mod_id_label = $"%ModID"
14+
onready var check_box = $"%CheckBox"
15+
16+
17+
func set_error_color() -> void:
18+
_set_label_color(color_error)
19+
20+
21+
func set_mandatory_color() -> void:
22+
_set_label_color(color_mandatory)
23+
24+
25+
func _set_label_color(color: Color) -> void:
26+
mod_id_label.add_color_override("font_color", color)
27+
28+
29+
func _set_mod_id(new_mod_id: String) -> void:
30+
mod_id = new_mod_id
31+
mod_id_label.text = new_mod_id
32+
33+
34+
func _set_is_active(new_is_active: bool) -> void:
35+
is_active = new_is_active
36+
check_box.pressed = new_is_active
37+
38+
39+
func _set_is_disabled(new_is_disabled: bool) -> void:
40+
is_disabled = is_disabled
41+
check_box.disabled = new_is_disabled
42+
43+
44+
func _on_CheckBox_toggled(button_pressed):
45+
is_active = button_pressed
46+
47+
48+
func _on_CheckBox_pressed():
49+
emit_signal("is_active_toggled", mod_id, is_active)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[gd_scene load_steps=3 format=2]
2+
3+
[ext_resource path="res://mods-unpacked/KANA-UserProfile/content/ModListMod.gd" type="Script" id=1]
4+
[ext_resource path="res://mods-unpacked/KANA-UserProfile/assets/fonts/text.tres" type="DynamicFont" id=2]
5+
6+
[node name="ModListMod" type="HBoxContainer"]
7+
margin_right = 1880.0
8+
size_flags_horizontal = 3
9+
script = ExtResource( 1 )
10+
color_mandatory = Color( 0.521569, 0.521569, 0.521569, 1 )
11+
12+
[node name="ModID" type="Label" parent="."]
13+
unique_name_in_owner = true
14+
margin_top = 3.0
15+
margin_right = 938.0
16+
margin_bottom = 20.0
17+
size_flags_horizontal = 3
18+
custom_colors/font_color = Color( 0.741176, 0.741176, 0.741176, 1 )
19+
custom_fonts/font = ExtResource( 2 )
20+
text = "%MODNAME%"
21+
22+
[node name="CheckBox" type="CheckBox" parent="."]
23+
unique_name_in_owner = true
24+
margin_left = 942.0
25+
margin_right = 1880.0
26+
margin_bottom = 24.0
27+
size_flags_horizontal = 3
28+
29+
[connection signal="pressed" from="CheckBox" to="." method="_on_CheckBox_pressed"]
30+
[connection signal="toggled" from="CheckBox" to="." method="_on_CheckBox_toggled"]
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
extends WindowDialog
2+
3+
4+
export(PackedScene) var user_profile_section: PackedScene
5+
export(String) var text_restart := "A game restart is required to apply the settings"
6+
export(String) var text_profile_create_error := "There was an error creating the profile - check logs"
7+
export(String) var text_profile_select_error := "There was an error selecting the profile - check logs"
8+
export(String) var text_profile_delete_error := "There was an error deleting the profile - check logs"
9+
export(String) var text_mod_enable_error := "There was an error enabling the mod - check logs"
10+
export(String) var text_mod_disable_error := "There was an error disabling the mod - check logs"
11+
export(String) var text_current_profile := " (Current Profile)"
12+
13+
onready var user_profile_sections := $"%UserProfileSections"
14+
onready var profile_select = $"%ProfileSelect"
15+
onready var popup_new_profile = $"%PopupNewProfile"
16+
onready var input_profile_name = $"%InputProfileName"
17+
onready var button_profile_name_submit = $"%ButtonProfileNameSubmit"
18+
onready var button_new_profile = $"%ButtonNewProfile"
19+
onready var mod_list = $"%ModList"
20+
onready var info_text = $"%InfoText"
21+
22+
23+
func _ready() -> void:
24+
_populate_profile_select()
25+
_generate_user_profile_section()
26+
27+
28+
func _input(event) -> void:
29+
if event is InputEventKey:
30+
if event.pressed and event.scancode == KEY_U:
31+
popup_centered() if not visible else hide()
32+
33+
34+
func _update_ui() -> void:
35+
# Update the profile select list
36+
_populate_profile_select()
37+
38+
# Update the Setting list
39+
_generate_user_profile_section()
40+
41+
func _populate_profile_select() -> void:
42+
var index_current_profile: int
43+
44+
profile_select.clear()
45+
46+
for user_profile in ModLoaderUserProfile.get_all_as_array():
47+
var is_current_profile := true if ModLoaderStore.current_user_profile == user_profile.name else false
48+
profile_select.add_item(user_profile.name + text_current_profile if is_current_profile else user_profile.name)
49+
50+
# Get the item index of the current profile
51+
if is_current_profile:
52+
index_current_profile = profile_select.get_item_count() - 1
53+
54+
# Select current profile
55+
profile_select.select(index_current_profile)
56+
57+
58+
func _generate_user_profile_section() -> void:
59+
mod_list.clear_mod_list()
60+
mod_list.generate_mod_list(ModLoaderUserProfile.get_current())
61+
62+
63+
func _on_ButtonNewProfile_pressed() -> void:
64+
popup_new_profile.popup_centered()
65+
66+
67+
func _on_ButtonDeleteProfile_pressed():
68+
var profile_to_delete := ModLoaderStore.current_user_profile
69+
# Switch to default profile
70+
if not ModLoaderUserProfile.set_profile("default"):
71+
info_text.text = text_profile_select_error
72+
return
73+
# Delete the profile
74+
if not ModLoaderUserProfile.delete_profile(profile_to_delete):
75+
info_text.text = text_profile_delete_error
76+
return
77+
78+
_update_ui()
79+
80+
81+
func _on_ButtonProfileNameSubmit_pressed() -> void:
82+
# Create new User Profile
83+
if not ModLoaderUserProfile.create_profile(input_profile_name.text):
84+
# If there was an error creating the profile
85+
# Add error message to the info text label
86+
info_text.text = text_profile_create_error
87+
# And return early
88+
return
89+
90+
_update_ui()
91+
92+
# Close popup
93+
popup_new_profile.hide()
94+
95+
96+
func _mod_is_active_changed(mod_id: String, is_active: bool) -> void:
97+
if is_active:
98+
if not ModLoaderUserProfile.enable_mod(mod_id):
99+
info_text.text = text_mod_enable_error
100+
return
101+
else:
102+
if not ModLoaderUserProfile.disable_mod(mod_id):
103+
info_text.text = text_mod_disable_error
104+
return
105+
106+
info_text.text = text_restart
107+
108+
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
113+
114+
_update_ui()
115+
116+
info_text.text = text_restart

0 commit comments

Comments
 (0)