예제 #1
0
        static void Play(string replayPath)
        {
            while (true)
            {
                var process = ClientProcessFinder.Find();
                if (process == null)
                {
                    break;
                }

                Console.WriteLine("The client has been already running. Please close it first.");
                Console.WriteLine("クライアントプロセスが既に起動しています。先に終了してください。");
                Thread.Sleep(2000);
                continue;
            }

            var(replayArgs, error) = ReplayArgsParser.Parse(File.ReadAllText(ReplayArgsPath));
            switch (error)
            {
            case ReplayArgsParserError.LackOfArguments:
            {
                Console.WriteLine("Replay arguments doesn't have enough length.");
                Console.WriteLine("リプレイの引数の数が足りませんでした。");
                Finish();
                break;
            }

            case ReplayArgsParserError.FirstArgumentIsNotExe:
            {
                Console.WriteLine("First argument should be a path to the client exe but isn't.");
                Console.WriteLine("リプレイの最初の引数はクライアントへのパスでないといけません。");
                Finish();
                break;
            }

            case ReplayArgsParserError.SecondArgumentIsNotRofl:
            {
                Console.WriteLine("Second argument should be a path to a rofl file but isn't.");
                Console.WriteLine("リプレイの2つ目の引数はリプレイファイル(rofl)へのパスでないといけません。");
                Finish();
                break;
            }

            case ReplayArgsParserError.None:
            {
                replayArgs.ReplayFile = new FileInfo(replayPath);
                ReplayPlayer.Play(replayArgs);
                break;
            }
            }
        }
예제 #2
0
        public static (ReplayArgs replayArgs, ReplayArgsFetcherError fetcherError, ReplayArgsParserError parserError) Fetch(Process clientProcess)
        {
            var replayArgsLine = clientProcess.GetCommandLine();

            if (replayArgsLine == null)
            {
                return(null, ReplayArgsFetcherError.CouldNotGetCommandLineArguments, ReplayArgsParserError.None);
            }

            var args = CommandLineParser.Parse(replayArgsLine);

            var(replayArgs, parserError) = ReplayArgsParser.Parse(args);
            return(replayArgs, ReplayArgsFetcherError.None, parserError);
        }