Add mouse sensitivity cvar, devconfig.cfg

This commit is contained in:
2025-03-20 22:09:08 +02:00
parent e6270ff541
commit 28b73be6c1
6 changed files with 74 additions and 12 deletions

View File

@@ -45,13 +45,18 @@ internal struct ConsoleVariable
{
if (field != null)
return (string)field.GetValue(null);
if (setter != null)
if (getter != null)
return (string)getter.Invoke(null, null);
}
else if (type == typeof(float))
{
if (field != null)
return field.GetValue(null).ToString();
if (getter != null)
return (string)getter.Invoke(null, null);
}
else
{
throw new Exception("cvar is not type of string");
}
throw new Exception($"Unsupported console variable type '{type.FullName}'");
throw new Exception("GetValueString no field or getter specified");
}
@@ -66,6 +71,15 @@ internal struct ConsoleVariable
else if (setter != null)
setter.Invoke(null, new object[] { value });
}
else if (type == typeof(float))
{
if (!float.TryParse(value, out var floatValue))
return;
if (field != null)
field.SetValue(null, floatValue);
else if (setter != null)
setter.Invoke(null, new object[] { floatValue });
}
else
{
throw new Exception("Unsupported type for SetValue: " + type.Name);