the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 57 lines 1.0 kB view raw
1#include "stdafx.h" 2#include "HtmlString.h" 3#include <iomanip> 4 5HtmlString::HtmlString(wstring text, eMinecraftColour hexColor, bool italics, bool indent) 6{ 7 this->text = escapeXML(text); 8 this->color = hexColor; 9 this->italics = italics; 10 this->indent = indent; 11} 12 13wstring HtmlString::ToString() 14{ 15 std::wstringstream ss; 16 17 if (indent) 18 { 19 ss << L"&nbsp;&nbsp;"; 20 } 21 22 if (italics) 23 { 24 ss << "<i>"; 25 } 26 27 eMinecraftColour color = this->color == eMinecraftColour_NOT_SET ? eHTMLColor_7 : this->color; 28 29 ss << L"<font color=\"#" << std::setfill(L'0') << std::setw(6) << std::hex << app.GetHTMLColor(color) << L"\">" << text << "</font>"; 30 31 if (italics) 32 { 33 ss << "</i>"; 34 } 35 36 return ss.str(); 37} 38 39wstring HtmlString::Compose(vector<HtmlString> *strings) 40{ 41 if (strings == NULL) return L""; 42 43 std::wstringstream ss; 44 45 for(int i = 0; i < strings->size(); i++) 46 { 47 ss << strings->at(i).ToString(); 48 49 // Add a break if there's another line 50 if (i + 1 < strings->size()) 51 { 52 ss << L"<br>"; 53 } 54 } 55 56 return ss.str(); 57}