Files
simian/include/gui/GuiManager.h
nick 3e23f7da8e
CI / build-and-test (push) Failing after 10m16s
CI / build-and-test (pull_request) Successful in 3m2s
feat: added physFS
2026-03-11 16:43:36 +13:00

155 lines
4.7 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 "raylib.h"
#include <entt.hpp>
#include <string>
#include <unordered_map>
#include <vector>
#include <cstdint>
class Application;
class GuiManager {
public:
GuiManager();
~GuiManager();
void Initialize(Application* application);
void Render(RenderTexture2D& renderTexture);
void ApplyRenderTextureResize(RenderTexture2D& renderTexture);
void Shutdown();
private:
enum class AssetUnloadType {
None,
Texture,
Shader,
Model,
Material
};
void SetupDockspace(RenderTexture2D& renderTexture);
void RenderNotifications();
void RenderErrorBanner();
void SetTheme();
void RenderSceneWindow();
void RenderAssetWindow();
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;
std::string group;
std::string description;
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::int64_t lastWriteTime = 0;
bool hasWriteTime = false;
};
enum class ScriptValueKind { Float, Int, Bool, String };
struct ScriptEditableValue {
ScriptValueKind kind = ScriptValueKind::Float;
bool hasValue = false;
bool hasBaseline = false;
float f = 0.0f;
float baselineF = 0.0f;
int i = 0;
int baselineI = 0;
bool b = false;
bool baselineB = false;
std::string s;
std::string baselineS;
};
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;
bool showAssetWindow = false;
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);
ImGuiID mainDockspaceId = 0;
bool requestSceneNew = false;
bool requestSceneLoad = false;
bool requestSceneSave = false;
char sceneLoadPath[260] = {0};
char sceneSavePath[260] = {0};
int addComponentIndex = 0;
char textureKeyBuffer[128] = {0};
char texturePathBuffer[260] = {0};
int textureUnloadIndex = 0;
char shaderKeyBuffer[128] = {0};
char shaderVsPathBuffer[260] = {0};
char shaderFsPathBuffer[260] = {0};
int shaderUnloadIndex = 0;
char modelKeyBuffer[128] = {0};
char modelPathBuffer[260] = {0};
char modelHeightmapPathBuffer[260] = {0};
char modelCubicmapPathBuffer[260] = {0};
int modelUnloadIndex = 0;
int modelPrimitiveIndex = 0;
float modelWidth = 1.0f;
float modelHeight = 1.0f;
float modelLength = 1.0f;
float modelRadius = 0.5f;
int modelRings = 16;
int modelSlices = 16;
int modelResX = 1;
int modelResZ = 1;
int modelRadSeg = 16;
int modelSides = 8;
int modelPolySides = 6;
float modelSizeX = 1.0f;
float modelSizeY = 1.0f;
float modelSizeZ = 1.0f;
int modelAutoKeyCounter = 0;
char materialKeyBuffer[128] = {0};
int materialUnloadIndex = 0;
int materialShaderIndex = 0;
int materialShaderId = 0;
float materialAlbedo[4] = {1.0f, 1.0f, 1.0f, 1.0f};
AssetUnloadType pendingAssetUnloadType = AssetUnloadType::None;
std::string pendingAssetUnloadKey;
Vector3 editorCameraPivot = {0.0f, 0.0f, 0.0f};
Vector3 editorPivotOffset = {0.0f, 0.0f, 0.0f};
entt::entity editorPivotEntity = entt::null;
bool editorPivotInitialized = false;
std::unordered_map<std::string, ScriptEditableCache> scriptEditableCache;
std::unordered_map<entt::entity, std::unordered_map<std::string, ScriptEditableValue>> scriptEditableStaged;
std::unordered_map<entt::entity, void*> scriptEditableInstancePtr;
};