Network tab + net.interp_ratio slider (#6918)

This commit is contained in:
Leeroy
2022-03-01 05:18:25 +03:00
committed by GitHub
parent de80c162d6
commit 36c780762b
6 changed files with 121 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
<PropertyGroup>
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
@@ -26,5 +26,4 @@
<Import Project="..\RobustToolbox\MSBuild\XamlIL.targets" />
<Import Project="..\RobustToolbox\MSBuild\Robust.Analyzers.targets" />
</Project>

View File

@@ -1,4 +1,4 @@
<DefaultWindow xmlns="https://spacestation14.io"
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:tabs="clr-namespace:Content.Client.EscapeMenu.UI.Tabs"
Title="{Loc 'ui-options-title'}"
MinSize="800 450">
@@ -6,5 +6,6 @@
<tabs:GraphicsTab />
<tabs:KeyRebindTab />
<tabs:AudioTab />
<tabs:NetworkTab/>
</TabContainer>
</DefaultWindow>

View File

@@ -1,4 +1,4 @@
using Robust.Client.AutoGenerated;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.IoC;
@@ -17,6 +17,7 @@ namespace Content.Client.EscapeMenu.UI
Tabs.SetTabTitle(0, Loc.GetString("ui-options-tab-graphics"));
Tabs.SetTabTitle(1, Loc.GetString("ui-options-tab-controls"));
Tabs.SetTabTitle(2, Loc.GetString("ui-options-tab-audio"));
Tabs.SetTabTitle(3, Loc.GetString("ui-options-tab-network"));
}
}
}

View File

@@ -0,0 +1,39 @@
<Control xmlns="https://spacestation14.io"
xmlns:hudUi="clr-namespace:Content.Client.HUD.UI"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Content.Client.EscapeMenu.UI.Tabs.NetworkTab">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Vertical" Margin="8 8 8 8" VerticalExpand="True">
<BoxContainer Orientation="Horizontal" Margin="5 0 0 0">
<Label Text="{Loc 'ui-options-net-interp-ratio'}" />
<Control MinSize="8 0" />
<Slider Name="NetInterpRatioSlider"
MinValue="0"
MaxValue="6"
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>
<hudUi: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" />
<Control MinSize="2 0" />
<Button Name="ApplyButton"
Text="{Loc 'ui-options-apply'}"
TextAlign="Center"
HorizontalAlignment="Right" />
</BoxContainer>
</hudUi:StripeBack>
</BoxContainer>
</Control>

View File

@@ -0,0 +1,72 @@
using System;
using Content.Shared.CCVar;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared;
using Robust.Shared.Maths;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Client.EscapeMenu.UI.Tabs
{
[GenerateTypedNameReferences]
public sealed partial class NetworkTab : Control
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
public NetworkTab()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
ApplyButton.OnPressed += OnApplyButtonPressed;
ResetButton.OnPressed += OnResetButtonPressed;
NetInterpRatioSlider.OnValueChanged += OnNetInterpRatioSliderChanged;
Reset();
}
protected override void Dispose(bool disposing)
{
ApplyButton.OnPressed -= OnApplyButtonPressed;
ResetButton.OnPressed -= OnResetButtonPressed;
NetInterpRatioSlider.OnValueChanged -= OnNetInterpRatioSliderChanged;
base.Dispose(disposing);
}
private void OnNetInterpRatioSliderChanged(Robust.Client.UserInterface.Controls.Range range)
{
UpdateChanges();
}
private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
{
_cfg.SetCVar(CVars.NetInterpRatio, (int) NetInterpRatioSlider.Value);
_cfg.SaveToFile();
UpdateChanges();
}
private void OnResetButtonPressed(BaseButton.ButtonEventArgs args)
{
Reset();
}
private void Reset()
{
NetInterpRatioSlider.Value = _cfg.GetCVar(CVars.NetInterpRatio);
UpdateChanges();
}
private void UpdateChanges()
{
var isEverythingSame = NetInterpRatioSlider.Value == _cfg.GetCVar(CVars.NetInterpRatio);
ApplyButton.Disabled = isEverythingSame;
ResetButton.Disabled = isEverythingSame;
NetInterpRatioLabel.Text = NetInterpRatioSlider.Value.ToString();
}
}
}

View File

@@ -4,6 +4,7 @@ ui-options-title = Game Options
ui-options-tab-graphics = Graphics
ui-options-tab-controls = Controls
ui-options-tab-audio = Audio
ui-options-tab-network = Network
ui-options-apply = Apply
ui-options-reset-all = Reset All
@@ -148,3 +149,7 @@ ui-options-function-loadout6 = Hotbar Loadout 6
ui-options-function-loadout7 = Hotbar Loadout 7
ui-options-function-loadout8 = Hotbar Loadout 8
ui-options-function-loadout9 = Hotbar Loadout 9
## Network menu
ui-options-net-interp-ratio = Network Smoothing