[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);
}
}

View File

@@ -13,6 +13,7 @@ using Content.Client.UserInterface.Systems.MenuBar.Widgets;
using Content.Shared.Administration;
using Content.Shared.CCVar;
using Content.Shared.Input;
using Content.Shared.White;
using JetBrains.Annotations;
using Robust.Client.Audio;
using Robust.Client.Graphics;
@@ -21,6 +22,7 @@ using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Audio;
using Robust.Shared.Configuration;
using Robust.Shared.Input.Binding;
using Robust.Shared.Network;
@@ -38,6 +40,8 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[UISystemDependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly IClientAdminManager _clientAdminManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
private BwoinkSystem? _bwoinkSystem;
private MenuButton? GameAHelpButton => UIManager.GetActiveUIWidgetOrNull<GameTopMenuBar>()?.AHelpButton;
@@ -47,12 +51,17 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
private bool _hasUnreadAHelp;
private string? _aHelpSound;
private float defaultBwoinkVolume;
private float adminBwoinkVolume;
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<BwoinkDiscordRelayUpdated>(DiscordRelayUpdated);
SubscribeNetworkEvent<BwoinkPlayerTypingUpdated>(PeopleTypingUpdated);
defaultBwoinkVolume = WhiteCVars.BwoinkVolume.DefaultValue;
_cfg.OnValueChanged(WhiteCVars.BwoinkVolume, volume => adminBwoinkVolume = volume);
_adminManager.AdminStatusUpdated += OnAdminStatusUpdated;
_config.OnValueChanged(CCVars.AHelpSound, v => _aHelpSound = v, true);
@@ -133,10 +142,20 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
{
return;
}
float bwoinkVolume = _clientAdminManager.IsActive() ? adminBwoinkVolume : defaultBwoinkVolume;
var audioParams = new AudioParams()
{
Volume = bwoinkVolume
};
if (localPlayer.UserId != message.TrueSender)
{
if (_aHelpSound != null)
_audio.PlayGlobal(_aHelpSound, Filter.Local(), false);
_audio.PlayGlobal(_aHelpSound, Filter.Local(), false, audioParams);
_clyde.RequestWindowAttention();
}

View File

@@ -150,4 +150,11 @@ public sealed class WhiteCVars
public static readonly CVarDef<int> GhostRespawnMaxPlayers =
CVarDef.Create("ghost.respawn_max_players", 40, CVar.SERVERONLY);
/*
* Bwoink
*/
public static readonly CVarDef<float> BwoinkVolume =
CVarDef.Create("white.admin.bwoinkVolume", 0f, CVar.CLIENTONLY | CVar.ARCHIVE);
}