From 56183611c524efd7106e57ea2879f40fec66bfe0 Mon Sep 17 00:00:00 2001 From: Pspritechologist <81725545+Pspritechologist@users.noreply.github.com> Date: Mon, 30 Oct 2023 09:55:07 -0400 Subject: [PATCH] Uses ResPath now Also slightly cleaner, a fix or two --- .../Jukebox/Ui/JukeboxBoundUserInterface.cs | 3 --- .../Jukebox/Ui/JukeboxWindow.xaml.cs | 22 +++++++++---------- .../Jukebox/JukeboxSystems.Interactions.cs | 9 +++----- .../Jukebox/JukeboxComponent.cs | 11 +++++----- .../Prototypes/JukeboxTrackPrototype.cs | 3 ++- .../Structures/Machines/Fun/jukebox.yml | 13 ++++++++++- 6 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Content.Client/SimpleStation14/Jukebox/Ui/JukeboxBoundUserInterface.cs b/Content.Client/SimpleStation14/Jukebox/Ui/JukeboxBoundUserInterface.cs index 81765bac77..19db0140ca 100644 --- a/Content.Client/SimpleStation14/Jukebox/Ui/JukeboxBoundUserInterface.cs +++ b/Content.Client/SimpleStation14/Jukebox/Ui/JukeboxBoundUserInterface.cs @@ -1,9 +1,6 @@ using Content.Shared.SimpleStation14.Jukebox; using JetBrains.Annotations; using Robust.Client.GameObjects; -using Robust.Shared.Prototypes; -using Robust.Shared.Timing; -using Content.Shared.SimpleStation14.Prototypes; namespace Content.Client.SimpleStation14.Jukebox.Ui; diff --git a/Content.Client/SimpleStation14/Jukebox/Ui/JukeboxWindow.xaml.cs b/Content.Client/SimpleStation14/Jukebox/Ui/JukeboxWindow.xaml.cs index 04bc48be0d..418464091a 100644 --- a/Content.Client/SimpleStation14/Jukebox/Ui/JukeboxWindow.xaml.cs +++ b/Content.Client/SimpleStation14/Jukebox/Ui/JukeboxWindow.xaml.cs @@ -19,7 +19,7 @@ public sealed partial class JukeboxWindow : FancyWindow { [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IPrototypeManager _prototype = default!; - [Dependency] private readonly IResourceCache _resourceCache = default!; + [Dependency] private readonly IResourceCache _resource = default!; private readonly ISawmill _log = default!; @@ -51,7 +51,7 @@ public JukeboxWindow(JukeboxComponent jukeboxComp, ISawmill log) SerialTitle.SetMessage(Loc.GetString("jukebox-ui-serial-title")); SerialNumber.Text = jukeboxComp.SerialNumber; - SkipButton.TexturePath = jukeboxComp.UiButtonSkip; + SkipButton.TextureNormal = _resource.GetTexture(_jukeboxComp.UiButtonSkip); // Sets up the custom colours of the ui. BG_1.PanelOverride = new StyleBoxFlat { BackgroundColor = jukeboxComp.UiColorBG }; @@ -64,11 +64,11 @@ public JukeboxWindow(JukeboxComponent jukeboxComp, ISawmill log) Accent_4.PanelOverride = new StyleBoxFlat { BackgroundColor = jukeboxComp.UiColorAccent }; // Sets up all the fonts. - SongName.FontOverride = _resourceCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 18); - SongsLabel.FontOverride = _resourceCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 22); + SongName.FontOverride = _resource.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 18); + SongsLabel.FontOverride = _resource.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 22); // SerialTitle.FontOverride = _resourceCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 16); - SerialHeader.FontOverride = _resourceCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 28); - SerialNumber.FontOverride = _resourceCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 16); + SerialHeader.FontOverride = _resource.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 28); + SerialNumber.FontOverride = _resource.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 16); if (!jukeboxComp.DecorativeUi) // Hides the decorative portion of the UI if the Jukebox doesn't have it. { @@ -81,7 +81,7 @@ public JukeboxWindow(JukeboxComponent jukeboxComp, ISawmill log) { if (control is Label label) { - label.FontOverride = _resourceCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 16); + label.FontOverride = _resource.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 16); label.FontColorOverride = Color.FromHex("#A5762F"); label.HorizontalAlignment = HAlignment.Center; label.HorizontalExpand = false; @@ -207,7 +207,7 @@ public void UpdateState(bool repopulateSongs = false) if (_jukeboxComp.CurrentlyPlayingTrack == null || !_prototype.TryIndex(_jukeboxComp.CurrentlyPlayingTrack, out var track)) { SongName.Text = Loc.GetString("jukebox-ui-current-empty"); - SongIcon.TexturePath = _jukeboxComp.DefaultSongArtPath; + SongIcon.Texture = _resource.GetTexture(_jukeboxComp.DefaultSongArtPath); SkipButton.Disabled = true; PlayButton.Disabled = true; @@ -215,7 +215,7 @@ public void UpdateState(bool repopulateSongs = false) _timeWillFinish = TimeSpan.Zero; _timeStopped = TimeSpan.Zero; - PlayButton.TexturePath = _jukeboxComp.UiButtonPlay; + PlayButton.TextureNormal = _resource.GetTexture(_jukeboxComp.UiButtonPlay); PlayButton.Disabled = true; SkipButton.Disabled = true; @@ -230,12 +230,12 @@ public void UpdateState(bool repopulateSongs = false) _songDuration = track.Duration; SongName.Text = track.Name; - SongIcon.TexturePath = track.ArtPath ?? _jukeboxComp.DefaultSongArtPath; + SongIcon.Texture = _resource.GetTexture(track.ArtPath ?? _jukeboxComp.DefaultSongArtPath); SkipButton.Disabled = false; PlayButton.Disabled = false; - PlayButton.TexturePath = _jukeboxComp.Paused ? _jukeboxComp.UiButtonPlay : _jukeboxComp.UiButtonPause; + PlayButton.TextureNormal = _resource.GetTexture(_jukeboxComp.Playing ? _jukeboxComp.UiButtonPause : _jukeboxComp.UiButtonPlay); PlayButton.Disabled = false; SkipButton.Disabled = false; diff --git a/Content.Server/SimpleStation14/Jukebox/JukeboxSystems.Interactions.cs b/Content.Server/SimpleStation14/Jukebox/JukeboxSystems.Interactions.cs index c55e9111d6..1cb0fed288 100644 --- a/Content.Server/SimpleStation14/Jukebox/JukeboxSystems.Interactions.cs +++ b/Content.Server/SimpleStation14/Jukebox/JukeboxSystems.Interactions.cs @@ -80,14 +80,11 @@ public string GenerateSerialNumber() digits[6] = digits[4] * digits[5]; digits[7] = (digits[0] + digits[1] + digits[5] + digits[4]) % 5; - for (var i = 0; i < digits.Length; i++) - digits[i] = Math.Abs(digits[i]); - - var serial = $"{digits[0]}{digits[1]}{digits[2]}{digits[3]}{digits[4]}{digits[5]}{digits[6]}"; - var letter = digits[7] == 0 ? 90 : digits[7] % 2 == 0 ? (digits[7] + 65) : (90 - digits[7]); - return $"{serial}{(char) letter}"; + var serial = $"{digits[0]}{digits[1]}{digits[2]}{digits[3]}{digits[4]}{digits[Math.Abs(5)]}{digits[Math.Abs(6)]}{digits[7]}{(char) letter}"; + + return serial; } private void OnRefreshParts(EntityUid uid, JukeboxComponent component, RefreshPartsEvent args) diff --git a/Content.Shared/SimpleStation14/Jukebox/JukeboxComponent.cs b/Content.Shared/SimpleStation14/Jukebox/JukeboxComponent.cs index 4dc7afafe0..6018d19552 100644 --- a/Content.Shared/SimpleStation14/Jukebox/JukeboxComponent.cs +++ b/Content.Shared/SimpleStation14/Jukebox/JukeboxComponent.cs @@ -1,9 +1,8 @@ -using Content.Shared.SimpleStation14.Prototypes; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Content.Shared.Construction.Prototypes; -using Content.Shared.DeviceLinking; +using Robust.Shared.Utility; namespace Content.Shared.SimpleStation14.Jukebox; @@ -45,7 +44,7 @@ public sealed partial class JukeboxComponent : Component /// The song art to be used when no song is playing. /// [DataField("defaultSongArtPath")] - public string DefaultSongArtPath { get; } = "/Textures/SimpleStation14/JukeboxTracks/default.png"; + public ResPath DefaultSongArtPath { get; } = new("/Textures/SimpleStation14/JukeboxTracks/default.png"); /// /// A colour to be used in the Jukebox's UI. @@ -63,13 +62,13 @@ public sealed partial class JukeboxComponent : Component public Color UiColorAccent { get; } = Color.FromHex("#20181B"); [DataField("uiButtonPlay")] - public string UiButtonPlay { get; } = "/Textures/SimpleStation14/Interface/MediaControls/play.png"; + public ResPath UiButtonPlay { get; } = new("/Textures/SimpleStation14/Interface/MediaControls/play.png"); [DataField("uiButtonPause")] - public string UiButtonPause { get; } = "/Textures/SimpleStation14/Interface/MediaControls/pause.png"; + public ResPath UiButtonPause { get; } = new("/Textures/SimpleStation14/Interface/MediaControls/pause.png"); [DataField("uiButtonSkip")] - public string UiButtonSkip { get; } = "/Textures/SimpleStation14/Interface/MediaControls/skip.png"; + public ResPath UiButtonSkip { get; } = new("/Textures/SimpleStation14/Interface/MediaControls/skip.png"); /// /// Whether or not to include the decorative portion of the UI diff --git a/Content.Shared/SimpleStation14/Prototypes/JukeboxTrackPrototype.cs b/Content.Shared/SimpleStation14/Prototypes/JukeboxTrackPrototype.cs index 92c3d0bdda..0aa5384ac2 100644 --- a/Content.Shared/SimpleStation14/Prototypes/JukeboxTrackPrototype.cs +++ b/Content.Shared/SimpleStation14/Prototypes/JukeboxTrackPrototype.cs @@ -1,6 +1,7 @@ using Robust.Shared.Prototypes; using Robust.Shared.Audio; using Robust.Shared.Serialization; +using Robust.Shared.Utility; namespace Content.Shared.SimpleStation14.Prototypes; @@ -43,7 +44,7 @@ public sealed class JukeboxTrackPrototype : IPrototype, ISerializationHooks /// Path of this track's art file. /// [DataField("artPath")] - public string? ArtPath { get; } = null; + public ResPath? ArtPath { get; } = null; void ISerializationHooks.AfterDeserialization() { diff --git a/Resources/Prototypes/SimpleStation14/Entities/Structures/Machines/Fun/jukebox.yml b/Resources/Prototypes/SimpleStation14/Entities/Structures/Machines/Fun/jukebox.yml index 8c6252f269..53f86013b0 100644 --- a/Resources/Prototypes/SimpleStation14/Entities/Structures/Machines/Fun/jukebox.yml +++ b/Resources/Prototypes/SimpleStation14/Entities/Structures/Machines/Fun/jukebox.yml @@ -26,6 +26,17 @@ name: jukebox description: An old fashioned jukebox. components: + - type: Fixtures + fixtures: + fix1: + shape: + !type:PhysShapeAabb + bounds: "-0.25,-0.45,0.25,0.45" + mask: + - MachineMask + layer: + - MachineLayer + density: 200 - type: Jukebox songs: - DanyaVodovozFunkOMatic @@ -43,7 +54,7 @@ - JonShuemakerTheCurrent - JonShuemakerDrift - JonShuemakerWashedAway - - ApelsinsaftAllAccessVacation + # - ApelsinsaftAllAccessVacation # Brokey - ApelsinsaftAndTheClownSmiledOutsideTheAirlock - ApelsinsaftAtmospherics - ApelsinsaftATinyGreenBeetleBeat