+++ /dev/null
-<Control xmlns="https://spacestation14.io"
- xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- x:Class="Content.Client.Options.UI.Tabs.NetworkTab">
- <BoxContainer Orientation="Vertical" >
- <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">
- <Label Text="{Loc 'ui-options-net-interp-ratio'}" />
- <Control MinSize="8 0" />
- <Slider Name="NetInterpRatioSlider"
- ToolTip="{Loc 'ui-options-net-interp-ratio-tooltip'}"
- MaxValue="8"
- HorizontalExpand="True"
- MinSize="80 0"
- Rounded="True" />
- <Control MinSize="8 0" />
- <Label Name="NetInterpRatioLabel" MinSize="48 0" Align="Right" />
- <Control MinSize="4 0"/>
- </BoxContainer>
- <BoxContainer Orientation="Horizontal" Margin="4 10 4 0">
- <Label Text="{Loc 'ui-options-net-predict-tick-bias'}" />
- <Control MinSize="8 0" />
- <Slider Name="NetPredictTickBiasSlider"
- ToolTip="{Loc 'ui-options-net-predict-tick-bias-tooltip'}"
- MaxValue="6"
- MinValue="0"
- HorizontalExpand="True"
- MinSize="80 0"
- Rounded="True" />
- <Control MinSize="8 0" />
- <Label Name="NetPredictTickBiasLabel" MinSize="48 0" Align="Right" />
- <Control MinSize="4 0"/>
- </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">
- <Label Text="{Loc 'ui-options-net-pvs-entry'}" />
- <Control MinSize="8 0" />
- <Slider Name="NetPvsEntrySlider"
- ToolTip="{Loc 'ui-options-net-pvs-entry-tooltip'}"
- MaxValue="500"
- MinValue="20"
- HorizontalExpand="True"
- MinSize="80 0"
- Rounded="True" />
- <Control MinSize="8 0" />
- <Label Name="NetPvsEntryLabel" MinSize="48 0" Align="Right" />
- <Control MinSize="4 0"/>
- </BoxContainer>
- <BoxContainer Orientation="Horizontal" Margin="4 10 4 10">
- <Label Text="{Loc 'ui-options-net-pvs-leave'}" />
- <Control MinSize="8 0" />
- <Slider Name="NetPvsLeaveSlider"
- ToolTip="{Loc 'ui-options-net-pvs-leave-tooltip'}"
- MaxValue="300"
- MinValue="20"
- HorizontalExpand="True"
- MinSize="80 0"
- Rounded="True" />
- <Control MinSize="8 0" />
- <Label Name="NetPvsLeaveLabel" MinSize="48 0" Align="Right" />
- <Control MinSize="4 0"/>
- </BoxContainer>
- </BoxContainer>
- <controls:StripeBack HasBottomEdge="False" HasMargins="False">
- <BoxContainer Orientation="Horizontal"
- Align="End"
- HorizontalExpand="True"
- VerticalExpand="True">
- <Button Name="ResetButton"
- Text="{Loc 'ui-options-reset-all'}"
- StyleClasses="Caution"
- HorizontalExpand="True"
- HorizontalAlignment="Right" />
- <Button Name="DefaultButton"
- Text="{Loc 'ui-options-default'}"
- TextAlign="Center"
- HorizontalAlignment="Right" />
- <Control MinSize="2 0" />
- <Button Name="ApplyButton"
- Text="{Loc 'ui-options-apply'}"
- TextAlign="Center"
- HorizontalAlignment="Right" />
- </BoxContainer>
- </controls:StripeBack>
- </BoxContainer>
-</Control>
+++ /dev/null
-using System.Globalization;
-using Robust.Client.AutoGenerated;
-using Robust.Client.UserInterface;
-using Robust.Client.UserInterface.Controls;
-using Robust.Client.UserInterface.XAML;
-using Robust.Shared;
-using Robust.Shared.Configuration;
-using Robust.Client.GameStates;
-using Content.Client.Entry;
-
-namespace Content.Client.Options.UI.Tabs
-{
- [GenerateTypedNameReferences]
- public sealed partial class NetworkTab : Control
- {
- [Dependency] private readonly IConfigurationManager _cfg = default!;
- [Dependency] private readonly IClientGameStateManager _stateMan = default!;
-
- public NetworkTab()
- {
-
- RobustXamlLoader.Load(this);
- IoCManager.InjectDependencies(this);
-
- ApplyButton.OnPressed += OnApplyButtonPressed;
- ResetButton.OnPressed += OnResetButtonPressed;
- DefaultButton.OnPressed += OnDefaultButtonPressed;
- NetPredictCheckbox.OnToggled += OnPredictToggled;
- NetInterpRatioSlider.OnValueChanged += OnSliderChanged;
- NetInterpRatioSlider.MinValue = _stateMan.MinBufferSize;
- NetPredictTickBiasSlider.OnValueChanged += OnSliderChanged;
- NetPvsSpawnSlider.OnValueChanged += OnSliderChanged;
- NetPvsEntrySlider.OnValueChanged += OnSliderChanged;
- NetPvsLeaveSlider.OnValueChanged += OnSliderChanged;
-
- Reset();
- }
-
- protected override void Dispose(bool disposing)
- {
- ApplyButton.OnPressed -= OnApplyButtonPressed;
- ResetButton.OnPressed -= OnResetButtonPressed;
- DefaultButton.OnPressed -= OnDefaultButtonPressed;
- NetPredictCheckbox.OnToggled -= OnPredictToggled;
- NetInterpRatioSlider.OnValueChanged -= OnSliderChanged;
- NetPredictTickBiasSlider.OnValueChanged -= OnSliderChanged;
- NetPvsSpawnSlider.OnValueChanged -= OnSliderChanged;
- NetPvsEntrySlider.OnValueChanged -= OnSliderChanged;
- NetPvsLeaveSlider.OnValueChanged -= OnSliderChanged;
- base.Dispose(disposing);
- }
-
- private void OnPredictToggled(BaseButton.ButtonToggledEventArgs obj)
- {
- UpdateChanges();
- }
-
- private void OnSliderChanged(Robust.Client.UserInterface.Controls.Range range)
- {
- UpdateChanges();
- }
-
- private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
- {
- _cfg.SetCVar(CVars.NetBufferSize, (int) NetInterpRatioSlider.Value - _stateMan.MinBufferSize);
- _cfg.SetCVar(CVars.NetPredictTickBias, (int) NetPredictTickBiasSlider.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.NetPredict, NetPredictCheckbox.Pressed);
-
- _cfg.SaveToFile();
- UpdateChanges();
- }
-
- private void OnResetButtonPressed(BaseButton.ButtonEventArgs args)
- {
- Reset();
- }
-
- private void OnDefaultButtonPressed(BaseButton.ButtonEventArgs obj)
- {
- NetPredictTickBiasSlider.Value = CVars.NetPredictTickBias.DefaultValue;
- NetPvsSpawnSlider.Value = CVars.NetPVSEntityBudget.DefaultValue;
- NetPvsEntrySlider.Value = CVars.NetPVSEntityEnterBudget.DefaultValue;
- NetPvsLeaveSlider.Value = CVars.NetPVSEntityExitBudget.DefaultValue;
- NetInterpRatioSlider.Value = CVars.NetBufferSize.DefaultValue + _stateMan.MinBufferSize;
-
- UpdateChanges();
- }
-
- private void Reset()
- {
- NetInterpRatioSlider.Value = _cfg.GetCVar(CVars.NetBufferSize) + _stateMan.MinBufferSize;
- NetPredictTickBiasSlider.Value = _cfg.GetCVar(CVars.NetPredictTickBias);
- NetPvsSpawnSlider.Value = _cfg.GetCVar(CVars.NetPVSEntityBudget);
- NetPvsEntrySlider.Value = _cfg.GetCVar(CVars.NetPVSEntityEnterBudget);
- NetPvsLeaveSlider.Value = _cfg.GetCVar(CVars.NetPVSEntityExitBudget);
- NetPredictCheckbox.Pressed = _cfg.GetCVar(CVars.NetPredict);
- UpdateChanges();
- }
-
- private void UpdateChanges()
- {
- var isEverythingSame =
- NetInterpRatioSlider.Value == _cfg.GetCVar(CVars.NetBufferSize) + _stateMan.MinBufferSize &&
- NetPredictTickBiasSlider.Value == _cfg.GetCVar(CVars.NetPredictTickBias) &&
- NetPredictCheckbox.Pressed == _cfg.GetCVar(CVars.NetPredict) &&
- NetPvsSpawnSlider.Value == _cfg.GetCVar(CVars.NetPVSEntityBudget) &&
- NetPvsEntrySlider.Value == _cfg.GetCVar(CVars.NetPVSEntityEnterBudget) &&
- NetPvsLeaveSlider.Value == _cfg.GetCVar(CVars.NetPVSEntityExitBudget);
-
- ApplyButton.Disabled = isEverythingSame;
- ResetButton.Disabled = isEverythingSame;
- NetInterpRatioLabel.Text = NetInterpRatioSlider.Value.ToString(CultureInfo.InvariantCulture);
- NetPredictTickBiasLabel.Text = NetPredictTickBiasSlider.Value.ToString(CultureInfo.InvariantCulture);
- NetPvsSpawnLabel.Text = NetPvsSpawnSlider.Value.ToString(CultureInfo.InvariantCulture);
- NetPvsEntryLabel.Text = NetPvsEntrySlider.Value.ToString(CultureInfo.InvariantCulture);
- NetPvsLeaveLabel.Text = NetPvsLeaveSlider.Value.ToString(CultureInfo.InvariantCulture);
-
- // 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
- }
- }
-}