[add] Ahelp volume change

This commit is contained in:
rhailrake
2023-04-28 07:55:20 +06:00
committed by Aviu00
parent e458ec9fcd
commit a6f88c6608
6 changed files with 133 additions and 3 deletions

View File

@@ -8,5 +8,6 @@
<tabs:KeyRebindTab Name="KeyRebindTab" />
<tabs:AudioTab Name="AudioTab" />
<tabs:NetworkTab Name="NetworkTab" />
<tabs:AdminSettingsTab Name="AdminSettingsTab"/>
</TabContainer>
</DefaultWindow>

View File

@@ -1,15 +1,17 @@
using Content.Client.Administration.Managers;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.IoC;
using Content.Client.Options.UI.Tabs;
using Robust.Shared.Timing;
namespace Content.Client.Options.UI
{
[GenerateTypedNameReferences]
public sealed partial class OptionsMenu : DefaultWindow
{
[Dependency] private readonly IClientAdminManager _clientAdminManager = default!;
public OptionsMenu()
{
RobustXamlLoader.Load(this);
@@ -20,6 +22,7 @@ namespace Content.Client.Options.UI
Tabs.SetTabTitle(2, Loc.GetString("ui-options-tab-controls"));
Tabs.SetTabTitle(3, Loc.GetString("ui-options-tab-audio"));
Tabs.SetTabTitle(4, Loc.GetString("ui-options-tab-network"));
Tabs.SetTabTitle(5, "Админ");
UpdateTabs();
}
@@ -28,5 +31,11 @@ namespace Content.Client.Options.UI
{
GraphicsTab.UpdateProperties();
}
protected override void FrameUpdate(FrameEventArgs args)
{
Tabs.SetTabVisible(5, _clientAdminManager.IsActive());
base.FrameUpdate(args);
}
}
}

View File

@@ -0,0 +1,44 @@
<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.AdminSettingsTab">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Vertical" Margin="5 0 0 0" VerticalExpand="True">
<BoxContainer Orientation="Horizontal" Margin="0 3 0 0">
<Label Text="Громкость звука ахелпа" HorizontalExpand="True"/>
<Control MinSize="8 0" />
<Slider Name="AhelpSoundVolume"
MinValue="0"
MaxValue="100"
HorizontalExpand="True"
MinSize="80 0"
Rounded="True" />
<Control MinSize="8 0" />
<Label Name="AhelpSoundVolumeLabel" MinSize="48 0"></Label>
</BoxContainer>
</BoxContainer>
<BoxContainer Orientation="Vertical" >
<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>
</BoxContainer>
</Control>

View File

@@ -0,0 +1,50 @@
using Content.Shared.CCVar;
using Content.Shared.White;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Range = Robust.Client.UserInterface.Controls.Range;
namespace Content.Client.Options.UI.Tabs;
[GenerateTypedNameReferences]
public sealed partial class AdminSettingsTab : Control
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
public AdminSettingsTab()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
LoadData();
AhelpSoundVolume.OnValueChanged += OnAhelpVolumeChanged;
}
protected override void Dispose(bool disposing)
{
AhelpSoundVolume.OnValueChanged -= OnAhelpVolumeChanged;
base.Dispose(disposing);
}
private void LoadData()
{
var bwoinkVolume = _cfg.GetCVar(WhiteCVars.BwoinkVolume);
AhelpSoundVolume.Value = bwoinkVolume;
AhelpSoundVolumeLabel.Text = ((int) bwoinkVolume).ToString();
}
private void OnAhelpVolumeChanged(Range newValue)
{
_cfg.SetCVar(WhiteCVars.BwoinkVolume, LV100ToDB(newValue.Value));
AhelpSoundVolumeLabel.Text = ((int)newValue.Value).ToString();
}
private float LV100ToDB(float lv100)
{
// Saving negative infinity doesn't work, so use -10000000 instead (MidiManager does it)
return MathF.Max(-10000000, MathF.Log(lv100 / 100, 10) * 10);
}
}