WIP added an event to become a server. changed xml file.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#ifndef Events_BecomeServer_h__
|
||||
#define Events_BecomeServer_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct BecomeServer : public Event { };
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "Input/EInputCommand.h"
|
||||
#include "Network/ESearchForServers.h"
|
||||
#include "Network/EConnectRequest.h"
|
||||
#include "Network/EBecomeServer.h"
|
||||
|
||||
|
||||
class MainMenuSystem : public ImpureSystem
|
||||
|
||||
@@ -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>
|
||||
|
||||
+6087
-6008
File diff suppressed because it is too large
Load Diff
@@ -284,3 +284,8 @@ int Game::parseArgs(int argc, char* argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Game::OnBecomeServer(const Events::BecomeServer& e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user