public void CopyCvarsToDictionary(idDict dict, CvarFlags flags) { dict.Clear(); foreach (KeyValuePair <string, idInternalCvar> cvar in _cvarList) { if ((cvar.Value.Flags & flags) != 0) { dict.Set(cvar.Value.Name, cvar.ToString()); } } }
private void SetInternal(string name, string value, CvarFlags flags) { idInternalCvar intern = FindInternal(name); if (intern != null) { intern.SetStringInternal(value); intern.Flags |= flags & ~CvarFlags.Static; intern.UpdateCheat(); } else { idConsole.Warning("Tried to set unknown cvar '{0}'", name); intern = new idInternalCvar(name, value, flags); _cvarList.Add(intern.Name, intern); } }
private void Init(string name, string value, string description, float valueMin, float valueMax, string[] valueStrings, CvarFlags flags, ArgCompletion valueCompletion) { _name = name; _value = value; _flags = flags | CvarFlags.Static; _description = description; _valueMin = valueMin; _valueMax = valueMax; _valueStrings = valueStrings; _valueCompletion = valueCompletion; _intValue = 0; _floatValue = 0.0f; _internal = this; idE.CvarSystem.Register(this); //idCvarSystem.StaticList.Add(this); }
private string _descriptionString; // description. #endregion #region Constructor public idInternalCvar(string name, string value, CvarFlags flags) { _name = name; _nameString = name; _value = value; _valueString = value; _resetString = value; _description = string.Empty; _descriptionString = string.Empty; _flags = (flags & ~CvarFlags.Static) | CvarFlags.Modified; _valueMin = 1; _valueMax = -1; _valueStrings = null; UpdateValue(); UpdateCheat(); _internal = this; }
public idCvar(string name, string value, string description, string[] valueStrings, CvarFlags flags) : this(name, value, valueStrings, description, null, flags) { }
public idCvar(string name, string value, string[] valueStrings, string description, ArgCompletion valueCompletion, CvarFlags flags) { Init(name, value, description, 1, -1, valueStrings, flags, valueCompletion); }
private void SetInternal(string name, string value, CvarFlags flags) { idInternalCvar intern = FindInternal(name); if(intern != null) { intern.SetStringInternal(value); intern.Flags |= flags & ~CvarFlags.Static; intern.UpdateCheat(); } else { idConsole.Warning("Tried to set unknown cvar '{0}'", name); intern = new idInternalCvar(name, value, flags); _cvarList.Add(intern.Name, intern); } }
public idCvar(string name, string value, float valueMin, float valueMax, string description, ArgCompletion valueCompletion, CvarFlags flags) { Init(name, value, description, valueMin, valueMax, null, flags, valueCompletion); }
public void SetBool(string name, bool value, CvarFlags flags = 0) { SetInternal(name, ((value == true) ? 1 : 0).ToString(), flags); }
public void SetFloat(string name, float value, CvarFlags flags = 0) { SetInternal(name, value.ToString(), flags); }
public idCvar(string name, string value, float valueMin, float valueMax, string description, CvarFlags flags) : this(name, value, valueMin, valueMax, description, null, flags) { }
public idCvar(string name, string value, string description, CvarFlags flags) { Init(name, value, description, 0, 0, null, flags, null); }
private void ListByFlags(idCmdArgs args, CvarFlags flags) { int argNum = 1; string match; ShowMode show = ShowMode.Value; List<idCvar> list = new List<idCvar>(); if((StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum), "-") == 0) || (StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum), "/") == 0)) { if((StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum + 1), "help") == 0) || (StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum + 1), "?") == 0)) { argNum = 3; show = ShowMode.Description; } else if((StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum + 1), "type") == 0) || (StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum + 1), "range") == 0)) { argNum = 3; show = ShowMode.Type; } else if(StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum + 1), "flags") == 0) { argNum = 3; show = ShowMode.Flags; } } if(args.Length > argNum) { match = args.Get(argNum, -1); match = match.Replace(" ", ""); } else { match = ""; } foreach(KeyValuePair<string, idInternalCvar> kvp in _cvarList) { idInternalCvar cvar = kvp.Value; if((cvar.Flags & flags) == 0) { continue; } if((match.Length > 0) && (cvar.Name.ToLower().Contains(match.ToLower()) == false)) { continue; } list.Add(cvar); } list.OrderBy(a => a.Name); switch(show) { case ShowMode.Value: foreach(idCvar cvar in list) { idConsole.WriteLine("{0}{1}\"{2}\"", cvar.Name.PadRight(32), idColorString.White, cvar.ToString()); } break; case ShowMode.Description: foreach(idCvar cvar in list) { idConsole.WriteLine("{0}{1}{2}", cvar.Name.PadRight(32), idColorString.White, idHelper.WrapText(cvar.Description, 77 - 33, 33)); } break; case ShowMode.Type: foreach(idCvar cvar in list) { if((cvar.Flags & CvarFlags.Bool) == CvarFlags.Bool) { idConsole.WriteLine("{0}{1}bool", cvar.Name.PadRight(32), idColorString.Cyan); } else if((cvar.Flags & CvarFlags.Integer) == CvarFlags.Integer) { if(cvar.MinValue < cvar.MaxValue) { idConsole.WriteLine("{0}{1}int {2}[{3}, {4}]", cvar.Name.PadRight(32), idColorString.Green, idColorString.White, cvar.MinValue, cvar.MaxValue); } else { idConsole.WriteLine("{0}{1}int", cvar.Name.PadRight(32), idColorString.Green); } } else if((cvar.Flags & CvarFlags.Float) == CvarFlags.Float) { if(cvar.MinValue < cvar.MaxValue) { idConsole.WriteLine("{0}{1}float {2}[{3}, {4}]", cvar.Name.PadRight(32), idColorString.Red, idColorString.White, cvar.MinValue, cvar.MaxValue); } else { idConsole.WriteLine("{0}{1}float", cvar.Name.PadRight(32), idColorString.Red); } } else if(cvar.ValueStrings != null) { idConsole.Write("{0}{1}string {2}[", cvar.Name.PadRight(32), idColorString.White, idColorString.White); int count = cvar.ValueStrings.Length; for(int j = 0; j < count; j++) { if(j > 0) { idConsole.Write("{0}, {1}", idColorString.White, cvar.ValueStrings[j]); } else { idConsole.Write("{0}{1}", idColorString.White, cvar.ValueStrings[j]); } } idConsole.WriteLine("{0}]", idColorString.White); } else { idConsole.WriteLine("{0}{1}string", cvar.Name.PadRight(32), idColorString.White); } } break; case ShowMode.Flags: foreach(idCvar cvar in list) { idConsole.Write(cvar.Name.PadRight(32)); string str = string.Empty; if((cvar.Flags & CvarFlags.Bool) == CvarFlags.Bool) { str += string.Format("{0}B ", idColorString.Cyan); } else if((cvar.Flags & CvarFlags.Integer) == CvarFlags.Integer) { str += string.Format("{0}U ", idColorString.Green); } else if((cvar.Flags & CvarFlags.Float) == CvarFlags.Float) { str += string.Format("{0}F ", idColorString.Red); } else { str += string.Format("{0}S ", idColorString.White); } if((cvar.Flags & CvarFlags.System) == CvarFlags.System) { str += string.Format("{0}SYS ", idColorString.White); } else if((cvar.Flags & CvarFlags.Renderer) == CvarFlags.Renderer) { str += string.Format("{0}RNDR ", idColorString.White); } else if((cvar.Flags & CvarFlags.Sound) == CvarFlags.Sound) { str += string.Format("{0}SND ", idColorString.White); } else if((cvar.Flags & CvarFlags.Gui) == CvarFlags.Gui) { str += string.Format("{0}GUI ", idColorString.White); } else if((cvar.Flags & CvarFlags.Game) == CvarFlags.Game) { str += string.Format("{0}GAME ", idColorString.White); } else if((cvar.Flags & CvarFlags.Tool) == CvarFlags.Tool) { str += string.Format("{0}TOOL ", idColorString.White); } else { str += string.Format("{0} ", idColorString.White); } str += ((cvar.Flags & CvarFlags.UserInfo) == CvarFlags.UserInfo) ? "UI " : " "; str += ((cvar.Flags & CvarFlags.ServerInfo) == CvarFlags.ServerInfo) ? "SI " : " "; str += ((cvar.Flags & CvarFlags.Static) == CvarFlags.Static) ? "ST " : " "; str += ((cvar.Flags & CvarFlags.Cheat) == CvarFlags.Cheat) ? "CH " : " "; str += ((cvar.Flags & CvarFlags.Init) == CvarFlags.Init) ? "IN " : " "; str += ((cvar.Flags & CvarFlags.ReadOnly) == CvarFlags.ReadOnly) ? "RO " : " "; str += ((cvar.Flags & CvarFlags.Archive) == CvarFlags.Archive) ? "AR " : " "; str += ((cvar.Flags & CvarFlags.Modified) == CvarFlags.Modified) ? "MO " : " "; idConsole.WriteLine(str); } break; } idConsole.WriteLine("\n{0} cvars listed\n", list.Count); idConsole.WriteLine("listCvar [search string] = list cvar values"); idConsole.WriteLine("listCvar -help [search string] = list cvar descriptions"); idConsole.WriteLine("listCvar -type [search string] = list cvar types"); idConsole.WriteLine("listCvar -flags [search string] = list cvar flags"); }
public void SetInteger(string name, int value, CvarFlags flags = 0) { SetInternal(name, value.ToString(), flags); }
public void SetString(string name, string value, CvarFlags flags = 0) { SetInternal(name, value, flags); }
public void CopyCvarsToDictionary(idDict dict, CvarFlags flags) { dict.Clear(); foreach(KeyValuePair<string, idInternalCvar> cvar in _cvarList) { if((cvar.Value.Flags & flags) != 0) { dict.Set(cvar.Value.Name, cvar.ToString()); } } }
private void ListByFlags(idCmdArgs args, CvarFlags flags) { int argNum = 1; string match; ShowMode show = ShowMode.Value; List <idCvar> list = new List <idCvar>(); if ((StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum), "-") == 0) || (StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum), "/") == 0)) { if ((StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum + 1), "help") == 0) || (StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum + 1), "?") == 0)) { argNum = 3; show = ShowMode.Description; } else if ((StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum + 1), "type") == 0) || (StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum + 1), "range") == 0)) { argNum = 3; show = ShowMode.Type; } else if (StringComparer.InvariantCultureIgnoreCase.Compare(args.Get(argNum + 1), "flags") == 0) { argNum = 3; show = ShowMode.Flags; } } if (args.Length > argNum) { match = args.Get(argNum, -1); match = match.Replace(" ", ""); } else { match = ""; } foreach (KeyValuePair <string, idInternalCvar> kvp in _cvarList) { idInternalCvar cvar = kvp.Value; if ((cvar.Flags & flags) == 0) { continue; } if ((match.Length > 0) && (cvar.Name.ToLower().Contains(match.ToLower()) == false)) { continue; } list.Add(cvar); } list.OrderBy(a => a.Name); switch (show) { case ShowMode.Value: foreach (idCvar cvar in list) { idConsole.WriteLine("{0}{1}\"{2}\"", cvar.Name.PadRight(32), idColorString.White, cvar.ToString()); } break; case ShowMode.Description: foreach (idCvar cvar in list) { idConsole.WriteLine("{0}{1}{2}", cvar.Name.PadRight(32), idColorString.White, idHelper.WrapText(cvar.Description, 77 - 33, 33)); } break; case ShowMode.Type: foreach (idCvar cvar in list) { if ((cvar.Flags & CvarFlags.Bool) == CvarFlags.Bool) { idConsole.WriteLine("{0}{1}bool", cvar.Name.PadRight(32), idColorString.Cyan); } else if ((cvar.Flags & CvarFlags.Integer) == CvarFlags.Integer) { if (cvar.MinValue < cvar.MaxValue) { idConsole.WriteLine("{0}{1}int {2}[{3}, {4}]", cvar.Name.PadRight(32), idColorString.Green, idColorString.White, cvar.MinValue, cvar.MaxValue); } else { idConsole.WriteLine("{0}{1}int", cvar.Name.PadRight(32), idColorString.Green); } } else if ((cvar.Flags & CvarFlags.Float) == CvarFlags.Float) { if (cvar.MinValue < cvar.MaxValue) { idConsole.WriteLine("{0}{1}float {2}[{3}, {4}]", cvar.Name.PadRight(32), idColorString.Red, idColorString.White, cvar.MinValue, cvar.MaxValue); } else { idConsole.WriteLine("{0}{1}float", cvar.Name.PadRight(32), idColorString.Red); } } else if (cvar.ValueStrings != null) { idConsole.Write("{0}{1}string {2}[", cvar.Name.PadRight(32), idColorString.White, idColorString.White); int count = cvar.ValueStrings.Length; for (int j = 0; j < count; j++) { if (j > 0) { idConsole.Write("{0}, {1}", idColorString.White, cvar.ValueStrings[j]); } else { idConsole.Write("{0}{1}", idColorString.White, cvar.ValueStrings[j]); } } idConsole.WriteLine("{0}]", idColorString.White); } else { idConsole.WriteLine("{0}{1}string", cvar.Name.PadRight(32), idColorString.White); } } break; case ShowMode.Flags: foreach (idCvar cvar in list) { idConsole.Write(cvar.Name.PadRight(32)); string str = string.Empty; if ((cvar.Flags & CvarFlags.Bool) == CvarFlags.Bool) { str += string.Format("{0}B ", idColorString.Cyan); } else if ((cvar.Flags & CvarFlags.Integer) == CvarFlags.Integer) { str += string.Format("{0}U ", idColorString.Green); } else if ((cvar.Flags & CvarFlags.Float) == CvarFlags.Float) { str += string.Format("{0}F ", idColorString.Red); } else { str += string.Format("{0}S ", idColorString.White); } if ((cvar.Flags & CvarFlags.System) == CvarFlags.System) { str += string.Format("{0}SYS ", idColorString.White); } else if ((cvar.Flags & CvarFlags.Renderer) == CvarFlags.Renderer) { str += string.Format("{0}RNDR ", idColorString.White); } else if ((cvar.Flags & CvarFlags.Sound) == CvarFlags.Sound) { str += string.Format("{0}SND ", idColorString.White); } else if ((cvar.Flags & CvarFlags.Gui) == CvarFlags.Gui) { str += string.Format("{0}GUI ", idColorString.White); } else if ((cvar.Flags & CvarFlags.Game) == CvarFlags.Game) { str += string.Format("{0}GAME ", idColorString.White); } else if ((cvar.Flags & CvarFlags.Tool) == CvarFlags.Tool) { str += string.Format("{0}TOOL ", idColorString.White); } else { str += string.Format("{0} ", idColorString.White); } str += ((cvar.Flags & CvarFlags.UserInfo) == CvarFlags.UserInfo) ? "UI " : " "; str += ((cvar.Flags & CvarFlags.ServerInfo) == CvarFlags.ServerInfo) ? "SI " : " "; str += ((cvar.Flags & CvarFlags.Static) == CvarFlags.Static) ? "ST " : " "; str += ((cvar.Flags & CvarFlags.Cheat) == CvarFlags.Cheat) ? "CH " : " "; str += ((cvar.Flags & CvarFlags.Init) == CvarFlags.Init) ? "IN " : " "; str += ((cvar.Flags & CvarFlags.ReadOnly) == CvarFlags.ReadOnly) ? "RO " : " "; str += ((cvar.Flags & CvarFlags.Archive) == CvarFlags.Archive) ? "AR " : " "; str += ((cvar.Flags & CvarFlags.Modified) == CvarFlags.Modified) ? "MO " : " "; idConsole.WriteLine(str); } break; } idConsole.WriteLine("\n{0} cvars listed\n", list.Count); idConsole.WriteLine("listCvar [search string] = list cvar values"); idConsole.WriteLine("listCvar -help [search string] = list cvar descriptions"); idConsole.WriteLine("listCvar -type [search string] = list cvar types"); idConsole.WriteLine("listCvar -flags [search string] = list cvar flags"); }