-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1552 from space-syndicate/upstream-sync
Upstream sync
- Loading branch information
Showing
764 changed files
with
19,220 additions
and
13,326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.Info.PlaytimeStats; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class PlaytimeStatsEntry : ContainerButton | ||
{ | ||
public TimeSpan Playtime { get; private set; } // new TimeSpan property | ||
|
||
public PlaytimeStatsEntry(string role, TimeSpan playtime, StyleBox styleBox) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
RoleLabel.Text = role; | ||
Playtime = playtime; // store the TimeSpan value directly | ||
PlaytimeLabel.Text = ConvertTimeSpanToHoursMinutes(playtime); // convert to string for display | ||
BackgroundColorPanel.PanelOverride = styleBox; | ||
} | ||
|
||
private static string ConvertTimeSpanToHoursMinutes(TimeSpan timeSpan) | ||
{ | ||
var hours = (int)timeSpan.TotalHours; | ||
var minutes = timeSpan.Minutes; | ||
|
||
var formattedTimeLoc = Loc.GetString("ui-playtime-time-format", ("hours", hours), ("minutes", minutes)); | ||
return formattedTimeLoc; | ||
} | ||
|
||
public void UpdateShading(StyleBoxFlat styleBox) | ||
{ | ||
BackgroundColorPanel.PanelOverride = styleBox; | ||
} | ||
public string? PlaytimeText => PlaytimeLabel.Text; | ||
|
||
public string? RoleText => RoleLabel.Text; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<ContainerButton xmlns="https://spacestation14.io" | ||
xmlns:customControls1="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
EnableAllKeybinds="True"> | ||
<PanelContainer Name="BackgroundColorPanel"/> | ||
<BoxContainer Orientation="Horizontal" | ||
HorizontalExpand="True" | ||
SeparationOverride="4"> | ||
<Label Name="RoleLabel" | ||
SizeFlagsStretchRatio="3" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Margin="5,5,5,5"/> | ||
<customControls1:VSeparator/> | ||
<Label Name="PlaytimeLabel" | ||
SizeFlagsStretchRatio="3" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Margin="5,5,5,5"/> | ||
</BoxContainer> | ||
</ContainerButton> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Input; | ||
|
||
namespace Content.Client.Info.PlaytimeStats; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class PlaytimeStatsHeader : ContainerButton | ||
{ | ||
public event Action<Header, SortDirection>? OnHeaderClicked; | ||
private SortDirection _roleDirection = SortDirection.Ascending; | ||
private SortDirection _playtimeDirection = SortDirection.Descending; | ||
|
||
public PlaytimeStatsHeader() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
RoleLabel.OnKeyBindDown += RoleClicked; | ||
PlaytimeLabel.OnKeyBindDown += PlaytimeClicked; | ||
|
||
UpdateLabels(); | ||
} | ||
|
||
public enum Header : byte | ||
{ | ||
Role, | ||
Playtime | ||
} | ||
public enum SortDirection : byte | ||
{ | ||
Ascending, | ||
Descending | ||
} | ||
|
||
private void HeaderClicked(GUIBoundKeyEventArgs args, Header header) | ||
{ | ||
if (args.Function != EngineKeyFunctions.UIClick) | ||
{ | ||
return; | ||
} | ||
|
||
switch (header) | ||
{ | ||
case Header.Role: | ||
_roleDirection = _roleDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending; | ||
break; | ||
case Header.Playtime: | ||
_playtimeDirection = _playtimeDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending; | ||
break; | ||
} | ||
|
||
UpdateLabels(); | ||
OnHeaderClicked?.Invoke(header, header == Header.Role ? _roleDirection : _playtimeDirection); | ||
args.Handle(); | ||
} | ||
private void UpdateLabels() | ||
{ | ||
RoleLabel.Text = Loc.GetString("ui-playtime-header-role-type") + | ||
(_roleDirection == SortDirection.Ascending ? " ↓" : " ↑"); | ||
PlaytimeLabel.Text = Loc.GetString("ui-playtime-header-role-time") + | ||
(_playtimeDirection == SortDirection.Ascending ? " ↓" : " ↑"); | ||
} | ||
|
||
private void RoleClicked(GUIBoundKeyEventArgs args) | ||
{ | ||
HeaderClicked(args, Header.Role); | ||
} | ||
|
||
private void PlaytimeClicked(GUIBoundKeyEventArgs args) | ||
{ | ||
HeaderClicked(args, Header.Playtime); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
|
||
if (disposing) | ||
{ | ||
RoleLabel.OnKeyBindDown -= RoleClicked; | ||
PlaytimeLabel.OnKeyBindDown -= PlaytimeClicked; | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
Content.Client/Info/PlaytimeStats/PlaytimeStatsHeader.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<ContainerButton xmlns="https://spacestation14.io" | ||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
EnableAllKeybinds="True"> | ||
<PanelContainer Name="BackgroundColorPlaytimePanel" Access="Public"/> | ||
<BoxContainer Orientation="Vertical" | ||
HorizontalExpand="True"> | ||
<BoxContainer Orientation="Horizontal" | ||
HorizontalExpand="True" | ||
SeparationOverride="4"> | ||
<Label Name="RoleLabel" | ||
SizeFlagsStretchRatio="3" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Text="{Loc ui-playtime-header-role-type}" | ||
MouseFilter="Pass" | ||
Margin="5,5,5,5"/> | ||
<customControls:VSeparator/> | ||
<Label Name="PlaytimeLabel" | ||
SizeFlagsStretchRatio="3" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Text="{Loc ui-playtime-header-role-time}" | ||
MouseFilter="Pass" | ||
Margin="5,5,5,5"/> | ||
</BoxContainer> | ||
<!-- Horizontal Separator --> | ||
<customControls:HSeparator/> | ||
</BoxContainer> | ||
</ContainerButton> |
Oops, something went wrong.