first commit, long overdue

deez
This commit is contained in:
martyTF 2025-11-22 21:04:34 +01:00
commit 54b9012a47
79 changed files with 2516 additions and 0 deletions

View file

@ -0,0 +1,152 @@
extends Node2D
var category
var item
var item_filter = ""
var config
var ini
var sheet
var sort = "alphabetically"
func _enter_tree() -> void:
ini = "res://02 - Configurations/" + category + ".ini"
%new_item_name.visible = false
%delete.visible = false
%item_name.visible = false
%save.visible = false
%new_item.text = "New " + category
%filter.placeholder_text = "Filter " + category
%new_item_name.placeholder_text = "Set " + category + " name"
%save.text = "Save " + category
#print(category)
list_items()
func _on_close_button_up() -> void:
queue_free()
func list_items() -> void:
config = ConfigFile.new()
config.load(ini)
print(ini)
var k = config.get_sections()
if sort == "alphabetically":
k.sort()
#print(str(k))
var i = 0
%list.item_count = k.size()
#print(str(%list.item_count))
for j in k:
if item_filter == "":
%list.set_item_text(i,str(j))
i = i+1
elif item_filter.to_lower() in j.to_lower():
%list.set_item_text(i,str(j))
i = i+1
#print(j)
else:
%list.item_count = %list.item_count -1
#print(str(%list.item_count))
func refresh_view():
%item_name.text = item
if item != "":
config = ConfigFile.new()
config.load(ini)
%save.visible = false
func _on_list_item_selected(index: int) -> void:
item = %list.get_item_text(index)
#print(%list.get_item_text(index))
%delete.text = "Delete " + %list.get_item_text(index)
%delete.visible = true
%item_name.visible = true
if sheet:
remove_child(sheet)
sheet = load("res://01 - Menus/03 - Sheets/item.tscn").instantiate()
sheet.item = item
sheet.category = category
sheet.position.x = 512
sheet.position.y = 256
add_child(sheet)
refresh_view()
func _on_filter_text_changed(new_text: String) -> void:
item_filter = new_text
#print(str(%list.get_selected_items()))
list_items()
if %list.item_count == 1:
%list.select(0)
else:
%list.select(0)
%list.deselect(0)
func _on_new_item_button_up() -> void:
%new_item_name.visible = true
%new_item_name.grab_focus()
func _on_new_item_name_text_submitted(new_text: String) -> void:
config = ConfigFile.new()
item = new_text
config.load(ini)
config.set_value(item,"type",category)
config.save(ini)
%new_item_name.text = ""
%new_item_name.visible = false
# sheet.save()
refresh_view()
list_items()
func _on_new_item_name_editing_toggled(toggled_on: bool) -> void:
if !toggled_on:
%new_item_name.text = ""
%new_item_name.visible = false
func _on_delete_button_up() -> void:
config = ConfigFile.new()
config.load(ini)
config.erase_section(item)
config.save(ini)
list_items()
item = ""
%delete.visible = false
%item_name.visible = false
remove_child(sheet)
refresh_view()
func _on_save_button_up() -> void:
sheet.save()
%save.visible = false
func show_save():
%save.visible = true
func set_menu_items(pixel_x,pixel_y,ui_scale):
%ui_background.size.y = pixel_y
%close.position.y = pixel_y - 96 * ui_scale
%new_item.position.y = pixel_y - 192 * ui_scale
%new_item_name.position.y = pixel_y - 192 * ui_scale
%delete.position.y = pixel_y - 286 * ui_scale
%filter.position.y = pixel_y - 384 * ui_scale
%list.position = (Vector2(128,128)) * ui_scale
%list.size.y = pixel_y/ui_scale - 620
if pixel_x < pixel_y: #mobile
%ui_background.size.x = pixel_x
for i in [%close,%new_item,%filter,%delete,%save,%new_item_name,%list]:
i.scale = Vector2(ui_scale,ui_scale)
i.size.x = pixel_x/ui_scale - 128
i.position.x = 64 * ui_scale
else:
%ui_background.size.x = 512.0 * ui_scale
for i in [%close,%new_item,%filter,%delete,%save,%new_item_name,%list]:
i.scale = Vector2(ui_scale,ui_scale)
i.size.x = 448
i.position.x = 32 * ui_scale

View file

@ -0,0 +1 @@
uid://c7qgo02sbv7wl

View file

@ -0,0 +1,96 @@
[gd_scene load_steps=2 format=3 uid="uid://cefrjogovj4ql"]
[ext_resource type="Script" uid="uid://c7qgo02sbv7wl" path="res://01 - Menus/02 - Selector/selector.gd" id="1_03gsk"]
[node name="selector" type="Node2D"]
script = ExtResource("1_03gsk")
[node name="background" type="Node2D" parent="."]
[node name="ui_background" type="ColorRect" parent="background"]
unique_name_in_owner = true
offset_right = 512.0
offset_bottom = 1440.0
color = Color(0.047058824, 0.07058824, 0.09803922, 1)
[node name="close" type="Button" parent="."]
unique_name_in_owner = true
offset_left = 96.0
offset_top = 1280.0
offset_right = 416.0
offset_bottom = 1344.0
text = "Close"
[node name="new_item" type="Button" parent="."]
unique_name_in_owner = true
offset_left = 96.0
offset_top = 1184.0
offset_right = 416.0
offset_bottom = 1248.0
text = "New Item
"
[node name="new_item_name" type="LineEdit" parent="."]
unique_name_in_owner = true
offset_left = 40.0
offset_top = 1184.0
offset_right = 490.0
offset_bottom = 1248.0
placeholder_text = "Set Item Name"
[node name="filter" type="LineEdit" parent="."]
unique_name_in_owner = true
offset_left = 96.0
offset_top = 992.0
offset_right = 432.0
offset_bottom = 1056.0
placeholder_text = "Filter Items"
[node name="list" type="ItemList" parent="."]
unique_name_in_owner = true
clip_contents = false
offset_left = 64.0
offset_top = 100.0
offset_right = 448.0
offset_bottom = 832.0
allow_reselect = true
item_count = 2
item_0/text = "Item A"
item_1/text = "Item B"
[node name="delete" type="Button" parent="."]
unique_name_in_owner = true
offset_left = 96.0
offset_top = 1088.0
offset_right = 416.0
offset_bottom = 1152.0
text = "Delete Item"
[node name="save" type="Button" parent="."]
unique_name_in_owner = true
offset_left = 96.0
offset_top = 896.0
offset_right = 416.0
offset_bottom = 960.0
text = "Save Item"
[node name="item_name" type="Label" parent="."]
unique_name_in_owner = true
offset_left = 1280.0
offset_top = 96.0
offset_right = 1920.0
offset_bottom = 170.0
theme_override_font_sizes/font_size = 50
text = "Item Name"
horizontal_alignment = 1
[node name="HTTPRequest" type="HTTPRequest" parent="."]
[connection signal="button_up" from="close" to="." method="_on_close_button_up"]
[connection signal="button_up" from="new_item" to="." method="_on_new_item_button_up"]
[connection signal="editing_toggled" from="new_item_name" to="." method="_on_new_item_name_editing_toggled"]
[connection signal="text_submitted" from="new_item_name" to="." method="_on_new_item_name_text_submitted"]
[connection signal="text_changed" from="filter" to="." method="_on_filter_text_changed"]
[connection signal="item_selected" from="list" to="." method="_on_list_item_selected"]
[connection signal="button_up" from="delete" to="." method="_on_delete_button_up"]
[connection signal="button_up" from="save" to="." method="_on_save_button_up"]