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/editor/importers/aseprite/docks/aseprite_importer_inspector_dock_room.gd b/addons/popochiu/editor/importers/aseprite/docks/aseprite_importer_inspector_dock_room.gd index 7b1576a0..52df8ba5 100644 --- a/addons/popochiu/editor/importers/aseprite/docks/aseprite_importer_inspector_dock_room.gd +++ b/addons/popochiu/editor/importers/aseprite/docks/aseprite_importer_inspector_dock_room.gd @@ -86,25 +86,6 @@ func _create_prop(name: String, is_clickable: bool = true, is_visible: bool = tr func _save_prop(prop: PopochiuProp): var packed_scene: PackedScene = PackedScene.new() - - # FIXME - # IMPROVE This function contains a workaround for Godot's GH-81982 - # this is probably not needed if they fix an unwanted behavior in - # Godot 4.1. See comments below to get rid of the WA as soon as possible. - - # Working around a Godot 4.1 problem with not-owned children - # See: - # - https://github.com/godotengine/godot/issues/81982 - # - https://ask.godotengine.org/35684/packedscene-errore-is_a_parent_of-pnode-is-true - var not_owned_children = [] - for child in prop.get_children(): - if child.owner == prop: continue - # This node is not owned by the prop - not_owned_children.append(child) - # Unparent the offending node - child.get_parent().remove_child(child) - - # Saving the prop in a sane way packed_scene.pack(prop) if ResourceSaver.save(packed_scene, prop.scene_file_path) != OK: push_error( @@ -112,13 +93,4 @@ func _save_prop(prop: PopochiuProp): [prop.name, prop.scene_file_path] ) return ResultCodes.ERR_CANT_SAVE_OBJ_SCENE - - # Working around a Godot 4.1 problem with not-owned children - # See: - # - https://github.com/godotengine/godot/issues/81982 - # - https://ask.godotengine.org/35684/packedscene-errore-is_a_parent_of-pnode-is-true - for child in not_owned_children: - # Unparent the offending node - prop.add_child(child) - return ResultCodes.SUCCESS 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 00000000..30f4a9db Binary files /dev/null and b/addons/popochiu/icons/interaction_polygon.png differ 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 00000000..8024404e Binary files /dev/null and b/popochiu/sources/aseprite/room_exterior.aseprite differ