Beispiel #1
0
        public CacheForm(DirectoryInfo cacheDirectory)
        {
            InitializeComponent();

            if (cacheDirectory.GetFiles("*.dat").Length == 0) // gen3
            {
                var smf = new SelectMapForm(cacheDirectory);

                if (smf.ShowDialog() != DialogResult.OK)
                {
                    Close();
                }

                Text  = smf.SelectedFile.FullName;
                Cache = GameCache.Open(smf.SelectedFile);
            }

            else // HO
            {
                Text  = cacheDirectory.FullName + "\\tags.dat";
                Cache = GameCache.Open(new FileInfo(Text));
            }

            var docFile = new FileInfo(Path.Combine(Application.StartupPath, "BlamCore.xml"));

            if (Documentation.ChildNodes.Count == 0 && docFile.Exists)
            {
                Documentation.Load(docFile.FullName);
            }
        }
Beispiel #2
0
        public override object Execute(List <string> args)
        {
            if (args.Count < 1)
            {
                return(false);
            }

            while (args.Count > 1)
            {
                switch (args[0].ToLower())
                {
                case "memory":
                    break;

                default:
                    throw new FormatException(args[0]);
                }

                args.RemoveAt(0);
            }

            var fileName = new FileInfo(args[0]);

            if (!fileName.Exists)
            {
                Console.WriteLine($"Cache {fileName.FullName} does not exist");
                return(true);
            }

            Console.Write("Loading cache...");

            GameCache blamCache = GameCache.Open(fileName);

            ContextStack.Push(PortingContextFactory.Create(ContextStack, Cache, blamCache));

            Console.WriteLine("done.");

            return(true);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.GetCultureInfo("en-US");
            ConsoleHistory.Initialize();

            // If there are extra arguments, use them to automatically execute a command
            List <string> autoexecCommand = null;

            if (args.Length > 1)
            {
                autoexecCommand = args.Skip(1).ToList();
            }

            if (autoexecCommand == null)
            {
                Console.WriteLine($"Tag Tool [{Assembly.GetExecutingAssembly().GetName().Version}]");
                Console.WriteLine();
                Console.WriteLine("Please report any bugs and/or feature requests at");
                Console.WriteLine("<https://github.com/TheGuardians-CI/TagTool/issues>.");
                Console.WriteLine();
            }

start:
            // Get the file path from the first argument
            // If no argument is given, load tags.dat
            // legacy from older cache system where only HO caches could be loaded
            var fileInfo = new FileInfo((args.Length > 0) ? args[0] : "tags.dat");

            while (!fileInfo.Exists)
            {
                Console.WriteLine("Enter the path to a Halo cache file (.map or tags.dat)':");
                Console.Write("> ");
                var tagCacheFile = Console.ReadLine();

                switch (tagCacheFile.ToLower())
                {
                case "restart":
                    Console.WriteLine();
                    goto start;

                case "exit":
                case "quit":
                    Console.WriteLine();
                    goto end;
                }

                //sometimes drag&drop files have quotes placed around them, remove the quotes
                tagCacheFile = tagCacheFile.Replace("\"", "").Replace("\'", "");

                if (File.Exists(tagCacheFile))
                {
                    fileInfo = new FileInfo(tagCacheFile);
                }
                else
                {
                    Console.WriteLine("Invalid path to 'tags.dat'!");
                }

                Console.WriteLine();
            }

            GameCache gameCache = null;

#if !DEBUG
            try
            {
#endif
            gameCache = GameCache.Open(fileInfo);
#if !DEBUG
        }
        catch (Exception e)
        {
            Console.WriteLine("ERROR: " + e.Message);
            Console.WriteLine("STACKTRACE: " + Environment.NewLine + e.StackTrace);
            ConsoleHistory.Dump("hott_*_init.log");
            return;
        }
#endif

            // Create command context
            var contextStack = new CommandContextStack();
            var tagsContext  = TagCacheContextFactory.Create(contextStack, gameCache);
            contextStack.Push(tagsContext);

            var commandRunner = new CommandRunner(contextStack);

            // If autoexecuting a command, just run it and return
            if (autoexecCommand != null)
            {
                commandRunner.RunCommand(string.Join(" ", autoexecCommand), false);
                goto end;
            }

            Console.WriteLine("Enter \"help\" to list available commands. Enter \"exit\" to quit.");
            while (!commandRunner.EOF)
            {
                // Read and parse a command
                Console.WriteLine();
                Console.Write("{0}> ", contextStack.GetPath());
                Console.Title = $"TagTool {contextStack.GetPath()}>";

                var line = Console.ReadLine();
                if (line == "restart")
                {
                    goto start;
                }
                commandRunner.RunCommand(line, false);
            }

            end : return;
        }