Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into plasmaman
Browse files Browse the repository at this point in the history
  • Loading branch information
angelofallars committed Jan 17, 2025
2 parents a0d6109 + 0ba8772 commit d14271b
Show file tree
Hide file tree
Showing 192 changed files with 1,896 additions and 156 deletions.
16 changes: 8 additions & 8 deletions Content.Client/Chemistry/UI/ChemMasterWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
MinSize="620 670"
MinSize="620 770"
Title="{Loc 'chem-master-bound-user-interface-title'}">
<TabContainer Name="Tabs" Margin="5 5 7 5">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="5" SeparationOverride="10">
Expand All @@ -13,12 +13,12 @@
<Button MinSize="80 0" Name="InputEjectButton" Access="Public" Text="{Loc 'chem-master-window-eject-button'}" />
</BoxContainer>

<PanelContainer VerticalExpand="True" MinSize="0 200">
<PanelContainer VerticalExpand="True" MinSize="0 300">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>

<ScrollContainer HorizontalExpand="True" MinSize="0 200">
<ScrollContainer HorizontalExpand="True" MinSize="0 300">
<!-- Initially empty, when server sends state data this will have container contents and fill volume.-->
<BoxContainer Name="InputContainerInfo" Orientation="Vertical" Margin="4" HorizontalExpand="True">
<Label Text="{Loc 'chem-master-window-no-container-loaded-text'}" />
Expand All @@ -38,12 +38,12 @@
</BoxContainer>

<!-- Buffer info -->
<PanelContainer VerticalExpand="True" MinSize="0 200">
<PanelContainer VerticalExpand="True" MinSize="0 300">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>

<ScrollContainer HorizontalExpand="True" MinSize="0 200">
<ScrollContainer HorizontalExpand="True" MinSize="0 300">
<!-- Buffer reagent list -->
<BoxContainer Name="BufferInfo" Orientation="Vertical" Margin="4" HorizontalExpand="True">
<Label Text="{Loc 'chem-master-window-buffer-empty-text'}" />
Expand All @@ -60,12 +60,12 @@
<Button MinSize="80 0" Name="OutputEjectButton" Access="Public" Text="{Loc 'chem-master-window-eject-button'}" />
</BoxContainer>

<PanelContainer VerticalExpand="True" MinSize="0 200">
<PanelContainer VerticalExpand="True" MinSize="0 300">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>

<ScrollContainer HorizontalExpand="True" MinSize="0 200">
<ScrollContainer HorizontalExpand="True" MinSize="0 300">
<!-- Initially empty, when server sends state data this will have container contents and fill volume.-->
<BoxContainer Name="OutputContainerInfo" Orientation="Vertical" Margin="4" HorizontalExpand="True">
<Label Text="{Loc 'chem-master-window-no-container-loaded-text'}" />
Expand Down Expand Up @@ -129,4 +129,4 @@
</PanelContainer>
</BoxContainer>
</TabContainer>
</controls:FancyWindow>
</controls:FancyWindow>
5 changes: 3 additions & 2 deletions Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@ private ReagentButton MakeReagentButton(string text, ChemMasterReagentAmount amo
private List<ReagentButton> CreateReagentTransferButtons(ReagentId reagent, bool isBuffer, bool addReagentButtons)
{
if (!addReagentButtons)
return new List<ReagentButton>(); // Return an empty list if reagentTransferButton creation is disabled.
return new(); // Return an empty list if reagentTransferButton creation is disabled.

var buttons = new List<ReagentButton>();
var names = Enum.GetNames<ChemMasterReagentAmount>();
var values = Enum.GetValues<ChemMasterReagentAmount>();

for (int i = 0; i < names.Length; i++)
{
var name = names[i];
var isNumber = int.TryParse(names[i].Substring(1), out int number);
var name = isNumber ? number.ToString() : names[i];
var reagentAmount = values[i];

var reagentTransferButton = MakeReagentButton(
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/GameTicking/Managers/ClientGameTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Client.Lobby;
using Content.Client.RoundEnd;
using Content.Shared.GameTicking;
using Content.Shared.GameTicking.Prototypes;
using Content.Shared.GameWindow;
using JetBrains.Annotations;
using Robust.Client.Graphics;
Expand All @@ -26,7 +27,7 @@ public sealed class ClientGameTicker : SharedGameTicker
[ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public string? RestartSound { get; private set; }
[ViewVariables] public string? LobbyBackground { get; private set; }
[ViewVariables] public LobbyBackgroundPrototype? LobbyBackground { get; private set; }
[ViewVariables] public bool DisallowedLateJoin { get; private set; }
[ViewVariables] public string? ServerInfoBlob { get; private set; }
[ViewVariables] public TimeSpan StartTime { get; private set; }
Expand Down
34 changes: 28 additions & 6 deletions Content.Client/Lobby/LobbyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;


namespace Content.Client.Lobby
{
public sealed class LobbyState : Robust.Client.State.State
Expand All @@ -25,6 +24,7 @@ public sealed class LobbyState : Robust.Client.State.State
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IVoteManager _voteManager = default!;

private ISawmill _sawmill = default!;
private ClientGameTicker _gameTicker = default!;
private ContentAudioSystem _contentAudioSystem = default!;

Expand All @@ -42,6 +42,7 @@ protected override void Startup()
_gameTicker = _entityManager.System<ClientGameTicker>();
_contentAudioSystem = _entityManager.System<ContentAudioSystem>();
_contentAudioSystem.LobbySoundtrackChanged += UpdateLobbySoundtrackInfo;
_sawmill = Logger.GetSawmill("lobby");

chatController.SetMainChat(true);

Expand Down Expand Up @@ -113,7 +114,7 @@ public override void FrameUpdate(FrameEventArgs e)
return;
}

Lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-not-started");
Lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-not-started");
string text;

if (_gameTicker.Paused)
Expand Down Expand Up @@ -161,7 +162,7 @@ private void UpdateLobbyUi()
else
{
Lobby!.StartTime.Text = string.Empty;
Lobby!.ReadyButton.Text = Loc.GetString(Lobby!.ReadyButton.Pressed ? "lobby-state-player-status-ready": "lobby-state-player-status-not-ready");
Lobby!.ReadyButton.Text = Loc.GetString(Lobby!.ReadyButton.Pressed ? "lobby-state-player-status-ready" : "lobby-state-player-status-not-ready");
Lobby!.ReadyButton.ToggleMode = true;
Lobby!.ReadyButton.Disabled = false;
Lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady;
Expand Down Expand Up @@ -200,10 +201,31 @@ private void UpdateLobbySoundtrackInfo(LobbySoundtrackChangedEvent ev)
private void UpdateLobbyBackground()
{
if (_gameTicker.LobbyBackground != null)
Lobby!.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground);
else
Lobby!.Background.Texture = null;
{
Lobby!.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground.Background);

var lobbyBackground = _gameTicker.LobbyBackground;

var name = string.IsNullOrEmpty(lobbyBackground.Name)
? Loc.GetString("lobby-state-background-unknown-title")
: lobbyBackground.Name;

var artist = string.IsNullOrEmpty(lobbyBackground.Artist)
? Loc.GetString("lobby-state-background-unknown-artist")
: lobbyBackground.Artist;

var markup = Loc.GetString("lobby-state-background-text",
("backgroundName", name),
("backgroundArtist", artist));

Lobby!.LobbyBackground.SetMarkup(markup);

return;
}

_sawmill.Warning("_gameTicker.LobbyBackground was null! No lobby background selected.");
Lobby!.Background.Texture = null;
Lobby!.LobbyBackground.SetMarkup(Loc.GetString("lobby-state-background-no-background-text"));
}

private void SetReady(bool newReady)
Expand Down
5 changes: 4 additions & 1 deletion Content.Client/Lobby/UI/LobbyGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@
<!-- Vertical Padding-->
<Control VerticalExpand="True" />
<!-- Left Bot Panel -->
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom">
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" SeparationOverride="4">
<info:DevInfoBanner Name="DevInfoBanner" VerticalExpand="false" Margin="3 3 3 3" />
<PanelContainer StyleClasses="AngleRect">
<RichTextLabel Name="LobbySong" Access="Public" HorizontalAlignment="Center" />
</PanelContainer>
<PanelContainer StyleClasses="AngleRect">
<RichTextLabel Name="LobbyBackground" Access="Public" HorizontalAlignment="Center" />
</PanelContainer>
</BoxContainer>
</Control>
<!-- Character setup state -->
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Lobby/UI/LobbyGui.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public LobbyGui()
SetAnchorPreset(Background, LayoutPreset.Wide);

LobbySong.SetMarkup(Loc.GetString("lobby-state-song-no-song-text"));
LobbyBackground.SetMarkup(Loc.GetString("lobby-state-background-no-background-text"));

LeaveButton.OnPressed += _ => _consoleHost.ExecuteCommand("disconnect");
OptionsButton.OnPressed += _ => UserInterfaceManager.GetUIController<OptionsUIController>().ToggleWindow();
Expand Down
62 changes: 62 additions & 0 deletions Content.Client/_NC/Radio/UI/HandheldRadioBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Content.Shared._NC.Radio;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

namespace Content.Client._NC.Radio.UI;


[UsedImplicitly]
public sealed class HandheldRadioBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private HandheldRadioMenu? _menu;

public HandheldRadioBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{

}

protected override void Open()
{
base.Open();

_menu = new();

_menu.OnMicPressed += enabled =>
{
SendMessage(new ToggleHandheldRadioMicMessage(enabled));
};
_menu.OnSpeakerPressed += enabled =>
{
SendMessage(new ToggleHandheldRadioSpeakerMessage(enabled));
};
_menu.OnFrequencyChanged += frequency =>
{
if (int.TryParse(frequency.Trim(), out var intFreq) && intFreq > 0)
SendMessage(new SelectHandheldRadioFrequencyMessage(intFreq));
else
SendMessage(new SelectHandheldRadioFrequencyMessage(-1)); // Query the current frequency
};

_menu.OnClose += Close;
_menu.OpenCentered();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_menu?.Close();
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not HandheldRadioBoundUIState msg)
return;

_menu?.Update(msg);
}
}
29 changes: 29 additions & 0 deletions Content.Client/_NC/Radio/UI/HandheldRadioMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'handheld-radio-menu-title'}"
MinSize="200 150"
SetSize="200 150">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
Margin="5 0 5 0">
<Control MinHeight="10"/>
<BoxContainer Orientation="Vertical" SeparationOverride="4" MinWidth="150">
<Label Name="CurrentTextFrequency" Text="{Loc 'handheld-radio-current-text-frequency'}" />
<LineEdit Name="FrequencyLineEdit" Text="1330"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" HorizontalAlignment="Right" Margin="5 0 5 5">
<Button Name="MicButton" ToggleMode="True" Text="{Loc 'handheld-radio-button-text-mic'}" StyleClasses="OpenRight" MinWidth="70"/>
<Button Name="SpeakerButton" ToggleMode="True" Text="{Loc 'handheld-radio-button-text-speaker'}" StyleClasses="OpenLeft" MinWidth="70"/>
</BoxContainer>
<BoxContainer Orientation="Vertical">
<PanelContainer StyleClasses="LowDivider" />
<BoxContainer Orientation="Horizontal" Margin="10 2 5 0" VerticalAlignment="Bottom">
<Label Text="{Loc 'handheld-radio-flavor-text-left'}" StyleClasses="WindowFooterText"
HorizontalAlignment="Left" HorizontalExpand="True" Margin="0 0 5 0" />
<TextureRect StyleClasses="NTLogoDark" Stretch="KeepAspectCentered"
VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="19 19"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
55 changes: 55 additions & 0 deletions Content.Client/_NC/Radio/UI/HandheldRadioMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Content.Client.UserInterface.Controls;
using Content.Shared._NC.Radio;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;

namespace Content.Client._NC.Radio.UI;
// TODO: Fix silly ui update issues
[GenerateTypedNameReferences]
public sealed partial class HandheldRadioMenu : FancyWindow
{

public event Action<bool>? OnMicPressed;
public event Action<bool>? OnSpeakerPressed;
public event Action<string>? OnFrequencyChanged;

private string _lastFrequency = "1330";

public HandheldRadioMenu()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

MicButton.OnPressed += args => OnMicPressed?.Invoke(args.Button.Pressed);
SpeakerButton.OnPressed += args => OnSpeakerPressed?.Invoke(args.Button.Pressed);

FrequencyLineEdit.OnTextEntered += e => OnFrequencyChanged?.Invoke(e.Text);
FrequencyLineEdit.OnTextChanged += ValidateText;
FrequencyLineEdit.OnFocusExit += e => OnFrequencyChanged?.Invoke(e.Text);
}

private void ValidateText(LineEdit.LineEditEventArgs args)
{
if (!int.TryParse(args.Text, out int frequency))
{
FrequencyLineEdit.SetText(_lastFrequency);
return;
}

_lastFrequency = args.Text;
}

public void Update(HandheldRadioBoundUIState state)
{
if (state.MicEnabled != MicButton.Pressed)
MicButton.Pressed = state.MicEnabled;

if (state.SpeakerEnabled != SpeakerButton.Pressed)
SpeakerButton.Pressed = state.SpeakerEnabled;

if (state.Frequency.ToString() != FrequencyLineEdit.Text)
FrequencyLineEdit.Text = state.Frequency.ToString();
}
}
2 changes: 1 addition & 1 deletion Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void OnDamageExamine(EntityUid uid, DamageOtherOnHitComponent component,

var staminaCostMarkup = FormattedMessage.FromMarkupOrThrow(
Loc.GetString("damage-stamina-cost",
("type", Loc.GetString("damage-throw")), ("cost", component.StaminaCost)));
("type", Loc.GetString("damage-throw")), ("cost", Math.Round(component.StaminaCost, 2).ToString("0.##"))));
args.Message.PushNewline();
args.Message.AddMessage(staminaCostMarkup);
}
Expand Down
22 changes: 14 additions & 8 deletions Content.Server/GameTicking/GameTicker.LobbyBackground.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Server.GameTicking.Prototypes;
using Content.Shared.GameTicking.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using System.Linq;
Expand All @@ -8,24 +8,30 @@ namespace Content.Server.GameTicking;
public sealed partial class GameTicker
{
[ViewVariables]
public string? LobbyBackground { get; private set; }
public LobbyBackgroundPrototype? LobbyBackground { get; private set; }

[ViewVariables]
private List<ResPath>? _lobbyBackgrounds;
private List<LobbyBackgroundPrototype> _lobbyBackgrounds = [];

private static readonly string[] WhitelistedBackgroundExtensions = new string[] {"png", "jpg", "jpeg", "webp"};

private void InitializeLobbyBackground()
{
_lobbyBackgrounds = _prototypeManager.EnumeratePrototypes<LobbyBackgroundPrototype>()
.Select(x => x.Background)
.Where(x => WhitelistedBackgroundExtensions.Contains(x.Extension))
.ToList();
foreach (var prototype in _prototypeManager.EnumeratePrototypes<LobbyBackgroundPrototype>())
{
if (!WhitelistedBackgroundExtensions.Contains(prototype.Background.Extension))
{
_sawmill.Warning($"Lobby background '{prototype.ID}' has an invalid extension '{prototype.Background.Extension}' and will be ignored.");
continue;
}

_lobbyBackgrounds.Add(prototype);
}

RandomizeLobbyBackground();
}

private void RandomizeLobbyBackground() {
LobbyBackground = _lobbyBackgrounds!.Any() ? _robustRandom.Pick(_lobbyBackgrounds!).ToString() : null;
LobbyBackground = _lobbyBackgrounds!.Any() ? _robustRandom.Pick(_lobbyBackgrounds!) : null;
}
}
Loading

0 comments on commit d14271b

Please sign in to comment.