Started implementing deficated editor GUI

This commit is contained in:
2025-12-04 15:51:56 +03:00
parent 6eed5063e6
commit e0db570581
14 changed files with 768 additions and 33 deletions

View File

@@ -15,6 +15,8 @@
#include "PhysicsModule.h"
#include "EventModule.h"
#include "CharacterManagerModule.h"
#include "VehicleManagerModule.h"
#include "AppModule.h"
#include "world-build.h"
namespace ECS
@@ -30,18 +32,9 @@ void setup_minimal()
ecs.import <GameWorldModule>();
ecs.import <EventModule>();
ecs.import <CharacterManagerModule>();
ecs.import <VehicleManagerModule>();
ecs.import <WaterModule>();
ecs.component<InWater>();
ecs.component<WaterReady>().add(flecs::Singleton);
ecs.component<WaterAlmostReady>().add(flecs::Singleton);
ecs.component<GroundCheckReady>().add(flecs::Singleton);
ecs.component<App>()
.on_add([](App &app) {
app.mInput = nullptr;
app.mGuiOverlay = nullptr;
app.listeners.clear();
})
.add(flecs::Singleton);
ecs.import <AppModule>();
/* lots of things depend on it */
ecs.component<Body2Entity>().add(flecs::Singleton);
}
@@ -108,6 +101,11 @@ void setup(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode,
nullptr,
false,
{ 0, 0, 0 } });
if (!ecs.has<LuaBase>())
ecs.add<LuaBase>();
if (!ecs.has<LuaEvent>())
ecs.set<LuaEvent>({});
// ecs.set<Body2Entity>({});
std::cout << "Setup GameData done\n";
@@ -116,6 +114,79 @@ void setup(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode,
{ 0, 0, 4 }, Ogre::Quaternion(Ogre::Radian(Ogre::Math::PI),
Ogre::Vector3::UNIT_Y));
}
void setupEditor(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode,
Ogre::Camera *camera, Ogre::RenderWindow *window)
{
std::cout << "Setup Editor\n";
setup_minimal();
ecs.component<RenderWindow>().add(flecs::Singleton);
ecs.import <CharacterModule>();
ecs.import <BoatModule>();
ecs.import <PhysicsModule>();
ecs.import <WaterModule>();
ecs.import <SunModule>();
ecs.import <TerrainModule>();
ecs.import <EditorGUIModule>();
ecs.import <EventTriggerModule>();
ecs.import <LuaModule>();
// ecs.import <WorldMapModule>();
ecs.import <CharacterAnimationModule>();
ecs.system<EngineData>("UpdateDelta")
.kind(flecs::OnUpdate)
.each([](EngineData &eng) {
eng.delta = ECS::get().delta_time();
});
ecs.system<EngineData>("UpdateDelay")
.kind(flecs::OnUpdate)
.with<TerrainReady>()
.with<WaterReady>()
.with<GroundCheckReady>()
.each([](EngineData &eng) {
if (eng.startupDelay >= 0.0f)
eng.startupDelay -= eng.delta;
#ifdef VDEBUG
if (ECS::get().has<GroundCheckReady>())
std::cout << "ground check ready\n";
#endif
});
ecs.system<EngineData>("CheckStatus")
.kind(flecs::OnUpdate)
.run([](flecs::iter &it) {
#ifdef VDEBUG
if (ECS::get().has<WaterReady>())
std::cout << "water ready\n";
if (ECS::get().has<TerrainReady>())
std::cout << "terrain ready\n";
if (ECS::get().has<GroundCheckReady>())
std::cout << "ground check ready\n";
#endif
});
ecs.set<EngineData>({ scnMgr, 0.0f, 5.0f, (int)window->getWidth(),
(int)window->getHeight(), false });
ecs.set<Camera>({ cameraNode, camera, false });
ecs.add<GameData>();
ecs.add<Input>();
ecs.add<WaterSurface>();
ecs.set<Sun>({ nullptr, nullptr, nullptr, nullptr });
ecs.set<Terrain>({ nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
false,
{ 0, 0, 0 } });
ecs.set<GUI>({ true, true, true, false, false, "", {}, -1 });
ecs.get_mut<GUI>().enabled = true;
ecs.get_mut<GUI>().setWindowGrab(false);
ecs.modified<GUI>();
ecs.get_mut<GUI>().setWindowGrab(true);
ecs.modified<GUI>();
ecs.get_mut<GUI>().enabled = true;
ecs.modified<GUI>();
}
void update(float delta)
{
ecs.progress(delta);