Cleaning and commenting
This commit is contained in:
parent
3f817ae4b5
commit
5193aabb41
2 changed files with 8 additions and 39 deletions
14
traits.gd
14
traits.gd
|
@ -35,14 +35,16 @@ func build_traits() -> void:
|
|||
var list_amount: int = amount
|
||||
var pinned: Array = []
|
||||
|
||||
# First, clear the box for non-pinned traits
|
||||
# Keep track of pinned content
|
||||
|
||||
for child in traits_list.get_children():
|
||||
for sub_child in child.get_children():
|
||||
if sub_child is CheckBox:
|
||||
if sub_child.button_pressed:
|
||||
list_amount -= 1
|
||||
pinned.append([child.get_index(), child])
|
||||
|
||||
|
||||
# Then clear the Hbox for non-pinned traits
|
||||
for child in traits_list.get_children():
|
||||
for sub_child in child.get_children():
|
||||
if sub_child is CheckBox:
|
||||
|
@ -52,24 +54,22 @@ func build_traits() -> void:
|
|||
child.queue_free()
|
||||
|
||||
|
||||
# generate the amount of traits needed
|
||||
# Generate the amount of traits needed and store in an array
|
||||
var char_traits: Dictionary = generate_traits(traits, seed, list_amount)
|
||||
var char_traits_list: Array = []
|
||||
|
||||
for key in char_traits.keys():
|
||||
char_traits_list.append([key, char_traits[key][0], char_traits[key][1]])
|
||||
|
||||
# Insert pinned in their position
|
||||
for pin in pinned:
|
||||
char_traits_list.insert(pin[0], pin[1])
|
||||
|
||||
# Generate a line for each trait
|
||||
for traitline in range(amount):
|
||||
print("At index: ", traitline, " found: ", char_traits_list[traitline])
|
||||
if char_traits_list[traitline] is HBoxContainer:
|
||||
print("Je confirme")
|
||||
print("Parent: ", char_traits_list[traitline].get_parent())
|
||||
# For pinned content
|
||||
traits_list.add_child(char_traits_list[traitline])
|
||||
#char_traits_list[traitline].reparent(traits_list)
|
||||
else:
|
||||
# Create horizontal container for elements
|
||||
var container = HBoxContainer.new()
|
||||
|
|
33
traits.tscn
33
traits.tscn
|
@ -1,7 +1,6 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cl5wswke7jxpi"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cl5wswke7jxpi"]
|
||||
|
||||
[ext_resource type="Script" path="res://traits.gd" id="1_6h04s"]
|
||||
[ext_resource type="Texture2D" uid="uid://cafw5ytvxgep4" path="res://textures/arrowDown.png" id="2_iexdr"]
|
||||
|
||||
[node name="Traits" type="Control"]
|
||||
layout_mode = 3
|
||||
|
@ -18,33 +17,3 @@ script = ExtResource("1_6h04s")
|
|||
layout_mode = 0
|
||||
offset_right = 232.0
|
||||
offset_bottom = 119.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Traits_list"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CheckBox" type="CheckBox" parent="Traits_list/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Traits_list/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "My text"
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Traits_list/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("2_iexdr")
|
||||
expand_mode = 3
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="Traits_list"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CheckBox" type="CheckBox" parent="Traits_list/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Traits_list/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "My text"
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Traits_list/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("2_iexdr")
|
||||
expand_mode = 3
|
||||
|
|
Loading…
Reference in a new issue