From 6a3d97b8fc39560fa77b2f0bbe2ffd4792e23958 Mon Sep 17 00:00:00 2001 From: Paolo Pustorino Date: Sun, 3 Dec 2023 23:09:23 +0100 Subject: [PATCH] refs #37: InteractionPolygons for props and hotspots have been moved in the scene and an edit button has been exposed in the toolbar to edit them. --- .../factories/factory_popochiu_hostspot.gd | 6 ---- .../editor/factories/factory_popochiu_prop.gd | 6 ---- .../editor/helpers/popochiu_types_helper.gd | 2 +- .../objects/clickable/popochiu_clickable.gd | 2 ++ .../objects/hotspot/popochiu_hotspot.tscn | 5 ++- .../engine/objects/prop/popochiu_prop.tscn | 3 ++ addons/popochiu/icons/interaction_polygon.png | Bin 0 -> 160 bytes .../icons/interaction_polygon.png.import | 34 ++++++++++++++++++ addons/popochiu/popochiu_plugin.gd | 30 ++++++++++++++-- .../sources/aseprite/room_exterior.aseprite | Bin 0 -> 9508 bytes 10 files changed, 72 insertions(+), 16 deletions(-) create mode 100644 addons/popochiu/icons/interaction_polygon.png create mode 100644 addons/popochiu/icons/interaction_polygon.png.import create mode 100644 popochiu/sources/aseprite/room_exterior.aseprite diff --git a/addons/popochiu/editor/factories/factory_popochiu_hostspot.gd b/addons/popochiu/editor/factories/factory_popochiu_hostspot.gd index cc399064..4f4294c7 100644 --- a/addons/popochiu/editor/factories/factory_popochiu_hostspot.gd +++ b/addons/popochiu/editor/factories/factory_popochiu_hostspot.gd @@ -37,12 +37,6 @@ func create(obj_name: String, room: PopochiuRoom) -> int: # Save the hostspot scene (.tscn) and put it into _scene class property result_code = _save_obj_scene(new_obj) if result_code != ResultCodes.SUCCESS: return result_code - - # Create a collision polygon as a child in the room scene - var collision := CollisionPolygon2D.new() - collision.name = 'InteractionPolygon' - collision.modulate = Color.BLUE - _add_visible_child(collision) # ▓▓▓ END OF LOCAL CODE ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ # Add the object to its room diff --git a/addons/popochiu/editor/factories/factory_popochiu_prop.gd b/addons/popochiu/editor/factories/factory_popochiu_prop.gd index 42168887..5b010299 100644 --- a/addons/popochiu/editor/factories/factory_popochiu_prop.gd +++ b/addons/popochiu/editor/factories/factory_popochiu_prop.gd @@ -46,12 +46,6 @@ func create(obj_name: String, room: PopochiuRoom, is_interactive:bool = false, i # Save the scene (.tscn) and put it into _scene class property result_code = _save_obj_scene(new_obj) if result_code != ResultCodes.SUCCESS: return result_code - - # Create a collision polygon as a child in the room scene - var collision := CollisionPolygon2D.new() - collision.name = 'InteractionPolygon' - _add_visible_child(collision) - # ▓▓▓ END OF LOCAL CODE ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ # Add the object to its room diff --git a/addons/popochiu/editor/helpers/popochiu_types_helper.gd b/addons/popochiu/editor/helpers/popochiu_types_helper.gd index a896aa8b..4be432f9 100644 --- a/addons/popochiu/editor/helpers/popochiu_types_helper.gd +++ b/addons/popochiu/editor/helpers/popochiu_types_helper.gd @@ -25,4 +25,4 @@ static func is_walkable_area(node: Node) -> bool: ## TODO: If and when #67 is ready, add static facade metods to create items ## so we can just pass this object as entry point for all operations -## on Popochiu objects \ No newline at end of file +## on Popochiu objects diff --git a/addons/popochiu/engine/objects/clickable/popochiu_clickable.gd b/addons/popochiu/engine/objects/clickable/popochiu_clickable.gd index 4d681132..4b36dbed 100644 --- a/addons/popochiu/engine/objects/clickable/popochiu_clickable.gd +++ b/addons/popochiu/engine/objects/clickable/popochiu_clickable.gd @@ -111,11 +111,13 @@ func _on_item_used(item: PopochiuInventoryItem) -> void: func hide_helpers() -> void: $BaselineHelper.hide() $WalkToHelper.hide() + $InteractionPolygon.hide() func show_helpers() -> void: $BaselineHelper.show() $WalkToHelper.show() + $InteractionPolygon.show() func disable() -> Callable: diff --git a/addons/popochiu/engine/objects/hotspot/popochiu_hotspot.tscn b/addons/popochiu/engine/objects/hotspot/popochiu_hotspot.tscn index d1b731eb..6dee2332 100644 --- a/addons/popochiu/engine/objects/hotspot/popochiu_hotspot.tscn +++ b/addons/popochiu/engine/objects/hotspot/popochiu_hotspot.tscn @@ -4,7 +4,6 @@ [node name="Hotspot" type="Area2D"] script = ExtResource("1") -walk_to_point = Vector2(0, 0) cursor = 1 [node name="BaselineHelper" type="Line2D" parent="."] @@ -19,3 +18,7 @@ offset_top = -2.5 offset_right = 2.5 offset_bottom = 2.5 color = Color(0, 1, 1, 1) + +[node name="InteractionPolygon" type="CollisionPolygon2D" parent="."] +modulate = Color(0, 0, 1, 1) +polygon = PackedVector2Array(-12, -12, 12, -12, 12, 12, -12, 12) diff --git a/addons/popochiu/engine/objects/prop/popochiu_prop.tscn b/addons/popochiu/engine/objects/prop/popochiu_prop.tscn index f89dfb0e..a4b467ad 100644 --- a/addons/popochiu/engine/objects/prop/popochiu_prop.tscn +++ b/addons/popochiu/engine/objects/prop/popochiu_prop.tscn @@ -18,6 +18,9 @@ offset_right = 2.5 offset_bottom = 2.5 color = Color(0, 1, 1, 1) +[node name="InteractionPolygon" type="CollisionPolygon2D" parent="."] +polygon = PackedVector2Array(-12, -12, 12, -12, 12, 12, -12, 12) + [node name="Sprite2D" type="Sprite2D" parent="."] texture_filter = 1 diff --git a/addons/popochiu/icons/interaction_polygon.png b/addons/popochiu/icons/interaction_polygon.png new file mode 100644 index 0000000000000000000000000000000000000000..30f4a9db9b7836ea14bb8efdfa1459d74704dbfb GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|qC8z3Lo9le z6Be*#m~8uTKO^Vke3`F0CxqOKxH^qe-hX^Nqv=SNTli_0HEJ;lR~iDDB|tz@LLqZ@ zV`JmNo0leO_-FVdQ&MBb@ E07;TI6951J literal 0 HcmV?d00001 diff --git a/addons/popochiu/icons/interaction_polygon.png.import b/addons/popochiu/icons/interaction_polygon.png.import new file mode 100644 index 00000000..68363e01 --- /dev/null +++ b/addons/popochiu/icons/interaction_polygon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cesndtvbchw7v" +path="res://.godot/imported/interaction_polygon.png-28f3d05312276a3121232981bf4f2bee.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/popochiu/icons/interaction_polygon.png" +dest_files=["res://.godot/imported/interaction_polygon.png-28f3d05312276a3121232981bf4f2bee.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/addons/popochiu/popochiu_plugin.gd b/addons/popochiu/popochiu_plugin.gd index 60623fc9..793d4b89 100644 --- a/addons/popochiu/popochiu_plugin.gd +++ b/addons/popochiu/popochiu_plugin.gd @@ -28,6 +28,7 @@ var _selected_node: Node = null var _vsep := VSeparator.new() var _btn_baseline := Button.new() var _btn_walk_to := Button.new() +var _btn_interaction_polygon := Button.new() var _types_helper: Resource = null var _tool_btn_stylebox :=\ _editor_interface.get_base_control().get_theme_stylebox("normal", "Button") @@ -341,9 +342,11 @@ func _check_nodes() -> void: _btn_baseline.show() _btn_walk_to.show() + _btn_interaction_polygon.show() else: _btn_baseline.hide() _btn_walk_to.hide() + _btn_interaction_polygon.hide() func _on_files_moved(old_file: String, new_file: String) -> void: @@ -374,9 +377,17 @@ func _create_container_buttons() -> void: _btn_walk_to.add_theme_stylebox_override('hover', _tool_btn_stylebox) _btn_walk_to.pressed.connect(_select_walk_to) + _btn_interaction_polygon.icon = preload('res://addons/popochiu/icons/interaction_polygon.png') + _btn_interaction_polygon.tooltip_text = 'Interaction Polygon' + _btn_interaction_polygon.toggle_mode = true + _btn_interaction_polygon.add_theme_stylebox_override('normal', _tool_btn_stylebox) + _btn_interaction_polygon.add_theme_stylebox_override('hover', _tool_btn_stylebox) + _btn_interaction_polygon.pressed.connect(_select_interaction_polygon) + hbox.add_child(_vsep) hbox.add_child(_btn_baseline) hbox.add_child(_btn_walk_to) + hbox.add_child(_btn_interaction_polygon) panl.add_child(hbox) @@ -384,7 +395,7 @@ func _create_container_buttons() -> void: EditorPlugin.CONTAINER_CANVAS_EDITOR_MENU, panl ) - + _vsep.hide() _btn_baseline.hide() _btn_walk_to.hide() @@ -393,6 +404,7 @@ func _create_container_buttons() -> void: func _select_walk_to() -> void: _btn_walk_to.set_pressed_no_signal(true) _btn_baseline.set_pressed_no_signal(false) + _btn_interaction_polygon.set_pressed_no_signal(false) _vsep.hide() if _types_helper.is_prop(_selected_node)\ @@ -403,8 +415,9 @@ func _select_walk_to() -> void: func _select_baseline() -> void: - _btn_baseline.set_pressed_no_signal(true) _btn_walk_to.set_pressed_no_signal(false) + _btn_baseline.set_pressed_no_signal(true) + _btn_interaction_polygon.set_pressed_no_signal(false) _vsep.show() if _types_helper.is_prop(_selected_node)\ @@ -414,6 +427,19 @@ func _select_baseline() -> void: _editor_interface.edit_node(_selected_node.get_node('../BaselineHelper')) +func _select_interaction_polygon() -> void: + _btn_walk_to.set_pressed_no_signal(false) + _btn_baseline.set_pressed_no_signal(false) + _btn_interaction_polygon.set_pressed_no_signal(true) + _vsep.hide() + + if _types_helper.is_prop(_selected_node)\ + or _types_helper.is_hotspot(_selected_node): + _editor_interface.edit_node(_selected_node.get_node('InteractionPolygon')) + else: + _editor_interface.edit_node(_selected_node.get_node('../InteractionPolygon')) + + func _move_to_project(id: int) -> void: # Move files and folders so developer can overwrite them if id == PopochiuResources.GI: diff --git a/popochiu/sources/aseprite/room_exterior.aseprite b/popochiu/sources/aseprite/room_exterior.aseprite new file mode 100644 index 0000000000000000000000000000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