SpiecsEngine
 
Loading...
Searching...
No Matches
SlateInfoBar.h
Go to the documentation of this file.
1/**
2* @file SlateInfoBar.h.
3* @brief The SlateInfoBar Class Definitions.
4* @author Spices.
5*/
6
7#pragma once
8#include "Core/Core.h"
9#include "Systems/SlateSystem.h"
10#include "Slate/Imgui/ImguiInfoBar.h"
11
12namespace Spices {
13
14 /**
15 * @brief This Class defines InfoBar instance.
16 */
18 {
19 public:
20
21 /**
22 * @brief InfoBar Type.
23 */
24 enum class Type
25 {
27 count
28 };
29
30 public:
31
32 /**
33 * @brief Constructor Function.
34 * @param[in] info InfoBar info content.
35 * @param[in] rateFunc InfoBar progress rate.
36 * @param[in] type InfoBar Type.
37 */
38 SlateInfoBar(const std::string& info, std::function<std::any()>& rateFunc, std::function<bool(SlateInfoBar*)>& destroyFunc, Type type)
39 : m_Info(info)
42 , m_Type(type)
43 {}
44
45 /**
46 * @brief Destructor Function.
47 */
48 virtual ~SlateInfoBar() = default;
49
50 /**
51 * @brief Create InfoBar Instance, and registy to Slate.
52 * @tparam R InfoBar return type.
53 * @param[in] info InfoBar info content.
54 * @param[in] rateFunc InfoBar progress rate.
55 * @param[in] destroyFunc InfoBar destroy condition.
56 */
57 template<typename R>
58 static void Create(const std::string& info, std::function<std::any()> rateFunc, std::function<bool(SlateInfoBar*)> destroyFunc = nullptr);
59
60 /**
61 * @brief Get this InfoBar info content.
62 * @return Returns this InfoBar info content.
63 */
64 const std::string& GetInfo() { return m_Info; }
65
66 /**
67 * @brief Get this InfoBar info progress rate.
68 * @return Returns this InfoBar info progress rate.
69 */
71 {
72 assert(m_RateFunc);
73 return m_RateFunc();
74 }
75
76 /**
77 * @brief Determine if this slate info bar needs to be destroy.
78 * @return Returns true if this slate info bar needs to be destroy.
79 */
80 bool IsDestroy()
81 {
82 if (m_DestroyFunc)
83 {
84 return m_DestroyFunc(this);
85 }
86 else
87 {
88 return false;
89 }
90 }
91
92 /**
93 * @brief Get this type.
94 * @return Returns this type.
95 */
96 Type GetType() const { return m_Type; }
97
98 private:
99
100 /**
101 * @brief this InfoBar info content.
102 */
103 std::string m_Info;
104
105 /**
106 * @brief InfoBar progress rate function.
107 */
109
110 /**
111 * @brief InfoBar progress destroy function.
112 */
113 std::function<bool(SlateInfoBar*)> m_DestroyFunc;
114
115 /**
116 * @brief InfoBar Type.
117 */
119
120 };
121
122 template<typename R>
123 inline void SlateInfoBar::Create(const std::string& info, std::function<std::any()> rateFunc, std::function<bool(SlateInfoBar*)> destroyFunc)
124 {
126
127 auto ptr = dynamic_cast<ImguiInfoBar*>(SlateSystem::GetRegister()->GetSlate("InfoBar").get());
128
129 if constexpr (std::is_same_v<R, float>)
130 {
131 ptr->Push(std::make_shared<SlateInfoBar>(info, rateFunc, destroyFunc, Type::progress));
132 }
133 else if constexpr (std::is_same_v<R, int>)
134 {
135 ptr->Push(std::make_shared<SlateInfoBar>(info, rateFunc, destroyFunc, Type::count));
136 }
137 }
138}
#define SPICES_PROFILE_ZONE
EntityComponent Class. This class defines the specific behaves of EntityComponent.
Entity Class. This class defines the specific behaves of Entity.
Definition Entity.h:20
Wrapper of Gltf Json Accessors.
Wrapper of Gltf Json BufferViews.
Wrapper of Gltf Json Buffers.
Definition GltfBuffers.h:17
Entity CreateEntityRecursive(World *world, const std::string &tag, uint32_t node, const glm::mat4 &model, std::shared_ptr< LoadingState > loadingState)
Create Entity recursive from gltf file nodes.
GltfCollection(const std::string &path)
Constructor Function.
void CreateEntity(World *world, const std::string &tag, Transform transform={})
Create Entity instance from gltf file.
Wrapper of Gltf file data.
Wrapper of Gltf Json Images.
Definition GltfImages.h:21
static bool Load(const std::string &fileName, GltfCollection *collection)
Load a gltf file to GltfCollection.
static bool LoadPack(GltfPack *pack, const GltfMeshes::Primitive &primitive, GltfAccessors *accessors, GltfBuffers *buffers, GltfBufferViews *bufferViews)
Load a gltf mesh to GltfPack.
static std::shared_ptr< Material > LoadMaterial(const GltfMaterials::Item &material, GltfImages *images)
Load a Material from Gltf file material component.
Loader of load gltf file or items.
Definition GltfLoader.h:23
Wrapper of Gltf Json Materials.
Wrapper of Gltf Json Meshes.
Definition GltfMeshes.h:17
Wrapper of Gltf Json Nodes.
Definition GltfNodes.h:19
std::function< void(GltfPack *) m_Func)
function pointer of createPack.
Definition GltfPack.h:52
GltfPack(const std::string &name, const std::function< void(GltfPack *)> &f, bool instanced=true)
Constructor Function.
Definition GltfPack.h:28
virtual ~GltfPack() override=default
Destructor Function.
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific meshPack data.
Definition GltfPack.cpp:13
GltfPack Class. This class defines gltf type meshPack.
Definition GltfPack.h:19
Material Class. This class contains a branch of parameter and shader, also descriptor.
Definition Material.h:62
MeshComponent Class. This class defines the specific behaves of MeshComponent.
MeshPack(const std::string &name, bool instanced)
Constructor Function.
Definition MeshPack.cpp:78
std::string m_PackType
specific mesh pack type.
Definition MeshPack.h:363
MeshPack Class. This class defines some basic behaves and variables. This class need to be inherited ...
Definition MeshPack.h:156
Builder Class. This class helps to create a mesh.
Definition Mesh.h:29
MeshRenderer Class. This class is a wrapper of mashpack.
Definition Mesh.h:21
virtual ~SlateInfoBar()=default
Destructor Function.
std::function< std::any()> m_RateFunc
InfoBar progress rate function.
Type GetType() const
Get this type.
SlateInfoBar(const std::string &info, std::function< std::any()> &rateFunc, std::function< bool(SlateInfoBar *)> &destroyFunc, Type type)
Constructor Function.
static void Create(const std::string &info, std::function< std::any()> rateFunc, std::function< bool(SlateInfoBar *)> destroyFunc=nullptr)
Create InfoBar Instance, and registy to Slate.
std::any GetRate()
Get this InfoBar info progress rate.
const std::string & GetInfo()
Get this InfoBar info content.
bool IsDestroy()
Determine if this slate info bar needs to be destroy.
Type m_Type
InfoBar Type.
std::string m_Info
this InfoBar info content.
std::function< bool(SlateInfoBar *) m_DestroyFunc)
InfoBar progress destroy function.
This Class defines InfoBar instance.
TransformComponent Class. This class defines the specific behaves of TransformComponent.
void Mark(WorldMarkFlags flags)
Mark WorldMarkFlags with flags.
Definition World.h:125
Entity CreateEntity(const std::string &name="None")
Create a new empty entity in this world.
Definition World.cpp:13
@ MeshAddedToWorld
Definition World.h:47
World Class. This class defines the basic behaves of World. When we create an new world,...
Definition World.h:41
Materials Item data.
Primitive Item data.
Definition GltfMeshes.h:24
Nodes Item data.
Definition GltfNodes.h:26
Wrapper of 3D Transform.
Definition Transform.h:16