uggly main menu
This commit is contained in:
74
src/client/ClientApp.cpp
Normal file
74
src/client/ClientApp.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#include <client/ClientApp.h>
|
||||
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Core/StateMachine.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Widgets.hpp>
|
||||
#include <client/states/MainMenuState.h>
|
||||
#include <random>
|
||||
|
||||
namespace blitz {
|
||||
namespace client {
|
||||
|
||||
constexpr Nz::UInt32 RenderMaskUI = 0x00010000;
|
||||
constexpr Nz::UInt32 RenderMask3D = 0x0000FFFF;
|
||||
|
||||
ClientApp::ClientApp(Nz::ApplicationBase& app) : Nz::ApplicationComponent(app), m_StateMachine(std::make_unique<Nz::StateMachine>()) {
|
||||
auto& windowing = app.GetComponent<Nz::WindowingAppComponent>();
|
||||
|
||||
std::string windowTitle = "Blitz 2";
|
||||
m_Window = &windowing.CreateWindow(Nz::VideoMode(1920, 1080, 32), windowTitle);
|
||||
|
||||
auto& ecs = app.GetComponent<Nz::EntitySystemAppComponent>();
|
||||
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
|
||||
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>();
|
||||
|
||||
Nz::SwapchainParameters params;
|
||||
params.presentMode.clear();
|
||||
params.presentMode.push_back(Nz::PresentMode::VerticalSync);
|
||||
|
||||
Nz::WindowSwapchain& windowSwapchain = renderSystem.CreateSwapchain(*m_Window, params);
|
||||
|
||||
auto renderTarget = std::make_shared<Nz::RenderWindow>(windowSwapchain);
|
||||
|
||||
entt::handle cameraEntity = world.CreateEntity();
|
||||
{
|
||||
cameraEntity.emplace<Nz::NodeComponent>();
|
||||
|
||||
auto& cameraComponent = cameraEntity.emplace<Nz::CameraComponent>(renderTarget, Nz::ProjectionType::Orthographic);
|
||||
|
||||
cameraComponent.UpdateClearColor(Nz::Color(0.0f, 0.f, .0f, 0.0f));
|
||||
cameraComponent.UpdateRenderMask(RenderMaskUI);
|
||||
cameraComponent.UpdateRenderOrder(1);
|
||||
}
|
||||
|
||||
m_StateData = std::make_shared<StateData>();
|
||||
m_StateData->m_App = &app;
|
||||
m_StateData->m_AppComponent = this;
|
||||
m_StateData->m_RenderTarget = renderTarget;
|
||||
m_StateData->m_Window = m_Window;
|
||||
m_StateData->m_World = &world;
|
||||
m_StateData->m_Canvas.emplace(
|
||||
world.GetRegistry(), m_Window->GetEventHandler(), m_Window->GetCursorController().CreateHandle(), RenderMaskUI);
|
||||
m_StateData->m_Canvas->Resize(Nz::Vector2f(m_Window->GetSize()));
|
||||
|
||||
m_StateMachine->PushState(std::make_shared<MainMenuState>(m_StateData));
|
||||
}
|
||||
|
||||
ClientApp::~ClientApp() {
|
||||
m_StateMachine->ResetState(nullptr);
|
||||
m_StateMachine->Update(Nz::Time::Zero());
|
||||
}
|
||||
|
||||
void ClientApp::Update(Nz::Time elapsedTime) {
|
||||
if (!m_StateMachine->Update(elapsedTime))
|
||||
GetApp().Quit();
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
} // namespace blitz
|
||||
Reference in New Issue
Block a user