Ejemplo n.º 1
0
        public GameMasterTemplate(string filePath)
        {
            FileName = Path.GetFileNameWithoutExtension(filePath);
            string rawFilePath = Path.Combine(Path.GetDirectoryName(filePath), FileName);

            HaveRawGameMaster = File.Exists(rawFilePath);
            GameMaster        = GameMasterDecoder.GetGameMaster(rawFilePath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes the the GameMaster object into a .json file.
        /// </summary>
        /// <param name="filePathJson"></param>
        internal static void WriteGameMasterJson(GameMaster gameMaster, string filePathJson)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                Formatting = Formatting.Indented,
            };

            using (StreamWriter writer = new StreamWriter(filePathJson))
                writer.Write(JsonConvert.SerializeObject(gameMaster, settings));

            GameMasterTimestampUtils.FixGameMasterFileTime(filePathJson);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Static method to load a GAME_MASTER file.
        /// </summary>
        /// <param name="filePathGameMaster">Path to the GAME_MASTER file.</param>
        /// <returns></returns>
        /// <remarks>
        /// If a .json exists, it will be loaded.
        /// If not, the GAME_MASTER file will be loaded and the .json will be created.
        /// </remarks>
        public static GameMaster GetGameMaster(string filePathGameMaster)
        {
            string filePathJson = filePathGameMaster + ".json";

            if (File.Exists(filePathJson))
            {
                return(ReadGameMasterJson(filePathJson));
            }
            else
            {
                GameMaster gameMaster = ReadGameMaster(filePathGameMaster);
                if (gameMaster != null)
                {
                    GameMasterTimestampUtils.FixGameMasterFileTime(filePathGameMaster);
                    WriteGameMasterJson(gameMaster, filePathJson);
                }

                return(gameMaster);
            }
        }
Ejemplo n.º 4
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");
        }