// public DLLPage(EControl pageControl) : base(pageControl) { comboBox = (EComboBox)PageControl.Controls["InformationType"]; comboBox.Items.Add("Managed assemblies"); comboBox.Items.Add("DLLs"); comboBox.SelectedIndex = 0; comboBox.SelectedIndexChange += ComboBox_SelectedIndexChange; }
void comboBoxMaps_SelectedIndexChange(EComboBox sender) { lastMapName = SelectedMapName; //send map name to clients GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { server.CustomMessagesService.SendToAllClients("Lobby_MapName", SelectedMapName); } }
void ComboBox_SelectedIndexChange( EComboBox sender ) { updated = false; }
// public DLLPage( EControl pageControl ) : base(pageControl) { comboBox = (EComboBox)PageControl.Controls[ "InformationType" ]; comboBox.Items.Add( "Managed assemblies" ); comboBox.Items.Add( "DLLs" ); comboBox.SelectedIndex = 0; comboBox.SelectedIndexChange += ComboBox_SelectedIndexChange; }
/////////////////////////////////////////// protected override void OnAttach() { base.OnAttach(); EComboBox comboBox; EScrollBar scrollBar; ECheckBox checkBox; window = ControlDeclarationManager.Instance.CreateControl( "Gui\\OptionsWindow.gui" ); Controls.Add( window ); ( (EButton)window.Controls[ "Options" ].Controls[ "Quit" ] ).Click += delegate( EButton sender ) { SetShouldDetach(); }; //pageVideo { EControl pageVideo = window.Controls[ "TabControl" ].Controls[ "Video" ]; Vec2i currentMode = EngineApp.Instance.VideoMode; //screenResolutionComboBox comboBox = (EComboBox)pageVideo.Controls[ "ScreenResolution" ]; comboBox.Enable = !EngineApp.Instance.WebPlayerMode; comboBoxResolution = comboBox; foreach( Vec2i mode in DisplaySettings.VideoModes ) { if( mode.X < 640 ) continue; comboBox.Items.Add( mode.X.ToString() + "x" + mode.Y.ToString() ); if( mode == currentMode ) comboBox.SelectedIndex = comboBox.Items.Count - 1; } comboBox.SelectedIndexChange += delegate( EComboBox sender ) { ChangeVideoMode(); }; //gamma scrollBar = (EScrollBar)pageVideo.Controls[ "Gamma" ]; scrollBar.Value = GameEngineApp._Gamma; scrollBar.Enable = !EngineApp.Instance.WebPlayerMode; scrollBar.ValueChange += delegate( EScrollBar sender ) { float value = float.Parse( sender.Value.ToString( "F1" ) ); GameEngineApp._Gamma = value; pageVideo.Controls[ "GammaValue" ].Text = value.ToString( "F1" ); }; pageVideo.Controls[ "GammaValue" ].Text = GameEngineApp._Gamma.ToString( "F1" ); //MaterialScheme { comboBox = (EComboBox)pageVideo.Controls[ "MaterialScheme" ]; foreach( MaterialSchemes materialScheme in Enum.GetValues( typeof( MaterialSchemes ) ) ) { comboBox.Items.Add( materialScheme.ToString() ); if( GameEngineApp.MaterialScheme == materialScheme ) comboBox.SelectedIndex = comboBox.Items.Count - 1; } comboBox.SelectedIndexChange += delegate( EComboBox sender ) { if( sender.SelectedIndex != -1 ) GameEngineApp.MaterialScheme = (MaterialSchemes)sender.SelectedIndex; }; } //ShadowTechnique { comboBox = (EComboBox)pageVideo.Controls[ "ShadowTechnique" ]; comboBox.Items.Add( new ShadowTechniqueItem( ShadowTechniques.None, "None" ) ); comboBox.Items.Add( new ShadowTechniqueItem( ShadowTechniques.ShadowmapLow, "Low" ) ); comboBox.Items.Add( new ShadowTechniqueItem( ShadowTechniques.ShadowmapMedium, "Medium (shaders 3.0 only)" ) ); comboBox.Items.Add( new ShadowTechniqueItem( ShadowTechniques.ShadowmapHigh, "High (shaders 3.0 only)" ) ); comboBox.Items.Add( new ShadowTechniqueItem( ShadowTechniques.Stencil, "Stencil" ) ); for( int n = 0; n < comboBox.Items.Count; n++ ) { ShadowTechniqueItem item = (ShadowTechniqueItem)comboBox.Items[ n ]; if( item.Technique == GameEngineApp.ShadowTechnique ) comboBox.SelectedIndex = n; } comboBox.SelectedIndexChange += delegate( EComboBox sender ) { if( sender.SelectedIndex != -1 ) { ShadowTechniqueItem item = (ShadowTechniqueItem)sender.SelectedItem; GameEngineApp.ShadowTechnique = item.Technique; } UpdateShadowControlsEnable(); }; UpdateShadowControlsEnable(); } //ShadowUseMapSettings { checkBox = (ECheckBox)pageVideo.Controls[ "ShadowUseMapSettings" ]; checkBox.Checked = GameEngineApp.ShadowUseMapSettings; checkBox.CheckedChange += delegate( ECheckBox sender ) { GameEngineApp.ShadowUseMapSettings = sender.Checked; if( sender.Checked && Map.Instance != null ) { GameEngineApp.ShadowFarDistance = Map.Instance.InitialShadowFarDistance; GameEngineApp.ShadowColor = Map.Instance.InitialShadowColor; } UpdateShadowControlsEnable(); if( sender.Checked ) { ( (EScrollBar)pageVideo.Controls[ "ShadowFarDistance" ] ).Value = GameEngineApp.ShadowFarDistance; pageVideo.Controls[ "ShadowFarDistanceValue" ].Text = ( (int)GameEngineApp.ShadowFarDistance ).ToString(); ColorValue color = GameEngineApp.ShadowColor; ( (EScrollBar)pageVideo.Controls[ "ShadowColor" ] ).Value = ( color.Red + color.Green + color.Blue ) / 3; } }; } //ShadowFarDistance scrollBar = (EScrollBar)pageVideo.Controls[ "ShadowFarDistance" ]; scrollBar.Value = GameEngineApp.ShadowFarDistance; scrollBar.ValueChange += delegate( EScrollBar sender ) { GameEngineApp.ShadowFarDistance = sender.Value; pageVideo.Controls[ "ShadowFarDistanceValue" ].Text = ( (int)GameEngineApp.ShadowFarDistance ).ToString(); }; pageVideo.Controls[ "ShadowFarDistanceValue" ].Text = ( (int)GameEngineApp.ShadowFarDistance ).ToString(); //ShadowColor scrollBar = (EScrollBar)pageVideo.Controls[ "ShadowColor" ]; scrollBar.Value = ( GameEngineApp.ShadowColor.Red + GameEngineApp.ShadowColor.Green + GameEngineApp.ShadowColor.Blue ) / 3; scrollBar.ValueChange += delegate( EScrollBar sender ) { float color = sender.Value; GameEngineApp.ShadowColor = new ColorValue( color, color, color, color ); }; //Shadow2DTextureSize comboBox = (EComboBox)pageVideo.Controls[ "Shadow2DTextureSize" ]; comboBox.Items.Add( 256 ); comboBox.Items.Add( 512 ); comboBox.Items.Add( 1024 ); comboBox.Items.Add( 2048 ); if( GameEngineApp.Shadow2DTextureSize == 256 ) comboBox.SelectedIndex = 0; if( GameEngineApp.Shadow2DTextureSize == 512 ) comboBox.SelectedIndex = 1; else if( GameEngineApp.Shadow2DTextureSize == 1024 ) comboBox.SelectedIndex = 2; else if( GameEngineApp.Shadow2DTextureSize == 2048 ) comboBox.SelectedIndex = 3; comboBox.SelectedIndexChange += delegate( EComboBox sender ) { GameEngineApp.Shadow2DTextureSize = (int)sender.SelectedItem; }; //Shadow2DTextureCount comboBox = (EComboBox)pageVideo.Controls[ "Shadow2DTextureCount" ]; for( int n = 0; n < 3; n++ ) { int count = n + 1; comboBox.Items.Add( count ); if( count == GameEngineApp.Shadow2DTextureCount ) comboBox.SelectedIndex = n; } comboBox.SelectedIndexChange += delegate( EComboBox sender ) { GameEngineApp.Shadow2DTextureCount = (int)sender.SelectedItem; }; //ShadowCubicTextureSize comboBox = (EComboBox)pageVideo.Controls[ "ShadowCubicTextureSize" ]; comboBox.Items.Add( 256 ); comboBox.Items.Add( 512 ); comboBox.Items.Add( 1024 ); comboBox.Items.Add( 2048 ); if( GameEngineApp.ShadowCubicTextureSize == 256 ) comboBox.SelectedIndex = 0; if( GameEngineApp.ShadowCubicTextureSize == 512 ) comboBox.SelectedIndex = 1; else if( GameEngineApp.ShadowCubicTextureSize == 1024 ) comboBox.SelectedIndex = 2; else if( GameEngineApp.ShadowCubicTextureSize == 2048 ) comboBox.SelectedIndex = 3; comboBox.SelectedIndexChange += delegate( EComboBox sender ) { GameEngineApp.ShadowCubicTextureSize = (int)sender.SelectedItem; }; //ShadowCubicTextureCount comboBox = (EComboBox)pageVideo.Controls[ "ShadowCubicTextureCount" ]; for( int n = 0; n < 3; n++ ) { int count = n + 1; comboBox.Items.Add( count ); if( count == GameEngineApp.ShadowCubicTextureCount ) comboBox.SelectedIndex = n; } comboBox.SelectedIndexChange += delegate( EComboBox sender ) { GameEngineApp.ShadowCubicTextureCount = (int)sender.SelectedItem; }; //fullScreenCheckBox checkBox = (ECheckBox)pageVideo.Controls[ "FullScreen" ]; checkBox.Enable = !EngineApp.Instance.WebPlayerMode; checkBox.Checked = EngineApp.Instance.FullScreen; checkBox.CheckedChange += delegate( ECheckBox sender ) { EngineApp.Instance.FullScreen = sender.Checked; }; //waterReflectionLevel comboBox = (EComboBox)pageVideo.Controls[ "WaterReflectionLevel" ]; foreach( WaterPlane.ReflectionLevels level in Enum.GetValues( typeof( WaterPlane.ReflectionLevels ) ) ) { comboBox.Items.Add( level ); if( GameEngineApp.WaterReflectionLevel == level ) comboBox.SelectedIndex = comboBox.Items.Count - 1; } comboBox.SelectedIndexChange += delegate( EComboBox sender ) { GameEngineApp.WaterReflectionLevel = (WaterPlane.ReflectionLevels)sender.SelectedItem; }; //showDecorativeObjects checkBox = (ECheckBox)pageVideo.Controls[ "ShowDecorativeObjects" ]; checkBox.Checked = GameEngineApp.ShowDecorativeObjects; checkBox.CheckedChange += delegate( ECheckBox sender ) { GameEngineApp.ShowDecorativeObjects = sender.Checked; }; //showSystemCursorCheckBox checkBox = (ECheckBox)pageVideo.Controls[ "ShowSystemCursor" ]; checkBox.Checked = GameEngineApp._ShowSystemCursor; checkBox.CheckedChange += delegate( ECheckBox sender ) { GameEngineApp._ShowSystemCursor = sender.Checked; sender.Checked = GameEngineApp._ShowSystemCursor; }; //showFPSCheckBox checkBox = (ECheckBox)pageVideo.Controls[ "ShowFPS" ]; checkBox.Checked = GameEngineApp._DrawFPS; checkBox.CheckedChange += delegate( ECheckBox sender ) { GameEngineApp._DrawFPS = sender.Checked; sender.Checked = GameEngineApp._DrawFPS; }; } //pageSound { EControl pageSound = window.Controls[ "TabControl" ].Controls[ "Sound" ]; //soundVolumeCheckBox scrollBar = (EScrollBar)pageSound.Controls[ "SoundVolume" ]; scrollBar.Value = GameEngineApp.SoundVolume; scrollBar.ValueChange += delegate( EScrollBar sender ) { GameEngineApp.SoundVolume = sender.Value; }; //musicVolumeCheckBox scrollBar = (EScrollBar)pageSound.Controls[ "MusicVolume" ]; scrollBar.Value = GameEngineApp.MusicVolume; scrollBar.ValueChange += delegate( EScrollBar sender ) { GameEngineApp.MusicVolume = sender.Value; }; } //pageControls { EControl pageControls = window.Controls[ "TabControl" ].Controls[ "Controls" ]; //MouseHSensitivity scrollBar = (EScrollBar)pageControls.Controls[ "MouseHSensitivity" ]; scrollBar.Value = GameControlsManager.Instance.MouseSensitivity.X; scrollBar.ValueChange += delegate( EScrollBar sender ) { Vec2 value = GameControlsManager.Instance.MouseSensitivity; value.X = sender.Value; GameControlsManager.Instance.MouseSensitivity = value; }; //MouseVSensitivity scrollBar = (EScrollBar)pageControls.Controls[ "MouseVSensitivity" ]; scrollBar.Value = Math.Abs( GameControlsManager.Instance.MouseSensitivity.Y ); scrollBar.ValueChange += delegate( EScrollBar sender ) { Vec2 value = GameControlsManager.Instance.MouseSensitivity; bool invert = ( (ECheckBox)pageControls.Controls[ "MouseVInvert" ] ).Checked; value.Y = sender.Value * ( invert ? -1.0f : 1.0f ); GameControlsManager.Instance.MouseSensitivity = value; }; //MouseVInvert checkBox = (ECheckBox)pageControls.Controls[ "MouseVInvert" ]; checkBox.Checked = GameControlsManager.Instance.MouseSensitivity.Y < 0; checkBox.CheckedChange += delegate( ECheckBox sender ) { Vec2 value = GameControlsManager.Instance.MouseSensitivity; value.Y = ( (EScrollBar)pageControls.Controls[ "MouseVSensitivity" ] ).Value * ( sender.Checked ? -1.0f : 1.0f ); GameControlsManager.Instance.MouseSensitivity = value; }; //Devices comboBox = (EComboBox)pageControls.Controls[ "InputDevices" ]; comboBoxInputDevices = comboBox; comboBox.Items.Add( "Keyboard/Mouse" ); if( InputDeviceManager.Instance != null ) { foreach( InputDevice device in InputDeviceManager.Instance.Devices ) comboBox.Items.Add( device ); } comboBox.SelectedIndex = 0; comboBox.SelectedIndexChange += delegate( EComboBox sender ) { UpdateBindedInputControlsTextBox(); }; //Controls UpdateBindedInputControlsTextBox(); } }
// protected override void OnAttach() { base.OnAttach(); window = ControlDeclarationManager.Instance.CreateControl( "Gui\\MapsWindow.gui" ); Controls.Add( window ); string[] mapList = VirtualDirectory.GetFiles( "", "*.map", SearchOption.AllDirectories ); //maps listBox { listBox = (EListBox)window.Controls[ "List" ]; //dynamic map example listBox.Items.Add( dynamicMapExampleText ); foreach( string name in mapList ) { listBox.Items.Add( name ); if( Map.Instance != null ) { if( string.Compare( name.Replace( '/', '\\' ), Map.Instance.VirtualFileName.Replace( '/', '\\' ), true ) == 0 ) listBox.SelectedIndex = listBox.Items.Count - 1; } } listBox.SelectedIndexChange += listBox_SelectedIndexChanged; if( listBox.Items.Count != 0 && listBox.SelectedIndex == -1 ) listBox.SelectedIndex = 0; if( listBox.Items.Count != 0 ) listBox_SelectedIndexChanged( null ); listBox.ItemMouseDoubleClick += delegate( object sender, EListBox.ItemMouseEventArgs e ) { RunMap( (string)e.Item ); }; } //autorunMap comboBoxAutorunMap = (EComboBox)window.Controls[ "autorunMap" ]; if( comboBoxAutorunMap != null ) { comboBoxAutorunMap.Items.Add( "(None)" ); comboBoxAutorunMap.SelectedIndex = 0; foreach( string name in mapList ) { comboBoxAutorunMap.Items.Add( name ); if( string.Compare( GameEngineApp.autorunMapName, name, true ) == 0 ) comboBoxAutorunMap.SelectedIndex = comboBoxAutorunMap.Items.Count - 1; } comboBoxAutorunMap.SelectedIndexChange += delegate( EComboBox sender ) { if( sender.SelectedIndex != 0 ) GameEngineApp.autorunMapName = (string)sender.SelectedItem; else GameEngineApp.autorunMapName = ""; }; } //Run button event handler ( (EButton)window.Controls[ "Run" ] ).Click += delegate( EButton sender ) { if( listBox.SelectedIndex != -1 ) RunMap( (string)listBox.SelectedItem ); }; //Quit button event handler ( (EButton)window.Controls[ "Quit" ] ).Click += delegate( EButton sender ) { SetShouldDetach(); }; }
void ComboBox_SelectedIndexChange(EComboBox sender) { updated = false; }
/////////////////////////////////////////// protected override void OnAttach() { base.OnAttach(); //register config fields EngineApp.Instance.Config.RegisterClassParameters(GetType()); //create window window = ControlDeclarationManager.Instance.CreateControl( "Gui\\MultiplayerLobbyWindow.gui"); Controls.Add(window); ((EButton)window.Controls["Exit"]).Click += Exit_Click; buttonStart = (EButton)window.Controls["Start"]; if (GameNetworkServer.Instance != null) { buttonStart.Click += Start_Click; } if (GameNetworkClient.Instance != null) { buttonStart.Enable = false; } listBoxUsers = (EListBox)window.Controls["Users"]; editBoxChatMessage = (EEditBox)window.Controls["ChatMessage"]; editBoxChatMessage.PreKeyDown += editBoxChatMessage_PreKeyDown; //comboBoxMaps { comboBoxMaps = (EComboBox)window.Controls["Maps"]; if (GameNetworkServer.Instance != null) { //dynamic map example comboBoxMaps.Items.Add(new MapItem(dynamicMapExampleText, false)); if (lastMapName == dynamicMapExampleText) { comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; } string[] mapList = VirtualDirectory.GetFiles("", "*.map", SearchOption.AllDirectories); foreach (string mapName in mapList) { //check for network support if (VirtualFile.Exists(string.Format("{0}\\NoNetworkSupport.txt", Path.GetDirectoryName(mapName)))) { continue; } bool recommended = mapName.Contains("JigsawPuzzleGame") || mapName.Contains("TankDemo") || mapName.Contains("DeathmatchDemo"); comboBoxMaps.Items.Add(new MapItem(mapName, recommended)); if (mapName == lastMapName) { comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; } } comboBoxMaps.SelectedIndexChange += comboBoxMaps_SelectedIndexChange; if (comboBoxMaps.Items.Count != 0 && comboBoxMaps.SelectedIndex == -1) { comboBoxMaps.SelectedIndex = 0; } } else { comboBoxMaps.Enable = false; } } //checkBoxAllowToConnectDuringGame { checkBoxAllowToConnectDuringGame = (ECheckBox)window.Controls[ "AllowToConnectDuringGame"]; if (GameNetworkServer.Instance != null) { checkBoxAllowToConnectDuringGame.CheckedChange += checkBoxAllowToConnectDuringGame_CheckedChange; } else { checkBoxAllowToConnectDuringGame.Enable = false; } } //server specific GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { //for receive map name server.UserManagementService.AddUserEvent += Server_UserManagementService_AddUserEvent; //for chat support server.ChatService.ReceiveText += Server_ChatService_ReceiveText; } //client specific GameNetworkClient client = GameNetworkClient.Instance; if (client != null) { //for receive map name client.CustomMessagesService.ReceiveMessage += Client_CustomMessagesService_ReceiveMessage; //for chat support client.ChatService.ReceiveText += Client_ChatService_ReceiveText; AddMessage(string.Format("Connected to server: \"{0}\"", client.RemoteServerName)); foreach (string serviceName in client.ServerConnectedNode.RemoteServices) { AddMessage(string.Format("Server service: \"{0}\"", serviceName)); } } UpdateControls(); }
// protected override void OnAttach() { base.OnAttach(); window = ControlDeclarationManager.Instance.CreateControl("Gui\\MapsWindow.gui"); Controls.Add(window); string[] mapList = VirtualDirectory.GetFiles("", "*.map", SearchOption.AllDirectories); //maps listBox { listBox = (EListBox)window.Controls["List"]; //dynamic map example listBox.Items.Add(dynamicMapExampleText); foreach (string name in mapList) { listBox.Items.Add(name); if (Map.Instance != null) { if (string.Compare(name.Replace('/', '\\'), Map.Instance.VirtualFileName.Replace('/', '\\'), true) == 0) { listBox.SelectedIndex = listBox.Items.Count - 1; } } } listBox.SelectedIndexChange += listBox_SelectedIndexChanged; if (listBox.Items.Count != 0 && listBox.SelectedIndex == -1) { listBox.SelectedIndex = 0; } if (listBox.Items.Count != 0) { listBox_SelectedIndexChanged(null); } listBox.ItemMouseDoubleClick += delegate(object sender, EListBox.ItemMouseEventArgs e) { RunMap((string)e.Item); }; } //autorunMap comboBoxAutorunMap = (EComboBox)window.Controls["autorunMap"]; if (comboBoxAutorunMap != null) { comboBoxAutorunMap.Items.Add("(None)"); comboBoxAutorunMap.SelectedIndex = 0; foreach (string name in mapList) { comboBoxAutorunMap.Items.Add(name); if (string.Compare(GameEngineApp.autorunMapName, name, true) == 0) { comboBoxAutorunMap.SelectedIndex = comboBoxAutorunMap.Items.Count - 1; } } comboBoxAutorunMap.SelectedIndexChange += delegate(EComboBox sender) { if (sender.SelectedIndex != 0) { GameEngineApp.autorunMapName = (string)sender.SelectedItem; } else { GameEngineApp.autorunMapName = ""; } }; } //Run button event handler ((EButton)window.Controls["Run"]).Click += delegate(EButton sender) { if (listBox.SelectedIndex != -1) { RunMap((string)listBox.SelectedItem); } }; //Quit button event handler ((EButton)window.Controls["Quit"]).Click += delegate(EButton sender) { SetShouldDetach(); }; }
/////////////////////////////////////////// protected override void OnAttach() { base.OnAttach(); //register config fields EngineApp.Instance.Config.RegisterClassParameters( GetType() ); //create window window = ControlDeclarationManager.Instance.CreateControl( "Gui\\MultiplayerLobbyWindow.gui" ); Controls.Add( window ); ( (EButton)window.Controls[ "Exit" ] ).Click += Exit_Click; buttonStart = (EButton)window.Controls[ "Start" ]; if( GameNetworkServer.Instance != null ) buttonStart.Click += Start_Click; if( GameNetworkClient.Instance != null ) buttonStart.Enable = false; listBoxUsers = (EListBox)window.Controls[ "Users" ]; editBoxChatMessage = (EEditBox)window.Controls[ "ChatMessage" ]; editBoxChatMessage.PreKeyDown += editBoxChatMessage_PreKeyDown; //comboBoxMaps { comboBoxMaps = (EComboBox)window.Controls[ "Maps" ]; if( GameNetworkServer.Instance != null ) { //dynamic map example comboBoxMaps.Items.Add( new MapItem( dynamicMapExampleText, false ) ); if( lastMapName == dynamicMapExampleText ) comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; string[] mapList = VirtualDirectory.GetFiles( "", "*.map", SearchOption.AllDirectories ); foreach( string mapName in mapList ) { //check for network support if( VirtualFile.Exists( string.Format( "{0}\\NoNetworkSupport.txt", Path.GetDirectoryName( mapName ) ) ) ) { continue; } bool recommended = mapName.Contains( "JigsawPuzzleGame" ) || mapName.Contains( "TankDemo" ) || mapName.Contains( "DeathmatchDemo" ); comboBoxMaps.Items.Add( new MapItem( mapName, recommended ) ); if( mapName == lastMapName ) comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; } comboBoxMaps.SelectedIndexChange += comboBoxMaps_SelectedIndexChange; if( comboBoxMaps.Items.Count != 0 && comboBoxMaps.SelectedIndex == -1 ) comboBoxMaps.SelectedIndex = 0; } else { comboBoxMaps.Enable = false; } } //checkBoxAllowToConnectDuringGame { checkBoxAllowToConnectDuringGame = (ECheckBox)window.Controls[ "AllowToConnectDuringGame" ]; if( GameNetworkServer.Instance != null ) { checkBoxAllowToConnectDuringGame.CheckedChange += checkBoxAllowToConnectDuringGame_CheckedChange; } else { checkBoxAllowToConnectDuringGame.Enable = false; } } //server specific GameNetworkServer server = GameNetworkServer.Instance; if( server != null ) { //for receive map name server.UserManagementService.AddUserEvent += Server_UserManagementService_AddUserEvent; //for chat support server.ChatService.ReceiveText += Server_ChatService_ReceiveText; } //client specific GameNetworkClient client = GameNetworkClient.Instance; if( client != null ) { //for receive map name client.CustomMessagesService.ReceiveMessage += Client_CustomMessagesService_ReceiveMessage; //for chat support client.ChatService.ReceiveText += Client_ChatService_ReceiveText; AddMessage( string.Format( "Connected to server: \"{0}\"", client.RemoteServerName ) ); foreach( string serviceName in client.ServerConnectedNode.RemoteServices ) AddMessage( string.Format( "Server service: \"{0}\"", serviceName ) ); } UpdateControls(); }
void comboBoxMaps_SelectedIndexChange( EComboBox sender ) { lastMapName = SelectedMapName; //send map name to clients GameNetworkServer server = GameNetworkServer.Instance; if( server != null ) server.CustomMessagesService.SendToAllClients( "Lobby_MapName", SelectedMapName ); }
/////////////////////////////////////////// protected override void OnAttach() { base.OnAttach(); EComboBox comboBox; EScrollBar scrollBar; ECheckBox checkBox; window = ControlDeclarationManager.Instance.CreateControl("Gui\\OptionsWindow.gui"); Controls.Add(window); ((EButton)window.Controls["Options"].Controls["Quit"]).Click += delegate(EButton sender) { SetShouldDetach(); }; //pageVideo { EControl pageVideo = window.Controls["TabControl"].Controls["Video"]; Vec2i currentMode = EngineApp.Instance.VideoMode; //screenResolutionComboBox comboBox = (EComboBox)pageVideo.Controls["ScreenResolution"]; comboBox.Enable = !EngineApp.Instance.WebPlayerMode; comboBoxResolution = comboBox; foreach (Vec2i mode in DisplaySettings.VideoModes) { if (mode.X < 640) { continue; } comboBox.Items.Add(mode.X.ToString() + "x" + mode.Y.ToString()); if (mode == currentMode) { comboBox.SelectedIndex = comboBox.Items.Count - 1; } } comboBox.SelectedIndexChange += delegate(EComboBox sender) { ChangeVideoMode(); }; //gamma scrollBar = (EScrollBar)pageVideo.Controls["Gamma"]; scrollBar.Value = GameEngineApp._Gamma; scrollBar.Enable = !EngineApp.Instance.WebPlayerMode; scrollBar.ValueChange += delegate(EScrollBar sender) { float value = float.Parse(sender.Value.ToString("F1")); GameEngineApp._Gamma = value; pageVideo.Controls["GammaValue"].Text = value.ToString("F1"); }; pageVideo.Controls["GammaValue"].Text = GameEngineApp._Gamma.ToString("F1"); //MaterialScheme { comboBox = (EComboBox)pageVideo.Controls["MaterialScheme"]; foreach (MaterialSchemes materialScheme in Enum.GetValues(typeof(MaterialSchemes))) { comboBox.Items.Add(materialScheme.ToString()); if (GameEngineApp.MaterialScheme == materialScheme) { comboBox.SelectedIndex = comboBox.Items.Count - 1; } } comboBox.SelectedIndexChange += delegate(EComboBox sender) { if (sender.SelectedIndex != -1) { GameEngineApp.MaterialScheme = (MaterialSchemes)sender.SelectedIndex; } }; } //ShadowTechnique { comboBox = (EComboBox)pageVideo.Controls["ShadowTechnique"]; comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.None, "None")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapLow, "Low")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapMedium, "Medium (shaders 3.0 only)")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapHigh, "High (shaders 3.0 only)")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapLowPSSM, "Low PSSM (shaders 3.0 only)")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapMediumPSSM, "Medium PSSM (shaders 3.0 only)")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapHighPSSM, "High PSSM (shaders 3.0 only)")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.Stencil, "Stencil")); for (int n = 0; n < comboBox.Items.Count; n++) { ShadowTechniqueItem item = (ShadowTechniqueItem)comboBox.Items[n]; if (item.Technique == GameEngineApp.ShadowTechnique) { comboBox.SelectedIndex = n; } } comboBox.SelectedIndexChange += delegate(EComboBox sender) { if (sender.SelectedIndex != -1) { ShadowTechniqueItem item = (ShadowTechniqueItem)sender.SelectedItem; GameEngineApp.ShadowTechnique = item.Technique; } UpdateShadowControlsEnable(); }; UpdateShadowControlsEnable(); } //ShadowUseMapSettings { checkBox = (ECheckBox)pageVideo.Controls["ShadowUseMapSettings"]; checkBox.Checked = GameEngineApp.ShadowUseMapSettings; checkBox.CheckedChange += delegate(ECheckBox sender) { GameEngineApp.ShadowUseMapSettings = sender.Checked; if (sender.Checked && Map.Instance != null) { GameEngineApp.ShadowPSSMSplitFactors = Map.Instance.InitialShadowPSSMSplitFactors; GameEngineApp.ShadowFarDistance = Map.Instance.InitialShadowFarDistance; GameEngineApp.ShadowColor = Map.Instance.InitialShadowColor; } UpdateShadowControlsEnable(); if (sender.Checked) { ((EScrollBar)pageVideo.Controls["ShadowFarDistance"]).Value = GameEngineApp.ShadowFarDistance; pageVideo.Controls["ShadowFarDistanceValue"].Text = ((int)GameEngineApp.ShadowFarDistance).ToString(); ColorValue color = GameEngineApp.ShadowColor; ((EScrollBar)pageVideo.Controls["ShadowColor"]).Value = (color.Red + color.Green + color.Blue) / 3; } }; } //ShadowPSSMSplitFactor1 scrollBar = (EScrollBar)pageVideo.Controls["ShadowPSSMSplitFactor1"]; scrollBar.Value = GameEngineApp.ShadowPSSMSplitFactors[0]; scrollBar.ValueChange += delegate(EScrollBar sender) { GameEngineApp.ShadowPSSMSplitFactors = new Vec2( sender.Value, GameEngineApp.ShadowPSSMSplitFactors[1]); pageVideo.Controls["ShadowPSSMSplitFactor1Value"].Text = (GameEngineApp.ShadowPSSMSplitFactors[0].ToString("F2")).ToString(); }; pageVideo.Controls["ShadowPSSMSplitFactor1Value"].Text = (GameEngineApp.ShadowPSSMSplitFactors[0].ToString("F2")).ToString(); //ShadowPSSMSplitFactor2 scrollBar = (EScrollBar)pageVideo.Controls["ShadowPSSMSplitFactor2"]; scrollBar.Value = GameEngineApp.ShadowPSSMSplitFactors[1]; scrollBar.ValueChange += delegate(EScrollBar sender) { GameEngineApp.ShadowPSSMSplitFactors = new Vec2( GameEngineApp.ShadowPSSMSplitFactors[0], sender.Value); pageVideo.Controls["ShadowPSSMSplitFactor2Value"].Text = (GameEngineApp.ShadowPSSMSplitFactors[1].ToString("F2")).ToString(); }; pageVideo.Controls["ShadowPSSMSplitFactor2Value"].Text = (GameEngineApp.ShadowPSSMSplitFactors[1].ToString("F2")).ToString(); //ShadowFarDistance scrollBar = (EScrollBar)pageVideo.Controls["ShadowFarDistance"]; scrollBar.Value = GameEngineApp.ShadowFarDistance; scrollBar.ValueChange += delegate(EScrollBar sender) { GameEngineApp.ShadowFarDistance = sender.Value; pageVideo.Controls["ShadowFarDistanceValue"].Text = ((int)GameEngineApp.ShadowFarDistance).ToString(); }; pageVideo.Controls["ShadowFarDistanceValue"].Text = ((int)GameEngineApp.ShadowFarDistance).ToString(); //ShadowColor scrollBar = (EScrollBar)pageVideo.Controls["ShadowColor"]; scrollBar.Value = (GameEngineApp.ShadowColor.Red + GameEngineApp.ShadowColor.Green + GameEngineApp.ShadowColor.Blue) / 3; scrollBar.ValueChange += delegate(EScrollBar sender) { float color = sender.Value; GameEngineApp.ShadowColor = new ColorValue(color, color, color, color); }; //ShadowDirectionalLightTextureSize { comboBox = (EComboBox)pageVideo.Controls["ShadowDirectionalLightTextureSize"]; comboBox.Items.Add(256); comboBox.Items.Add(512); comboBox.Items.Add(1024); comboBox.Items.Add(2048); if (GameEngineApp.ShadowDirectionalLightTextureSize == 256) { comboBox.SelectedIndex = 0; } if (GameEngineApp.ShadowDirectionalLightTextureSize == 512) { comboBox.SelectedIndex = 1; } else if (GameEngineApp.ShadowDirectionalLightTextureSize == 1024) { comboBox.SelectedIndex = 2; } else if (GameEngineApp.ShadowDirectionalLightTextureSize == 2048) { comboBox.SelectedIndex = 3; } comboBox.SelectedIndexChange += delegate(EComboBox sender) { GameEngineApp.ShadowDirectionalLightTextureSize = (int)sender.SelectedItem; }; } ////ShadowDirectionalLightMaxTextureCount //{ // comboBox = (EComboBox)pageVideo.Controls[ "ShadowDirectionalLightMaxTextureCount" ]; // for( int n = 0; n < 3; n++ ) // { // int count = n + 1; // comboBox.Items.Add( count ); // if( count == GameEngineApp.ShadowDirectionalLightMaxTextureCount ) // comboBox.SelectedIndex = n; // } // comboBox.SelectedIndexChange += delegate( EComboBox sender ) // { // GameEngineApp.ShadowDirectionalLightMaxTextureCount = (int)sender.SelectedItem; // }; //} //ShadowSpotLightTextureSize { comboBox = (EComboBox)pageVideo.Controls["ShadowSpotLightTextureSize"]; comboBox.Items.Add(256); comboBox.Items.Add(512); comboBox.Items.Add(1024); comboBox.Items.Add(2048); if (GameEngineApp.ShadowSpotLightTextureSize == 256) { comboBox.SelectedIndex = 0; } if (GameEngineApp.ShadowSpotLightTextureSize == 512) { comboBox.SelectedIndex = 1; } else if (GameEngineApp.ShadowSpotLightTextureSize == 1024) { comboBox.SelectedIndex = 2; } else if (GameEngineApp.ShadowSpotLightTextureSize == 2048) { comboBox.SelectedIndex = 3; } comboBox.SelectedIndexChange += delegate(EComboBox sender) { GameEngineApp.ShadowSpotLightTextureSize = (int)sender.SelectedItem; }; } //ShadowSpotLightMaxTextureCount { comboBox = (EComboBox)pageVideo.Controls["ShadowSpotLightMaxTextureCount"]; for (int n = 0; n < 3; n++) { int count = n + 1; comboBox.Items.Add(count); if (count == GameEngineApp.ShadowSpotLightMaxTextureCount) { comboBox.SelectedIndex = n; } } comboBox.SelectedIndexChange += delegate(EComboBox sender) { GameEngineApp.ShadowSpotLightMaxTextureCount = (int)sender.SelectedItem; }; } //ShadowPointLightTextureSize { comboBox = (EComboBox)pageVideo.Controls["ShadowPointLightTextureSize"]; comboBox.Items.Add(256); comboBox.Items.Add(512); comboBox.Items.Add(1024); comboBox.Items.Add(2048); if (GameEngineApp.ShadowPointLightTextureSize == 256) { comboBox.SelectedIndex = 0; } if (GameEngineApp.ShadowPointLightTextureSize == 512) { comboBox.SelectedIndex = 1; } else if (GameEngineApp.ShadowPointLightTextureSize == 1024) { comboBox.SelectedIndex = 2; } else if (GameEngineApp.ShadowPointLightTextureSize == 2048) { comboBox.SelectedIndex = 3; } comboBox.SelectedIndexChange += delegate(EComboBox sender) { GameEngineApp.ShadowPointLightTextureSize = (int)sender.SelectedItem; }; } //ShadowPointLightMaxTextureCount { comboBox = (EComboBox)pageVideo.Controls["ShadowPointLightMaxTextureCount"]; for (int n = 0; n < 3; n++) { int count = n + 1; comboBox.Items.Add(count); if (count == GameEngineApp.ShadowPointLightMaxTextureCount) { comboBox.SelectedIndex = n; } } comboBox.SelectedIndexChange += delegate(EComboBox sender) { GameEngineApp.ShadowPointLightMaxTextureCount = (int)sender.SelectedItem; }; } //fullScreenCheckBox checkBox = (ECheckBox)pageVideo.Controls["FullScreen"]; checkBox.Enable = !EngineApp.Instance.WebPlayerMode; checkBox.Checked = EngineApp.Instance.FullScreen; checkBox.CheckedChange += delegate(ECheckBox sender) { EngineApp.Instance.FullScreen = sender.Checked; }; //waterReflectionLevel comboBox = (EComboBox)pageVideo.Controls["WaterReflectionLevel"]; foreach (WaterPlane.ReflectionLevels level in Enum.GetValues( typeof(WaterPlane.ReflectionLevels))) { comboBox.Items.Add(level); if (GameEngineApp.WaterReflectionLevel == level) { comboBox.SelectedIndex = comboBox.Items.Count - 1; } } comboBox.SelectedIndexChange += delegate(EComboBox sender) { GameEngineApp.WaterReflectionLevel = (WaterPlane.ReflectionLevels)sender.SelectedItem; }; //showDecorativeObjects checkBox = (ECheckBox)pageVideo.Controls["ShowDecorativeObjects"]; checkBox.Checked = GameEngineApp.ShowDecorativeObjects; checkBox.CheckedChange += delegate(ECheckBox sender) { GameEngineApp.ShowDecorativeObjects = sender.Checked; }; //showSystemCursorCheckBox checkBox = (ECheckBox)pageVideo.Controls["ShowSystemCursor"]; checkBox.Checked = GameEngineApp._ShowSystemCursor; checkBox.CheckedChange += delegate(ECheckBox sender) { GameEngineApp._ShowSystemCursor = sender.Checked; sender.Checked = GameEngineApp._ShowSystemCursor; }; //showFPSCheckBox checkBox = (ECheckBox)pageVideo.Controls["ShowFPS"]; checkBox.Checked = GameEngineApp._DrawFPS; checkBox.CheckedChange += delegate(ECheckBox sender) { GameEngineApp._DrawFPS = sender.Checked; sender.Checked = GameEngineApp._DrawFPS; }; } //pageSound { EControl pageSound = window.Controls["TabControl"].Controls["Sound"]; //soundVolumeCheckBox scrollBar = (EScrollBar)pageSound.Controls["SoundVolume"]; scrollBar.Value = GameEngineApp.SoundVolume; scrollBar.ValueChange += delegate(EScrollBar sender) { GameEngineApp.SoundVolume = sender.Value; }; //musicVolumeCheckBox scrollBar = (EScrollBar)pageSound.Controls["MusicVolume"]; scrollBar.Value = GameEngineApp.MusicVolume; scrollBar.ValueChange += delegate(EScrollBar sender) { GameEngineApp.MusicVolume = sender.Value; }; } //pageControls { EControl pageControls = window.Controls["TabControl"].Controls["Controls"]; //MouseHSensitivity scrollBar = (EScrollBar)pageControls.Controls["MouseHSensitivity"]; scrollBar.Value = GameControlsManager.Instance.MouseSensitivity.X; scrollBar.ValueChange += delegate(EScrollBar sender) { Vec2 value = GameControlsManager.Instance.MouseSensitivity; value.X = sender.Value; GameControlsManager.Instance.MouseSensitivity = value; }; //MouseVSensitivity scrollBar = (EScrollBar)pageControls.Controls["MouseVSensitivity"]; scrollBar.Value = Math.Abs(GameControlsManager.Instance.MouseSensitivity.Y); scrollBar.ValueChange += delegate(EScrollBar sender) { Vec2 value = GameControlsManager.Instance.MouseSensitivity; bool invert = ((ECheckBox)pageControls.Controls["MouseVInvert"]).Checked; value.Y = sender.Value * (invert ? -1.0f : 1.0f); GameControlsManager.Instance.MouseSensitivity = value; }; //MouseVInvert checkBox = (ECheckBox)pageControls.Controls["MouseVInvert"]; checkBox.Checked = GameControlsManager.Instance.MouseSensitivity.Y < 0; checkBox.CheckedChange += delegate(ECheckBox sender) { Vec2 value = GameControlsManager.Instance.MouseSensitivity; value.Y = ((EScrollBar)pageControls.Controls["MouseVSensitivity"]).Value * (sender.Checked ? -1.0f : 1.0f); GameControlsManager.Instance.MouseSensitivity = value; }; //Devices comboBox = (EComboBox)pageControls.Controls["InputDevices"]; comboBoxInputDevices = comboBox; comboBox.Items.Add("Keyboard/Mouse"); if (InputDeviceManager.Instance != null) { foreach (InputDevice device in InputDeviceManager.Instance.Devices) { comboBox.Items.Add(device); } } comboBox.SelectedIndex = 0; comboBox.SelectedIndexChange += delegate(EComboBox sender) { UpdateBindedInputControlsTextBox(); }; //Controls UpdateBindedInputControlsTextBox(); } }