From 8ceaae995d8fc72beb599fd3e346798e5ca71803 Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 11 Mar 2016 13:00:34 +0100 Subject: [PATCH] Options menu started working on --- include/Game/Systems/MainMenuSystem.h | 3 +- resources/Schema/Components.xsd | 2 + resources/Schema/Entities/OptionMenu.xml | 182 +++++++++++++++++------ resources/Schema/Types/Entity.xsd | 2 + src/Game/Systems/MainMenuSystem.cpp | 94 +++++++----- 5 files changed, 193 insertions(+), 90 deletions(-) diff --git a/include/Game/Systems/MainMenuSystem.h b/include/Game/Systems/MainMenuSystem.h index ddefcbf4..be89cd55 100644 --- a/include/Game/Systems/MainMenuSystem.h +++ b/include/Game/Systems/MainMenuSystem.h @@ -7,7 +7,6 @@ #include "Core/Event.h" #include "Systems/SpawnerSystem.h" - #include "GUI/EButtonClicked.h" #include "GUI/EButtonPressed.h" #include "GUI/EButtonReleased.h" @@ -24,6 +23,8 @@ public: private: IRenderer* m_Renderer; + void OnPlay(const Events::InputCommand& e); + void OnOptions(const Events::InputCommand& e); EventRelay m_EClicked; bool OnButtonClick(const Events::ButtonClicked& e); diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index bc6da932..282a17b3 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -68,4 +68,6 @@ + + \ No newline at end of file diff --git a/resources/Schema/Entities/OptionMenu.xml b/resources/Schema/Entities/OptionMenu.xml index 21e93530..c1c4b517 100644 --- a/resources/Schema/Entities/OptionMenu.xml +++ b/resources/Schema/Entities/OptionMenu.xml @@ -6,47 +6,6 @@ - - - - - - - - - - - Models/Core/UnitQuad.mesh - - Textures/Core/White.png - - - - - - - - - - - 1920x1080 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - @@ -72,6 +31,20 @@ + + + + Models/Core/UnitQuad.mesh + + Textures/Core/White.png + + + + + + + + @@ -88,16 +61,127 @@ - + + + + + + + + + + + + + + + + 1920 + 1080 + + + Models/Core/UnitQuad.mesh + + Textures/Core/White.png + true + + + + + + + + + - - Models/Core/UnitQuad.mesh - - Textures/Core/White.png - + + 1920x1080 + Fonts/DroidSans.ttf,64 + + + + + - - + + + + + + + + + + + + + 1366 + 768 + + + Models/Core/UnitQuad.mesh + + Textures/Core/White.png + true + + + + + + + + + + + 1366x768 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + 1280 + 720 + + + Models/Core/UnitQuad.mesh + + Textures/Core/White.png + true + + + + + + + + + + + + 1280x720 + Fonts/DroidSans.ttf,64 + + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index c0ac15aa..34f08afd 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -71,6 +71,8 @@ + + diff --git a/src/Game/Systems/MainMenuSystem.cpp b/src/Game/Systems/MainMenuSystem.cpp index 848070b4..ac64f4c1 100644 --- a/src/Game/Systems/MainMenuSystem.cpp +++ b/src/Game/Systems/MainMenuSystem.cpp @@ -16,6 +16,57 @@ void MainMenuSystem::Update(double dt) } + +void MainMenuSystem::OnPlay(const Events::InputCommand& e) +{ + auto menus = m_World->GetComponents("Menu"); + if (menus == nullptr) { + return; + } + + if (m_OpenSubMenu == EntityWrapper::Invalid) { + //No submenu is open, open one. + for (auto& menu : *menus) { + EntityWrapper menuEntity = EntityWrapper(m_World, menu.EntityID); + auto serverListSpawner = menuEntity.FirstChildByName(e.Command + "Spawner"); + if (!serverListSpawner.HasComponent("Spawner")) { + return; + } + m_OpenSubMenu = SpawnerSystem::Spawn(serverListSpawner, serverListSpawner); + Events::SearchForServers event; + m_EventBroker->Publish(event); + break; + } + + } else if (!m_OpenSubMenu.HasComponent("ServerList")) { + //Menu is open, but not the right one, delete the old one and open a new one. + m_World->DeleteEntity(m_OpenSubMenu.ID); + m_OpenSubMenu = EntityWrapper::Invalid; + + for (auto& menu : *menus) { + EntityWrapper menuEntity = EntityWrapper(m_World, menu.EntityID); + auto serverListSpawner = menuEntity.FirstChildByName(e.Command + "Spawner"); + if (!serverListSpawner.HasComponent("Spawner")) { + return; + } + m_OpenSubMenu = SpawnerSystem::Spawn(serverListSpawner, serverListSpawner); + Events::SearchForServers event; + m_EventBroker->Publish(event); + break; + } + } else { + //Serverlist submenu is open, close it. + m_World->DeleteEntity(m_OpenSubMenu.ID); + m_OpenSubMenu = EntityWrapper::Invalid; + } +} + + +void MainMenuSystem::OpenSubMenu(const Events::InputCommand& e) +{ + +} + bool MainMenuSystem::OnButtonClick(const Events::ButtonClicked& e) { if (e.EntityName == "ServerIdentityConnect") { @@ -45,49 +96,12 @@ bool MainMenuSystem::OnButtonPress(const Events::ButtonPressed& e) bool MainMenuSystem::OnInputCommand(const Events::InputCommand& e) { if(e.Command == "Play" && e.Value == 1) { - auto menus = m_World->GetComponents("Menu"); - if (menus == nullptr) { - return 0; - } - - if (m_OpenSubMenu == EntityWrapper::Invalid) { - //No submenu is open, open one. - 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); - Events::SearchForServers event; - m_EventBroker->Publish(event); - break; - } - - } else if(!m_OpenSubMenu.HasComponent("ServerList")) { - //Menu is open, but not the right one, delete the old one and open a new one. - m_World->DeleteEntity(m_OpenSubMenu.ID); - m_OpenSubMenu = EntityWrapper::Invalid; - - 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); - Events::SearchForServers event; - m_EventBroker->Publish(event); - break; - } - } else { - //Serverlist submenu is open, close it. - m_World->DeleteEntity(m_OpenSubMenu.ID); - m_OpenSubMenu = EntityWrapper::Invalid; - } + OnPlay(e); } else if (e.Command == "RefreshServerList" && e.Value == 1){ Events::SearchForServers event; m_EventBroker->Publish(event); + } else if (e.Command == "Options" && e.Value == 1) { + OnOptions(e); } return true; } \ No newline at end of file