Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DV/Nyano/Frontier Port] Deuteranopia (DogVision) and Tritanopia (UltraVision) traits #1702

Merged
merged 5 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Content.Client/Options/UI/OptionsMenu.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:tabs="clr-namespace:Content.Client.Options.UI.Tabs"
xmlns:dtabs="clr-namespace:Content.Client._DV.Options.UI.Tabs"
Title="{Loc 'ui-options-title'}"
MinSize="800 450">
<TabContainer Name="Tabs" Access="Public">
Expand All @@ -8,5 +9,6 @@
<tabs:KeyRebindTab Name="KeyRebindTab" />
<tabs:AudioTab Name="AudioTab" />
<tabs:AccessibilityTab Name="AccessibilityTab" />
<dtabs:DeltaTab Name="ExtraTab" />
</TabContainer>
</DefaultWindow>
1 change: 1 addition & 0 deletions Content.Client/Options/UI/OptionsMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public OptionsMenu()
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-accessibility"));
Tabs.SetTabTitle(5, Loc.GetString("ui-options-tab-extra")); // Extra settings

UpdateTabs();
}
Expand Down
23 changes: 23 additions & 0 deletions Content.Client/_DV/Options/UI/Tabs/DeltaTab.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<tabs:DeltaTab xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:tabs="clr-namespace:Content.Client._DV.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>
46 changes: 46 additions & 0 deletions Content.Client/_DV/Options/UI/Tabs/DeltaTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Content.Shared._DV.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._DV.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;
}
}
52 changes: 52 additions & 0 deletions Content.Client/_DV/Overlays/UltraVisionOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Content.Shared.Abilities;
using System.Numerics;

namespace Content.Client._DV.Overlays;

public sealed partial class UltraVisionOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] IEntityManager _entityManager = default!;


public override bool RequestScreenTexture => true;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _ultraVisionShader;

public UltraVisionOverlay()
{
IoCManager.InjectDependencies(this);
_ultraVisionShader = _prototypeManager.Index<ShaderPrototype>("UltraVision").Instance().Duplicate();
}

protected override bool BeforeDraw(in OverlayDrawArgs args)
{
if (_playerManager.LocalEntity is not { Valid: true } player
|| !_entityManager.HasComponent<UltraVisionComponent>(player))
{
return false;
}

return base.BeforeDraw(in args);
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture is null)
return;

_ultraVisionShader.SetParameter("SCREEN_TEXTURE", ScreenTexture);

var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
worldHandle.SetTransform(Matrix3x2.Identity);
worldHandle.UseShader(_ultraVisionShader);
worldHandle.DrawRect(viewport, Color.White);
worldHandle.UseShader(null); // important - as of writing, construction overlay breaks without this
}
}
61 changes: 61 additions & 0 deletions Content.Client/_DV/Overlays/UltraVisionSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Content.Shared.Abilities;
using Content.Shared._DV.CCVars;
using Robust.Client.Graphics;
using Robust.Shared.Configuration;
using Robust.Shared.Player;

namespace Content.Client._DV.Overlays;

public sealed partial class UltraVisionSystem : EntitySystem
{
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly ISharedPlayerManager _playerMan = default!;

private UltraVisionOverlay _overlay = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<UltraVisionComponent, ComponentInit>(OnUltraVisionInit);
SubscribeLocalEvent<UltraVisionComponent, ComponentShutdown>(OnUltraVisionShutdown);
SubscribeLocalEvent<UltraVisionComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<UltraVisionComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

Subs.CVar(_cfg, DCCVars.NoVisionFilters, OnNoVisionFiltersChanged);

_overlay = new();
}

private void OnUltraVisionInit(EntityUid uid, UltraVisionComponent component, ComponentInit args)
{
if (uid == _playerMan.LocalEntity && !_cfg.GetCVar(DCCVars.NoVisionFilters))
_overlayMan.AddOverlay(_overlay);
}

private void OnUltraVisionShutdown(EntityUid uid, UltraVisionComponent component, ComponentShutdown args)
{
if (uid == _playerMan.LocalEntity)
_overlayMan.RemoveOverlay(_overlay);
}

private void OnPlayerAttached(EntityUid uid, UltraVisionComponent component, LocalPlayerAttachedEvent args)
{
if (!_cfg.GetCVar(DCCVars.NoVisionFilters))
_overlayMan.AddOverlay(_overlay);
}

private void OnPlayerDetached(EntityUid uid, UltraVisionComponent component, LocalPlayerDetachedEvent args)
{
_overlayMan.RemoveOverlay(_overlay);
}

private void OnNoVisionFiltersChanged(bool enabled)
{
if (enabled)
_overlayMan.RemoveOverlay(_overlay);
else
_overlayMan.AddOverlay(_overlay);
}
}
52 changes: 52 additions & 0 deletions Content.Client/_Nyanotrasen/Overlays/DogVisionOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System.Numerics;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Content.Shared.Abilities;

namespace Content.Client._Nyanotrasen.Overlays;

public sealed partial class DogVisionOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] IEntityManager _entityManager = default!;


public override bool RequestScreenTexture => true;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _dogVisionShader;

public DogVisionOverlay()
{
IoCManager.InjectDependencies(this);
_dogVisionShader = _prototypeManager.Index<ShaderPrototype>("DogVision").Instance().Duplicate();
}

protected override bool BeforeDraw(in OverlayDrawArgs args)
{
if (_playerManager.LocalEntity is not { Valid: true } player
|| !_entityManager.HasComponent<DogVisionComponent>(player))
{
return false;
}

return base.BeforeDraw(in args);
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture is null)
return;

_dogVisionShader.SetParameter("SCREEN_TEXTURE", ScreenTexture);

var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
worldHandle.SetTransform(Matrix3x2.Identity);
worldHandle.UseShader(_dogVisionShader);
worldHandle.DrawRect(viewport, Color.White);
worldHandle.UseShader(null); // important - as of writing, construction overlay breaks without this
}
}
61 changes: 61 additions & 0 deletions Content.Client/_Nyanotrasen/Overlays/DogVisionSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Content.Shared.Abilities;
using Content.Shared._DV.CCVars;
using Robust.Client.Graphics;
using Robust.Shared.Configuration;
using Robust.Shared.Player;

namespace Content.Client._Nyanotrasen.Overlays;

public sealed partial class DogVisionSystem : EntitySystem
{
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly ISharedPlayerManager _playerMan = default!;

private DogVisionOverlay _overlay = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<DogVisionComponent, ComponentInit>(OnDogVisionInit);
SubscribeLocalEvent<DogVisionComponent, ComponentShutdown>(OnDogVisionShutdown);
SubscribeLocalEvent<DogVisionComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<DogVisionComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

Subs.CVar(_cfg, DCCVars.NoVisionFilters, OnNoVisionFiltersChanged);

_overlay = new();
}

private void OnDogVisionInit(EntityUid uid, DogVisionComponent component, ComponentInit args)
{
if (uid == _playerMan.LocalEntity && !_cfg.GetCVar(DCCVars.NoVisionFilters))
_overlayMan.AddOverlay(_overlay);
}

private void OnDogVisionShutdown(EntityUid uid, DogVisionComponent component, ComponentShutdown args)
{
if (uid == _playerMan.LocalEntity)
_overlayMan.RemoveOverlay(_overlay);
}

private void OnPlayerAttached(EntityUid uid, DogVisionComponent component, LocalPlayerAttachedEvent args)
{
if (!_cfg.GetCVar(DCCVars.NoVisionFilters))
_overlayMan.AddOverlay(_overlay);
}

private void OnPlayerDetached(EntityUid uid, DogVisionComponent component, LocalPlayerDetachedEvent args)
{
_overlayMan.RemoveOverlay(_overlay);
}

private void OnNoVisionFiltersChanged(bool enabled)
{
if (enabled)
_overlayMan.RemoveOverlay(_overlay);
else
_overlayMan.AddOverlay(_overlay);
}
}
8 changes: 8 additions & 0 deletions Content.Shared/_DV/Abilities/UltraVisionComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Abilities;

[RegisterComponent]
[NetworkedComponent]

public sealed partial class UltraVisionComponent : Component
{}
5 changes: 5 additions & 0 deletions Content.Shared/_DV/CCVars/DCCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,9 @@ public sealed class DCCVars
public static readonly CVarDef<int> MailLargeMalus =
CVarDef.Create("mail.largemalus", -250, 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", true, CVar.CLIENTONLY | CVar.ARCHIVE);
}
10 changes: 10 additions & 0 deletions Content.Shared/_Nyanotrasen/Abilities/DogVisionComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Abilities
{
[RegisterComponent]
[NetworkedComponent]

public sealed partial class DogVisionComponent : Component
{}
}
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/_DV/escape-menu/options-menu.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ui-options-tab-extra = Extra
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
10 changes: 10 additions & 0 deletions Resources/Locale/en-US/_DV/traits/traits.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ trait-estradiol-sensitive-desc = Your body is capable of taking on Nanotrasen's

trait-testosterone-sensitive-name = Testosterone sensitive
trait-testosterone-sensitive-desc = Your body is capable of taking on Nanotrasen's special masculinization medicines.

# impstation edit - removing mentions of unimplemented species

trait-ultravision-name = Ultraviolet vision
trait-ultravision-desc = Whether through custom bionic eyes, random mutation,
or something else, you perceive the world with ultraviolet light.

trait-deuteranopia-name = Deuteranopia
trait-deuteranopia-desc = Whether through custom bionic eyes, random mutation,
or something else, you have red-green colour blindness.
4 changes: 4 additions & 0 deletions Resources/Prototypes/_DV/Shaders/birdvision.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- type: shader
id: UltraVision
kind: source
path: "/Textures/_DV/Shaders/ultravision.swsl"
15 changes: 15 additions & 0 deletions Resources/Prototypes/_DV/Traits/disabilities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- type: trait
id: UltraVision
name: trait-ultravision-name
description: trait-ultravision-desc
category: Disabilities
components:
- type: UltraVision

- type: trait
id: DogVision
name: trait-deuteranopia-name
description: trait-deuteranopia-desc
category: Disabilities
components:
- type: DogVision
4 changes: 4 additions & 0 deletions Resources/Prototypes/_Nyanotrasen/Shaders/dogvision.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- type: shader
id: DogVision
kind: source
path: "/Textures/_Nyanotrasen/Shaders/dogvision.swsl"
Loading
Loading