Tweaks and a new state: NetLoadState
This commit is contained in:
parent
c5c0047b5c
commit
fe6742f9e2
|
@ -215,6 +215,7 @@
|
|||
<ClCompile Include="GameClientState\LobbyState.cpp" />
|
||||
<ClCompile Include="GameClientState\C_Object.cpp" />
|
||||
<ClCompile Include="GameClientState\MainState.cpp" />
|
||||
<ClCompile Include="GameClientState\NetLoadState.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GameClientState\Camera_Basic.h" />
|
||||
|
@ -237,6 +238,7 @@
|
|||
<ClInclude Include="GameClientState\LevelLoader\ParseFunctions.h" />
|
||||
<ClInclude Include="GameClientState\LobbyAdminState.h" />
|
||||
<ClInclude Include="GameClientState\MainState.h" />
|
||||
<ClInclude Include="GameClientState\NetLoadState.h" />
|
||||
<ClInclude Include="Include\DanBiasGame.h" />
|
||||
<ClInclude Include="GameClientState\LobbyState.h" />
|
||||
<ClInclude Include="GameClientState\C_Object.h" />
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "GameClientState\LobbyAdminState.h"
|
||||
#include "GameClientState\MainState.h"
|
||||
#include "GameClientState\LanMenuState.h"
|
||||
#include "GameClientState\NetLoadState.h"
|
||||
#include <Protocols.h>
|
||||
#include "NetworkClient.h"
|
||||
#include <GameServerAPI.h>
|
||||
|
@ -182,8 +183,8 @@ namespace DanBias
|
|||
|
||||
switch (state)
|
||||
{
|
||||
case Client::GameClientState::ClientState_LobbyCreate:
|
||||
data.state = new Client::LobbyAdminState();
|
||||
case Client::GameClientState::ClientState_Main:
|
||||
data.state = new Client::MainState();
|
||||
stateChanged = true;
|
||||
break;
|
||||
case Client::GameClientState::ClientState_Lan:
|
||||
|
@ -194,10 +195,18 @@ namespace DanBias
|
|||
data.state = new Client::LobbyState();
|
||||
stateChanged = true;
|
||||
break;
|
||||
case Client::GameClientState::ClientState_LobbyCreate:
|
||||
data.state = new Client::LobbyAdminState();
|
||||
stateChanged = true;
|
||||
break;
|
||||
case Client::GameClientState::ClientState_Game:
|
||||
data.state = new Client::GameState();
|
||||
stateChanged = true;
|
||||
break;
|
||||
case Client::GameClientState::ClientState_NetLoad:
|
||||
data.state = new Client::NetLoadState();
|
||||
stateChanged = true;
|
||||
break;
|
||||
case Client::GameClientState::ClientState_Quit:
|
||||
data.state->Release();
|
||||
return Result_quit;
|
||||
|
|
|
@ -78,36 +78,35 @@ namespace DanBias { namespace Client
|
|||
{
|
||||
::Oyster::Math::Float lineStep = this->fontHeight + this->lineSpacing;
|
||||
::Oyster::Math::Float2 rowSize = ::Oyster::Math::Float2( this->size.x, this->fontHeight );
|
||||
::Oyster::Math::Float3 fieldTopLeft = this->pos - Float3( this->size * 0.25f, 0.0f );
|
||||
::Oyster::Math::Float3 topLeft = fieldTopLeft;
|
||||
|
||||
if( this->isBottomAligned )
|
||||
{
|
||||
::Oyster::Math::Float3 topLeft = this->pos;
|
||||
topLeft.y += this->size.y - lineStep;
|
||||
|
||||
auto line = this->lines.rbegin();
|
||||
for( ; line != this->lines.rend(); ++line )
|
||||
{
|
||||
if( topLeft.y - lineStep >= this->pos.y )
|
||||
{
|
||||
::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor );
|
||||
topLeft.y -= lineStep;
|
||||
}
|
||||
else break;
|
||||
if( topLeft.y < fieldTopLeft.y )
|
||||
break;
|
||||
|
||||
::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor );
|
||||
topLeft.y -= lineStep;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
::Oyster::Math::Float3 topLeft = this->pos;
|
||||
topLeft.y += this->lineSpacing;
|
||||
|
||||
auto line = this->lines.begin();
|
||||
for( ; line != this->lines.end(); ++line )
|
||||
{
|
||||
if( topLeft.y + lineStep < this->size.y )
|
||||
{
|
||||
::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor );
|
||||
topLeft.y += lineStep;
|
||||
}
|
||||
else break;
|
||||
if( topLeft.y >= fieldTopLeft.y + this->size.y )
|
||||
break;
|
||||
|
||||
::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor );
|
||||
topLeft.y += lineStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,12 @@ namespace DanBias { namespace Client
|
|||
public:
|
||||
enum ClientState
|
||||
{
|
||||
ClientState_Login,
|
||||
ClientState_Main,
|
||||
ClientState_Lan,
|
||||
ClientState_Lobby,
|
||||
ClientState_LobbyCreate,
|
||||
ClientState_LobbyReady,
|
||||
ClientState_NetLoad,
|
||||
ClientState_Game,
|
||||
ClientState_Same,
|
||||
ClientState_Quit
|
||||
|
|
|
@ -42,7 +42,7 @@ bool GameState::Init(NetworkClient* nwClient)
|
|||
LoadGame();
|
||||
|
||||
//tell server ready
|
||||
nwClient->Send(GameLogic::Protocol_General_Status(GameLogic::Protocol_General_Status::States_ready));
|
||||
nwClient->Send( GameLogic::Protocol_General_Status(GameLogic::Protocol_General_Status::States_ready) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ struct LanMenuState::MyData
|
|||
} privData;
|
||||
|
||||
void OnButtonInteract_Connect( Oyster::Event::ButtonEvent<LanMenuState*>& e );
|
||||
void OnButtonInteract_Exit( Oyster::Event::ButtonEvent<LanMenuState*>& e );
|
||||
|
||||
LanMenuState::LanMenuState() {}
|
||||
|
||||
|
@ -55,19 +56,22 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient)
|
|||
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
||||
|
||||
// create guiElements
|
||||
ButtonRectangle<LanMenuState*> *guiElements;
|
||||
|
||||
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
||||
this->privData->guiElements.AddButton( guiElements );
|
||||
|
||||
this->privData->connectIP = new TextField<LanMenuState*>( L"earth_md.png", Float3(1.0f), this, Float3(0.1f, 0.2f, 0.5f), Float2(0.45f, 0.1f), ResizeAspectRatio_Width );
|
||||
this->privData->connectIP = new TextField<LanMenuState*>( L"earth_md.png", Float3(1.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None );
|
||||
this->privData->connectIP->ReserveLines( 1 );
|
||||
this->privData->connectIP->AppendText( L"127.0.0.1" );
|
||||
this->privData->connectIP->SetFontHeight( 0.1f );
|
||||
this->privData->connectIP->SetLineSpacing( 0.0f );
|
||||
this->privData->connectIP->SetFontHeight( 0.08f );
|
||||
this->privData->connectIP->SetLineSpacing( 0.005f );
|
||||
this->privData->connectIP->SetTopAligned();
|
||||
|
||||
this->privData->guiElements.AddButton( this->privData->connectIP );
|
||||
|
||||
ButtonRectangle<LanMenuState*> *guiElements;
|
||||
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
|
||||
this->privData->guiElements.AddButton( guiElements );
|
||||
|
||||
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Exit", Float3(1.0f), OnButtonInteract_Exit, this, Float3(0.5f, 0.5f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
|
||||
this->privData->guiElements.AddButton( guiElements );
|
||||
|
||||
// bind guiElements collection to the singleton eventhandler
|
||||
EventHandler::Instance().AddCollection( &this->privData->guiElements );
|
||||
|
||||
|
@ -136,3 +140,14 @@ void OnButtonInteract_Connect( Oyster::Event::ButtonEvent<LanMenuState*>& e )
|
|||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnButtonInteract_Exit( Oyster::Event::ButtonEvent<LanMenuState*>& e )
|
||||
{
|
||||
switch( e.state )
|
||||
{
|
||||
case ButtonState_Released:
|
||||
e.owner->ChangeState( GameClientState::ClientState_Main );
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ void LobbyState::ChangeState( ClientState next )
|
|||
{
|
||||
if( next == GameClientState::ClientState_LobbyReady )
|
||||
{ // Send ready signal to server lobby
|
||||
|
||||
this->ChangeState( GameClientState::ClientState_NetLoad );
|
||||
}
|
||||
else
|
||||
this->privData->nextState = next;
|
||||
|
|
Loading…
Reference in New Issue