-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chatbox.cs
74 lines (63 loc) · 1.84 KB
/
Chatbox.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Limestone.Utility;
using Limestone.Entities;
namespace Limestone
{
public class Chatbox
{
List<string> totalTexts = new List<string>();
List<string> texts = new List<string>();
public string text = "";
private string wrapped = "";
private int timeout = 300;
public bool updated = false;
public Chatbox()
{
}
public string AddShout(string enemyName, string text)
{
texts.Insert(0, "<" + enemyName + ">: " + text + "\n");
totalTexts.Insert(0, "<" + enemyName + ">: " + text + "\n");
updated = true;
return this.text;
}
public StringBuilder Add(string text)
{
return null;
}
public string ShowText()
{
StringBuilder sb = new StringBuilder();
foreach (string t in texts)
sb.Append(t);
if (updated)
{
SpriteFont font = Assets.GetFont("munro12");
StringBuilder wrapped = new StringBuilder();
wrapped.Append(TextHelper.WrapText(font, sb.ToString(), 256));
this.wrapped = wrapped.ToString();
return this.wrapped.ToString();
}
else return this.wrapped;
}
public void Update(Main main)
{
if (texts.Count > 0)
timeout--;
if (timeout <= 0)
{
texts.RemoveAt(texts.Count - 1);
timeout = 300;
}
}
public void InterpretString(Main main)
{
}
}
}