Change cvar usages to use CVarDef and define them in CCVars (#2250)
* Change cvar usages to use CVarDef and define them in CCVars * Merge fixes * Remove duplicate cvar registration
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Content.Shared;
|
||||
using Robust.Client.Interfaces.Console;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -14,10 +15,13 @@ namespace Content.Client.Commands
|
||||
|
||||
public bool Execute(IDebugConsole console, params string[] args)
|
||||
{
|
||||
var _configurationManager = IoCManager.Resolve<IConfigurationManager>();
|
||||
var old = _configurationManager.GetCVar<bool>("outline.enabled");
|
||||
_configurationManager.SetCVar("outline.enabled", !old);
|
||||
console.AddLine($"Draw outlines set to: {_configurationManager.GetCVar<bool>("outline.enabled")}");
|
||||
var configurationManager = IoCManager.Resolve<IConfigurationManager>();
|
||||
var cvar = CCVars.OutlineEnabled;
|
||||
var old = configurationManager.GetCVar(cvar);
|
||||
|
||||
configurationManager.SetCVar(cvar, !old);
|
||||
console.AddLine($"Draw outlines set to: {configurationManager.GetCVar(cvar)}");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,8 +101,6 @@ namespace Content.Client
|
||||
{
|
||||
IoCManager.Resolve<IMapManager>().CreateNewMapEntity(MapId.Nullspace);
|
||||
};
|
||||
|
||||
_configurationManager.RegisterCVar("outline.enabled", true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.Interfaces.Parallax;
|
||||
using Content.Shared;
|
||||
using Nett;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
@@ -34,12 +35,12 @@ namespace Content.Client.Parallax
|
||||
|
||||
public async void LoadParallax()
|
||||
{
|
||||
if (!_configurationManager.GetCVar<bool>("parallax.enabled"))
|
||||
if (!_configurationManager.GetCVar(CCVars.ParallaxEnabled))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var debugParallax = _configurationManager.GetCVar<bool>("parallax.debug");
|
||||
var debugParallax = _configurationManager.GetCVar(CCVars.ParallaxDebug);
|
||||
string contents;
|
||||
TomlTable table;
|
||||
// Load normal config into memory
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Content.Client.GameObjects.Components;
|
||||
using Content.Client.Utility;
|
||||
using Content.Shared;
|
||||
using Robust.Client.GameObjects.EntitySystems;
|
||||
using Robust.Client.Interfaces.GameObjects;
|
||||
using Robust.Client.Interfaces.Graphics.ClientEye;
|
||||
@@ -71,7 +72,7 @@ namespace Content.Client.State
|
||||
}
|
||||
|
||||
InteractionOutlineComponent outline;
|
||||
if(!ConfigurationManager.GetCVar<bool>("outline.enabled"))
|
||||
if(!ConfigurationManager.GetCVar(CCVars.OutlineEnabled))
|
||||
{
|
||||
if(entityToClick != null && entityToClick.TryGetComponent(out outline))
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ using Robust.Client.Interfaces.UserInterface;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -111,10 +112,10 @@ namespace Content.Client.State
|
||||
return;
|
||||
}
|
||||
|
||||
var configName = _configurationManager.GetCVar<string>("player.name");
|
||||
var configName = _configurationManager.GetCVar(CVars.PlayerName);
|
||||
if (_mainMenuControl.UserNameBox.Text != configName)
|
||||
{
|
||||
_configurationManager.SetCVar("player.name", inputName);
|
||||
_configurationManager.SetCVar(CVars.PlayerName, inputName);
|
||||
_configurationManager.SaveToFile();
|
||||
}
|
||||
|
||||
@@ -248,7 +249,7 @@ namespace Content.Client.State
|
||||
vBox.AddChild(userNameHBox);
|
||||
userNameHBox.AddChild(new Label {Text = "Username:"});
|
||||
|
||||
var currentUserName = _configurationManager.GetCVar<string>("player.name");
|
||||
var currentUserName = _configurationManager.GetCVar(CVars.PlayerName);
|
||||
UserNameBox = new LineEdit
|
||||
{
|
||||
Text = currentUserName, PlaceHolder = "Username",
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Robust.Client.Graphics;
|
||||
using Content.Shared;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
@@ -121,7 +123,7 @@ namespace Content.Client.UserInterface
|
||||
});
|
||||
ApplyButton.OnPressed += OnApplyButtonPressed;
|
||||
|
||||
VSyncCheckBox.Pressed = _cfg.GetCVar<bool>("display.vsync");
|
||||
VSyncCheckBox.Pressed = _cfg.GetCVar(CVars.DisplayVSync);
|
||||
FullscreenCheckBox.Pressed = ConfigIsFullscreen;
|
||||
LightingPresetOption.SelectId(GetConfigLightingQuality());
|
||||
_uiScaleOption.SelectId(GetConfigUIScalePreset(ConfigUIScale));
|
||||
@@ -137,11 +139,11 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
_cfg.SetCVar("display.vsync", VSyncCheckBox.Pressed);
|
||||
_cfg.SetCVar(CVars.DisplayVSync, VSyncCheckBox.Pressed);
|
||||
SetConfigLightingQuality(LightingPresetOption.SelectedId);
|
||||
_cfg.SetCVar("display.windowmode",
|
||||
_cfg.SetCVar(CVars.DisplayWindowMode,
|
||||
(int) (FullscreenCheckBox.Pressed ? WindowMode.Fullscreen : WindowMode.Windowed));
|
||||
_cfg.SetCVar("display.uiScale", UIScaleOptions[_uiScaleOption.SelectedId]);
|
||||
_cfg.SetCVar(CVars.DisplayUIScale, UIScaleOptions[_uiScaleOption.SelectedId]);
|
||||
_cfg.SaveToFile();
|
||||
UpdateApplyButton();
|
||||
}
|
||||
@@ -159,7 +161,7 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private void UpdateApplyButton()
|
||||
{
|
||||
var isVSyncSame = VSyncCheckBox.Pressed == _cfg.GetCVar<bool>("display.vsync");
|
||||
var isVSyncSame = VSyncCheckBox.Pressed == _cfg.GetCVar(CVars.DisplayVSync);
|
||||
var isFullscreenSame = FullscreenCheckBox.Pressed == ConfigIsFullscreen;
|
||||
var isLightingQualitySame = LightingPresetOption.SelectedId == GetConfigLightingQuality();
|
||||
var isUIScaleSame = MathHelper.CloseTo(UIScaleOptions[_uiScaleOption.SelectedId], ConfigUIScale);
|
||||
@@ -167,14 +169,14 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
|
||||
private bool ConfigIsFullscreen =>
|
||||
_cfg.GetCVar<int>("display.windowmode") == (int) WindowMode.Fullscreen;
|
||||
_cfg.GetCVar(CVars.DisplayWindowMode) == (int) WindowMode.Fullscreen;
|
||||
|
||||
private float ConfigUIScale => _cfg.GetCVar<float>("display.uiScale");
|
||||
private float ConfigUIScale => _cfg.GetCVar(CVars.DisplayUIScale);
|
||||
|
||||
private int GetConfigLightingQuality()
|
||||
{
|
||||
var val = _cfg.GetCVar<int>("display.lightmapdivider");
|
||||
var soft = _cfg.GetCVar<bool>("display.softshadows");
|
||||
var val = _cfg.GetCVar(CVars.DisplayLightMapDivider);
|
||||
var soft = _cfg.GetCVar(CVars.DisplaySoftShadows);
|
||||
if (val >= 8)
|
||||
{
|
||||
return 0;
|
||||
@@ -198,20 +200,20 @@ namespace Content.Client.UserInterface
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
_cfg.SetCVar("display.lightmapdivider", 8);
|
||||
_cfg.SetCVar("display.softshadows", false);
|
||||
_cfg.SetCVar(CVars.DisplayLightMapDivider, 8);
|
||||
_cfg.SetCVar(CVars.DisplaySoftShadows, false);
|
||||
break;
|
||||
case 1:
|
||||
_cfg.SetCVar("display.lightmapdivider", 2);
|
||||
_cfg.SetCVar("display.softshadows", false);
|
||||
_cfg.SetCVar(CVars.DisplayLightMapDivider, 2);
|
||||
_cfg.SetCVar(CVars.DisplaySoftShadows, false);
|
||||
break;
|
||||
case 2:
|
||||
_cfg.SetCVar("display.lightmapdivider", 2);
|
||||
_cfg.SetCVar("display.softshadows", true);
|
||||
_cfg.SetCVar(CVars.DisplayLightMapDivider, 2);
|
||||
_cfg.SetCVar(CVars.DisplaySoftShadows, true);
|
||||
break;
|
||||
case 3:
|
||||
_cfg.SetCVar("display.lightmapdivider", 1);
|
||||
_cfg.SetCVar("display.softshadows", true);
|
||||
_cfg.SetCVar(CVars.DisplayLightMapDivider, 1);
|
||||
_cfg.SetCVar(CVars.DisplaySoftShadows, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user