Elevate Engine 1
Loading...
Searching...
No Matches
EEObject.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <glm/vec4.hpp>
5
6// Category class declaration and macro definition
8{
9public:
11 EECategory(const std::string& path) :
12 m_path(path), m_name(GenerateName()), m_depth(GenerateDepth()) { }
13 EECategory(const EECategory& other)
14 : m_depth(other.m_depth), m_name(other.m_name), m_path(other.m_path) { }
15
16 inline const std::string& GetName() const
17 {
18 return m_name;
19 }
20
21 inline const std::string& GetPath() const
22 {
23 return m_path;
24 }
25
26 inline size_t GetDepth()
27 {
28 return m_depth;
29 }
30
31 bool operator<(const EECategory& other) const
32 {
33 return m_path < other.m_path;
34 }
35
36 bool operator==(const EECategory& other) const
37 {
38 return m_path == other.m_path;
39 }
40
41 glm::vec4 GetCategoryColor() {
42 if (m_path == "Physics") return glm::vec4(0.3f, 0.6f, 0.3f, 1.0f); // Dark Vibrant Green
43 if (m_path == "Rendering") return glm::vec4(0.7f, 0.4f, 0.2f, 1.0f); // Dark Vibrant Orange
44 if (m_path == "Audio") return glm::vec4(0.3f, 0.5f, 0.8f, 1.0f); // Dark Vibrant Blue
45 if (m_path == "Script") return glm::vec4(0.6f, 0.3f, 0.7f, 1.0f); // Dark Vibrant Purple
46 if (m_path == "Transform") return glm::vec4(0.9f, 0.9f, 0.3f, 1.0f); // Bright Yellow
47 return glm::vec4(0.2f, 0.3f, 0.4f, 1.0f); // Dark Blue-Grey for Default
48 }
49
50 inline std::string GetNameAtDepth(size_t index) const
51 {
52 size_t start = 0;
53 size_t end = m_path.find('/');
54
55 for (size_t i = 0; i < index; i++)
56 {
57 if (end == std::string::npos)
58 {
59 return "";
60 }
61 start = end + 1;
62 end = m_path.find('/', start);
63 }
64
65 if (end == std::string::npos)
66 {
67 return m_path.substr(start);
68 }
69 else
70 {
71 return m_path.substr(start, end - start);
72 }
73 }
74
75private:
76 inline std::string GenerateName() const
77 {
78 if (m_path.empty())
79 {
80 return "Default";
81 }
82
83 size_t i = m_path.find_last_of('/');
84 if (i == std::string::npos)
85 {
86 return m_path;
87 }
88
89 return m_path.substr(i + 1);
90 }
91
92 inline size_t GenerateDepth() const
93 {
94 size_t count = 0;
95 for (auto& c : m_path)
96 {
97 if (c == '/')
98 {
99 count++;
100 }
101 }
102 return count;
103 }
104private:
105 std::string m_path;
106 std::string m_name;
107 size_t m_depth;
108};
109
111{
112protected:
114public:
115 virtual EECategory GetCategory() const { return m_category; }
116};
glm::vec4 GetCategoryColor()
Definition EEObject.h:41
EECategory(const std::string &path)
Definition EEObject.h:11
bool operator==(const EECategory &other) const
Definition EEObject.h:36
EECategory(const EECategory &other)
Definition EEObject.h:13
const std::string & GetPath() const
Definition EEObject.h:21
bool operator<(const EECategory &other) const
Definition EEObject.h:31
size_t GetDepth()
Definition EEObject.h:26
std::string GetNameAtDepth(size_t index) const
Definition EEObject.h:50
const std::string & GetName() const
Definition EEObject.h:16
virtual EECategory GetCategory() const
Definition EEObject.h:115
EECategory m_category
Definition EEObject.h:113