mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-06-19 11:16:37 +02:00
fix entt update
This commit is contained in:
@ -94,9 +94,9 @@ public:
|
||||
ComponentInfo& registerComponent(const ComponentInfo& component_info)
|
||||
{
|
||||
auto index = entt::type_hash<Component>::value();
|
||||
auto [it, insert_result] = component_infos.insert_or_assign(index, component_info);
|
||||
MM_IEEE_ASSERT(insert_result);
|
||||
return std::get<ComponentInfo>(*it);
|
||||
auto insert_info = component_infos.insert_or_assign(index, component_info);
|
||||
MM_IEEE_ASSERT(insert_info.second);
|
||||
return std::get<ComponentInfo>(*insert_info.first);
|
||||
}
|
||||
|
||||
template <class Component>
|
||||
|
@ -65,44 +65,9 @@ bool ImGuiService::enable(Engine& engine) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: register event handle
|
||||
_event_handle = sdl_ss.addEventHandler([](const SDL_Event& e) {
|
||||
if (!ImGui_ImplSDL2_ProcessEvent(&e)) {
|
||||
return false; // if the event was not relevant to imgui anyway
|
||||
}
|
||||
|
||||
auto& io = ImGui::GetIO();
|
||||
// keyboard
|
||||
if ((
|
||||
e.type == SDL_KEYDOWN ||
|
||||
e.type == SDL_KEYUP ||
|
||||
e.type == SDL_TEXTEDITING ||
|
||||
e.type == SDL_TEXTINPUT
|
||||
)
|
||||
&& io.WantCaptureKeyboard) {
|
||||
return true;
|
||||
}
|
||||
// mouse
|
||||
if ((
|
||||
e.type == SDL_MOUSEMOTION ||
|
||||
e.type == SDL_MOUSEBUTTONUP ||
|
||||
e.type == SDL_MOUSEBUTTONDOWN ||
|
||||
e.type == SDL_MOUSEWHEEL // ????
|
||||
)
|
||||
&& io.WantCaptureMouse) {
|
||||
return true;
|
||||
}
|
||||
//// controller ???
|
||||
//if ((
|
||||
//e.type == SDL_CONTROLLERBUTTONUP ||
|
||||
//e.type == SDL_CONTROLLERBUTTONDOWN
|
||||
//)[>
|
||||
//&& io.WantCaptureKeyboard*/) {
|
||||
//return false;
|
||||
//}
|
||||
|
||||
return false;
|
||||
});
|
||||
_event_handle = sdl_ss.addEventHandler(
|
||||
[this](const SDL_Event& e) { return handle_sdl_event(e); }
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -121,6 +86,7 @@ void ImGuiService::disable(Engine& engine) {
|
||||
}
|
||||
|
||||
std::vector<UpdateStrategies::UpdateCreationInfo> ImGuiService::registerUpdates(void) {
|
||||
using namespace entt::literals;
|
||||
return {
|
||||
{
|
||||
"ImGuiService::new_frame"_hs,
|
||||
@ -144,5 +110,43 @@ void ImGuiService::imgui_new_frame(Engine& engine) {
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
||||
bool ImGuiService::handle_sdl_event(const SDL_Event& e) {
|
||||
if (!ImGui_ImplSDL2_ProcessEvent(&e)) {
|
||||
return false; // if the event was not relevant to imgui anyway
|
||||
}
|
||||
|
||||
auto& io = ImGui::GetIO();
|
||||
// keyboard
|
||||
if ((
|
||||
e.type == SDL_KEYDOWN ||
|
||||
e.type == SDL_KEYUP ||
|
||||
e.type == SDL_TEXTEDITING ||
|
||||
e.type == SDL_TEXTINPUT
|
||||
)
|
||||
&& io.WantCaptureKeyboard) {
|
||||
return true;
|
||||
}
|
||||
// mouse
|
||||
if ((
|
||||
e.type == SDL_MOUSEMOTION ||
|
||||
e.type == SDL_MOUSEBUTTONUP ||
|
||||
e.type == SDL_MOUSEBUTTONDOWN ||
|
||||
e.type == SDL_MOUSEWHEEL // ????
|
||||
)
|
||||
&& io.WantCaptureMouse) {
|
||||
return true;
|
||||
}
|
||||
//// controller ???
|
||||
//if ((
|
||||
//e.type == SDL_CONTROLLERBUTTONUP ||
|
||||
//e.type == SDL_CONTROLLERBUTTONDOWN
|
||||
//)[>
|
||||
//&& io.WantCaptureKeyboard*/) {
|
||||
//return false;
|
||||
//}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace MM::Services
|
||||
|
||||
|
@ -23,6 +23,8 @@ namespace MM::Services {
|
||||
|
||||
private:
|
||||
void imgui_new_frame(Engine& engine);
|
||||
|
||||
bool handle_sdl_event(const SDL_Event& e);
|
||||
};
|
||||
|
||||
} // namespace MM::Services
|
||||
|
@ -203,6 +203,7 @@ namespace MM::Services {
|
||||
}
|
||||
|
||||
std::vector<UpdateStrategies::UpdateCreationInfo> ImGuiSceneToolsService::registerUpdates(void) {
|
||||
using namespace entt::literals;
|
||||
return {
|
||||
{
|
||||
"ImGuiSceneToolsService::render"_hs,
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
static char* argv0;
|
||||
|
||||
using namespace entt::literals;
|
||||
|
||||
TEST(imgui_scene_tools, it) {
|
||||
MM::Engine engine;
|
||||
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
const char* argv0;
|
||||
|
||||
using namespace entt::literals;
|
||||
|
||||
class ImGuiSpeechy : public MM::Services::Service {
|
||||
private:
|
||||
SoLoud::Speech speech;
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
static char* argv0;
|
||||
|
||||
using namespace entt::literals;
|
||||
|
||||
class TemplateUpdateMainService : public MM::Services::Service {
|
||||
std::function<void(MM::Engine&)> _fn;
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
const char* argv0;
|
||||
|
||||
using namespace entt::literals;
|
||||
|
||||
TEST(imgui_widgets, basic) {
|
||||
MM::Engine engine;
|
||||
|
||||
|
Reference in New Issue
Block a user