Skip to content

Commit

Permalink
Hotfix crash on paths (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
MewPurPur authored Nov 27, 2023
1 parent d0cc8b9 commit 3f92ce6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/ui_elements/CustomSpacedHBoxContainer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
class_name CustomSpacedHBoxContainer extends Container

# Array for the spacing between elements.
var _spacing_array: Array[int]
var _spacing_array: Array # Array[int]

func _ready() -> void:
sort_children.connect(_sort_children)

func set_spacing_array(new_arr: Array[int]) -> void:
func set_spacing_array(new_arr: Array) -> void:
_spacing_array = new_arr
queue_sort()

Expand Down
18 changes: 9 additions & 9 deletions src/ui_elements/path_command_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ var fields: Array[Control] = []

func update_type() -> void:
cmd_char = path_command.command_char
var command_type := cmd_char.to_upper()
var cmd_type := cmd_char.to_upper()
fields.clear()
setup_relative_button()

fields_container.set_spacing_array(spacing_dict[command_type])
var spacing: Array = spacing_dict[cmd_type] if cmd_type in spacing_dict else []
fields_container.set_spacing_array(spacing)

# Instantiate the input fields.
if command_type == "A":
if cmd_type == "A":
var field_rx: BetterLineEdit = add_number_field()
var field_ry: BetterLineEdit = add_number_field()
var field_rot: BetterLineEdit = add_number_field()
Expand Down Expand Up @@ -71,7 +72,7 @@ func update_type() -> void:
fields.append(field_rot)
fields.append(field_large_arc_flag)
fields.append(field_sweep_flag)
if command_type == "Q" or command_type == "C":
if cmd_type == "Q" or cmd_type == "C":
var field_x1: BetterLineEdit = add_number_field()
var field_y1: BetterLineEdit = add_number_field()
field_x1.set_value(path_command.x1)
Expand All @@ -82,7 +83,7 @@ func update_type() -> void:
field_y1.value_changed.connect(update_value.bind(&"y1"))
fields.append(field_x1)
fields.append(field_y1)
if command_type == "C" or command_type == "S":
if cmd_type == "C" or cmd_type == "S":
var field_x2: BetterLineEdit = add_number_field()
var field_y2: BetterLineEdit = add_number_field()
field_x2.set_value(path_command.x2)
Expand All @@ -93,14 +94,14 @@ func update_type() -> void:
field_y2.value_changed.connect(update_value.bind(&"y2"))
fields.append(field_x2)
fields.append(field_y2)
if command_type != "Z":
if command_type == "H":
if cmd_type != "Z":
if cmd_type == "H":
var field_x: BetterLineEdit = add_number_field()
field_x.set_value(path_command.x)
field_x.tooltip_text = "x"
field_x.value_changed.connect(update_value.bind(&"x"))
fields.append(field_x)
elif command_type == "V":
elif cmd_type == "V":
var field_y: BetterLineEdit = add_number_field()
field_y.set_value(path_command.y)
field_y.tooltip_text ="y"
Expand Down Expand Up @@ -207,7 +208,6 @@ func _ready() -> void:
Indications.selection_changed.connect(determine_selection_highlight)
Indications.hover_changed.connect(determine_selection_highlight)
determine_selection_highlight()
more_button.pressed.connect(open_actions)


# Helpers
Expand Down
1 change: 1 addition & 0 deletions src/ui_elements/path_command_editor.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ icon = ExtResource("3_a76tm")
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
[connection signal="pressed" from="HBox/RelativeButton" to="HBox" method="_on_relative_button_pressed"]
[connection signal="pressed" from="HBox/MoreButton" to="." method="open_actions"]
20 changes: 13 additions & 7 deletions src/ui_elements/unknown_field.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ extends AttributeEditor

@onready var line_edit: BetterLineEdit = $LineEdit

signal value_changed(new_value: String)
signal value_changed(new_value: String, update_type: UpdateType)
var _value: String # Must not be updated directly.

func set_value(new_value: String, emit_value_changed := true):
if _value != new_value:
func set_value(new_value: String, update_type := UpdateType.REGULAR):
if _value != new_value or update_type == UpdateType.FINAL:
_value = new_value
if emit_value_changed:
value_changed.emit(new_value)
if update_type != UpdateType.NO_SIGNAL:
value_changed.emit(new_value, update_type)

func get_value() -> String:
return _value
Expand All @@ -24,10 +24,16 @@ func _ready() -> void:
line_edit.text = get_value()
line_edit.tooltip_text = attribute_name + "\n(" + tr(&"#unknown_tooltip") + ")"

func _on_value_changed(new_value: String) -> void:
func _on_value_changed(new_value: String, update_type: UpdateType) -> void:
line_edit.text = new_value
if attribute != null:
attribute.set_value(new_value)
match update_type:
UpdateType.INTERMEDIATE:
attribute.set_value(new_value, Attribute.SyncMode.INTERMEDIATE)
UpdateType.FINAL:
attribute.set_value(new_value, Attribute.SyncMode.FINAL)
_:
attribute.set_value(new_value)


func _on_text_submitted(new_text: String) -> void:
Expand Down

0 comments on commit 3f92ce6

Please sign in to comment.