]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Enhanced APC UI + New NT logo to footer (#14258)
authorJames Simonson <jamessimo89@gmail.com>
Tue, 7 Mar 2023 01:55:35 +0000 (09:55 +0800)
committerGitHub <noreply@github.com>
Tue, 7 Mar 2023 01:55:35 +0000 (21:55 -0400)
12 files changed:
Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs
Content.Client/Power/APC/ApcBoundUserInterface.cs
Content.Client/Power/APC/UI/ApcMenu.xaml
Content.Client/Power/APC/UI/ApcMenu.xaml.cs
Content.Client/Stylesheets/StyleNano.cs
Content.Server/Power/Components/ApcComponent.cs
Content.Server/Power/EntitySystems/ApcSystem.cs
Content.Shared/APC/SharedApc.cs
Resources/Locale/en-US/ui/power-apc.ftl
Resources/Textures/Interface/Nano/ntlogo.svg [new file with mode: 0644]
Resources/Textures/Interface/Nano/ntlogo.svg.png [new file with mode: 0644]
Resources/Textures/Interface/Nano/ntlogo.svg.png.yml [new file with mode: 0644]

index 9eb989f715fcf3af2a1adfd2012ee967be593997..1ef9158aeb3439ad54564c04aaf340a0b4fd288c 100644 (file)
@@ -5,7 +5,6 @@ using Content.Shared.CrewManifest;
 using Robust.Client.GameObjects;
 using Robust.Shared.Prototypes;
 using static Content.Shared.Access.Components.SharedIdCardConsoleComponent;
-
 namespace Content.Client.Access.UI
 {
     public sealed class IdCardConsoleBoundUserInterface : BoundUserInterface
@@ -16,7 +15,6 @@ namespace Content.Client.Access.UI
         public IdCardConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
         {
         }
-
         private IdCardConsoleWindow? _window;
 
         protected override void Open()
index 65ba4c7ec04423f83822469281ba82a650cd4693..d85edb8d1a3fa667c908f9a4495dcc09f468f2fe 100644 (file)
@@ -16,7 +16,7 @@ namespace Content.Client.Power.APC
         {
             base.Open();
 
-            _menu = new ApcMenu(this);
+            _menu = new ApcMenu(this,Owner);
             _menu.OnClose += Close;
             _menu.OpenCentered();
         }
index 5926b5de4cd19edd07e9532377631acff4a89180..0ce4a943da7ed1809f2f7c7412a22d2a900b7569 100644 (file)
@@ -1,28 +1,59 @@
-<DefaultWindow xmlns="https://spacestation14.io"
-            Name="APCMenu"
-            Title="{Loc 'apc-menu-title'}"
-            Resizable="False">
-    <BoxContainer Orientation="Vertical"
-                  SeparationOverride="4">
-        <BoxContainer Orientation="Horizontal">
-            <Label Text="{Loc 'apc-menu-breaker-label'}"/>
-            <Button Name="BreakerButton" Text="{Loc 'apc-menu-breaker-button'}"></Button>
-        </BoxContainer>
-        <Label Name="PowerLabel"/>
-        <BoxContainer Orientation="Horizontal">
-            <Label Text="{Loc 'apc-menu-external-label'}"/>
-            <Label Name="ExternalPowerStateLabel" Text="{Loc 'apc-menu-power-state-good'}"/>
-        </BoxContainer>
-        <BoxContainer Orientation="Horizontal">
-            <Label Text="{Loc 'apc-menu-charge-label'}"/>
+<controls:FancyWindow  xmlns="https://spacestation14.io"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
+    xmlns:style="clr-namespace:Content.Client.Stylesheets"
+    Name="APCMenu"
+    Title="{Loc 'apc-menu-title'}"
+    Resizable="False">
+
+    <BoxContainer Orientation="Vertical">
+        <BoxContainer Margin="0 5 10 10" Orientation="Vertical">
+            <BoxContainer Margin="0" Orientation="Horizontal">
+                <!-- Sprite View -->
+                <PanelContainer Margin="0" StyleClasses="Inset" VerticalAlignment="Center">
+                    <SpriteView Name="EntityView" Scale="2 2" SetSize="64 64" OverrideDirection="South" />
+                </PanelContainer>
+                <!-- Data -->
+                <BoxContainer Orientation="Vertical" HorizontalExpand="True">
+                    <GridContainer Margin="10 0 0 0" Columns="2">
+                        <!-- Power On/Off -->
+                        <Label Text="{Loc 'apc-menu-breaker-label'}" HorizontalExpand="True"
+                                StyleClasses="StatusFieldTitle" MinWidth="120"/>
+                        <BoxContainer Orientation="Horizontal" MinWidth="90">
+                            <Button Name="BreakerButton" Text="{Loc 'apc-menu-breaker-button'}" HorizontalExpand="True"/>
+                        </BoxContainer>
+                        <!--Charging Status-->
+                        <Label Text="{Loc 'apc-menu-external-label'}" StyleClasses="StatusFieldTitle" MinWidth="120" />
+                        <Label Name="ExternalPowerStateLabel" Text="{Loc 'apc-menu-power-state-good'}" />
+                        <!--Battery Power-->
+                        <Label Text="{Loc 'apc-menu-power-label'}" StyleClasses="StatusFieldTitle" MinWidth="120" />
+                        <Label Name="PowerLabel"/>
+                    </GridContainer>
+                </BoxContainer>
+            </BoxContainer>
+            <!-- Charge Progress Bar-->
             <ProgressBar Name="ChargeBar"
-                         HorizontalExpand="True"
-                         MinValue="0"
-                         MaxValue="1"
-                         Page="0"
-                         Value="0.5">
+                        HorizontalExpand="True"
+                        MinValue="0"
+                        MaxValue="1"
+                        MinHeight = "25"
+                        Page="0"
+                        Margin="10 10 0 0"
+                        Value="0.5">
+                <Label Name="ChargePercentage" Margin="4 0" Text="0 %" />
             </ProgressBar>
-            <Label Name="ChargePercentage"/>
+        </BoxContainer>
+
+        <!-- Footer -->
+        <BoxContainer Orientation="Vertical">
+            <PanelContainer StyleClasses="LowDivider" />
+            <BoxContainer Orientation="Horizontal" Margin="10 2 5 0" VerticalAlignment="Bottom">
+                <Label Text="{Loc 'apc-menu-flavor-left'}" StyleClasses="WindowFooterText" />
+                <Label Text="{Loc 'apc-menu-flavor-right'}" StyleClasses="WindowFooterText"
+                        HorizontalAlignment="Right" HorizontalExpand="True"  Margin="0 0 5 0" />
+                <TextureRect StyleClasses="NTLogoDark" Stretch="KeepAspectCentered"
+                        VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="19 19"/>
+            </BoxContainer>
         </BoxContainer>
     </BoxContainer>
-</DefaultWindow>
+</controls:FancyWindow>
index 1a33b416359a5a94381acbc7affc30890197b199..15b3e0b67dd93d885da5b308df3c7a28e8b55241 100644 (file)
@@ -1,25 +1,29 @@
 using Robust.Client.AutoGenerated;
-using Robust.Client.UserInterface.CustomControls;
 using Robust.Client.UserInterface.XAML;
+using Robust.Client.GameObjects;
 using Robust.Shared.IoC;
 using System;
 using Content.Client.Stylesheets;
 using Content.Shared.APC;
 using Robust.Client.Graphics;
+using Robust.Client.UserInterface.Controls;
 using Robust.Shared.GameObjects;
 using Robust.Shared.Localization;
 using Robust.Shared.Maths;
+using FancyWindow = Content.Client.UserInterface.Controls.FancyWindow;
 
 namespace Content.Client.Power.APC.UI
 {
     [GenerateTypedNameReferences]
-    public sealed partial class ApcMenu : DefaultWindow
+    public sealed partial class ApcMenu : FancyWindow
     {
-        public ApcMenu(ApcBoundUserInterface owner)
+        [Dependency] private readonly IEntityManager _entityManager = default!;
+        public ApcMenu(ApcBoundUserInterface owner, ClientUserInterfaceComponent component)
         {
             IoCManager.InjectDependencies(this);
             RobustXamlLoader.Load(this);
 
+            EntityView.Sprite = _entityManager.GetComponent<SpriteComponent>(component.Owner);
             BreakerButton.OnPressed += _ => owner.BreakerPressed();
         }
 
@@ -29,12 +33,22 @@ namespace Content.Client.Power.APC.UI
 
             if (BreakerButton != null)
             {
-                BreakerButton.Pressed = castState.MainBreaker;
+                if(castState.HasAccess == false)
+                {
+                    BreakerButton.Disabled = true;
+                    BreakerButton.ToolTip = Loc.GetString("apc-component-insufficient-access");
+                }
+                else
+                {
+                    BreakerButton.Disabled = false;
+                    BreakerButton.ToolTip = null;
+                    BreakerButton.Pressed = castState.MainBreaker;
+                }
             }
 
             if (PowerLabel != null)
             {
-                PowerLabel.Text = Loc.GetString("apc-menu-power-label", ("power", castState.Power));
+                PowerLabel.Text = castState.Power + "W";
             }
 
             if (ExternalPowerStateLabel != null)
@@ -62,12 +76,8 @@ namespace Content.Client.Power.APC.UI
             {
                 ChargeBar.Value = castState.Charge;
                 UpdateChargeBarColor(castState.Charge);
-
-                if (APCMenu != null)
-                {
-                    var chargePercentage = (castState.Charge / ChargeBar.MaxValue) * 100.0f;
-                    ChargePercentage.Text = " " + chargePercentage.ToString("0.00") + "%";
-                }
+                var chargePercentage = (castState.Charge / ChargeBar.MaxValue);
+                ChargePercentage.Text = Loc.GetString("apc-menu-charge-label",("percent",  chargePercentage.ToString("P0")));
             }
         }
 
index 7d2fb429f7ff868e3d47a0f4109e91d5027efeb6..58f68ff45821effcd9a6c2d9bb079882884bb4b9 100644 (file)
@@ -138,6 +138,7 @@ namespace Content.Client.Stylesheets
 
         public StyleNano(IResourceCache resCache) : base(resCache)
         {
+            var notoSans8 = resCache.NotoStack(size: 8);
             var notoSans10 = resCache.NotoStack(size: 10);
             var notoSansItalic10 = resCache.NotoStack(variation: "Italic", size: 10);
             var notoSans12 = resCache.NotoStack(size: 12);
@@ -1303,6 +1304,7 @@ namespace Content.Client.Stylesheets
                         ContentMarginBottomOverride = 2
                     }),
 
+                // Window Headers
                 Element<Label>().Class("FancyWindowTitle")
                     .Prop("font", boxFont13)
                     .Prop("font-color", NanoGold),
@@ -1319,6 +1321,15 @@ namespace Content.Client.Stylesheets
                     .Prop("panel", new StyleBoxTexture(BaseButtonOpenBoth) { Padding = default })
                     .Prop(Control.StylePropertyModulateSelf, Color.FromHex("#1F1F23")),
 
+                // Window Footer
+                Element<TextureRect>().Class("NTLogoDark")
+                    .Prop(TextureRect.StylePropertyTexture, resCache.GetTexture("/Textures/Interface/Nano/ntlogo.svg.png"))
+                    .Prop(Control.StylePropertyModulateSelf, Color.FromHex("#757575")),
+
+                Element<Label>().Class("WindowFooterText")
+                    .Prop(Label.StylePropertyFont, notoSans8)
+                    .Prop(Label.StylePropertyFontColor, Color.FromHex("#757575")),
+
                 // X Texture button ---
                 Element<TextureButton>().Class("CrossButtonRed")
                     .Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/Interface/Nano/cross.svg.png"))
index 12a7f619211b88ae2555bb96b807a060c90f17af..1109f5a22e7ea8fece7a6d4bcb5697024b3611e7 100644 (file)
@@ -26,6 +26,7 @@ public sealed class ApcComponent : BaseApcNetComponent
 
     [ViewVariables]
     public bool MainBreakerEnabled = true;
+    public bool HasAccess = false;
 
     public const float HighPowerThreshold = 0.9f;
     public static TimeSpan VisualsChangeDelay = TimeSpan.FromSeconds(1);
index d1333759bfa04a11591803bcec98cb691d37478b..691ba32d8a2733895b2a01fa0418af7e053cb58a 100644 (file)
@@ -37,6 +37,7 @@ namespace Content.Server.Power.EntitySystems
 
             UpdatesAfter.Add(typeof(PowerNetSystem));
 
+            SubscribeLocalEvent<ApcComponent, BoundUIOpenedEvent>(OnBoundUiOpen);
             SubscribeLocalEvent<ApcComponent, MapInitEvent>(OnApcInit);
             SubscribeLocalEvent<ApcComponent, ChargeChangedEvent>(OnBatteryChargeChanged);
             SubscribeLocalEvent<ApcComponent, ApcToggleMainBreakerMessage>(OnToggleMainBreaker);
@@ -59,6 +60,22 @@ namespace Content.Server.Power.EntitySystems
         {
             UpdateApcState(uid, component);
         }
+        //Update the HasAccess var for UI to read
+        private void OnBoundUiOpen(EntityUid uid, ApcComponent component, BoundUIOpenedEvent args)
+        {
+            TryComp<AccessReaderComponent>(uid, out var access);
+            if (args.Session.AttachedEntity == null)
+                return;
+
+            if (access == null || _accessReader.IsAllowed(args.Session.AttachedEntity.Value, access))
+            {
+                component.HasAccess = true;
+            }
+            else
+            {
+                component.HasAccess = false;
+            }
+        }
         private void OnToggleMainBreaker(EntityUid uid, ApcComponent component, ApcToggleMainBreakerMessage args)
         {
             TryComp<AccessReaderComponent>(uid, out var access);
@@ -141,7 +158,7 @@ namespace Content.Server.Power.EntitySystems
 
             if (_userInterfaceSystem.GetUiOrNull(uid, ApcUiKey.Key, ui) is { } bui)
             {
-                bui.SetState(new ApcBoundInterfaceState(apc.MainBreakerEnabled, (int)MathF.Ceiling(power), apc.LastExternalState, battery.CurrentCharge / battery.MaxCharge));
+                bui.SetState(new ApcBoundInterfaceState(apc.MainBreakerEnabled, apc.HasAccess, (int)MathF.Ceiling(power), apc.LastExternalState, battery.CurrentCharge / battery.MaxCharge));
             }
         }
 
index d49115b151bf4ce4c582da7d1c5b2f82d5f8bff4..cb634a107d9a4fd3ae43e66b9807aeca441115c9 100644 (file)
@@ -57,13 +57,15 @@ namespace Content.Shared.APC
     public sealed class ApcBoundInterfaceState : BoundUserInterfaceState
     {
         public readonly bool MainBreaker;
+        public readonly bool HasAccess;
         public readonly int Power;
         public readonly ApcExternalPowerState ApcExternalPower;
         public readonly float Charge;
 
-        public ApcBoundInterfaceState(bool mainBreaker, int power, ApcExternalPowerState apcExternalPower, float charge)
+        public ApcBoundInterfaceState(bool mainBreaker, bool hasAccess, int power, ApcExternalPowerState apcExternalPower, float charge)
         {
             MainBreaker = mainBreaker;
+            HasAccess = hasAccess;
             Power = power;
             ApcExternalPower = apcExternalPower;
             Charge = charge;
index 829b459ee901056b2e367a9c0c0681331042a84e..311a9d276033435886d600c6d5cdaf699e71920f 100644 (file)
@@ -1,12 +1,17 @@
 apc-menu-title = APC
-apc-menu-breaker-label = Main Breaker:{" "}
+apc-menu-breaker-label = Main Breaker
 apc-menu-breaker-button = Toggle
-apc-menu-power-label = Power: {$power} W
-apc-menu-external-label = External Power:{" "}
-apc-menu-charge-label = Charge:{" "}
+apc-menu-power-label = Battery Power
+apc-menu-external-label = External Power
+apc-menu-charge-label = {$percent} Charged
 
 # For the power state label
 
 apc-menu-power-state-good = Good
 apc-menu-power-state-low = Low
 apc-menu-power-state-none = None
+
+# For the flavor text on the footer
+
+apc-menu-flavor-left = Contact an engineer for assistance.
+apc-menu-flavor-right = v1.1
diff --git a/Resources/Textures/Interface/Nano/ntlogo.svg b/Resources/Textures/Interface/Nano/ntlogo.svg
new file mode 100644 (file)
index 0000000..ce8c779
--- /dev/null
@@ -0,0 +1,3 @@
+<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M0.359947 9.76624C0.201373 9.63414 0.0876491 9.45694 0.0341941 9.25865C-0.0192608 9.06037 -0.00986073 8.8506 0.0611199 8.65779C0.1321 8.46498 0.261228 8.29845 0.430994 8.18078C0.60076 8.06311 0.802953 8 1.01016 8H5.99001C6.09717 8 6.19995 8.04216 6.27572 8.11722C6.3515 8.19227 6.39407 8.29407 6.39407 8.40021V14.793L0.359947 9.76624ZM13.4014 8H8.03851C7.90345 8 7.77392 8.05081 7.67842 8.14124C7.58291 8.23168 7.52926 8.35434 7.52926 8.48223V23.5178C7.52926 23.6457 7.58291 23.7683 7.67842 23.8588C7.77392 23.9492 7.90345 24 8.03851 24H12.0384C12.1735 24 12.303 23.9492 12.3985 23.8588C12.494 23.7683 12.5476 23.6457 12.5476 23.5178V15.3911L17.9868 23.7703C18.0323 23.8405 18.0961 23.8985 18.1721 23.9387C18.248 23.9789 18.3336 24 18.4206 24H23.9606C24.0956 24 24.2252 23.9492 24.3207 23.8588C24.4162 23.7683 24.4698 23.6457 24.4698 23.5178V8.48223C24.4698 8.4189 24.4566 8.3562 24.431 8.29769C24.4055 8.23918 24.3679 8.18602 24.3207 8.14124C24.2734 8.09646 24.2172 8.06094 24.1554 8.03671C24.0937 8.01247 24.0274 8 23.9606 8H19.8395C19.7044 8 19.5749 8.05081 19.4794 8.14124C19.3839 8.23168 19.3302 8.35434 19.3302 8.48223V16.695L13.8352 8.2297C13.7897 8.15951 13.7259 8.10154 13.6499 8.06133C13.574 8.02111 13.4884 8 13.4014 8ZM31.9657 22.7414C31.9122 22.5431 31.7985 22.3659 31.6399 22.2338L25.6058 17.207V23.5999C25.6058 23.6524 25.6162 23.7044 25.6366 23.753C25.6569 23.8016 25.6866 23.8457 25.7241 23.8828C25.7617 23.92 25.8062 23.9495 25.8552 23.9696C25.9043 23.9897 25.9568 24.0001 26.0099 24.0001H30.9897C31.1969 24.0001 31.3991 23.937 31.5689 23.8193C31.7386 23.7016 31.8678 23.5351 31.9387 23.3423C32.0097 23.1495 32.0191 22.9397 31.9657 22.7414Z" fill="white"/>
+</svg>
diff --git a/Resources/Textures/Interface/Nano/ntlogo.svg.png b/Resources/Textures/Interface/Nano/ntlogo.svg.png
new file mode 100644 (file)
index 0000000..a5c241b
Binary files /dev/null and b/Resources/Textures/Interface/Nano/ntlogo.svg.png differ
diff --git a/Resources/Textures/Interface/Nano/ntlogo.svg.png.yml b/Resources/Textures/Interface/Nano/ntlogo.svg.png.yml
new file mode 100644 (file)
index 0000000..5c43e23
--- /dev/null
@@ -0,0 +1,2 @@
+sample:
+  filter: true