#include "Watermark.h"
#include "Client.h"
#include "Utils/ImGuiRenderUtils.h"
#include "Utils/ColorUtils.h"
#include "Utils/MathUtils.h"

#include "Interface.h"

auto Watermark::onImGuiRender() -> void {
	Interface* interfaceMod = Client::findMod<Interface>(_("Interface"));

	if (Client::screenName == _("start_screen")) return;

	Utils::ImGuiRender::setFont(ImGui::GetIO().Fonts->Fonts[(bold ? 1 : 0) + (4 * interfaceMod->font)]);
	Utils::ImGuiRender::setDrawList(ImGui::GetBackgroundDrawList());

	Utils::ImGuiRender::setSize(2.3f);
	float sizeY_ = Utils::ImGuiRender::getTextSize("").y;
	static ImVec2 pos_ = ImVec2(10.f, -sizeY_);
	pos_.y = Utils::Math::animate(10.f, pos_.y, Client::deltaTime);

	ImVec2 pos = pos_;

	int index = 0;
	for (char s : std::string(version ? Client::clientName + _(" ") + Client::clientVersion : Client::clientName + _(" Client"))) {
		std::stringstream ss;
		ss << s;

		Utils::ImGuiRender::setDrawList(ImGui::GetBackgroundDrawList());
		if (index <= Client::clientName.length() || !version) {
			Utils::ImGuiRender::setSize(version ? 2.3f : 2.f);
			Utils::ImGuiRender::setColor(Utils::Color::getColor(4.f, index * 60, 1.f));

			ImVec2 size = Utils::ImGuiRender::getTextSize(ss.str());

			Utils::ImGuiRender::setSize(5.f);
			Utils::ImGuiRender::setThickness(120.f);
			Utils::ImGuiRender::drawShadow(ImVec2(pos.x, pos.y + (size.y / 2)));
		}

		if (index <= Client::clientName.length() || !version) {
			Utils::ImGuiRender::setSize(version ? 2.f : 1.8f);
		}
		else {
			Utils::ImGuiRender::setSize(1.4f);
			Utils::ImGuiRender::setColor(ImColor(0.7f, 0.7f, 0.7f, 1.f));
		}

		Utils::ImGuiRender::setDrawList(ImGui::GetForegroundDrawList());
		Utils::ImGuiRender::drawText(ss.str(), pos);

		ImVec2 size = Utils::ImGuiRender::getTextSize(ss.str());


		pos.x += size.x;
		index++;
	}
}
