diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-11-21 21:38:49 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-11-21 21:39:07 +0200 |
| commit | 6824649c8961b8aa695b6be805401fa357a61793 (patch) | |
| tree | 0441c52355be55518cd74a08b363740d78a093df | |
| parent | 242dec6cb636be957fe1c13415762f1e204deef7 (diff) | |
Improve map
| -rw-r--r-- | docs/index.html | 2 | ||||
| -rw-r--r-- | docs/index.pck | bin | 2036644 -> 2037248 bytes | |||
| -rw-r--r-- | docs/index.service.worker.js | 2 | ||||
| -rw-r--r-- | map.gd | 17 | ||||
| -rw-r--r-- | map.tscn | 61 | ||||
| -rw-r--r-- | map_room.tscn | 12 | ||||
| -rw-r--r-- | project.godot | 5 | ||||
| -rw-r--r-- | top.gd | 14 | ||||
| -rw-r--r-- | top.tscn | 5 | ||||
| -rw-r--r-- | touch_screen_button.gd | 13 | ||||
| -rw-r--r-- | touch_screen_button.tscn | 7 | ||||
| -rw-r--r-- | touch_screen_ui.gd | 7 | ||||
| -rw-r--r-- | touch_screen_ui.gd.uid | 1 | ||||
| -rw-r--r-- | touch_screen_ui.tscn | 24 |
14 files changed, 92 insertions, 78 deletions
diff --git a/docs/index.html b/docs/index.html index 5d39e8b..be4cc3f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -112,7 +112,7 @@ body { <script src="index.js"></script> <script> -const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":true,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":2036644,"index.wasm":38034280},"focusCanvas":true,"gdextensionLibs":[],"godotPoolSize":4,"serviceWorker":"index.service.worker.js"}; +const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":true,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":2037248,"index.wasm":38034280},"focusCanvas":true,"gdextensionLibs":[],"godotPoolSize":4,"serviceWorker":"index.service.worker.js"}; const GODOT_THREADS_ENABLED = false; const engine = new Engine(GODOT_CONFIG); diff --git a/docs/index.pck b/docs/index.pck Binary files differindex e7bf4ba..8d160c3 100644 --- a/docs/index.pck +++ b/docs/index.pck diff --git a/docs/index.service.worker.js b/docs/index.service.worker.js index b82f376..0c5ac3d 100644 --- a/docs/index.service.worker.js +++ b/docs/index.service.worker.js @@ -4,7 +4,7 @@ // Incrementing CACHE_VERSION will kick off the install event and force // previously cached resources to be updated from the network. /** @type {string} */ -const CACHE_VERSION = '1763737689|4451920408'; +const CACHE_VERSION = '1763753940|13605624650'; /** @type {string} */ const CACHE_PREFIX = 'MobileMetroidvan-sw-cache-'; const CACHE_NAME = CACHE_PREFIX + CACHE_VERSION; @@ -10,17 +10,20 @@ func _ready(): func set_active_name(map_room_name: String): if active_map_room: active_map_room.unhighlight() - active_map_room = get_node_or_null(map_room_name) + active_map_room = get_node_or_null("Rooms/" + map_room_name) - if active_map_room: active_map_room.highlight() + if active_map_room: + active_map_room.highlight() + var pos = active_map_room.position + var size = get_viewport().get_visible_rect().size + var delta = Vector2(size.x / 2, size.y / 2) + $Rooms.position = -pos + delta - active_map_room.size / 2 + #$Rooms.position = -pos + Vector2(10, 10) func show_map(): visible = true - $UnpauseButton.mouse_filter = Control.MOUSE_FILTER_STOP + get_tree().call_group("ui_movement", "set_visible", false) func hide_map(): visible = false - $UnpauseButton.mouse_filter = Control.MOUSE_FILTER_IGNORE - -func _on_unpause_button_pressed() -> void: - Input.action_press("menu") + get_tree().call_group("ui_movement", "set_visible", true) @@ -1,56 +1,41 @@ -[gd_scene load_steps=4 format=3 uid="uid://cseqghymhiyqo"] +[gd_scene load_steps=3 format=3 uid="uid://cseqghymhiyqo"] [ext_resource type="Script" uid="uid://dh0b4xa4f8h1o" path="res://map.gd" id="1_wijl4"] [ext_resource type="PackedScene" uid="uid://clm2kocuhjqbb" path="res://map_room.tscn" id="2_e0an3"] -[ext_resource type="Texture2D" uid="uid://c1h4ev7ma1neg" path="res://assets/kenney_1-bit-input-prompts-pixel-16/Tiles (White)/tile_0200.png" id="3_e0an3"] [node name="Map" type="CanvasLayer"] process_mode = 3 script = ExtResource("1_wijl4") [node name="Bg" type="ColorRect" parent="."] +z_index = 1 offset_right = 192.0 offset_bottom = 108.0 mouse_filter = 2 color = Color(0, 0.019607844, 0.039215688, 0.81960785) -[node name="RoomTest1" parent="." instance=ExtResource("2_e0an3")] -offset_left = 84.0 -offset_top = 48.0 -offset_right = 92.0 -offset_bottom = 53.0 +[node name="Rooms" type="CanvasGroup" parent="."] +z_index = 3 -[node name="Line2D" type="Line2D" parent="RoomTest1"] -position = Vector2(7.275, 2.5) -points = PackedVector2Array(0.7251587, 0.15686035, 2.7251587, 0.15686035) -width = 1.0 +[node name="RoomTest1" parent="Rooms" instance=ExtResource("2_e0an3")] +offset_left = 63.0 +offset_top = 41.0 +offset_right = 79.0 +offset_bottom = 51.0 -[node name="Line2D2" type="Line2D" parent="RoomTest1"] -position = Vector2(3.2749996, 7.5) -points = PackedVector2Array(0.7251587, 0.15686035, 0.7249985, -2.5) -width = 1.0 +[node name="Line2D" type="Line2D" parent="Rooms/RoomTest1"] +z_index = -1 +points = PackedVector2Array(8, 19, 8, 5, 30, 5) +width = 2.0 -[node name="RoomTest3" parent="." instance=ExtResource("2_e0an3")] -offset_left = 84.0 -offset_top = 55.0 -offset_right = 92.0 -offset_bottom = 60.0 - -[node name="RoomTest2" parent="." instance=ExtResource("2_e0an3")] -offset_left = 94.0 -offset_top = 48.0 -offset_right = 102.0 -offset_bottom = 53.0 +[node name="RoomTest2" parent="Rooms" instance=ExtResource("2_e0an3")] +offset_left = 83.0 +offset_top = 41.0 +offset_right = 99.0 +offset_bottom = 51.0 -[node name="UnpauseButton" type="Button" parent="."] -offset_left = 188.0 -offset_top = 105.0 -offset_right = 212.0 -offset_bottom = 129.0 -rotation = 3.1415927 -mouse_default_cursor_shape = 2 -action_mode = 0 -icon = ExtResource("3_e0an3") -flat = true - -[connection signal="pressed" from="UnpauseButton" to="." method="_on_unpause_button_pressed"] +[node name="RoomTest3" parent="Rooms" instance=ExtResource("2_e0an3")] +offset_left = 63.0 +offset_top = 55.0 +offset_right = 79.0 +offset_bottom = 65.0 diff --git a/map_room.tscn b/map_room.tscn index 74e41f5..711562d 100644 --- a/map_room.tscn +++ b/map_room.tscn @@ -4,18 +4,16 @@ [ext_resource type="Texture2D" uid="uid://bkfsgbkx3t3oe" path="res://assets/kenney_1-bit-platformer-pack/Tiles/Transparent/tile_0241.png" id="2_vqn3c"] [node name="MapRoom" type="ColorRect"] -offset_left = 68.0 -offset_top = 57.0 -offset_right = 76.0 -offset_bottom = 62.0 +offset_right = 16.0 +offset_bottom = 10.0 script = ExtResource("1_oc81s") inactive_color = Color(0.7490196, 0.76862746, 0.8901961, 1) active_color = Color(0.5463331, 0.66674966, 1, 1) [node name="PlayerIcon" type="TextureRect" parent="."] layout_mode = 0 -offset_left = 2.0 -offset_right = 18.0 +offset_left = 4.0 +offset_right = 20.0 offset_bottom = 16.0 -scale = Vector2(0.25, 0.25) +scale = Vector2(0.5, 0.5) texture = ExtResource("2_vqn3c") diff --git a/project.godot b/project.godot index 38af158..e467ac5 100644 --- a/project.godot +++ b/project.godot @@ -26,6 +26,11 @@ window/size/window_height_override=1080 window/stretch/mode="canvas_items" window/stretch/scale_mode="integer" +[global_group] + +ui_movement="" +ui_menu="" + [input] move_right={ @@ -9,6 +9,8 @@ var save_state = ConfigFile.new() func _ready() -> void: $Map.hide_map() + get_tree().call_group("ui_movement", "set_visible", false) + get_tree().call_group("ui_menu", "set_visible", false) var room = initial_room.instantiate() active_room_name = room.name @@ -37,13 +39,10 @@ func replace_active_room(new_room: Node, on_changed: Callable): var current_room = get_node("ActiveRoom") remove_child(current_room) current_room.queue_free() - - var next_is_main_menu = new_room.name == "MainMenu" - var touchscreen_ui_exists = has_node("TouchScreenUI") - if next_is_main_menu and touchscreen_ui_exists: - remove_child(get_node("TouchScreenUI")) - elif not next_is_main_menu and not touchscreen_ui_exists: - add_child(preload("res://touch_screen_ui.tscn").instantiate()) + + var show_touchscreen_ui = (new_room.name != "MainMenu") + get_tree().call_group("ui_movement", "set_visible", show_touchscreen_ui) + get_tree().call_group("ui_menu", "set_visible", show_touchscreen_ui) active_room_name = new_room.name new_room.name = "ActiveRoom" @@ -64,3 +63,4 @@ func open_pause_menu(): func close_pause_menu(): get_tree().paused = false $Map.hide_map() + @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=3 uid="uid://cey3jxnpmommt"] +[gd_scene load_steps=6 format=3 uid="uid://cey3jxnpmommt"] [ext_resource type="Script" uid="uid://dxbspy72bg0db" path="res://top.gd" id="1_on2c2"] [ext_resource type="PackedScene" uid="uid://cjdhfl70fgt6m" path="res://room_main_menu.tscn" id="2_58ij3"] [ext_resource type="PackedScene" uid="uid://c2shuyjjq06p8" path="res://transition_manager.tscn" id="3_2exal"] [ext_resource type="PackedScene" uid="uid://cseqghymhiyqo" path="res://map.tscn" id="3_58ij3"] +[ext_resource type="PackedScene" uid="uid://cciwccvljuuyq" path="res://touch_screen_ui.tscn" id="5_edsjh"] [node name="Top" type="Node2D"] process_mode = 3 @@ -13,3 +14,5 @@ initial_room = ExtResource("2_58ij3") [node name="TransitionManager" parent="." instance=ExtResource("3_2exal")] [node name="Map" parent="." instance=ExtResource("3_58ij3")] + +[node name="TouchScreenUI" parent="." instance=ExtResource("5_edsjh")] diff --git a/touch_screen_button.gd b/touch_screen_button.gd index 1a84776..b607964 100644 --- a/touch_screen_button.gd +++ b/touch_screen_button.gd @@ -1,10 +1,15 @@ extends TouchScreenButton @export var texture: Texture2D -@export var desktop_visible: bool +@export var inactive_color: Color +@export var active_color: Color -# Called when the node enters the scene tree for the first time. func _ready() -> void: $TextureRect.texture = texture - if not DisplayServer.is_touchscreen_available(): - visible = desktop_visible + $TextureRect/CanvasModulate.color = inactive_color + +func _on_pressed() -> void: + $TextureRect/CanvasModulate.color = active_color + +func _on_released() -> void: + $TextureRect/CanvasModulate.color = inactive_color diff --git a/touch_screen_button.tscn b/touch_screen_button.tscn index 355d491..e1d0898 100644 --- a/touch_screen_button.tscn +++ b/touch_screen_button.tscn @@ -10,6 +10,8 @@ shape = SubResource("RectangleShape2D_l8v81") passby_press = true visibility_mode = 1 script = ExtResource("1_8gxd0") +inactive_color = Color(0.54509807, 0.6666667, 1, 0.5019608) +active_color = Color(0, 0.77254903, 0.7764706, 0.5019608) [node name="TextureRect" type="TextureRect" parent="."] offset_left = -8.0 @@ -17,3 +19,8 @@ offset_top = -8.0 offset_right = 8.0 offset_bottom = 8.0 expand_mode = 1 + +[node name="CanvasModulate" type="CanvasModulate" parent="TextureRect"] + +[connection signal="pressed" from="." to="." method="_on_pressed"] +[connection signal="released" from="." to="." method="_on_released"] diff --git a/touch_screen_ui.gd b/touch_screen_ui.gd new file mode 100644 index 0000000..0da7f1c --- /dev/null +++ b/touch_screen_ui.gd @@ -0,0 +1,7 @@ +extends CanvasLayer + +@export var desktop_visible: bool + +func _ready() -> void: + if not DisplayServer.is_touchscreen_available(): + visible = desktop_visible diff --git a/touch_screen_ui.gd.uid b/touch_screen_ui.gd.uid new file mode 100644 index 0000000..1500fcc --- /dev/null +++ b/touch_screen_ui.gd.uid @@ -0,0 +1 @@ +uid://get1ypni1vfp diff --git a/touch_screen_ui.tscn b/touch_screen_ui.tscn index 3748379..a9b29b3 100644 --- a/touch_screen_ui.tscn +++ b/touch_screen_ui.tscn @@ -1,33 +1,33 @@ [gd_scene load_steps=7 format=3 uid="uid://cciwccvljuuyq"] [ext_resource type="PackedScene" uid="uid://dwl0fylftkrn7" path="res://touch_screen_button.tscn" id="1_e48dh"] -[ext_resource type="Texture2D" uid="uid://dxwflmdxikfiu" path="res://assets/kenney_1-bit-input-prompts-pixel-16/Tiles (Black)/tile_0758.png" id="2_v5djr"] -[ext_resource type="Texture2D" uid="uid://bhpl1ew34plow" path="res://assets/kenney_1-bit-input-prompts-pixel-16/Tiles (Black)/tile_0760.png" id="3_jinrf"] -[ext_resource type="Texture2D" uid="uid://m46a5qu4rgui" path="res://assets/kenney_1-bit-input-prompts-pixel-16/Tiles (Black)/tile_0757.png" id="4_ay5rb"] -[ext_resource type="Texture2D" uid="uid://dsetjcrrlp7gu" path="res://assets/kenney_1-bit-input-prompts-pixel-16/Tiles (Black)/tile_0769.png" id="5_ac8rc"] +[ext_resource type="Texture2D" uid="uid://80qwkqluar71" path="res://assets/kenney_1-bit-input-prompts-pixel-16/Tiles (White)/tile_0758.png" id="2_e48dh"] +[ext_resource type="Texture2D" uid="uid://dcmysr8ayphbq" path="res://assets/kenney_1-bit-input-prompts-pixel-16/Tiles (White)/tile_0760.png" id="3_e48dh"] +[ext_resource type="Texture2D" uid="uid://dubf0an7e4r8q" path="res://assets/kenney_1-bit-input-prompts-pixel-16/Tiles (White)/tile_0757.png" id="4_e48dh"] +[ext_resource type="Texture2D" uid="uid://jc43kdg6konu" path="res://assets/kenney_1-bit-input-prompts-pixel-16/Tiles (White)/tile_0769.png" id="5_e48dh"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_k6i1l"] size = Vector2(40, 26) [node name="TouchScreenUI" type="CanvasLayer"] -[node name="TouchScreenButtonRight" parent="." instance=ExtResource("1_e48dh")] +[node name="TouchScreenButtonRight" parent="." groups=["ui_movement"] instance=ExtResource("1_e48dh")] position = Vector2(60, 88) action = "move_right" -texture = ExtResource("2_v5djr") +texture = ExtResource("2_e48dh") -[node name="TouchScreenButtonLeft" parent="." instance=ExtResource("1_e48dh")] +[node name="TouchScreenButtonLeft" parent="." groups=["ui_movement"] instance=ExtResource("1_e48dh")] position = Vector2(20, 88) action = "move_left" -texture = ExtResource("3_jinrf") +texture = ExtResource("3_e48dh") -[node name="TouchScreenButtonJump" parent="." instance=ExtResource("1_e48dh")] +[node name="TouchScreenButtonJump" parent="." groups=["ui_movement"] instance=ExtResource("1_e48dh")] position = Vector2(172, 88) action = "jump" -texture = ExtResource("4_ay5rb") +texture = ExtResource("4_e48dh") -[node name="TouchScreenButtonMenu" parent="." instance=ExtResource("1_e48dh")] +[node name="TouchScreenButtonMenu" parent="." groups=["ui_menu"] instance=ExtResource("1_e48dh")] position = Vector2(172, 13) shape = SubResource("RectangleShape2D_k6i1l") action = "menu" -texture = ExtResource("5_ac8rc") +texture = ExtResource("5_e48dh") |
