示例#1
0
        /// <summary>
        /// Writes the the current GameMaster object into a .json file.
        /// </summary>
        /// <param name="filePathJson"></param>
        internal static void WriteGameMasterJson(string filePathGameMaster)
        {
            GameMaster gameMaster = GameMasterDecoder.ReadGameMaster(filePathGameMaster);

            WriteGameMasterJson(gameMaster, filePathGameMaster + ".json");
        }
示例#2
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Count() < 1 || args[0].Contains("?"))
                {
                    WriteHelp();
                    return;
                }

                int decoded = 0;
                for (int arg = 0; arg < args.Length; arg++)
                {
                    bool createOnly = string.Equals(args[arg], "-c") || string.Equals(args[arg], "-create");
                    if (createOnly)
                    {
                        arg++;
                        if (arg >= args.Length)
                        {
                            break;
                        }
                    }

                    string folder;
                    string filePattern;
                    int    pos = args[arg].LastIndexOf('\\');
                    if (pos == -1)
                    {
                        folder      = ".";
                        filePattern = args[arg];
                    }
                    else
                    {
                        folder      = args[arg].Substring(0, pos);
                        filePattern = args[arg].Substring(pos + 1);
                    }

                    if (!Directory.Exists(folder))
                    {
                        ConsoleOutput.OutputError("ERROR: Folder does not exist: \"{0}\"", folder);
                        continue;
                    }

                    GameMasterTimestampUtils.Init(folder);

                    foreach (var filePath in Directory.EnumerateFiles(folder, filePattern))
#if true
                    { if (Path.GetExtension(filePath).Length == 0 && (!createOnly || !File.Exists(filePath + ".json")))
                      {
                          Console.Out.WriteLine("Decoding \"" + filePath + "\"");
                          GameMasterDecoder.WriteGameMasterJson(filePath);
                          decoded++;
                      }
                    }
#else
                    {   // This code is to reset the timestamps of the files
                        try
                        {
                            GameMasterTimestampUtils.FixGameMasterFileTime(filePath);
                        }
                        catch (Exception) { }
                    }
#endif
                }

                ConsoleOutput.OutputSuccess($"Finished. {decoded} files decoded.");
            }
            catch (Exception ex)
            {
                ConsoleOutput.OutputException(ex, "********** ERROR!!! **********");
            }
        }