mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-04-08 05:42:59 +02:00
fix entt update
This commit is contained in:
parent
f62ed43209
commit
1d59003858
@ -11,6 +11,8 @@
|
|||||||
using ::testing::Return;
|
using ::testing::Return;
|
||||||
using ::testing::_;
|
using ::testing::_;
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
class MockService : public MM::Services::Service {
|
class MockService : public MM::Services::Service {
|
||||||
public:
|
public:
|
||||||
const char* name(void) override { return "MockService"; }
|
const char* name(void) override { return "MockService"; }
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
using ::testing::Return;
|
using ::testing::Return;
|
||||||
using ::testing::_;
|
using ::testing::_;
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
class MockUpdateStrategy : public MM::UpdateStrategies::UpdateStrategy {
|
class MockUpdateStrategy : public MM::UpdateStrategies::UpdateStrategy {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD(
|
MOCK_METHOD(
|
||||||
|
@ -94,9 +94,9 @@ public:
|
|||||||
ComponentInfo& registerComponent(const ComponentInfo& component_info)
|
ComponentInfo& registerComponent(const ComponentInfo& component_info)
|
||||||
{
|
{
|
||||||
auto index = entt::type_hash<Component>::value();
|
auto index = entt::type_hash<Component>::value();
|
||||||
auto [it, insert_result] = component_infos.insert_or_assign(index, component_info);
|
auto insert_info = component_infos.insert_or_assign(index, component_info);
|
||||||
MM_IEEE_ASSERT(insert_result);
|
MM_IEEE_ASSERT(insert_info.second);
|
||||||
return std::get<ComponentInfo>(*it);
|
return std::get<ComponentInfo>(*insert_info.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Component>
|
template <class Component>
|
||||||
|
@ -65,44 +65,9 @@ bool ImGuiService::enable(Engine& engine) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: register event handle
|
_event_handle = sdl_ss.addEventHandler(
|
||||||
_event_handle = sdl_ss.addEventHandler([](const SDL_Event& e) {
|
[this](const SDL_Event& e) { return handle_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;
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -121,6 +86,7 @@ void ImGuiService::disable(Engine& engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UpdateStrategies::UpdateCreationInfo> ImGuiService::registerUpdates(void) {
|
std::vector<UpdateStrategies::UpdateCreationInfo> ImGuiService::registerUpdates(void) {
|
||||||
|
using namespace entt::literals;
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"ImGuiService::new_frame"_hs,
|
"ImGuiService::new_frame"_hs,
|
||||||
@ -144,5 +110,43 @@ void ImGuiService::imgui_new_frame(Engine& engine) {
|
|||||||
ImGui::NewFrame();
|
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
|
} // namespace MM::Services
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ namespace MM::Services {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void imgui_new_frame(Engine& engine);
|
void imgui_new_frame(Engine& engine);
|
||||||
|
|
||||||
|
bool handle_sdl_event(const SDL_Event& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace MM::Services
|
} // namespace MM::Services
|
||||||
|
@ -203,6 +203,7 @@ namespace MM::Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UpdateStrategies::UpdateCreationInfo> ImGuiSceneToolsService::registerUpdates(void) {
|
std::vector<UpdateStrategies::UpdateCreationInfo> ImGuiSceneToolsService::registerUpdates(void) {
|
||||||
|
using namespace entt::literals;
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"ImGuiSceneToolsService::render"_hs,
|
"ImGuiSceneToolsService::render"_hs,
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
static char* argv0;
|
static char* argv0;
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
TEST(imgui_scene_tools, it) {
|
TEST(imgui_scene_tools, it) {
|
||||||
MM::Engine engine;
|
MM::Engine engine;
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
const char* argv0;
|
const char* argv0;
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
class ImGuiSpeechy : public MM::Services::Service {
|
class ImGuiSpeechy : public MM::Services::Service {
|
||||||
private:
|
private:
|
||||||
SoLoud::Speech speech;
|
SoLoud::Speech speech;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
static char* argv0;
|
static char* argv0;
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
class TemplateUpdateMainService : public MM::Services::Service {
|
class TemplateUpdateMainService : public MM::Services::Service {
|
||||||
std::function<void(MM::Engine&)> _fn;
|
std::function<void(MM::Engine&)> _fn;
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
const char* argv0;
|
const char* argv0;
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
TEST(imgui_widgets, basic) {
|
TEST(imgui_widgets, basic) {
|
||||||
MM::Engine engine;
|
MM::Engine engine;
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@ void InputService::disable(Engine& engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UpdateStrategies::UpdateCreationInfo> InputService::registerUpdates(void) {
|
std::vector<UpdateStrategies::UpdateCreationInfo> InputService::registerUpdates(void) {
|
||||||
|
using namespace entt::literals;
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"InputService::update"_hs,
|
"InputService::update"_hs,
|
||||||
|
@ -47,6 +47,7 @@ class InputVisualizer : public MM::Services::Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<MM::UpdateStrategies::UpdateCreationInfo> registerUpdates(void) override {
|
std::vector<MM::UpdateStrategies::UpdateCreationInfo> registerUpdates(void) override {
|
||||||
|
using namespace entt::literals;
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"InputVisualizer::render"_hs,
|
"InputVisualizer::render"_hs,
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
namespace MM::Services {
|
namespace MM::Services {
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
OpenGLRenderer::OpenGLRenderer(void) {
|
OpenGLRenderer::OpenGLRenderer(void) {
|
||||||
MM::Logger::initSectionLogger("OpenGL");
|
MM::Logger::initSectionLogger("OpenGL");
|
||||||
MM::Logger::initSectionLogger("OpenGLRenderer");
|
MM::Logger::initSectionLogger("OpenGLRenderer");
|
||||||
@ -71,8 +73,8 @@ bool OpenGLRenderer::enable(Engine& engine) {
|
|||||||
_sdl_event_handle = sdl_s.addEventHandler([this, &engine](const SDL_Event& e) -> bool {
|
_sdl_event_handle = sdl_s.addEventHandler([this, &engine](const SDL_Event& e) -> bool {
|
||||||
if (e.type == SDL_WINDOWEVENT) {
|
if (e.type == SDL_WINDOWEVENT) {
|
||||||
if (e.window.event == SDL_WINDOWEVENT_RESIZED || e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
if (e.window.event == SDL_WINDOWEVENT_RESIZED || e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||||
auto& sdl_s = engine.getService<MM::Services::SDLService>();
|
auto& sdl = engine.getService<MM::Services::SDLService>();
|
||||||
auto new_window_size = sdl_s.getWindowSize();
|
auto new_window_size = sdl.getWindowSize();
|
||||||
glViewport(0, 0, new_window_size.first, new_window_size.second);
|
glViewport(0, 0, new_window_size.first, new_window_size.second);
|
||||||
|
|
||||||
// TODO: recreate fbos, dirvers seem to have problems otherwise
|
// TODO: recreate fbos, dirvers seem to have problems otherwise
|
||||||
@ -111,7 +113,6 @@ bool OpenGLRenderer::enable(Engine& engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // default texures
|
{ // default texures
|
||||||
using namespace entt::literals;
|
|
||||||
auto& rm_t = MM::ResourceManager<MM::OpenGL::Texture>::ref();
|
auto& rm_t = MM::ResourceManager<MM::OpenGL::Texture>::ref();
|
||||||
if (!rm_t.contains("default"_hs)) {
|
if (!rm_t.contains("default"_hs)) {
|
||||||
if (!rm_t.load<MM::OpenGL::TextureLoaderConstBuffer>("default", default_png, default_png_len)) {
|
if (!rm_t.load<MM::OpenGL::TextureLoaderConstBuffer>("default", default_png, default_png_len)) {
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include <physfs.h>
|
#include <physfs.h>
|
||||||
#include "res/textures.zip.h"
|
#include "res/textures.zip.h"
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
const char* argv0;
|
const char* argv0;
|
||||||
|
|
||||||
TEST(batched_spritesheet_render_task, it) {
|
TEST(batched_spritesheet_render_task, it) {
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
const char* argv0;
|
const char* argv0;
|
||||||
|
|
||||||
TEST(blur_render_task, it) {
|
TEST(blur_render_task, it) {
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
TEST(imgui_render_task, demowindow) {
|
TEST(imgui_render_task, demowindow) {
|
||||||
MM::Engine engine;
|
MM::Engine engine;
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
const char* argv0;
|
const char* argv0;
|
||||||
|
|
||||||
TEST(simple_sprite_render_task, it) {
|
TEST(simple_sprite_render_task, it) {
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include <physfs.h>
|
#include <physfs.h>
|
||||||
#include "res/textures.zip.h"
|
#include "res/textures.zip.h"
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
TEST(simple_spritesheet_render_task, it) {
|
TEST(simple_spritesheet_render_task, it) {
|
||||||
MM::Engine engine;
|
MM::Engine engine;
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include <mm/opengl/texture_loader.hpp>
|
#include <mm/opengl/texture_loader.hpp>
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
TEST(tilemap_render_task_test, it) {
|
TEST(tilemap_render_task_test, it) {
|
||||||
MM::Engine engine;
|
MM::Engine engine;
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include <entt/resource/cache.hpp>
|
#include <entt/resource/cache.hpp>
|
||||||
|
|
||||||
|
using namespace entt::literals; // :D
|
||||||
|
|
||||||
// disable, this just tests entt and not MM
|
// disable, this just tests entt and not MM
|
||||||
#if 0
|
#if 0
|
||||||
TEST(EngineResourceManagerTest, entt_cache) {
|
TEST(EngineResourceManagerTest, entt_cache) {
|
||||||
|
@ -26,6 +26,7 @@ void ScreenDirector::disable(MM::Engine&) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UpdateStrategies::UpdateCreationInfo> ScreenDirector::registerUpdates(void) {
|
std::vector<UpdateStrategies::UpdateCreationInfo> ScreenDirector::registerUpdates(void) {
|
||||||
|
using namespace entt::literals;
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"ScreenDirector::update"_hs,
|
"ScreenDirector::update"_hs,
|
||||||
|
@ -140,11 +140,11 @@ TEST(SceneDirectorSimple, online) {
|
|||||||
auto& screen_1 = sd.screens["screen_1"];
|
auto& screen_1 = sd.screens["screen_1"];
|
||||||
screen_1.start_disable.push_back(engine.type<TestService2>());
|
screen_1.start_disable.push_back(engine.type<TestService2>());
|
||||||
screen_1.start_enable.push_back(engine.type<TestService1>());
|
screen_1.start_enable.push_back(engine.type<TestService1>());
|
||||||
screen_1.start_fn = [](MM::Engine& engine) {
|
screen_1.start_fn = [](MM::Engine& e) {
|
||||||
std::cout << "now in screen_1\n";
|
std::cout << "now in screen_1\n";
|
||||||
|
|
||||||
// and queue next screen immediately (for the purpose of this test)
|
// and queue next screen immediately (for the purpose of this test)
|
||||||
engine.tryService<MM::Services::ScreenDirector>()->queueChangeScreenTo("screen_2");
|
e.tryService<MM::Services::ScreenDirector>()->queueChangeScreenTo("screen_2");
|
||||||
};
|
};
|
||||||
screen_1.end_fn = [](auto&) {
|
screen_1.end_fn = [](auto&) {
|
||||||
std::cout << "exiting screen_1\n";
|
std::cout << "exiting screen_1\n";
|
||||||
@ -156,11 +156,11 @@ TEST(SceneDirectorSimple, online) {
|
|||||||
auto& screen_2 = sd.screens["screen_2"];
|
auto& screen_2 = sd.screens["screen_2"];
|
||||||
screen_2.start_disable.push_back(engine.type<TestService1>());
|
screen_2.start_disable.push_back(engine.type<TestService1>());
|
||||||
screen_2.start_enable.push_back(engine.type<TestService2>());
|
screen_2.start_enable.push_back(engine.type<TestService2>());
|
||||||
screen_2.start_fn = [](MM::Engine& engine) {
|
screen_2.start_fn = [](MM::Engine& e) {
|
||||||
std::cout << "now in screen_2\n";
|
std::cout << "now in screen_2\n";
|
||||||
|
|
||||||
// and queue next screen immediately (for the purpose of this test)
|
// and queue next screen immediately (for the purpose of this test)
|
||||||
engine.tryService<MM::Services::ScreenDirector>()->queueChangeScreenTo("screen_end");
|
e.tryService<MM::Services::ScreenDirector>()->queueChangeScreenTo("screen_end");
|
||||||
};
|
};
|
||||||
screen_2.end_fn = [](auto&) {
|
screen_2.end_fn = [](auto&) {
|
||||||
std::cout << "exiting screen_2\n";
|
std::cout << "exiting screen_2\n";
|
||||||
@ -170,8 +170,8 @@ TEST(SceneDirectorSimple, online) {
|
|||||||
// id end, quits the engine
|
// id end, quits the engine
|
||||||
{
|
{
|
||||||
auto& screen_end = sd.screens["screen_end"];
|
auto& screen_end = sd.screens["screen_end"];
|
||||||
screen_end.start_fn = [](MM::Engine& engine) {
|
screen_end.start_fn = [](MM::Engine& e) {
|
||||||
engine.stop();
|
e.stop();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ SDLService::~SDLService(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UpdateStrategies::UpdateCreationInfo> SDLService::registerUpdates(void) {
|
std::vector<UpdateStrategies::UpdateCreationInfo> SDLService::registerUpdates(void) {
|
||||||
|
using namespace entt::literals;
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"SDLService::events"_hs,
|
"SDLService::events"_hs,
|
||||||
|
@ -29,6 +29,7 @@ void SimpleSceneService::disable(Engine&) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UpdateStrategies::UpdateCreationInfo> SimpleSceneService::registerUpdates(void) {
|
std::vector<UpdateStrategies::UpdateCreationInfo> SimpleSceneService::registerUpdates(void) {
|
||||||
|
using namespace entt::literals;
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"SimpleSceneService::scene_tick"_hs,
|
"SimpleSceneService::scene_tick"_hs,
|
||||||
|
@ -58,6 +58,7 @@ void SimpleSDLRendererService::disable(Engine&) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UpdateStrategies::UpdateCreationInfo> SimpleSDLRendererService::registerUpdates(void) {
|
std::vector<UpdateStrategies::UpdateCreationInfo> SimpleSDLRendererService::registerUpdates(void) {
|
||||||
|
using namespace entt::literals;
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"SimpleSDLRendererService::render"_hs,
|
"SimpleSDLRendererService::render"_hs,
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
// inlining zip
|
// inlining zip
|
||||||
#include "res/erik_gun_fx_1.zip.h"
|
#include "res/erik_gun_fx_1.zip.h"
|
||||||
|
|
||||||
|
using namespace entt::literals;
|
||||||
|
|
||||||
extern char* argv0;
|
extern char* argv0;
|
||||||
|
|
||||||
TEST(soloud_fs_loader, basic) {
|
TEST(soloud_fs_loader, basic) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user