reworked the general update strategy interface

This commit is contained in:
2021-04-28 19:38:25 +02:00
parent b8a5cd7cf4
commit efad254193
53 changed files with 756 additions and 889 deletions

View File

@@ -7,6 +7,7 @@
#include <mm/engine.hpp>
#include "./imgui_menu_bar.hpp"
#include "mm/components/time_delta.hpp"
#include "mm/services/service.hpp"
#include <imgui/imgui.h>
@@ -36,7 +37,7 @@
namespace MM::Services {
bool ImGuiSceneToolsService::enable(Engine& engine) {
bool ImGuiSceneToolsService::enable(Engine& engine, std::vector<UpdateStrategies::TaskInfo>& task_array) {
if (!engine.tryService<MM::Services::SceneServiceInterface>()) {
LOGIGS("error: no SceneServiceInterface");
return false;
@@ -82,6 +83,13 @@ namespace MM::Services {
ImGui::MenuItem("TimeDelta Context", NULL, &_show_time_delta_ctx, td_ptr);
};
// add task
task_array.push_back(
UpdateStrategies::TaskInfo{"ImGuiSceneToolsService::render"}
.fn([this](Engine& e){ renderImGui(e); })
.succeed("ImGuiMenuBar::render")
);
return true;
}
@@ -94,22 +102,6 @@ namespace MM::Services {
menu_bar.menu_tree["Scene"].erase("TimeCtx");
}
std::vector<UpdateStrategies::UpdateCreationInfo> ImGuiSceneToolsService::registerUpdates(void) {
using namespace entt::literals;
return {
{
"ImGuiSceneToolsService::render"_hs,
"ImGuiSceneToolsService::render",
[this](Engine& e){ renderImGui(e); },
UpdateStrategies::update_phase_t::MAIN,
true,
{
"ImGuiMenuBar::render"_hs
}
}
};
}
void ImGuiSceneToolsService::renderImGui(Engine& engine) {
auto& scene = engine.tryService<MM::Services::SceneServiceInterface>()->getScene();