static void LoadLookupFile(string fileName) { // Extract name var lookupname = Path.GetFileNameWithoutExtension(fileName).ToLower(); // Create new list DataLookupList dll = new DataLookupList(); // Add it LookupLists.Add(lookupname, dll); // Load file List <string> sl = File.ReadAllLines(fileName).ToList(); // Parse File foreach (string line in sl) { string[] fields = line.Split(';'); if (fields.Length > 1) { if (TryFieldParse(fields[0], out UInt64 newID)) { DataLookupEntry dle = new DataLookupEntry(); dle.ID = newID; dle.Val = fields[1]; if (fields.Length > 2) { dle.Extra = fields[2]; } dll.data.Add(newID, dle); } } } }
static bool LoadLookupFile(string fileName) { // Extract name var lookupname = Path.GetFileNameWithoutExtension(fileName).ToLower(); // Remove a old list if it already exists if (LookupLists.TryGetValue(lookupname, out _)) { LookupLists.Remove(lookupname); } // Create new list DataLookupList dll = new DataLookupList(); // Add it LookupLists.Add(lookupname, dll); // Load file List <string> sl = File.ReadAllLines(fileName).ToList(); // Parse File var linenumber = 0; foreach (string line in sl) { linenumber++; try { string[] fields = line.Split(';'); if (fields.Length > 1) { if (TryFieldParse(fields[0], out int newID)) { DataLookupEntry dle = new DataLookupEntry(); dle.ID = (UInt64)newID; dle.Val = fields[1]; if (fields.Length > 2) { dle.Extra = fields[2]; } dll.data.Add((UInt64)newID, dle); // for autocomplete AllValues.Add(dle.Val); } } } catch (Exception x) { AllLoadErrors += string.Format("\n\r\n\rException loading {0} at line {1} :\n\r{2}\r\n=> {3}", fileName, linenumber, x.Message, line); return(false); } } return(true); }
public static void RegisterCustomLookup(string customListName, UInt64 customID, string customValue) { customListName = customListName.ToLower(); if (customListName == "@math") { return; } if (!customListName.StartsWith("@")) { customListName = "@" + customListName; } DataLookupList list = null; foreach (var ll in LookupLists) { if (ll.Key.ToLower() == customListName) { list = ll.Value; break; } } if (list == null) { list = new DataLookupList(); LookupLists.Add(customListName, list); } foreach (var li in list.data) { // If a value is already in here, overwrite it if (li.Key == customID) { var listv = li.Value; // Special case, don't update if this is a "null string" parsed if ((customValue != "NULL") && (listv.Val != customValue)) { listv.Val = customValue; } listv.Extra = string.Empty; return; } } var newlistv = new DataLookupEntry(); newlistv.ID = customID; newlistv.Val = customValue; newlistv.Extra = string.Empty; list.data.Add(customID, newlistv); AllValues.Add(customValue); }
public void AddValuesFromMobList(ref Dictionary <uint, FFXI_MobListEntry> mobList) { foreach (var MLE in mobList) { if (data.TryGetValue(MLE.Key, out _)) { continue; } DataLookupEntry DLE = new DataLookupEntry(); DLE.ID = MLE.Value.Id; DLE.Val = MLE.Value.Name; DLE.Extra = MLE.Value.ExpectedZoneId.ToString(); data.Add(DLE.ID, DLE); } }
public void UpdateData() { if (items.Count <= 0) { return; } data.Clear(); foreach (var i in items) { DataLookupEntry dle = new DataLookupEntry(); dle.ID = i.Value.Id; dle.Val = i.Value.Name; dle.Extra = i.Value.Description; data.Add(dle.ID, dle); } }
public void UpdateData() { if (dialogsCache.Count <= 0) { return; } data.Clear(); foreach (var i in dialogsCache) { DataLookupEntry dle = new DataLookupEntry(); dle.ID = i.Value.Id; dle.Val = i.Value.Text; dle.Extra = string.Empty; data.Add(dle.ID, dle); } }