From 34f080e03e29c33eda5394619cd2b144f6adcf2a Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 31 Dec 2021 08:08:02 +0100 Subject: [PATCH] The ui will now reflect axis constaint state. --- .../addons/mesh_data_resource_editor/MDIEd.gd | 39 ++++++++++++++++--- .../mesh_data_resource_editor/MDIEd.tscn | 3 ++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/game/addons/mesh_data_resource_editor/MDIEd.gd b/game/addons/mesh_data_resource_editor/MDIEd.gd index d94b90d3..3b0ad928 100644 --- a/game/addons/mesh_data_resource_editor/MDIEd.gd +++ b/game/addons/mesh_data_resource_editor/MDIEd.gd @@ -29,14 +29,41 @@ func _unhandled_key_input(event : InputEventKey) -> void: #rotate set_edit_mode_rotate() elif event.scancode == KEY_X: - if plugin: - plugin.set_axis_x(event.pressed) + set_axis_x(!get_axis_x()) elif event.scancode == KEY_Y: - if plugin: - plugin.set_axis_y(event.pressed) + set_axis_y(!get_axis_y()) elif event.scancode == KEY_Z: - if plugin: - plugin.set_axis_z(event.pressed) + set_axis_z(!get_axis_z()) + +func get_axis_x() -> bool: + return $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisX.pressed + +func get_axis_y() -> bool: + return $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisY.pressed + +func get_axis_z() -> bool: + return $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisZ.pressed + +func set_axis_x(on : bool) -> void: + $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisX.pressed = on + +func set_axis_y(on : bool) -> void: + $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisY.pressed = on + +func set_axis_z(on : bool) -> void: + $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisZ.pressed = on + +func on_axis_x_toggled(on : bool) -> void: + if plugin: + plugin.set_axis_x(on) + +func on_axis_y_toggled(on : bool) -> void: + if plugin: + plugin.set_axis_y(on) + +func on_axis_z_toggled(on : bool) -> void: + if plugin: + plugin.set_axis_z(on) func set_edit_mode_translate() -> void: $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer/Translate.pressed = true diff --git a/game/addons/mesh_data_resource_editor/MDIEd.tscn b/game/addons/mesh_data_resource_editor/MDIEd.tscn index be8ac561..f13104b5 100644 --- a/game/addons/mesh_data_resource_editor/MDIEd.tscn +++ b/game/addons/mesh_data_resource_editor/MDIEd.tscn @@ -284,6 +284,9 @@ script = ExtResource( 3 ) [connection signal="toggled" from="VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer/Translate" to="." method="on_edit_mode_translate_toggled"] [connection signal="toggled" from="VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer/Rotate" to="." method="on_edit_mode_rotate_toggled"] [connection signal="toggled" from="VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer/Scale" to="." method="on_edit_mode_scale_toggled"] +[connection signal="toggled" from="VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisX" to="." method="on_axis_x_toggled"] +[connection signal="toggled" from="VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisY" to="." method="on_axis_y_toggled"] +[connection signal="toggled" from="VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisZ" to="." method="on_axis_z_toggled"] [connection signal="pressed" from="VBoxContainer/Operations/Operations/Extrude" to="." method="_on_Extrude_pressed"] [connection signal="pressed" from="VBoxContainer/Operations/Operations/UnwrapButton" to="." method="_on_UnwrapButton_pressed"] [connection signal="pressed" from="VBoxContainer/Add/Add/AddBox" to="." method="_on_AddBox_pressed"]