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

bool StartupMenuEditor::renderComponent(flecs::entity entity,
					StartupMenuComponent &sm)
{
	(void)entity;
	bool modified = false;

	if (ImGui::CollapsingHeader("Startup Menu",
				    ImGuiTreeNodeFlags_DefaultOpen)) {
		ImGui::Indent();

		char fontNameBuf[256];
		snprintf(fontNameBuf, sizeof(fontNameBuf), "%s",
			 sm.fontName.c_str());
		if (ImGui::InputText("Font Name", fontNameBuf,
				     sizeof(fontNameBuf))) {
			sm.fontName = fontNameBuf;
			modified = true;
		}

		if (ImGui::DragFloat("Font Size", &sm.fontSize, 0.5f, 8.0f,
				     128.0f)) {
			modified = true;
		}

		char sceneBuf[256];
		snprintf(sceneBuf, sizeof(sceneBuf), "%s",
			 sm.newGameScene.c_str());
		if (ImGui::InputText("New Game Scene", sceneBuf,
				     sizeof(sceneBuf))) {
			sm.newGameScene = sceneBuf;
			modified = true;
		}

		if (ImGui::Checkbox("Show Load Game", &sm.showLoadGame))
			modified = true;
		if (ImGui::Checkbox("Show Options", &sm.showOptions))
			modified = true;
		if (ImGui::Checkbox("Show Quit", &sm.showQuit))
			modified = true;

		ImGui::Unindent();
	}

	return modified;
}
