Skip to content
This repository has been archived by the owner on Dec 30, 2024. It is now read-only.

Commit

Permalink
Uses ResPath now
Browse files Browse the repository at this point in the history
Also slightly cleaner, a fix or two
  • Loading branch information
Pspritechologist committed Oct 30, 2023
1 parent 791e9f0 commit 5618361
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
22 changes: 11 additions & 11 deletions Content.Client/SimpleStation14/Jukebox/Ui/JukeboxWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;

Expand Down Expand Up @@ -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 };
Expand All @@ -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.
{
Expand All @@ -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;
Expand Down Expand Up @@ -207,15 +207,15 @@ public void UpdateState(bool repopulateSongs = false)
if (_jukeboxComp.CurrentlyPlayingTrack == null || !_prototype.TryIndex<JukeboxTrackPrototype>(_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;

_timeWillFinish = TimeSpan.Zero;
_timeStopped = TimeSpan.Zero;

PlayButton.TexturePath = _jukeboxComp.UiButtonPlay;
PlayButton.TextureNormal = _resource.GetTexture(_jukeboxComp.UiButtonPlay);

PlayButton.Disabled = true;
SkipButton.Disabled = true;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions Content.Shared/SimpleStation14/Jukebox/JukeboxComponent.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -45,7 +44,7 @@ public sealed partial class JukeboxComponent : Component
/// The song art to be used when no song is playing.
/// </summary>
[DataField("defaultSongArtPath")]
public string DefaultSongArtPath { get; } = "/Textures/SimpleStation14/JukeboxTracks/default.png";
public ResPath DefaultSongArtPath { get; } = new("/Textures/SimpleStation14/JukeboxTracks/default.png");

/// <summary>
/// A colour to be used in the Jukebox's UI.
Expand All @@ -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");

/// <summary>
/// Whether or not to include the decorative portion of the UI
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -43,7 +44,7 @@ public sealed class JukeboxTrackPrototype : IPrototype, ISerializationHooks
/// Path of this track's art file.
/// </summary>
[DataField("artPath")]
public string? ArtPath { get; } = null;
public ResPath? ArtPath { get; } = null;

void ISerializationHooks.AfterDeserialization()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,7 +54,7 @@
- JonShuemakerTheCurrent
- JonShuemakerDrift
- JonShuemakerWashedAway
- ApelsinsaftAllAccessVacation
# - ApelsinsaftAllAccessVacation # Brokey
- ApelsinsaftAndTheClownSmiledOutsideTheAirlock
- ApelsinsaftAtmospherics
- ApelsinsaftATinyGreenBeetleBeat
Expand Down

0 comments on commit 5618361

Please sign in to comment.