Add new PVS options slider (#12146)

This commit is contained in:
Leon Friedrich
2022-10-26 16:19:11 +13:00
committed by GitHub
parent f6db79d303
commit 0dd60bb6a7
3 changed files with 51 additions and 7 deletions

View File

@@ -4,6 +4,9 @@
x:Class="Content.Client.Options.UI.Tabs.NetworkTab"> x:Class="Content.Client.Options.UI.Tabs.NetworkTab">
<BoxContainer Orientation="Vertical" > <BoxContainer Orientation="Vertical" >
<BoxContainer Orientation="Vertical" Margin="8 8 8 8" VerticalExpand="True"> <BoxContainer Orientation="Vertical" Margin="8 8 8 8" VerticalExpand="True">
<BoxContainer Orientation="Horizontal" Margin="4 10 4 0">
<CheckBox Name="NetPredictCheckbox" Text="{Loc 'ui-options-net-predict'}" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" Margin="4 10 4 0"> <BoxContainer Orientation="Horizontal" Margin="4 10 4 0">
<Label Text="{Loc 'ui-options-net-interp-ratio'}" /> <Label Text="{Loc 'ui-options-net-interp-ratio'}" />
<Control MinSize="8 0" /> <Control MinSize="8 0" />
@@ -31,12 +34,26 @@
<Label Name="NetPredictTickBiasLabel" MinSize="48 0" Align="Right" /> <Label Name="NetPredictTickBiasLabel" MinSize="48 0" Align="Right" />
<Control MinSize="4 0"/> <Control MinSize="4 0"/>
</BoxContainer> </BoxContainer>
<BoxContainer Orientation="Horizontal" Margin="4 10 4 0">
<Label Text="{Loc 'ui-options-net-pvs-spawn'}" />
<Control MinSize="8 0" />
<Slider Name="NetPvsSpawnSlider"
ToolTip="{Loc 'ui-options-net-pvs-spawn-tooltip'}"
MaxValue="150"
MinValue="20"
HorizontalExpand="True"
MinSize="80 0"
Rounded="True" />
<Control MinSize="8 0" />
<Label Name="NetPvsSpawnLabel" MinSize="48 0" Align="Right" />
<Control MinSize="4 0"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" Margin="4 10 4 0"> <BoxContainer Orientation="Horizontal" Margin="4 10 4 0">
<Label Text="{Loc 'ui-options-net-pvs-entry'}" /> <Label Text="{Loc 'ui-options-net-pvs-entry'}" />
<Control MinSize="8 0" /> <Control MinSize="8 0" />
<Slider Name="NetPvsEntrySlider" <Slider Name="NetPvsEntrySlider"
ToolTip="{Loc 'ui-options-net-pvs-entry-tooltip'}" ToolTip="{Loc 'ui-options-net-pvs-entry-tooltip'}"
MaxValue="150" MaxValue="500"
MinValue="20" MinValue="20"
HorizontalExpand="True" HorizontalExpand="True"
MinSize="80 0" MinSize="80 0"

View File

@@ -24,9 +24,11 @@ namespace Content.Client.Options.UI.Tabs
ApplyButton.OnPressed += OnApplyButtonPressed; ApplyButton.OnPressed += OnApplyButtonPressed;
ResetButton.OnPressed += OnResetButtonPressed; ResetButton.OnPressed += OnResetButtonPressed;
DefaultButton.OnPressed += OnDefaultButtonPressed; DefaultButton.OnPressed += OnDefaultButtonPressed;
NetPredictCheckbox.OnToggled += OnPredictToggled;
NetInterpRatioSlider.OnValueChanged += OnSliderChanged; NetInterpRatioSlider.OnValueChanged += OnSliderChanged;
NetInterpRatioSlider.MinValue = _stateMan.MinBufferSize; NetInterpRatioSlider.MinValue = _stateMan.MinBufferSize;
NetPredictTickBiasSlider.OnValueChanged += OnSliderChanged; NetPredictTickBiasSlider.OnValueChanged += OnSliderChanged;
NetPvsSpawnSlider.OnValueChanged += OnSliderChanged;
NetPvsEntrySlider.OnValueChanged += OnSliderChanged; NetPvsEntrySlider.OnValueChanged += OnSliderChanged;
NetPvsLeaveSlider.OnValueChanged += OnSliderChanged; NetPvsLeaveSlider.OnValueChanged += OnSliderChanged;
@@ -38,13 +40,20 @@ namespace Content.Client.Options.UI.Tabs
ApplyButton.OnPressed -= OnApplyButtonPressed; ApplyButton.OnPressed -= OnApplyButtonPressed;
ResetButton.OnPressed -= OnResetButtonPressed; ResetButton.OnPressed -= OnResetButtonPressed;
DefaultButton.OnPressed -= OnDefaultButtonPressed; DefaultButton.OnPressed -= OnDefaultButtonPressed;
NetPredictCheckbox.OnToggled -= OnPredictToggled;
NetInterpRatioSlider.OnValueChanged -= OnSliderChanged; NetInterpRatioSlider.OnValueChanged -= OnSliderChanged;
NetPredictTickBiasSlider.OnValueChanged -= OnSliderChanged; NetPredictTickBiasSlider.OnValueChanged -= OnSliderChanged;
NetPvsSpawnSlider.OnValueChanged -= OnSliderChanged;
NetPvsEntrySlider.OnValueChanged -= OnSliderChanged; NetPvsEntrySlider.OnValueChanged -= OnSliderChanged;
NetPvsLeaveSlider.OnValueChanged -= OnSliderChanged; NetPvsLeaveSlider.OnValueChanged -= OnSliderChanged;
base.Dispose(disposing); base.Dispose(disposing);
} }
private void OnPredictToggled(BaseButton.ButtonToggledEventArgs obj)
{
UpdateChanges();
}
private void OnSliderChanged(Robust.Client.UserInterface.Controls.Range range) private void OnSliderChanged(Robust.Client.UserInterface.Controls.Range range)
{ {
UpdateChanges(); UpdateChanges();
@@ -54,8 +63,10 @@ namespace Content.Client.Options.UI.Tabs
{ {
_cfg.SetCVar(CVars.NetBufferSize, (int) NetInterpRatioSlider.Value - _stateMan.MinBufferSize); _cfg.SetCVar(CVars.NetBufferSize, (int) NetInterpRatioSlider.Value - _stateMan.MinBufferSize);
_cfg.SetCVar(CVars.NetPredictTickBias, (int) NetPredictTickBiasSlider.Value); _cfg.SetCVar(CVars.NetPredictTickBias, (int) NetPredictTickBiasSlider.Value);
_cfg.SetCVar(CVars.NetPVSEntityBudget, (int) NetPvsEntrySlider.Value); _cfg.SetCVar(CVars.NetPVSEntityBudget, (int) NetPvsSpawnSlider.Value);
_cfg.SetCVar(CVars.NetPVSEntityEnterBudget, (int) NetPvsEntrySlider.Value);
_cfg.SetCVar(CVars.NetPVSEntityExitBudget, (int) NetPvsLeaveSlider.Value); _cfg.SetCVar(CVars.NetPVSEntityExitBudget, (int) NetPvsLeaveSlider.Value);
_cfg.SetCVar(CVars.NetPredict, NetPredictCheckbox.Pressed);
_cfg.SaveToFile(); _cfg.SaveToFile();
UpdateChanges(); UpdateChanges();
@@ -69,7 +80,8 @@ namespace Content.Client.Options.UI.Tabs
private void OnDefaultButtonPressed(BaseButton.ButtonEventArgs obj) private void OnDefaultButtonPressed(BaseButton.ButtonEventArgs obj)
{ {
NetPredictTickBiasSlider.Value = CVars.NetPredictTickBias.DefaultValue; NetPredictTickBiasSlider.Value = CVars.NetPredictTickBias.DefaultValue;
NetPvsEntrySlider.Value = CVars.NetPVSEntityBudget.DefaultValue; NetPvsSpawnSlider.Value = CVars.NetPVSEntityBudget.DefaultValue;
NetPvsEntrySlider.Value = CVars.NetPVSEntityEnterBudget.DefaultValue;
NetPvsLeaveSlider.Value = CVars.NetPVSEntityExitBudget.DefaultValue; NetPvsLeaveSlider.Value = CVars.NetPVSEntityExitBudget.DefaultValue;
// Apparently default value doesn't get updated when using override defaults, so using a const // Apparently default value doesn't get updated when using override defaults, so using a const
@@ -82,8 +94,10 @@ namespace Content.Client.Options.UI.Tabs
{ {
NetInterpRatioSlider.Value = _cfg.GetCVar(CVars.NetBufferSize) + _stateMan.MinBufferSize; NetInterpRatioSlider.Value = _cfg.GetCVar(CVars.NetBufferSize) + _stateMan.MinBufferSize;
NetPredictTickBiasSlider.Value = _cfg.GetCVar(CVars.NetPredictTickBias); NetPredictTickBiasSlider.Value = _cfg.GetCVar(CVars.NetPredictTickBias);
NetPvsEntrySlider.Value = _cfg.GetCVar(CVars.NetPVSEntityBudget); NetPvsSpawnSlider.Value = _cfg.GetCVar(CVars.NetPVSEntityBudget);
NetPvsEntrySlider.Value = _cfg.GetCVar(CVars.NetPVSEntityEnterBudget);
NetPvsLeaveSlider.Value = _cfg.GetCVar(CVars.NetPVSEntityExitBudget); NetPvsLeaveSlider.Value = _cfg.GetCVar(CVars.NetPVSEntityExitBudget);
NetPredictCheckbox.Pressed = _cfg.GetCVar(CVars.NetPredict);
UpdateChanges(); UpdateChanges();
} }
@@ -92,15 +106,21 @@ namespace Content.Client.Options.UI.Tabs
var isEverythingSame = var isEverythingSame =
NetInterpRatioSlider.Value == _cfg.GetCVar(CVars.NetBufferSize) + _stateMan.MinBufferSize && NetInterpRatioSlider.Value == _cfg.GetCVar(CVars.NetBufferSize) + _stateMan.MinBufferSize &&
NetPredictTickBiasSlider.Value == _cfg.GetCVar(CVars.NetPredictTickBias) && NetPredictTickBiasSlider.Value == _cfg.GetCVar(CVars.NetPredictTickBias) &&
NetPvsEntrySlider.Value == _cfg.GetCVar(CVars.NetPVSEntityBudget) && NetPredictCheckbox.Pressed == _cfg.GetCVar(CVars.NetPredict) &&
NetPvsSpawnSlider.Value == _cfg.GetCVar(CVars.NetPVSEntityBudget) &&
NetPvsEntrySlider.Value == _cfg.GetCVar(CVars.NetPVSEntityEnterBudget) &&
NetPvsLeaveSlider.Value == _cfg.GetCVar(CVars.NetPVSEntityExitBudget); NetPvsLeaveSlider.Value == _cfg.GetCVar(CVars.NetPVSEntityExitBudget);
ApplyButton.Disabled = isEverythingSame; ApplyButton.Disabled = isEverythingSame;
ResetButton.Disabled = isEverythingSame; ResetButton.Disabled = isEverythingSame;
NetInterpRatioLabel.Text = NetInterpRatioSlider.Value.ToString(); NetInterpRatioLabel.Text = NetInterpRatioSlider.Value.ToString();
NetPredictTickBiasLabel.Text = NetPredictTickBiasSlider.Value.ToString(); NetPredictTickBiasLabel.Text = NetPredictTickBiasSlider.Value.ToString();
NetPvsSpawnLabel.Text = NetPvsSpawnSlider.Value.ToString();
NetPvsEntryLabel.Text = NetPvsEntrySlider.Value.ToString(); NetPvsEntryLabel.Text = NetPvsEntrySlider.Value.ToString();
NetPvsLeaveLabel.Text = NetPvsLeaveSlider.Value.ToString(); NetPvsLeaveLabel.Text = NetPvsLeaveSlider.Value.ToString();
// TODO disable / grey-out the predict and interp sliders if prediction is disabled.
// Currently no option to do this, but should be added to the slider control in general
} }
} }
} }

View File

@@ -178,6 +178,8 @@ ui-options-function-shuttle-brake = Brake
## Network menu ## Network menu
ui-options-net-predict = Client-side prediction
ui-options-net-interp-ratio = State buffer size ui-options-net-interp-ratio = State buffer size
ui-options-net-interp-ratio-tooltip = Increasing this will generally make the game more resistant ui-options-net-interp-ratio-tooltip = Increasing this will generally make the game more resistant
to server->client packet-loss, however in doing so it to server->client packet-loss, however in doing so it
@@ -190,11 +192,16 @@ ui-options-net-predict-tick-bias-tooltip = Increasing this will generally make t
effectively adds slightly more latency and requires the effectively adds slightly more latency and requires the
client to predict more future ticks. client to predict more future ticks.
ui-options-net-pvs-entry = PVS entity budget ui-options-net-pvs-spawn = PVS entity spawn budget
ui-options-net-pvs-entry-tooltip = This limits the rate at which the server will send new ui-options-net-pvs-spawn-tooltip = This limits the rate at which the server will send newly spawned
entities to the client. Lowering this can help reduce entities to the client. Lowering this can help reduce
stuttering due to entity spawning, but can lead to pop-in. stuttering due to entity spawning, but can lead to pop-in.
ui-options-net-pvs-entry = PVS entity budget
ui-options-net-pvs-entry-tooltip = This limits the rate at which the server will send newly visible
entities to the client. Lowering this can help reduce
stuttering, but can lead to pop-in.
ui-options-net-pvs-leave = PVS detach rate ui-options-net-pvs-leave = PVS detach rate
ui-options-net-pvs-leave-tooltip = This limits the rate at which the client will remove ui-options-net-pvs-leave-tooltip = This limits the rate at which the client will remove
out-of-view entities. Lowering this can help reduce out-of-view entities. Lowering this can help reduce