private void LoadData() { data = Json.GetOrCreate(file, new Data()); Mod.Instance.Logger.Info("Loading data"); splineColors = new Dictionary <string, Color>(); keyRegexList = new Dictionary <Regex, Color>(); // Making sure colors that copy from other are set properly HashSet <string> toRemove = new HashSet <string>(); Dictionary <string, JsonColor> rewrite = new Dictionary <string, JsonColor>(); foreach (var item in data.spline_colors) { JsonColor color = item.Value; if (string.Equals(color.type, JsonColor.TYPE_COPY, StringComparison.InvariantCultureIgnoreCase)) { if (data.spline_colors.ContainsKey(color.from)) { rewrite.Add(item.Key, data.spline_colors[color.from]); } else { toRemove.Add(item.Key); } } } toRemove.Do(key => data.spline_colors.Remove(key)); foreach (var item in rewrite) { data.spline_colors.Remove(item.Key); data.spline_colors.Add(item.Key, item.Value); } foreach (var item in data.spline_colors) { try { string[] subSplines = item.Key.Split(ITEM_DELIMITER); Array.Sort(subSplines); string lcaseKey = string.Join(string.Empty, subSplines).ToLower(); Color color = item.Value; splineColors.Add(lcaseKey, color); keyRegexList.Add(new Regex(item.Key), color); Mod.Instance.Logger.Info($"{item.Key} ({ColorEx.ColorToHexUnity(color)})"); } catch (Exception e) { Mod.Instance.Logger.Exception(e); Mod.Instance.Logger.Error($"Could not read color data for spline_color \"{item.Key}\""); } } }
public void EditHexClick() { IsEditing = true; EnableMenu(false); Color color = Menu.colorPicker_.Color_; InputPromptPanel.Create(OnSubmit, () => Mod.Instance.StartCoroutine(CloseInput()), "HEX COLOR", $"#{ColorEx.ColorToHexUnity(color).ToUpper()}"); }