WIP
This commit is contained in:
@@ -5,11 +5,13 @@
|
|||||||
#include "../Rendering/IRenderer.h"
|
#include "../Rendering/IRenderer.h"
|
||||||
#include "../Core/ResourceManager.h"
|
#include "../Core/ResourceManager.h"
|
||||||
#include "../Core/Event.h"
|
#include "../Core/Event.h"
|
||||||
|
#include "Systems/SpawnerSystem.h"
|
||||||
|
|
||||||
|
|
||||||
#include "EButtonClicked.h"
|
#include "EButtonClicked.h"
|
||||||
#include "EButtonPressed.h"
|
#include "EButtonPressed.h"
|
||||||
#include "EButtonReleased.h"
|
#include "EButtonReleased.h"
|
||||||
|
#include "../Input/EInputCommand.h"
|
||||||
|
|
||||||
|
|
||||||
class MainMenuSystem : public ImpureSystem
|
class MainMenuSystem : public ImpureSystem
|
||||||
@@ -27,6 +29,10 @@ private:
|
|||||||
bool OnButtonRelease(const Events::ButtonReleased& e);
|
bool OnButtonRelease(const Events::ButtonReleased& e);
|
||||||
EventRelay<MainMenuSystem, Events::ButtonPressed> m_EPressed;
|
EventRelay<MainMenuSystem, Events::ButtonPressed> m_EPressed;
|
||||||
bool OnButtonPress(const Events::ButtonPressed& e);
|
bool OnButtonPress(const Events::ButtonPressed& e);
|
||||||
|
EventRelay<MainMenuSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
|
|
||||||
|
std::string m_CurrentCommand = "";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef MainMenuSystem_h__
|
||||||
|
#define MainMenuSystem_h__
|
||||||
|
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "Rendering/IRenderer.h"
|
||||||
|
#include "Core/ResourceManager.h"
|
||||||
|
#include "Core/Event.h"
|
||||||
|
#include "Systems/SpawnerSystem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "GUI/EButtonClicked.h"
|
||||||
|
#include "GUI/EButtonPressed.h"
|
||||||
|
#include "GUI/EButtonReleased.h"
|
||||||
|
#include "Input/EInputCommand.h"
|
||||||
|
|
||||||
|
|
||||||
|
class MainMenuSystem : public ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MainMenuSystem(SystemParams params, IRenderer* renderer);
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
IRenderer* m_Renderer;
|
||||||
|
|
||||||
|
EventRelay<MainMenuSystem, Events::ButtonClicked> m_EClicked;
|
||||||
|
bool OnButtonClick(const Events::ButtonClicked& e);
|
||||||
|
EventRelay<MainMenuSystem, Events::ButtonReleased> m_EReleased;
|
||||||
|
bool OnButtonRelease(const Events::ButtonReleased& e);
|
||||||
|
EventRelay<MainMenuSystem, Events::ButtonPressed> m_EPressed;
|
||||||
|
bool OnButtonPress(const Events::ButtonPressed& e);
|
||||||
|
EventRelay<MainMenuSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
|
|
||||||
|
std::string m_CurrentCommand = "";
|
||||||
|
EntityWrapper m_OpenSubMenu = EntityWrapper::Invalid;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -17,6 +17,47 @@
|
|||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
|
<Entity name="ButtonPos_3">
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="-0.140000001" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity name="Button_3">
|
||||||
|
<Components>
|
||||||
|
<c:Button/>
|
||||||
|
<c:Sprite>
|
||||||
|
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
|
||||||
|
<BlurBackground>true</BlurBackground>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<Color A="0.588235319" B="1" G="1" R="1"/>
|
||||||
|
</c:Sprite>
|
||||||
|
<c:Transform>
|
||||||
|
<Scale X="0.200000003" Y="0.0500000007" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Text">
|
||||||
|
<Components>
|
||||||
|
<c:Text>
|
||||||
|
<Content>Credits</Content>
|
||||||
|
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||||
|
<Color A="1" B="0" G="0" R="0"/>
|
||||||
|
<Alignment>
|
||||||
|
<Left/>
|
||||||
|
</Alignment>
|
||||||
|
</c:Text>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.075000003" Y="-0.0150000006" Z="0.00100000005"/>
|
||||||
|
<Scale X="0.0199999996" Y="0.0199999996" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
<Entity name="ButtonPos_1">
|
<Entity name="ButtonPos_1">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
@@ -101,47 +142,6 @@
|
|||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
<Entity name="ButtonPos_3">
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="-0.140000001" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity name="Button_3">
|
|
||||||
<Components>
|
|
||||||
<c:Button/>
|
|
||||||
<c:Sprite>
|
|
||||||
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
|
|
||||||
<BlurBackground>true</BlurBackground>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<Color A="0.588235319" B="1" G="1" R="1"/>
|
|
||||||
</c:Sprite>
|
|
||||||
<c:Transform>
|
|
||||||
<Scale X="0.200000003" Y="0.0500000007" Z="1"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity name="Text">
|
|
||||||
<Components>
|
|
||||||
<c:Text>
|
|
||||||
<Content>Credits</Content>
|
|
||||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
|
||||||
<Color A="1" B="0" G="0" R="0"/>
|
|
||||||
<Alignment>
|
|
||||||
<Left/>
|
|
||||||
</Alignment>
|
|
||||||
</c:Text>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-0.075000003" Y="-0.0150000006" Z="0.00100000005"/>
|
|
||||||
<Scale X="0.0199999996" Y="0.0199999996" Z="1"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
<Entity name="ButtonPos_4">
|
<Entity name="ButtonPos_4">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
<Entity name="ServerListSpawner">
|
<Entity name="PlaySpawner">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Spawner>
|
<c:Spawner>
|
||||||
<EntityFile>Schema/Entities/ServerList.xml</EntityFile>
|
<EntityFile>Schema/Entities/ServerList.xml</EntityFile>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "GUI/MainMenuSystem.h"
|
#include "../Game/Systems/MainMenuSystem.h"
|
||||||
|
|
||||||
MainMenuSystem::MainMenuSystem(SystemParams params, IRenderer* renderer)
|
MainMenuSystem::MainMenuSystem(SystemParams params, IRenderer* renderer)
|
||||||
: System(params)
|
: System(params)
|
||||||
@@ -8,6 +8,7 @@ MainMenuSystem::MainMenuSystem(SystemParams params, IRenderer* renderer)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPressed, &MainMenuSystem::OnButtonPress);
|
EVENT_SUBSCRIBE_MEMBER(m_EPressed, &MainMenuSystem::OnButtonPress);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EReleased, &MainMenuSystem::OnButtonRelease);
|
EVENT_SUBSCRIBE_MEMBER(m_EReleased, &MainMenuSystem::OnButtonRelease);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EClicked, &MainMenuSystem::OnButtonClick);
|
EVENT_SUBSCRIBE_MEMBER(m_EClicked, &MainMenuSystem::OnButtonClick);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &MainMenuSystem::OnInputCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMenuSystem::Update(double dt)
|
void MainMenuSystem::Update(double dt)
|
||||||
@@ -18,7 +19,8 @@ void MainMenuSystem::Update(double dt)
|
|||||||
bool MainMenuSystem::OnButtonClick(const Events::ButtonClicked& e)
|
bool MainMenuSystem::OnButtonClick(const Events::ButtonClicked& e)
|
||||||
{
|
{
|
||||||
if(e.EntityName == "Play") {
|
if(e.EntityName == "Play") {
|
||||||
//Run play code
|
//OpenServerList
|
||||||
|
|
||||||
} else if(e.EntityName == "Connect") {
|
} else if(e.EntityName == "Connect") {
|
||||||
//Run connect code
|
//Run connect code
|
||||||
} else if(e.EntityName == "Host") {
|
} else if(e.EntityName == "Host") {
|
||||||
@@ -52,3 +54,31 @@ bool MainMenuSystem::OnButtonPress(const Events::ButtonPressed& e)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainMenuSystem::OnInputCommand(const Events::InputCommand& e)
|
||||||
|
{
|
||||||
|
if(e.Command == "Play") {
|
||||||
|
if (m_OpenSubMenu == EntityWrapper::Invalid) {
|
||||||
|
//No submenu is open, open one.
|
||||||
|
|
||||||
|
} else if(!m_OpenSubMenu.HasComponent("ServerList")) {
|
||||||
|
//Menu is open, but not the right one, delete the old one and open a new one.
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//Serverlist submenu is open, close it.
|
||||||
|
}
|
||||||
|
//Create new entity through the spawner. Should also despawn all other menus.
|
||||||
|
auto menus = m_World->GetComponents("Menu");
|
||||||
|
if(menus == nullptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
for (auto& menu : *menus) {
|
||||||
|
EntityWrapper menuEntity = EntityWrapper(m_World, menu.EntityID);
|
||||||
|
auto serverListSpawner = menuEntity.FirstChildByName(e.Command + "Spawner");
|
||||||
|
if(!serverListSpawner.HasComponent("Spawner")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
m_OpenSubMenu = SpawnerSystem::Spawn(serverListSpawner, serverListSpawner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user