Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into plasmaman2
Browse files Browse the repository at this point in the history
  • Loading branch information
angelofallars committed Jan 8, 2025
2 parents c650a04 + 442e25b commit 67cf147
Show file tree
Hide file tree
Showing 897 changed files with 190,792 additions and 1,088 deletions.
84 changes: 82 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// CLIENT CONFIGS
{
"name": "Client",
"type": "coreclr",
Expand All @@ -14,14 +15,56 @@
"stopAtEntry": false
},
{
"name": "Client (Compatibility renderer)",
"name": "Client (Tools)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build (Tools)",
"program": "${workspaceFolder}/bin/Content.Client/Content.Client.dll",
"args": [],
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Client (Release)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build (Release)",
"program": "${workspaceFolder}/bin/Content.Client/Content.Client.dll",
"args": [],
"console": "internalConsole",
"stopAtEntry": false
},
// COMPATABILITY RENDERERS
{
"name": "Client (Compatibility Renderer)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/bin/Content.Client/Content.Client.dll",
"args": "--cvar display.compat=true",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Client (Tools) - (Compatability Renderer)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build (Tools)",
"program": "${workspaceFolder}/bin/Content.Client/Content.Client.dll",
"args": ["--cvar display.compat=true"],
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Client (Release) - (Compatability Renderer)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build (Release)",
"program": "${workspaceFolder}/bin/Debug/Content.Client/Content.Client.dll",
"args": ["--cvar display.compat=true"],
"console": "internalConsole",
"stopAtEntry": false
},
// SERVER CONFIGS
{
"name": "Server",
"type": "coreclr",
Expand All @@ -31,6 +74,27 @@
"console": "integratedTerminal",
"stopAtEntry": false
},
{
"name": "Server (Tools)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build (Tools)",
"program": "${workspaceFolder}/bin/Content.Server/Content.Server.dll",
"args": [],
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Server (Release)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build (Release)",
"program": "${workspaceFolder}/bin/Content.Server/Content.Server.dll",
"args": [],
"console": "internalConsole",
"stopAtEntry": false
},
// LINTER
{
"name": "YAML Linter",
"type": "coreclr",
Expand All @@ -50,6 +114,22 @@
"Client"
],
"preLaunchTask": "build"
},
{
"name": "Server/Client (Tools)",
"configurations": [
"Server (Tools)",
"Client (Tools)"
],
"preLaunchTask": "build (Tools)"
},
{
"name": "Server/Client (Release)",
"configurations": [
"Server (Release)",
"Client (Release)"
],
"preLaunchTask": "build (Release)"
}
]
}
}
42 changes: 41 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,46 @@
},
"problemMatcher": "$msCompile"
},
{
"label": "build (Tools)",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"--configuration",
"Tools",
"/property:GenerateFullPaths=true", // Ask dotnet build to generate full paths for file names.
"/consoleloggerparameters:NoSummary" // Do not generate summary otherwise it leads to duplicate errors in Problems panel
],
"group": {
"kind": "build",
"isDefault": false
},
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"label": "build (Release)",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"--configuration",
"Release",
"/property:GenerateFullPaths=true", // Ask dotnet build to generate full paths for file names.
"/consoleloggerparameters:NoSummary" // Do not generate summary otherwise it leads to duplicate errors in Problems panel
],
"group": {
"kind": "build",
"isDefault": false
},
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"label": "build-yaml-linter",
"command": "dotnet",
Expand All @@ -34,4 +74,4 @@
"problemMatcher": "$msCompile"
}
]
}
}
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
Loading

0 comments on commit 67cf147

Please sign in to comment.