// TODO: async preload and cache icons? internal void ReloadViewList() { ListValues.Clear(); ListValues.AddRange( PluginList.Select(p => new CustomListTableData.CustomCellInfo( p.Plugin.Name, $"{p.Plugin.Author} <size=80%>{p.Plugin.Version}</size>", p.Icon, Enumerable.Empty <Sprite>() .AppendIf(p.Plugin.IsBare, Helpers.LibrarySprite) .AppendIf(p.State == PluginState.Disabled, Helpers.XSprite) .AppendIf(p.State == PluginState.Enabled && p.Plugin.RuntimeOptions == RuntimeOptions.DynamicInit, Helpers.OSprite) .AppendIf(p.State == PluginState.Ignored, Helpers.WarnSprite)))); customListTableData?.tableView?.ReloadData(); }
public bool Load(string fullPath) { if (!File.Exists(fullPath)) { return(false); } StringValues.Clear(); ListValues.Clear(); IsConfigLoaded = false; // YML Parser try { bool isNextLineList = false; string listName = ""; List <string> currentList = new List <string>(); string[] configLines = File.ReadAllLines(fullPath); for (int i = 0; i < configLines.Length; i++) { string line = configLines[i]; // even if in the middle of a list, still allow empty spaces if (line == string.Empty || line.TrimStart()[0] == '#') { continue; } // parse lists. cannot parse lists within a list... not yet atleast ;) if (isNextLineList) { string trimmedListItemStart = line.TrimStart(); if (trimmedListItemStart[0] == '-') { string listItem = trimmedListItemStart.After("-").TrimStart().TrimEnd(); currentList.Add(listItem); // last line if ((i + 1) == configLines.Length) { if (isNextLineList) { isNextLineList = false; ListValues.Add(listName, new List <string>(currentList)); listName = ""; currentList.Clear(); break; } } continue; } else { ListValues.Add(listName, new List <string>(currentList)); listName = ""; currentList.Clear(); isNextLineList = false; } } // parse fields. "string" and "bool" pairs are treaded the same when loading and saving // tho they can be parsed to "true" or "false" as a bool later on... see TryGetBoolean string trimmedStart = line.TrimStart(); string trimmedEnd = line.TrimEnd(); string fieldName = trimmedStart.Before(":"); string fieldValue = trimmedEnd.After(":").TrimStart(); if (fieldName.IsEmpty() || fieldName[0] == ':') { continue; } // this is the only thing that can tell if looking for a field/value // or a field/list. fieldValue will always be empty unless you put a // value after the colon. if you put something after the colon then // add the - listValues... idek what could happen but it could break if (fieldValue.IsEmpty()) { isNextLineList = true; listName = fieldName; } else { StringValues.Add(fieldName, fieldValue); } } ConfigPath = fullPath; IsConfigLoaded = true; return(true); } catch { StringValues.Clear(); ListValues.Clear(); IsConfigLoaded = false; return(false); } }
public void Clear() { ListValues.Clear(); ListAddresses.Clear(); }