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:
@@ -28,20 +28,24 @@
|
|||||||
HorizontalExpand="True"
|
HorizontalExpand="True"
|
||||||
MinSize="50 50"
|
MinSize="50 50"
|
||||||
Margin="8">
|
Margin="8">
|
||||||
|
<ContainerButton Name="PdaOwnerButton">
|
||||||
<RichTextLabel Name="PdaOwnerLabel" Access="Public"/>
|
<RichTextLabel Name="PdaOwnerLabel" Access="Public"/>
|
||||||
<RichTextLabel Name="IdInfoLabel"
|
</ContainerButton>
|
||||||
Access="Public"
|
<ContainerButton Name="IdInfoButton">
|
||||||
HorizontalExpand="True" />
|
<RichTextLabel Name="IdInfoLabel" Access="Public"/>
|
||||||
<PanelContainer>
|
</ContainerButton>
|
||||||
<BoxContainer Orientation="Horizontal">
|
<ContainerButton Name="StationNameButton">
|
||||||
<RichTextLabel Name="StationNameLabel"
|
<RichTextLabel Name="StationNameLabel" Access="Public"/>
|
||||||
Access="Public"
|
</ContainerButton>
|
||||||
HorizontalExpand="True" />
|
<ContainerButton Name="StationAlertLevelButton">
|
||||||
</BoxContainer>
|
|
||||||
</PanelContainer>
|
|
||||||
<RichTextLabel Name="StationAlertLevelLabel" Access="Public"/>
|
<RichTextLabel Name="StationAlertLevelLabel" Access="Public"/>
|
||||||
|
</ContainerButton>
|
||||||
|
<ContainerButton Name="StationTimeButton">
|
||||||
<RichTextLabel Name="StationTimeLabel" Access="Public"/>
|
<RichTextLabel Name="StationTimeLabel" Access="Public"/>
|
||||||
|
</ContainerButton>
|
||||||
|
<ContainerButton Name="StationAlertLevelInstructionsButton">
|
||||||
<RichTextLabel Name="StationAlertLevelInstructions" Access="Public"/>
|
<RichTextLabel Name="StationAlertLevelInstructions" Access="Public"/>
|
||||||
|
</ContainerButton>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="True">
|
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="True">
|
||||||
<BoxContainer Orientation="Vertical"
|
<BoxContainer Orientation="Vertical"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace Content.Client.PDA
|
|||||||
[GenerateTypedNameReferences]
|
[GenerateTypedNameReferences]
|
||||||
public sealed partial class PdaMenu : PdaWindow
|
public sealed partial class PdaMenu : PdaWindow
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IClipboardManager _clipboard = null!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
|
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
|
||||||
private readonly ClientGameTicker _gameTicker;
|
private readonly ClientGameTicker _gameTicker;
|
||||||
@@ -24,6 +25,15 @@ namespace Content.Client.PDA
|
|||||||
public const int SettingsView = 2;
|
public const int SettingsView = 2;
|
||||||
public const int ProgramContentView = 3;
|
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;
|
private int _currentView;
|
||||||
|
|
||||||
public event Action<EntityUid>? OnProgramItemPressed;
|
public event Action<EntityUid>? OnProgramItemPressed;
|
||||||
@@ -84,6 +94,39 @@ namespace Content.Client.PDA
|
|||||||
ToHomeScreen();
|
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();
|
HideAllViews();
|
||||||
ToHomeScreen();
|
ToHomeScreen();
|
||||||
@@ -95,24 +138,29 @@ namespace Content.Client.PDA
|
|||||||
|
|
||||||
if (state.PdaOwnerInfo.ActualOwnerName != null)
|
if (state.PdaOwnerInfo.ActualOwnerName != null)
|
||||||
{
|
{
|
||||||
|
_pdaOwner = state.PdaOwnerInfo.ActualOwnerName;
|
||||||
PdaOwnerLabel.SetMarkup(Loc.GetString("comp-pda-ui-owner",
|
PdaOwnerLabel.SetMarkup(Loc.GetString("comp-pda-ui-owner",
|
||||||
("actualOwnerName", state.PdaOwnerInfo.ActualOwnerName)));
|
("actualOwnerName", _pdaOwner)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (state.PdaOwnerInfo.IdOwner != null || state.PdaOwnerInfo.JobTitle != null)
|
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",
|
IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui",
|
||||||
("owner", state.PdaOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown")),
|
("owner", _owner),
|
||||||
("jobTitle", state.PdaOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned"))));
|
("jobTitle", _jobTitle)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui-blank"));
|
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",
|
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);
|
var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
|
||||||
|
|
||||||
@@ -122,16 +170,17 @@ namespace Content.Client.PDA
|
|||||||
var alertLevel = state.PdaOwnerInfo.StationAlertLevel;
|
var alertLevel = state.PdaOwnerInfo.StationAlertLevel;
|
||||||
var alertColor = state.PdaOwnerInfo.StationAlertColor;
|
var alertColor = state.PdaOwnerInfo.StationAlertColor;
|
||||||
var alertLevelKey = alertLevel != null ? $"alert-level-{alertLevel}" : "alert-level-unknown";
|
var alertLevelKey = alertLevel != null ? $"alert-level-{alertLevel}" : "alert-level-unknown";
|
||||||
|
_alertLevel = Loc.GetString(alertLevelKey);
|
||||||
|
|
||||||
StationAlertLevelLabel.SetMarkup(Loc.GetString(
|
StationAlertLevelLabel.SetMarkup(Loc.GetString(
|
||||||
"comp-pda-ui-station-alert-level",
|
"comp-pda-ui-station-alert-level",
|
||||||
("color", alertColor),
|
("color", alertColor),
|
||||||
("level", Loc.GetString(alertLevelKey))
|
("level", _alertLevel)
|
||||||
));
|
));
|
||||||
|
_instructions = Loc.GetString($"{alertLevelKey}-instructions");
|
||||||
StationAlertLevelInstructions.SetMarkup(Loc.GetString(
|
StationAlertLevelInstructions.SetMarkup(Loc.GetString(
|
||||||
"comp-pda-ui-station-alert-level-instructions",
|
"comp-pda-ui-station-alert-level-instructions",
|
||||||
("instructions", Loc.GetString($"{alertLevelKey}-instructions")))
|
("instructions", _instructions))
|
||||||
);
|
);
|
||||||
|
|
||||||
AddressLabel.Text = state.Address?.ToUpper() ?? " - ";
|
AddressLabel.Text = state.Address?.ToUpper() ?? " - ";
|
||||||
|
|||||||
Reference in New Issue
Block a user