Skip to content

Commit

Permalink
Merge branch 'master' into visions
Browse files Browse the repository at this point in the history
  • Loading branch information
Spatison authored Jan 8, 2025
2 parents 4b27105 + 70f7298 commit 6791eb9
Show file tree
Hide file tree
Showing 50 changed files with 1,104 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<cc:UICommandButton Command="callshuttle" Text="{Loc admin-player-actions-window-shuttle}" WindowType="{x:Type at:AdminShuttleWindow}"/>
<cc:CommandButton Command="adminlogs" Text="{Loc admin-player-actions-window-admin-logs}"/>
<cc:CommandButton Command="faxui" Text="{Loc admin-player-actions-window-admin-fax}"/>
<cc:CommandButton Command="timetransferpanel" Text="{Loc admin-player-actions-window-time-transfer}"/>
</GridContainer>
</BoxContainer>
</Control>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc nano-chat-new-title}"
Title="{Loc nano-chat-edit-title}"
MinSize="300 200">
<PanelContainer StyleClasses="AngleRect">
<BoxContainer Orientation="Vertical" Margin="4">
Expand Down Expand Up @@ -42,8 +42,8 @@
Text="{Loc nano-chat-cancel}"
StyleClasses="OpenRight"
MinSize="80 0" />
<Button Name="CreateButton"
Text="{Loc nano-chat-create}"
<Button Name="ConfirmButton"
Text="{Loc nano-chat-confirm}"
StyleClasses="OpenLeft"
MinSize="80 0"
Disabled="True" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Linq;
using Content.Client.DeltaV.NanoChat;
using Content.Shared.Access.Components;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
Expand All @@ -9,9 +9,14 @@ namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;
[GenerateTypedNameReferences]
public sealed partial class EditChatPopup : DefaultWindow
{
private const int MaxInputLength = 16;
private const int MaxNumberLength = 4;

// Used to see if the user input is different from the original data
// to check if the user can submit
private string _originalNumber = "";
private string _originalName = "";
private string _originalJob = "";

public event Action<uint, string, string?>? OnContactEdited;

public EditChatPopup()
Expand All @@ -23,22 +28,23 @@ public EditChatPopup()

// Button handlers
CancelButton.OnPressed += _ => Close();
CreateButton.OnPressed += _ => EditChat();
ConfirmButton.OnPressed += _ => EditChat();

// Input validation
NameInput.OnTextChanged += _ => ValidateInputs();

NameInput.OnTextChanged += args =>
{
if (args.Text.Length > MaxInputLength)
NameInput.Text = args.Text[..MaxInputLength];
if (args.Text.Length > IdCardConsoleComponent.MaxFullNameLength)
NameInput.Text = args.Text[..IdCardConsoleComponent.MaxFullNameLength];
ValidateInputs();
};

JobInput.OnTextChanged += args =>
{
if (args.Text.Length > MaxInputLength)
JobInput.Text = args.Text[..MaxInputLength];
if (args.Text.Length > IdCardConsoleComponent.MaxJobTitleLength)
JobInput.Text = args.Text[..IdCardConsoleComponent.MaxJobTitleLength];
ValidateInputs();
};

NumberInput.OnTextChanged += args =>
Expand All @@ -58,10 +64,15 @@ public EditChatPopup()
private void ValidateInputs()
{
var isValid = !string.IsNullOrWhiteSpace(NumberInput.Text) &&
!string.IsNullOrWhiteSpace(NameInput.Text) &&
uint.TryParse(NumberInput.Text, out _);

CreateButton.Disabled = !isValid;
!string.IsNullOrWhiteSpace(NameInput.Text) &&
NumberInput.Text.Length == MaxNumberLength &&
uint.TryParse(NumberInput.Text, out _) &&
// Only valid if there are any changes
(NumberInput.Text != _originalNumber ||
NameInput.Text != _originalName ||
JobInput.Text != _originalJob);

ConfirmButton.Disabled = !isValid;
}

private void EditChat()
Expand All @@ -83,7 +94,21 @@ public void ClearInputs()
ValidateInputs();
}

public void SetNumberInput(string newNumber) => NumberInput.Text = newNumber;
public void SetNameInput(string newName) => NameInput.Text = newName;
public void SetJobInput(string newJob) => JobInput.Text = newJob;
public void SetNumberInput(string newNumber)
{
NumberInput.Text = newNumber.PadLeft(MaxNumberLength, '0');
_originalNumber = newNumber;
}

public void SetNameInput(string newName)
{
NameInput.Text = newName;
_originalName = newName;
}

public void SetJobInput(string newJob)
{
JobInput.Text = newJob;
_originalJob = newJob;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;
[GenerateTypedNameReferences]
public sealed partial class NanoChatEntry : BoxContainer
{
private const int MaxNameLength = 14;
private const int MaxJobLength = 20;

public event Action<uint>? OnPressed;
private uint _number;
private Action<EventArgs>? _pressHandler;
Expand All @@ -29,11 +32,19 @@ public void SetRecipient(NanoChatRecipient recipient, uint number, bool isSelect
_pressHandler = _ => OnPressed?.Invoke(_number);
ChatButton.OnPressed += _pressHandler;

NameLabel.Text = recipient.Name;
JobLabel.Text = recipient.JobTitle ?? "";
NameLabel.Text = Truncate(recipient.Name, MaxNameLength);
JobLabel.Text = Truncate(recipient.JobTitle ?? "", MaxJobLength);
JobLabel.Visible = !string.IsNullOrEmpty(recipient.JobTitle);
UnreadIndicator.Visible = recipient.HasUnread;

ChatButton.ModulateSelfOverride = isSelected ? NanoChatMessageBubble.OwnMessageColor : null;
}

/// <summary>
/// Truncates a string to a maximum length.
/// </summary>
private static string Truncate(string text, int maxLength) =>
text.Length <= maxLength
? text
: text[..(maxLength - 3)] + "...";
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@
VerticalAlignment="Center"
Margin="0 0 8 0" />
<Button Name="EditChatButton"
Text="E"
MaxSize="32 32"
Visible="False"
StyleClasses="OpenBoth"
Margin="0 0 4 0"
ToolTip="{Loc nano-chat-edit}">
<TextureRect StyleClasses="ButtonSquare"
TexturePath="/Textures/Interface/VerbIcons/edit.svg.png"
Stretch="KeepAspectCentered"
MinSize="18 18" />
</Button>
<Button Name="DeleteChatButton"
MaxSize="32 32"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public sealed partial class NanoChatUiFragment : BoxContainer
{
[Dependency] private readonly IGameTiming _timing = default!;

private const int MaxMessageLength = 256;

private readonly NewChatPopup _newChatPopup;
private readonly EditChatPopup _editChatPopup;
private uint? _currentChat;
Expand Down Expand Up @@ -50,8 +48,7 @@ private void SetupEventHandlers()

_editChatPopup.OnContactEdited += (number, name, job) =>
{
DeleteCurrentChat();
ActionSendUiMessage?.Invoke(NanoChatUiMessageType.NewChat, number, name, job);
ActionSendUiMessage?.Invoke(NanoChatUiMessageType.EditChat, number, name, job);
};

NewChatButton.OnPressed += _ =>
Expand All @@ -71,18 +68,18 @@ private void SetupEventHandlers()
{
var length = args.Text.Length;
var isValid = !string.IsNullOrWhiteSpace(args.Text) &&
length <= MaxMessageLength &&
length <= NanoChatMessage.MaxContentLength &&
(_currentChat != null || _pendingChat != null);

SendButton.Disabled = !isValid;

// Show character count when over limit
CharacterCount.Visible = length > MaxMessageLength;
if (length > MaxMessageLength)
CharacterCount.Visible = length > NanoChatMessage.MaxContentLength;
if (length > NanoChatMessage.MaxContentLength)
{
CharacterCount.Text = Loc.GetString("nano-chat-message-too-long",
("current", length),
("max", MaxMessageLength));
("max", NanoChatMessage.MaxContentLength));
CharacterCount.StyleClasses.Add("LabelDanger");
}
};
Expand All @@ -100,6 +97,12 @@ private void SendMessage()
return;

var messageContent = MessageInput.Text;
if (!string.IsNullOrWhiteSpace(messageContent))
{
messageContent = messageContent.Trim();
if (messageContent.Length > NanoChatMessage.MaxContentLength)
messageContent = messageContent[..NanoChatMessage.MaxContentLength];
}

// Add predicted message
var predictedMessage = new NanoChatMessage(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Shared.Access.Components;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
Expand All @@ -8,7 +9,6 @@ namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;
[GenerateTypedNameReferences]
public sealed partial class NewChatPopup : DefaultWindow
{
private const int MaxInputLength = 16;
private const int MaxNumberLength = 4; // i hardcoded it to be 4 so suffer

public event Action<uint, string, string?>? OnChatCreated;
Expand Down Expand Up @@ -44,22 +44,23 @@ public NewChatPopup()

NameInput.OnTextChanged += args =>
{
if (args.Text.Length > MaxInputLength)
NameInput.Text = args.Text[..MaxInputLength];
if (args.Text.Length > IdCardConsoleComponent.MaxFullNameLength)
NameInput.Text = args.Text[..IdCardConsoleComponent.MaxFullNameLength];
ValidateInputs();
};

JobInput.OnTextChanged += args =>
{
if (args.Text.Length > MaxInputLength)
JobInput.Text = args.Text[..MaxInputLength];
if (args.Text.Length > IdCardConsoleComponent.MaxJobTitleLength)
JobInput.Text = args.Text[..IdCardConsoleComponent.MaxJobTitleLength];
};
}

private void ValidateInputs()
{
var isValid = !string.IsNullOrWhiteSpace(NumberInput.Text) &&
!string.IsNullOrWhiteSpace(NameInput.Text) &&
NumberInput.Text.Length == MaxNumberLength &&
uint.TryParse(NumberInput.Text, out _);

CreateButton.Disabled = !isValid;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/MassMedia/Ui/NewsArticleCard.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed partial class NewsArticleCard : Control
public string? Title
{
get => TitleLabel.Text;
set => TitleLabel.Text = value?.Length <= 30 ? value : $"{value?[..30]}...";
set => TitleLabel.Text = value?.Length <= 40 ? value : $"{value?[..40]}...";
}

public string? Author
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/MassMedia/Ui/NewsWriterMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xmlns:ui="clr-namespace:Content.Client.MassMedia.Ui"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Title="{Loc 'news-write-ui-default-title'}"
MinSize="348 443"
SetSize="348 443">
MinSize="404 443"
SetSize="404 443">

<ui:ArticleEditorPanel Name="ArticleEditorPanel" HorizontalAlignment="Left" VerticalExpand="True"
MinWidth="410" MinHeight="370" Margin="0 0 0 30" Access="Public" Visible="False"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
Margin="5 5"
HorizontalExpand="True"
Visible="True">
<PanelContainer StyleClasses="AngleRect" HorizontalExpand="True">
<BoxContainer Orientation="Horizontal">
<BoxContainer Orientation="Vertical" VerticalAlignment="Center">
<CheckBox Name="GroupCheckbox" HorizontalAlignment="Center"/>
</BoxContainer>
<customControls:VSeparator Margin="0 0 10 0"/>
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<TextureRect Name="JobIcon" VerticalAlignment="Center" TextureScale="2 2"/>
<Control MinWidth="4"/>
<Label Name="JobLabel" Text=" " HorizontalAlignment="Center"/>
</BoxContainer>
<Control MinHeight="4"/>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Name="TimeLabel" Text="{Loc time-transfer-panel-time}" HorizontalAlignment="Center"/>
<Control MinWidth="5"/>
<LineEdit Name="TimeEdit" PlaceHolder="0h0m" HorizontalExpand="True"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</PanelContainer>
</BoxContainer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Content.Shared.Roles;
using Content.Shared.StatusIcon;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;

namespace Content.Client._Goobstation.Administration.UI.TimeTransferPanel;

[GenerateTypedNameReferences]
public sealed partial class TimeTransferEntry : BoxContainer
{
public string PlaytimeTracker;
public string JobName;

public TimeTransferEntry(JobPrototype jobProto, SpriteSystem spriteSystem, IPrototypeManager prototypeManager)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

PlaytimeTracker = jobProto.PlayTimeTracker;
JobLabel.Text = jobProto.LocalizedName;
JobName = jobProto.LocalizedName;

if (prototypeManager.TryIndex<JobIconPrototype>(jobProto.Icon, out var jobIcon))
JobIcon.Texture = spriteSystem.Frame0(jobIcon.Icon);
}

public void UpdateGroupVisibility(bool inGrouped)
{
TimeLabel.Visible = !inGrouped;
TimeEdit.Visible = !inGrouped;
GroupCheckbox.Visible = inGrouped;
}

public string GetJobTimeString()
{
return TimeEdit.Text != null ? TimeEdit.Text : "";
}

public bool InGroup()
{
return GroupCheckbox.Pressed;
}
}
Loading

0 comments on commit 6791eb9

Please sign in to comment.