From dae96feeb945108957fba5d1a2d09c0f3778ca84 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Sun, 4 Feb 2024 23:07:13 +0100 Subject: [PATCH] Demo: Link game to showcase and vice versa --- demo/demo/scenes/{ => base}/arena.tscn | 0 demo/demo/scenes/{ => base}/clouds.tscn | 0 .../scenes/{ => base}/toggle_fullscreen.gd | 0 demo/demo/scenes/{demo.gd => game.gd} | 4 + demo/demo/scenes/{demo.tscn => game.tscn} | 86 ++++++++++--------- .../scenes/{agent_showcase.gd => showcase.gd} | 4 + .../{agent_showcase.tscn => showcase.tscn} | 52 ++++++----- demo/project.godot | 2 +- 8 files changed, 88 insertions(+), 60 deletions(-) rename demo/demo/scenes/{ => base}/arena.tscn (100%) rename demo/demo/scenes/{ => base}/clouds.tscn (100%) rename demo/demo/scenes/{ => base}/toggle_fullscreen.gd (100%) rename demo/demo/scenes/{demo.gd => game.gd} (95%) rename demo/demo/scenes/{demo.tscn => game.tscn} (72%) rename demo/demo/scenes/{agent_showcase.gd => showcase.gd} (95%) rename demo/demo/scenes/{agent_showcase.tscn => showcase.tscn} (77%) diff --git a/demo/demo/scenes/arena.tscn b/demo/demo/scenes/base/arena.tscn similarity index 100% rename from demo/demo/scenes/arena.tscn rename to demo/demo/scenes/base/arena.tscn diff --git a/demo/demo/scenes/clouds.tscn b/demo/demo/scenes/base/clouds.tscn similarity index 100% rename from demo/demo/scenes/clouds.tscn rename to demo/demo/scenes/base/clouds.tscn diff --git a/demo/demo/scenes/toggle_fullscreen.gd b/demo/demo/scenes/base/toggle_fullscreen.gd similarity index 100% rename from demo/demo/scenes/toggle_fullscreen.gd rename to demo/demo/scenes/base/toggle_fullscreen.gd diff --git a/demo/demo/scenes/demo.gd b/demo/demo/scenes/game.gd similarity index 95% rename from demo/demo/scenes/demo.gd rename to demo/demo/scenes/game.gd index 6453a55..911fa9f 100644 --- a/demo/demo/scenes/demo.gd +++ b/demo/demo/scenes/game.gd @@ -81,3 +81,7 @@ func _on_agent_death() -> void: func _on_player_death() -> void: await get_tree().create_timer(3.0).timeout get_tree().reload_current_scene() + + +func _on_switch_to_showcase_pressed() -> void: + get_tree().change_scene_to_file("res://demo/scenes/showcase.tscn") diff --git a/demo/demo/scenes/demo.tscn b/demo/demo/scenes/game.tscn similarity index 72% rename from demo/demo/scenes/demo.tscn rename to demo/demo/scenes/game.tscn index 822407d..cd69daa 100644 --- a/demo/demo/scenes/demo.tscn +++ b/demo/demo/scenes/game.tscn @@ -1,39 +1,39 @@ [gd_scene load_steps=15 format=3 uid="uid://clyhgbpfpmtw7"] -[ext_resource type="Script" path="res://demo/scenes/demo.gd" id="1_foif6"] -[ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/arena.tscn" id="1_rab6h"] -[ext_resource type="Theme" uid="uid://boqtjf88xcpu4" path="res://demo/assets/ui.theme" id="2_e6mlj"] -[ext_resource type="PackedScene" uid="uid://bpd1wmw2f7bvg" path="res://demo/props/gong.tscn" id="3_nbeay"] -[ext_resource type="Texture2D" uid="uid://tyu0ua1ju38l" path="res://demo/assets/logo.png" id="3_t7by8"] -[ext_resource type="FontFile" uid="uid://d25vkmce7mhlt" path="res://demo/assets/fonts/knewave_regular.ttf" id="4_xx6j3"] -[ext_resource type="Script" path="res://demo/scenes/toggle_fullscreen.gd" id="5_2oy30"] -[ext_resource type="PackedScene" uid="uid://d07ag5dcje13i" path="res://demo/agents/player/player.tscn" id="5_cmgoj"] -[ext_resource type="Texture2D" uid="uid://dlw15foygohrk" path="res://demo/assets/hp_under.png" id="6_3dtym"] -[ext_resource type="Texture2D" uid="uid://cls8jtnu413o8" path="res://demo/assets/hp_over.png" id="7_3xolo"] -[ext_resource type="Texture2D" uid="uid://hnwi23oef752" path="res://demo/assets/hp_bar.png" id="8_ee1p0"] +[ext_resource type="Script" path="res://demo/scenes/game.gd" id="1_qw71e"] +[ext_resource type="Theme" uid="uid://boqtjf88xcpu4" path="res://demo/assets/ui.theme" id="2_r21q3"] +[ext_resource type="Texture2D" uid="uid://tyu0ua1ju38l" path="res://demo/assets/logo.png" id="3_g0us4"] +[ext_resource type="FontFile" uid="uid://d25vkmce7mhlt" path="res://demo/assets/fonts/knewave_regular.ttf" id="4_w0vii"] +[ext_resource type="Script" path="res://demo/scenes/base/toggle_fullscreen.gd" id="5_m16ov"] +[ext_resource type="Texture2D" uid="uid://dlw15foygohrk" path="res://demo/assets/hp_under.png" id="6_622dk"] +[ext_resource type="Texture2D" uid="uid://cls8jtnu413o8" path="res://demo/assets/hp_over.png" id="7_430mt"] +[ext_resource type="Texture2D" uid="uid://hnwi23oef752" path="res://demo/assets/hp_bar.png" id="8_invih"] +[ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/base/arena.tscn" id="9_k3uu1"] +[ext_resource type="PackedScene" uid="uid://bpd1wmw2f7bvg" path="res://demo/props/gong.tscn" id="10_tftjb"] +[ext_resource type="PackedScene" uid="uid://d07ag5dcje13i" path="res://demo/agents/player/player.tscn" id="11_bndob"] [sub_resource type="LabelSettings" id="LabelSettings_628x3"] -font = ExtResource("4_xx6j3") +font = ExtResource("4_w0vii") font_size = 36 font_color = Color(1, 1, 0.239216, 1) outline_size = 20 outline_color = Color(0.211521, 0.23888, 0.290166, 1) [sub_resource type="LabelSettings" id="LabelSettings_0r6iv"] -font = ExtResource("4_xx6j3") +font = ExtResource("4_w0vii") font_size = 37 outline_size = 15 outline_color = Color(0.211521, 0.23888, 0.290166, 1) [sub_resource type="LabelSettings" id="LabelSettings_qvxvp"] -font = ExtResource("4_xx6j3") +font = ExtResource("4_w0vii") font_size = 33 outline_size = 11 outline_color = Color(0.258915, 0.234974, 0.191974, 1) [node name="Demo" type="Node2D"] y_sort_enabled = true -script = ExtResource("1_foif6") +script = ExtResource("1_qw71e") [node name="UI Layer" type="CanvasLayer" parent="."] @@ -44,7 +44,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -theme = ExtResource("2_e6mlj") +theme = ExtResource("2_r21q3") [node name="Logo" type="TextureRect" parent="UI Layer/Control"] layout_mode = 1 @@ -59,7 +59,7 @@ offset_right = -1643.0 offset_bottom = -45.0 grow_horizontal = 0 grow_vertical = 0 -texture = ExtResource("3_t7by8") +texture = ExtResource("3_g0us4") [node name="Demo project" type="Label" parent="UI Layer/Control/Logo"] layout_mode = 1 @@ -79,22 +79,6 @@ label_settings = SubResource("LabelSettings_628x3") horizontal_alignment = 2 vertical_alignment = 1 -[node name="ToggleFullscreen" type="Button" parent="UI Layer/Control"] -layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -214.0 -offset_top = 30.0 -offset_right = -31.0 -offset_bottom = 75.0 -grow_horizontal = 0 -focus_mode = 0 -theme_override_fonts/font = ExtResource("4_xx6j3") -theme_override_font_sizes/font_size = 22 -text = "Toggle Fullscreen" -script = ExtResource("5_2oy30") - [node name="VBoxContainer" type="VBoxContainer" parent="UI Layer/Control"] layout_mode = 1 anchors_preset = 3 @@ -116,6 +100,29 @@ Attack ENTER or F Dodge SPACE" label_settings = SubResource("LabelSettings_0r6iv") +[node name="HBoxContainer" type="HBoxContainer" parent="UI Layer/Control"] +layout_mode = 0 +offset_left = 1512.0 +offset_top = 29.0 +offset_right = 1912.0 +offset_bottom = 74.0 + +[node name="ToggleFullscreen" type="Button" parent="UI Layer/Control/HBoxContainer"] +layout_mode = 2 +focus_mode = 0 +theme_override_fonts/font = ExtResource("4_w0vii") +theme_override_font_sizes/font_size = 22 +text = "Toggle Fullscreen" +script = ExtResource("5_m16ov") + +[node name="Switch to Showcase" type="Button" parent="UI Layer/Control/HBoxContainer"] +layout_mode = 2 +focus_mode = 0 +theme_override_fonts/font = ExtResource("4_w0vii") +theme_override_font_sizes/font_size = 22 +text = "Switch to Showcase +" + [node name="HPBar" type="TextureProgressBar" parent="UI Layer/Control"] unique_name_in_owner = true layout_mode = 0 @@ -124,9 +131,9 @@ offset_top = 24.0 offset_right = 405.0 offset_bottom = 84.0 value = 100.0 -texture_under = ExtResource("6_3dtym") -texture_over = ExtResource("7_3xolo") -texture_progress = ExtResource("8_ee1p0") +texture_under = ExtResource("6_622dk") +texture_over = ExtResource("7_430mt") +texture_progress = ExtResource("8_invih") [node name="RoundCounter" type="Label" parent="UI Layer/Control"] unique_name_in_owner = true @@ -138,12 +145,12 @@ offset_bottom = 81.0 text = "Round: 0/1" label_settings = SubResource("LabelSettings_qvxvp") -[node name="Arena" parent="." instance=ExtResource("1_rab6h")] +[node name="Arena" parent="." instance=ExtResource("9_k3uu1")] -[node name="Gong" parent="." instance=ExtResource("3_nbeay")] +[node name="Gong" parent="." instance=ExtResource("10_tftjb")] position = Vector2(923, -21) -[node name="Player" parent="." instance=ExtResource("5_cmgoj")] +[node name="Player" parent="." instance=ExtResource("11_bndob")] position = Vector2(843, 455) [node name="Camera2D" type="Camera2D" parent="Player"] @@ -187,4 +194,5 @@ position = Vector2(629, 417) [node name="SpawnPosition10" type="Marker2D" parent="SpawnPoints"] position = Vector2(1859, 3) +[connection signal="pressed" from="UI Layer/Control/HBoxContainer/Switch to Showcase" to="." method="_on_switch_to_showcase_pressed"] [connection signal="gong_struck" from="Gong" to="." method="_on_gong_gong_struck"] diff --git a/demo/demo/scenes/agent_showcase.gd b/demo/demo/scenes/showcase.gd similarity index 95% rename from demo/demo/scenes/agent_showcase.gd rename to demo/demo/scenes/showcase.gd index 9f0a2e3..e3268f9 100644 --- a/demo/demo/scenes/agent_showcase.gd +++ b/demo/demo/scenes/showcase.gd @@ -78,3 +78,7 @@ func _on_agent_selection_id_pressed(id: int) -> void: agent_selection.text = bt_player.behavior_tree.resource_path.get_file() previous.disabled = id == 0 next.disabled = id == (agent_files.size()-1) + + +func _on_switch_to_game_pressed() -> void: + get_tree().change_scene_to_file("res://demo/scenes/game.tscn") diff --git a/demo/demo/scenes/agent_showcase.tscn b/demo/demo/scenes/showcase.tscn similarity index 77% rename from demo/demo/scenes/agent_showcase.tscn rename to demo/demo/scenes/showcase.tscn index 7541b29..e0be5ce 100644 --- a/demo/demo/scenes/agent_showcase.tscn +++ b/demo/demo/scenes/showcase.tscn @@ -1,22 +1,22 @@ [gd_scene load_steps=11 format=3 uid="uid://b3ae14mc2ty3y"] -[ext_resource type="Script" path="res://demo/scenes/agent_showcase.gd" id="1_frr2n"] -[ext_resource type="Theme" uid="uid://boqtjf88xcpu4" path="res://demo/assets/ui.theme" id="2_hb4lh"] -[ext_resource type="Texture2D" uid="uid://tyu0ua1ju38l" path="res://demo/assets/logo.png" id="3_v6wtt"] -[ext_resource type="FontFile" uid="uid://d25vkmce7mhlt" path="res://demo/assets/fonts/knewave_regular.ttf" id="4_tju7a"] -[ext_resource type="FontFile" uid="uid://n231m6uqsq6x" path="res://demo/assets/fonts/junction_bold.otf" id="5_0fprc"] -[ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/arena.tscn" id="6_6awy2"] -[ext_resource type="Script" path="res://demo/scenes/toggle_fullscreen.gd" id="6_y6c7b"] -[ext_resource type="PackedScene" uid="uid://c5fhe3tulhlco" path="res://demo/props/dummy.tscn" id="7_ao7an"] +[ext_resource type="Script" path="res://demo/scenes/showcase.gd" id="1_l12ql"] +[ext_resource type="Theme" uid="uid://boqtjf88xcpu4" path="res://demo/assets/ui.theme" id="2_3d7dj"] +[ext_resource type="FontFile" uid="uid://d25vkmce7mhlt" path="res://demo/assets/fonts/knewave_regular.ttf" id="3_7vli5"] +[ext_resource type="FontFile" uid="uid://n231m6uqsq6x" path="res://demo/assets/fonts/junction_bold.otf" id="4_7ubu6"] +[ext_resource type="Texture2D" uid="uid://tyu0ua1ju38l" path="res://demo/assets/logo.png" id="5_rwygb"] +[ext_resource type="Script" path="res://demo/scenes/base/toggle_fullscreen.gd" id="6_uggpo"] +[ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/base/arena.tscn" id="7_42nq6"] +[ext_resource type="PackedScene" uid="uid://c5fhe3tulhlco" path="res://demo/props/dummy.tscn" id="8_apshw"] [sub_resource type="LabelSettings" id="LabelSettings_3uhve"] -font = ExtResource("4_tju7a") +font = ExtResource("3_7vli5") font_size = 29 outline_size = 10 outline_color = Color(0.145083, 0.168536, 0.203708, 1) [sub_resource type="LabelSettings" id="LabelSettings_la4ui"] -font = ExtResource("4_tju7a") +font = ExtResource("3_7vli5") font_size = 36 font_color = Color(1, 1, 0.239216, 1) outline_size = 20 @@ -24,7 +24,7 @@ outline_color = Color(0.211521, 0.23888, 0.290166, 1) [node name="AgentShowcase" type="Node2D"] y_sort_enabled = true -script = ExtResource("1_frr2n") +script = ExtResource("1_l12ql") metadata/_edit_horizontal_guides_ = [1019.0] [node name="UI Layer" type="CanvasLayer" parent="."] @@ -36,7 +36,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -theme = ExtResource("2_hb4lh") +theme = ExtResource("2_3d7dj") [node name="Panel" type="Panel" parent="UI Layer/Control"] custom_minimum_size = Vector2(600, 0) @@ -87,7 +87,7 @@ unique_name_in_owner = true custom_minimum_size = Vector2(400, 50) layout_mode = 2 size_flags_horizontal = 3 -theme_override_fonts/font = ExtResource("5_0fprc") +theme_override_fonts/font = ExtResource("4_7ubu6") theme_override_font_sizes/font_size = 30 text = "02_agent_imp.tres " @@ -128,7 +128,7 @@ offset_right = -1643.0 offset_bottom = -45.0 grow_horizontal = 0 grow_vertical = 0 -texture = ExtResource("3_v6wtt") +texture = ExtResource("5_rwygb") [node name="Demo project" type="Label" parent="UI Layer/Control/Logo"] layout_mode = 1 @@ -148,17 +148,27 @@ label_settings = SubResource("LabelSettings_la4ui") horizontal_alignment = 2 vertical_alignment = 1 -[node name="ToggleFullscreen" type="Button" parent="UI Layer/Control"] +[node name="HBoxContainer" type="HBoxContainer" parent="UI Layer/Control"] layout_mode = 0 offset_left = 8.0 offset_top = 8.0 -offset_right = 120.0 +offset_right = 191.0 offset_bottom = 53.0 + +[node name="ToggleFullscreen" type="Button" parent="UI Layer/Control/HBoxContainer"] +layout_mode = 2 focus_mode = 0 -theme_override_fonts/font = ExtResource("4_tju7a") +theme_override_fonts/font = ExtResource("3_7vli5") theme_override_font_sizes/font_size = 22 text = "Toggle Fullscreen" -script = ExtResource("6_y6c7b") +script = ExtResource("6_uggpo") + +[node name="SwitchToGame" type="Button" parent="UI Layer/Control/HBoxContainer"] +layout_mode = 2 +focus_mode = 0 +theme_override_fonts/font = ExtResource("3_7vli5") +theme_override_font_sizes/font_size = 22 +text = "Switch to Game" [node name="Camera2D" type="Camera2D" parent="."] position = Vector2(400, 0) @@ -172,8 +182,10 @@ drag_top_margin = 0.1 drag_right_margin = 0.0 drag_bottom_margin = 0.1 -[node name="Arena" parent="." instance=ExtResource("6_6awy2")] +[node name="Arena" parent="." instance=ExtResource("7_42nq6")] metadata/_edit_lock_ = true -[node name="Dummy" parent="." instance=ExtResource("7_ao7an")] +[node name="Dummy" parent="." instance=ExtResource("8_apshw")] position = Vector2(1106, 423) + +[connection signal="pressed" from="UI Layer/Control/HBoxContainer/SwitchToGame" to="." method="_on_switch_to_game_pressed"] diff --git a/demo/project.godot b/demo/project.godot index 7b27a2d..5b694f9 100644 --- a/demo/project.godot +++ b/demo/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="LimboAI Demo" -run/main_scene="res://demo/scenes/demo.tscn" +run/main_scene="res://demo/scenes/showcase.tscn" config/features=PackedStringArray("4.2", "Forward Plus") config/icon="res://demo/icon.svg"