public void Save(string file) { QuestLoader.mkDir(saveLocation()); // Write to disk using (BinaryWriter writer = new BinaryWriter(File.Open(saveLocation() + "/" + file, FileMode.Create))) { writer.Write(download.bytes); writer.Close(); } string section = file.Substring(0, file.Length - ".valkyrie".Length); int localVersion, remoteVersion; int.TryParse(localManifest.Get(section, "version"), out localVersion); int.TryParse(remoteManifest.Get(section, "version"), out remoteVersion); localManifest.Remove(section); localManifest.Add(section, remoteManifest.Get(section)); if (File.Exists(saveLocation() + "/manifest.ini")) { File.Delete(saveLocation() + "/manifest.ini"); } File.WriteAllText(saveLocation() + "/manifest.ini", localManifest.ToString()); Destroyer.Dialog(); DrawList(); }
public void SetQuestAvailability(string key, bool isAvailable) { // update list of local quest IniData localManifest = IniRead.ReadFromString(""); string saveLocation = ContentData.DownloadPath(); if (File.Exists(saveLocation + "/manifest.ini")) { localManifest = IniRead.ReadFromIni(saveLocation + "/manifest.ini"); } if (isAvailable) { IniData downloaded_quest = IniRead.ReadFromString(remote_quests_data[key].ToString()); localManifest.Remove(key); localManifest.Add(key, downloaded_quest.data["Quest"]); } else { if (localManifest.Get(key) != null) { localManifest.Remove(key); } // we need to delete /temp and reload list UnloadLocalQuests(); } if (File.Exists(saveLocation + "/manifest.ini")) { File.Delete(saveLocation + "/manifest.ini"); } File.WriteAllText(saveLocation + "/manifest.ini", localManifest.ToString()); // update status quest remote_quests_data[key].downloaded = isAvailable; remote_quests_data[key].update_available = false; }
/// <summary> /// Parse ini data into data structure /// </summary> /// <param name="lines">array of text lines</param> /// <param name="path">path from where lines came</param> /// <returns></returns> public static IniData ReadFromStringArray(string[] lines, string path) { // Create a dictionary for the first section Dictionary <string, string> entryData = new Dictionary <string, string>(); // Name for the current section string entryName = ""; // Create object to hold output IniData output = new IniData(); // Section headers have these chars removed char[] charsToTrim = { '[', ']' }; // Parse all lines foreach (string l in lines) { // Start of new section if (l.Length > 0 && l.Trim()[0] == '[') { // If not first section, add the last section of data if (entryName != "") { if (!output.Add(entryName, entryData)) { ValkyrieDebug.Log("Warning: duplicate section \"" + entryName + "\" in " + path + " will be ignored."); } } // create new data for new section entryData = new Dictionary <string, string>(); // Get name of new section entryName = l.Trim().Trim(charsToTrim); // Blank section names not allowed, but not fatal if (entryName.Equals("")) { ValkyrieDebug.Log("Warning: empty section in " + path + " will be ignored."); } } // If the line is not a comment (starts with ;) else if (l.Length > 0 && l.Trim()[0] != ';') { int equalsLocation = l.IndexOf('='); // Add data as entry with no value if (equalsLocation == -1) { entryData.Add(l.Trim(), ""); } // If there is an = add data as key and value else { string key = l.Substring(0, equalsLocation).Trim(); if (entryData.ContainsKey(key)) { ValkyrieDebug.Log("Warning: duplicate \"" + key + "\" data in section \"" + entryName + "\" in " + path + " will be ignored."); } else { string value = l.Substring(equalsLocation + 1).Trim().Trim('\"'); //string translatedValue = LocalizationRead.FFGLookup(value); entryData.Add(key, value); } } // This won't go anywhere if we don't have a section if (entryName.Equals("")) { ValkyrieDebug.Log("Warning: data without section in " + path + " will be ignored."); } } } // Add the last section if (entryName != "") { if (!output.Add(entryName, entryData)) { ValkyrieDebug.Log("Warning: duplicate section \"" + entryName + "\" in " + path + " will be ignored."); } } return(output); }
public void AddPack(string gameType, string pack, string language = "") { data.Add(gameType + "Packs", pack, language); LocalizationRead.SetGroupTranslationLanguage(pack, language); Save(); }