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,40 @@
extends Node2D
var config
var items:Array
var module
var modules_list
var name_
var name_self
func _enter_tree() -> void:
%scroll.visible = false
config = ConfigFile.new()
config.load("res://02 - Configurations/campaign/categories.ini")
func _on_close_button_up() -> void:
queue_free()
func _on_items_button_up() -> void:
%scroll.visible = true
config = ConfigFile.new()
config.load("res://02 - Configurations/campaign/categories.ini")
items = config.get_sections()
for j in %container.get_children():
%container.remove_child(j)
for i in items + [""]:
var item = load("res://01 - Menus/05 - Campaign Manager/item_helper.tscn").instantiate()
item.item = i
%container.add_child(item)
func _on_save_button_up() -> void:
config = ConfigFile.new()
config.load("res://02 - Configurations/campaign/categories.ini")
for i in items.size() + 1:
%container.get_child(i).save()
_on_items_button_up()

View file

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

View file

@ -0,0 +1,55 @@
[gd_scene load_steps=2 format=3 uid="uid://c6cqrvu2ifno6"]
[ext_resource type="Script" uid="uid://cn6njcwxgyat2" path="res://01 - Menus/05 - Campaign Manager/campaign_manager.gd" id="1_wb8ha"]
[node name="campaign_manager" type="Node2D"]
script = ExtResource("1_wb8ha")
[node name="ui_background" type="ColorRect" parent="."]
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="items" type="Button" parent="."]
unique_name_in_owner = true
offset_left = 96.0
offset_top = 320.0
offset_right = 416.0
offset_bottom = 384.0
text = "items"
[node name="save" 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 = "Save"
[node name="scroll" type="ScrollContainer" parent="."]
unique_name_in_owner = true
clip_contents = false
offset_left = 576.0
offset_top = 64.0
offset_right = 2496.0
offset_bottom = 1408.0
horizontal_scroll_mode = 0
[node name="container" type="VBoxContainer" parent="scroll"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[connection signal="button_up" from="close" to="." method="_on_close_button_up"]
[connection signal="button_up" from="items" to="." method="_on_items_button_up"]
[connection signal="button_up" from="save" to="." method="_on_save_button_up"]

View file

@ -0,0 +1,117 @@
extends Control
var item
var config
var name_
var name_self
var module
var modules_list
var main_menu_entry = ""
func _enter_tree() -> void:
config = ConfigFile.new()
config.load("res://02 - Configurations/campaign/categories.ini")
name_ = config.get_value(item,"name","")
name_self = config.get_value(item,"name_self","")
modules_list = config.get_value(item,"modules_list",[])
%item.text = item
%name.text = name_
%name_self.text = name_self
%add_new_select.visible = false
%module.add_item("")
%module.add_item(%item.text)
print("item_helper:_enter_tree: item_helper for " + item)
var modules:Array = [""]
var select_module = 0
for i in config.get_sections():
print("item_helper:_enter_tree:i populating %add_new_select with " + i)
%add_new_select.add_item(i)
var k = config.get_value(i,"module","")
if k == %item.text: # select item 1 when module has same name as item
print("item_helper:_enter_tree: selecting " + k)
select_module = 1
elif k != "": # proceed only if module is set
if not modules.has(k): # don't duplicate entries
print("item_helper:_enter_tree:2 " + str(k) + " into " + str(modules))
modules = modules + [config.get_value(i,"module","")]
%module.add_item(k)
if k == config.get_value(item,"module",""):
print("item_helper:_enter_tree:3 selecting " + k + " for " + str(i))
select_module = modules.find(k) + 1
%module.select(select_module)
config = ConfigFile.new()
config.load("res://02 - Configurations/campaign/main_menu.ini")
var h = 1
for i in config.get_sections():
%categories.add_item(config.get_value(i,"name",""))
%categories.set_item_tooltip(%categories.item_count - 1,i)
if config.get_value(i,"items",[]).has(item):
%categories.select(h)
h = h + 1
config = ConfigFile.new()
config.load("res://02 - Configurations/campaign/categories.ini")
var j:float = modules_list.size()
if j != 0:
%modules_list.max_columns = j
%modules_list.fixed_column_width = %modules_list.size.x/(1.1*j) - (j *8)
for i in modules_list:
print("item_helper:_enter_tree:1 " + i)
%modules_list.add_item(i)
func save():
if %item.text != "":
config = ConfigFile.new()
config.load("res://02 - Configurations/campaign/categories.ini")
item = %item.text
config.set_value(item,"name",%name.text)
config.set_value(item,"name_self",%name_self.text)
config.set_value(item,"module",%module.text)
var j = []
for i in %modules_list.item_count:
j = j + [%modules_list.get_item_text(i)]
config.set_value(item,"modules_list",j)
print("item_helper:save:1 saving " + item)
config.save("res://02 - Configurations/campaign/categories.ini")
config = ConfigFile.new()
config.load("res://02 - Configurations/campaign/main_menu.ini")
if not config.get_value(main_menu_entry,"items",[]).has(item) and main_menu_entry != "":
print("item_helper:save:2 " + item + " not in " + str(config.get_value(main_menu_entry,"items",[])))
config.set_value(main_menu_entry,"items",config.get_value(main_menu_entry,"items",[]) + [item])
config.save("res://02 - Configurations/campaign/main_menu.ini")
func _on_modules_list_item_selected(index: int) -> void:
print("item_helper:_on_modules_list_item_selected:2 remove " + %modules_list.get_item_text(index))
%modules_list.remove_item(index)
func _on_add_new_item_selected(index: int) -> void:
%modules_list.add_item(%add_new_select.get_item_text(index))
var j:float = %modules_list.item_count
%modules_list.max_columns = j
%modules_list.fixed_column_width = %modules_list.size.x/(1.1*j) - (j *8)
%add_new_select.visible = false
func _on_module_item_selected(index: int) -> void:
module = %module.get_item_text(index)
func _on_add_new_button_up() -> void:
print("item_helper:_on_add_new_button_up:1 Add new")
%add_new_select.visible = true
func _on_add_new_select_focus_exited() -> void:
%add_new_select.visible = false
func _on_item_text_changed(new_text: String) -> void:
%module.set_item_text(1,new_text)
func _on_categories_item_selected(index: int) -> void:
main_menu_entry = %categories.get_item_tooltip(index)
print("item_helper:_on_categories_item_selected:1 " + str(main_menu_entry))

View file

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

View file

@ -0,0 +1,131 @@
[gd_scene load_steps=2 format=3 uid="uid://chky5yb5bj7gy"]
[ext_resource type="Script" uid="uid://nft8qh8eyyn4" path="res://01 - Menus/05 - Campaign Manager/item_helper.gd" id="1_yac37"]
[node name="item_helper" type="Control"]
custom_minimum_size = Vector2(0, 320)
layout_mode = 3
anchors_preset = 0
offset_right = 2112.0
offset_bottom = 192.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_yac37")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 0
offset_right = 1920.0
offset_bottom = 320.0
color = Color(0.047058824, 0.07058824, 0.09803922, 1)
[node name="item" type="LineEdit" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.030303031
anchor_top = 0.2
anchor_right = 0.030303031
anchor_bottom = 0.2
offset_right = 256.0
offset_bottom = 64.0
placeholder_text = "technical name"
metadata/_edit_use_anchors_ = true
[node name="name_self" type="LineEdit" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.18200001
anchor_top = 0.2
anchor_right = 0.18200001
anchor_bottom = 0.2
offset_left = -0.3840332
offset_right = 255.61597
offset_bottom = 64.0
placeholder_text = "singular name"
metadata/_edit_use_anchors_ = true
[node name="name" type="LineEdit" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.333
anchor_top = 0.2
anchor_right = 0.333
anchor_bottom = 0.2
offset_left = 0.7039795
offset_right = 256.70398
offset_bottom = 64.0
placeholder_text = "multiple name"
metadata/_edit_use_anchors_ = true
[node name="modules_list" type="ItemList" parent="."]
unique_name_in_owner = true
clip_contents = false
layout_mode = 1
anchors_preset = -1
anchor_left = 0.030000001
anchor_top = 0.5
anchor_right = 0.030000001
anchor_bottom = 0.5
offset_left = 0.6399994
offset_right = 1472.64
offset_bottom = 128.0
metadata/_edit_use_anchors_ = true
[node name="add_new_select" type="OptionButton" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = -1
anchor_left = 0.54545456
anchor_top = 0.6
anchor_right = 0.54545456
anchor_bottom = 0.6
offset_right = 512.0
offset_bottom = 64.0
metadata/_edit_use_anchors_ = true
[node name="module" type="OptionButton" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.4848485
anchor_top = 0.2
anchor_right = 0.4848485
anchor_bottom = 0.2
offset_right = 256.0
offset_bottom = 64.0
metadata/_edit_use_anchors_ = true
[node name="add_new" type="Button" parent="."]
unique_name_in_owner = true
layout_mode = 0
offset_left = 1600.0
offset_top = 192.0
offset_right = 1856.0
offset_bottom = 256.0
text = "Add list"
[node name="categories" type="OptionButton" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.63600004
anchor_top = 0.2
anchor_right = 0.63600004
anchor_bottom = 0.2
offset_left = 0.76794434
offset_right = 256.76794
offset_bottom = 64.0
item_count = 1
popup/item_0/id = 0
metadata/_edit_use_anchors_ = true
[connection signal="text_changed" from="item" to="." method="_on_item_text_changed"]
[connection signal="item_selected" from="modules_list" to="." method="_on_modules_list_item_selected"]
[connection signal="focus_exited" from="add_new_select" to="." method="_on_add_new_select_focus_exited"]
[connection signal="item_selected" from="add_new_select" to="." method="_on_add_new_item_selected"]
[connection signal="item_selected" from="module" to="." method="_on_module_item_selected"]
[connection signal="button_up" from="add_new" to="." method="_on_add_new_button_up"]
[connection signal="item_selected" from="categories" to="." method="_on_categories_item_selected"]