public GameMasterTemplate(string filePath) { FileName = Path.GetFileNameWithoutExtension(filePath); string rawFilePath = Path.Combine(Path.GetDirectoryName(filePath), FileName); HaveRawGameMaster = File.Exists(rawFilePath); GameMaster = GameMasterDecoder.GetGameMaster(rawFilePath); }
/// <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); }
/// <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); } }
/// <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"); }