Files
simian/include/gui/GuiManager.h
T
nick 2a74648ffd
CI / build-and-test (push) Successful in 2m19s
feat: editable properties
2026-03-09 13:24:39 +13:00

90 lines
2.8 KiB
C++

#pragma once
#include "rlImGui.h"
#include "imgui.h"
#include "extras/IconsFontAwesome6.h"
#include "gui/fa-solid-900.h"
#include "gui/ImGuiNotify.hpp"
#include "LogWindow.h" // Include the new LogWindow class
#include <entt.hpp>
#include <string>
#include <unordered_map>
#include <vector>
#include <filesystem>
class Application;
class GuiManager {
public:
GuiManager();
~GuiManager();
void Initialize(Application* application);
void Render(RenderTexture2D& renderTexture);
void ApplyRenderTextureResize(RenderTexture2D& renderTexture);
void Shutdown();
private:
void SetupDockspace(RenderTexture2D& renderTexture);
void RenderNotifications();
void RenderErrorBanner();
void SetTheme();
void RenderSceneWindow();
void RenderInspectorWindow();
void RenderEntityNode(entt::entity entity);
bool IsEntityAncestor(entt::entity ancestor, entt::entity entity) const;
const char* GetEntityLabel(entt::entity entity);
struct ScriptEditableFieldMeta {
std::string name;
std::string type;
bool hasRange = false;
float rangeMin = 0.0f;
float rangeMax = 1.0f;
std::vector<std::string> options;
};
struct ScriptEditableCache {
std::string className;
std::vector<ScriptEditableFieldMeta> fields;
std::filesystem::file_time_type lastWriteTime;
bool hasWriteTime = false;
};
enum class ScriptValueKind { Float, Int, Bool, String };
struct ScriptEditableValue {
ScriptValueKind kind = ScriptValueKind::Float;
bool hasValue = false;
float f = 0.0f;
int i = 0;
bool b = false;
std::string s;
};
void SyncTagBuffer(entt::entity entity);
void SyncScriptPathBuffer(entt::entity entity);
void RenderScriptEditableControls(entt::entity entity);
ScriptEditableCache &GetOrParseEditableCache(const std::string &path, const std::string &className);
bool showLogWindow = true;
bool showSceneWindow = true;
bool showInspectorWindow = true;
Application *app;
LogWindow logWindow; // Add LogWindow as a member
entt::entity selectedEntity = entt::null;
entt::entity tagBufferEntity = entt::null;
char tagBuffer[128] = {0};
entt::entity scriptPathEntity = entt::null;
char scriptPathBuffer[260] = {0};
char sceneScriptPathBuffer[260] = {0};
std::string lastSceneScriptPath;
ImVec2 desiredRenderSize = ImVec2(0.0f, 0.0f);
bool requestSceneNew = false;
bool requestSceneLoad = false;
bool requestSceneSave = false;
char sceneLoadPath[260] = {0};
char sceneSavePath[260] = {0};
int addComponentIndex = 0;
std::unordered_map<std::string, ScriptEditableCache> scriptEditableCache;
std::unordered_map<entt::entity, std::unordered_map<std::string, ScriptEditableValue>> scriptEditableStaged;
};