Skip to content

Commit

Permalink
Merge branch 'upstream-merge' into 'arumoon-server'
Browse files Browse the repository at this point in the history
Upstream sync + Borgs walk sound fix + TG Maps: Update

See merge request Workbench-Team/space-station-14!125
  • Loading branch information
MilenVolf committed Aug 14, 2023
2 parents 5f63181 + 23d5434 commit 58d2ee5
Show file tree
Hide file tree
Showing 505 changed files with 48,213 additions and 43,213 deletions.
17 changes: 17 additions & 0 deletions Content.Client/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
using Content.Shared.Administration;
using JetBrains.Annotations;
using Robust.Shared.Network;
using Robust.Shared.Timing;

namespace Content.Client.Administration.Systems
{
[UsedImplicitly]
public sealed class BwoinkSystem : SharedBwoinkSystem
{
[Dependency] private readonly IGameTiming _timing = default!;

public event EventHandler<BwoinkTextMessage>? OnBwoinkTextMessageRecieved;
private (TimeSpan Timestamp, bool Typing) _lastTypingUpdateSent;

protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs)
{
Expand All @@ -20,6 +24,19 @@ public void Send(NetUserId channelId, string text)
// Reuse the channel ID as the 'true sender'.
// Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help.
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text));
SendInputTextUpdated(channelId, false);
}

public void SendInputTextUpdated(NetUserId channel, bool typing)
{
if (_lastTypingUpdateSent.Typing == typing &&
_lastTypingUpdateSent.Timestamp + TimeSpan.FromSeconds(1) > _timing.RealTime)
{
return;
}

_lastTypingUpdateSent = (_timing.RealTime, typing);
RaiseNetworkEvent(new BwoinkClientTypingUpdated(channel, typing));
}
}
}
1 change: 1 addition & 0 deletions Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Orientation="Vertical"
HorizontalExpand="True">
<OutputPanel Name="TextOutput" VerticalExpand="true" />
<RichTextLabel Name="TypingIndicator" Access="Public" />
<HistoryLineEdit Name="SenderLineEdit" />
<RichTextLabel Name="RelayedToDiscordLabel" Access="Public" Visible="False" />
</BoxContainer>
59 changes: 59 additions & 0 deletions Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client.Administration.UI.Bwoink
Expand All @@ -13,6 +14,8 @@ public sealed partial class BwoinkPanel : BoxContainer

public int Unread { get; private set; } = 0;
public DateTime LastMessage { get; private set; } = DateTime.MinValue;
private List<string> PeopleTyping { get; set; } = new();
public event Action<string>? InputTextChanged;

public BwoinkPanel(Action<string> messageSender)
{
Expand All @@ -32,6 +35,8 @@ public BwoinkPanel(Action<string> messageSender)
Unread = 0;
};
SenderLineEdit.OnTextEntered += Input_OnTextEntered;
SenderLineEdit.OnTextChanged += Input_OnTextChanged;
UpdateTypingIndicator();
}

private void Input_OnTextEntered(LineEdit.LineEditEventArgs args)
Expand All @@ -43,6 +48,11 @@ private void Input_OnTextEntered(LineEdit.LineEditEventArgs args)
SenderLineEdit.Clear();
}

private void Input_OnTextChanged(LineEdit.LineEditEventArgs args)
{
InputTextChanged?.Invoke(args.Text);
}

public void ReceiveLine(SharedBwoinkSystem.BwoinkTextMessage message)
{
if (!Visible)
Expand All @@ -53,5 +63,54 @@ public void ReceiveLine(SharedBwoinkSystem.BwoinkTextMessage message)
TextOutput.AddMessage(formatted);
LastMessage = message.SentAt;
}

private void UpdateTypingIndicator()
{
var msg = new FormattedMessage();
msg.PushColor(Color.LightGray);

var text = PeopleTyping.Count == 0
? string.Empty
: Loc.GetString("bwoink-system-typing-indicator",
("players", string.Join(", ", PeopleTyping)),
("count", PeopleTyping.Count));

msg.AddText(text);
msg.Pop();

TypingIndicator.SetMessage(msg);
}

public void UpdatePlayerTyping(string name, bool typing)
{
if (typing)
{
if (PeopleTyping.Contains(name))
return;

PeopleTyping.Add(name);
Timer.Spawn(TimeSpan.FromSeconds(10), () =>
{
if (Disposed)
return;
PeopleTyping.Remove(name);
UpdateTypingIndicator();
});
}
else
{
PeopleTyping.Remove(name);
}

UpdateTypingIndicator();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

InputTextChanged = null;
}
}
}
18 changes: 12 additions & 6 deletions Content.Client/Administration/UI/Logs/AdminLogsControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,18 @@ private void SetTypes(LogType[] types)
public void SetPlayers(Dictionary<Guid, string> players)
{
var buttons = new SortedSet<AdminLogPlayerButton>(_adminLogPlayerButtonComparer);
var allSelected = true;

foreach (var control in PlayersContainer.Children.ToArray())
{
if (control is not AdminLogPlayerButton player ||
!players.Remove(player.Id))
{
if (control is not AdminLogPlayerButton player)
continue;

if (!SelectedPlayers.Contains(player.Id))
allSelected = false;

if (!players.Remove(player.Id))
continue;
}

buttons.Add(player);
}
Expand All @@ -437,10 +441,12 @@ public void SetPlayers(Dictionary<Guid, string> players)
var button = new AdminLogPlayerButton(id)
{
Text = name,
Pressed = true
Pressed = allSelected
};

SelectedPlayers.Add(id);
if (allSelected)
SelectedPlayers.Add(id);

button.OnPressed += PlayerButtonPressed;

buttons.Add(button);
Expand Down
68 changes: 60 additions & 8 deletions Content.Client/Administration/UI/Notes/NoteEdit.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Database;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
Expand All @@ -24,6 +25,9 @@ public NoteEdit(SharedAdminNote? note, string playerName, bool canCreate, bool c
RobustXamlLoader.Load(this);
PlayerName = playerName;
Title = Loc.GetString("admin-note-editor-title-new", ("player", PlayerName));
IsCreating = note is null;
CanCreate = canCreate;
CanEdit = canEdit;

ResetSubmitButton();

Expand All @@ -33,6 +37,7 @@ public NoteEdit(SharedAdminNote? note, string playerName, bool canCreate, bool c
TypeOption.OnItemSelected += OnTypeChanged;


SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-select"), -1);
SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-none"), (int) Shared.Database.NoteSeverity.None);
SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-low"), (int) Shared.Database.NoteSeverity.Minor);
SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-medium"), (int) Shared.Database.NoteSeverity.Medium);
Expand All @@ -42,10 +47,11 @@ public NoteEdit(SharedAdminNote? note, string playerName, bool canCreate, bool c
PermanentCheckBox.OnPressed += OnPermanentPressed;
SecretCheckBox.OnPressed += OnSecretPressed;
SubmitButton.OnPressed += OnSubmitButtonPressed;
SubmitButton.OnMouseEntered += OnSubmitButtonMouseEntered;
SubmitButton.OnMouseExited += OnSubmitButtonMouseExited;

if (note is null && !canCreate)
{
SubmitButton.Disabled = true;
TypeOption.Disabled = true;
SeverityOption.Disabled = true;
}
Expand Down Expand Up @@ -77,21 +83,45 @@ public NoteEdit(SharedAdminNote? note, string playerName, bool canCreate, bool c
UpdatePermanentCheckboxFields();
ExpiryLineEdit.Text = ExpiryTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
}

if (!canEdit)
{
SubmitButton.Disabled = true;
}
}

UpdateSubmitButton();
}

private void OnSubmitButtonMouseEntered(GUIMouseHoverEventArgs args)
{
if (!SubmitButton.Disabled)
return;

SeverityOption.ModulateSelfOverride = Color.Red;
}

private void OnSubmitButtonMouseExited(GUIMouseHoverEventArgs args)
{
SeverityOption.ModulateSelfOverride = null;
}

private NoteSeverity? _noteSeverity = null;

private string PlayerName { get; }
private int NoteId { get; }
private bool IsSecret { get; set; }
private NoteType NoteType { get; set; }
private NoteSeverity? NoteSeverity { get; set; } = Shared.Database.NoteSeverity.None;

private NoteSeverity? NoteSeverity
{
get => _noteSeverity;
set
{
_noteSeverity = value;
UpdateSubmitButton();
}
}
private DateTime? ExpiryTime { get; set; }
private TimeSpan? DeleteResetOn { get; set; }
private bool IsCreating { get; set; }
private bool CanCreate { get; set; }
private bool CanEdit { get; set; }

private void OnTypeChanged(OptionButton.ItemSelectedEventArgs args)
{
Expand Down Expand Up @@ -153,7 +183,7 @@ private void OnSecretPressed(BaseButton.ButtonEventArgs _)

private void OnSeverityChanged(OptionButton.ItemSelectedEventArgs args)
{
NoteSeverity = (NoteSeverity) args.Id;
NoteSeverity = args.Id == -1 ? NoteSeverity = null : (NoteSeverity) args.Id;
SeverityOption.SelectId(args.Id);
}

Expand Down Expand Up @@ -192,6 +222,26 @@ protected override void FrameUpdate(FrameEventArgs args)
}
}

/// <summary>
/// Updates whether or not the submit button is disabled.
/// </summary>
private void UpdateSubmitButton()
{
if (!CanEdit)
{
SubmitButton.Disabled = true;
return;
}

if (IsCreating && !CanCreate)
{
SubmitButton.Disabled = true;
return;
}

SubmitButton.Disabled = NoteSeverity == null;
}

private void ResetSubmitButton()
{
SubmitButton.Text = Loc.GetString("admin-note-editor-submit");
Expand Down Expand Up @@ -236,6 +286,8 @@ protected override void Dispose(bool disposing)
PermanentCheckBox.OnPressed -= OnPermanentPressed;
SecretCheckBox.OnPressed -= OnSecretPressed;
SubmitButton.OnPressed -= OnSubmitButtonPressed;
SubmitButton.OnMouseEntered -= OnSubmitButtonMouseEntered;
SubmitButton.OnMouseExited -= OnSubmitButtonMouseExited;

SubmitPressed = null;
}
Expand Down
4 changes: 3 additions & 1 deletion Content.Client/DragDrop/DragDropSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using System.Linq;
using System.Numerics;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;

Expand Down Expand Up @@ -57,7 +56,10 @@ public sealed class DragDropSystem : SharedDragDropSystem
// mousedown event so it can be treated like a regular click
private const float MaxMouseDownTimeForReplayingClick = 0.85f;

[ValidatePrototypeId<ShaderPrototype>]
private const string ShaderDropTargetInRange = "SelectionOutlineInrange";

[ValidatePrototypeId<ShaderPrototype>]
private const string ShaderDropTargetOutOfRange = "SelectionOutline";

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/Fax/AdminUI/AdminFaxEui.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.Eui;
using Content.Client.Eui;
using Content.Shared.Eui;
using Content.Shared.Fax;
using JetBrains.Annotations;
Expand All @@ -15,7 +15,8 @@ public AdminFaxEui()
_window = new AdminFaxWindow();
_window.OnClose += () => SendMessage(new AdminFaxEuiMsg.Close());
_window.OnFollowFax += uid => SendMessage(new AdminFaxEuiMsg.Follow(uid));
_window.OnMessageSend += args => SendMessage(new AdminFaxEuiMsg.Send(args.uid, args.title, args.from, args.message, args.stamp));
_window.OnMessageSend += args => SendMessage(new AdminFaxEuiMsg.Send(args.uid, args.title,
args.stampedBy, args.message, args.stampSprite, args.stampColor));
}

public override void Opened()
Expand Down
4 changes: 3 additions & 1 deletion Content.Client/Fax/AdminUI/AdminFaxWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<DefaultWindow xmlns="https://spacestation14.io"
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc admin-fax-title}"
MinWidth="400">
<BoxContainer Orientation="Vertical" VerticalExpand="True">
Expand All @@ -21,6 +21,8 @@
<Control MinWidth="5" />
<OptionButton Name="StampSelector" HorizontalExpand="True" />
</BoxContainer>
<Label Text="{Loc admin-fax-stamp-color}" />
<ColorSelectorSliders Margin="12 0 0 0" Name="StampColorSelector" Color="#BB3232"/>
<Control MinHeight="10" />
<Button Name="SendButton" Text="{Loc admin-fax-send}"></Button>
</BoxContainer>
Expand Down
10 changes: 7 additions & 3 deletions Content.Client/Fax/AdminUI/AdminFaxWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Fax;
using Content.Shared.Fax;
using Robust.Client.AutoGenerated;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
Expand All @@ -13,7 +13,7 @@ public sealed partial class AdminFaxWindow : DefaultWindow
{
private const string StampsRsiPath = "/Textures/Objects/Misc/bureaucracy.rsi";

public Action<(EntityUid uid, string title, string from, string message, string stamp)>? OnMessageSend;
public Action<(EntityUid uid, string title, string stampedBy, string message, string stampSprite, Color stampColor)>? OnMessageSend;
public Action<EntityUid>? OnFollowFax;

public AdminFaxWindow()
Expand All @@ -28,6 +28,9 @@ public AdminFaxWindow()
FollowButton.OnPressed += FollowFax;
SendButton.OnPressed += SendMessage;

// Don't use this, but ColorSelectorSliders requires it:
StampColorSelector.OnColorChanged += (Color) => {};

var loc = IoCManager.Resolve<ILocalizationManager>();
MessageEdit.Placeholder = new Rope.Leaf(loc.GetString("admin-fax-message-placeholder")); // TextEdit work only with Nodes
}
Expand Down Expand Up @@ -90,6 +93,7 @@ private void SendMessage(BaseButton.ButtonEventArgs obj)
return;

var from = FromEdit.Text;
OnMessageSend?.Invoke((faxUid.Value, title, from, message, stamp));
var stampColor = StampColorSelector.Color;
OnMessageSend?.Invoke((faxUid.Value, title, from, message, stamp, stampColor));
}
}
Loading

0 comments on commit 58d2ee5

Please sign in to comment.