protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (VariableManager != null)
                {
                    VariableManager.Dispose();
                }
                if (CursorManager != null)
                {
                    CursorManager.Dispose();
                }
            }

            CursorManager   = null;
            VariableManager = null;
            base.Dispose(disposing);
        }
예제 #2
0
        public static void InitializeMod(string mod, Arguments args)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => { };
            ConnectionStateChanged = om => { };
            BeforeGameStart        = () => { };
            OnRemoteDirectConnect  = endpoint => { };
            delayedActions         = new ActionQueue();

            Ui.ResetAll();

            worldRenderer?.Dispose();
            worldRenderer = null;
            server?.Shutdown();
            OrderManager?.Dispose();

            if (ModData != null)
            {
                ModData.ModFiles.UnmountAll();
                ModData.Dispose();
            }

            ModData = null;

            if (mod == null)
            {
                throw new InvalidOperationException("Game.Mod argument missing.");
            }

            if (!Mods.ContainsKey(mod))
            {
                throw new InvalidOperationException($"Unknown or invalid mod '{mod}'.");
            }

            Console.WriteLine("Loading mod: {0}", mod);

            Sound.StopVideo();

            ModData = new ModData(Mods[mod], Mods, true);

            LocalPlayerProfile = new LocalPlayerProfile(Path.Combine(Platform.SupportDir, Settings.Game.AuthProfile), ModData.Manifest.Get <PlayerDatabase>());

            if (!ModData.LoadScreen.BeforeLoad())
            {
                return;
            }

            ModData.InitializeLoaders(ModData.DefaultFileSystem);
            Renderer.InitializeFonts(ModData);

            using (new PerfTimer("LoadMaps"))
                ModData.MapCache.LoadMaps();

            var grid = ModData.Manifest.Contains <MapGrid>() ? ModData.Manifest.Get <MapGrid>() : null;

            Renderer.InitializeDepthBuffer(grid);

            Cursor?.Dispose();

            Cursor = new CursorManager(ModData.CursorProvider);

            PerfHistory.Items["render"].HasNormalTick           = false;
            PerfHistory.Items["batches"].HasNormalTick          = false;
            PerfHistory.Items["render_world"].HasNormalTick     = false;
            PerfHistory.Items["render_widgets"].HasNormalTick   = false;
            PerfHistory.Items["render_flip"].HasNormalTick      = false;
            PerfHistory.Items["terrain_lighting"].HasNormalTick = false;

            JoinLocal();

            ChromeMetrics.TryGet("ChatMessageColor", out chatMessageColor);
            ChromeMetrics.TryGet("SystemMessageColor", out systemMessageColor);
            if (!ChromeMetrics.TryGet("SystemMessageLabel", out systemMessageLabel))
            {
                systemMessageLabel = "Battlefield Control";
            }

            ModData.LoadScreen.StartGame(args);
        }
예제 #3
0
파일: Game.cs 프로젝트: szlatkow/OpenRA
        public static void InitializeMod(string mod, Arguments args)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => { };
            ConnectionStateChanged = om => { };
            BeforeGameStart        = () => { };
            OnRemoteDirectConnect  = endpoint => { };
            delayedActions         = new ActionQueue();

            Ui.ResetAll();

            if (worldRenderer != null)
            {
                worldRenderer.Dispose();
            }
            worldRenderer = null;
            if (server != null)
            {
                server.Shutdown();
            }
            if (OrderManager != null)
            {
                OrderManager.Dispose();
            }

            if (ModData != null)
            {
                ModData.ModFiles.UnmountAll();
                ModData.Dispose();
            }

            ModData = null;

            if (mod == null)
            {
                throw new InvalidOperationException("Game.Mod argument missing.");
            }

            if (!Mods.ContainsKey(mod))
            {
                throw new InvalidOperationException("Unknown or invalid mod '{0}'.".F(mod));
            }

            Console.WriteLine("Loading mod: {0}", mod);

            Sound.StopVideo();

            ModData = new ModData(Mods[mod], Mods, true);

            LocalPlayerProfile = new LocalPlayerProfile(Platform.ResolvePath(Path.Combine("^", Settings.Game.AuthProfile)), ModData.Manifest.Get <PlayerDatabase>());

            if (!ModData.LoadScreen.BeforeLoad())
            {
                return;
            }

            using (new PerfTimer("LoadMaps"))
                ModData.MapCache.LoadMaps();

            ModData.InitializeLoaders(ModData.DefaultFileSystem);
            Renderer.InitializeFonts(ModData);

            var grid = ModData.Manifest.Contains <MapGrid>() ? ModData.Manifest.Get <MapGrid>() : null;

            Renderer.InitializeDepthBuffer(grid);

            if (Cursor != null)
            {
                Cursor.Dispose();
            }

            Cursor = new CursorManager(ModData.CursorProvider);

            PerfHistory.Items["render"].HasNormalTick         = false;
            PerfHistory.Items["batches"].HasNormalTick        = false;
            PerfHistory.Items["render_world"].HasNormalTick   = false;
            PerfHistory.Items["render_widgets"].HasNormalTick = false;
            PerfHistory.Items["render_flip"].HasNormalTick    = false;

            JoinLocal();

            try
            {
                if (discoverNat != null)
                {
                    discoverNat.Wait();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("NAT discovery failed: {0}", e.Message);
                Log.Write("nat", e.ToString());
            }

            ChromeMetrics.TryGet("ChatMessageColor", out chatMessageColor);
            ChromeMetrics.TryGet("SystemMessageColor", out systemMessageColor);

            ModData.LoadScreen.StartGame(args);
        }