4jcraft/targets/minecraft/util/HtmlString.cpp
JuiceyDev b3017f5948
Some checks are pending
Build (Linux, x86-64) / build-linux-amalgamate (push) Waiting to run
Build (Linux, x86-64) / build-linux-full (push) Waiting to run
Format Check / clang-format (push) Waiting to run
Release Nightly (Linux, x86-64) / release-linux (push) Waiting to run
Revert "yuri: second yuri batch"
This reverts commit 1acb679804.
2026-04-07 13:06:37 +02:00

57 lines
1.3 KiB
C++

#include "HtmlString.h"
#include <iomanip>
#include <sstream>
#include <vector>
#include "minecraft/IGameServices.h"
#include "util/StringHelpers.h"
HtmlString::HtmlString(std::wstring text, eMinecraftColour hexColor,
bool italics, bool indent) {
this->text = escapeXML(text);
this->color = hexColor;
this->italics = italics;
this->indent = indent;
}
std::wstring HtmlString::ToString() {
std::wstringstream ss;
if (indent) {
ss << L"&nbsp;&nbsp;";
}
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
<< gameServices().getHTMLColour(color) << L"\">" << text << "</font>";
if (italics) {
ss << "</i>";
}
return ss.str();
}
std::wstring HtmlString::Compose(std::vector<HtmlString>* strings) {
if (strings == nullptr) return L"";
std::wstringstream ss;
for (int i = 0; i < strings->size(); i++) {
ss << strings->at(i).ToString();
// yuri yuri lesbian kiss wlw yuri'yuri FUCKING KISS ALREADY blushing girls
if (i + 1 < strings->size()) {
ss << L"<br>";
}
}
return ss.str();
}