Ejemplo n.º 1
0
 /// <summary>
 /// Loads all content for the game, and starts the systems.
 /// </summary>
 /// <param name="sender">Irrelevant.</param>
 /// <param name="e">Irrelevant.</param>
 private void Window_Load(object sender, EventArgs e)
 {
     SysConsole.Output(OutputType.INIT, "GameClient starting load sequence...");
     GL.Viewport(0, 0, Window.Width, Window.Height);
     GL.Enable(EnableCap.Texture2D);
     GL.Enable(EnableCap.Blend);
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
     GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
     GL.Disable(EnableCap.CullFace);
     GraphicsUtil.CheckError("GEB - Initial");
     SysConsole.Output(OutputType.INIT, "GameClient loading file helpers...");
     Files = new FileHandler();
     Files.Init();
     SysConsole.Output(OutputType.INIT, "GameClient loading shader helpers...");
     Shaders = new ShaderEngine();
     Shaders.InitShaderSystem();
     SysConsole.Output(OutputType.INIT, "GameClient loading texture helpers...");
     Textures = new TextureEngine();
     Textures.InitTextureSystem(Files);
     GraphicsUtil.CheckError("GEB - Textures");
     SysConsole.Output(OutputType.INIT, "GameClient loading font helpers...");
     GLFonts = new GLFontEngine(Textures, Shaders);
     GLFonts.Init(Files);
     FontSets = new FontSetEngine(GLFonts)
     {
         FixTo = Shaders.ColorMult2DShader
     };
     // TODO: FGE/Core->Languages engine!
     FontSets.Init((subdata) => null, () => Ortho, () => GlobalTickTime);
     GraphicsUtil.CheckError("GEB - Fonts");
     SysConsole.Output(OutputType.INIT, "GameClient loading 2D/UI render helper...");
     MainUI = new ViewUI2D(this);
     SysConsole.Output(OutputType.INIT, "GameEngine loading model engine...");
     Animations = new AnimationEngine();
     Models     = new ModelEngine();
     Models.Init(Animations, this);
     SysConsole.Output(OutputType.INIT, "GameEngine loading render helper...");
     Rendering3D = new Renderer(Textures, Shaders, Models);
     Rendering3D.Init();
     Rendering2D = new Renderer2D(Textures, Shaders);
     Rendering2D.Init();
     SysConsole.Output(OutputType.INIT, "GameClient calling engine load...");
     CurrentEngine.Load();
     SysConsole.Output(OutputType.INIT, "GameClient calling external load event...");
     OnWindowLoad?.Invoke();
     SysConsole.Output(OutputType.INIT, "GameClient is ready and loaded! Starting main game loop...");
     GraphicsUtil.CheckError("GEB - Loaded");
     Loaded = true;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads all shaders from the backing engine given.
        /// </summary>
        /// <param name="Shaders">The given backing shader engine.</param>
        /// <param name="AllowLL">Whether to allow and load the LL lighting helper.</param>
        /// <param name="forNorm">Whether to enable forward-mode normal effects.</param>
        /// <param name="forLight">Whether to enable forward-mode lighting.</param>
        /// <param name="forShad">Whether to enable forward-mode shadow effects.</param>
        public void LoadAll(ShaderEngine Shaders, bool AllowLL, bool forNorm, bool forLight, bool forShad)
        {
            string def = Shaders.MCM_GOOD_GRAPHICS ? "#MCM_GOOD_GRAPHICS" : "#";

            Deferred.ShadowPass_Basic            = Shaders.GetShader("shadow" + def);
            Deferred.ShadowPass_NoBones          = Shaders.GetShader("shadow" + def + ",MCM_NO_BONES");
            Deferred.GBufferSolid                = Shaders.GetShader("fbo" + def);
            Deferred.GBuffer_AllTransparencies   = Shaders.GetShader("fbo" + def + ",MCM_TRANSP_ALLOWED");
            Deferred.GBuffer_Refraction          = Shaders.GetShader("fbo" + def + ",MCM_REFRACT");
            Deferred.ShadowAdderPass             = Shaders.GetShader("lightadder" + def + ",MCM_SHADOWS");
            Deferred.LightAdderPass              = Shaders.GetShader("lightadder" + def);
            Deferred.ShadowAdderPass_SSAO        = Shaders.GetShader("lightadder" + def + ",MCM_SHADOWS,MCM_SSAO");
            Deferred.LightAdderPass_SSAO         = Shaders.GetShader("lightadder" + def + ",MCM_SSAO");
            Deferred.Transparents                = Shaders.GetShader("transponly" + def);
            Deferred.Transparents_Lights         = Shaders.GetShader("transponly" + def + ",MCM_LIT");
            Deferred.Transparents_Lights_Shadows = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_SHADOWS");
            Deferred.Godrays = Shaders.GetShader("godray" + def);
            Deferred.TransparentAdderPass        = Shaders.GetShader("transpadder" + def);
            Deferred.FinalPass_Basic             = Shaders.GetShader("finalgodray" + def);
            Deferred.FinalPass_Toonify           = Shaders.GetShader("finalgodray" + def + ",MCM_TOONIFY");
            Deferred.FinalPass_Lights            = Shaders.GetShader("finalgodray" + def + ",MCM_LIGHTS");
            Deferred.FinalPass_Lights_Toonify    = Shaders.GetShader("finalgodray" + def + ",MCM_LIGHTS,MCM_TOONIFY");
            Deferred.FinalPass_Lights_MotionBlur = Shaders.GetShader("finalgodray" + def + ",MCM_LIGHTS,MCM_MOTBLUR");
            string forw_extra = (forNorm ? ",MCM_NORMALS" : "")
                                + (forLight ? ",MCM_LIGHTS" : "")
                                + (forShad ? ",MCM_SHADOWS" : "");

            Forward.BasicSolid               = Shaders.GetShader("forward" + def + forw_extra);
            Forward.BasicSolid_NoBones       = Shaders.GetShader("forward" + def + ",MCM_NO_BONES" + forw_extra);
            Forward.BasicTransparent         = Shaders.GetShader("forward" + def + ",MCM_TRANSP" + forw_extra);
            Forward.BasicTransparent_NoBones = Shaders.GetShader("forward" + def + ",MCM_TRANSP,MCM_NO_BONES" + forw_extra);
            if (AllowLL)
            {
                Deferred.Transparents_LL                = Shaders.GetShader("transponly" + def + ",MCM_LL");
                Deferred.Transparents_Lights_LL         = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_LL");
                Deferred.Transparents_Lights_Shadows_LL = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_SHADOWS,MCM_LL");
                Deferred.LLClearerPass = Shaders.GetShader("clearer" + def);
                Deferred.LLFinalPass   = Shaders.GetShader("fpass" + def);
            }
            Deferred.HDRPass                               = Shaders.GetShader("hdrpass" + def);
            Forward.PostProcess                            = Shaders.GetShader("postfast" + def);
            Forward.Grass                                  = Shaders.GetShader("forward" + def + ",MCM_GEOM_ACTIVE,MCM_GEOM_THREED_TEXTURE" + forw_extra + "?grass");
            Deferred.GBuffer_Grass                         = Shaders.GetShader("fbo" + def + ",MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_GEOM_THREED_TEXTURE?grass");
            Deferred.ShadowPass_Grass                      = Shaders.GetShader("shadow" + def + ",MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_SHADOWS,MCM_IS_A_SHADOW,MCM_GEOM_THREED_TEXTURE?grass");
            Deferred.ShadowPass_Particles                  = Shaders.GetShader("shadow" + def + ",MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_SHADOWS,MCM_NO_ALPHA_CAP,MCM_FADE_DEPTH,MCM_IS_A_SHADOW?particles");
            Forward.Particles                              = Shaders.GetShader("forward" + def + ",MCM_GEOM_ACTIVE,MCM_TRANSP,MCM_BRIGHT,MCM_NO_ALPHA_CAP,MCM_FADE_DEPTH" + forw_extra + "?particles");
            Deferred.GBuffer_Decals                        = Shaders.GetShader("fbo" + def + ",MCM_INVERSE_FADE,MCM_NO_ALPHA_CAP,MCM_GEOM_ACTIVE,MCM_PRETTY?decal");
            Forward.Decals                                 = Shaders.GetShader("forward" + def + ",MCM_INVERSE_FADE,MCM_NO_ALPHA_CAP,MCM_GEOM_ACTIVE" + forw_extra + "?decal");
            Forward.AllTransparencies_NoFog                = Shaders.GetShader("forward" + def + ",MCM_NO_ALPHA_CAP,MCM_BRIGHT,MCM_NO_BONES" + forw_extra);
            Forward.AllTransparencies_Objects              = Shaders.GetShader("forward" + def + ",MCM_NO_BONES" + forw_extra);
            Forward.AllTransparencies_Sky                  = Shaders.GetShader("forward" + def + ",MCM_NO_ALPHA_CAP,MCM_BRIGHT,MCM_NO_BONES,MCM_SKY_FOG" + forw_extra);
            Deferred.Transparents_Particles                = Shaders.GetShader("transponly" + def + ",MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
            Deferred.Transparents_Particles_Lights         = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
            Deferred.Transparents_Particles_Lights_Shadows = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_SHADOWS,MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
            if (AllowLL)
            {
                Deferred.Transparents_Particles_LL                = Shaders.GetShader("transponly" + def + ",MCM_LL,MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
                Deferred.Transparents_Particles_Lights_LL         = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_LL,MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
                Deferred.Transparents_Particles_Lights_Shadows_LL = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_SHADOWS,MCM_LL,MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called when the window is loading, only to be used by the startup process.
        /// </summary>
        void Window_Load(object sender, EventArgs e)
        {
            SysConsole.Output(OutputType.CLIENTINIT, "Window generated!");
            DPIScale = Window.Width / CVars.r_width.ValueF;
            SysConsole.Output(OutputType.CLIENTINIT, "DPIScale is " + DPIScale + "!");
            SysConsole.Output(OutputType.CLIENTINIT, "Setting up a game engine backend placeholder...");
            FakeEngine();
            SysConsole.Output(OutputType.CLIENTINIT, "Loading base textures...");
            PreInitRendering();
            Textures = new TextureEngine();
            Textures.InitTextureSystem(Files);
            ItemFrame        = Textures.GetTexture("ui/hud/item_frame");
            CWindow.Textures = Textures;
            SysConsole.Output(OutputType.CLIENTINIT, "Loading shaders...");
            Shaders    = new ShaderEngine();
            GLVendor   = GL.GetString(StringName.Vendor);
            GLVersion  = GL.GetString(StringName.Version);
            GLRenderer = GL.GetString(StringName.Renderer);
            SysConsole.Output(OutputType.CLIENTINIT, "Vendor: " + GLVendor + ", GLVersion: " + GLVersion + ", Renderer: " + GLRenderer);
            if (GLVendor.ToLowerFast().Contains("intel"))
            {
                SysConsole.Output(OutputType.CLIENTINIT, "Disabling good graphics (Appears to be Intel: '" + GLVendor + "')");
                Shaders.MCM_GOOD_GRAPHICS = false;
            }
            Shaders.InitShaderSystem();
            CWindow.Shaders = Shaders;
            Engine.GetShaders();
            GraphicsUtil.CheckError("Load - Shaders");
            SysConsole.Output(OutputType.CLIENTINIT, "Loading animation engine...");
            Animations         = new AnimationEngine();
            CWindow.Animations = Animations;
            SysConsole.Output(OutputType.CLIENTINIT, "Loading model engine...");
            Models = new ModelEngine();
            Models.Init(Animations, CWindow);
            LODHelp        = new ModelLODHelper(this);
            CWindow.Models = Models;
            SysConsole.Output(OutputType.CLIENTINIT, "Loading rendering helper...");
            Rendering = new Renderer(Textures, Shaders, Models);
            Rendering.Init();
            CWindow.Rendering3D = Rendering;
            CWindow.Rendering2D = new Renderer2D(Textures, Shaders);
            CWindow.Rendering2D.Init();
            SysConsole.Output(OutputType.CLIENTINIT, "Preparing load screen...");
            load_screen = Textures.GetTexture("ui/menus/loadscreen");
            Establish2D();
            SWLoading.Start();
            PassLoadScreen();
            SysConsole.Output(OutputType.CLIENTINIT, "Loading block textures...");
            TBlock = new TextureBlock();
            TBlock.Generate(this, CVars, Textures, false);
            GraphicsUtil.CheckError("Load - Textures");
            SysConsole.Output(OutputType.CLIENTINIT, "Loading fonts...");
            Fonts = new GLFontEngine(Textures, Shaders);
            Fonts.Init(Files);
            FontSets = new FontSetEngine(Fonts);
            FontSets.Init((subdat) => Languages.GetText(Files, subdat), () => Ortho, () => GlobalTickTimeLocal);
            GraphicsUtil.CheckError("Load - Fonts");
            PassLoadScreen();
            CWindow.FontSets = FontSets;
            CWindow.GLFonts  = Fonts;
            SysConsole.Output(OutputType.CLIENTINIT, "Loading general graphics settings...");
            CVars.r_vsync.OnChanged += OnVsyncChanged;
            OnVsyncChanged(CVars.r_vsync, EventArgs.Empty);
            CVars.r_cloudshadows.OnChanged += OnCloudShadowChanged;
            CVars.r_transpll.OnChanged     += OnLLChanged;
            OnLLChanged(CVars.r_transpll, EventArgs.Empty);
            GraphicsUtil.CheckError("Load - General Graphics");
            SysConsole.Output(OutputType.CLIENTINIT, "Loading UI engine...");
            UIConsole.InitConsole(); // TODO: make this non-static
            InitChatSystem();
            PassLoadScreen();
            GraphicsUtil.CheckError("Load - UI");
            SysConsole.Output(OutputType.CLIENTINIT, "Preparing rendering engine...");
            InitRendering();
            GraphicsUtil.CheckError("Load - Rendering");
            SysConsole.Output(OutputType.CLIENTINIT, "Loading particle effect engine...");
            Particles = new ParticleHelper(this)
            {
                Engine = new ParticleEngine(this)
            };
            SysConsole.Output(OutputType.CLIENTINIT, "Preparing mouse and keyboard handlers...");
            KeyHandler.Init();
            Gamepad = new GamePadHandler();
            Gamepad.Init(this);
            PassLoadScreen();
            GraphicsUtil.CheckError("Load - Keyboard/mouse");
            SysConsole.Output(OutputType.CLIENTINIT, "Building the sound system...");
            Sounds.Init(Engine);
            GraphicsUtil.CheckError("Load - Sound");
            SysConsole.Output(OutputType.CLIENTINIT, "Building game world...");
            BuildWorld();
            PassLoadScreen();
            GraphicsUtil.CheckError("Load - World");
            SysConsole.Output(OutputType.CLIENTINIT, "Preparing networking...");
            Network = new NetworkBase(this);
            RegisterDefaultEntityTypes();
            GraphicsUtil.CheckError("Load - Net");
            PassLoadScreen();
            SysConsole.Output(OutputType.CLIENTINIT, "Loading Voxel computer...");
            try
            {
                VoxelComputer = new VoxelComputeEngine();
                VoxelComputer.Init(this);
            }
            catch (Exception ex)
            {
                SysConsole.Output(ex);
            }
            PassLoadScreen();
            SysConsole.Output(OutputType.CLIENTINIT, "Playing background music...");
            BackgroundMusic();
            CVars.a_musicvolume.OnChanged += OnMusicVolumeChanged;
            CVars.a_musicpitch.OnChanged  += OnMusicPitchChanged;
            CVars.a_music.OnChanged       += OnMusicChanged;
            CVars.a_echovolume.OnChanged  += OnEchoVolumeChanged;
            OnEchoVolumeChanged(null, null);
            PassLoadScreen();
            SysConsole.Output(OutputType.CLIENTINIT, "Setting up screens...");
            TheMainMenuScreen         = new MainMenuScreen(this);
            TheGameScreen             = new GameScreen(this);
            TheSingleplayerMenuScreen = new SingleplayerMenuScreen(this);
            TheLoadScreen             = new LoadScreen(this);
            CScreen = TheMainMenuScreen;
            SysConsole.Output(OutputType.CLIENTINIT, "Trying to grab RawGamePad...");
            try
            {
                RawGamePad = new XInput();
            }
            catch (Exception ex)
            {
                SysConsole.Output(OutputType.CLIENTINIT, "Failed to grab RawGamePad: " + ex.Message);
            }
            SysConsole.Output(OutputType.CLIENTINIT, "Preparing inventory...");
            InitInventory();
            PassLoadScreen();
            SysConsole.Output(OutputType.CLIENTINIT, "Creating sky...");
            CreateSkyBox();
            SysConsole.Output(OutputType.CLIENTINIT, "Requesting a menu server...");
            LocalServer?.ShutDown();
            LocalServer = new Server(28009)
            {
                IsMenu = true
            };                                                 // TODO: Grab first free port?
            Object locky = new Object();
            bool   ready = false;

            Schedule.StartAsyncTask(() =>
            {
                LocalServer.StartUp("menu", () =>
                {
                    lock (locky)
                    {
                        ready = true;
                    }
                });
            });
            while (true)
            {
                lock (locky)
                {
                    if (ready)
                    {
                        break;
                    }
                }
                PassLoadScreen();
                Thread.Sleep(50);
            }
            SysConsole.Output(OutputType.CLIENTINIT, "Connecting to a menu server...");
            Network.LastConnectionFailed = false;
            Network.Connect("localhost", "28009", true, null); // TODO: Grab accurate local IP?
            Stopwatch sw = new Stopwatch();

            sw.Start();
            bool annc = false;

            while (true)
            {
                if (Network.LastConnectionFailed)
                {
                    SysConsole.Output(OutputType.CLIENTINIT, "Failed to connect to menu server! Failing!");
                    Window.Close();
                    return;
                }
                if (Network.IsAlive)
                {
                    break;
                }
                sw.Stop();
                long ms = sw.ElapsedMilliseconds;
                sw.Start();
                if (ms > 10000 && !annc)
                {
                    annc = true;
                    SysConsole.Output(OutputType.WARNING, "Taking weirdly long, did something fail?!");
                }
                if (ms > 20000)
                {
                    SysConsole.Output(OutputType.CLIENTINIT, "Timed out while trying to connect to menu server! Failing!");
                    Window.Close();
                    return;
                }
                PassLoadScreen();
                Thread.Sleep(50);
            }
            SysConsole.Output(OutputType.CLIENTINIT, "Showing main menu...");
            ShowMainMenu();
            GraphicsUtil.CheckError("Load - Final");
            SysConsole.Output(OutputType.CLIENTINIT, "Ready and looping!");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called when the window is loading, only to be used by the startup process.
        /// </summary>
        void Window_Load(object sender, EventArgs e)
        {
            SysConsole.Output(OutputType.INIT, "Window generated!");
            DPIScale = Window.Width / CVars.r_width.ValueF;
            SysConsole.Output(OutputType.INIT, "DPIScale is " + DPIScale + "!");
            SysConsole.Output(OutputType.INIT, "Loading base textures...");
            PreInitRendering();
            Textures = new TextureEngine();
            Textures.InitTextureSystem(this);
            ItemFrame = Textures.GetTexture("ui/hud/item_frame");
            SysConsole.Output(OutputType.INIT, "Loading shaders...");
            Shaders  = new ShaderEngine();
            GLVendor = GL.GetString(StringName.Vendor);
            CVars.s_glvendor.Value = GLVendor;
            GLVersion = GL.GetString(StringName.Version);
            CVars.s_glversion.Value = GLVersion;
            GLRenderer = GL.GetString(StringName.Renderer);
            CVars.s_glrenderer.Value = GLRenderer;
            SysConsole.Output(OutputType.INIT, "Vendor: " + GLVendor + ", GLVersion: " + GLVersion + ", Renderer: " + GLRenderer);
            if (GLVendor.ToLowerFast().Contains("intel"))
            {
                SysConsole.Output(OutputType.INIT, "Disabling good graphics (Appears to be Intel: '" + GLVendor + "')");
                Shaders.MCM_GOOD_GRAPHICS = false;
            }
            Shaders.InitShaderSystem(this);
            View3D.CheckError("Load - Shaders");
            SysConsole.Output(OutputType.INIT, "Loading rendering helper...");
            Rendering = new Renderer(Textures, Shaders);
            Rendering.Init();
            SysConsole.Output(OutputType.INIT, "Preparing load screen...");
            Texture load_screen = Textures.GetTexture("ui/menus/loadscreen");

            load_screen.Bind();
            Shaders.ColorMultShader.Bind();
            Establish2D();
            Rendering.RenderRectangle(0, 0, Window.Width, Window.Height);
            Window.SwapBuffers();
            SysConsole.Output(OutputType.INIT, "Loading block textures...");
            TBlock = new TextureBlock();
            TBlock.Generate(this, CVars, Textures);
            View3D.CheckError("Load - Textures");
            SysConsole.Output(OutputType.INIT, "Loading fonts...");
            Fonts = new GLFontEngine(Shaders);
            Fonts.Init(this);
            FontSets = new FontSetEngine(Fonts);
            FontSets.Init(this);
            View3D.CheckError("Load - Fonts");
            SysConsole.Output(OutputType.INIT, "Loading animation engine...");
            Animations = new AnimationEngine();
            SysConsole.Output(OutputType.INIT, "Loading model engine...");
            Models = new ModelEngine();
            Models.Init(Animations, this);
            SysConsole.Output(OutputType.INIT, "Loading general graphics settings...");
            CVars.r_vsync.OnChanged += onVsyncChanged;
            onVsyncChanged(CVars.r_vsync, null);
            CVars.r_cloudshadows.OnChanged += onCloudShadowChanged;
            View3D.CheckError("Load - General Graphics");
            SysConsole.Output(OutputType.INIT, "Loading UI engine...");
            UIConsole.InitConsole(); // TODO: make this non-static
            InitChatSystem();
            View3D.CheckError("Load - UI");
            SysConsole.Output(OutputType.INIT, "Preparing rendering engine...");
            InitRendering();
            View3D.CheckError("Load - Rendering");
            SysConsole.Output(OutputType.INIT, "Loading particle effect engine...");
            Particles = new ParticleHelper(this)
            {
                Engine = new ParticleEngine(this)
            };
            SysConsole.Output(OutputType.INIT, "Preparing mouse, keyboard, and gamepad handlers...");
            KeyHandler.Init();
            GamePadHandler.Init();
            View3D.CheckError("Load - Keyboard/mouse");
            SysConsole.Output(OutputType.INIT, "Building the sound system...");
            Sounds = new SoundEngine();
            Sounds.Init(this, CVars);
            View3D.CheckError("Load - Sound");
            SysConsole.Output(OutputType.INIT, "Building game world...");
            BuildWorld();
            View3D.CheckError("Load - World");
            SysConsole.Output(OutputType.INIT, "Preparing networking...");
            Network = new NetworkBase(this);
            RegisterDefaultEntityTypes();
            View3D.CheckError("Load - Net");
            SysConsole.Output(OutputType.INIT, "Playing background music...");
            BackgroundMusic();
            CVars.a_musicvolume.OnChanged += onMusicVolumeChanged;
            CVars.a_musicpitch.OnChanged  += onMusicPitchChanged;
            CVars.a_music.OnChanged       += onMusicChanged;
            CVars.a_echovolume.OnChanged  += OnEchoVolumeChanged;
            OnEchoVolumeChanged(null, null);
            SysConsole.Output(OutputType.INIT, "Setting up screens...");
            TheMainMenuScreen         = new MainMenuScreen(this);
            TheGameScreen             = new GameScreen(this);
            TheSingleplayerMenuScreen = new SingleplayerMenuScreen(this);
            SysConsole.Output(OutputType.INIT, "Preparing inventory...");
            InitInventory();
            SysConsole.Output(OutputType.INIT, "Showing main menu...");
            ShowMainMenu();
            SysConsole.Output(OutputType.INIT, "Trying to grab RawGamePad...");
            try
            {
                RawGamePad = new XInput();
            }
            catch (Exception ex)
            {
                SysConsole.Output(OutputType.INIT, "Failed to grab RawGamePad: " + ex.Message);
            }
            View3D.CheckError("Load - Final");
            SysConsole.Output(OutputType.INIT, "Ready and looping!");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads all shaders from the backing engine given.
        /// </summary>
        /// <param name="Shaders">The given backing shader engine.</param>
        /// <param name="AllowLL">Whether to allow and load the LL lighting helper.</param>
        /// <param name="forNorm">Whether to enable forward-mode normal effects.</param>
        /// <param name="forLight">Whether to enable forward-mode lighting.</param>
        /// <param name="forShad">Whether to enable forward-mode shadow effects.</param>
        public void LoadAll(ShaderEngine Shaders, bool AllowLL, bool forNorm, bool forLight, bool forShad)
        {
            string def = Shaders.MCM_GOOD_GRAPHICS ? "#MCM_GOOD_GRAPHICS" : "#";

            s_shadow                     = Shaders.GetShader("shadow" + def);
            s_shadow_nobones             = Shaders.GetShader("shadow" + def + ",MCM_NO_BONES");
            s_fbo                        = Shaders.GetShader("fbo" + def);
            s_fbot                       = Shaders.GetShader("fbo" + def + ",MCM_TRANSP_ALLOWED");
            s_fbo_refract                = Shaders.GetShader("fbo" + def + ",MCM_REFRACT");
            s_shadowadder                = Shaders.GetShader("lightadder" + def + ",MCM_SHADOWS");
            s_lightadder                 = Shaders.GetShader("lightadder" + def);
            s_shadowadder_ssao           = Shaders.GetShader("lightadder" + def + ",MCM_SHADOWS,MCM_SSAO");
            s_lightadder_ssao            = Shaders.GetShader("lightadder" + def + ",MCM_SSAO");
            s_transponly                 = Shaders.GetShader("transponly" + def);
            s_transponlylit              = Shaders.GetShader("transponly" + def + ",MCM_LIT");
            s_transponlylitsh            = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_SHADOWS");
            s_godray                     = Shaders.GetShader("godray" + def);
            s_transpadder                = Shaders.GetShader("transpadder" + def);
            s_finalgodray                = Shaders.GetShader("finalgodray" + def);
            s_finalgodray_toonify        = Shaders.GetShader("finalgodray" + def + ",MCM_TOONIFY");
            s_finalgodray_lights         = Shaders.GetShader("finalgodray" + def + ",MCM_LIGHTS");
            s_finalgodray_lights_toonify = Shaders.GetShader("finalgodray" + def + ",MCM_LIGHTS,MCM_TOONIFY");
            s_finalgodray_lights_motblur = Shaders.GetShader("finalgodray" + def + ",MCM_LIGHTS,MCM_MOTBLUR");
            string forw_extra = (forNorm ? ",MCM_NORMALS" : "")
                                + (forLight ? ",MCM_LIGHTS" : "")
                                + (forShad ? ",MCM_SHADOWS" : "");

            s_forw               = Shaders.GetShader("forward" + def + forw_extra);
            s_forw_nobones       = Shaders.GetShader("forward" + def + ",MCM_NO_BONES" + forw_extra);
            s_forw_trans         = Shaders.GetShader("forward" + def + ",MCM_TRANSP" + forw_extra);
            s_forw_trans_nobones = Shaders.GetShader("forward" + def + ",MCM_TRANSP,MCM_NO_BONES" + forw_extra);
            if (AllowLL)
            {
                s_transponly_ll      = Shaders.GetShader("transponly" + def + ",MCM_LL");
                s_transponlylit_ll   = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_LL");
                s_transponlylitsh_ll = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_SHADOWS,MCM_LL");
                s_ll_clearer         = Shaders.GetShader("clearer" + def);
                s_ll_fpass           = Shaders.GetShader("fpass" + def);
            }
            s_hdrpass                   = Shaders.GetShader("hdrpass" + def);
            s_post_fast                 = Shaders.GetShader("postfast" + def);
            s_forw_grass                = Shaders.GetShader("forward" + def + ",MCM_GEOM_ACTIVE,MCM_GEOM_THREED_TEXTURE" + forw_extra + "?grass");
            s_fbo_grass                 = Shaders.GetShader("fbo" + def + ",MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_GEOM_THREED_TEXTURE?grass");
            s_shadow_grass              = Shaders.GetShader("shadow" + def + ",MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_SHADOWS,MCM_IS_A_SHADOW,MCM_GEOM_THREED_TEXTURE?grass");
            s_shadow_parts              = Shaders.GetShader("shadow" + def + ",MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_SHADOWS,MCM_NO_ALPHA_CAP,MCM_FADE_DEPTH,MCM_IS_A_SHADOW?particles");
            s_forw_particles            = Shaders.GetShader("forward" + def + ",MCM_GEOM_ACTIVE,MCM_TRANSP,MCM_BRIGHT,MCM_NO_ALPHA_CAP,MCM_FADE_DEPTH" + forw_extra + "?particles");
            s_fbodecal                  = Shaders.GetShader("fbo" + def + ",MCM_INVERSE_FADE,MCM_NO_ALPHA_CAP,MCM_GEOM_ACTIVE,MCM_PRETTY?decal");
            s_forwdecal                 = Shaders.GetShader("forward" + def + ",MCM_INVERSE_FADE,MCM_NO_ALPHA_CAP,MCM_GEOM_ACTIVE" + forw_extra + "?decal");
            s_forwt_nofog               = Shaders.GetShader("forward" + def + ",MCM_NO_ALPHA_CAP,MCM_BRIGHT,MCM_NO_BONES" + forw_extra);
            s_forwt_obj                 = Shaders.GetShader("forward" + def + ",MCM_NO_BONES" + forw_extra);
            s_forwt                     = Shaders.GetShader("forward" + def + ",MCM_NO_ALPHA_CAP,MCM_BRIGHT,MCM_NO_BONES,MCM_SKY_FOG" + forw_extra);
            s_transponly_particles      = Shaders.GetShader("transponly" + def + ",MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
            s_transponlylit_particles   = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
            s_transponlylitsh_particles = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_SHADOWS,MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
            if (AllowLL)
            {
                s_transponly_ll_particles      = Shaders.GetShader("transponly" + def + ",MCM_LL,MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
                s_transponlylit_ll_particles   = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_LL,MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
                s_transponlylitsh_ll_particles = Shaders.GetShader("transponly" + def + ",MCM_LIT,MCM_SHADOWS,MCM_LL,MCM_ANY,MCM_GEOM_ACTIVE,MCM_PRETTY,MCM_FADE_DEPTH?particles");
            }
        }