コード例 #1
0
        public void AddMessage(string text)
        {
            EListBox listBox = (EListBox)window.Controls["Messages"];

            listBox.Items.Add(text);
            listBox.SelectedIndex = listBox.Items.Count - 1;
        }
コード例 #2
0
        protected override void OnAttach()
        {
            base.OnAttach();

            window = ControlDeclarationManager.Instance.CreateControl("Gui\\WorldLoadSaveWindow.gui");
            Controls.Add(window);

            //worlds listBox
            {
                listBox = (EListBox)window.Controls["List"];

                for (int slotIndex = 1; slotIndex <= slotCount; slotIndex++)
                {
                    string fileName = GetWorldFileName(slotIndex);

                    string item;
                    if (VirtualFile.Exists(fileName))
                    {
                        item = fileName;
                    }
                    else
                    {
                        item = emptySlotText;
                    }

                    listBox.Items.Add(item);
                }

                listBox.SelectedIndexChange += listBox_SelectedIndexChanged;
                if (listBox.Items.Count != 0 && listBox.SelectedIndex == -1)
                {
                    listBox.SelectedIndex = 0;
                }
                if (listBox.Items.Count != 0)
                {
                    listBox_SelectedIndexChanged(null);
                }
            }

            //Load button event handler
            loadButton        = (EButton)window.Controls["Load"];
            loadButton.Click += delegate(EButton sender)
            {
                string item = (string)listBox.SelectedItem;
                if (item != null && item != emptySlotText)
                {
                    Load(item);
                }
            };

            //Save button event handler
            saveButton        = (EButton)window.Controls["Save"];
            saveButton.Click += delegate(EButton sender)
            {
                string item = (string)listBox.SelectedItem;
                if (item != null)
                {
                    if (item == emptySlotText)
                    {
                        item = GetWorldFileName(listBox.SelectedIndex + 1);
                    }
                    Save(item);
                }
            };

            //Close button event handler
            ((EButton)window.Controls["Close"]).Click += delegate(EButton sender)
            {
                SetShouldDetach();
            };

            UpdateButtonsEnabledFlag();
        }
コード例 #3
0
        protected override void OnAttach()
        {
            base.OnAttach();

            window = ControlDeclarationManager.Instance.CreateControl( "Gui\\WorldLoadSaveWindow.gui" );
            Controls.Add( window );

            //worlds listBox
            {
                listBox = (EListBox)window.Controls[ "List" ];

                for( int slotIndex = 1; slotIndex <= slotCount; slotIndex++ )
                {
                    string fileName = GetWorldFileName( slotIndex );

                    string item;
                    if( VirtualFile.Exists( fileName ) )
                        item = fileName;
                    else
                        item = emptySlotText;

                    listBox.Items.Add( item );
                }

                listBox.SelectedIndexChange += listBox_SelectedIndexChanged;
                if( listBox.Items.Count != 0 && listBox.SelectedIndex == -1 )
                    listBox.SelectedIndex = 0;
                if( listBox.Items.Count != 0 )
                    listBox_SelectedIndexChanged( null );
            }

            //Load button event handler
            loadButton = (EButton)window.Controls[ "Load" ];
            loadButton.Click += delegate( EButton sender )
            {
                string item = (string)listBox.SelectedItem;
                if( item != null && item != emptySlotText )
                    Load( item );
            };

            //Save button event handler
            saveButton = (EButton)window.Controls[ "Save" ];
            saveButton.Click += delegate( EButton sender )
            {
                string item = (string)listBox.SelectedItem;
                if( item != null )
                {
                    if( item == emptySlotText )
                        item = GetWorldFileName( listBox.SelectedIndex + 1 );
                    Save( item );
                }
            };

            //Close button event handler
            ( (EButton)window.Controls[ "Close" ] ).Click += delegate( EButton sender )
            {
                SetShouldDetach();
            };

            UpdateButtonsEnabledFlag();
        }
コード例 #4
0
ファイル: PostEffectsWindow.cs プロジェクト: huytd/fosproject
        //
        protected override void OnAttach()
        {
            base.OnAttach();

            viewport = RendererWorld.Instance.DefaultViewport;

            window = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\PostEffectsWindow.gui" );
            Controls.Add( window );

            for( int n = 0; n < scrollBarFloatParameters.Length; n++ )
            {
                scrollBarFloatParameters[ n ] = (EScrollBar)window.Controls[
                    "FloatParameter" + n.ToString() ];
                scrollBarFloatParameters[ n ].ValueChange += floatParameter_ValueChange;
            }
            for( int n = 0; n < checkBoxBoolParameters.Length; n++ )
            {
                checkBoxBoolParameters[ n ] = (ECheckBox)window.Controls[ "BoolParameter" + n.ToString() ];
                checkBoxBoolParameters[ n ].CheckedChange += boolParameter_CheckedChange;
            }

            listBox = (EListBox)window.Controls[ "List" ];
            listBox.Items.Add( "HDR" );
            listBox.Items.Add( "Glass" );
            listBox.Items.Add( "OldTV" );
            listBox.Items.Add( "HeatVision" );
            listBox.Items.Add( "MotionBlur" );
            listBox.Items.Add( "RadialBlur" );
            listBox.Items.Add( "Blur" );
            listBox.Items.Add( "Grayscale" );
            listBox.Items.Add( "Invert" );
            listBox.Items.Add( "Tiling" );

            listBox.SelectedIndexChange += listBox_SelectedIndexChange;

            checkBoxEnabled = (ECheckBox)window.Controls[ "Enabled" ];
            checkBoxEnabled.Click += checkBoxEnabled_Click;

            for( int n = 0; n < listBox.Items.Count; n++ )
            {
                EButton itemButton = listBox.ItemButtons[ n ];
                ECheckBox checkBox = (ECheckBox)itemButton.Controls[ "CheckBox" ];

                string name = GetListCompositorItemName( (string)listBox.Items[ n ] );

                CompositorInstance instance = viewport.GetCompositorInstance( name );
                if( instance != null && instance.Enabled )
                    checkBox.Checked = true;

                if( itemButton.Text == "HDR" )
                    checkBox.Enable = false;

                checkBox.Click += listBoxCheckBox_Click;
            }

            listBox.SelectedIndex = 0;

            ( (EButton)window.Controls[ "Close" ] ).Click += delegate( EButton sender )
            {
                SetShouldDetach();
            };

            //ApplyToTheScreenGUI
            {
                ECheckBox checkBox = (ECheckBox)window.Controls[ "ApplyToTheScreenGUI" ];
                checkBox.Checked = EngineApp.Instance.ScreenGuiRenderer.ApplyPostEffectsToScreenRenderer;
                checkBox.Click += delegate( ECheckBox sender )
                {
                    EngineApp.Instance.ScreenGuiRenderer.ApplyPostEffectsToScreenRenderer = sender.Checked;
                };
            }
        }
コード例 #5
0
ファイル: PostEffectsWindow.cs プロジェクト: huytd/fosproject
 void listBox_SelectedIndexChange( EListBox sender )
 {
     UpdateCurrentPostEffectControls();
 }
コード例 #6
0
        ///////////////////////////////////////////
        /// <summary>
        /// Creates a window of the main menu and creates the background world.
        /// </summary>
        protected override void OnAttach()
        {
            base.OnAttach();

            //create main menu window
            window = ControlDeclarationManager.Instance.CreateControl( "Gui\\AntMain.gui" );

            string[] mapList = VirtualDirectory.GetFiles("Maps\\AntRTS", "*.map", SearchOption.AllDirectories);

            window.ColorMultiplier = new ColorValue( 1, 1, 1, 0 );
            Controls.Add( window );

            //no shader model 2 warning
            //if( window.Controls[ "NoShaderModel2" ] != null )
                //window.Controls[ "NoShaderModel2" ].Visible = !RenderSystem.Instance.HasShaderModel2();

            //button handlers
            //( (EButton)window.Controls[ "Run" ] ).Click += Run_Click;

            //( (EButton)window.Controls[ "Multiplayer" ] ).Click += Multiplayer_Click;
            ((EButton)window.Controls["ToggleFaction"]).Click += ToggleFaction_Click;
            ((EButton)window.Controls["SelectFaction"]).Click += Faction_Click;
            ((EButton)window.Controls["Back"]).Click += Back_Click;
            //add version info control
            versionTextBox = new ETextBox();
            versionTextBox.TextHorizontalAlign = HorizontalAlign.Left;
            versionTextBox.TextVerticalAlign = VerticalAlign.Bottom;
            versionTextBox.Text = "Version " + EngineVersionInformation.Version;
            versionTextBox.ColorMultiplier = new ColorValue( 1, 1, 1, 0 );

            Controls.Add( versionTextBox );

            //maps listBox

                listBox = (EListBox)window.Controls["MapSelect"];

                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)
                {
                    GameEngineApp.Instance.SetNeedMapLoad((string)e.Item);
                };

            ((EButton)window.Controls["Run"]).Click += delegate(EButton sender)
            {
                if (listBox.SelectedIndex != -1)
                    GameEngineApp.Instance.SetNeedMapLoad((string)listBox.SelectedItem);
            };

            //play background music
            GameMusic.MusicPlay( "Sounds\\Music\\Bumps.ogg", true );

            //update sound listener
            SoundWorld.Instance.SetListener( new Vec3( 1000, 1000, 1000 ),
                Vec3.Zero, new Vec3( 1, 0, 0 ), new Vec3( 0, 0, 1 ) );

            //create the background world
            CreateMap();

            ResetTime();
        }
コード例 #7
0
        //
        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();
            };
        }
コード例 #8
0
            public override void OnUpdate()
            {
                if (updated)
                {
                    return;
                }
                updated = true;

                int informationTypeIndex = ((EComboBox)PageControl.Controls["InformationType"]).
                                           SelectedIndex;

                EListBox listBox = (EListBox)PageControl.Controls["Information"];

                int lastSelectedIndex = listBox.SelectedIndex;

                listBox.Items.Clear();

                if (informationTypeIndex == 0)
                {
                    //managed assemblies

                    Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();

                    List <AssemblyName> resultAssemblyNames = new List <AssemblyName>(assemblies.Length);
                    {
                        List <Assembly> remainingAssemblies = new List <Assembly>(assemblies);

                        while (true)
                        {
                            Assembly notReferencedAssembly = null;
                            {
                                foreach (Assembly assembly in remainingAssemblies)
                                {
                                    AssemblyName[] referencedAssemblies = assembly.GetReferencedAssemblies();

                                    foreach (Assembly a in remainingAssemblies)
                                    {
                                        if (assembly == a)
                                        {
                                            continue;
                                        }

                                        AssemblyName aName = a.GetName();

                                        foreach (AssemblyName referencedAssembly in referencedAssemblies)
                                        {
                                            if (referencedAssembly.Name == aName.Name)
                                            {
                                                goto nextAssembly;
                                            }
                                        }
                                    }

                                    notReferencedAssembly = assembly;
                                    break;

                                    nextAssembly :;
                                }
                            }

                            if (notReferencedAssembly != null)
                            {
                                remainingAssemblies.Remove(notReferencedAssembly);
                                resultAssemblyNames.Add(notReferencedAssembly.GetName());
                            }
                            else
                            {
                                //no exists not referenced assemblies
                                foreach (Assembly assembly in remainingAssemblies)
                                {
                                    resultAssemblyNames.Add(assembly.GetName());
                                }
                                break;
                            }
                        }
                    }

                    foreach (AssemblyName assemblyName in resultAssemblyNames)
                    {
                        string text = string.Format("{0}, {1}", assemblyName.Name,
                                                    assemblyName.Version);
                        listBox.Items.Add(text);
                    }
                }
                else if (informationTypeIndex == 1)
                {
                    //dlls
                    string[] names = EngineApp.Instance.GetNativeModuleNames();

                    ArrayUtils.SelectionSort(names, delegate(string s1, string s2)
                    {
                        return(string.Compare(s1, s2, true));
                    });

                    foreach (string name in names)
                    {
                        string text = string.Format("{0} - {1}", Path.GetFileName(name), name);
                        listBox.Items.Add(text);
                    }
                }

                if (lastSelectedIndex >= 0 && lastSelectedIndex < listBox.Items.Count)
                {
                    listBox.SelectedIndex = lastSelectedIndex;
                }
                if (listBox.Items.Count != 0 && listBox.SelectedIndex == -1)
                {
                    listBox.SelectedIndex = 0;
                }
            }
コード例 #9
0
            public override void OnUpdate()
            {
                RenderStatisticsInfo statistics = RendererWorld.Instance.Statistics;

                PageControl.Controls["Triangles"].Text = statistics.Triangles.ToString("N0");
                PageControl.Controls["Batches"].Text   = statistics.Batches.ToString("N0");
                PageControl.Controls["Lights"].Text    = statistics.Lights.ToString("N0");

                //performance counter
                {
                    float otherTime = 0;

                    foreach (PerformanceCounter.Counter counter in PerformanceCounter.Counters)
                    {
                        PerformanceCounter.TimeCounter timeCounter =
                            counter as PerformanceCounter.TimeCounter;

                        if (timeCounter != null)
                        {
                            string counterNameWithoutSpaces = counter.Name.Replace(" ", "");

                            EControl timeControl = PageControl.Controls[
                                counterNameWithoutSpaces + "Time"];
                            EControl fpsControl = PageControl.Controls[
                                counterNameWithoutSpaces + "FPS"];

                            if (timeControl != null)
                            {
                                timeControl.Text = (timeCounter.CalculatedValue * 1000.0f).
                                                   ToString("F2");
                            }
                            if (fpsControl != null)
                            {
                                fpsControl.Text = (1.0f / timeCounter.CalculatedValue).ToString("F1");
                            }

                            if (!counter.InnerCounter)
                            {
                                if (counter == PerformanceCounter.TotalTimeCounter)
                                {
                                    otherTime += timeCounter.CalculatedValue;
                                }
                                else
                                {
                                    otherTime -= timeCounter.CalculatedValue;
                                }
                            }
                        }
                    }

                    {
                        ETextBox timeControl = PageControl.Controls["OtherTime"] as ETextBox;
                        ETextBox fpsControl  = PageControl.Controls["OtherFPS"] as ETextBox;

                        if (timeControl != null)
                        {
                            timeControl.Text = (otherTime * 1000.0f).ToString("F2");
                        }
                        if (fpsControl != null)
                        {
                            fpsControl.Text = (1.0f / otherTime).ToString("F1");
                        }
                    }
                }

                //cameras
                {
                    EListBox camerasListBox = (EListBox)PageControl.Controls["Cameras"];

                    //update cameras list
                    {
                        StatisticsInfoItem lastSelectedItem = camerasListBox.SelectedItem as
                                                              StatisticsInfoItem;

                        camerasListBox.Items.Clear();

                        foreach (RenderStatisticsInfo.CameraStatistics cameraStatistics in
                                 statistics.CamerasStatistics)
                        {
                            StatisticsInfoItem item = new StatisticsInfoItem();
                            item.cameraInformation     = cameraStatistics.CameraInformation;
                            item.ownerCameraIdentifier = cameraStatistics.OwnerCameraIdentifier;
                            camerasListBox.Items.Add(item);

                            if (lastSelectedItem != null)
                            {
                                if (item.cameraInformation == lastSelectedItem.cameraInformation &&
                                    item.ownerCameraIdentifier == lastSelectedItem.ownerCameraIdentifier)
                                {
                                    camerasListBox.SelectedIndex = camerasListBox.Items.Count - 1;
                                }
                            }
                        }

                        camerasListBox.Items.Add("Total");
                        if (lastSelectedItem != null && lastSelectedItem.cameraInformation == "Total")
                        {
                            camerasListBox.SelectedIndex = camerasListBox.Items.Count - 1;
                        }

                        if (camerasListBox.SelectedIndex == -1)
                        {
                            camerasListBox.SelectedIndex = camerasListBox.Items.Count - 1;
                        }
                    }

                    //update camera info
                    if (camerasListBox.SelectedIndex == camerasListBox.Items.Count - 1)
                    {
                        //total statistics

                        int staticMeshObjects = 0;
                        int sceneNodes        = 0;
                        int guiRenderers      = 0;
                        int guiBatches        = 0;
                        int triangles         = 0;
                        int batches           = 0;

                        foreach (RenderStatisticsInfo.CameraStatistics cameraStatistics in
                                 statistics.CamerasStatistics)
                        {
                            staticMeshObjects += cameraStatistics.StaticMeshObjects;
                            sceneNodes        += cameraStatistics.SceneNodes;
                            guiRenderers      += cameraStatistics.GuiRenderers;
                            guiBatches        += cameraStatistics.GuiBatches;
                            triangles         += cameraStatistics.Triangles;
                            batches           += cameraStatistics.Batches;
                        }

                        PageControl.Controls["CameraOutdoorWalks"].Text  = "No camera";
                        PageControl.Controls["CameraPortalsPassed"].Text = "No camera";
                        PageControl.Controls["CameraZonesPassed"].Text   = "No camera";

                        PageControl.Controls["CameraStaticMeshObjects"].Text =
                            staticMeshObjects.ToString("N0");
                        PageControl.Controls["CameraSceneNodes"].Text   = sceneNodes.ToString("N0");
                        PageControl.Controls["CameraGuiRenderers"].Text = guiRenderers.ToString("N0");
                        PageControl.Controls["CameraGuiBatches"].Text   = guiBatches.ToString("N0");
                        PageControl.Controls["CameraTriangles"].Text    = triangles.ToString("N0");
                        PageControl.Controls["CameraBatches"].Text      = batches.ToString("N0");
                    }
                    else if (camerasListBox.SelectedIndex != -1)
                    {
                        //selected camera statistics

                        RenderStatisticsInfo.CameraStatistics activeCameraStatistics =
                            statistics.CamerasStatistics[camerasListBox.SelectedIndex];

                        RenderStatisticsInfo.CameraStatistics.PortalSystemInfo portalSystemInfo =
                            activeCameraStatistics.PortalSystem;
                        if (portalSystemInfo != null)
                        {
                            PageControl.Controls["CameraOutdoorWalks"].Text =
                                portalSystemInfo.OutdoorWalks.ToString("N0");
                            PageControl.Controls["CameraPortalsPassed"].Text =
                                portalSystemInfo.PortalsPassed.ToString("N0");
                            PageControl.Controls["CameraZonesPassed"].Text =
                                portalSystemInfo.ZonesPassed.ToString("N0");
                        }
                        else
                        {
                            PageControl.Controls["CameraOutdoorWalks"].Text  = "No zones";
                            PageControl.Controls["CameraPortalsPassed"].Text = "No zones";
                            PageControl.Controls["CameraZonesPassed"].Text   = "No zones";
                        }

                        PageControl.Controls["CameraStaticMeshObjects"].Text =
                            activeCameraStatistics.StaticMeshObjects.ToString("N0");
                        PageControl.Controls["CameraSceneNodes"].Text =
                            activeCameraStatistics.SceneNodes.ToString("N0");
                        PageControl.Controls["CameraGuiRenderers"].Text =
                            activeCameraStatistics.GuiRenderers.ToString("N0");
                        PageControl.Controls["CameraGuiBatches"].Text =
                            activeCameraStatistics.GuiBatches.ToString("N0");
                        PageControl.Controls["CameraTriangles"].Text =
                            activeCameraStatistics.Triangles.ToString("N0");
                        PageControl.Controls["CameraBatches"].Text =
                            activeCameraStatistics.Batches.ToString("N0");
                    }
                    else
                    {
                        //no camera selected

                        PageControl.Controls["CameraOutdoorWalks"].Text  = "";
                        PageControl.Controls["CameraPortalsPassed"].Text = "";
                        PageControl.Controls["CameraZonesPassed"].Text   = "";

                        PageControl.Controls["CameraStaticMeshObjects"].Text = "";
                        PageControl.Controls["CameraSceneNodes"].Text        = "";
                        PageControl.Controls["CameraGuiRenderers"].Text      = "";
                        PageControl.Controls["CameraGuiBatches"].Text        = "";
                        PageControl.Controls["CameraTriangles"].Text         = "";
                        PageControl.Controls["CameraBatches"].Text           = "";
                    }
                }
            }
コード例 #10
0
        ///////////////////////////////////////////

        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();
        }
コード例 #11
0
ファイル: PostEffectsWindow.cs プロジェクト: gsaone/forklift
        //

        protected override void OnAttach()
        {
            base.OnAttach();

            instance = this;

            viewport = RendererWorld.Instance.DefaultViewport;

            window = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\PostEffectsWindow.gui");
            Controls.Add(window);

            for (int n = 0; n < scrollBarFloatParameters.Length; n++)
            {
                scrollBarFloatParameters[n] = (EScrollBar)window.Controls[
                    "FloatParameter" + n.ToString()];
                scrollBarFloatParameters[n].ValueChange += floatParameter_ValueChange;
            }
            for (int n = 0; n < checkBoxBoolParameters.Length; n++)
            {
                checkBoxBoolParameters[n] = (ECheckBox)window.Controls["BoolParameter" + n.ToString()];
                checkBoxBoolParameters[n].CheckedChange += boolParameter_CheckedChange;
            }

            listBox = (EListBox)window.Controls["List"];
            listBox.Items.Add("HDR");
            listBox.Items.Add("LDRBloom");
            listBox.Items.Add("Glass");
            listBox.Items.Add("OldTV");
            listBox.Items.Add("HeatVision");
            listBox.Items.Add("MotionBlur");
            listBox.Items.Add("RadialBlur");
            listBox.Items.Add("Blur");
            listBox.Items.Add("Grayscale");
            listBox.Items.Add("Invert");
            listBox.Items.Add("Tiling");

            listBox.SelectedIndexChange += listBox_SelectedIndexChange;

            checkBoxEnabled        = (ECheckBox)window.Controls["Enabled"];
            checkBoxEnabled.Click += checkBoxEnabled_Click;

            for (int n = 0; n < listBox.Items.Count; n++)
            {
                EButton   itemButton = listBox.ItemButtons[n];
                ECheckBox checkBox   = (ECheckBox)itemButton.Controls["CheckBox"];

                string name = GetListCompositorItemName((string)listBox.Items[n]);

                CompositorInstance compositorInstance = viewport.GetCompositorInstance(name);
                if (compositorInstance != null && compositorInstance.Enabled)
                {
                    checkBox.Checked = true;
                }

                if (itemButton.Text == "HDR")
                {
                    checkBox.Enable = false;
                }

                checkBox.Click += listBoxCheckBox_Click;
            }

            listBox.SelectedIndex = 0;

            ((EButton)window.Controls["Close"]).Click += delegate(EButton sender)
            {
                SetShouldDetach();
            };

            //ApplyToTheScreenGUI
            {
                ECheckBox checkBox = (ECheckBox)window.Controls["ApplyToTheScreenGUI"];
                checkBox.Checked = EngineApp.Instance.ScreenGuiRenderer.ApplyPostEffectsToScreenRenderer;
                checkBox.Click  += delegate(ECheckBox sender)
                {
                    EngineApp.Instance.ScreenGuiRenderer.ApplyPostEffectsToScreenRenderer = sender.Checked;
                };
            }
        }
コード例 #12
0
ファイル: PostEffectsWindow.cs プロジェクト: gsaone/forklift
 void listBox_SelectedIndexChange(EListBox sender)
 {
     UpdateCurrentPostEffectControls();
 }
コード例 #13
0
        //

        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();
            };
        }
コード例 #14
0
        ///////////////////////////////////////////
        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();
        }