[add] Ahelp volume change
This commit is contained in:
50
Content.Client/Options/UI/Tabs/AdminSettingsTab.xaml.cs
Normal file
50
Content.Client/Options/UI/Tabs/AdminSettingsTab.xaml.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user