diff --git a/dialog/npcs/villager_normal.json b/dialog/npcs/villager_normal.json index 6e4bbee..d8fb1ad 100644 --- a/dialog/npcs/villager_normal.json +++ b/dialog/npcs/villager_normal.json @@ -1,12 +1,12 @@ { "randomWelcomeText":[ - "Oh hello, {player}... You look great! What do you want from me?", - "Hey, {player}! Hope you have fun today!", - "Hi! What's up {player}?" + "Oh hello, {0}... You look great! What do you want from me?", + "Hey, {0}! Hope you have fun today!", + "Hi! What's up {0}?" ], "debugAnswer": "This is a debug answer!", "randomGoodbyeText":[ "Was nice talking to you goodbye!", - "Have a great day, {player}!" + "Have a great day, {0}!" ] } \ No newline at end of file diff --git a/scenes/gui/dialog_bubble.tscn b/scenes/gui/dialog_bubble.tscn index 9255e73..1721d74 100644 --- a/scenes/gui/dialog_bubble.tscn +++ b/scenes/gui/dialog_bubble.tscn @@ -26,16 +26,17 @@ anchor_left = 0.218 anchor_top = 0.812 anchor_right = 0.837 anchor_bottom = 0.972 -offset_left = 0.319977 -offset_top = -19.64 -offset_right = 0.380005 -offset_bottom = -4.84003 +offset_left = -15.066 +offset_top = 8.43201 +offset_right = -16.469 +offset_bottom = -9.80798 grow_horizontal = 2 grow_vertical = 0 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_fonts/font = ExtResource("1_vlvkg") theme_override_font_sizes/font_size = 32 text = "This is test text" +autowrap_mode = 3 [node name="NameLabel" type="Label" parent="."] anchors_preset = -1 @@ -43,10 +44,10 @@ anchor_left = 0.164 anchor_top = 0.782 anchor_right = 0.197 anchor_bottom = 0.808 -offset_left = 0.259995 -offset_top = -0.430054 -offset_right = -0.39502 -offset_bottom = 0.0799561 +offset_left = 7.93199 +offset_top = 4.35199 +offset_right = 7.27698 +offset_bottom = 4.888 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_fonts/font = ExtResource("1_vlvkg") theme_override_font_sizes/font_size = 16 diff --git a/scenes/main.tscn b/scenes/main.tscn index 86c4713..964216e 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -9,5 +9,7 @@ [node name="first_world" parent="." instance=ExtResource("2_x8nyb")] [node name="player" parent="." instance=ExtResource("1_p5d84")] +playerName = "vaporvee" [node name="dialog_bubble" parent="." instance=ExtResource("3_ohogx")] +visible = false diff --git a/scenes/tiles/dialogdebug_cupcake.tscn b/scenes/tiles/dialogdebug_cupcake.tscn index 092a2c9..3cc38b0 100644 --- a/scenes/tiles/dialogdebug_cupcake.tscn +++ b/scenes/tiles/dialogdebug_cupcake.tscn @@ -19,6 +19,7 @@ shape = SubResource("RectangleShape2D_pchpi") [node name="dialog_trigger_area" parent="." instance=ExtResource("2_blpmd")] dialogFile = "res://dialog/npcs/villager_normal.json" +dialogTitle = "Talking Cupcake" [node name="collision_shape_2d" parent="dialog_trigger_area" index="0"] shape = SubResource("RectangleShape2D_d78tr") diff --git a/src/scene-scripts/dialog_trigger_area.cs b/src/scene-scripts/dialog_trigger_area.cs index cf4c085..ffdeec3 100644 --- a/src/scene-scripts/dialog_trigger_area.cs +++ b/src/scene-scripts/dialog_trigger_area.cs @@ -6,10 +6,12 @@ public partial class dialog_trigger_area : Area2D { [Export(PropertyHint.File, "*json")] string dialogFile; - - public string currentKey = "randomWelcomeText"; - public void OnInteraction() + [Export] + string dialogTitle; + public string printedDialog; + public void OnInteraction(string playerName) { + string currentKey = "randomWelcomeText"; using var file = FileAccess.Open(dialogFile, FileAccess.ModeFlags.Read); string text = file.GetAsText(); @@ -17,7 +19,10 @@ public partial class dialog_trigger_area : Area2D Dictionary allDialog = (Dictionary)jsonFile; if (currentKey.BeginsWith("random")) { string[] dialogPart = allDialog[currentKey].AsStringArray(); - GD.Print(dialogPart[GD.Randi() % dialogPart.Length]); - } else GD.Print(allDialog[currentKey]); + printedDialog = dialogPart[GD.Randi() % dialogPart.Length]; + } else printedDialog = allDialog[currentKey].AsString(); + printedDialog = String.Format(printedDialog, playerName); + + GetNode("/root/main/dialog_bubble").Call("ImportString",dialogTitle, printedDialog); } } diff --git a/src/scene-scripts/gui/dialog_bubble.cs b/src/scene-scripts/gui/dialog_bubble.cs index 79df3a1..d0c0315 100644 --- a/src/scene-scripts/gui/dialog_bubble.cs +++ b/src/scene-scripts/gui/dialog_bubble.cs @@ -3,13 +3,10 @@ using System; public partial class dialog_bubble : CanvasLayer { - public override void _Ready() + public void ImportString(string dialogTitle, string printedDialog) { - Show(); - ImportString(); - } - public void ImportString() - { - + Visible = !Visible; + GetNode