public static void LoadColorPresets() { if (!SettingsPrefs.HasKey("TP_ColorPresets")) { SaveColorPresets(); return; } string saveData = SettingsPrefs.GetString("TP_ColorPresets"); string[] presets = saveData.Split(new char[] { '{', '}' }, System.StringSplitOptions.RemoveEmptyEntries); List <Color> colors = new List <Color> (presets.Length); for (int i = 0; i < presets.Length; i++) { string[] colorValueData = presets[i].Split(';'); if (colorValueData.Length < 4) { continue; } float[] values = new float[4]; for (int iV = 0; iV < 4; iV++) { float value = 0; if (float.TryParse(colorValueData[iV], out value)) { values[iV] = value; } } colors.Add(new Color(values[0], values[1], values[2], values[3])); } GlobalPainting.colorPresets = colors; }
public static void LoadBrushPresets() { if (!SettingsPrefs.HasKey("TP_BrushPresets")) { SaveBrushPresets(); return; } string saveData = SettingsPrefs.GetString("TP_BrushPresets"); string[] presets = saveData.Split(new char[] { '{', '}' }, System.StringSplitOptions.RemoveEmptyEntries); List <Painting.Brush> brushes = new List <Painting.Brush> (presets.Length); for (int i = 0; i < presets.Length; i++) { string[] brushValueData = presets[i].Split(';'); if (brushValueData.Length < 4) { continue; } float[] values = new float[6] { (float)Painting.BlendMode.Add, 0f, 0.05f, 0.2f, 0f, 1f }; for (int iV = 0; iV < brushValueData.Length && iV < values.Length; iV++) { float value = 0; if (float.TryParse(brushValueData[iV], out value)) { values[iV] = value; } } brushes.Add(new Painting.Brush { mode = (Painting.PaintMode)values[0], type = (int)values[1], size = values[2], intensity = values[3], falloff = values[4], hardness = values[5] }); } GlobalPainting.brushPresets = brushes; }