#region ================== Namespaces using System; using System.Collections.Generic; using CodeImp.DoomBuilder.Rendering; #endregion namespace CodeImp.DoomBuilder.Data { internal class CvarsCollection { #region ================== Variables internal readonly Dictionary Integers; internal readonly Dictionary Floats; internal readonly Dictionary Colors; internal readonly Dictionary Booleans; internal readonly Dictionary Strings; private readonly HashSet allnames; #endregion #region ================== Constructor public CvarsCollection() { Integers = new Dictionary(StringComparer.OrdinalIgnoreCase); Floats = new Dictionary(StringComparer.OrdinalIgnoreCase); Colors = new Dictionary(StringComparer.OrdinalIgnoreCase); Booleans = new Dictionary(StringComparer.OrdinalIgnoreCase); Strings = new Dictionary(StringComparer.OrdinalIgnoreCase); allnames = new HashSet(StringComparer.OrdinalIgnoreCase); } #endregion #region ================== Methods public bool AddValue(string name, int value) { if(allnames.Contains(name)) return false; allnames.Add(name); Integers.Add(name, value); return true; } public bool AddValue(string name, float value) { if(allnames.Contains(name)) return false; allnames.Add(name); Floats.Add(name, value); return true; } public bool AddValue(string name, PixelColor value) { if(allnames.Contains(name)) return false; allnames.Add(name); Colors.Add(name, value); return true; } public bool AddValue(string name, bool value) { if(allnames.Contains(name)) return false; allnames.Add(name); Booleans.Add(name, value); return true; } public bool AddValue(string name, string value) { if(allnames.Contains(name)) return false; allnames.Add(name); Strings.Add(name, value); return true; } #endregion } }