69 lines
1.4 KiB
C++
69 lines
1.4 KiB
C++
|
#include "MainMenu.h"
|
||
|
|
||
|
#include <LWE/IO/RenderWindow.h>
|
||
|
#include <LWE/GameLoop.h>
|
||
|
#include <LWE/Entity.h>
|
||
|
#include <LWE/IO/Model/Mesh.h>
|
||
|
#include <LWE/IO/FontAtlas.h>
|
||
|
#include <LWE/Systems/CameraSystem.h>
|
||
|
#include <LWE/Systems/RigidBodySystem.h>
|
||
|
#include <LWE/Systems/GuiSystem.h>
|
||
|
#include <LWE/Components/Camera.h>
|
||
|
|
||
|
#include "TestLevel.h"
|
||
|
|
||
|
MainMenu::MainMenu(const lwe::Str_8& id)
|
||
|
: Level(id)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void MainMenu::SetupResources()
|
||
|
{
|
||
|
Level::SetupResources();
|
||
|
|
||
|
}
|
||
|
|
||
|
void MainMenu::Setup()
|
||
|
{
|
||
|
Level::Setup();
|
||
|
|
||
|
AddSystem(new lwe::CameraSystem());
|
||
|
AddSystem(new lwe::RigidBodySystem());
|
||
|
AddSystem(new lwe::GuiSystem());
|
||
|
|
||
|
lwe::Entity* cam = new lwe::Entity("Camera");
|
||
|
|
||
|
lwe::Camera* com = new lwe::Camera("Main");
|
||
|
cam->AddComponent(com);
|
||
|
|
||
|
AddEntity(cam);
|
||
|
}
|
||
|
|
||
|
void MainMenu::PostInitialize(lwe::GpuCmdBuffer* cmdBuffer)
|
||
|
{
|
||
|
Level::PostInitialize(cmdBuffer);
|
||
|
}
|
||
|
|
||
|
void MainMenu::OnUpdate(lwe::Input* input, const float delta)
|
||
|
{
|
||
|
Level::OnUpdate(input, delta);
|
||
|
|
||
|
lwe::GameLoop* gl = (lwe::GameLoop*)GetParent("GameLoop");
|
||
|
if (!gl)
|
||
|
return;
|
||
|
|
||
|
lwe::RenderWindow* win = gl->GetWindow();
|
||
|
if (!win)
|
||
|
return;
|
||
|
|
||
|
lwe::Vec2_f client = win->GetScale();
|
||
|
|
||
|
lwe::Entity* sp = GetEntity("SinglePlayer");
|
||
|
if (sp)
|
||
|
sp->SetPos({client.x * 0.5f - sp->GetScale().x * 0.5f, sp->GetPos().y, 0.0f});
|
||
|
|
||
|
lwe::Entity* mp = GetEntity("MultiPlayer");
|
||
|
if (mp)
|
||
|
mp->SetPos({client.x * 0.5f - mp->GetScale().x * 0.5f, mp->GetPos().y, 0.0f});
|
||
|
}
|