Vision filter accessibility option (#889)

* Add option to disable vision filters

* Remove DefaultVision in favor of the setting

* Clean DeltaTab.xaml.cs
This commit is contained in:
Debug 2024-02-23 19:36:18 +01:00 committed by GitHub
parent 39282a0c51
commit b32a3446ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 112 additions and 40 deletions

View File

@ -0,0 +1,23 @@
<tabs:DeltaTab xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:tabs="clr-namespace:Content.Client.DeltaV.Options.UI.Tabs"
xmlns:xNamespace="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Content.Client.Stylesheets">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Vertical" Margin="8 8 8 8" VerticalExpand="True">
<Label Text="{Loc 'ui-options-general-forknotice'}"
FontColorOverride="{xNamespace:Static s:StyleNano.ConcerningOrangeFore}"
StyleClasses="LabelKeyText"/>
<Label Text="{Loc 'ui-options-general-accessibility'}"
FontColorOverride="{xNamespace:Static s:StyleNano.NanoGold}"
StyleClasses="LabelKeyText"/>
<CheckBox Name="DisableFiltersCheckBox" Text="{Loc 'ui-options-no-filters'}" />
</BoxContainer>
<controls:StripeBack HasBottomEdge="False" HasMargins="False">
<Button Name="ApplyButton"
Text="{Loc 'ui-options-apply'}"
TextAlign="Center"
HorizontalAlignment="Right" />
</controls:StripeBack>
</BoxContainer>
</tabs:DeltaTab>

View File

@ -0,0 +1,46 @@
using Content.Shared.DeltaV.CCVars;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
namespace Content.Client.DeltaV.Options.UI.Tabs;
[GenerateTypedNameReferences]
public sealed partial class DeltaTab : Control
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
public DeltaTab()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
DisableFiltersCheckBox.OnToggled += OnCheckBoxToggled;
DisableFiltersCheckBox.Pressed = _cfg.GetCVar(DCCVars.NoVisionFilters);
ApplyButton.OnPressed += OnApplyButtonPressed;
UpdateApplyButton();
}
private void OnCheckBoxToggled(BaseButton.ButtonToggledEventArgs args)
{
UpdateApplyButton();
}
private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
{
_cfg.SetCVar(DCCVars.NoVisionFilters, DisableFiltersCheckBox.Pressed);
_cfg.SaveToFile();
UpdateApplyButton();
}
private void UpdateApplyButton()
{
var isNoVisionFiltersSame = DisableFiltersCheckBox.Pressed == _cfg.GetCVar(DCCVars.NoVisionFilters);
ApplyButton.Disabled = isNoVisionFiltersSame;
}
}

View File

@ -1,11 +1,14 @@
using Content.Shared.Abilities;
using Content.Shared.DeltaV.CCVars;
using Robust.Client.Graphics;
using Robust.Shared.Configuration;
namespace Content.Client.DeltaV.Overlays;
public sealed partial class UltraVisionSystem : EntitySystem
{
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
private UltraVisionOverlay _overlay = default!;
@ -16,16 +19,27 @@ public sealed partial class UltraVisionSystem : EntitySystem
SubscribeLocalEvent<UltraVisionComponent, ComponentInit>(OnUltraVisionInit);
SubscribeLocalEvent<UltraVisionComponent, ComponentShutdown>(OnUltraVisionShutdown);
Subs.CVar(_cfg, DCCVars.NoVisionFilters, OnNoVisionFiltersChanged);
_overlay = new();
}
private void OnUltraVisionInit(EntityUid uid, UltraVisionComponent component, ComponentInit args)
{
_overlayMan.AddOverlay(_overlay);
if (!_cfg.GetCVar(DCCVars.NoVisionFilters))
_overlayMan.AddOverlay(_overlay);
}
private void OnUltraVisionShutdown(EntityUid uid, UltraVisionComponent component, ComponentShutdown args)
{
_overlayMan.RemoveOverlay(_overlay);
}
private void OnNoVisionFiltersChanged(bool enabled)
{
if (enabled)
_overlayMan.RemoveOverlay(_overlay);
else
_overlayMan.AddOverlay(_overlay);
}
}

View File

@ -1,11 +1,14 @@
using Content.Shared.Abilities;
using Content.Shared.DeltaV.CCVars;
using Robust.Client.Graphics;
using Robust.Shared.Configuration;
namespace Content.Client.Nyanotrasen.Overlays;
public sealed partial class DogVisionSystem : EntitySystem
{
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
private DogVisionOverlay _overlay = default!;
@ -16,16 +19,27 @@ public sealed partial class DogVisionSystem : EntitySystem
SubscribeLocalEvent<DogVisionComponent, ComponentInit>(OnDogVisionInit);
SubscribeLocalEvent<DogVisionComponent, ComponentShutdown>(OnDogVisionShutdown);
Subs.CVar(_cfg, DCCVars.NoVisionFilters, OnNoVisionFiltersChanged);
_overlay = new();
}
private void OnDogVisionInit(EntityUid uid, DogVisionComponent component, ComponentInit args)
{
_overlayMan.AddOverlay(_overlay);
if (!_cfg.GetCVar(DCCVars.NoVisionFilters))
_overlayMan.AddOverlay(_overlay);
}
private void OnDogVisionShutdown(EntityUid uid, DogVisionComponent component, ComponentShutdown args)
{
_overlayMan.RemoveOverlay(_overlay);
}
private void OnNoVisionFiltersChanged(bool enabled)
{
if (enabled)
_overlayMan.RemoveOverlay(_overlay);
else
_overlayMan.AddOverlay(_overlay);
}
}

View File

@ -1,5 +1,6 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:tabs="clr-namespace:Content.Client.Options.UI.Tabs"
xmlns:dtabs="clr-namespace:Content.Client.DeltaV.Options.UI.Tabs"
Title="{Loc 'ui-options-title'}"
MinSize="800 450">
<TabContainer Name="Tabs" Access="Public">
@ -8,5 +9,6 @@
<tabs:KeyRebindTab Name="KeyRebindTab" />
<tabs:AudioTab Name="AudioTab" />
<tabs:NetworkTab Name="NetworkTab" />
<dtabs:DeltaTab Name="DeltaTab" />
</TabContainer>
</DefaultWindow>

View File

@ -20,6 +20,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, Loc.GetString("ui-options-tab-deltav")); // DeltaV specific settings
UpdateTabs();
}

View File

@ -1,8 +0,0 @@
using Robust.Shared.GameStates;
namespace Content.Shared.DeltaV.Abilities;
[RegisterComponent]
[NetworkedComponent]
public sealed partial class DefaultVisionComponent : Component
{}

View File

@ -1,20 +0,0 @@
using Content.Shared.Abilities;
using Content.Shared.DeltaV.Abilities;
namespace Content.Client.DeltaV.Overlays;
public sealed partial class DefaultVisionSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DefaultVisionComponent, ComponentInit>(OnDefaultVisionInit);
}
private void OnDefaultVisionInit(EntityUid uid, DefaultVisionComponent component, ComponentInit args)
{
RemComp<UltraVisionComponent>(uid);
RemComp<DogVisionComponent>(uid);
}
}

View File

@ -15,4 +15,10 @@ public sealed class DCCVars
/// </summary>
public static readonly CVarDef<bool> RoundEndPacifist =
CVarDef.Create("game.round_end_pacifist", false, CVar.SERVERONLY);
/// <summary>
/// Disables all vision filters for species like Vulpkanin or Harpies. There are good reasons someone might want to disable these.
/// </summary>
public static readonly CVarDef<bool> NoVisionFilters =
CVarDef.Create("accessibility.no_vision_filters", false, CVar.CLIENTONLY | CVar.ARCHIVE);
}

View File

@ -0,0 +1,4 @@
ui-options-tab-deltav = DeltaV
ui-options-general-forknotice = Note: These settings are fork-specific and might not apply on other servers.
ui-options-no-filters = Disable species vision filters

View File

@ -9,8 +9,5 @@ trait-deuteranopia-name = Deuteranopia
trait-deuteranopia-desc = Whether through custom bionic eyes, random mutation,
or being a Vulpkanin, you have redgreen colour blindness.
trait-defaultvision-name = Normal Vision
trait-defaultvision-desc = You lack any vision variation from the norm for a non-human species.
trait-uncloneable-name = Uncloneable
trait-uncloneable-desc = Cannot be cloned

View File

@ -11,10 +11,3 @@
description: trait-deuteranopia-desc
components:
- type: DogVision
- type: trait
id: DefaultVision
name: trait-defaultvision-name
description: trait-defaultvision-desc
components:
- type: DefaultVision