refactor(mirror): adjust to new ecs
This commit is contained in:
parent
91d86545dc
commit
7266451b45
5 changed files with 20 additions and 19 deletions
|
|
@ -28,9 +28,9 @@ public:
|
||||||
using Surface = lt::surface::SurfaceComponent;
|
using Surface = lt::surface::SurfaceComponent;
|
||||||
using Input = lt::input::InputComponent;
|
using Input = lt::input::InputComponent;
|
||||||
|
|
||||||
auto view = m_registry->get_entt_registry().view<Surface, Input>();
|
for (auto &[entity, surface, input] : m_registry->view<Surface, Input>())
|
||||||
|
{
|
||||||
view.each([&](Surface &surface, Input &input) {});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto tick() -> bool override
|
auto tick() -> bool override
|
||||||
|
|
@ -42,8 +42,8 @@ public:
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds { 10 });
|
std::this_thread::sleep_for(std::chrono::milliseconds { 10 });
|
||||||
auto should_quit = false;
|
auto should_quit = false;
|
||||||
auto view = m_registry->get_entt_registry().view<Surface, Input>();
|
for (auto &[entity, surface, input] : m_registry->view<Surface, Input>())
|
||||||
view.each([&](Surface &surface, Input &input) {
|
{
|
||||||
using State = lt::input::InputAction::State;
|
using State = lt::input::InputAction::State;
|
||||||
const auto &[x, y] = surface.get_position();
|
const auto &[x, y] = surface.get_position();
|
||||||
const auto &[width, height] = surface.get_resolution();
|
const auto &[width, height] = surface.get_resolution();
|
||||||
|
|
@ -76,7 +76,7 @@ public:
|
||||||
log_dbg("Deubg action 4");
|
log_dbg("Deubg action 4");
|
||||||
surface.push_request(surface::ModifyResolutionRequest({ width - 5, height - 5 }));
|
surface.push_request(surface::ModifyResolutionRequest({ width - 5, height - 5 }));
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
timer.reset();
|
timer.reset();
|
||||||
return should_quit;
|
return should_quit;
|
||||||
|
|
@ -125,15 +125,18 @@ public:
|
||||||
using lt::surface::SurfaceComponent;
|
using lt::surface::SurfaceComponent;
|
||||||
m_surface_system = create_ref<lt::surface::System>(m_editor_registry);
|
m_surface_system = create_ref<lt::surface::System>(m_editor_registry);
|
||||||
|
|
||||||
m_window = m_editor_registry->create_entity("Editor Window");
|
m_window = m_editor_registry->create_entity();
|
||||||
m_window.add_component<SurfaceComponent>(SurfaceComponent::CreateInfo {
|
m_editor_registry->add<SurfaceComponent>(
|
||||||
.title = "Editor Window",
|
m_window,
|
||||||
.resolution = { 400u, 400u },
|
SurfaceComponent::CreateInfo {
|
||||||
.vsync = true,
|
.title = "Editor Window",
|
||||||
.visible = true,
|
.resolution = { 400u, 400u },
|
||||||
});
|
.vsync = true,
|
||||||
|
.visible = true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
auto &input = m_window.add_component<InputComponent>();
|
auto &input = m_editor_registry->add<InputComponent>(m_window, {});
|
||||||
auto quit_action_key = input.add_action(
|
auto quit_action_key = input.add_action(
|
||||||
input::InputAction {
|
input::InputAction {
|
||||||
.name = "quit",
|
.name = "quit",
|
||||||
|
|
@ -142,7 +145,6 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
auto debug_action_keys = std::array<lt::input::InputAction::Key, 4> {};
|
auto debug_action_keys = std::array<lt::input::InputAction::Key, 4> {};
|
||||||
|
|
||||||
debug_action_keys[0] = input.add_action(
|
debug_action_keys[0] = input.add_action(
|
||||||
input::InputAction {
|
input::InputAction {
|
||||||
.name = "debug_1",
|
.name = "debug_1",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include <asset_manager/asset_manager.hpp>
|
#include <asset_manager/asset_manager.hpp>
|
||||||
#include <camera/component.hpp>
|
#include <camera/component.hpp>
|
||||||
#include <ecs/components.hpp>
|
#include <ecs/components.hpp>
|
||||||
#include <ecs/scene.hpp>
|
#include <ecs/registry.hpp>
|
||||||
#include <ecs/serializer.hpp>
|
#include <ecs/serializer.hpp>
|
||||||
#include <input/input.hpp>
|
#include <input/input.hpp>
|
||||||
#include <input/key_codes.hpp>
|
#include <input/key_codes.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include <asset_manager/asset_manager.hpp>
|
#include <asset_manager/asset_manager.hpp>
|
||||||
#include <ecs/scene.hpp>
|
#include <ecs/registry.hpp>
|
||||||
#include <ecs/serializer.hpp>
|
#include <ecs/serializer.hpp>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <mirror/panels/asset_browser.hpp>
|
#include <mirror/panels/asset_browser.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#include <ecs/components.hpp>
|
#include <ecs/components.hpp>
|
||||||
#include <entt/entt.hpp>
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <mirror/panels/properties.hpp>
|
#include <mirror/panels/properties.hpp>
|
||||||
#include <mirror/panels/scene_hierarchy.hpp>
|
#include <mirror/panels/scene_hierarchy.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ecs/entity.hpp>
|
#include <ecs/entity.hpp>
|
||||||
#include <ecs/scene.hpp>
|
#include <ecs/registry.hpp>
|
||||||
#include <mirror/panels/panel.hpp>
|
#include <mirror/panels/panel.hpp>
|
||||||
|
|
||||||
namespace lt {
|
namespace lt {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue