예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Waiting for game...");
            while (!Utils.ConnectToGame())
            {
                ;
            }
            Console.Clear();
            Console.WriteLine("Black Ops 2 GameScript Compiler by dtx12.");

            using (var dialog = new FolderBrowserDialog())
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                foreach (var file in ParseAllFiles(dialog.SelectedPath))
                {
                    var    script         = new LoadScriptAsset();
                    byte[] compiledScript = null;
                    if (file.Contains(".txt"))
                    {
                        var grammar  = new GSCGrammar();
                        var parser   = new Parser(grammar);
                        var compiler = new ScriptCompiler(parser.Parse(File.ReadAllText(file)), file);
                        if (!compiler.Init())
                        {
                            return;
                        }
                        compiledScript = compiler.Compiled;
                    }
                    else if (file.Contains("Compiled"))
                    {
                        continue;
                    }
                    else if (file.Contains(".gsc"))
                    {
                        compiledScript = File.ReadAllBytes(file);
                    }
                    script.LoadScript(compiledScript, Path.GetFileName(file.Replace(".txt", ".gsc")));
                }
            }
            Console.WriteLine("All scripts loaded and compiled. Press any key to quit.");
            Console.ReadKey();
        }