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

Mail (Delta-V Port) #1333

Merged
merged 32 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fd5ec89
Mail 1
DebugOk Oct 1, 2023
756bedd
remove throw damage from mail (#609)
deltanedas Dec 29, 2023
34c556d
MAIL CRAFTABLE IDK
Adrian16199 Mar 28, 2024
de1938a
Mail fixes
honeyed-lemons Jan 12, 2025
7f34840
MAIL 3
portfiend Aug 16, 2024
a0e58b4
MAIl 4
portfiend Aug 13, 2024
4b2d616
Dying
Sep 2, 2024
30f3dc9
CancerMouseFix (#2061)
Solaris7518 Oct 28, 2024
9cb952d
Fix 4123414142141241245151545234
MilonPL Oct 28, 2024
3f80dec
Add missing RPDS sprites from Frontier (#2267)
Kr8art Nov 22, 2024
1fd2512
Massive yaml fix and file migration. Godspeed myself.
honeyed-lemons Jan 13, 2025
6f76485
Why was that there?????????
honeyed-lemons Jan 13, 2025
833081e
Move code to _DV
honeyed-lemons Jan 13, 2025
14aca0d
Mail Telepad resprite!
honeyed-lemons Jan 14, 2025
3049f85
Resprite mail items!
honeyed-lemons Jan 14, 2025
75b9d55
Fix attributions
honeyed-lemons Jan 14, 2025
24d1774
ABSOLUTELY MASSIVE COMMIT. Adds Courier job and a lot of texture chan…
honeyed-lemons Jan 15, 2025
a9f089b
MISSED YOU IM SO SORRY
honeyed-lemons Jan 15, 2025
3e8f1bc
Merge branch 'master' into mail-dv
honeyed-lemons Jan 15, 2025
84f41e8
dying,crying,dying again.
honeyed-lemons Jan 15, 2025
d243500
add extended access to salvager and cargo tech
honeyed-lemons Jan 15, 2025
6070c17
Port frontier and delta-v mail over!
honeyed-lemons Jan 15, 2025
ce40b91
Add courier clothes to the clothing lathe
honeyed-lemons Jan 15, 2025
06e183b
removed courier from loadout menu until we get it mapped
honeyed-lemons Jan 15, 2025
b240430
undid that.
honeyed-lemons Jan 15, 2025
2daff30
Maps courier to Box and Xeno
honeyed-lemons Jan 15, 2025
a3aaa19
Maps courier to Box and Xeno
honeyed-lemons Jan 15, 2025
f56b347
Merge remote-tracking branch 'origin/mail-dv' into mail-dv
honeyed-lemons Jan 15, 2025
f92ffdf
fix holopad maybe please hah aplease
honeyed-lemons Jan 15, 2025
34292ac
Fixes? Please? PLEASE? PLEASE? PLEASE?
honeyed-lemons Jan 15, 2025
e6444ce
Wanted Changes (90% of them, at least)
honeyed-lemons Jan 16, 2025
68b29b6
Fix maybe idfk
honeyed-lemons Jan 16, 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
29 changes: 29 additions & 0 deletions Content.Client/_DV/CartridgeLoader/Cartridges/MailMetricUi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Content.Client.UserInterface.Fragments;
using Content.Shared._DV.CartridgeLoader.Cartridges;
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.UserInterface;

namespace Content.Client._DV.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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<cartridges:MailMetricUiFragment
xmlns:cartridges="clr-namespace:Content.Client._DV.CartridgeLoader.Cartridges"
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using Content.Shared._DV.CartridgeLoader.Cartridges;
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._DV.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 static string GetClassForGrade(OpenedMailPercentGrade? grade)
{
return grade switch
{
OpenedMailPercentGrade.Good => "Good",
OpenedMailPercentGrade.Average => "Caution",
OpenedMailPercentGrade.Bad => "Danger",
_ => string.Empty,
};
}
}

public enum OpenedMailPercentGrade : byte
{
Good,
Average,
Bad
}
60 changes: 60 additions & 0 deletions Content.Client/_DV/Mail/MailVisuals.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Content.Shared._DV.Mail;
using Content.Shared.StatusIcon;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;

namespace Content.Client._DV.Mail;

/// <summary>
/// Display a cool stamp on the parcel based on the job of the recipient.
/// </summary>
/// <remarks>
/// GenericVisualizer is not powerful enough to handle setting a string on
/// visual data then directly relaying that string to a layer's state.
/// I.e. there is nothing like a regex capture group for visual data.
/// Hence why this system exists.
/// To do this with GenericVisualizer would require a separate condition
/// for every job value, which would be extra mess to maintain.
/// It would look something like this, multipled a couple dozen times.
/// enum.MailVisuals.JobIcon:
/// enum.MailVisualLayers.JobStamp:
/// StationEngineer:
/// state: StationEngineer
/// SecurityOfficer:
/// state: SecurityOfficer
/// </remarks>
public sealed class MailJobVisualizerSystem : VisualizerSystem<MailComponent>
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SpriteSystem _sprite = default!;

protected override void OnAppearanceChange(EntityUid uid, MailComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;

_appearance.TryGetData(uid, MailVisuals.JobIcon, out string job, args.Component);

if (string.IsNullOrEmpty(job))
job = "JobIconUnknown";

if (!_proto.TryIndex<JobIconPrototype>(job, out var icon))
{
args.Sprite.LayerSetTexture(MailVisualLayers.JobStamp, _sprite.Frame0(_proto.Index("JobIconUnknown")));
return;
}

args.Sprite.LayerSetTexture(MailVisualLayers.JobStamp, _sprite.Frame0(icon.Icon));
}
}

public enum MailVisualLayers : byte
{
Icon,
Lock,
FragileStamp,
JobStamp,
PriorityTape,
Breakage
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Shared._DV.CartridgeLoader.Cartridges;
using Content.Shared.Cargo;

namespace Content.Server._DV.Cargo.Components;

/// <summary>
/// Added to the abstract representation of a station to track stats related to mail delivery and income
/// </summary>
[RegisterComponent, Access(typeof(SharedCargoSystem))]
public sealed partial class StationLogisticStatsComponent : Component
{
[DataField]
public MailStats Metrics;
}
Loading
Loading