示例#1
0
        protected override void LoadContent()
        {
            var fontStream = Assembly.GetEntryAssembly().GetManifestResourceStream("Alex.Resources.DebugFont.xnb");

            DebugFont = (WrappedSpriteFont)Content.Load <SpriteFont>(fontStream.ReadAllBytes());

            _spriteBatch = new SpriteBatch(GraphicsDevice);
            InputManager = new InputManager(this);
            GuiRenderer  = new GuiRenderer(this);
            GuiManager   = new GuiManager(this, InputManager, GuiRenderer);

            GuiDebugHelper = new GuiDebugHelper(GuiManager);

            AlexIpcService = new AlexIpcService();
            Services.AddService <AlexIpcService>(AlexIpcService);
            AlexIpcService.Start();

            OnCharacterInput += GuiManager.FocusManager.OnTextInput;

            GameStateManager = new GameStateManager(GraphicsDevice, _spriteBatch, GuiManager);

            var splash = new SplashScreen();

            GameStateManager.AddState("splash", splash);
            GameStateManager.SetActiveState("splash");

            WindowSize = this.Window.ClientBounds.Size;
            //	Log.Info($"Initializing Alex...");
            ThreadPool.QueueUserWorkItem((o) => { InitializeGame(splash); });
        }
示例#2
0
        protected override void UnloadContent()
        {
            //ProfileManager.SaveProfiles();

            Services.GetService <IOptionsProvider>().Save();

            GuiDebugHelper.Dispose();

            PluginManager.UnloadAll();
        }
示例#3
0
        protected override void Update(GameTime gt)
        {
            if (!UIThreadQueue.IsEmpty && UIThreadQueue.TryDequeue(out Action a))
            {
                try
                {
                    a.Invoke();
                }
                catch (Exception ex)
                {
                    Log.Warn($"Exception on UIThreadQueue: {ex.ToString()}");
                }
            }

            InputManager.Update(gt);

            GuiManager.Update(gt);
            GameStateManager.Update(gt);
            GuiDebugHelper.Update(gt);
        }
示例#4
0
        protected override void LoadContent()
        {
            var options = Services.GetService <IOptionsProvider>();

            options.Load();

            DebugFont = (WrappedSpriteFont)Content.Load <SpriteFont>("Alex.Resources.DebugFont.xnb");

            ResourceManager.BlockEffect    = Content.Load <Effect>("Alex.Resources.Blockshader.xnb").Clone();
            ResourceManager.LightingEffect = Content.Load <Effect>("Alex.Resources.Lightmap.xnb").Clone();
            //	ResourceManager.BlockEffect.GraphicsDevice = GraphicsDevice;

            _spriteBatch = new SpriteBatch(GraphicsDevice);
            InputManager = new InputManager(this);

            GuiRenderer = new GuiRenderer();
            //GuiRenderer.Init(GraphicsDevice);

            GuiManager = new GuiManager(this, Services, InputManager, GuiRenderer, options);
            GuiManager.Init(GraphicsDevice, Services);

            options.AlexOptions.VideoOptions.UseVsync.Bind((value, newValue) => { SetVSync(newValue); });
            if (options.AlexOptions.VideoOptions.UseVsync.Value)
            {
                SetVSync(true);
            }

            options.AlexOptions.VideoOptions.Fullscreen.Bind((value, newValue) => { SetFullscreen(newValue); });
            if (options.AlexOptions.VideoOptions.Fullscreen.Value)
            {
                SetFullscreen(true);
            }

            options.AlexOptions.VideoOptions.LimitFramerate.Bind((value, newValue) =>
            {
                SetFrameRateLimiter(newValue, options.AlexOptions.VideoOptions.MaxFramerate.Value);
            });

            options.AlexOptions.VideoOptions.MaxFramerate.Bind((value, newValue) =>
            {
                SetFrameRateLimiter(options.AlexOptions.VideoOptions.LimitFramerate.Value, newValue);
            });

            if (options.AlexOptions.VideoOptions.LimitFramerate.Value)
            {
                SetFrameRateLimiter(true, options.AlexOptions.VideoOptions.MaxFramerate.Value);
            }

            options.AlexOptions.VideoOptions.Antialiasing.Bind((value, newValue) =>
            {
                SetAntiAliasing(newValue > 0, newValue);
            });

            options.AlexOptions.MiscelaneousOptions.Language.Bind((value, newValue) =>
            {
                GuiRenderer.SetLanguage(newValue);
            });
            GuiRenderer.SetLanguage(options.AlexOptions.MiscelaneousOptions.Language);

            SetAntiAliasing(options.AlexOptions.VideoOptions.Antialiasing > 0,
                            options.AlexOptions.VideoOptions.Antialiasing.Value);

            GuiDebugHelper = new GuiDebugHelper(GuiManager);

            OnCharacterInput += GuiManager.FocusManager.OnTextInput;

            GameStateManager = new GameStateManager(GraphicsDevice, _spriteBatch, GuiManager);

            var splash = new SplashScreen();

            GameStateManager.AddState("splash", splash);
            GameStateManager.SetActiveState("splash");

            WindowSize = this.Window.ClientBounds.Size;
            //	Log.Info($"Initializing Alex...");
            ThreadPool.QueueUserWorkItem(() =>
            {
                try
                {
                    InitializeGame(splash);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, $"Could not initialize! {ex}");
                }
            });
        }
示例#5
0
        protected override void LoadContent()
        {
            Stopwatch loadingStopwatch = Stopwatch.StartNew();

            var builtInFont = ResourceManager.ReadResource("Alex.Resources.default_font.png");

            var image = Image.Load <Rgba32>(builtInFont);

            OnResourcePackPreLoadCompleted(image, McResourcePack.BitmapFontCharacters.ToList());

            var options = Services.GetService <IOptionsProvider>();

            options.Load();

            //	DebugFont = (WrappedSpriteFont) Content.Load<SpriteFont>("Alex.Resources.DebugFont.xnb");

            //	ResourceManager.EntityEffect = Content.Load<Effect>("Alex.Resources.Entityshader.xnb").Clone();
#if DIRECTX
            ResourceManager.BlockEffect    = Content.Load <Effect>("Alex.Resources.Blockshader_dx.xnb").Clone();
            ResourceManager.LightingEffect = Content.Load <Effect>("Alex.Resources.Lightmap_dx.xnb").Clone();
#else
            ResourceManager.BlockEffect    = Content.Load <Effect>("Alex.Resources.Blockshader.xnb").Clone();
            ResourceManager.LightingEffect = Content.Load <Effect>("Alex.Resources.Lightmap.xnb").Clone();
#endif
            //	ResourceManager.BlockEffect.GraphicsDevice = GraphicsDevice;

            _spriteBatch = new SpriteBatch(GraphicsDevice);
            InputManager = new InputManager(this);

            GuiRenderer = new GuiRenderer();
            //GuiRenderer.Init(GraphicsDevice);

            GuiManager = new GuiManager(this, Services, InputManager, GuiRenderer, options);
            GuiManager.Init(GraphicsDevice, Services);

            options.AlexOptions.VideoOptions.FancyGraphics.Bind(
                (value, newValue) =>
            {
                Block.FancyGraphics = newValue;
            });

            Block.FancyGraphics = options.AlexOptions.VideoOptions.FancyGraphics.Value;

            options.AlexOptions.VideoOptions.UseVsync.Bind((value, newValue) => { SetVSync(newValue); });

            if (options.AlexOptions.VideoOptions.UseVsync.Value)
            {
                SetVSync(true);
            }

            options.AlexOptions.VideoOptions.Fullscreen.Bind((value, newValue) => { SetFullscreen(newValue); });

            if (options.AlexOptions.VideoOptions.Fullscreen.Value)
            {
                SetFullscreen(true);
            }

            options.AlexOptions.VideoOptions.LimitFramerate.Bind(
                (value, newValue) =>
            {
                SetFrameRateLimiter(newValue, options.AlexOptions.VideoOptions.MaxFramerate.Value);
            });

            options.AlexOptions.VideoOptions.MaxFramerate.Bind(
                (value, newValue) =>
            {
                SetFrameRateLimiter(options.AlexOptions.VideoOptions.LimitFramerate.Value, newValue);
            });

            if (options.AlexOptions.VideoOptions.LimitFramerate.Value)
            {
                SetFrameRateLimiter(true, options.AlexOptions.VideoOptions.MaxFramerate.Value);
            }

            options.AlexOptions.VideoOptions.Antialiasing.Bind(
                (value, newValue) => { SetAntiAliasing(newValue > 0, newValue); });

            options.AlexOptions.MiscelaneousOptions.Language.Bind(
                (value, newValue) => { GuiRenderer.SetLanguage(newValue); });

            if (!GuiRenderer.SetLanguage(options.AlexOptions.MiscelaneousOptions.Language))
            {
                GuiRenderer.SetLanguage(CultureInfo.InstalledUICulture.Name);
            }

            options.AlexOptions.VideoOptions.SmoothLighting.Bind(
                (value, newValue) => { ResourcePackBlockModel.SmoothLighting = newValue; });

            ResourcePackBlockModel.SmoothLighting = options.AlexOptions.VideoOptions.SmoothLighting.Value;

            SetAntiAliasing(
                options.AlexOptions.VideoOptions.Antialiasing > 0, options.AlexOptions.VideoOptions.Antialiasing.Value);

            GuiDebugHelper = new GuiDebugHelper(GuiManager);

            OnCharacterInput += GuiManager.FocusManager.OnTextInput;

            GameStateManager = new GameStateManager(GraphicsDevice, _spriteBatch, GuiManager);

            var splash = new SplashScreen();
            GameStateManager.AddState("splash", splash);
            GameStateManager.SetActiveState("splash");

            WindowSize = this.Window.ClientBounds.Size;

            //	Log.Info($"Initializing Alex...");
            ThreadPool.QueueUserWorkItem(
                (o) =>
            {
                try
                {
                    InitializeGame(splash);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, $"Could not initialize! {ex}");
                }
                finally
                {
                    loadingStopwatch.Stop();
                    Log.Info($"Startup time: {loadingStopwatch.Elapsed}");
                }
            });
        }