Initialize() 공개 메소드

public Initialize ( ISoundLoader loaders, IReadOnlyFileSystem fileSystem ) : void
loaders ISoundLoader
fileSystem IReadOnlyFileSystem
리턴 void
예제 #1
0
파일: Game.cs 프로젝트: JamesDunne/OpenRA
        public static void InitializeWithMods(string[] mods)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => {};
            AddChatLine            = (a, b, c) => {};
            ConnectionStateChanged = om => {};
            BeforeGameStart        = () => {};
            Ui.ResetAll();

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

            // Discard any invalid mods
            var mm = mods.Where(m => Mod.AllMods.ContainsKey(m)).ToArray();

            Console.WriteLine("Loading mods: {0}", mm.JoinWith(","));
            Settings.Game.Mods = mm;
            Settings.Save();

            Sound.StopMusic();
            Sound.StopVideo();
            Sound.Initialize();

            modData = new ModData(mm);
            Renderer.InitializeFonts(modData.Manifest);
            modData.LoadInitialAssets();


            PerfHistory.items["render"].hasNormalTick         = false;
            PerfHistory.items["batches"].hasNormalTick        = false;
            PerfHistory.items["render_widgets"].hasNormalTick = false;
            PerfHistory.items["render_flip"].hasNormalTick    = false;

            JoinLocal();
            viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);

            modData.LoadScreen.StartGame();
        }
예제 #2
0
        public static void InitializeMod(string mod, Arguments args)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => { };
            ConnectionStateChanged = om => { };
            BeforeGameStart        = () => { };
            OnRemoteDirectConnect  = (a, b) => { };
            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.Dispose();
            }
            ModData = null;

            // Fall back to default if the mod doesn't exist
            if (!ModMetadata.AllMods.ContainsKey(mod))
            {
                mod = new GameSettings().Mod;
            }

            Console.WriteLine("Loading mod: {0}", mod);
            Settings.Game.Mod = mod;

            Sound.StopMusic();
            Sound.StopVideo();
            Sound.Initialize();

            ModData = new ModData(mod, !Settings.Server.Dedicated);
            ModData.InitializeLoaders();
            if (!Settings.Server.Dedicated)
            {
                Renderer.InitializeFonts(ModData.Manifest);
            }

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

            if (Settings.Graphics.HardwareCursors)
            {
                try
                {
                    Cursor = new HardwareCursor(ModData.CursorProvider);
                }
                catch (Exception e)
                {
                    Log.Write("debug", "Failed to initialize hardware cursors. Falling back to software cursors.");
                    Log.Write("debug", "Error was: " + e.Message);

                    Console.WriteLine("Failed to initialize hardware cursors. Falling back to software cursors.");
                    Console.WriteLine("Error was: " + e.Message);

                    Cursor = new SoftwareCursor(ModData.CursorProvider);
                    Settings.Graphics.HardwareCursors = false;
                }
            }
            else
            {
                Cursor = new SoftwareCursor(ModData.CursorProvider);
            }

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

            JoinLocal();

            if (Settings.Server.Dedicated)
            {
                while (true)
                {
                    Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
                    Settings.Save();
                    CreateServer(new ServerSettings(Settings.Server));
                    while (true)
                    {
                        Thread.Sleep(100);

                        if (server.State == Server.ServerState.GameStarted && server.Conns.Count < 1)
                        {
                            Console.WriteLine("No one is playing, shutting down...");
                            server.Shutdown();
                            break;
                        }
                    }

                    if (Settings.Server.DedicatedLoop)
                    {
                        Console.WriteLine("Starting a new server instance...");
                        ModData.MapCache.LoadMaps();
                        continue;
                    }

                    break;
                }

                Environment.Exit(0);
            }
            else
            {
                ModData.LoadScreen.StartGame(args);
            }
        }
예제 #3
0
        public static void InitializeWithMods(string[] mods)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => {};
            AddChatLine            = (a, b, c) => {};
            ConnectionStateChanged = om => {};
            BeforeGameStart        = () => {};
            Ui.ResetAll();

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

            // Discard any invalid mods, set RA as default
            var mm = mods.Where(m => Mod.AllMods.ContainsKey(m)).ToArray();

            if (mm.Length == 0)
            {
                mm = new[] { "ra" }
            }
            ;
            Console.WriteLine("Loading mods: {0}", mm.JoinWith(","));
            Settings.Game.Mods = mm;

            Sound.StopMusic();
            Sound.StopVideo();
            Sound.Initialize();

            modData = new ModData(mm);
            Renderer.InitializeFonts(modData.Manifest);
            modData.LoadInitialAssets(true);


            PerfHistory.items["render"].hasNormalTick         = false;
            PerfHistory.items["batches"].hasNormalTick        = false;
            PerfHistory.items["render_widgets"].hasNormalTick = false;
            PerfHistory.items["render_flip"].hasNormalTick    = false;

            JoinLocal();
            viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);

            if (Game.Settings.Server.Dedicated)
            {
                while (true)
                {
                    Game.Settings.Server.Map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
                    Game.Settings.Save();
                    Game.CreateServer(new ServerSettings(Game.Settings.Server));
                    while (true)
                    {
                        System.Threading.Thread.Sleep(100);

                        if ((server.State == Server.ServerState.GameStarted) &&
                            (server.conns.Count <= 1))
                        {
                            Console.WriteLine("No one is playing, shutting down...");
                            server.Shutdown();
                            break;
                        }
                    }
                    if (Game.Settings.Server.DedicatedLoop)
                    {
                        Console.WriteLine("Starting a new server instance...");
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
                System.Environment.Exit(0);
            }
            else
            {
                modData.LoadScreen.StartGame();
                Settings.Save();
            }
        }
예제 #4
0
파일: Game.cs 프로젝트: voidAsterisk/OpenRA
        public static void InitializeMod(string mod, Arguments args)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => { };
            AddChatLine            = (a, b, c) => { };
            ConnectionStateChanged = om => { };
            BeforeGameStart        = () => { };
            Ui.ResetAll();

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

            // Fall back to default if the mod doesn't exist
            if (!ModMetadata.AllMods.ContainsKey(mod))
            {
                mod = new GameSettings().Mod;
            }

            Console.WriteLine("Loading mod: {0}", mod);
            Settings.Game.Mod = mod;

            Sound.StopMusic();
            Sound.StopVideo();
            Sound.Initialize();

            modData = new ModData(mod);
            Renderer.InitializeFonts(modData.Manifest);
            modData.InitializeLoaders();
            using (new PerfTimer("LoadMaps"))
                modData.MapCache.LoadMaps();

            PerfHistory.items["render"].hasNormalTick         = false;
            PerfHistory.items["batches"].hasNormalTick        = false;
            PerfHistory.items["render_widgets"].hasNormalTick = false;
            PerfHistory.items["render_flip"].hasNormalTick    = false;

            JoinLocal();

            if (Settings.Server.Dedicated)
            {
                while (true)
                {
                    Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
                    Settings.Save();
                    CreateServer(new ServerSettings(Settings.Server));
                    while (true)
                    {
                        System.Threading.Thread.Sleep(100);

                        if (server.State == Server.ServerState.GameStarted && server.Conns.Count < 1)
                        {
                            Console.WriteLine("No one is playing, shutting down...");
                            server.Shutdown();
                            break;
                        }
                    }

                    if (Settings.Server.DedicatedLoop)
                    {
                        Console.WriteLine("Starting a new server instance...");
                        modData.MapCache.LoadMaps();
                        continue;
                    }

                    break;
                }

                Environment.Exit(0);
            }
            else
            {
                var window = args != null?args.GetValue("Launch.Window", null) : null;

                if (!string.IsNullOrEmpty(window))
                {
                    var installData = modData.Manifest.ContentInstaller;
                    if (installData.InstallerBackgroundWidget != null)
                    {
                        Ui.LoadWidget(installData.InstallerBackgroundWidget, Ui.Root, new WidgetArgs());
                    }

                    Widgets.Ui.OpenWindow(window, new WidgetArgs());
                }
                else
                {
                    modData.LoadScreen.StartGame();
                    Settings.Save();
                    var replay = args != null?args.GetValue("Launch.Replay", null) : null;

                    if (!string.IsNullOrEmpty(replay))
                    {
                        Game.JoinReplay(replay);
                    }
                }
            }
        }
예제 #5
0
파일: Game.cs 프로젝트: zhangolove/OpenRA
        public static void InitializeMod(string mod, Arguments args)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => { };
            ConnectionStateChanged = om => { };
            BeforeGameStart        = () => { };
            OnRemoteDirectConnect  = (a, b) => { };
            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.Dispose();
            }
            ModData = null;

            // Fall back to default if the mod doesn't exist
            if (!ModMetadata.AllMods.ContainsKey(mod))
            {
                mod = new GameSettings().Mod;
            }

            Console.WriteLine("Loading mod: {0}", mod);
            Settings.Game.Mod = mod;

            Sound.StopVideo();
            Sound.Initialize();

            ModData = new ModData(mod, !Settings.Server.Dedicated);

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

            if (Settings.Server.Dedicated)
            {
                RunDedicatedServer();
                Environment.Exit(0);
            }

            var installData           = ModData.Manifest.Get <ContentInstaller>();
            var isModContentInstalled = installData.TestFiles.All(f => File.Exists(Platform.ResolvePath(f)));

            // Mod assets are missing!
            if (!isModContentInstalled)
            {
                InitializeMod("modchooser", new Arguments());
                return;
            }

            ModData.MountFiles();
            ModData.InitializeLoaders();
            Renderer.InitializeFonts(ModData.Manifest);

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

            if (Settings.Graphics.HardwareCursors)
            {
                try
                {
                    Cursor = new HardwareCursor(ModData.CursorProvider);
                }
                catch (Exception e)
                {
                    Log.Write("debug", "Failed to initialize hardware cursors. Falling back to software cursors.");
                    Log.Write("debug", "Error was: " + e.Message);

                    Console.WriteLine("Failed to initialize hardware cursors. Falling back to software cursors.");
                    Console.WriteLine("Error was: " + e.Message);

                    Cursor = new SoftwareCursor(ModData.CursorProvider);
                }
            }
            else
            {
                Cursor = new SoftwareCursor(ModData.CursorProvider);
            }

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

            JoinLocal();

            ModData.LoadScreen.StartGame(args);
        }
예제 #6
0
파일: Game.cs 프로젝트: xbayrockx/OpenRA
        public static void InitializeWithMod(string mod)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => { };
            AddChatLine            = (a, b, c) => { };
            ConnectionStateChanged = om => { };
            BeforeGameStart        = () => { };
            Ui.ResetAll();

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

            // Fall back to RA if the mod doesn't exist
            if (!Mod.AllMods.ContainsKey(mod))
            {
                mod = "ra";
            }

            Console.WriteLine("Loading mod: {0}", mod);
            Settings.Game.Mod = mod;

            Sound.StopMusic();
            Sound.StopVideo();
            Sound.Initialize();

            modData = new ModData(mod);
            Renderer.InitializeFonts(modData.Manifest);
            modData.InitializeLoaders();

            PerfHistory.items["render"].hasNormalTick         = false;
            PerfHistory.items["batches"].hasNormalTick        = false;
            PerfHistory.items["render_widgets"].hasNormalTick = false;
            PerfHistory.items["render_flip"].hasNormalTick    = false;

            JoinLocal();

            if (Settings.Server.Dedicated)
            {
                while (true)
                {
                    Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
                    Settings.Save();
                    CreateServer(new ServerSettings(Settings.Server));
                    while (true)
                    {
                        System.Threading.Thread.Sleep(100);

                        if (server.State == Server.ServerState.GameStarted && server.Conns.Count <= 1)
                        {
                            Console.WriteLine("No one is playing, shutting down...");
                            server.Shutdown();
                            break;
                        }
                    }

                    if (Settings.Server.DedicatedLoop)
                    {
                        Console.WriteLine("Starting a new server instance...");
                        continue;
                    }

                    break;
                }

                Environment.Exit(0);
            }
            else
            {
                modData.LoadScreen.StartGame();
                Settings.Save();
            }
        }