#include "AnimationTreeTemplateEditor.hpp"
#include <imgui.h>

bool AnimationTreeTemplateEditor::renderComponent(
	flecs::entity entity, AnimationTreeTemplate &templ)
{
	ImGui::PushID("AnimTreeTempl");
	(void)entity;
	bool modified = false;

	if (ImGui::CollapsingHeader("Animation Tree Template",
				    ImGuiTreeNodeFlags_DefaultOpen)) {
		ImGui::Indent();

		char nameBuf[256];
		snprintf(nameBuf, sizeof(nameBuf), "%s", templ.name.c_str());
		if (ImGui::InputText("Template Name", nameBuf,
				     sizeof(nameBuf))) {
			templ.name = nameBuf;
			modified = true;
		}
		if (ImGui::IsItemHovered()) {
			ImGui::SetTooltip(
				"Other entities reference this template by name in their Animation Tree component.");
		}

		ImGui::TextDisabled("Version: %llu",
				    (unsigned long long)templ.version);
		ImGui::TextDisabled(
			"Edit the Animation Tree component on this entity to modify the template.");

		ImGui::Unindent();
	}

	ImGui::PopID();
	return modified;
}
