Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDA messaging Port #245

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
75d3651
Merge pull request #1 from ss14-harmony/master
Ermucat Dec 21, 2024
224b4cf
ALright basic system online, all systems operational …
Ermucat Dec 25, 2024
85582ec
Agent ID is now working maybe
Ermucat Dec 25, 2024
f31bc98
Log probe is done kinda gotta sort out some bugs but is mostly done
Ermucat Dec 25, 2024
c70fea6
Log Probe is now fixed yay
Ermucat Dec 25, 2024
7deea72
Adding nanochat systems and some ymls
Ermucat Dec 25, 2024
eeb8b39
It is finished
Ermucat Dec 25, 2024
ab3664a
Fixes Test fail yay
Ermucat Dec 25, 2024
789fa6e
Maybe fixes test fail?
Ermucat Dec 25, 2024
e1732c4
Moved files?
Ermucat Dec 25, 2024
ea7cc2e
Fixes it?
Ermucat Dec 25, 2024
69d7351
What is going on?
Ermucat Dec 25, 2024
0c5f83b
Revert "What is going on?"
Ermucat Dec 25, 2024
12b88bd
Revert "Fixes it?"
Ermucat Dec 25, 2024
ea6a857
Revert "Maybe fixes test fail?"
Ermucat Dec 25, 2024
84dc3db
Revert "Moved files?"
Ermucat Dec 26, 2024
11ecc63
Revert "Fixes Test fail yay"
Ermucat Dec 26, 2024
f2611d9
Right fixes sprite for real
Ermucat Dec 26, 2024
a16df61
Fixed Nanochat stock trading
Ermucat Dec 26, 2024
2ad5028
Test fail fixed?
Ermucat Dec 26, 2024
cd085b6
Yeah I dont know anymore
Ermucat Dec 26, 2024
d27492a
Revert "Fixes it?"
Ermucat Dec 26, 2024
04537fa
Revert "Yeah I dont know anymore"
Ermucat Dec 26, 2024
b7b3359
Revert "Test fail fixed?"
Ermucat Dec 26, 2024
16adf2a
I believe its done
Ermucat Dec 26, 2024
cf511c6
Moving more files and fixing deltaV file names
Ermucat Dec 26, 2024
766ff17
Admin tools
Ermucat Dec 29, 2024
c7485fc
Made it look better
Ermucat Dec 29, 2024
b05910c
Shared System Changes
Ermucat Jan 6, 2025
9c0b905
cONTENT cLIENT changes
Ermucat Jan 6, 2025
d21d96f
buh
Ermucat Jan 6, 2025
34260ea
Server files
Ermucat Jan 6, 2025
e0e6333
please
Ermucat Jan 6, 2025
8f5e25d
ITS FIXED YESS
Ermucat Jan 6, 2025
7454638
Merge branch 'master' into Pdamessagingreal
Ermucat Jan 7, 2025
363c024
Implements the pr rah
Ermucat Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ protected override void Open()
_window.OnNameChanged += OnNameChanged;
_window.OnJobChanged += OnJobChanged;
_window.OnJobIconChanged += OnJobIconChanged;
_window.OnNumberChanged += OnNumberChanged; // DeltaV
}

// DeltaV - Add number change handler
private void OnNumberChanged(uint newNumber)
{
SendMessage(new AgentIDCardNumberChangedMessage(newNumber));
}

private void OnNameChanged(string newName)
Expand Down Expand Up @@ -56,6 +63,7 @@ protected override void UpdateState(BoundUserInterfaceState state)
_window.SetCurrentName(cast.CurrentName);
_window.SetCurrentJob(cast.CurrentJob);
_window.SetAllowedIcons(cast.CurrentJobIconId);
_window.SetCurrentNumber(cast.CurrentNumber); // DeltaV
}
}
}
4 changes: 4 additions & 0 deletions Content.Client/Access/UI/AgentIDCardWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<LineEdit Name="NameLineEdit" />
<Label Name="CurrentJob" Text="{Loc 'agent-id-card-current-job'}" />
<LineEdit Name="JobLineEdit" />
<!-- DeltaV - Add NanoChat number field -->
<Label Name="CurrentNumber" Text="{Loc 'agent-id-card-current-number'}" />
<LineEdit Name="NumberLineEdit" PlaceHolder="#0000" />
<!-- DeltaV end -->
<Label Text="{Loc 'agent-id-card-job-icon-label'}"/>
<GridContainer Name="IconGrid" Columns="10">
<!-- Job icon buttons are generated in the code -->
Expand Down
35 changes: 35 additions & 0 deletions Content.Client/Access/UI/AgentIDCardWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ public sealed partial class AgentIDCardWindow : DefaultWindow

private const int JobIconColumnCount = 10;

private const int MaxNumberLength = 4; // DeltaV - Same as NewChatPopup

public event Action<string>? OnNameChanged;
public event Action<string>? OnJobChanged;

public event Action<uint>? OnNumberChanged; // DeltaV - Add event for number changes

public event Action<ProtoId<JobIconPrototype>>? OnJobIconChanged;

public AgentIDCardWindow()
Expand All @@ -37,6 +41,37 @@ public AgentIDCardWindow()

JobLineEdit.OnTextEntered += e => OnJobChanged?.Invoke(e.Text);
JobLineEdit.OnFocusExit += e => OnJobChanged?.Invoke(e.Text);

// DeltaV - Add handlers for number changes
NumberLineEdit.OnTextEntered += OnNumberEntered;
NumberLineEdit.OnFocusExit += OnNumberEntered;

// DeltaV - Filter to only allow digits
NumberLineEdit.OnTextChanged += args =>
{
if (args.Text.Length > MaxNumberLength)
{
NumberLineEdit.Text = args.Text[..MaxNumberLength];
}

// Filter to digits only
var newText = string.Concat(args.Text.Where(char.IsDigit));
if (newText != args.Text)
NumberLineEdit.Text = newText;
};
}

// DeltaV - Add number validation and event
private void OnNumberEntered(LineEdit.LineEditEventArgs args)
{
if (uint.TryParse(args.Text, out var number) && number > 0)
OnNumberChanged?.Invoke(number);
}

// DeltaV - Add setter for current number
public void SetCurrentNumber(uint? number)
{
NumberLineEdit.Text = number?.ToString("D4") ?? "";
}

public void SetAllowedIcons(string currentJobIconId)
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public override void UpdateState(BoundUserInterfaceState state)
if (state is not LogProbeUiState logProbeUiState)
return;

_fragment?.UpdateState(logProbeUiState.PulledLogs);
_fragment?.UpdateState(logProbeUiState); // DeltaV - just take the state
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,30 @@
BorderColor="#5a5a5a"
BorderThickness="0 0 0 1"/>
</PanelContainer.PanelOverride>
<BoxContainer Orientation="Horizontal" Margin="4 8">
<Label Align="Right" SetWidth="26" ClipText="True" Text="{Loc 'log-probe-label-number'}"/>
<Label Align="Center" SetWidth="100" ClipText="True" Text="{Loc 'log-probe-label-time'}"/>
<Label Align="Left" SetWidth="390" ClipText="True" Text="{Loc 'log-probe-label-accessor'}"/>
<BoxContainer Orientation="Vertical" Margin="4 8">
<!-- DeltaV begin - Add title label -->
<Label Name="TitleLabel"
Text="{Loc 'log-probe-header-access'}"
StyleClasses="LabelHeading"
HorizontalAlignment="Center"
Margin="0 0 0 8"/>
<!-- DeltaV end -->

<!-- DeltaV begin - Add card number display -->
<Label Name="CardNumberLabel"
StyleClasses="LabelSubText"
HorizontalAlignment="Center"
Margin="0 0 0 8"
Visible="False"/>
<!-- DeltaV end -->

<!-- DeltaV begin - Adjust column headers -->
<BoxContainer Orientation="Horizontal">
<Label Align="Right" SetWidth="26" ClipText="True" Text="{Loc 'log-probe-label-number'}"/>
<Label Align="Center" SetWidth="100" ClipText="True" Text="{Loc 'log-probe-label-time'}"/>
<Label Name="ContentLabel" Align="Left" SetWidth="390" ClipText="True" Text="{Loc 'log-probe-label-accessor'}"/>
</BoxContainer>
<!-- DeltaV end -->
</BoxContainer>
</PanelContainer>
<ScrollContainer VerticalExpand="True" HScrollEnabled="True">
Expand Down
109 changes: 107 additions & 2 deletions Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Content.Shared.CartridgeLoader.Cartridges;
using System.Linq; // DeltaV
using Content.Client.DeltaV.CartridgeLoader.Cartridges; // DeltaV
using Content.Shared.CartridgeLoader.Cartridges;
using Content.Shared.DeltaV.CartridgeLoader.Cartridges; // DeltaV
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
Expand All @@ -13,10 +16,112 @@ public LogProbeUiFragment()
RobustXamlLoader.Load(this);
}

public void UpdateState(List<PulledAccessLog> logs)
// DeltaV begin - Update to handle both types of data
public void UpdateState(LogProbeUiState state)
{
ProbedDeviceContainer.RemoveAllChildren();

if (state.NanoChatData != null)
{
SetupNanoChatView(state.NanoChatData.Value);
DisplayNanoChatData(state.NanoChatData.Value);
}
else
{
SetupAccessLogView();
if (state.PulledLogs.Count > 0)
DisplayAccessLogs(state.PulledLogs);
}
}

private void SetupNanoChatView(NanoChatData data)
{
TitleLabel.Text = Loc.GetString("log-probe-header-nanochat");
ContentLabel.Text = Loc.GetString("log-probe-label-message");

// Show card info if available
var cardInfo = new List<string>();
if (data.CardNumber != null)
cardInfo.Add(Loc.GetString("log-probe-card-number", ("number", $"#{data.CardNumber:D4}")));

// Add recipient count
cardInfo.Add(Loc.GetString("log-probe-recipients", ("count", data.Recipients.Count)));

CardNumberLabel.Text = string.Join(" | ", cardInfo);
CardNumberLabel.Visible = true;
}

private void SetupAccessLogView()
{
TitleLabel.Text = Loc.GetString("log-probe-header-access");
ContentLabel.Text = Loc.GetString("log-probe-label-accessor");
CardNumberLabel.Visible = false;
}

private void DisplayNanoChatData(NanoChatData data)
{
// First add a recipient list entry
var recipientsList = Loc.GetString("log-probe-recipient-list") + "\n" + string.Join("\n",
data.Recipients.Values
.OrderBy(r => r.Name)
.Select(r => $" {r.Name}" +
(string.IsNullOrEmpty(r.JobTitle) ? "" : $" ({r.JobTitle})") +
$" | #{r.Number:D4}"));

var recipientsEntry = new LogProbeUiEntry(0, "---", recipientsList);
ProbedDeviceContainer.AddChild(recipientsEntry);

var count = 1;
foreach (var (partnerId, messages) in data.Messages)
{
// Show only successfully delivered incoming messages
var incomingMessages = messages
.Where(msg => msg.SenderId == partnerId && !msg.DeliveryFailed)
.OrderByDescending(msg => msg.Timestamp);

foreach (var msg in incomingMessages)
{
var messageText = Loc.GetString("log-probe-message-format",
("sender", $"#{msg.SenderId:D4}"),
("recipient", $"#{data.CardNumber:D4}"),
("content", msg.Content));

var entry = new NanoChatLogEntry(
count,
TimeSpan.FromSeconds(Math.Truncate(msg.Timestamp.TotalSeconds)).ToString(),
messageText);

ProbedDeviceContainer.AddChild(entry);
count++;
}

// Show only successfully delivered outgoing messages
var outgoingMessages = messages
.Where(msg => msg.SenderId == data.CardNumber && !msg.DeliveryFailed)
.OrderByDescending(msg => msg.Timestamp);

foreach (var msg in outgoingMessages)
{
var messageText = Loc.GetString("log-probe-message-format",
("sender", $"#{msg.SenderId:D4}"),
("recipient", $"#{partnerId:D4}"),
("content", msg.Content));

var entry = new NanoChatLogEntry(
count,
TimeSpan.FromSeconds(Math.Truncate(msg.Timestamp.TotalSeconds)).ToString(),
messageText);

ProbedDeviceContainer.AddChild(entry);
count++;
}
}
}
// DeltaV end

// DeltaV - Handle this in a separate method
private void DisplayAccessLogs(List<PulledAccessLog> logs)
{
//Reverse the list so the oldest entries appear at the bottom
logs.Reverse();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<BoxContainer
xmlns="https://spacestation14.io"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
HorizontalExpand="True">
<Button Name="ChatButton"
StyleClasses="ButtonSquare"
HorizontalExpand="True"
MaxSize="137 64"
Margin="0 1">
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="True"
MinWidth="132"
Margin="6 4"
VerticalAlignment="Center">
<!-- Unread indicator dot -->
<PanelContainer Name="UnreadIndicator"
MinSize="8 8"
MaxSize="8 8"
VerticalAlignment="Center"
Margin="0 0 6 0">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat
BackgroundColor="#17c622"
BorderColor="#0f7a15" />
</PanelContainer.PanelOverride>
</PanelContainer>

<!-- Text container -->
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
VerticalAlignment="Center">
<RichTextLabel Name="NameLabel"
StyleClasses="LabelHeading"
HorizontalExpand="True"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="0 -2 0 0" />
<Label Name="JobLabel"
StyleClasses="LabelSubText"
HorizontalExpand="True"
ClipText="False"
HorizontalAlignment="Center" />
</BoxContainer>
</BoxContainer>
</Button>
</BoxContainer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Content.Shared.DeltaV.CartridgeLoader.Cartridges;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;

[GenerateTypedNameReferences]
public sealed partial class NanoChatEntry : BoxContainer
{
public event Action<uint>? OnPressed;
private uint _number;
private Action<EventArgs>? _pressHandler;

public NanoChatEntry()
{
RobustXamlLoader.Load(this);
}

public void SetRecipient(NanoChatRecipient recipient, uint number, bool isSelected)
{
// Remove old handler if it exists
if (_pressHandler != null)
ChatButton.OnPressed -= _pressHandler;

_number = number;

// Create and store new handler
_pressHandler = _ => OnPressed?.Invoke(_number);
ChatButton.OnPressed += _pressHandler;

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

ChatButton.ModulateSelfOverride = isSelected ? NanoChatMessageBubble.OwnMessageColor : null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
Margin="4"
Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label Name="NumberLabel"
Align="Right"
SetWidth="26"
ClipText="True" />
<Label Name="TimeLabel"
Align="Center"
SetWidth="100"
ClipText="True" />
<Label Name="MessageLabel"
Align="Left"
MinWidth="390"
HorizontalExpand="True"
ClipText="False" />
</BoxContainer>
<customControls:HSeparator Margin="0 5 0 5" />
</BoxContainer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.DeltaV.CartridgeLoader.Cartridges;

[GenerateTypedNameReferences]
public sealed partial class NanoChatLogEntry : BoxContainer
{
public NanoChatLogEntry(int number, string time, string message)
{
RobustXamlLoader.Load(this);
NumberLabel.Text = number.ToString();
TimeLabel.Text = time;
MessageLabel.Text = message;
}
}
Loading
Loading