diff --git a/scenes/game_elements/props/collectible_item/collectible_item.tscn b/scenes/game_elements/props/collectible_item/collectible_item.tscn index 815230f0e2..4581dcd741 100644 --- a/scenes/game_elements/props/collectible_item/collectible_item.tscn +++ b/scenes/game_elements/props/collectible_item/collectible_item.tscn @@ -311,7 +311,7 @@ metadata/_custom_type_script = "uid://du8wfijr35r35" [node name="CollisionShape2D" type="CollisionShape2D" parent="InteractArea" unique_id=1121983883] shape = SubResource("CircleShape2D_ghwae") -debug_color = Color(0.600391, 0.54335, 0, 0.42) +debug_color = Color(0.6, 0.545, 0, 0.42) [node name="Marker" type="Marker2D" parent="InteractArea" unique_id=1961850851] position = Vector2(0, -48) diff --git a/scenes/game_elements/props/health_item/components/health_item.png b/scenes/game_elements/props/health_item/components/health_item.png new file mode 100644 index 0000000000..0f11215716 --- /dev/null +++ b/scenes/game_elements/props/health_item/components/health_item.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3f92a4ace61c9d55ed6336311c32d57f6c32855a3e75f820a9d655fbbbcc253 +size 15951 diff --git a/scenes/game_elements/props/health_item/components/health_item.png.import b/scenes/game_elements/props/health_item/components/health_item.png.import new file mode 100644 index 0000000000..374d3b3f1d --- /dev/null +++ b/scenes/game_elements/props/health_item/components/health_item.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b8mjjvpetr2sx" +path="res://.godot/imported/health_item.png-ffcb4d6c1ce83d09f66b82c207b78406.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/game_elements/props/health_item/components/health_item.png" +dest_files=["res://.godot/imported/health_item.png-ffcb4d6c1ce83d09f66b82c207b78406.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/scenes/game_elements/props/health_item/components/health_item.tres b/scenes/game_elements/props/health_item/components/health_item.tres new file mode 100644 index 0000000000..e7ebd873d7 --- /dev/null +++ b/scenes/game_elements/props/health_item/components/health_item.tres @@ -0,0 +1,88 @@ +[gd_resource type="SpriteFrames" format=3 uid="uid://xuw3tderjceg"] + +[ext_resource type="Texture2D" uid="uid://b8mjjvpetr2sx" path="res://scenes/game_elements/props/health_item/components/health_item.png" id="1_qtkly"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_as7yo"] +atlas = ExtResource("1_qtkly") +region = Rect2(0, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_fremn"] +atlas = ExtResource("1_qtkly") +region = Rect2(64, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0su3u"] +atlas = ExtResource("1_qtkly") +region = Rect2(128, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_xcv83"] +atlas = ExtResource("1_qtkly") +region = Rect2(0, 64, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8um1a"] +atlas = ExtResource("1_qtkly") +region = Rect2(64, 64, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_eob1k"] +atlas = ExtResource("1_qtkly") +region = Rect2(128, 64, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_84oik"] +atlas = ExtResource("1_qtkly") +region = Rect2(0, 128, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7cpmn"] +atlas = ExtResource("1_qtkly") +region = Rect2(64, 128, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gvmf1"] +atlas = ExtResource("1_qtkly") +region = Rect2(128, 128, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rq52m"] +atlas = ExtResource("1_qtkly") +region = Rect2(0, 192, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dy20p"] +atlas = ExtResource("1_qtkly") +region = Rect2(64, 192, 64, 64) + +[resource] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_as7yo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_fremn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0su3u") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_xcv83") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8um1a") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_eob1k") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_84oik") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7cpmn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gvmf1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rq52m") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dy20p") +}], +"loop": 1, +"name": &"default", +"speed": 10.0 +}] diff --git a/scenes/globals/mouse_manager/mouse_manager.gd b/scenes/globals/mouse_manager/mouse_manager.gd index dc37b2e319..5293636028 100644 --- a/scenes/globals/mouse_manager/mouse_manager.gd +++ b/scenes/globals/mouse_manager/mouse_manager.gd @@ -7,6 +7,9 @@ signal mode_changed const MOUSE_CURSOR_DEFAULT = preload("uid://cee2juvnxco6c") const MOUSE_CURSOR_CROSS = preload("uid://bx11wyx7unc4q") +## Conteo de referencias para controlar cuándo está permitida la interacción con ratón. +var _holds: int = 0 + @onready var hide_timer: Timer = %HideTimer @@ -15,25 +18,66 @@ func _ready() -> void: Input.set_custom_mouse_cursor(MOUSE_CURSOR_CROSS, Input.CURSOR_CROSS, Vector2(32, 32)) Input.set_default_cursor_shape(Input.CURSOR_CROSS) + # El cursor comienza oculto hasta que un sistema solicite un hold y se mueva el ratón. + Input.mouse_mode = Input.MOUSE_MODE_HIDDEN + DialogueManager.dialogue_started.connect(_on_dialogue_started) DialogueManager.dialogue_ended.connect(_on_dialogue_ended) +## Registra una solicitud para habilitar la interacción con el ratón. +func hold() -> void: + _holds += 1 + + +## Libera una solicitud previa de interacción con el ratón. +func release() -> void: + _holds = maxi(0, _holds - 1) + if _holds == 0: + _hide_mouse() + + func _input(event: InputEvent) -> void: if event is InputEventMouseMotion: + if _holds > 0: + _show_mouse() + elif _is_keyboard_or_controller_event(event): + _hide_mouse() + + +func _is_keyboard_or_controller_event(event: InputEvent) -> bool: + if event is InputEventKey and event.is_pressed(): + return true + if event is InputEventJoypadButton and event.is_pressed(): + return true + if event is InputEventJoypadMotion and absf(event.axis_value) > 0.5: + return true + return false + + +func _show_mouse() -> void: + if Input.mouse_mode != Input.MOUSE_MODE_VISIBLE: Input.mouse_mode = Input.MOUSE_MODE_VISIBLE mode_changed.emit() - hide_timer.start() + hide_timer.start() + + +func _hide_mouse() -> void: + hide_timer.stop() + if Input.mouse_mode != Input.MOUSE_MODE_HIDDEN: + Input.mouse_mode = Input.MOUSE_MODE_HIDDEN + mode_changed.emit() func _on_hide_timer_timeout() -> void: - Input.mouse_mode = Input.MOUSE_MODE_HIDDEN - mode_changed.emit() + _hide_mouse() func _on_dialogue_started(_resource: DialogueResource) -> void: Input.set_default_cursor_shape(Input.CURSOR_ARROW) + hold() func _on_dialogue_ended(_resource: DialogueResource) -> void: Input.set_default_cursor_shape(Input.CURSOR_CROSS) + release() diff --git a/scenes/globals/mouse_manager/mouse_manager.tscn b/scenes/globals/mouse_manager/mouse_manager.tscn index 457ffc5ef2..5b7ed5cc76 100644 --- a/scenes/globals/mouse_manager/mouse_manager.tscn +++ b/scenes/globals/mouse_manager/mouse_manager.tscn @@ -11,6 +11,5 @@ script = ExtResource("1_u8i10") unique_name_in_owner = true wait_time = 3.0 one_shot = true -autostart = true [connection signal="timeout" from="HideTimer" to="." method="_on_hide_timer_timeout"] diff --git a/scenes/globals/pause/pause_overlay.gd b/scenes/globals/pause/pause_overlay.gd index ac67f74dbc..96c0222cd7 100644 --- a/scenes/globals/pause/pause_overlay.gd +++ b/scenes/globals/pause/pause_overlay.gd @@ -34,6 +34,10 @@ func toggle_pause() -> void: get_tree().paused = new_state Input.set_default_cursor_shape(Input.CURSOR_ARROW if new_state else Input.CURSOR_CROSS) + if new_state: + MouseManager.hold() + else: + MouseManager.release() if new_state: if not GameState.quest: diff --git a/scenes/menus/title/components/title_screen.gd b/scenes/menus/title/components/title_screen.gd index 7dfe7e4fc0..7425b2d499 100644 --- a/scenes/menus/title/components/title_screen.gd +++ b/scenes/menus/title/components/title_screen.gd @@ -9,6 +9,16 @@ var opening_quest: Quest @onready var credits: Control = %Credits +func _enter_tree() -> void: + MouseManager.hold() + Input.set_default_cursor_shape(Input.CURSOR_ARROW) + + +func _exit_tree() -> void: + MouseManager.release() + Input.set_default_cursor_shape(Input.CURSOR_CROSS) + + func _ready() -> void: opening_quest = load( ThreadbareProjectSettings.get_setting(ThreadbareProjectSettings.OPENING_QUEST)