fish-station/Content.Client/Options/UI/Tabs/ExtraTab.xaml.cs

138 lines
6.3 KiB
C#

using Content.Client.Audio;
using Content.Shared._Sunrise.Lobby;
using Content.Shared._Sunrise.SunriseCCVars;
using Content.Shared.GameTicking;
using Content.Shared.GameTicking.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
namespace Content.Client.Options.UI.Tabs;
[GenerateTypedNameReferences]
public sealed partial class ExtraTab : Control
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public ExtraTab()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
Control.AddOptionPercentSlider(
SunriseCCVars.TTSVolume,
SliderTts,
scale: ContentAudioSystem.TtsMultiplier);
Control.AddOptionPercentSlider(
SunriseCCVars.TTSRadioVolume,
SliderTtsRadio,
scale: ContentAudioSystem.TtsMultiplier);
Control.AddOptionCheckBox(SunriseCCVars.TTSClientEnabled, TtsClientCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.TTSClientQueueEnabled, TtsClientCheckBoxQueue);
Control.AddOptionCheckBox(SunriseCCVars.TTSRadioGhostEnabled, TtsRadioGhostCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.TapePlayerClientEnabled, TapePlayerClientCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.JumpSoundDisable, JumpSoundDisableCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.VoteMusicDisable, VoteMusicDisableCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.MuteGhostRoleNotification, MuteGhostRoleNotificationCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.TracesEnabled, TracesCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.PlayHeartBeatSound, PlayHeartbeatSound);
_cfg.OnValueChanged(SunriseCCVars.LobbyBackgroundType, OnLobbyBackgroundTypeChanged, true);
var lobbyBackgroundTypes = new List<OptionDropDownCVar<string>.ValueOption>
{
new("Random", Loc.GetString("background-type-Random")),
};
var lobbyArts = new List<OptionDropDownCVar<string>.ValueOption>
{
new("Random", Loc.GetString("lobby-art-Random")),
};
var lobbyParallaxes = new List<OptionDropDownCVar<string>.ValueOption>
{
new ("Random", Loc.GetString("lobby-parallax-Random")),
};
var lobbyAnimations = new List<OptionDropDownCVar<string>.ValueOption>
{
new("Random", Loc.GetString("lobby-animation-Random")),
};
foreach (var backgroundType in Enum.GetValues(typeof(LobbyBackgroundType)))
{
var layoutLoc = Loc.GetString($"background-type-{backgroundType}");
lobbyBackgroundTypes.Add(new OptionDropDownCVar<string>.ValueOption(backgroundType.ToString()!, layoutLoc));
}
var lobbyParallaxesPrototypes = _prototypeManager.EnumeratePrototypes<LobbyParallaxPrototype>();
foreach (var lobbyParallax in lobbyParallaxesPrototypes)
{
var layoutLoc = Loc.GetString($"lobby-parallax-{lobbyParallax.ID}");
lobbyParallaxes.Add(new OptionDropDownCVar<string>.ValueOption(lobbyParallax.ID, layoutLoc));
}
var lobbyArtsPrototypes = _prototypeManager.EnumeratePrototypes<LobbyArtPrototype>();
foreach (var lobbyArt in lobbyArtsPrototypes)
{
var layoutLoc = Loc.GetString($"lobby-art-{lobbyArt.ID}");
lobbyArts.Add(new OptionDropDownCVar<string>.ValueOption(lobbyArt.ID, layoutLoc));
}
var lobbyAnimationsPrototypes = _prototypeManager.EnumeratePrototypes<LobbyAnimationPrototype>();
foreach (var lobbyAnimation in lobbyAnimationsPrototypes)
{
var layoutLoc = Loc.GetString($"lobby-animation-{lobbyAnimation.ID}");
lobbyAnimations.Add(new OptionDropDownCVar<string>.ValueOption(lobbyAnimation.ID, layoutLoc));
}
Control.AddOptionDropDown(SunriseCCVars.LobbyBackgroundType, DropDownLobbyBackgroundType, lobbyBackgroundTypes);
Control.AddOptionDropDown(SunriseCCVars.LobbyArt, DropDownLobbyArt, lobbyArts);
Control.AddOptionDropDown(SunriseCCVars.LobbyAnimation, DropDownLobbyAnimation, lobbyAnimations);
Control.AddOptionDropDown(SunriseCCVars.LobbyParallax, DropDownLobbyParallax, lobbyParallaxes);
Control.AddOptionPercentSlider(SunriseCCVars.LobbyOpacity, LobbyOpacitySlider);
Control.AddOptionCheckBox(SunriseCCVars.LobbyUnloadResources, LobbyUnloadResourcesCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.DamageOverlayEnable, DamageOverlayEnableCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.DamageOverlaySelf, DamageOverlaySelfCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.DamageOverlayStructures, DamageOverlayStructuresCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.ChatIconsEnable, ChatIconsEnableCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.ChatPointingVisuals, ChatPointingVisualsEnableCheckBox);
Control.Initialize();
}
private void OnLobbyBackgroundTypeChanged(string lobbyBackgroundTypeString)
{
if (lobbyBackgroundTypeString == "Random")
{
DropDownLobbyArt.Visible = true;
DropDownLobbyAnimation.Visible = true;
DropDownLobbyParallax.Visible = true;
return;
}
if (!Enum.TryParse(lobbyBackgroundTypeString, out LobbyBackgroundType lobbyBackgroundType))
{
lobbyBackgroundType = default;
}
switch (lobbyBackgroundType)
{
case LobbyBackgroundType.Parallax:
DropDownLobbyArt.Visible = false;
DropDownLobbyAnimation.Visible = false;
DropDownLobbyParallax.Visible = true;
break;
case LobbyBackgroundType.Art:
DropDownLobbyArt.Visible = true;
DropDownLobbyAnimation.Visible = false;
DropDownLobbyParallax.Visible = false;
break;
case LobbyBackgroundType.Animation:
DropDownLobbyArt.Visible = false;
DropDownLobbyAnimation.Visible = true;
DropDownLobbyParallax.Visible = false;
break;
}
}
}