summaryrefslogtreecommitdiff
path: root/scripts/GUI/Message.cs
blob: 11f3532e45666eca27739e1e8f50e835cbee047f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Godot;

namespace TheLegendOfGustav.GUI;

public partial class Message : Label
{
	private static readonly LabelSettings baseSettings = GD.Load<LabelSettings>("res://assets/definitions/message_label_settings.tres");
	
	private string plainText;
	private int count = 1;

	public Message(string text)
	{
		PlainText = text;
		Text = text;
		LabelSettings = (LabelSettings)baseSettings.Duplicate();
		AutowrapMode = TextServer.AutowrapMode.WordSmart;
	}
	
	public string PlainText 
	{
		get => plainText;
		private set
		{
			plainText = value;
		}
	}
	public int Count
	{
		get => count;
		set
		{
			count = value;
			Text = FullText;
		}
	}

	public string FullText
	{
		get
		{
			if (count > 1)
			{
				return $"{plainText} ({count})";
			}
			return plainText;
		}
	}
}