From 9d0148c5c24465cdf0f8de66a45d505d27b9ae33 Mon Sep 17 00:00:00 2001 From: Dennis Andersen Date: Sun, 16 Feb 2014 01:12:27 +0100 Subject: [PATCH] GameServer - Merged with Standalone Server and modified some stuff, still compile errors, will try to merge with other --- Code/CLIStandaloneServer/AssemblyInfo.cpp | 2 +- Code/CLIStandaloneServer/C++StandaloneCLI.h | 56 -------- .../CLIStandaloneServer.vcxproj | 5 +- ...oneCLI.cpp => StandaloneGameServerCLI.cpp} | 41 +++--- .../StandaloneGameServerCLI.h | 58 ++++++++ .../Game/DanBiasGame/DanBiasGame.vcxproj.user | 2 +- .../DanBiasGame/GameClientState/MainState.cpp | 15 +- .../DanBiasLauncher.vcxproj.user | 2 +- Code/Game/GameServer/GameServer.vcxproj.user | 2 +- .../Implementation/GameSession_General.cpp | 3 +- Code/Input/L_inputClass.cpp | 21 +++ Code/Input/L_inputClass.h | 7 +- Code/StandAloneLauncher/App.config | 7 +- Code/StandAloneLauncher/Form1.Designer.cs | 136 +++++++++++++++++- Code/StandAloneLauncher/Form1.cs | 55 +++++++ Code/StandAloneLauncher/Program.cs | 8 +- .../StandAloneLauncher.csproj | 22 ++- .../StandAloneLauncher.csproj.user | 9 ++ .../bin/Debug/StandAloneLauncher.exe.config | 6 - .../StandAloneLauncher.vshost.exe.config | 6 - .../StandAloneLauncher.vshost.exe.manifest | 11 -- .../x86/Debug/StandAloneLauncher.exe.config | 6 - .../StandAloneLauncher.vshost.exe.config | 6 - 23 files changed, 346 insertions(+), 140 deletions(-) delete mode 100644 Code/CLIStandaloneServer/C++StandaloneCLI.h rename Code/CLIStandaloneServer/{C++StandaloneCLI.cpp => StandaloneGameServerCLI.cpp} (56%) create mode 100644 Code/CLIStandaloneServer/StandaloneGameServerCLI.h create mode 100644 Code/StandAloneLauncher/StandAloneLauncher.csproj.user delete mode 100644 Code/StandAloneLauncher/bin/Debug/StandAloneLauncher.exe.config delete mode 100644 Code/StandAloneLauncher/bin/Debug/StandAloneLauncher.vshost.exe.config delete mode 100644 Code/StandAloneLauncher/bin/Debug/StandAloneLauncher.vshost.exe.manifest delete mode 100644 Code/StandAloneLauncher/bin/x86/Debug/StandAloneLauncher.exe.config delete mode 100644 Code/StandAloneLauncher/bin/x86/Debug/StandAloneLauncher.vshost.exe.config diff --git a/Code/CLIStandaloneServer/AssemblyInfo.cpp b/Code/CLIStandaloneServer/AssemblyInfo.cpp index 20a72bc0..a521826c 100644 --- a/Code/CLIStandaloneServer/AssemblyInfo.cpp +++ b/Code/CLIStandaloneServer/AssemblyInfo.cpp @@ -9,7 +9,7 @@ using namespace System::Security::Permissions; // set of attributes. Change these attribute values to modify the information // associated with an assembly. // -[assembly:AssemblyTitleAttribute("PhysicsGameCLIWrapper")]; +[assembly:AssemblyTitleAttribute("StandaloneServerCLIWrapper")]; [assembly:AssemblyDescriptionAttribute("")]; [assembly:AssemblyConfigurationAttribute("")]; [assembly:AssemblyCompanyAttribute("Microsoft")]; diff --git a/Code/CLIStandaloneServer/C++StandaloneCLI.h b/Code/CLIStandaloneServer/C++StandaloneCLI.h deleted file mode 100644 index 2e0d8530..00000000 --- a/Code/CLIStandaloneServer/C++StandaloneCLI.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef CLISTANDALONESERVER_CPP_Standalone_CLI_H -#define CLISTANDALONESERVER_CPP_Standalone_CLI_H - -#include -#include -#include - -#include "..\Game\GameServer\GameServerAPI.h" - -enum DanBiasServerReturn -{ - DanBiasServerReturn_Error, - DanBiasServerReturn_Sucess, - DanBiasServerReturn_GameNotCreated, -}; - -public value struct ServerInitDesc -{ - System::String^ serverName; - int listenPort; - bool broadcast; //Not fully implemented! - -}; - -public value struct GameServerInfo -{ - unsigned int listenPort; // If set to 0, the default port 15151 will be used - System::String^ serverIp; // This cant be mofidfied.. -}; - -public ref class CppStandaloneCLI -{ -public: - CppStandaloneCLI(); - ~CppStandaloneCLI(); - - DanBiasServerReturn ServerInitiate(ServerInitDesc desc); - void ServerStart(); - void ServerStop(); - void ServerUpdate(); - GameServerInfo ServerGetInfo(); - bool ServerIsRunning(); - - void GameSetMapId(const int val); - void GameSetMaxClients(const int val); - void GameSetGameMode(const int val); - void GameSetGameTime(const int val); - int GameGetMapId(); - int GameGetMaxClients(); - int GameGetGameMode(); - int GameGetGameTime(); - System::String^ GameGetGameName(); - bool GameStart(); -}; - -#endif \ No newline at end of file diff --git a/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj b/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj index 6b49c390..ccefa56d 100644 --- a/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj +++ b/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj @@ -139,14 +139,15 @@ - + - + + diff --git a/Code/CLIStandaloneServer/C++StandaloneCLI.cpp b/Code/CLIStandaloneServer/StandaloneGameServerCLI.cpp similarity index 56% rename from Code/CLIStandaloneServer/C++StandaloneCLI.cpp rename to Code/CLIStandaloneServer/StandaloneGameServerCLI.cpp index b331e37f..ff50416b 100644 --- a/Code/CLIStandaloneServer/C++StandaloneCLI.cpp +++ b/Code/CLIStandaloneServer/StandaloneGameServerCLI.cpp @@ -1,17 +1,20 @@ -#include "C++StandaloneCLI.h" +#include "StandaloneGameServerCLI.h" + using namespace System; +using namespace System::Windows::Interop; +using namespace System::Windows; using namespace System::Runtime::InteropServices; -CppStandaloneCLI::CppStandaloneCLI() +StandaloneGameServerCLI::StandaloneGameServerCLI() { } -CppStandaloneCLI::~CppStandaloneCLI() +StandaloneGameServerCLI::~StandaloneGameServerCLI() { } -DanBiasServerReturn CppStandaloneCLI::ServerInitiate(ServerInitDesc desc) +DanBiasServerReturn StandaloneGameServerCLI::ServerInitiate(ServerInitDesc desc) { DanBias::GameServerAPI::ServerInitDesc d; //Convert from String to char* @@ -25,22 +28,22 @@ DanBiasServerReturn CppStandaloneCLI::ServerInitiate(ServerInitDesc desc) return (DanBiasServerReturn)DanBias::GameServerAPI::ServerInitiate(d); } -void CppStandaloneCLI::ServerStart() +void StandaloneGameServerCLI::ServerStart() { DanBias::GameServerAPI::ServerStart(); } -void CppStandaloneCLI::ServerStop() +void StandaloneGameServerCLI::ServerStop() { DanBias::GameServerAPI::ServerStop(); } -void CppStandaloneCLI::ServerUpdate() +void StandaloneGameServerCLI::ServerUpdate() { DanBias::GameServerAPI::ServerUpdate(); } -GameServerInfo CppStandaloneCLI::ServerGetInfo() +GameServerInfo StandaloneGameServerCLI::ServerGetInfo() { GameServerInfo info; @@ -51,57 +54,57 @@ GameServerInfo CppStandaloneCLI::ServerGetInfo() return info; } -bool CppStandaloneCLI::ServerIsRunning() +bool StandaloneGameServerCLI::ServerIsRunning() { return DanBias::GameServerAPI::ServerIsRunning(); } -void CppStandaloneCLI::GameSetMapId(const int val) +void StandaloneGameServerCLI::GameSetMapId(const int val) { DanBias::GameServerAPI::GameSetMapId(val); } -void CppStandaloneCLI::GameSetMaxClients(const int val) +void StandaloneGameServerCLI::GameSetMaxClients(const int val) { DanBias::GameServerAPI::GameSetMaxClients(val); } -void CppStandaloneCLI::GameSetGameMode(const int val) +void StandaloneGameServerCLI::GameSetGameMode(const int val) { DanBias::GameServerAPI::GameSetGameMode(val); } -void CppStandaloneCLI::GameSetGameTime(const int val) +void StandaloneGameServerCLI::GameSetGameTime(const int val) { DanBias::GameServerAPI::GameSetGameTime(val); } -int CppStandaloneCLI::GameGetMapId() +int StandaloneGameServerCLI::GameGetMapId() { return DanBias::GameServerAPI::GameGetMapId(); } -int CppStandaloneCLI::GameGetMaxClients() +int StandaloneGameServerCLI::GameGetMaxClients() { return DanBias::GameServerAPI::GameGetMaxClients(); } -int CppStandaloneCLI::GameGetGameMode() +int StandaloneGameServerCLI::GameGetGameMode() { return DanBias::GameServerAPI::GameGetGameMode(); } -int CppStandaloneCLI::GameGetGameTime() +int StandaloneGameServerCLI::GameGetGameTime() { return DanBias::GameServerAPI::GameGetGameTime(); } -String^ CppStandaloneCLI::GameGetGameName() +String^ StandaloneGameServerCLI::GameGetGameName() { return gcnew String(DanBias::GameServerAPI::GameGetGameName()); } -bool CppStandaloneCLI::GameStart() +bool StandaloneGameServerCLI::GameStart() { return DanBias::GameServerAPI::GameStart(); } \ No newline at end of file diff --git a/Code/CLIStandaloneServer/StandaloneGameServerCLI.h b/Code/CLIStandaloneServer/StandaloneGameServerCLI.h new file mode 100644 index 00000000..92ab8783 --- /dev/null +++ b/Code/CLIStandaloneServer/StandaloneGameServerCLI.h @@ -0,0 +1,58 @@ +#ifndef CLISTANDALONESERVER_CPP_Standalone_CLI_H +#define CLISTANDALONESERVER_CPP_Standalone_CLI_H + +#include + +#include "..\Game\GameServer\GameServerAPI.h" + + +namespace System { namespace Windows { namespace Interop +{ + public enum class DanBiasServerReturn + { + DanBiasServerReturn_Error, + DanBiasServerReturn_Sucess, + DanBiasServerReturn_GameNotCreated, + }; + + public value struct ServerInitDesc + { + System::String^ serverName; + int listenPort; + bool broadcast; //Not fully implemented! + + }; + + public value struct GameServerInfo + { + unsigned int listenPort; // If set to 0, the default port 15151 will be used + System::String^ serverIp; // This cant be mofidfied.. + }; + + public ref class StandaloneGameServerCLI + { + public: + StandaloneGameServerCLI(); + ~StandaloneGameServerCLI(); + + DanBiasServerReturn ServerInitiate(ServerInitDesc desc); + void ServerStart(); + void ServerStop(); + void ServerUpdate(); + GameServerInfo ServerGetInfo(); + bool ServerIsRunning(); + + void GameSetMapId(const int val); + void GameSetMaxClients(const int val); + void GameSetGameMode(const int val); + void GameSetGameTime(const int val); + int GameGetMapId(); + int GameGetMaxClients(); + int GameGetGameMode(); + int GameGetGameTime(); + System::String^ GameGetGameName(); + bool GameStart(); + }; + +} } } +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj.user b/Code/Game/DanBiasGame/DanBiasGame.vcxproj.user index 4b847ee6..2e28d6f7 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj.user +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj.user @@ -1,7 +1,7 @@  - false + true $(OutDir) diff --git a/Code/Game/DanBiasGame/GameClientState/MainState.cpp b/Code/Game/DanBiasGame/GameClientState/MainState.cpp index 3c82fc05..81794252 100644 --- a/Code/Game/DanBiasGame/GameClientState/MainState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/MainState.cpp @@ -67,22 +67,16 @@ bool MainState::Init( NetworkClient* nwClient ) return true; } -float mouseX, mouseY; // debug test - GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyInput) { MouseInput mouseState; { - mouseState.x = KeyInput->GetPitch(); - mouseState.y = KeyInput->GetYaw(); + KeyInput->GetMousePos( mouseState.x, mouseState.y ); mouseState.mouseButtonPressed = KeyInput->IsMousePressed(); } EventHandler::Instance().Update( mouseState ); - mouseX = mouseState.x; // debug test - mouseY = mouseState.y; // debug test - return this->privData->nextState; } @@ -91,15 +85,12 @@ bool MainState::Render() Graphics::API::NewFrame(); Graphics::API::StartGuiRender(); - Graphics::API::RenderGuiElement( this->privData->background, Float2(0.5f), Float2(1.0f) ); + Graphics::API::RenderGuiElement( this->privData->background, Float3(0.5f, 0.5f, 1.0f), Float2(1.0f) ); this->privData->guiElements.RenderTexture(); Graphics::API::StartTextRender(); this->privData->guiElements.RenderText(); - Graphics::API::RenderText( ::std::to_wstring(mouseX), Float2(0.2f, 0.5f), Float2(0.2f, 0.05f) ); // debug test - Graphics::API::RenderText( ::std::to_wstring(mouseY), Float2(0.5f, 0.5f), Float2(0.2f, 0.05f) ); // debug test - Graphics::API::EndFrame(); return true; } @@ -108,7 +99,7 @@ bool MainState::Release() { if( this->privData ) { - Graphics::API::DeleteTexture( this->privData->background ); // TODO: @todo bug caught when exiting by X + Graphics::API::DeleteTexture( this->privData->background ); EventHandler::Instance().ReleaseCollection( &this->privData->guiElements ); this->privData = NULL; diff --git a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj.user b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj.user index 4b847ee6..2e28d6f7 100644 --- a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj.user +++ b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj.user @@ -1,7 +1,7 @@  - false + true $(OutDir) diff --git a/Code/Game/GameServer/GameServer.vcxproj.user b/Code/Game/GameServer/GameServer.vcxproj.user index 4b847ee6..2e28d6f7 100644 --- a/Code/Game/GameServer/GameServer.vcxproj.user +++ b/Code/Game/GameServer/GameServer.vcxproj.user @@ -1,7 +1,7 @@  - false + true $(OutDir) diff --git a/Code/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp index bdde6de1..647cee4a 100644 --- a/Code/Game/GameServer/Implementation/GameSession_General.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp @@ -207,7 +207,8 @@ namespace DanBias { if(this->clients[i]) { - Protocol_ObjectCreate oc(this->clients[i]->GetPlayer()->GetOrientation(), this->clients[i]->GetPlayer()->GetID(), "char_white.dan"); + IPlayerData* p = this->clients[i]->GetPlayer(); + Protocol_ObjectCreate oc(p->GetPosition(), p->GetRotation(), p->GetScale(), p->GetID(), "char_white.dan"); this->clients[i]->GetClient()->Send(oc); } } diff --git a/Code/Input/L_inputClass.cpp b/Code/Input/L_inputClass.cpp index 5fd15a54..03271333 100644 --- a/Code/Input/L_inputClass.cpp +++ b/Code/Input/L_inputClass.cpp @@ -5,6 +5,8 @@ InputClass::InputClass() m_directInput = NULL; m_keyboard = NULL; m_mouse = NULL; + mousePosX = 0.0f; + mousePosY = 0.0f; } InputClass::~InputClass() @@ -128,6 +130,13 @@ bool InputClass::Update() return true; } +bool InputClass::Update( float mousePosX, float mousePosY ) +{ + this->mousePosX = mousePosX; + this->mousePosY = mousePosY; + return this->Update(); +} + bool InputClass::ReadKeyboard() { HRESULT result; @@ -198,3 +207,15 @@ bool InputClass::IsKeyPressed(int key) return false; } + +void InputClass::SetMousePos( float x, float y ) +{ + this->mousePosX = y; + this->mousePosY = x; +} + +void InputClass::GetMousePos( float &x, float &y ) +{ + x = this->mousePosX; + y = this->mousePosY; +} \ No newline at end of file diff --git a/Code/Input/L_inputClass.h b/Code/Input/L_inputClass.h index 08358135..8ed8e528 100644 --- a/Code/Input/L_inputClass.h +++ b/Code/Input/L_inputClass.h @@ -14,8 +14,6 @@ #include - - class InputClass { private: @@ -26,6 +24,8 @@ private: unsigned char m_keyboardState[256]; DIMOUSESTATE m_mouseState; + float mousePosX, mousePosY; + bool ReadKeyboard(); bool ReadMouse(); @@ -40,6 +40,7 @@ public: //read the mouse and keyboard and send back // delta mouse pos and if any button is pressed bool Update(); + bool Update( float mousePosX, float mousePosY ); bool IsKeyPressed(int key); bool IsMousePressed(); @@ -48,6 +49,8 @@ public: float GetYaw(); float GetPitch(); + void SetMousePos( float x, float y ); + void GetMousePos( float &x, float &y ); }; #endif \ No newline at end of file diff --git a/Code/StandAloneLauncher/App.config b/Code/StandAloneLauncher/App.config index 8e156463..32412984 100644 --- a/Code/StandAloneLauncher/App.config +++ b/Code/StandAloneLauncher/App.config @@ -3,4 +3,9 @@ - \ No newline at end of file + + + + + + diff --git a/Code/StandAloneLauncher/Form1.Designer.cs b/Code/StandAloneLauncher/Form1.Designer.cs index 3ee09fcb..82913f45 100644 --- a/Code/StandAloneLauncher/Form1.Designer.cs +++ b/Code/StandAloneLauncher/Form1.Designer.cs @@ -28,20 +28,154 @@ /// private void InitializeComponent() { + this.serverToggle = new System.Windows.Forms.Button(); + this.lanBroadcast = new System.Windows.Forms.CheckBox(); + this.serverName = new System.Windows.Forms.TextBox(); + this.label_serverName = new System.Windows.Forms.Label(); + this.listenPort = new System.Windows.Forms.NumericUpDown(); + this.label_listenPort = new System.Windows.Forms.Label(); + this.panel_serverOptions = new System.Windows.Forms.Panel(); + this.panel_commands = new System.Windows.Forms.Panel(); + this.panel_clientArea = new System.Windows.Forms.Panel(); + this.clientInfoBox = new System.Windows.Forms.ListBox(); + ((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit(); + this.panel_serverOptions.SuspendLayout(); + this.panel_clientArea.SuspendLayout(); this.SuspendLayout(); // + // serverToggle + // + this.serverToggle.Location = new System.Drawing.Point(90, 81); + this.serverToggle.Name = "serverToggle"; + this.serverToggle.Size = new System.Drawing.Size(75, 23); + this.serverToggle.TabIndex = 0; + this.serverToggle.Text = "Start server"; + this.serverToggle.UseVisualStyleBackColor = true; + this.serverToggle.Click += new System.EventHandler(this.button1_serverToggle_Click); + // + // lanBroadcast + // + this.lanBroadcast.AutoSize = true; + this.lanBroadcast.Location = new System.Drawing.Point(81, 58); + this.lanBroadcast.Name = "lanBroadcast"; + this.lanBroadcast.Size = new System.Drawing.Size(95, 17); + this.lanBroadcast.TabIndex = 1; + this.lanBroadcast.Text = "Lan Broadcast"; + this.lanBroadcast.UseVisualStyleBackColor = true; + // + // serverName + // + this.serverName.Location = new System.Drawing.Point(81, 3); + this.serverName.Name = "serverName"; + this.serverName.Size = new System.Drawing.Size(95, 20); + this.serverName.TabIndex = 3; + // + // label_serverName + // + this.label_serverName.AutoSize = true; + this.label_serverName.Location = new System.Drawing.Point(6, 6); + this.label_serverName.Name = "label_serverName"; + this.label_serverName.Size = new System.Drawing.Size(69, 13); + this.label_serverName.TabIndex = 4; + this.label_serverName.Text = "Server Name"; + // + // listenPort + // + this.listenPort.Location = new System.Drawing.Point(81, 29); + this.listenPort.Maximum = new decimal(new int[] { + 65000, + 0, + 0, + 0}); + this.listenPort.Minimum = new decimal(new int[] { + 2048, + 0, + 0, + 0}); + this.listenPort.Name = "listenPort"; + this.listenPort.Size = new System.Drawing.Size(95, 20); + this.listenPort.TabIndex = 5; + this.listenPort.Value = new decimal(new int[] { + 2048, + 0, + 0, + 0}); + // + // label_listenPort + // + this.label_listenPort.AutoSize = true; + this.label_listenPort.Location = new System.Drawing.Point(6, 31); + this.label_listenPort.Name = "label_listenPort"; + this.label_listenPort.Size = new System.Drawing.Size(56, 13); + this.label_listenPort.TabIndex = 4; + this.label_listenPort.Text = "Listen port"; + // + // panel_serverOptions + // + this.panel_serverOptions.Controls.Add(this.serverName); + this.panel_serverOptions.Controls.Add(this.listenPort); + this.panel_serverOptions.Controls.Add(this.serverToggle); + this.panel_serverOptions.Controls.Add(this.label_listenPort); + this.panel_serverOptions.Controls.Add(this.lanBroadcast); + this.panel_serverOptions.Controls.Add(this.label_serverName); + this.panel_serverOptions.Location = new System.Drawing.Point(12, 12); + this.panel_serverOptions.Name = "panel_serverOptions"; + this.panel_serverOptions.Size = new System.Drawing.Size(183, 112); + this.panel_serverOptions.TabIndex = 6; + // + // panel_commands + // + this.panel_commands.Location = new System.Drawing.Point(12, 130); + this.panel_commands.Name = "panel_commands"; + this.panel_commands.Size = new System.Drawing.Size(183, 231); + this.panel_commands.TabIndex = 7; + // + // panel_clientArea + // + this.panel_clientArea.Controls.Add(this.clientInfoBox); + this.panel_clientArea.Location = new System.Drawing.Point(202, 12); + this.panel_clientArea.Name = "panel_clientArea"; + this.panel_clientArea.Size = new System.Drawing.Size(303, 349); + this.panel_clientArea.TabIndex = 8; + // + // clientInfoBox + // + this.clientInfoBox.FormattingEnabled = true; + this.clientInfoBox.Location = new System.Drawing.Point(3, 6); + this.clientInfoBox.Name = "clientInfoBox"; + this.clientInfoBox.Size = new System.Drawing.Size(297, 342); + this.clientInfoBox.TabIndex = 0; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(791, 318); + this.ClientSize = new System.Drawing.Size(517, 373); + this.Controls.Add(this.panel_clientArea); + this.Controls.Add(this.panel_commands); + this.Controls.Add(this.panel_serverOptions); this.Name = "Form1"; this.Text = "Form1"; + ((System.ComponentModel.ISupportInitialize)(this.listenPort)).EndInit(); + this.panel_serverOptions.ResumeLayout(false); + this.panel_serverOptions.PerformLayout(); + this.panel_clientArea.ResumeLayout(false); this.ResumeLayout(false); } #endregion + + private System.Windows.Forms.Button serverToggle; + private System.Windows.Forms.CheckBox lanBroadcast; + private System.Windows.Forms.TextBox serverName; + private System.Windows.Forms.Label label_serverName; + private System.Windows.Forms.NumericUpDown listenPort; + private System.Windows.Forms.Label label_listenPort; + private System.Windows.Forms.Panel panel_serverOptions; + private System.Windows.Forms.Panel panel_commands; + private System.Windows.Forms.Panel panel_clientArea; + private System.Windows.Forms.ListBox clientInfoBox; } } diff --git a/Code/StandAloneLauncher/Form1.cs b/Code/StandAloneLauncher/Form1.cs index cd716360..56d69810 100644 --- a/Code/StandAloneLauncher/Form1.cs +++ b/Code/StandAloneLauncher/Form1.cs @@ -7,14 +7,69 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Windows.Interop; +using System.Runtime.InteropServices; namespace StandAloneLauncher { public partial class Form1 : Form { + System.Windows.Interop.StandaloneGameServerCLI gameServer; + bool serverIsRunning = false; + public Form1() { InitializeComponent(); + + + } + + public bool Initiate() + { + this.gameServer = new StandaloneGameServerCLI(); + + return true; + } + public void Run() + { + while (this.Created) + { + Application.DoEvents(); + + //Do some stuff + this.gameServer.ServerUpdate(); + } + } + + private void button1_serverToggle_Click(object sender, EventArgs e) + { + if (this.serverIsRunning) + { + this.serverIsRunning = false; + this.gameServer.ServerStop(); + this.listenPort.Enabled = true; + this.serverName.Enabled = true; + this.lanBroadcast.Enabled = true; + this.serverToggle.Text = "Start server"; + } + else + { + this.serverIsRunning = true; + ServerInitDesc desc = new ServerInitDesc(); + desc.broadcast = this.lanBroadcast.Checked; + desc.listenPort = (int)this.listenPort.Value; + desc.serverName = this.serverName.Text; + + if (this.gameServer.ServerInitiate(desc) == DanBiasServerReturn.DanBiasServerReturn_Sucess) + { + this.listenPort.Enabled = false; + this.serverName.Enabled = false; + this.lanBroadcast.Enabled = false; + this.serverToggle.Text = "Stop server"; + this.gameServer.ServerStart(); + this.clientInfoBox.Items.Add((Object)"Server initiated!"); + } + } } } } diff --git a/Code/StandAloneLauncher/Program.cs b/Code/StandAloneLauncher/Program.cs index 80169b50..22102cec 100644 --- a/Code/StandAloneLauncher/Program.cs +++ b/Code/StandAloneLauncher/Program.cs @@ -16,7 +16,13 @@ namespace StandAloneLauncher { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); + //Application.Run(new Form1()); + + + Form1 myf = new Form1(); + myf.Show(); + myf.Initiate(); + myf.Run(); } } } diff --git a/Code/StandAloneLauncher/StandAloneLauncher.csproj b/Code/StandAloneLauncher/StandAloneLauncher.csproj index fad6a6a6..8cedeb8f 100644 --- a/Code/StandAloneLauncher/StandAloneLauncher.csproj +++ b/Code/StandAloneLauncher/StandAloneLauncher.csproj @@ -17,32 +17,35 @@ true full false - bin\Debug\ + ..\..\Bin\DLL\ DEBUG;TRACE prompt 4 + true AnyCPU pdbonly true - bin\Release\ + ..\..\Bin\DLL\ TRACE prompt 4 + true true - bin\x64\Debug\ + ..\..\Bin\DLL\ DEBUG;TRACE full x64 prompt MinimumRecommendedRules.ruleset true + true - bin\x64\Release\ + ..\..\Bin\DLL\ TRACE true pdbonly @@ -50,19 +53,21 @@ prompt MinimumRecommendedRules.ruleset true + true true - bin\x86\Debug\ + ..\..\Bin\DLL\ DEBUG;TRACE full x86 prompt MinimumRecommendedRules.ruleset true + true - bin\x86\Release\ + ..\..\Bin\DLL\ TRACE true pdbonly @@ -70,6 +75,7 @@ prompt MinimumRecommendedRules.ruleset true + true @@ -121,8 +127,12 @@ {c8cba520-5d7d-4d61-a8da-6e05fd132bcb} CLIStandaloneServer + False + + +