private void DrawCVarWindow() { if (CVars.Get <bool>("debug_show_cvar_viewer")) { ImGui.SetNextWindowSize(new System.Numerics.Vector2(500, 400), ImGuiCond.FirstUseEver); ImGui.Begin("CVar Viewer", ref CVars.Get <bool>("debug_show_cvar_viewer")); if (ImGui.Button("Save##Control")) { CVars.Save(); } ImGui.SameLine(); if (ImGui.Button("Load##Control")) { CVars.SynchronizeFromFile(); } string[] names = CVars.GetNames(); Array.Sort(names); ImGui.Columns(4); ImGui.Text("CVar"); ImGui.NextColumn(); ImGui.Text("Value"); ImGui.NextColumn(); ImGui.Text("Default"); ImGui.NextColumn(); ImGui.Text("Description"); ImGui.NextColumn(); ImGui.Separator(); foreach (string name in names) { if (ImGui.Button(name)) { _cvarEditing = name; } ImGui.NextColumn(); ICVar cvar = CVars.RawGet(name); if (_cvarEditing == name) { switch (cvar) { case CVar <byte> numCVar: { int num = (int)numCVar.Value; ImGui.InputInt("##" + name, ref num); numCVar.Value = (byte)num; } break; case CVar <short> numCVar: { int num = (int)numCVar.Value; ImGui.InputInt("##" + name, ref num); numCVar.Value = (short)num; } break; case CVar <int> numCVar: ImGui.InputInt("##" + name, ref numCVar.Value); break; case CVar <float> numCVar: ImGui.InputFloat("##" + name, ref numCVar.Value); break; case CVar <double> numCVar: ImGui.InputDouble("##" + name, ref numCVar.Value); break; case CVar <bool> boolCVar: ImGui.Checkbox("##" + name, ref boolCVar.Value); break; case CVar <Color> colorCVar: { System.Numerics.Vector3 color = new System.Numerics.Vector3(colorCVar.Value.R / 255.0f, colorCVar.Value.G / 255.0f, colorCVar.Value.B / 255.0f); ImGui.ColorEdit3("##" + name, ref color); colorCVar.Value.R = (byte)(color.X * 255); colorCVar.Value.G = (byte)(color.Y * 255); colorCVar.Value.B = (byte)(color.Z * 255); } break; default: { string strValue = cvar.Serialize(); byte[] buff = new byte[strValue.Length + 500]; Array.Copy(Encoding.UTF8.GetBytes(strValue), buff, strValue.Length); ImGui.InputText("##" + name, buff, (uint)buff.Length); cvar.Deserialize(Encoding.UTF8.GetString(buff, 0, buff.Length)); } break; } } else { ImGui.Text(cvar.Serialize()); } ImGui.NextColumn(); if (ImGui.Button(cvar.SerializeDefault() + "##" + name)) { cvar.Reset(); } ImGui.NextColumn(); ImGui.TextWrapped(cvar.GetDescription()); ImGui.NextColumn(); } ImGui.End(); } }