Ejemplo n.º 1
0
        void Client_EntitySystemService_WorldCreateBegin(EntitySystemClientNetworkService sender,
                                                         WorldType worldType, string mapVirtualFileName)
        {
            //show map loading window
            EControl mapLoadingWindow = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\MapLoadingWindow.gui");

            if (mapLoadingWindow != null)
            {
                mapLoadingWindow.Text = mapVirtualFileName;
                controlManager.Controls.Add(mapLoadingWindow);
            }
            RenderScene();

            DeleteAllGameWindows();

            MapSystemWorld.MapDestroy();

            if (!EntitySystemWorld.Instance.WorldCreate(WorldSimulationTypes.ClientOnly,
                                                        worldType, sender.NetworkingInterface))
            {
                Log.Fatal("GameEngineApp: Client_EntitySystemService_WorldCreateBegin: " +
                          "EntitySystemWorld.WorldCreate failed.");
            }
        }
Ejemplo n.º 2
0
        protected override void OnAttach()
        {
            base.OnAttach();

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

            InitCheckBox( "StaticPhysics", typeof( GameWindow ).GetField( "mapDrawStaticPhysics" ) );
            InitCheckBox( "DynamicPhysics", typeof( GameWindow ).GetField( "mapDrawDynamicPhysics" ) );
            InitCheckBox( "SceneGraphInfo", typeof( GameWindow ).GetField( "mapDrawSceneGraphInfo" ) );
            InitCheckBox( "Regions", typeof( GameWindow ).GetField( "mapDrawRegions" ) );
            InitCheckBox( "MapObjectBounds", typeof( GameWindow ).GetField( "mapDrawMapObjectBounds" ) );
            InitCheckBox( "SceneNodeBounds", typeof( GameWindow ).GetField( "mapDrawSceneNodeBounds" ) );
            InitCheckBox( "StaticMeshObjectBounds", typeof( GameWindow ).GetField( "mapDrawStaticMeshObjectBounds" ) );
            InitCheckBox( "ZonesPortalsOccluders", typeof( GameWindow ).GetField( "mapDrawZonesPortalsOccluders" ) );
            InitCheckBox( "FrustumTest", typeof( GameWindow ).GetField( "frustumTest" ) );
            InitCheckBox( "Lights", typeof( GameWindow ).GetField( "mapDrawLights" ) );
            InitCheckBox( "StaticGeometry", typeof( GameWindow ).GetField( "mapDrawStaticGeometry" ) );
            InitCheckBox( "Models", typeof( GameWindow ).GetField( "mapDrawModels" ) );
            InitCheckBox( "Effects", typeof( GameWindow ).GetField( "mapDrawEffects" ) );
            InitCheckBox( "Gui", typeof( GameWindow ).GetField( "mapDrawGui" ) );
            InitCheckBox( "Wireframe", typeof( GameWindow ).GetField( "mapDrawWireframe" ) );
            InitCheckBox( "PostEffects", typeof( GameWindow ).GetField( "drawPostEffects" ) );
            InitCheckBox( "GameSpecificDebugGeometry", typeof( GameWindow ).GetField( "drawGameSpecificDebugGeometry" ) );

            ( (EButton)window.Controls[ "Defaults" ] ).Click += Defaults_Click;

            ( (EButton)window.Controls[ "Close" ] ).Click += delegate( EButton sender )
            {
                SetShouldDetach();
            };
        }
Ejemplo n.º 3
0
        protected override void OnAttach()
        {
            base.OnAttach();

            EngineApp.Instance.Config.RegisterClassParameters(GetType());

            instance = this;

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

            backgroundCheckBox                = (ECheckBox)window.Controls["Background"];
            backgroundCheckBox.Checked        = background;
            backgroundCheckBox.CheckedChange += Background_CheckedChange;

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

            EControl tabControl = window.Controls["TabControl"];

            pages.Add(new GeneralPage(tabControl.Controls["General"]));
            pages.Add(new RenderPage(tabControl.Controls["Render"]));
            pages.Add(new PhysicsPage(tabControl.Controls["Physics"]));
            pages.Add(new SoundPage(tabControl.Controls["Sound"]));
            pages.Add(new EntitiesPage(tabControl.Controls["Entities"]));
            pages.Add(new MemoryPage(tabControl.Controls["Memory"]));
            pages.Add(new DLLPage(tabControl.Controls["DLL"]));
            pages.Add(new NetworkPage(tabControl.Controls["Network"]));

            UpdateColorMultiplier();
        }
Ejemplo n.º 4
0
        protected override void OnAttach()
        {
            base.OnAttach();

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

            Type type = typeof(EngineDebugSettings);

            InitCheckBox("StaticPhysics", type.GetProperty("DrawStaticPhysics"));
            InitCheckBox("DynamicPhysics", type.GetProperty("DrawDynamicPhysics"));
            InitCheckBox("SceneGraphInfo", type.GetProperty("DrawSceneGraphInfo"));
            InitCheckBox("Regions", type.GetProperty("DrawRegions"));
            InitCheckBox("MapObjectBounds", type.GetProperty("DrawMapObjectBounds"));
            InitCheckBox("SceneNodeBounds", type.GetProperty("DrawSceneNodeBounds"));
            InitCheckBox("StaticMeshObjectBounds", type.GetProperty("DrawStaticMeshObjectBounds"));
            InitCheckBox("ZonesPortalsOccluders", type.GetProperty("DrawZonesPortalsOccluders"));
            InitCheckBox("FrustumTest", type.GetProperty("FrustumTest"));
            InitCheckBox("Lights", type.GetProperty("DrawLights"));
            InitCheckBox("StaticGeometry", type.GetProperty("DrawStaticGeometry"));
            InitCheckBox("Models", type.GetProperty("DrawModels"));
            InitCheckBox("Effects", type.GetProperty("DrawEffects"));
            InitCheckBox("Gui", type.GetProperty("DrawGui"));
            InitCheckBox("Wireframe", type.GetProperty("DrawWireframe"));
            InitCheckBox("PostEffects", type.GetProperty("DrawPostEffects"));
            InitCheckBox("GameSpecificDebugGeometry", type.GetProperty("DrawGameSpecificDebugGeometry"));
            InitCheckBox("DrawShadowDebugging", type.GetProperty("DrawShadowDebugging"));

            ((EButton)window.Controls["Defaults"]).Click += Defaults_Click;

            ((EButton)window.Controls["Close"]).Click += delegate(EButton sender)
            {
                SetShouldDetach();
            };
        }
Ejemplo n.º 5
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\\MainMenuWindow.gui" );

            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[ "Multiplayer" ] ).Click += Multiplayer_Click;

            //play background music
            GameMusic.MusicPlay( "Sounds\\Music\\MainMenu.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 ) );

            ResetTime();
        }
Ejemplo n.º 6
0
        void LongOperationCallbackManager_LoadingCallback(string callerInfo, object userData)
        {
            //How to calculate time for progress bar.
            //It is impossible to make universal solution. It's depending to concrete project.
            //By "callerInfo" data you can collect useful info for calculation total loading time.

            //Limit fps.
            const float maxFPSInv = 1.0f / 15.0f;
            float       now       = Time;

            if (now - loadingCallbackLastTimeCall < maxFPSInv)
            {
                return;
            }
            loadingCallbackLastTimeCall = now;

            //animate "Indicator".
            EControl loadingWindow = userData as EControl;

            if (loadingWindow != null)
            {
                EControl indicator = loadingWindow.Controls["Indicator"];
                if (indicator != null)
                {
                    int frame = (int)((EngineApp.Instance.Time * 10) % 8);
                    indicator.BackTextureCoord =
                        new Rect((float)frame / 8, 0, (float)(frame + 1) / 8, 1);
                }
            }

            //Update frame (2D only).
            SceneManager.Instance.Enable3DSceneRendering = false;
            RenderScene();
            SceneManager.Instance.Enable3DSceneRendering = true;
        }
Ejemplo n.º 7
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\\MainMenuWindow.gui" );
            //window.ColorMultiplier = new ColorValue( 1, 1, 1, 0 );
            Controls.Add( window );

            //Run button handler
            ((EButton)window.Controls["Run"]).Click += delegate(EButton sender)
            {
                GameEngineApp.Instance.SetNeedMapLoad("Maps\\Vietheroes\\Map.map");
            };

            //play background music
            GameMusic.MusicPlay("Sounds\\Vietheroes\\NewLegend.mp3", 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();

            //GameEngineApp.Instance.SetNeedMapLoad("Maps\\Vietheroes\\Map.map");
        }
        protected override void OnAttach()
        {
            base.OnAttach();

            EngineApp.Instance.Config.RegisterClassParameters( GetType() );

            instance = this;

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

            backgroundCheckBox = (ECheckBox)window.Controls[ "Background" ];
            backgroundCheckBox.Checked = background;
            backgroundCheckBox.CheckedChange += Background_CheckedChange;

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

            EControl tabControl = window.Controls[ "TabControl" ];

            pages.Add( new GeneralPage( tabControl.Controls[ "General" ] ) );
            pages.Add( new RenderPage( tabControl.Controls[ "Render" ] ) );
            pages.Add( new PhysicsPage( tabControl.Controls[ "Physics" ] ) );
            pages.Add( new SoundPage( tabControl.Controls[ "Sound" ] ) );
            pages.Add( new EntitiesPage( tabControl.Controls[ "Entities" ] ) );
            pages.Add( new MemoryPage( tabControl.Controls[ "Memory" ] ) );
            pages.Add( new DLLPage( tabControl.Controls[ "DLL" ] ) );
            pages.Add( new NetworkPage( tabControl.Controls[ "Network" ] ) );

            UpdateColorMultiplier();
        }
Ejemplo n.º 9
0
        protected override void OnAttach()
        {
            base.OnAttach();

            EControl window = ControlDeclarationManager.Instance.CreateControl("Gui\\MenuWindow.gui");

            Controls.Add(window);

            ((EButton)window.Controls["Maps"]).Click           += mapsButton_Click;
            ((EButton)window.Controls["LoadSave"]).Click       += loadSaveButton_Click;
            ((EButton)window.Controls["Options"]).Click        += optionsButton_Click;
            ((EButton)window.Controls["PostEffects"]).Click    += postEffectsButton_Click;
            ((EButton)window.Controls["Debug"]).Click          += debugButton_Click;
            ((EButton)window.Controls["About"]).Click          += aboutButton_Click;
            ((EButton)window.Controls["ExitToMainMenu"]).Click += exitToMainMenuButton_Click;
            ((EButton)window.Controls["Exit"]).Click           += exitButton_Click;
            ((EButton)window.Controls["Resume"]).Click         += resumeButton_Click;

            if (GameWindow.Instance == null)
            {
                window.Controls["ExitToMainMenu"].Enable = false;
            }

            if (GameNetworkServer.Instance != null || GameNetworkClient.Instance != null)
            {
                window.Controls["Maps"].Enable     = false;
                window.Controls["LoadSave"].Enable = false;
            }

            MouseCover = true;

            BackColor = new ColorValue(0, 0, 0, .5f);
        }
Ejemplo n.º 10
0
        //

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

            //load the HUD screen
            hudControl = ControlDeclarationManager.Instance.CreateControl(
                "JigsawPuzzleGame\\JigsawPuzzleGameHUD.gui");
            //attach the HUD screen to the this window
            Controls.Add(hudControl);

            if (EntitySystemWorld.Instance.IsSingle())
            {
                //hide chat edit box for single mode
                hudControl.Controls["ChatText"].Visible    = false;
                hudControl.Controls["ChatMessage"].Visible = false;
            }

            //ExitToRooms button
            if (EntitySystemWorld.Instance.IsSingle())
            {
                ((EButton)hudControl.Controls["ExitToRooms"]).Click += delegate(EButton sender)
                {
                    string mapName        = "Maps\\MainDemo\\Map.map";
                    string spawnPointName = "SpawnPoint_FromJigsawPuzzleGame";
                    GameWorld.Instance.SetShouldChangeMap(mapName, spawnPointName, null);
                };
            }
            else
            {
                hudControl.Controls["ExitToRooms"].Visible = false;
            }

            chatMessageEditBox             = (EEditBox)hudControl.Controls["ChatMessage"];
            chatMessageEditBox.PreKeyDown += ChatMessageEditBox_PreKeyDown;

            //find first map camera
            foreach (Entity entity in Map.Instance.Children)
            {
                mapCamera = entity as MapCamera;
                if (mapCamera != null)
                {
                    break;
                }
            }

            //for chat support
            GameNetworkServer server = GameNetworkServer.Instance;

            if (server != null)
            {
                server.ChatService.ReceiveText += Server_ChatService_ReceiveText;
            }
            GameNetworkClient client = GameNetworkClient.Instance;

            if (client != null)
            {
                client.ChatService.ReceiveText += Client_ChatService_ReceiveText;
            }
        }
Ejemplo n.º 11
0
        //---------------------------------------------------------------
        // Metodos públicos de la clase
        //---------------------------------------------------------------

        #region Metodos publicos de la clase
        #endregion

        //---------------------------------------------------------------
        // Metodos privados de la clase
        //---------------------------------------------------------------

        #region Metodos del Generador
        /// <summary>
        /// Agrega o modifica un registro de la tabla: Controles
        /// (Código Fijo)
        /// </summary>
        /// <param name="p_dbcAccess">Conexion a la base de datos</param>
        /// <param name="p_entControl">Entidad con los datos a procesar</param>
        /// <param name="p_smResult">Estado final de la operacion</param>
        internal static void Save_f(DBConn p_dbcAccess,
                                    ref EControl p_entControl,
                                    StatMsg p_smResult)
        {
            // *********
            // Agregar acá los procesos adicionales
            // *********
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Agrega validacion de integridad a una entidad: Control
 /// (Código Fijo)
 /// </summary>
 /// <param name="p_dbcAccess">Conexion a la base de datos</param>
 /// <param name="p_entControl">Entidad con los datos a validar</param>
 /// <param name="p_smResult">Estado final de la operacion</param>
 internal static void TInt_f(DBConn p_dbcAccess,
                             EControl p_entControl,
                             StatMsg p_smResult)
 {
     // *********
     // Agregar acá las validaciones adicionales
     // *********
 }
Ejemplo n.º 13
0
            //

            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;
            }
Ejemplo n.º 14
0
        protected override void OnAttach()
        {
            base.OnAttach();
            window = ControlDeclarationManager.Instance.CreateControl("Gui\\world_map.gui");

            pPlayer = window.Controls["player"];
            //restore position
            pDest = window.Controls["dest"];
            Controls.Add(window);
        }
Ejemplo n.º 15
0
        ///////////////////////////////////////////

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

            //create window
            window = ControlDeclarationManager.Instance.CreateControl("Gui\\GuiTestWindow.gui");
            Controls.Add(window);

            ((EButton)window.Controls["Close"]).Click += Close_Click;
        }
Ejemplo n.º 16
0
        protected override void OnAttach()
        {
            base.OnAttach();

            EControl window = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\WindowsAppExampleHUD.gui");

            Controls.Add(window);

            ((EButton)window.Controls["Close"]).Click += CloseButton_Click;
        }
Ejemplo n.º 17
0
        protected override void OnControlDetach(EControl control)
        {
            if (control as MenuWindow != null)
            {
                if (EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle())
                {
                    EntitySystemWorld.Instance.Simulation = simulationAfterCloseMenuWindow;
                }
            }

            base.OnControlDetach(control);
        }
Ejemplo n.º 18
0
            public PhysicsPage(EControl pageControl)
                : base(pageControl)
            {
                PageControl.Controls["Library"].Text = string.Format("{0} ({1})",
                                                                     PhysicsWorld.Instance.DriverName, PhysicsWorld.Instance.DriverAssemblyFileName);

                ECheckBox hardwareAccelecatedCheckBox = (ECheckBox)PageControl.Controls[
                    "HardwareAccelerated"];

                hardwareAccelecatedCheckBox.Enable  = false;
                hardwareAccelecatedCheckBox.Checked = PhysicsWorld.Instance.HardwareAccelerated;
            }
        //
        protected override void OnAttach()
        {
            base.OnAttach();

            //load the HUD screen
            hudControl = ControlDeclarationManager.Instance.CreateControl(
                "JigsawPuzzleGame\\JigsawPuzzleGameHUD.gui" );
            //attach the HUD screen to the this window
            Controls.Add( hudControl );

            if( EntitySystemWorld.Instance.IsSingle() )
            {
                //hide chat edit box for single mode
                hudControl.Controls[ "ChatText" ].Visible = false;
                hudControl.Controls[ "ChatMessage" ].Visible = false;
            }

            //ExitToRooms button
            if( EntitySystemWorld.Instance.IsSingle() )
            {
                ( (EButton)hudControl.Controls[ "ExitToRooms" ] ).Click += delegate( EButton sender )
                {
                    string mapName = "Maps\\MainDemo\\Map.map";
                    string spawnPointName = "SpawnPoint_FromJigsawPuzzleGame";
                    GameWorld.Instance.SetShouldChangeMap( mapName, spawnPointName, null );
                };
            }
            else
                hudControl.Controls[ "ExitToRooms" ].Visible = false;

            chatMessageEditBox = (EEditBox)hudControl.Controls[ "ChatMessage" ];
            chatMessageEditBox.PreKeyDown += ChatMessageEditBox_PreKeyDown;

            //find first map camera
            foreach( Entity entity in Map.Instance.Children )
            {
                mapCamera = entity as MapCamera;
                if( mapCamera != null )
                    break;
            }

            //for chat support
            GameNetworkServer server = GameNetworkServer.Instance;
            if( server != null )
                server.ChatService.ReceiveText += Server_ChatService_ReceiveText;
            GameNetworkClient client = GameNetworkClient.Instance;
            if( client != null )
                client.ChatService.ReceiveText += Client_ChatService_ReceiveText;
        }
Ejemplo n.º 20
0
        protected override void OnControlDetach( EControl control )
        {
            base.OnControlDetach( control );

            if( ( control as OptionsWindow ) != null ||
                ( control as PostEffectsWindow ) != null ||
                ( control as DebugDrawOptionsWindow ) != null ||
                //( control as MapsWindow ) != null ||
                ( control as WorldLoadSaveWindow ) != null ||
                ( control as AboutWindow ) != null )
            {
                foreach( EControl c in Controls )
                    c.Visible = true;
            }
        }
Ejemplo n.º 21
0
        protected override void OnControlAttach(EControl control)
        {
            base.OnControlAttach(control);
            if (control as MenuWindow != null)
            {
                EngineApp.Instance.KeysAndMouseButtonUpAll();

                simulationAfterCloseMenuWindow = EntitySystemWorld.Instance.Simulation;

                if (EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle())
                {
                    EntitySystemWorld.Instance.Simulation = false;
                }

                EngineApp.Instance.MouseRelativeMode = false;
            }
        }
Ejemplo n.º 22
0
        protected override void OnControlDetach(EControl control)
        {
            base.OnControlDetach(control);

            if ((control as OptionsWindow) != null ||
                (control as PostEffectsWindow) != null ||
                (control as DebugDrawOptionsWindow) != null ||
                (control as MapsWindow) != null ||
                (control as WorldLoadSaveWindow) != null ||
                (control as AboutWindow) != null)
            {
                foreach (EControl c in Controls)
                {
                    c.Visible = true;
                }
            }
        }
        ///////////////////////////////////////////
        protected override void OnAttach()
        {
            base.OnAttach();

            //disable check for disconnection
            GameEngineApp.Instance.Client_AllowCheckForDisconnection = false;

            //register config fields
            EngineApp.Instance.Config.RegisterClassParameters( GetType() );

            //create window
            window = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\MultiplayerLoginWindow.gui" );
            Controls.Add( window );

            MouseCover = true;
            BackColor = new ColorValue( 0, 0, 0, .5f );

            //initialize controls

            buttonCreateServer = (EButton)window.Controls[ "CreateServer" ];
            buttonCreateServer.Click += CreateServer_Click;

            buttonConnect = (EButton)window.Controls[ "Connect" ];
            buttonConnect.Click += Connect_Click;

            ( (EButton)window.Controls[ "Exit" ] ).Click += Exit_Click;

            //generate user name
            if( string.IsNullOrEmpty( userName ) )
            {
                EngineRandom random = new EngineRandom();
                userName = "******" + random.Next( 1000 ).ToString( "D03" );
            }

            editBoxUserName = (EEditBox)window.Controls[ "UserName" ];
            editBoxUserName.Text = userName;
            editBoxUserName.TextChange += editBoxUserName_TextChange;

            editBoxConnectTo = (EEditBox)window.Controls[ "ConnectTo" ];
            editBoxConnectTo.Text = connectToAddress;
            editBoxConnectTo.TextChange += editBoxConnectTo_TextChange;

            SetInfo( "", false );
        }
Ejemplo n.º 24
0
        ///////////////////////////////////////////

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

            //disable check for disconnection
            GameEngineApp.Instance.Client_AllowCheckForDisconnection = false;

            //register config fields
            EngineApp.Instance.Config.RegisterClassParameters(GetType());

            //create window
            window = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\MultiplayerLoginWindow.gui");
            Controls.Add(window);

            MouseCover = true;
            BackColor  = new ColorValue(0, 0, 0, .5f);

            //initialize controls

            buttonCreateServer        = (EButton)window.Controls["CreateServer"];
            buttonCreateServer.Click += CreateServer_Click;

            buttonConnect        = (EButton)window.Controls["Connect"];
            buttonConnect.Click += Connect_Click;

            ((EButton)window.Controls["Exit"]).Click += Exit_Click;

            //generate user name
            if (string.IsNullOrEmpty(userName))
            {
                EngineRandom random = new EngineRandom();
                userName = "******" + random.Next(1000).ToString("D03");
            }

            editBoxUserName             = (EEditBox)window.Controls["UserName"];
            editBoxUserName.Text        = userName;
            editBoxUserName.TextChange += editBoxUserName_TextChange;

            editBoxConnectTo             = (EEditBox)window.Controls["ConnectTo"];
            editBoxConnectTo.Text        = connectToAddress;
            editBoxConnectTo.TextChange += editBoxConnectTo_TextChange;

            SetInfo("", false);
        }
Ejemplo n.º 25
0
        protected override void OnAttach()
        {
            base.OnAttach();

            EControl window = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\AboutWindow.gui");

            Controls.Add(window);

            window.Controls["Version"].Text   = EngineVersionInformation.Version;
            window.Controls["Copyright"].Text = EngineVersionInformation.Copyright;
            window.Controls["WWW"].Text       = EngineVersionInformation.WWW;

            ((EButton)window.Controls["Quit"]).Click += delegate(EButton sender)
            {
                SetShouldDetach();
            };
        }
Ejemplo n.º 26
0
            public RenderPage(EControl pageControl)
                : base(pageControl)
            {
                PageControl.Controls["Library"].Text = string.Format("{0} ({1})",
                                                                     RenderSystem.Instance.Name, RenderSystem.Instance.DllFileName);

                string gpuSyntaxes = "";

                foreach (string gpuSyntax in GpuProgramManager.Instance.SupportedSyntaxes)
                {
                    if (gpuSyntaxes != "")
                    {
                        gpuSyntaxes += " ";
                    }
                    gpuSyntaxes += gpuSyntax;
                }
                PageControl.Controls["GPUSyntaxes"].Text = gpuSyntaxes;
            }
        public void ChangeType(int id, int newActivePower, EControl control)
        {
            using (ApplicationDbContext context = new ApplicationDbContext())
            {
                var genFromDb = context.Generators.FirstOrDefault(gen => gen.Id == id);

                if (genFromDb != null && (genFromDb.Control != control || (genFromDb.Control == EControl.LOCAL && genFromDb.CurrentPower != newActivePower)))
                {
                    genFromDb.Control = control;

                    if (genFromDb.Control == 0)
                    {
                        genFromDb.CurrentPower = newActivePower;
                    }

                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 28
0
            public SoundPage(EControl pageControl)
                : base(pageControl)
            {
                EComboBox comboBox;

                string libraryText = SoundWorld.Instance.DriverName;

                if (SoundWorld.Instance.DriverName != "NULL")
                {
                    libraryText += string.Format(" ({0})", SoundWorld.Instance.DriverAssemblyFileName);
                }
                PageControl.Controls["Library"].Text = libraryText;

                comboBox = (EComboBox)PageControl.Controls["InformationType"];
                comboBox.Items.Add("Loaded sounds");
                comboBox.Items.Add("Virtual channels");
                comboBox.Items.Add("Real channels");
                comboBox.SelectedIndex = 0;
            }
Ejemplo n.º 29
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\\MainMenuWindow.gui");

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

            //no shader model 3 warning
            if (window.Controls["NoShaderModel3"] != null)
            {
                window.Controls["NoShaderModel3"].Visible = !RenderSystem.Instance.HasShaderModel3();
            }

            //button handlers
            ((EButton)window.Controls["Run"]).Click         += Run_Click;
            ((EButton)window.Controls["Multiplayer"]).Click += Multiplayer_Click;
            ((EButton)window.Controls["GuiTest"]).Click     += GuiTest_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);

            //play background music
            GameMusic.MusicPlay("Sounds\\Music\\MainMenu.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();
        }
Ejemplo n.º 30
0
        void CreateMainControl()
        {
            if (mainControl != null)
            {
                mainControl.Parent.Controls.Remove(mainControl);
                mainControl = null;
            }

            if (controlManager != null && !string.IsNullOrEmpty(initialControl))
            {
                mainControl = ControlDeclarationManager.Instance.CreateControl(initialControl);
                if (mainControl != null)
                {
                    controlManager.Controls.Add(mainControl);
                }
            }

            //update MapBounds
            SetTransform(Position, Rotation, Scale);
        }
Ejemplo n.º 31
0
        protected override void OnAttach()
        {
            base.OnAttach();

            TopMost = true;

            EControl window = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\MessageBoxWindow.gui");

            Controls.Add(window);

            window.Controls["MessageText"].Text = messageText;

            window.Text = caption;

            ((EButton)window.Controls["OK"]).Click += OKButton_Click;

            BackColor = new ColorValue(0, 0, 0, .5f);

            EngineApp.Instance.RenderScene();
        }
Ejemplo n.º 32
0
        public bool WorldSave(string fileName)
        {
            EControl worldSavingWindow = null;

            //world saving window
            {
                worldSavingWindow = ControlDeclarationManager.Instance.CreateControl(
                    "Gui\\WorldSavingWindow.gui");
                if (worldSavingWindow != null)
                {
                    worldSavingWindow.Text = fileName;
                    controlManager.Controls.Add(worldSavingWindow);
                }
                RenderScene();
            }

            GameWindow gameWindow = null;

            foreach (EControl control in controlManager.Controls)
            {
                gameWindow = control as GameWindow;
                if (gameWindow != null)
                {
                    break;
                }
            }
            if (gameWindow != null)
            {
                gameWindow.OnBeforeWorldSave();
            }

            bool result = MapSystemWorld.WorldSave(fileName);

            if (worldSavingWindow != null)
            {
                worldSavingWindow.SetShouldDetach();
            }

            return(result);
        }
Ejemplo n.º 33
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\\MainMenuWindow.gui" );

            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;

            //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 );

            //play background music
            GameMusic.MusicPlay( "Sounds\\Music\\MainMenu.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();
        }
Ejemplo n.º 34
0
        void UpdateShadowControlsEnable()
        {
            EControl pageVideo = window.Controls["TabControl"].Controls["Video"];

            bool textureShadows =
                GameEngineApp.ShadowTechnique == ShadowTechniques.ShadowmapLow ||
                GameEngineApp.ShadowTechnique == ShadowTechniques.ShadowmapMedium ||
                GameEngineApp.ShadowTechnique == ShadowTechniques.ShadowmapHigh ||
                GameEngineApp.ShadowTechnique == ShadowTechniques.ShadowmapLowPSSM ||
                GameEngineApp.ShadowTechnique == ShadowTechniques.ShadowmapMediumPSSM ||
                GameEngineApp.ShadowTechnique == ShadowTechniques.ShadowmapHighPSSM;

            bool pssm = GameEngineApp.ShadowTechnique == ShadowTechniques.ShadowmapLowPSSM ||
                        GameEngineApp.ShadowTechnique == ShadowTechniques.ShadowmapMediumPSSM ||
                        GameEngineApp.ShadowTechnique == ShadowTechniques.ShadowmapHighPSSM;

            bool allowShadowColor = GameEngineApp.ShadowTechnique != ShadowTechniques.None;

            pageVideo.Controls["ShadowColor"].Enable =
                !GameEngineApp.ShadowUseMapSettings && allowShadowColor;

            pageVideo.Controls["ShadowPSSMSplitFactor1"].Enable =
                !GameEngineApp.ShadowUseMapSettings && pssm;

            pageVideo.Controls["ShadowPSSMSplitFactor2"].Enable =
                !GameEngineApp.ShadowUseMapSettings && pssm;

            pageVideo.Controls["ShadowFarDistance"].Enable =
                !GameEngineApp.ShadowUseMapSettings &&
                GameEngineApp.ShadowTechnique != ShadowTechniques.None;

            pageVideo.Controls["ShadowDirectionalLightTextureSize"].Enable = textureShadows;
            //pageVideo.Controls[ "ShadowDirectionalLightMaxTextureCount" ].Enable = textureShadows;
            pageVideo.Controls["ShadowSpotLightTextureSize"].Enable      = textureShadows;
            pageVideo.Controls["ShadowSpotLightMaxTextureCount"].Enable  = textureShadows;
            pageVideo.Controls["ShadowPointLightTextureSize"].Enable     = textureShadows;
            pageVideo.Controls["ShadowPointLightMaxTextureCount"].Enable = textureShadows;
        }
 public NetworkPage( EControl pageControl )
     : base(pageControl)
 {
 }
Ejemplo n.º 36
0
        //
        protected override void OnAttach()
        {
            base.OnAttach();

            //To load the HUD screen
            hudControl = ControlDeclarationManager.Instance.CreateControl( "Gui\\ActionHUD.gui" );
            //Attach the HUD screen to the this window
            Controls.Add( hudControl );

            //CutSceneManager specific
            if( CutSceneManager.Instance != null )
            {
                CutSceneManager.Instance.CutSceneEnableChange += delegate( CutSceneManager manager )
                {
                    if( manager.CutSceneEnable )
                    {
                        //Cut scene activated. All keys and buttons need to reset.
                        EngineApp.Instance.KeysAndMouseButtonUpAll();
                        GameControlsManager.Instance.DoKeyUpAll();
                    }
                };
            }

            //fill observeCameraRegions list
            foreach( Entity entity in Map.Instance.Children )
            {
                ObserveCameraArea area = entity as ObserveCameraArea;
                if( area != null )
                    observeCameraAreas.Add( area );
            }

            FreeCameraEnabled = cameraType == CameraType.Free;

            //add game specific console command
            if( EngineConsole.Instance != null )
            {
                EngineConsole.Instance.AddCommand( "movePlayerUnitToCamera",
                    ConsoleCommand_MovePlayerUnitToCamera );
            }

            //accept commands of the player
            GameControlsManager.Instance.GameControlsEvent += GameControlsManager_GameControlsEvent;

            //MotionBlur for a player unit contusion
            {
                Compositor compositor = CompositorManager.Instance.GetByName( "MotionBlur" );
                if( compositor != null && compositor.IsSupported() )
                    RendererWorld.Instance.DefaultViewport.AddCompositor( "MotionBlur" );
            }
        }
Ejemplo n.º 37
0
        ///////////////////////////////////////////
        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();
            }
        }
Ejemplo n.º 38
0
        //
        protected override void OnAttach()
        {
            base.OnAttach();

            EngineApp.Instance.KeysAndMouseButtonUpAll();

            //hudControl
            hudControl = ControlDeclarationManager.Instance.CreateControl( "Gui\\RTSHUD.gui" );
            Controls.Add( hudControl );

            ( (EButton)hudControl.Controls[ "Menu" ] ).Click += delegate( EButton sender )
            {
                Controls.Add( new MenuWindow() );
            };

            ( (EButton)hudControl.Controls[ "Exit" ] ).Click += delegate( EButton sender )
            {
                string mapName = "Maps\\Vietheroes\\Map.map";
                string spawnPointName = "SpawnPoint_FromRTSDemo";
                GameWorld.Instance.SetShouldChangeMap( mapName, spawnPointName, null );
            };

            ( (EButton)hudControl.Controls[ "Help" ] ).Click += delegate( EButton sender )
            {
                hudControl.Controls[ "HelpWindow" ].Visible = !hudControl.Controls[ "HelpWindow" ].Visible;
            };

            ( (EButton)hudControl.Controls[ "HelpWindow" ].Controls[ "Close" ] ).Click += delegate( EButton sender )
            {
                hudControl.Controls[ "HelpWindow" ].Visible = false;
            };

            ( (EButton)hudControl.Controls[ "DebugPath" ] ).Click += delegate( EButton sender )
            {
                mapDrawPathMotionMap = !mapDrawPathMotionMap;
            };

            InitControlPanelButtons();
            UpdateControlPanel();

            //set playerFaction
            if( RTSFactionManager.Instance != null && RTSFactionManager.Instance.Factions.Count != 0 )
                playerFaction = RTSFactionManager.Instance.Factions[ 0 ].FactionType;

            //minimap
            minimapControl = hudControl.Controls[ "Minimap" ];
            string textureName = Map.Instance.GetSourceMapVirtualFileDirectory() + "\\Minimap\\Minimap";
            Texture minimapTexture = TextureManager.Instance.Load( textureName, Texture.Type.Type2D, 0 );
            minimapControl.BackTexture = minimapTexture;
            minimapControl.RenderUI += new RenderUIDelegate( Minimap_RenderUI );

            //set camera position
            foreach( Entity entity in Map.Instance.Children )
            {
                SpawnPoint spawnPoint = entity as SpawnPoint;
                if( spawnPoint == null )
                    continue;
                cameraPosition = spawnPoint.Position.ToVec2();
                break;
            }

            //World serialized data
            if( World.Instance.GetCustomSerializationValue( "cameraDistance" ) != null )
                cameraDistance = (float)World.Instance.GetCustomSerializationValue( "cameraDistance" );
            if( World.Instance.GetCustomSerializationValue( "cameraDirection" ) != null )
                cameraDirection = (SphereDir)World.Instance.GetCustomSerializationValue( "cameraDirection" );
            if( World.Instance.GetCustomSerializationValue( "cameraPosition" ) != null )
                cameraPosition = (Vec2)World.Instance.GetCustomSerializationValue( "cameraPosition" );
            for( int n = 0; ; n++ )
            {
                Unit unit = World.Instance.GetCustomSerializationValue(
                    "selectedUnit" + n.ToString() ) as Unit;
                if( unit == null )
                    break;
                SetEntitySelected( unit, true );
            }

            ResetTime();
        }
Ejemplo n.º 39
0
        void MiniMapArrow_RenderUI(EControl sender, GuiRenderer renderer)
        {
            //Thanks Thor22 from NeoAxis Forum
            //http://www.neoaxisgroup.com/phpBB2/viewtopic.php?t=1321&start=0
            Angles playerRot = GetPlayerUnit().Rotation.ToAngles();
            playerRot.Normalize360();
            float PlayerRotation = playerRot.Yaw; //If don't work try to add 90 or 180

            Texture arrowTexture = sender.BackTexture;

            //EControl arrowControl = minimapControl.Controls["Arrow"];
            //renderer.SetTransform(new Vec3(1, 1, 1), new Quat(0f, 0f, 0.001f, 1f), new Vec3(1f, 1f, 1f));
            RotateGuiControl(sender, PlayerRotation, arrowTexture, renderer);
        }
Ejemplo n.º 40
0
        private static Mock <IDbGenerator> MockChangeType(int generatorId, int newActivePower, EControl control)
        {
            Mock <ApplicationDbContext> mockedDbFactory = new Mock <ApplicationDbContext>();
            Mock <IDbGenerator>         mockedDB        = new Mock <IDbGenerator>();

            mockedDB.Setup(x => x.ChangeType(generatorId, newActivePower, control));
            return(mockedDB);
        }
            public RenderPage( EControl pageControl )
                : base(pageControl)
            {
                PageControl.Controls[ "Library" ].Text = string.Format( "{0} ({1})",
                    RenderSystem.Instance.Name, RenderSystem.Instance.DllFileName );

                string gpuSyntaxes = "";
                foreach( string gpuSyntax in GpuProgramManager.Instance.SupportedSyntaxes )
                {
                    if( gpuSyntaxes != "" )
                        gpuSyntaxes += " ";
                    gpuSyntaxes += gpuSyntax;
                }
                PageControl.Controls[ "GPUSyntaxes" ].Text = gpuSyntaxes;
            }
Ejemplo n.º 42
0
        public bool ServerOrSingle_MapLoad(string fileName, WorldType worldType,
                                           bool noChangeWindows)
        {
            GameNetworkServer server = GameNetworkServer.Instance;

            EControl mapLoadingWindow = null;

            //show map loading window
            if (!noChangeWindows)
            {
                mapLoadingWindow = ControlDeclarationManager.Instance.CreateControl(
                    "Gui\\MapLoadingWindow.gui");
                if (mapLoadingWindow != null)
                {
                    mapLoadingWindow.Text = fileName;
                    controlManager.Controls.Add(mapLoadingWindow);
                }
                RenderScene();
            }

            DeleteAllGameWindows();

            MapSystemWorld.MapDestroy();

            //create world if need
            if (World.Instance == null || World.Instance.Type != worldType)
            {
                WorldSimulationTypes worldSimulationType;
                EntitySystemWorld.NetworkingInterface networkingInterface = null;

                if (server != null)
                {
                    worldSimulationType = WorldSimulationTypes.ServerAndClient;
                    networkingInterface = server.EntitySystemService.NetworkingInterface;
                }
                else
                {
                    worldSimulationType = WorldSimulationTypes.Single;
                }

                if (!EntitySystemWorld.Instance.WorldCreate(worldSimulationType, worldType,
                                                            networkingInterface))
                {
                    Log.Fatal("GameEngineApp: MapLoad: EntitySystemWorld.WorldCreate failed.");
                }
            }

            //Subcribe to callbacks during map loading. We will render scene from callback.
            LongOperationCallbackManager.Subscribe(LongOperationCallbackManager_LoadingCallback,
                                                   mapLoadingWindow);

            //load map
            if (!MapSystemWorld.MapLoad(fileName))
            {
                if (mapLoadingWindow != null)
                {
                    mapLoadingWindow.SetShouldDetach();
                }

                LongOperationCallbackManager.Unsubscribe();

                return(false);
            }

            //inform clients about world created
            if (server != null)
            {
                server.EntitySystemService.InformClientsAfterWorldCreated();
            }

            //Simulate physics for 5 seconds. That the physics has fallen asleep.
            if (EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle())
            {
                SimulatePhysicsForLoadedMap(5);
            }

            //Update shadow settings. This operation can be slow because need update all
            //shaders if shadow technique changed.
            Map.Instance.UpdateSceneManagerShadowSettings();

            fullscreenFadingRemainingFrames = 35;

            LongOperationCallbackManager.Unsubscribe();

            //Error
            foreach (EControl control in controlManager.Controls)
            {
                if (control is MessageBoxWindow && !control.IsShouldDetach())
                {
                    return(false);
                }
            }

            if (!noChangeWindows)
            {
                CreateGameWindowForMap();
            }

            //play music
            if (!noChangeWindows)
            {
                if (GameMap.Instance != null)
                {
                    GameMusic.MusicPlay(GameMap.Instance.GameMusic, true);
                }
            }

            EntitySystemWorld.Instance.ResetExecutedTime();

            return(true);
        }
Ejemplo n.º 43
0
        protected override bool OnCreate()
        {
            instance = this;

            ChangeToBetterDefaultSettings();

            if (!base.OnCreate())
            {
                return(false);
            }

            SoundVolume = soundVolume;
            MusicVolume = musicVolume;

            controlManager = new ScreenControlManager(ScreenGuiRenderer);
            if (!ControlsWorld.Init())
            {
                return(false);
            }

            _ShowSystemCursor = _ShowSystemCursor;
            _DrawFPS          = _DrawFPS;
            MaterialScheme    = materialScheme;

            Log.Handlers.InfoHandler    += Log_Handlers_InfoHandler;
            Log.Handlers.WarningHandler += Log_Handlers_WarningHandler;
            Log.Handlers.ErrorHandler   += Log_Handlers_ErrorHandler;
            Log.Handlers.FatalHandler   += Log_Handlers_FatalHandler;

            //Camera
            Camera camera = RendererWorld.Instance.DefaultCamera;

            camera.NearClipDistance = .1f;
            camera.FarClipDistance  = 1000.0f;
            camera.FixedUp          = Vec3.ZAxis;
            camera.Fov      = 90;
            camera.Position = new Vec3(-10, -10, 10);
            camera.LookAt(new Vec3(0, 0, 0));

            EControl programLoadingWindow = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\ProgramLoadingWindow.gui");

            if (programLoadingWindow != null)
            {
                controlManager.Controls.Add(programLoadingWindow);
            }

            //Subcribe to callbacks during engine loading. We will render scene from callback.
            LongOperationCallbackManager.Subscribe(LongOperationCallbackManager_LoadingCallback,
                                                   programLoadingWindow);

            if (!HighLevelMaterialManager.Instance.LoadAllMaterials())
            {
                LongOperationCallbackManager.Unsubscribe();
                return(true);
            }

            RenderScene();

            //Game controls
            GameControlsManager.Init();

            //EntitySystem
            if (!EntitySystemWorld.Init(new EntitySystemWorld()))
            {
                LongOperationCallbackManager.Unsubscribe();
                return(true);
            }

            LongOperationCallbackManager.Unsubscribe();

            //close loading window.
            if (programLoadingWindow != null)
            {
                programLoadingWindow.SetShouldDetach();
            }

            string mapName = "";

            if (autorunMapName != "" && autorunMapName.Length > 2)
            {
                mapName = autorunMapName;
                if (!mapName.Contains("\\") && !mapName.Contains("/"))
                {
                    mapName = "Maps/" + mapName + "/Map.map";
                }
            }

            if (!WebPlayerMode)
            {
                string[] commandLineArgs = Environment.GetCommandLineArgs();
                if (commandLineArgs.Length > 1)
                {
                    string name = commandLineArgs[1];
                    if (name[0] == '\"' && name[name.Length - 1] == '\"')
                    {
                        name = name.Substring(1, name.Length - 2);
                    }
                    name = name.Replace('/', '\\');

                    string dataDirectory = VirtualFileSystem.ResourceDirectoryPath;
                    dataDirectory = dataDirectory.Replace('/', '\\');

                    if (name.Length > dataDirectory.Length)
                    {
                        if (string.Compare(name.Substring(0, dataDirectory.Length), dataDirectory, true) == 0)
                        {
                            name = name.Substring(dataDirectory.Length + 1);
                        }
                    }

                    mapName = name;
                }
            }

            if (mapName != "")
            {
                if (!ServerOrSingle_MapLoad(mapName, EntitySystemWorld.Instance.DefaultWorldType, false))
                {
                    //Error
                    foreach (EControl control in controlManager.Controls)
                    {
                        if (control is MessageBoxWindow && !control.IsShouldDetach())
                        {
                            return(true);
                        }
                    }

                    GameMusic.MusicPlay("Sounds\\Music\\MainMenu.ogg", true);
                    controlManager.Controls.Add(new EngineLogoWindow());
                }
            }
            else
            {
                GameMusic.MusicPlay("Sounds\\Music\\MainMenu.ogg", true);
                controlManager.Controls.Add(new EngineLogoWindow());
            }

            //showDebugInformation console command
            if (EngineConsole.Instance != null)
            {
                EngineConsole.Instance.AddCommand("showDebugInformationWindow",
                                                  ConsoleCommand_ShowDebugInformationWindow);
            }

            //example of custom input device
            //ExampleCustomInputDevice.InitDevice();

            return(true);
        }
Ejemplo n.º 44
0
        void RotateGuiControl(EControl sender, float alpha, Texture guiTexture, GuiRenderer renderer)
        {
            Rect controlRect = sender.GetScreenRectangle();
            Rect screenMapRect = sender.GetScreenRectangle();
            Vec2 size = controlRect.GetSize();
            float angle = MathFunctions.DegToRad(alpha);
            float smallRadius = 0.03f;
            float bigRadius = 0.8f;
            float width = 0.15f;

            Vec2 U = new Vec2(+(float)Math.Cos(angle), +(float)Math.Sin(angle));
            Vec2 V = new Vec2(-(float)Math.Sin(angle), +(float)Math.Cos(angle));
            Vec2 P1 = bigRadius * U + V * width / 2;
            Vec2 P2 = bigRadius * U - V * width / 2;
            Vec2 P3 = smallRadius * U + V * width / 2;
            Vec2 P4 = smallRadius * U - V * width / 2;

            float X1 = Vec2.Dot(P1, Vec2.XAxis);
            float Y1 = Vec2.Dot(P1, Vec2.YAxis);
            float X2 = Vec2.Dot(P2, Vec2.XAxis);
            float Y2 = Vec2.Dot(P2, Vec2.YAxis);
            float X3 = Vec2.Dot(P3, Vec2.XAxis);
            float Y3 = Vec2.Dot(P3, Vec2.YAxis);
            float X4 = Vec2.Dot(P4, Vec2.XAxis);
            float Y4 = Vec2.Dot(P4, Vec2.YAxis);

            X1 = controlRect.Left + (X1 + 1) / 2 * size.X ;
            Y1 = controlRect.Top + (Y1 + 1) / 2 * size.Y ;
            X2 = controlRect.Left + (X2 + 1) / 2 * size.X;
            Y2 = controlRect.Top + (Y2 + 1) / 2 * size.Y ;
            X3 = controlRect.Left + (X3 + 1) / 2 * size.X;
            Y3 = controlRect.Top + (Y3 + 1) / 2 * size.Y ;
            X4 = controlRect.Left + (X4 + 1) / 2 * size.X;
            Y4 = controlRect.Top + (Y4 + 1) / 2 * size.Y ;

            List<GuiRenderer.TriangleVertex> vert = new List<GuiRenderer.TriangleVertex>(6);
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X1, Y1), new ColorValue(1, 1, 1, 1), new Vec2(0, 0)));
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X2, Y2), new ColorValue(1, 1, 1, 1), new Vec2(1, 0)));
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X4, Y4), new ColorValue(1, 1, 1, 1), new Vec2(0, 1)));
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X3, Y3), new ColorValue(1, 1, 1, 1), new Vec2(1, 1)));
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X4, Y4), new ColorValue(1, 1, 1, 1), new Vec2(0, 1)));
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X2, Y2), new ColorValue(1, 1, 1, 1), new Vec2(1, 0)));
            renderer.AddTriangles(vert, guiTexture, false);
        }
Ejemplo n.º 45
0
        //Sound delete
        ////Inventory Icon
        //List <EControl> inventorySlotButton = new List<EControl>(12);
        protected override void OnAttach()
        {
            base.OnAttach();

            //To load the HUD screen
            hudControl = ControlDeclarationManager.Instance.CreateControl("Gui\\ActionHUD.gui");

            //Attach the HUD screen to the this window
            Controls.Add(hudControl);

            hudControl.Controls["Inventory"].Visible = false;

            //CutSceneManager specific
            if (CutSceneManager.Instance != null)
            {
                CutSceneManager.Instance.CutSceneEnableChange += delegate(CutSceneManager manager)
                {
                    if (manager.CutSceneEnable)
                    {
                        //Cut scene activated. All keys and buttons need to reset.
                        EngineApp.Instance.KeysAndMouseButtonUpAll();
                        GameControlsManager.Instance.DoKeyUpAll();
                    }
                };
            }

            //fill observeCameraRegions list
            foreach (Entity entity in Map.Instance.Children)
            {
                ObserveCameraArea area = entity as ObserveCameraArea;
                if (area != null)
                    observeCameraAreas.Add(area);
            }

            FreeCameraEnabled = cameraType == CameraType.Free;

            //add game specific console command
            EngineConsole.Instance.AddCommand("movePlayerUnitToCamera",
                ConsoleCommand_MovePlayerUnitToCamera);

            //accept commands of the player
            GameControlsManager.Instance.GameControlsEvent += GameControlsManager_GameControlsEvent;

            //Accept command from inventory
            {
                foreach (EControl control in hudControl.Controls["Inventory"].Controls)
                {
                    if (control.Name != String.Empty)
                        try
                        {
                            (control as EButton).Click += new EButton.ClickDelegate(InventoryItem_Click);
                        }
                        catch
                        {
                        }
                }
            }

            //Add scrool bar handle
            EScrollBar itemScroll = hudControl.Controls["Inventory/InventoryVScrollBar"] as EScrollBar;
            itemScroll.ValueChange += new EScrollBar.ValueChangeDelegate(ScrollBarValue_Change);

            //minimap
            minimapControl = hudControl.Controls["Minimap"];

            minimapControl.RenderUI += new RenderUIDelegate(Minimap_RenderUI);
            hudControl.Controls["Arrow"].BackTexture = null;
            hudControl.Controls["Arrow"].RenderUI += new RenderUIDelegate(MiniMapArrow_RenderUI);

            //EngineApp.Instance.ScreenGuiRenderer.AddText("Render minimap",
            //       new Vec2(.5f, .9f), HorizontalAlign.Center, VerticalAlign.Center);

            //EngineConsole.Instance.Print("Warning: Minimap render ", new ColorValue(1, 0, 0));

            InitCameraViewFromTarget();
        }
Ejemplo n.º 46
0
        protected override void OnControlAttach( EControl control )
        {
            base.OnControlAttach( control );
            if( control as MenuWindow != null )
            {
                EngineApp.Instance.KeysAndMouseButtonUpAll();

                simulationAfterCloseMenuWindow = EntitySystemWorld.Instance.Simulation;

                if( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() )
                    EntitySystemWorld.Instance.Simulation = false;

                EngineApp.Instance.MouseRelativeMode = false;
            }
        }
 public Page( EControl pageControl )
 {
     this.pageControl = pageControl;
 }
Ejemplo n.º 48
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();
        }
            public PhysicsPage( EControl pageControl )
                : base(pageControl)
            {
                PageControl.Controls[ "Library" ].Text = string.Format( "{0} ({1})",
                    PhysicsWorld.Instance.DriverName, PhysicsWorld.Instance.DriverAssemblyFileName );

                ECheckBox hardwareAccelecatedCheckBox = (ECheckBox)PageControl.Controls[
                    "HardwareAccelerated" ];
                hardwareAccelecatedCheckBox.Enable = false;
                hardwareAccelecatedCheckBox.Checked = PhysicsWorld.Instance.HardwareAccelerated;
            }
 //
 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;
 }
            public SoundPage( EControl pageControl )
                : base(pageControl)
            {
                EComboBox comboBox;

                string libraryText = SoundWorld.Instance.DriverName;
                if( SoundWorld.Instance.DriverName != "NULL" )
                    libraryText += string.Format( " ({0})", SoundWorld.Instance.DriverAssemblyFileName );
                PageControl.Controls[ "Library" ].Text = libraryText;

                comboBox = (EComboBox)PageControl.Controls[ "InformationType" ];
                comboBox.Items.Add( "Loaded sounds" );
                comboBox.Items.Add( "Virtual channels" );
                comboBox.Items.Add( "Real channels" );
                comboBox.SelectedIndex = 0;
            }
 public EntitiesPage( EControl pageControl )
     : base(pageControl)
 {
 }
Ejemplo n.º 53
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();
        }
 ///////////////
 public GeneralPage( EControl pageControl )
     : base(pageControl)
 {
 }
Ejemplo n.º 55
0
        //Draw minimap
        void Minimap_RenderUI( EControl sender, GuiRenderer renderer )
        {
            Rect screenMapRect = sender.GetScreenRectangle();

            Bounds initialBounds = Map.Instance.InitialCollisionBounds;
            Rect mapRect = new Rect( initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2() );

            Vec2 mapSizeInv = new Vec2( 1, 1 ) / mapRect.Size;

            //draw units
            Vec2 screenPixel = new Vec2( 1, 1 ) / new Vec2( EngineApp.Instance.VideoMode.Size.ToVec2() );

            foreach( Entity entity in Map.Instance.Children )
            {
                RTSUnit unit = entity as RTSUnit;
                if( unit == null )
                    continue;

                Rect rect = new Rect( unit.MapBounds.Minimum.ToVec2(), unit.MapBounds.Maximum.ToVec2() );

                rect -= mapRect.Minimum;
                rect.Minimum *= mapSizeInv;
                rect.Maximum *= mapSizeInv;
                rect.Minimum = new Vec2( rect.Minimum.X, 1.0f - rect.Minimum.Y );
                rect.Maximum = new Vec2( rect.Maximum.X, 1.0f - rect.Maximum.Y );
                rect.Minimum *= screenMapRect.Size;
                rect.Maximum *= screenMapRect.Size;
                rect += screenMapRect.Minimum;

                //increase 1 pixel
                rect.Maximum += new Vec2( screenPixel.X, -screenPixel.Y );

                ColorValue color;

                if( playerFaction == null || unit.Intellect == null || unit.Intellect.Faction == null )
                    color = new ColorValue( 1, 1, 0 );
                else if( playerFaction == unit.Intellect.Faction )
                    color = new ColorValue( 0, 1, 0 );
                else
                    color = new ColorValue( 1, 0, 0 );

                renderer.AddQuad( rect, color );
            }

            //Draw camera borders
            {
                Camera camera = RendererWorld.Instance.DefaultCamera;

                if( camera.Position.Z > 0 )
                {

                    Plane groundPlane = new Plane( 0, 0, 1, 0 );

                    Vec2[] points = new Vec2[ 4 ];

                    for( int n = 0; n < 4; n++ )
                    {
                        Vec2 p = Vec2.Zero;

                        switch( n )
                        {
                        case 0: p = new Vec2( 0, 0 ); break;
                        case 1: p = new Vec2( 1, 0 ); break;
                        case 2: p = new Vec2( 1, 1 ); break;
                        case 3: p = new Vec2( 0, 1 ); break;
                        }

                        Ray ray = camera.GetCameraToViewportRay( p );

                        float scale;
                        groundPlane.RayIntersection( ray, out scale );

                        Vec3 pos = ray.GetPointOnRay( scale );
                        if( ray.Direction.Z > 0 )
                            pos = ray.Origin + ray.Direction.GetNormalize() * 10000;

                        Vec2 point = pos.ToVec2();

                        point -= mapRect.Minimum;
                        point *= mapSizeInv;
                        point = new Vec2( point.X, 1.0f - point.Y );
                        point *= screenMapRect.Size;
                        point += screenMapRect.Minimum;

                        points[ n ] = point;
                    }

                    for( int n = 0; n < 4; n++ )
                        renderer.AddLine( points[ n ], points[ ( n + 1 ) % 4 ], new ColorValue( 1, 1, 1 ),
                            screenMapRect );
                }
            }
        }
 public MemoryPage( EControl pageControl )
     : base(pageControl)
 {
 }
Ejemplo n.º 57
0
        //
        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;
                };
            }
        }
Ejemplo n.º 58
0
        // TASK: Draw minimap
        void Minimap_RenderUI(EControl sender, GuiRenderer renderer)
        {
            Rect screenMapRect = sender.GetScreenRectangle();

            //Get Map Rectange
            Bounds initialBounds = Map.Instance.InitialCollisionBounds;
            Rect mapRect = new Rect(initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2());

            Vec2 mapSizeInv = new Vec2(1, 1) / mapRect.Size;

            Unit playerUnit = GetPlayerUnit();

            Rect rect = new Rect(playerUnit.MapBounds.Minimum.ToVec2(),
                                 playerUnit.MapBounds.Maximum.ToVec2() );

            //Get position in the worldmap 2d image
            float worldMapX = (playerUnit.Position.X + 500) / 1000 * 512;
            float worldMapY = (playerUnit.Position.Y + 500) / 1000 * 512;

            //Get begin cliped rectange postion in the worldmap 2d image
            float x1 = worldMapX - 56;
            float y1 = worldMapY - 56;

            float x2 = x1 + 128;
            float y2 = x2 + 128;

            //Convert to % unit : 0.00...1.00
            float fx1 = x1 / 512.0f;
            float fy1 = (float)y1 / 512.0f;

            float fx2 = x2 / 512.0f;
            float fy2 = y2 / 512.0f;

            Rect coordRect = new Rect(fx1, fy1, fx2, fy2);
            minimapControl.BackTextureCoord = coordRect;

            //    //draw units
            //    Vec2 screenPixel = new Vec2(1, 1) / new Vec2(EngineApp.Instance.VideoMode.Size.ToVec2());
            //    {
            //        ////Loading texture to the engine
            //        //Texture texture = null;
            //        //string mapDirectory = Path.GetDirectoryName(mapName);
            //        //string textureName = mapDirectory + "\\Data\\Minimap";
            //        //string textureFileName = "Minimap";
            //        //bool finded = false;
            //        //string[] extensions = new string[] { "dds", "tga", "png", "jpg" };
            //        //foreach (string extension in extensions)
            //        //{
            //        //    textureFileName = textureName + "." + extension;
            //        //    if (VirtualFile.Exists(textureFileName))
            //        //    {
            //        //        finded = true;
            //        //        break;
            //        //    }
            //        //}
            //        //if (finded)
            //        //    texture = TextureManager.Instance.Load(textureFileName);

            //        Unit playerUnit = GetPlayerUnit();

            //        Rect rect = new Rect(playerUnit.MapBounds.Minimum.ToVec2(),
            //                             playerUnit.MapBounds.Maximum.ToVec2()
            //                             );

            //        rect -= mapRect.Minimum;
            //        rect.Minimum *= mapSizeInv;
            //        rect.Maximum *= mapSizeInv;

            //        rect.Minimum = new Vec2(rect.Minimum.X, 1.0f - rect.Minimum.Y);
            //        rect.Maximum = new Vec2(rect.Maximum.X, 1.0f - rect.Maximum.Y);

            //        rect.Minimum *= screenMapRect.Size;
            //        rect.Maximum *= screenMapRect.Size;

            //        rect += screenMapRect.Minimum;

            //        //increase 1 pixel
            //        rect.Maximum += new Vec2(screenPixel.X, -screenPixel.Y);

            //        ColorValue color;

            //        if (playerUnit.Intellect == null || playerUnit.Intellect.Faction == null)
            //            color = new ColorValue(1, 1, 0);
            //        else
            //            color = new ColorValue(1, 0, 0);

            //        renderer.AddQuad(rect, color);

            //    }

            //    //foreach (Entity entity in Map.Instance.Children)
            //    //{
            //    //    GameCharacter unit = entity as GameCharacter;

            //    //    if (unit == null)
            //    //        continue;

            //    //    Rect rect = new Rect(unit.MapBounds.Minimum.ToVec2(), unit.MapBounds.Maximum.ToVec2());

            //    //    rect -= mapRect.Minimum;
            ////    rect.Minimum *= mapSizeInv;
            ////    rect.Maximum *= mapSizeInv;
            ////    rect.Minimum = new Vec2(rect.Minimum.X, 1.0f - rect.Minimum.Y);
            ////    rect.Maximum = new Vec2(rect.Maximum.X, 1.0f - rect.Maximum.Y);
            ////    rect.Minimum *= screenMapRect.Size;
            ////    rect.Maximum *= screenMapRect.Size;
            ////    rect += screenMapRect.Minimum;

            ////    //increase 1 pixel
            ////    rect.Maximum += new Vec2(screenPixel.X, -screenPixel.Y);

            ////    ColorValue color;

            ////    if (unit.Intellect == null || unit.Intellect.Faction == null)
            ////        color = new ColorValue(1, 1, 0);
            ////    else
            ////        color = new ColorValue(1, 0, 0);

            ////    renderer.AddQuad(rect, color);
            ////}

            //    //Draw camera borders
            //    {
            //        //    Camera camera = RendererWorld.Instance.DefaultCamera;

            //        //    if (camera.Position.Z > 0)
            //        //    {

            //        //        Plane groundPlane = new Plane(0, 0, 1, 0);

            //        //        Vec2[] points = new Vec2[4];

            //        //        for (int n = 0; n < 4; n++)
            //        //        {
            //        //            Vec2 p = Vec2.Zero;

            //        //            switch (n)
            //        //            {
            //        //                case 0: p = new Vec2(0, 0); break;
            //        //                case 1: p = new Vec2(1, 0); break;
            //        //                case 2: p = new Vec2(1, 1); break;
            //        //                case 3: p = new Vec2(0, 1); break;
            //        //            }

            //        //            Ray ray = camera.GetCameraToViewportRay(p);

            //        //            float scale;
            //        //            groundPlane.RayIntersection(ray, out scale);

            //        //            Vec3 pos = ray.GetPointOnRay(scale);
            //        //            if (ray.Direction.Z > 0)
            //        //                pos = ray.Origin + ray.Direction.GetNormalize() * 10000;

            //        //            Vec2 point = pos.ToVec2();

            //        //            point -= mapRect.Minimum;
            //        //            point *= mapSizeInv;
            //        //            point = new Vec2(point.X, 1.0f - point.Y);
            //        //            point *= screenMapRect.Size;
            //        //            point += screenMapRect.Minimum;

            //        //            points[n] = point;
            //        //        }

            //        //        for (int n = 0; n < 4; n++)
            //        //            renderer.AddLine(points[n], points[(n + 1) % 4], new ColorValue(1, 1, 1),
            //        //                screenMapRect);
            //        //    }
            //    }
        }
Ejemplo n.º 59
0
        protected override void OnControlDetach( EControl control )
        {
            if( control as MenuWindow != null )
            {
                if( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() )
                    EntitySystemWorld.Instance.Simulation = simulationAfterCloseMenuWindow;
            }

            base.OnControlDetach( control );
        }
Ejemplo n.º 60
0
        void UpdateHUDControlIcon( EControl control, string iconName )
        {
            if( !string.IsNullOrEmpty( iconName ) )
            {
                string fileName = string.Format( "Gui\\HUD\\Icons\\{0}.png", iconName );

                bool needUpdate = false;

                if( control.BackTexture != null )
                {
                    string current = control.BackTexture.Name;
                    current = current.Replace( '/', '\\' );

                    if( string.Compare( fileName, current, true ) != 0 )
                        needUpdate = true;
                }
                else
                    needUpdate = true;

                if( needUpdate )
                {
                    if( VirtualFile.Exists( fileName ) )
                        control.BackTexture = TextureManager.Instance.Load( fileName, Texture.Type.Type2D, 0 );
                    else
                        control.BackTexture = null;
                }
            }
            else
                control.BackTexture = null;
        }