/// <summary> /// Loads graphics content for this screen. This uses the shared ContentManager /// provided by the Game class, so the content will remain loaded forever. /// Whenever a subsequent MessageBoxScreen tries to load this same content, /// it will just get back another reference to the already loaded data. /// </summary> public override void LoadContent() { base.LoadContent(); Btn_Ok.Clicked += new EventHandler <vxGuiItemClickEventArgs>(Btn_Ok_Clicked); Btn_Cancel.Clicked += new EventHandler <vxGuiItemClickEventArgs>(Btn_Cancel_Clicked); Btn_Apply.Clicked += new EventHandler <vxGuiItemClickEventArgs>(Btn_Apply_Clicked); Btn_Apply.Text = "Refresh"; ScrollPanel = new vxListView( new Vector2( this.ArtProvider.BoundingGUIRectangle.X + this.ArtProvider.Padding.X, this.ArtProvider.BoundingGUIRectangle.Y + this.ArtProvider.Padding.Y), (int)(this.ArtProvider.BoundingGUIRectangle.Width - this.ArtProvider.Padding.X * 2), (int)(this.ArtProvider.BoundingGUIRectangle.Height - Btn_Ok.BoundingRectangle.Height - this.ArtProvider.Padding.Y * 3)); InternalvxGUIManager.Add(ScrollPanel); vxEngine.GameServerListRecieved += new EventHandler <vxGameServerListRecievedEventArgs>(Engine_GameServerListRecieved); //Send the request string vxEngine.SendMessage("vrtx_request_serverList"); }
/// <summary> /// Sets up Local Server Dialog. It also sends out the subnet broadcast here searching for any available servers on this subnet. /// </summary> public override void LoadContent() { base.LoadContent(); //The Okay Button here Acts as the "Ready" button for the Server Lobby Btn_Ok.Clicked += new EventHandler<vxGuiItemClickEventArgs>(Btn_Ok_Clicked); //The Cancel Button is Naturally the 'Back' button Btn_Cancel.Clicked += new EventHandler<vxGuiItemClickEventArgs>(Btn_Cancel_Clicked); ScrollPanel = new vxScrollPanel( new Vector2( this.ArtProvider.BoundingGUIRectangle.X + this.ArtProvider.Padding.X, this.ArtProvider.BoundingGUIRectangle.Y + this.ArtProvider.Padding.Y), (int)(this.ArtProvider.BoundingGUIRectangle.Width - this.ArtProvider.Padding.X * 2), (int)(this.ArtProvider.BoundingGUIRectangle.Height - Btn_Ok.BoundingRectangle.Height - this.ArtProvider.Padding.Y * 3)); ScrollPanel.ScrollBarWidth = 15; //Setup Client Events vxEngine.ClientManager.OtherPlayerConnected += ClientManager_OtherPlayerConnected; vxEngine.ClientManager.OtherPlayerDisconnected += ClientManager_OtherPlayerDisconnected; InternalvxGUIManager.Add(ScrollPanel); //Set up the Server Code if (vxEngine.NetworkedGameRoll == vxEnumNetworkPlayerRole.Server) { Vector2 viewportSize = new Vector2(vxEngine.GraphicsDevice.Viewport.Width, vxEngine.GraphicsDevice.Viewport.Height); //Create The New Server Button Btn_LaunchServer = new vxButton(vxEngine, "Launch Game", new Vector2(viewportSize.X / 2 - 115, viewportSize.Y / 2 + 20)); //Set the Button's Position relative too the background rectangle. Btn_LaunchServer.Position = new Vector2( this.ArtProvider.BoundingGUIRectangle.X, this.ArtProvider.BoundingGUIRectangle.Y) + new Vector2( vxEngine.vxGUITheme.Padding.X * 2, this.ArtProvider.BoundingGUIRectangle.Height - vxEngine.vxGUITheme.ArtProviderForButtons.DefaultHeight - vxEngine.vxGUITheme.Padding.Y * 2); Btn_LaunchServer.Clicked += Btn_LaunchServer_Clicked; ; InternalvxGUIManager.Add(Btn_LaunchServer); //Now Start The Server vxEngine.ServerManager.Start(); //Now Connect to it's self if it's the Server NetOutgoingMessage approval = vxEngine.ClientManager.CreateMessage(); approval.Write("secret"); vxEngine.ClientManager.Connect(NetUtility.Resolve("localhost").ToString(), vxEngine.ServerManager.Server.Configuration.Port, approval); } //vxEngine.NetworkedGameRoll == vxEnumNetworkPlayerRole.Client //The Server acts as a Client as well, so no need for an 'else if' block here. Btn_Ok.Text = "Not Ready"; }
/// <summary> /// Sets up Local Server Dialog. It also sends out the subnet broadcast here searching for any available servers on this subnet. /// </summary> public override void LoadContent() { base.LoadContent(); Vector2 viewportSize = new Vector2(vxEngine.GraphicsDevice.Viewport.Width, vxEngine.GraphicsDevice.Viewport.Height); //Create The New Server Button Btn_CreateNewLocalServer = new vxButton(vxEngine, "Create New Local Server", new Vector2(viewportSize.X / 2 - 115, viewportSize.Y / 2 + 20)); //Set the Button's Position relative too the background rectangle. Btn_CreateNewLocalServer.Position = new Vector2( this.ArtProvider.BoundingGUIRectangle.X, this.ArtProvider.BoundingGUIRectangle.Y) + new Vector2( vxEngine.vxGUITheme.Padding.X * 2, this.ArtProvider.BoundingGUIRectangle.Height - vxEngine.vxGUITheme.ArtProviderForButtons.DefaultHeight - vxEngine.vxGUITheme.Padding.Y * 2); Btn_CreateNewLocalServer.Clicked += Btn_CreateNewLocalServer_Clicked; InternalvxGUIManager.Add(Btn_CreateNewLocalServer); //The Okay Button here Selects the Selected Server in the List Btn_Ok.Clicked += new EventHandler <vxGuiItemClickEventArgs>(Btn_Ok_Clicked); //The Cancel Button is Naturally the 'Back' button Btn_Cancel.Clicked += new EventHandler <vxGuiItemClickEventArgs>(Btn_Cancel_Clicked); //The Apply Button here is used to start a New Server Btn_Apply.Clicked += Btn_Refresh_Clicked;// new EventHandler<vxGuiItemClickEventArgs>(Btn_Refresh_Clicked); Btn_Apply.Text = "Refresh"; ScrollPanel = new vxScrollPanel( new Vector2( this.ArtProvider.BoundingGUIRectangle.X + this.ArtProvider.Padding.X, this.ArtProvider.BoundingGUIRectangle.Y + this.ArtProvider.Padding.Y), (int)(this.ArtProvider.BoundingGUIRectangle.Width - this.ArtProvider.Padding.X * 2), (int)(this.ArtProvider.BoundingGUIRectangle.Height - Btn_Ok.BoundingRectangle.Height - this.ArtProvider.Padding.Y * 3)); ScrollPanel.ScrollBarWidth = 15; InternalvxGUIManager.Add(ScrollPanel); //Initialise the network client vxEngine.ClientManager.Init(); //Now setup the Event Handlers vxEngine.ClientManager.DiscoverySignalResponseRecieved += ClientManager_DiscoverySignalResponseRecieved; //By Default, The Game will start looking for other networked games as a client. vxEngine.NetworkedGameRoll = vxEnumNetworkPlayerRole.Client; //Finally at the end, send out a pulse of discovery signals vxConsole.WriteLine("Sending Discovery Signal..."); SendDiscoverySignal(); }
/// <summary> /// Loads graphics content for this screen. This uses the shared ContentManager /// provided by the Game class, so the content will remain loaded forever. /// Whenever a subsequent MessageBoxScreen tries to load this same content, /// it will just get back another reference to the already loaded data. /// </summary> public override void LoadContent() { base.LoadContent(); Btn_Ok.Clicked += new EventHandler <vxGuiItemClickEventArgs>(Btn_Ok_Clicked); Btn_Cancel.Clicked += new EventHandler <vxGuiItemClickEventArgs>(Btn_Cancel_Clicked); ScrollPanel = new vxScrollPanel( new Vector2( this.ArtProvider.BoundingGUIRectangle.X + this.ArtProvider.Padding.X, this.ArtProvider.BoundingGUIRectangle.Y + this.ArtProvider.Padding.Y) + this.ArtProvider.PosOffset, this.ArtProvider.BoundingGUIRectangle.Width - (int)this.ArtProvider.Padding.X * 2, this.ArtProvider.BoundingGUIRectangle.Height - Btn_Ok.BoundingRectangle.Height - (int)this.ArtProvider.Padding.Y * 4); InternalvxGUIManager.Add(ScrollPanel); }