Exemple #1
0
        private static IEnumerable <GameInstallation> FindInstallations()
        {
            var locator = new RegistryInstallationLocator();

            return(SageGames.GetAll()
                   .SelectMany(locator.FindInstallations));
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            var    noShellMap = false;
            var    definition = GameDefinition.FromGame(SageGame.CncGenerals);
            string mapName    = null;

            ArgumentSyntax.Parse(args, syntax =>
            {
                syntax.DefineOption("noshellmap", ref noShellMap, false, "Disables loading the shell map, speeding up startup time.");

                string gameName    = null;
                var availableGames = string.Join(", ", GameDefinition.All.Select(def => def.Game.ToString()));

                syntax.DefineOption("game", ref gameName, false, $"Chooses which game to start. Valid options: {availableGames}");

                // If a game has been specified, make sure it's valid.
                if (gameName != null && !GameDefinition.TryGetByName(gameName, out definition))
                {
                    syntax.ReportError($"Unknown game: {gameName}");
                }

                syntax.DefineOption("map", ref mapName, false,
                                    "Immediately starts a new skirmish with default settings in the specified map. The map file must be specified with the full path.");
            });

            Platform.CurrentPlatform = new Sdl2Platform();
            Platform.CurrentPlatform.Start();

            // TODO: Support other locators.
            var locator = new RegistryInstallationLocator();

            var game = GameFactory.CreateGame(
                definition,
                locator,
                // TODO: Read game version from assembly metadata or .git folder
                // TODO: Set window icon.
                () => Platform.CurrentPlatform.CreateWindow("OpenSAGE (master)", 100, 100, 1024, 768));

            game.Configuration.LoadShellMap = !noShellMap;

            if (mapName == null)
            {
                game.ShowMainMenu();
            }
            else
            {
                game.StartGame(mapName, new EchoConnection(), new[] { "America", "GLA" }, 0);
            }

            while (game.IsRunning)
            {
                game.Tick();
            }

            Platform.CurrentPlatform.Stop();
        }
        public static IEnumerable <GameInstallation> FindInstallations()
        {
            IInstallationLocator locator;

            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                locator = new RegistryInstallationLocator();
            }
            else
            {
                locator = new EnvironmentInstallationLocator();
            }

            return(GameDefinition.All.SelectMany(locator.FindInstallations));
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            // TODO: Get this from a launch parameter.
            const SageGame sageGame = SageGame.CncGenerals;

            // TODO: Support other locators.
            var locator      = new RegistryInstallationLocator();
            var installation = locator.FindInstallations(sageGame).First();
            var fileSystem   = installation.CreateFileSystem();

            HostPlatform.Start();

            var game = new Game(
                HostPlatform.GraphicsDevice,
                HostPlatform.GraphicsDevice2D,
                fileSystem,
                sageGame);

            SetupInitialScene(game);

            var hostView = new GameView
            {
                Game = game,
                Dock = DockStyle.Fill
            };

            // TODO: Use something other than WinForms for cross-platform compatibility.
            var window = new Form
            {
                Size = new Size(1024, 768),
                // TODO: Read game version from assembly metadata or .git folder
                Text = "OpenSAGE (master)",
                Icon = GetIcon()
            };

            window.Controls.Add(hostView);
            window.Show();

            // TODO: This only works on Windows and DX11. Implement this for other platforms.
            RenderLoop.Run(hostView, game.Tick);

            HostPlatform.Stop();
        }
Exemple #5
0
        static GameTestDiscoverer()
        {
            var locator = new RegistryInstallationLocator();

            InstalledGames = SageGames.GetAll().Where(game => locator.FindInstallations(game).Any()).ToSet();
        }
Exemple #6
0
        static GameTestDiscoverer()
        {
            var locator = new RegistryInstallationLocator();

            InstalledGames = GameDefinition.All.Where(game => locator.FindInstallations(game).Any()).ToSet();
        }
        public static IEnumerable <GameInstallation> FindInstallations()
        {
            var locator = new RegistryInstallationLocator();

            return(GameDefinition.All.SelectMany(locator.FindInstallations));
        }