-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewSystem.cpp
42 lines (31 loc) · 1006 Bytes
/
NewSystem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "kengine.hpp"
#include "Export.hpp"
#include "helpers/pluginHelper.hpp"
#include "data/NameComponent.hpp"
#include "data/ImGuiToolComponent.hpp"
#include "data/ImGuiScaleComponent.hpp"
#include "functions/Execute.hpp"
#include "imgui.h"
// can use this function to properly scale child windows and other elements
static float getScale() noexcept;
EXPORT void loadKenginePlugin(void * state) noexcept {
kengine::pluginHelper::initPlugin(state);
kengine::entities += [&](kengine::Entity & e) {
e += kengine::NameComponent{ "New System" };
auto & tool = e.attach<kengine::ImGuiToolComponent>();
tool.enabled = false;
e += kengine::functions::Execute{ [&](float deltaTime) noexcept {
if (!tool.enabled)
return;
if (ImGui::Begin("NewSystem", &tool.enabled)) {
}
ImGui::End();
}};
};
}
static float getScale() noexcept {
float ret = 1.f;
for (const auto & [e, scale] : kengine::entities.with<kengine::ImGuiScaleComponent>())
ret *= scale.scale;
return ret;
}