Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
ComponentPalettePanel.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include <map>
7
8namespace Olympe
9{
10 // Available component types that can be added to entity prefabs
12 {
13 std::string name;
14 std::string category;
15 std::string description;
16
17 ComponentType() = default;
18 ComponentType(const std::string& n, const std::string& c, const std::string& d = "")
19 : name(n), category(c), description(d) { }
20 };
21
23 {
24 public:
27
28 // Initialize with available components
29 void Initialize();
30
31 // Render the palette panel
33
34 // Get list of registered component types
35 const std::vector<ComponentType>& GetComponentTypes() const;
36
37 // Add a component type to the palette
38 void RegisterComponentType(const std::string& name, const std::string& category, const std::string& description = "");
39
40 // Load components from JSON file (./Gamedata/PrefabEntities/ComponentsParameters.json)
41 bool LoadComponentsFromJSON(const std::string& filepath);
42
43 private:
44 // ========== UI Styling Constants (Dense Layout) ==========
45 static constexpr float CATEGORY_HEADER_HEIGHT = 22.0f;
46 static constexpr float COMPONENT_ITEM_HEIGHT = 18.0f;
47 static constexpr float COMPONENT_ITEM_PADDING_X = 5.0f;
48 static constexpr float COMPONENT_ITEM_PADDING_Y = 2.0f;
49
50 std::vector<ComponentType> m_componentTypes;
51 std::vector<std::string> m_categories;
52 std::vector<bool> m_categoryExpanded; // Track expanded/collapsed state for each category
53 std::string m_searchFilter;
55 char m_searchBuffer[256];
56 char m_draggedComponentBuffer[256]; // Buffer for drag-drop payload (must be stable)
57
58 // Utility methods
59 void RenderSearchBar();
61 void RenderCategoryTabs();
63
64 // Category extraction from component type name
65 std::string ExtractCategoryFromComponentType(const std::string& componentType);
66 };
67}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
std::vector< ComponentType > m_componentTypes
void Render(EntityPrefabGraphDocument *document)
void RegisterComponentType(const std::string &name, const std::string &category, const std::string &description="")
static constexpr float COMPONENT_ITEM_HEIGHT
void AddComponentToGraph(EntityPrefabGraphDocument *document, const ComponentType &componentType)
bool LoadComponentsFromJSON(const std::string &filepath)
void RenderComponentList(EntityPrefabGraphDocument *document)
static constexpr float CATEGORY_HEADER_HEIGHT
std::vector< std::string > m_categories
static constexpr float COMPONENT_ITEM_PADDING_X
const std::vector< ComponentType > & GetComponentTypes() const
static constexpr float COMPONENT_ITEM_PADDING_Y
std::string ExtractCategoryFromComponentType(const std::string &componentType)
< Provides AssetID and INVALID_ASSET_ID
ComponentType(const std::string &n, const std::string &c, const std::string &d="")