コード例 #1
0
ファイル: Program.cs プロジェクト: Albeoris/Septerra
        private static Int32 RunGame(ProgramArguments arguments)
        {
            try
            {
                var spec = new RunGameSpecPreprocessor();

                if (arguments.TryGetNext(out String gameDirectoryPath))
                {
                    spec.GameDirectoryPath = gameDirectoryPath;

                    StringBuilder sb = new StringBuilder();
                    while (arguments.TryGetNext(out var arg))
                    {
                        sb.Append(arg);
                        sb.Append(' ');
                    }

                    if (sb.Length != 0)
                    {
                        sb.Length--;
                    }

                    spec.GameArguments = sb.ToString();
                }
                else
                {
                    spec.GameDirectory = GameDirectoryProvider.GetDefault();
                }

                spec.Preprocess();

                RunGameCoroutine coroutine = new RunGameCoroutine(spec);
                coroutine.Execute();

                return(0);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("----------------------------");
                Console.Error.WriteLine("Failed to run game.");
                Console.Error.WriteLine("----------------------------");
                Console.Error.WriteLine(ex);
                Console.Error.WriteLine("----------------------------");
                ShowRunHelp();
                Console.WriteLine();
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
                return(255);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Albeoris/Septerra
        private static Int32 Unpack(ProgramArguments arguments)
        {
            try
            {
                var spec = new UnpackGamePackagesSpecPreprocessor();
                if (arguments.TryGetNext(out String gameDirectoryPath))
                {
                    spec.GameDirectoryPath = gameDirectoryPath;
                }
                else
                {
                    spec.GameDirectory = GameDirectoryProvider.GetDefault();
                }

                if (arguments.TryGetNext(out String outputPath))
                {
                    spec.OutputDirectory = outputPath;
                }
                else
                {
                    spec.OutputDirectory = $".\\Data";
                }

                while (arguments.TryGetNext(out String arg))
                {
                    switch (arg)
                    {
                    case "-convert":
                        spec.Convert = true;
                        break;

                    case "-rename":
                        spec.Rename = true;
                        break;

                    default:
                        throw new ArgumentException(arg, nameof(arguments));
                    }
                }

                spec.Preprocess();

                UnpackGamePackagesCoroutine coroutine = new UnpackGamePackagesCoroutine(spec);
                coroutine.Execute();

                return(0);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("----------------------------");
                Console.Error.WriteLine("Failed to unpack game data.");
                Console.Error.WriteLine("----------------------------");
                Console.Error.WriteLine(ex);
                Console.Error.WriteLine("----------------------------");
                ShowUnpackHelp();
                Console.WriteLine();
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
                return(255);
            }
        }