WIP added an event to become a server. changed xml file.

This commit is contained in:
stiffly
2016-03-10 14:12:08 +01:00
parent 28de31d84d
commit d7f166b8ae
7 changed files with 6188 additions and 6027 deletions
+14
View File
@@ -0,0 +1,14 @@
#ifndef Events_BecomeServer_h__
#define Events_BecomeServer_h__
#include "Core/EventBroker.h"
namespace Events
{
struct BecomeServer : public Event { };
}
#endif
+2
View File
@@ -70,6 +70,8 @@ private:
bool m_IsServer = false;
int parseArgs(int argc, char* argv[]);
EventRelay<Game, Events::BecomeServer> m_EBecomeServer;
bool OnBecomeServer(const Events::BecomeServer& e);
};
#endif
+1
View File
@@ -14,6 +14,7 @@
#include "Input/EInputCommand.h"
#include "Network/ESearchForServers.h"
#include "Network/EConnectRequest.h"
#include "Network/EBecomeServer.h"
class MainMenuSystem : public ImpureSystem
+72 -15
View File
@@ -319,23 +319,80 @@
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Entity name="Popup_Origin">
<Components>
<c:Transform>
<Position X="-0.103822395" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="PlaySpawner">
<Entity name="ButtonPos_5">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/ServerList.xml</EntityFile>
</c:Spawner>
<c:Transform/>
<c:Transform>
<Position X="0" Y="-0.280000001" Z="0"/>
</c:Transform>
</Components>
<Children/>
<Children>
<Entity name="Button_5">
<Components>
<c:Button/>
<c:Sprite>
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
<BlurBackground>true</BlurBackground>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="0.392156869" B="0" G="0" R="0"/>
</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>Host</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Right/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="0.0920000002" Y="-0.0150000006" Z="0.00499999989"/>
<Scale X="0.0199999996" Y="0.0199999996" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="ButtonCorner_Origin">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="TopRight">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
<GlowMap></GlowMap>
</c:Sprite>
<c:Transform>
<Position X="0.0970000029" Y="0.0220000017" Z="0.00499999989"/>
<Scale X="0.00499999989" Y="0.00499999989" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="BottomRight">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
<GlowMap></GlowMap>
</c:Sprite>
<c:Transform>
<Position X="0.0970000029" Y="-0.0219999999" Z="0.00499999989"/>
<Orientation X="0" Y="0" Z="4.71199989"/>
<Scale X="0.00499999989" Y="0.00499999989" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
File diff suppressed because it is too large Load Diff
+5
View File
@@ -284,3 +284,8 @@ int Game::parseArgs(int argc, char* argv[])
return 0;
}
bool Game::OnBecomeServer(const Events::BecomeServer& e)
{
}
+7 -4
View File
@@ -21,7 +21,7 @@ bool MainMenuSystem::OnButtonClick(const Events::ButtonClicked& e)
if (e.EntityName == "ServerIdentityConnect") {
EntityWrapper entity = e.Entity;
EntityWrapper serverIdentityEntity = entity.FirstParentWithComponent("ServerIdentity");
if(serverIdentityEntity.Valid()) {
if (serverIdentityEntity.Valid()) {
Events::ConnectRequest event;
event.IP = (std::string)serverIdentityEntity["ServerIdentity"]["IP"];
event.Port = (int)serverIdentityEntity["ServerIdentity"]["Port"];
@@ -44,7 +44,10 @@ bool MainMenuSystem::OnButtonPress(const Events::ButtonPressed& e)
bool MainMenuSystem::OnInputCommand(const Events::InputCommand& e)
{
if(e.Command == "Play" && e.Value == 1) {
if (e.Command == "Host" && e.Value == 1) {
m_EventBroker->Publish(Events::BecomeServer());
}
if (e.Command == "Play" && e.Value == 1) {
auto menus = m_World->GetComponents("Menu");
if (menus == nullptr) {
return 0;
@@ -64,7 +67,7 @@ bool MainMenuSystem::OnInputCommand(const Events::InputCommand& e)
break;
}
} else if(!m_OpenSubMenu.HasComponent("ServerList")) {
} 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;
@@ -85,7 +88,7 @@ bool MainMenuSystem::OnInputCommand(const Events::InputCommand& e)
m_World->DeleteEntity(m_OpenSubMenu.ID);
m_OpenSubMenu = EntityWrapper::Invalid;
}
} else if (e.Command == "RefreshServerList" && e.Value == 1){
} else if (e.Command == "RefreshServerList" && e.Value == 1) {
Events::SearchForServers event;
m_EventBroker->Publish(event);
}