diff --git a/project.godot b/project.godot index 8f34f366..17dac41f 100644 --- a/project.godot +++ b/project.godot @@ -109,7 +109,7 @@ Throw={ [internationalization] -locale/translations_pot_files=PackedStringArray("res://src/dialog/TestDialogue.dialogue") +locale/translations_pot_files=PackedStringArray("res://src/dialog/Dialogue.dialogue", "res://src/dialog/TestDialogue.dialogue") [layer_names] diff --git a/src/dialog/Dialog.tres b/src/dialog/Dialog.tres new file mode 100644 index 00000000..90f073aa --- /dev/null +++ b/src/dialog/Dialog.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="DialogueResource" load_steps=2 format=3 uid="uid://dlbsw423e12au"] + +[ext_resource type="Script" path="res://addons/dialogue_manager/dialogue_resource.gd" id="1_p1wx7"] + +[resource] +script = ExtResource("1_p1wx7") +using_states = PackedStringArray() +titles = {} +character_names = PackedStringArray() +first_title = "" +lines = {} +raw_text = "" diff --git a/src/dialog/Dialog.tscn b/src/dialog/Dialog.tscn new file mode 100644 index 00000000..c411ee3e --- /dev/null +++ b/src/dialog/Dialog.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://kt5fg0it26cf"] + +[ext_resource type="Script" path="res://addons/dialogue_manager/dialogue_label.gd" id="1_bkcfu"] + +[node name="Dialog" type="RichTextLabel"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_bkcfu") +skip_pause_at_abbreviations = PackedStringArray("Mr", "Mrs", "Ms", "Dr", "etc", "eg", "ex") diff --git a/src/dialog/TestDialogue.dialogue b/src/dialog/Dialogue.dialogue similarity index 100% rename from src/dialog/TestDialogue.dialogue rename to src/dialog/Dialogue.dialogue diff --git a/src/dialog/Dialogue.dialogue.import b/src/dialog/Dialogue.dialogue.import new file mode 100644 index 00000000..210e7396 --- /dev/null +++ b/src/dialog/Dialogue.dialogue.import @@ -0,0 +1,15 @@ +[remap] + +importer="dialogue_manager_compiler_12" +type="Resource" +uid="uid://lao0opxww3ib" +path="res://.godot/imported/Dialogue.dialogue-176033575bc12c347010f3a30b2e302a.tres" + +[deps] + +source_file="res://src/dialog/Dialogue.dialogue" +dest_files=["res://.godot/imported/Dialogue.dialogue-176033575bc12c347010f3a30b2e302a.tres"] + +[params] + +defaults=true diff --git a/src/dialog/DialogueTest.cs b/src/dialog/DialogueTest.cs deleted file mode 100644 index 524617af..00000000 --- a/src/dialog/DialogueTest.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Godot; -using DialogueManagerRuntime; -using GameJamDungeon; -using Chickensoft.AutoInject; -using Chickensoft.Introspection; - -[Meta(typeof(IAutoNode))] -public partial class DialogueTest : Area3D -{ - public override void _Notification(int what) => this.Notify(what); - - [Export] - public Resource DialogueResource; - - [Export] - public string DialogueStart = "start"; - - [Dependency] - public IGameRepo GameRepo => this.DependOn(); - - public override void _Ready() - { - AreaEntered += DialogueTest_AreaEntered; - AreaExited += DialogueTest_AreaExited; - } - - private void DialogueTest_AreaExited(Area3D area) - { - GameRepo.IsWithinDialogueSpace = false; - } - - private void DialogueTest_AreaEntered(Area3D area) - { - GameRepo.IsWithinDialogueSpace = true; - } - - public override void _UnhandledInput(InputEvent @event) - { - if (Input.IsActionJustPressed("ui_accept") && GameRepo.IsWithinDialogueSpace) - DialogueManager.ShowDialogueBalloon(DialogueResource, DialogueStart); - } -} diff --git a/src/dialog/DialogueTest.tscn b/src/dialog/DialogueTest.tscn index 835c2460..a3fd6d2b 100644 --- a/src/dialog/DialogueTest.tscn +++ b/src/dialog/DialogueTest.tscn @@ -1,29 +1,9 @@ -[gd_scene load_steps=5 format=3 uid="uid://xb02opiwelet"] +[gd_scene format=3 uid="uid://b8n8hbe4kdyfw"] -[ext_resource type="Script" path="res://src/dialog/DialogueTest.cs" id="1_6offx"] -[ext_resource type="Script" path="res://addons/dialogue_manager/dialogue_label.gd" id="1_v3yy4"] -[ext_resource type="Resource" uid="uid://bw086h2dmhraf" path="res://src/dialog/TestDialogue.dialogue" id="2_c26a0"] - -[sub_resource type="BoxShape3D" id="BoxShape3D_dhaer"] -size = Vector3(2, 2, 2) - -[node name="Panel" type="Area3D"] -collision_layer = 0 -collision_mask = 128 -script = ExtResource("1_6offx") -DialogueResource = ExtResource("2_c26a0") - -[node name="DialogueTest" type="RichTextLabel" parent="."] +[node name="DialogueTest" type="Control"] +layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -scroll_active = false -scroll_following = true -script = ExtResource("1_v3yy4") -skip_pause_at_abbreviations = PackedStringArray() - -[node name="CollisionShape3D" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.254547, -0.166077, -1.29401) -shape = SubResource("BoxShape3D_dhaer") diff --git a/src/dialog/TestDialogue.dialogue.import b/src/dialog/TestDialogue.dialogue.import deleted file mode 100644 index b3971c03..00000000 --- a/src/dialog/TestDialogue.dialogue.import +++ /dev/null @@ -1,15 +0,0 @@ -[remap] - -importer="dialogue_manager_compiler_12" -type="Resource" -uid="uid://bw086h2dmhraf" -path="res://.godot/imported/TestDialogue.dialogue-ef49d7fb6d53dc49d01e69ca7037845f.tres" - -[deps] - -source_file="res://src/dialog/TestDialogue.dialogue" -dest_files=["res://.godot/imported/TestDialogue.dialogue-ef49d7fb6d53dc49d01e69ca7037845f.tres"] - -[params] - -defaults=true diff --git a/src/game/Game.tscn b/src/game/Game.tscn index 493cd10d..649a7e71 100644 --- a/src/game/Game.tscn +++ b/src/game/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=3 uid="uid://33ek675mfb5n"] +[gd_scene load_steps=15 format=3 uid="uid://33ek675mfb5n"] [ext_resource type="Script" path="res://src/game/Game.cs" id="1_ytcii"] [ext_resource type="PackedScene" uid="uid://cfecvvav8kkp6" path="res://src/player/Player.tscn" id="3_kk6ly"] @@ -9,7 +9,6 @@ [ext_resource type="PackedScene" uid="uid://b3r0r22kc67bl" path="res://src/map/dungeon/floors/Floor2.tscn" id="7_1sm5s"] [ext_resource type="PackedScene" uid="uid://b40sstnic41dw" path="res://src/map/dungeon/floors/Floor3.tscn" id="8_87yk1"] [ext_resource type="PackedScene" uid="uid://c3ek5i43cl0r5" path="res://src/map/Teleport.tscn" id="9_nwu7r"] -[ext_resource type="PackedScene" uid="uid://xb02opiwelet" path="res://src/dialog/DialogueTest.tscn" id="10_kejri"] [sub_resource type="Environment" id="Environment_fke5g"] @@ -72,7 +71,7 @@ script = ExtResource("1_ytcii") [node name="Player" parent="." instance=ExtResource("3_kk6ly")] process_mode = 1 -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.4456, 1.22144) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.74459, 1.22144) [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_fke5g") @@ -124,6 +123,3 @@ unique_name_in_owner = true process_mode = 3 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 900, 900, 900) disable_mode = 2 - -[node name="Panel" parent="." instance=ExtResource("10_kejri")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.42724, 0.203153, -2.07301) diff --git a/src/map/Overworld.tscn b/src/map/Overworld.tscn index 5ac0b9c2..50b860b3 100644 --- a/src/map/Overworld.tscn +++ b/src/map/Overworld.tscn @@ -1,13 +1,18 @@ -[gd_scene load_steps=5 format=3 uid="uid://dvnc26rebk6o0"] +[gd_scene load_steps=7 format=3 uid="uid://dvnc26rebk6o0"] [ext_resource type="Script" path="res://src/map/dungeon/floors/Overworld.cs" id="1_5hmt3"] +[ext_resource type="Resource" uid="uid://lao0opxww3ib" path="res://src/dialog/Dialogue.dialogue" id="2_k62pf"] [ext_resource type="PackedScene" uid="uid://c10nhqq8su6pp" path="res://src/items/weapons/models/RareSword.tscn" id="2_ni2nx"] [ext_resource type="PackedScene" uid="uid://d4l4qutp8x40c" path="res://src/npc/goddess/Goddess.tscn" id="3_4sm8u"] -[ext_resource type="PackedScene" uid="uid://xb02opiwelet" path="res://src/dialog/DialogueTest.tscn" id="4_thkm7"] +[ext_resource type="PackedScene" uid="uid://kt5fg0it26cf" path="res://src/dialog/Dialog.tscn" id="4_thkm7"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_46qk4"] +size = Vector3(1.96582, 2.5011, 2.21289) [node name="Overworld" type="Node3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.63488, -5.13176) script = ExtResource("1_5hmt3") +Dialogue = ExtResource("2_k62pf") [node name="CSGBox3D" type="CSGBox3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.82007, 0.766602, -1.46094) @@ -29,5 +34,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.8356, -2.30799) transform = Transform3D(1.4, 0, 0, 0, 1.4, 0, 0, 0, 1.4, -8.84798, -2.93175, -3.9493) [node name="Panel" parent="Goddess" instance=ExtResource("4_thkm7")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0604029, 0.440545, 0.961159) -collision_layer = 2 +unique_name_in_owner = true + +[node name="NPCBox" type="Area3D" parent="Goddess/Panel"] +unique_name_in_owner = true +collision_layer = 128 +collision_mask = 128 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Goddess/Panel/NPCBox"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.8395, -1.94114, -8.99061) +shape = SubResource("BoxShape3D_46qk4") diff --git a/src/map/dungeon/floors/Overworld.cs b/src/map/dungeon/floors/Overworld.cs index eed31614..c99c2d64 100644 --- a/src/map/dungeon/floors/Overworld.cs +++ b/src/map/dungeon/floors/Overworld.cs @@ -1,5 +1,7 @@ using Chickensoft.AutoInject; using Chickensoft.Introspection; +using DialogueManagerRuntime; +using GameJamDungeon; using Godot; [Meta(typeof(IAutoNode))] @@ -7,8 +9,32 @@ public partial class Overworld : Node3D, IDungeonFloor { public override void _Notification(int what) => this.Notify(what); + [Dependency] + public IGameRepo GameRepo => this.DependOn(); + + [Node] public Area3D NPCBox { get; set; } = default!; + + [Export] public Resource Dialogue { get; set; } + public void InitializeDungeon() { + NPCBox.AreaEntered += NPCBox_AreaEntered; + NPCBox.AreaExited += NPCBox_AreaExited; + } + private void NPCBox_AreaExited(Area3D area) + { + GameRepo.IsWithinDialogueSpace = false; + } + + private void NPCBox_AreaEntered(Area3D area) + { + GameRepo.IsWithinDialogueSpace = true; + } + + public override void _UnhandledInput(InputEvent @event) + { + if (Input.IsActionJustPressed("ui_accept") && GameRepo.IsWithinDialogueSpace) + DialogueManager.ShowDialogueBalloon(Dialogue, "start"); } }