From af95006827ec45c1662d6c73e95e4b2ee4edf867 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Mon, 29 Jan 2024 12:37:25 +0100 Subject: [PATCH 1/3] bug fixes --- content/entities/light/light.gd | 3 ++- content/entities/light/light.tscn | 2 -- content/system/house/align_reference.gd | 8 +++++++- content/system/house/align_reference.tscn | 5 +++-- content/system/house/house.gd | 3 +++ content/ui/menu/menu.gd | 6 ------ content/ui/menu/room/views/rooms.gd | 7 +++++-- content/ui/menu/settings/settings_menu.gd | 8 ++++++-- export_presets.cfg | 4 ++-- lib/events/event_key.gd | 2 +- 10 files changed, 29 insertions(+), 19 deletions(-) diff --git a/content/entities/light/light.gd b/content/entities/light/light.gd index 7535a73..11af630 100644 --- a/content/entities/light/light.gd +++ b/content/entities/light/light.gd @@ -26,7 +26,8 @@ func _ready(): set_state(stateInfo["state"] == "on") if stateInfo.has("attributes") && stateInfo["attributes"].has("effect_list") && stateInfo["attributes"]["effect_list"].size() > 0: - mode_label.text = stateInfo["attributes"]["effect"] + if stateInfo["attributes"].has("effect") && stateInfo["attributes"]["effect"] != null: + mode_label.text = stateInfo["attributes"]["effect"] mode_next.on_button_down.connect(func(): var index = stateInfo["attributes"]["effect_list"].find(stateInfo["attributes"]["effect"]) diff --git a/content/entities/light/light.tscn b/content/entities/light/light.tscn index 33f586e..45d9921 100644 --- a/content/entities/light/light.tscn +++ b/content/entities/light/light.tscn @@ -70,8 +70,6 @@ height = 0.005 [node name="Light" type="StaticBody3D" groups=["entity"]] collision_mask = 0 script = ExtResource("1_ykxy3") -color_off = null -color_on = null [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("SphereShape3D_ukj14") diff --git a/content/system/house/align_reference.gd b/content/system/house/align_reference.gd index 204d810..4773c5a 100644 --- a/content/system/house/align_reference.gd +++ b/content/system/house/align_reference.gd @@ -27,6 +27,9 @@ func _ready(): corner2.get_node("Movable").on_move.connect(func(position, rotation): edge.align_to_corners(corner1.global_position, corner2.global_position) + + corner2.look_at(corner1.global_position, Vector3.UP) + corner2.rotate(Vector3.UP, deg_to_rad(-90)) ) corner2.get_node("Movable").restrict_movement = func(new_position): @@ -40,7 +43,7 @@ func update_initial_positions(): edge.align_to_corners(corner1.global_position, corner2.global_position) marker.global_transform = House.body.transform -func get_new_transform(old_transform: Transform3D): +func get_new_transform(): marker.scale = Vector3(1, 1, 1) return marker.global_transform @@ -48,6 +51,9 @@ func update_align_reference(): corner1.global_position = Store.house.align_position1 corner2.global_position = Store.house.align_position2 + corner2.look_at(corner1.global_position, Vector3.UP) + corner2.rotate(Vector3.UP, deg_to_rad(-90)) + edge.align_to_corners(corner1.global_position, corner2.global_position) func update_store(): diff --git a/content/system/house/align_reference.tscn b/content/system/house/align_reference.tscn index 4521894..bd8f98d 100644 --- a/content/system/house/align_reference.tscn +++ b/content/system/house/align_reference.tscn @@ -4,7 +4,8 @@ [ext_resource type="PackedScene" uid="uid://brf6mm2gxj7y2" path="res://content/system/house/room/wall_corner.tscn" id="2_ppkie"] [ext_resource type="PackedScene" uid="uid://dlj5chj7ndgua" path="res://content/system/house/room/wall_edge.tscn" id="3_6o3xn"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="3_7ktdq"] -[ext_resource type="Material" uid="uid://dxyuncqxagt28" path="res://content/system/house/room/walls_mini.tres" id="4_jkpj4"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_64dod"] [sub_resource type="CylinderMesh" id="CylinderMesh_k2m3v"] top_radius = 0.001 @@ -26,7 +27,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0) [node name="MeshInstance3D" parent="Corner1/Corner2" index="1"] transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0) -material_override = ExtResource("4_jkpj4") +material_override = SubResource("StandardMaterial3D_64dod") mesh = SubResource("CylinderMesh_k2m3v") [node name="Movable" type="Node" parent="Corner1/Corner2"] diff --git a/content/system/house/house.gd b/content/system/house/house.gd index c02470c..d957a3b 100644 --- a/content/system/house/house.gd +++ b/content/system/house/house.gd @@ -210,11 +210,13 @@ func update_mini_view(): func edit_reference(): fixing_reference = false + align_reference.visible = true align_reference.disabled = false func fix_reference(): fixing_reference = true align_reference.disabled = false + align_reference.visible = true align_reference.update_initial_positions() func save_reference(): @@ -224,6 +226,7 @@ func save_reference(): align_reference.global_transform = align_transform align_reference.disabled = true + align_reference.visible = false align_reference.update_initial_positions() align_reference.update_store() diff --git a/content/ui/menu/menu.gd b/content/ui/menu/menu.gd index 6af6f86..90642d9 100644 --- a/content/ui/menu/menu.gd +++ b/content/ui/menu/menu.gd @@ -1,16 +1,10 @@ extends Node3D -const Proxy = preload("res://lib/utils/proxy.gd") const Notification = preload("res://content/ui/components/notification/notification.tscn") -@onready var menu_root = $AnimationContainer -@onready var content = $AnimationContainer/Content -@onready var nav = $AnimationContainer/Navigation @onready var animation_player = $AnimationPlayer @onready var notify_place = $AnimationContainer/NotifyPlace -var selected_nav = null - var show_menu := false: set(value): show_menu = value diff --git a/content/ui/menu/room/views/rooms.gd b/content/ui/menu/room/views/rooms.gd index 535fa4d..2ab4392 100644 --- a/content/ui/menu/room/views/rooms.gd +++ b/content/ui/menu/room/views/rooms.gd @@ -41,9 +41,12 @@ var edit_room = false: room_button.label = "edit" func _ready(): - Store.house.on_loaded.connect(func(): + if Store.house.is_loaded(): _generate_room_map() - ) + else: + Store.house.on_loaded.connect(func(): + _generate_room_map() + ) room_button.on_button_down.connect(func(): if selected_room == null: diff --git a/content/ui/menu/settings/settings_menu.gd b/content/ui/menu/settings/settings_menu.gd index 9ddc2a0..382245c 100644 --- a/content/ui/menu/settings/settings_menu.gd +++ b/content/ui/menu/settings/settings_menu.gd @@ -33,10 +33,14 @@ func _ready(): credits_instance.global_position = + label.to_global(label.position + Vector3(0.1, 0, -0.15)) ) - Store.settings.on_loaded.connect(func(): + if Store.settings.is_loaded(): input_url.text = Store.settings.url input_token.text = Store.settings.token - ) + else: + Store.settings.on_loaded.connect(func(): + input_url.text = Store.settings.url + input_token.text = Store.settings.token + ) button_connect.on_button_down.connect(func(): var url = input_url.text diff --git a/export_presets.cfg b/export_presets.cfg index a0d5431..3117478 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -248,8 +248,8 @@ architectures/armeabi-v7a=false architectures/arm64-v8a=true architectures/x86=false architectures/x86_64=false -version/code=8 -version/name="v0.2.1" +version/code=9 +version/name="v0.3.0" package/unique_name="de.nitwel.$genname" package/name="Immersive Home" package/signed=true diff --git a/lib/events/event_key.gd b/lib/events/event_key.gd index 9f6b535..6f5276f 100644 --- a/lib/events/event_key.gd +++ b/lib/events/event_key.gd @@ -12,7 +12,7 @@ static func key_to_string(key: Key, caps: bool = false, apply_to: String = "") - KEY_ASCIITILDE: apply_to += "~" KEY_SLASH: apply_to += "/" KEY_BACKSLASH: apply_to += "\\" - KEY_COLON: apply_to += ";" + KEY_COLON: apply_to += ":" KEY_COMMA: apply_to += "," KEY_PERIOD: apply_to += "." KEY_MINUS: apply_to += "-" From 584e2748c1bf4a1d21c1519303a776ef620bb0ba Mon Sep 17 00:00:00 2001 From: Nitwel Date: Mon, 29 Jan 2024 15:35:58 +0100 Subject: [PATCH 2/3] fix room setup --- content/system/house/house.gd | 21 ++++++++++++++++++--- content/system/house/room/states/edit.gd | 18 +++++++++--------- lib/stores/house.gd | 3 ++- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/content/system/house/house.gd b/content/system/house/house.gd index d957a3b..b4f8336 100644 --- a/content/system/house/house.gd +++ b/content/system/house/house.gd @@ -97,10 +97,16 @@ func delete_room(room_name): if editing_room == room: editing_room = null - room.get_parent().remove_child(room) room.queue_free() await room.tree_exited + var store_room = Store.house.get_room(room_name) + + if store_room != null: + Store.house.rooms.erase(store_room) + + Store.house.save_local() + func is_editiong(room_name): return editing_room != null && editing_room.name == room_name @@ -221,15 +227,24 @@ func fix_reference(): func save_reference(): if fixing_reference: + for room in get_rooms(0): + room.editable = true + var align_transform = align_reference.global_transform - transform = align_reference.get_new_transform(transform) + transform = align_reference.get_new_transform() align_reference.global_transform = align_transform + align_reference.update_store() + + for room in get_rooms(0): + room.editable = false + + save_all_entities() + align_reference.disabled = true align_reference.visible = false align_reference.update_initial_positions() - align_reference.update_store() Store.house.save_local() func save_all_entities(): diff --git a/content/system/house/room/states/edit.gd b/content/system/house/room/states/edit.gd index edb3c97..e17a000 100644 --- a/content/system/house/room/states/edit.gd +++ b/content/system/house/room/states/edit.gd @@ -19,13 +19,13 @@ func _on_enter(): var corners = room_store.corners if corners.size() > 0: - add_floor_corner(Vector3(corners[0].x, 0, corners[0].y)) - add_height_corner(Vector3(corners[0].x, 0, corners[0].y)) + add_floor_corner(room.to_local(Vector3(corners[0].x, 0, corners[0].y))) + add_height_corner(room.to_local(Vector3(corners[0].x, 0, corners[0].y))) room.room_ceiling.position.y = room_store.height - height_edge.align_to_corners(floor_corner.global_position, height_corner.global_position) + height_edge.align_to_corners(floor_corner.position, floor_corner.position + Vector3.UP * room.room_ceiling.position.y) for i in range(1, corners.size()): - add_corner(Vector3(corners[i].x, 0, corners[i].y)) + add_corner(room.to_local(Vector3(corners[i].x, 0, corners[i].y))) room.room_ceiling.get_node("CollisionShape3D").disabled = (floor_corner == null && height_corner == null) room.room_floor.get_node("CollisionShape3D").disabled = false @@ -164,7 +164,7 @@ func add_height_corner(position: Vector3): return room.room_ceiling.position.y = new_position.y - height_edge.align_to_corners(floor_corner.global_position, height_corner.global_position) + height_edge.align_to_corners(floor_corner.position, floor_corner.position + Vector3.UP * room.room_ceiling.position.y) ) @@ -266,15 +266,15 @@ func add_edge(from_pos: Vector3, to_pos: Vector3, index: int = -1): func update_store(): var store_room = Store.house.get_room(room.name) + if store_room == null: + return + var corners = [] for corner in room.wall_corners.get_children(): - corners.append(Vector2(corner.position.x, corner.position.z)) + corners.append(Vector2(corner.global_position.x, corner.global_position.z)) store_room.corners = corners store_room.height = room.room_ceiling.position.y - if corners.size() < 3: - House.body.delete_room(room.name) - Store.house.save_local() diff --git a/lib/stores/house.gd b/lib/stores/house.gd index d06f9a4..9726c65 100644 --- a/lib/stores/house.gd +++ b/lib/stores/house.gd @@ -21,7 +21,8 @@ func _init(): _save_path = "user://house.json" func clear(): - pass + rooms = [] + entities = [] func get_room(name): for room in rooms: From 8527b7b8b3a7c99ed626cbdbbf4803c964213219 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Mon, 29 Jan 2024 15:37:40 +0100 Subject: [PATCH 3/3] update version --- export_presets.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/export_presets.cfg b/export_presets.cfg index 3117478..468efad 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -248,8 +248,8 @@ architectures/armeabi-v7a=false architectures/arm64-v8a=true architectures/x86=false architectures/x86_64=false -version/code=9 -version/name="v0.3.0" +version/code=10 +version/name="v0.3.1" package/unique_name="de.nitwel.$genname" package/name="Immersive Home" package/signed=true