Add ability to copy data from pda (#23533)

* This commit add ability to copy station name and time to clipboard

* Add ability to copy name and profession. Fix style of code.

* fix

* Make copy by pressing on label

* Fix style code

---------

Co-authored-by: Ivan Rubinov <linuxkernelpatch8234@riseup.net>
This commit is contained in:
user424242420
2024-01-08 13:06:44 +03:00
committed by GitHub
parent 945a402d10
commit 6913ebcf05
2 changed files with 74 additions and 21 deletions

View File

@@ -28,20 +28,24 @@
HorizontalExpand="True"
MinSize="50 50"
Margin="8">
<RichTextLabel Name="PdaOwnerLabel" Access="Public" />
<RichTextLabel Name="IdInfoLabel"
Access="Public"
HorizontalExpand="True" />
<PanelContainer>
<BoxContainer Orientation="Horizontal">
<RichTextLabel Name="StationNameLabel"
Access="Public"
HorizontalExpand="True" />
</BoxContainer>
</PanelContainer>
<RichTextLabel Name="StationAlertLevelLabel" Access="Public" />
<RichTextLabel Name="StationTimeLabel" Access="Public" />
<RichTextLabel Name="StationAlertLevelInstructions" Access="Public" />
<ContainerButton Name="PdaOwnerButton">
<RichTextLabel Name="PdaOwnerLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="IdInfoButton">
<RichTextLabel Name="IdInfoLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="StationNameButton">
<RichTextLabel Name="StationNameLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="StationAlertLevelButton">
<RichTextLabel Name="StationAlertLevelLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="StationTimeButton">
<RichTextLabel Name="StationTimeLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="StationAlertLevelInstructionsButton">
<RichTextLabel Name="StationAlertLevelInstructions" Access="Public"/>
</ContainerButton>
</BoxContainer>
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="True">
<BoxContainer Orientation="Vertical"

View File

@@ -15,6 +15,7 @@ namespace Content.Client.PDA
[GenerateTypedNameReferences]
public sealed partial class PdaMenu : PdaWindow
{
[Dependency] private readonly IClipboardManager _clipboard = null!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
private readonly ClientGameTicker _gameTicker;
@@ -24,6 +25,15 @@ namespace Content.Client.PDA
public const int SettingsView = 2;
public const int ProgramContentView = 3;
private string _pdaOwner = Loc.GetString("comp-pda-ui-unknown");
private string _owner = Loc.GetString("comp-pda-ui-unknown");
private string _jobTitle = Loc.GetString("comp-pda-ui-unassigned");
private string _stationName = Loc.GetString("comp-pda-ui-unknown");
private string _alertLevel = Loc.GetString("comp-pda-ui-unknown");
private string _instructions = Loc.GetString("comp-pda-ui-unknown");
private int _currentView;
public event Action<EntityUid>? OnProgramItemPressed;
@@ -84,6 +94,39 @@ namespace Content.Client.PDA
ToHomeScreen();
};
PdaOwnerButton.OnPressed += _ =>
{
_clipboard.SetText(_pdaOwner);
};
IdInfoButton.OnPressed += _ =>
{
_clipboard.SetText(_owner + ", " + _jobTitle);
};
StationNameButton.OnPressed += _ =>
{
_clipboard.SetText(_stationName);
};
StationAlertLevelButton.OnPressed += _ =>
{
_clipboard.SetText(_alertLevel);
};
StationTimeButton.OnPressed += _ =>
{
var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
_clipboard.SetText((stationTime.ToString("hh\\:mm\\:ss")));
};
StationAlertLevelInstructionsButton.OnPressed += _ =>
{
_clipboard.SetText(_instructions);
};
HideAllViews();
ToHomeScreen();
@@ -95,24 +138,29 @@ namespace Content.Client.PDA
if (state.PdaOwnerInfo.ActualOwnerName != null)
{
_pdaOwner = state.PdaOwnerInfo.ActualOwnerName;
PdaOwnerLabel.SetMarkup(Loc.GetString("comp-pda-ui-owner",
("actualOwnerName", state.PdaOwnerInfo.ActualOwnerName)));
("actualOwnerName", _pdaOwner)));
}
if (state.PdaOwnerInfo.IdOwner != null || state.PdaOwnerInfo.JobTitle != null)
{
_owner = state.PdaOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown");
_jobTitle = state.PdaOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned");
IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui",
("owner", state.PdaOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown")),
("jobTitle", state.PdaOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned"))));
("owner", _owner),
("jobTitle", _jobTitle)));
}
else
{
IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui-blank"));
}
_stationName = state.StationName ?? Loc.GetString("comp-pda-ui-unknown");
StationNameLabel.SetMarkup(Loc.GetString("comp-pda-ui-station",
("station", state.StationName ?? Loc.GetString("comp-pda-ui-unknown"))));
("station", _stationName)));
var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
@@ -122,16 +170,17 @@ namespace Content.Client.PDA
var alertLevel = state.PdaOwnerInfo.StationAlertLevel;
var alertColor = state.PdaOwnerInfo.StationAlertColor;
var alertLevelKey = alertLevel != null ? $"alert-level-{alertLevel}" : "alert-level-unknown";
_alertLevel = Loc.GetString(alertLevelKey);
StationAlertLevelLabel.SetMarkup(Loc.GetString(
"comp-pda-ui-station-alert-level",
("color", alertColor),
("level", Loc.GetString(alertLevelKey))
("level", _alertLevel)
));
_instructions = Loc.GetString($"{alertLevelKey}-instructions");
StationAlertLevelInstructions.SetMarkup(Loc.GetString(
"comp-pda-ui-station-alert-level-instructions",
("instructions", Loc.GetString($"{alertLevelKey}-instructions")))
("instructions", _instructions))
);
AddressLabel.Text = state.Address?.ToUpper() ?? " - ";