-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop differentiating between attribute types (#692)
- Loading branch information
Showing
16 changed files
with
162 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
extends VBoxContainer | ||
|
||
const TransformField = preload("res://src/ui_elements/transform_field.tscn") | ||
const NumberField = preload("res://src/ui_elements/number_field.tscn") | ||
const NumberSlider = preload("res://src/ui_elements/number_field_with_slider.tscn") | ||
const ColorField = preload("res://src/ui_elements/color_field.tscn") | ||
const EnumField = preload("res://src/ui_elements/enum_field.tscn") | ||
|
||
@onready var attribute_container: HFlowContainer = $AttributeContainer | ||
@onready var path_field: VBoxContainer = $PathField | ||
|
||
var tag: Tag | ||
var tid: PackedInt32Array | ||
|
||
func _ready() -> void: | ||
path_field.attribute_name = "d" | ||
path_field.set_attribute(tag.attributes.d) | ||
for attribute_key in tag.attributes: | ||
if attribute_key == "d": | ||
continue | ||
var attribute: Attribute = tag.attributes[attribute_key] | ||
var input_field: Control | ||
if attribute is AttributeTransform: | ||
input_field = TransformField.instantiate() | ||
elif attribute is AttributeNumeric: | ||
if is_inf(attribute.max_value): | ||
input_field = NumberField.instantiate() | ||
if not is_inf(attribute.min_value): | ||
input_field.allow_lower = false | ||
input_field.min_value = attribute.min_value | ||
else: | ||
input_field = NumberSlider.instantiate() | ||
input_field.allow_lower = false | ||
input_field.allow_higher = false | ||
input_field.min_value = attribute.min_value | ||
input_field.max_value = attribute.max_value | ||
input_field.slider_step = 0.01 | ||
elif attribute is AttributeColor: | ||
input_field = ColorField.instantiate() | ||
elif attribute is AttributeEnum: | ||
input_field = EnumField.instantiate() | ||
input_field.attribute = attribute | ||
input_field.attribute_name = attribute_key | ||
input_field.focused.connect(Indications.normal_select.bind(tid)) | ||
attribute_container.add_child(input_field) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://ntom8irbw0d5"] | ||
|
||
[ext_resource type="Script" path="res://src/ui_elements/tag_content_path.gd" id="1_t5x4b"] | ||
[ext_resource type="PackedScene" uid="uid://dqy5lv33sy5r7" path="res://src/ui_elements/path_field.tscn" id="1_vf17i"] | ||
|
||
[node name="TagContentPath" type="VBoxContainer"] | ||
offset_right = 40.0 | ||
offset_bottom = 40.0 | ||
script = ExtResource("1_t5x4b") | ||
|
||
[node name="AttributeContainer" type="HFlowContainer" parent="."] | ||
layout_mode = 2 | ||
|
||
[node name="PathField" parent="." instance=ExtResource("1_vf17i")] | ||
layout_mode = 2 | ||
size_flags_horizontal = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,41 @@ | ||
extends VBoxContainer | ||
|
||
const UnknownField = preload("res://src/ui_elements/unknown_field.tscn") | ||
const TransformField = preload("res://src/ui_elements/transform_field.tscn") | ||
const NumberField = preload("res://src/ui_elements/number_field.tscn") | ||
const NumberSlider = preload("res://src/ui_elements/number_field_with_slider.tscn") | ||
const ColorField = preload("res://src/ui_elements/color_field.tscn") | ||
const PathField = preload("res://src/ui_elements/path_field.tscn") | ||
const EnumField = preload("res://src/ui_elements/enum_field.tscn") | ||
|
||
var unknown_container: HFlowContainer # Only created if there are unknown attributes. | ||
@onready var paint_container: FlowContainer = $PaintAttributes | ||
@onready var shape_container: FlowContainer = $ShapeAttributes | ||
@onready var attribute_container: HFlowContainer = $AttributeContainer | ||
|
||
var tag: Tag | ||
var tid: PackedInt32Array | ||
|
||
func _ready() -> void: | ||
# Fill up the containers. Start with unknown attributes, if there are any. | ||
if not tag.unknown_attributes.is_empty(): | ||
unknown_container = HFlowContainer.new() | ||
add_child(unknown_container) | ||
move_child(unknown_container, 0) | ||
for attribute in tag.unknown_attributes: | ||
var input_field := UnknownField.instantiate() | ||
input_field.attribute = attribute | ||
input_field.attribute_name = attribute.name | ||
unknown_container.add_child(input_field) | ||
# Continue with supported attributes. | ||
for attribute_key in tag.attributes: | ||
var attribute: Attribute = tag.attributes[attribute_key] | ||
var input_field: Control | ||
if attribute is AttributeTransform: | ||
input_field = TransformField.instantiate() | ||
elif attribute is AttributeNumeric: | ||
match attribute.mode: | ||
AttributeNumeric.Mode.FLOAT: | ||
input_field = NumberField.instantiate() | ||
AttributeNumeric.Mode.UFLOAT: | ||
input_field = NumberField.instantiate() | ||
if is_inf(attribute.max_value): | ||
input_field = NumberField.instantiate() | ||
if not is_inf(attribute.min_value): | ||
input_field.allow_lower = false | ||
AttributeNumeric.Mode.NFLOAT: | ||
input_field = NumberSlider.instantiate() | ||
input_field.allow_lower = false | ||
input_field.allow_higher = false | ||
input_field.slider_step = 0.01 | ||
input_field.min_value = attribute.min_value | ||
else: | ||
input_field = NumberSlider.instantiate() | ||
input_field.allow_lower = false | ||
input_field.allow_higher = false | ||
input_field.min_value = attribute.min_value | ||
input_field.max_value = attribute.max_value | ||
input_field.slider_step = 0.01 | ||
elif attribute is AttributeColor: | ||
input_field = ColorField.instantiate() | ||
elif attribute is AttributePath: | ||
input_field = PathField.instantiate() | ||
elif attribute is AttributeEnum: | ||
input_field = EnumField.instantiate() | ||
input_field.attribute = attribute | ||
input_field.attribute_name = attribute_key | ||
input_field.focused.connect(Indications.normal_select.bind(tid)) | ||
# Add the attribute to its corresponding container. | ||
if attribute_key in tag.known_shape_attributes: | ||
shape_container.add_child(input_field) | ||
elif attribute_key in tag.known_inheritable_attributes: | ||
paint_container.add_child(input_field) | ||
attribute_container.add_child(input_field) |
Oops, something went wrong.