forked from Grimbly-Station/Grimbly-Station
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I fixed the patch. (Grimbly-Station#109)
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Description. --- # TODO <!-- A list of everything you have to do before this PR is "complete" You probably won't have to complete everything before merging but it's good to leave future references --> - [ ] Task - [x] Completed Task --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p> ![Example Media Embed](https://example.com/thisimageisntreal.png) </p> </details> --- # Changelog <!-- You can add an author after the `:cl:` to change the name that appears in the changelog (ex: `:cl: Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> :cl: - add: Added fun :D - tweak: Tweaked fun - fix: Fixed fun! - remove: Removed fun :(
- Loading branch information
Showing
126 changed files
with
6,330 additions
and
2,399 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Content.Client.UserInterface.Fragments; | ||
using Content.Shared.CartridgeLoader.Cartridges; | ||
using Robust.Client.UserInterface; | ||
|
||
namespace Content.Client.CartridgeLoader.Cartridges; | ||
|
||
public sealed partial class MailMetricUi : UIFragment | ||
{ | ||
private MailMetricUiFragment? _fragment; | ||
|
||
public override Control GetUIFragmentRoot() | ||
{ | ||
return _fragment!; | ||
} | ||
|
||
public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner) | ||
{ | ||
_fragment = new MailMetricUiFragment(); | ||
} | ||
|
||
public override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
if (state is MailMetricUiState cast) | ||
{ | ||
_fragment?.UpdateState(cast); | ||
} | ||
} | ||
} |
183 changes: 183 additions & 0 deletions
183
Content.Client/CartridgeLoader/Cartridges/MailMetricUiFragment.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,183 @@ | ||
<cartridges:MailMetricUiFragment | ||
xmlns:cartridges="clr-namespace:Content.Client.CartridgeLoader.Cartridges" | ||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns="https://spacestation14.io" | ||
Margin="5" | ||
VerticalExpand="True" | ||
Orientation="Vertical"> | ||
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer> | ||
<controls:StripeBack Name="MailMetricHeaderContainer"> | ||
<PanelContainer> | ||
<Label Name="MailMetricHeader" | ||
Align="Center" | ||
Text="{Loc 'mail-metrics-header'}" /> | ||
</PanelContainer> | ||
</controls:StripeBack> | ||
<BoxContainer | ||
Orientation="Vertical" | ||
HorizontalExpand="True" | ||
Margin="20 0"> | ||
<BoxContainer Orientation="Horizontal" | ||
HorizontalExpand="True" | ||
SeparationOverride="2"> | ||
<Label Name="TitleEmpty1" | ||
SizeFlagsStretchRatio="2" | ||
HorizontalExpand="True" | ||
ClipText="True" /> | ||
<Label Name="MailCountLabel" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
StyleClasses="monospace" | ||
Align="Center" | ||
Text="{Loc 'mail-metrics-count-header'}" /> | ||
<Label Name="SpesosLabel" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Align="Center" | ||
StyleClasses="monospace" | ||
Text="{Loc 'mail-metrics-money-header'}" /> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Horizontal" | ||
HorizontalExpand="True" | ||
SeparationOverride="2"> | ||
<Label Name="OpenedLabel" | ||
SizeFlagsStretchRatio="2" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Text="{Loc 'mail-metrics-opened'}" /> | ||
<Label Name="OpenedMailCount" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
Align="Right" | ||
StyleClasses="monospace" | ||
ClipText="True" /> | ||
<Label Name="OpenedMailSpesos" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
Align="Right" | ||
StyleClasses="monospace" | ||
ClipText="True" /> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Horizontal" | ||
HorizontalExpand="True" | ||
SeparationOverride="2"> | ||
<Label Name="ExpiredLabel" | ||
SizeFlagsStretchRatio="2" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Text="{Loc 'mail-metrics-expired'}" /> | ||
<Label Name="ExpiredMailCount" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
Align="Right" | ||
StyleClasses="monospace" | ||
ClipText="True" /> | ||
<Label Name="ExpiredMailSpesos" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
Align="Right" | ||
StyleClasses="monospace" | ||
ClipText="True" /> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Horizontal" | ||
HorizontalExpand="True" | ||
SeparationOverride="2"> | ||
<Label Name="TamperedLabel" | ||
SizeFlagsStretchRatio="2" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Text="{Loc 'mail-metrics-tampered'}" /> | ||
<Label Name="TamperedMailCount" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
Align="Right" | ||
StyleClasses="monospace" | ||
ClipText="True" /> | ||
<Label Name="TamperedMailSpesos" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
Align="Right" | ||
StyleClasses="monospace" | ||
ClipText="True" /> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Horizontal" | ||
HorizontalExpand="True" | ||
SeparationOverride="2"> | ||
<Label Name="DamagedLabel" | ||
SizeFlagsStretchRatio="2" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Text="{Loc 'mail-metrics-damaged'}" /> | ||
<Label Name="DamagedMailCount" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
Align="Right" | ||
StyleClasses="monospace" | ||
ClipText="True" /> | ||
<Label Name="DamagedMailSpesos" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
StyleClasses="monospace" | ||
Align="Right" | ||
ClipText="True" /> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Horizontal" | ||
HorizontalExpand="True" | ||
SeparationOverride="2"> | ||
<Label Name="UnopenedLabel" | ||
SizeFlagsStretchRatio="2" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Text="{Loc 'mail-metrics-unopened'}" /> | ||
<Label Name="UnopenedMailCount" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
StyleClasses="monospace" | ||
Align="Right" | ||
ClipText="True" /> | ||
<Label Name="UnopenedMailSpesos" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
Align="Right" | ||
StyleClasses="monospace" | ||
ClipText="True" /> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Horizontal" | ||
HorizontalExpand="True" | ||
SeparationOverride="2"> | ||
<Label Name="TotalMailLabel" | ||
SizeFlagsStretchRatio="2" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Text="{Loc 'mail-metrics-total'}" /> | ||
<Label Name="TotalMailCount" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
Align="Right" | ||
StyleClasses="monospace" | ||
ClipText="True" /> | ||
<Label Name="TotalMailSpesos" | ||
SizeFlagsStretchRatio="1" | ||
HorizontalExpand="True" | ||
Align="Right" | ||
StyleClasses="monospace" | ||
ClipText="True" /> | ||
</BoxContainer> | ||
</BoxContainer> | ||
<BoxContainer | ||
Orientation="Vertical" | ||
HorizontalExpand="True" | ||
Margin="10"> | ||
<Label | ||
Name="SuccessRateCounts" | ||
Align="Center" | ||
StyleClasses="LabelBig" /> | ||
<Label | ||
Name="SuccessRatePercent" | ||
Align="Center" | ||
StyleClasses="LabelBig" /> | ||
</BoxContainer> | ||
</cartridges:MailMetricUiFragment> |
104 changes: 104 additions & 0 deletions
104
Content.Client/CartridgeLoader/Cartridges/MailMetricUiFragment.xaml.cs
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,104 @@ | ||
using Content.Shared.CartridgeLoader.Cartridges; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.CartridgeLoader.Cartridges; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class MailMetricUiFragment : BoxContainer | ||
{ | ||
|
||
private OpenedMailPercentGrade? _successGrade; | ||
|
||
public MailMetricUiFragment() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
// This my way of adding multiple classes to a XAML control. | ||
// Haha Batman I'm going to blow up Gotham City | ||
OpenedMailCount.StyleClasses.Add("Good"); | ||
OpenedMailSpesos.StyleClasses.Add("Good"); | ||
TamperedMailCount.StyleClasses.Add("Danger"); | ||
TamperedMailSpesos.StyleClasses.Add("Danger"); | ||
ExpiredMailCount.StyleClasses.Add("Danger"); | ||
ExpiredMailSpesos.StyleClasses.Add("Danger"); | ||
DamagedMailCount.StyleClasses.Add("Danger"); | ||
DamagedMailSpesos.StyleClasses.Add("Danger"); | ||
UnopenedMailCount.StyleClasses.Add("Caution"); | ||
} | ||
|
||
public void UpdateState(MailMetricUiState state) | ||
{ | ||
UpdateTextLabels(state); | ||
UpdateSuccessGrade(state); | ||
} | ||
|
||
public void UpdateTextLabels(MailMetricUiState state) | ||
{ | ||
var stats = state.Metrics; | ||
|
||
OpenedMailCount.Text = stats.OpenedCount.ToString(); | ||
OpenedMailSpesos.Text = stats.Earnings.ToString(); | ||
TamperedMailCount.Text = stats.TamperedCount.ToString(); | ||
TamperedMailSpesos.Text = stats.TamperedLosses.ToString(); | ||
ExpiredMailCount.Text = stats.ExpiredCount.ToString(); | ||
ExpiredMailSpesos.Text = stats.ExpiredLosses.ToString(); | ||
DamagedMailCount.Text = stats.DamagedCount.ToString(); | ||
DamagedMailSpesos.Text = stats.DamagedLosses.ToString(); | ||
UnopenedMailCount.Text = state.UnopenedMailCount.ToString(); | ||
TotalMailCount.Text = state.TotalMail.ToString(); | ||
TotalMailSpesos.Text = stats.TotalIncome.ToString(); | ||
SuccessRateCounts.Text = Loc.GetString("mail-metrics-progress", | ||
("opened", stats.OpenedCount), | ||
("total", state.TotalMail)); | ||
SuccessRatePercent.Text = Loc.GetString("mail-metrics-progress-percent", | ||
("successRate", state.SuccessRate)); | ||
} | ||
|
||
public void UpdateSuccessGrade(MailMetricUiState state) | ||
{ | ||
var previousGrade = _successGrade; | ||
_successGrade = GetSuccessRateGrade(state.SuccessRate); | ||
|
||
// No need to update if they're the same | ||
if (previousGrade == _successGrade) | ||
return; | ||
|
||
var previousGradeClass = GetClassForGrade(previousGrade); | ||
if (previousGradeClass != string.Empty) | ||
{ | ||
SuccessRatePercent.StyleClasses.Remove(previousGradeClass); | ||
} | ||
|
||
SuccessRatePercent.StyleClasses.Add(GetClassForGrade(_successGrade)); | ||
} | ||
|
||
private static OpenedMailPercentGrade GetSuccessRateGrade(double successRate) | ||
{ | ||
return successRate switch | ||
{ | ||
> 75 => OpenedMailPercentGrade.Good, | ||
> 50 => OpenedMailPercentGrade.Average, | ||
_ => OpenedMailPercentGrade.Bad, | ||
}; | ||
} | ||
|
||
private string GetClassForGrade(OpenedMailPercentGrade? grade) | ||
{ | ||
return grade switch | ||
{ | ||
OpenedMailPercentGrade.Good => "Good", | ||
OpenedMailPercentGrade.Average => "Caution", | ||
OpenedMailPercentGrade.Bad => "Danger", | ||
_ => string.Empty, | ||
}; | ||
} | ||
} | ||
|
||
enum OpenedMailPercentGrade | ||
{ | ||
Good, | ||
Average, | ||
Bad | ||
} |
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
Oops, something went wrong.