extended the dialog system
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
[gd_scene load_steps=5 format=3 uid="uid://h8na2j1qthm4"]
|
[gd_scene load_steps=5 format=3 uid="uid://dckxciecwjfgf"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://p5ubildre2tg" path="res://assets/textures/debug/cupcake.png" id="1_imilm"]
|
[ext_resource type="Texture2D" uid="uid://p5ubildre2tg" path="res://assets/textures/debug/cupcake.png" id="1_imilm"]
|
||||||
[ext_resource type="PackedScene" uid="uid://hyhe4kitrbt6" path="res://scenes/gui/dialog_trigger_area.tscn" id="2_blpmd"]
|
[ext_resource type="PackedScene" uid="uid://hyhe4kitrbt6" path="res://scenes/dialog_trigger_area.tscn" id="2_blpmd"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pchpi"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pchpi"]
|
||||||
size = Vector2(64, 58.5)
|
size = Vector2(64, 58.5)
|
||||||
|
@@ -1,14 +1,19 @@
|
|||||||
|
//WORK IN PROGRESS this code is very messy and will be fixed when it works
|
||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public partial class dialog_bubble : CanvasLayer
|
public partial class dialog_bubble : CanvasLayer
|
||||||
{
|
{
|
||||||
|
public List<string> currentDialogList = new List<string>();
|
||||||
public string currentDialogLine;
|
public string currentDialogLine;
|
||||||
public int debugCounter;
|
public int dialogCounter;
|
||||||
|
public string userName;
|
||||||
public void ImportString(string dialogTitle, string dialogFile, string playerName)
|
public void ImportString(string dialogTitle, string dialogFile, string playerName)
|
||||||
{
|
{
|
||||||
Visible = true;
|
userName = playerName;
|
||||||
|
GetNode<Label>("NameLabel").Text = dialogTitle;
|
||||||
GD.Print("test");
|
GD.Print("test");
|
||||||
GetNode("/root/main/player").Call("ChangeProcess",false);
|
GetNode("/root/main/player").Call("ChangeProcess",false);
|
||||||
string currentKey = "randomWelcomeText";
|
string currentKey = "randomWelcomeText";
|
||||||
@@ -22,15 +27,16 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
if (currentKey.StartsWith("random"))
|
if (currentKey.StartsWith("random"))
|
||||||
{
|
{
|
||||||
string[] dialogRand = allDialog[currentKey].AsStringArray();
|
string[] dialogRand = allDialog[currentKey].AsStringArray();
|
||||||
currentDialogLine = dialogRand[GD.Randi() % dialogRand.Length];
|
currentDialogList.Add(dialogRand[GD.Randi() % dialogRand.Length]);
|
||||||
|
currentDialogList.Add("Test!");
|
||||||
}
|
}
|
||||||
else currentDialogLine = allDialog[currentKey].AsString();
|
else currentDialogList.Add(allDialog[currentKey].AsString());
|
||||||
currentDialogLine = String.Format(currentDialogLine, playerName);
|
|
||||||
GetNode<Label>("TextLabel").Text = currentDialogLine;
|
|
||||||
GetNode<Label>("NameLabel").Text = dialogTitle;
|
|
||||||
}
|
}
|
||||||
public void EndDialog()
|
public void EndDialog()
|
||||||
{
|
{
|
||||||
|
currentDialogList = new List<string>();
|
||||||
|
dialogCounter = 0;
|
||||||
Visible = false;
|
Visible = false;
|
||||||
GetNode("/root/main/player").Call("ChangeProcess", true);
|
GetNode("/root/main/player").Call("ChangeProcess", true);
|
||||||
}
|
}
|
||||||
@@ -38,12 +44,17 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
{
|
{
|
||||||
if (Input.IsActionJustPressed("ui_accept"))
|
if (Input.IsActionJustPressed("ui_accept"))
|
||||||
{
|
{
|
||||||
debugCounter++;
|
dialogCounter++;
|
||||||
|
if (currentDialogList.Count >= dialogCounter)
|
||||||
|
{
|
||||||
|
Visible = true;
|
||||||
|
currentDialogLine = currentDialogList[dialogCounter - 1];
|
||||||
|
currentDialogLine = String.Format(currentDialogLine, userName);
|
||||||
|
GetNode<Label>("TextLabel").Text = currentDialogLine;
|
||||||
|
}
|
||||||
|
else GD.Print("No valid dialog available");
|
||||||
}
|
}
|
||||||
if(debugCounter > 1)
|
if(dialogCounter > currentDialogList.Count)
|
||||||
{
|
|
||||||
EndDialog();
|
EndDialog();
|
||||||
debugCounter = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user