blob: af6436718cb9df691fdf83bc46d38bbd10289201 (
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
50
51
52
53
54
55
56
57
|
#include "stdafx.h"
#include "HtmlString.h"
#include <iomanip>
HtmlString::HtmlString(wstring text, eMinecraftColour hexColor, bool italics, bool indent)
{
this->text = escapeXML(text);
this->color = hexColor;
this->italics = italics;
this->indent = indent;
}
wstring HtmlString::ToString()
{
std::wstringstream ss;
if (indent)
{
ss << L" ";
}
if (italics)
{
ss << "<i>";
}
eMinecraftColour color = this->color == eMinecraftColour_NOT_SET ? eHTMLColor_7 : this->color;
ss << L"<font color=\"#" << std::setfill(L'0') << std::setw(6) << std::hex << app.GetHTMLColor(color) << L"\">" << text << "</font>";
if (italics)
{
ss << "</i>";
}
return ss.str();
}
wstring HtmlString::Compose(vector<HtmlString> *strings)
{
if (strings == nullptr) return L"";
std::wstringstream ss;
for(int i = 0; i < strings->size(); i++)
{
ss << strings->at(i).ToString();
// Add a break if there's another line
if (i + 1 < strings->size())
{
ss << L"<br>";
}
}
return ss.str();
}
|