-
Notifications
You must be signed in to change notification settings - Fork 16
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
мини апстримчик <3 #164
мини апстримчик <3 #164
Changes from 22 commits
78c51b6
7200dfb
9de9a17
b84986e
63b9a05
2d96bb3
85a29fb
5625428
6fd816c
6b83754
2623935
f416875
7cdc016
9146ee3
94b2542
ee4fca4
8ac8da7
dce230f
93c13b4
600ef0e
f49142c
9f5e1b4
e74c460
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<BoxContainer xmlns="https://spacestation14.io" | ||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
Margin="10 10 10 0" | ||
HorizontalExpand="True" | ||
Visible="True"> | ||
<PanelContainer StyleClasses="AngleRect" HorizontalExpand="True"> | ||
<BoxContainer Orientation="Vertical" | ||
HorizontalExpand="True"> | ||
<BoxContainer Orientation="Horizontal"> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True"> | ||
<RichTextLabel Name="RewardLabel"/> | ||
<RichTextLabel Name="ManifestLabel"/> | ||
<RichTextLabel Name="NoticeLabel"/> | ||
</BoxContainer> | ||
<Control MinWidth="10"/> | ||
<BoxContainer Orientation="Vertical" MinWidth="120"> | ||
<RichTextLabel Name="StatusLabel" HorizontalAlignment="Right" Margin="0 0 5 0"/> | ||
<RichTextLabel Name="IdLabel" HorizontalAlignment="Right" Margin="0 0 5 0"/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</PanelContainer> | ||
</BoxContainer> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Content.Client.Message; | ||
using Content.Shared.Cargo; | ||
using Content.Shared.Cargo.Prototypes; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.Cargo.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class BountyHistoryEntry : BoxContainer | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
|
||
public BountyHistoryEntry(CargoBountyHistoryData bounty) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
if (!_prototype.TryIndex<CargoBountyPrototype>(bounty.Bounty, out var bountyPrototype)) | ||
return; | ||
|
||
var items = new List<string>(); | ||
foreach (var entry in bountyPrototype.Entries) | ||
{ | ||
items.Add(Loc.GetString("bounty-console-manifest-entry", | ||
("amount", entry.Amount), | ||
("item", Loc.GetString(entry.Name)))); | ||
} | ||
ManifestLabel.SetMarkup(Loc.GetString("bounty-console-manifest-label", ("item", string.Join(", ", items)))); | ||
RewardLabel.SetMarkup(Loc.GetString("bounty-console-reward-label", ("reward", bountyPrototype.Reward))); | ||
IdLabel.SetMarkup(Loc.GetString("bounty-console-id-label", ("id", bounty.Id))); | ||
|
||
var stationTime = bounty.Timestamp.ToString("hh\\:mm\\:ss"); | ||
if (bounty.ActorName == null) | ||
{ | ||
StatusLabel.SetMarkup(Loc.GetString("bounty-console-history-completed-label")); | ||
NoticeLabel.SetMarkup(Loc.GetString("bounty-console-history-notice-completed-label", ("time", stationTime))); | ||
} | ||
else | ||
{ | ||
StatusLabel.SetMarkup(Loc.GetString("bounty-console-history-skipped-label")); | ||
NoticeLabel.SetMarkup(Loc.GetString("bounty-console-history-notice-skipped-label", | ||
("id", bounty.ActorName), | ||
("time", stationTime))); | ||
} | ||
} | ||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
} | ||
Comment on lines
+50
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove empty FrameUpdate method The empty FrameUpdate method can be removed as it only calls the base implementation. -protected override void FrameUpdate(FrameEventArgs args)
-{
- base.FrameUpdate(args);
-} |
||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,8 +17,11 @@ public CargoBountyMenu() | |||||||||||||||||||||||
RobustXamlLoader.Load(this); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
public void UpdateEntries(List<CargoBountyData> bounties, TimeSpan untilNextSkip) | ||||||||||||||||||||||||
public void UpdateEntries(List<CargoBountyData> bounties, List<CargoBountyHistoryData> history, TimeSpan untilNextSkip) | ||||||||||||||||||||||||
{ | ||||||||||||||||||||||||
MasterTabContainer.SetTabTitle(0, Loc.GetString("bounty-console-tab-available-label")); | ||||||||||||||||||||||||
MasterTabContainer.SetTabTitle(1, Loc.GetString("bounty-console-tab-history-label")); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Comment on lines
+20
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add parameter validation The method should validate the input parameters to prevent potential null reference exceptions. Consider adding parameter validation: -public void UpdateEntries(List<CargoBountyData> bounties, List<CargoBountyHistoryData> history, TimeSpan untilNextSkip)
+public void UpdateEntries(List<CargoBountyData> bounties, List<CargoBountyHistoryData> history, TimeSpan untilNextSkip)
{
+ ArgumentNullException.ThrowIfNull(bounties);
+ ArgumentNullException.ThrowIfNull(history);
+
MasterTabContainer.SetTabTitle(0, Loc.GetString("bounty-console-tab-available-label"));
MasterTabContainer.SetTabTitle(1, Loc.GetString("bounty-console-tab-history-label")); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
BountyEntriesContainer.Children.Clear(); | ||||||||||||||||||||||||
foreach (var b in bounties) | ||||||||||||||||||||||||
{ | ||||||||||||||||||||||||
|
@@ -32,5 +35,12 @@ public void UpdateEntries(List<CargoBountyData> bounties, TimeSpan untilNextSkip | |||||||||||||||||||||||
{ | ||||||||||||||||||||||||
MinHeight = 10 | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
BountyHistoryContainer.Children.Clear(); | ||||||||||||||||||||||||
foreach (var h in history) | ||||||||||||||||||||||||
{ | ||||||||||||||||||||||||
var entry = new BountyHistoryEntry(h); | ||||||||||||||||||||||||
BountyHistoryContainer.AddChild(entry); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -8,7 +8,7 @@ | |||||||
namespace Content.Client.Stack | ||||||||
{ | ||||||||
[UsedImplicitly] | ||||||||
public sealed class StackSystem : SharedStackSystem | ||||||||
public sealed partial class StackSystem : SharedStackSystem // Frontier: add partial to class definition | ||||||||
{ | ||||||||
[Dependency] private readonly AppearanceSystem _appearanceSystem = default!; | ||||||||
[Dependency] private readonly ItemCounterSystem _counterSystem = default!; | ||||||||
|
@@ -44,7 +44,7 @@ public override void SetCount(EntityUid uid, int amount, StackComponent? compone | |||||||
// TODO PREDICT ENTITY DELETION: This should really just be a normal entity deletion call. | ||||||||
if (component.Count <= 0 && !component.Lingering) | ||||||||
{ | ||||||||
Xform.DetachEntity(uid, Transform(uid)); | ||||||||
Xform.DetachParentToNull(uid, Transform(uid)); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null check for Transform component The DetachParentToNull call should include a null check for the Transform component. -Xform.DetachParentToNull(uid, Transform(uid));
+if (TryComp<TransformComponent>(uid, out var transform))
+ Xform.DetachParentToNull(uid, transform); 📝 Committable suggestion
Suggested change
|
||||||||
return; | ||||||||
} | ||||||||
|
||||||||
|
@@ -56,20 +56,25 @@ private void OnAppearanceChange(EntityUid uid, StackComponent comp, ref Appearan | |||||||
if (args.Sprite == null || comp.LayerStates.Count < 1) | ||||||||
return; | ||||||||
|
||||||||
StackLayerData data = new StackLayerData(); // Frontier: use structure to store StackLayerData | ||||||||
|
||||||||
// Skip processing if no actual | ||||||||
if (!_appearanceSystem.TryGetData<int>(uid, StackVisuals.Actual, out var actual, args.Component)) | ||||||||
if (!_appearanceSystem.TryGetData<int>(uid, StackVisuals.Actual, out data.Actual, args.Component)) | ||||||||
return; | ||||||||
|
||||||||
if (!_appearanceSystem.TryGetData<int>(uid, StackVisuals.MaxCount, out var maxCount, args.Component)) | ||||||||
maxCount = comp.LayerStates.Count; | ||||||||
if (!_appearanceSystem.TryGetData<int>(uid, StackVisuals.MaxCount, out data.MaxCount, args.Component)) | ||||||||
data.MaxCount = comp.LayerStates.Count; | ||||||||
|
||||||||
if (!_appearanceSystem.TryGetData<bool>(uid, StackVisuals.Hide, out data.Hidden, args.Component)) | ||||||||
data.Hidden = false; | ||||||||
|
||||||||
if (!_appearanceSystem.TryGetData<bool>(uid, StackVisuals.Hide, out var hidden, args.Component)) | ||||||||
hidden = false; | ||||||||
if (comp.LayerFunction != StackLayerFunction.None) // Frontier: use stack layer function to modify appearance if provided. | ||||||||
ApplyLayerFunction(uid, comp, ref data); // Frontier: definition in _NF/Stack/StackSystem.Layers.cs | ||||||||
|
||||||||
if (comp.IsComposite) | ||||||||
_counterSystem.ProcessCompositeSprite(uid, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite); | ||||||||
_counterSystem.ProcessCompositeSprite(uid, data.Actual, data.MaxCount, comp.LayerStates, data.Hidden, sprite: args.Sprite); | ||||||||
else | ||||||||
_counterSystem.ProcessOpaqueSprite(uid, comp.BaseLayer, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite); | ||||||||
_counterSystem.ProcessOpaqueSprite(uid, comp.BaseLayer, data.Actual, data.MaxCount, comp.LayerStates, data.Hidden, sprite: args.Sprite); | ||||||||
} | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Content.Shared.Stacks.Components; | ||
using Content.Shared.Stacks; | ||
|
||
namespace Content.Client.Stack | ||
{ | ||
/// <summary> | ||
/// Data used to determine which layers of a stack's sprite are visible. | ||
/// </summary> | ||
public struct StackLayerData | ||
{ | ||
public int Actual; | ||
public int MaxCount; | ||
public bool Hidden; | ||
} | ||
|
||
public sealed partial class StackSystem : SharedStackSystem | ||
{ | ||
// Modifies a given stack component to adjust the layers to display. | ||
private bool ApplyLayerFunction(EntityUid uid, StackComponent comp, ref StackLayerData data) | ||
{ | ||
switch (comp.LayerFunction) | ||
{ | ||
case StackLayerFunction.Threshold: | ||
if (TryComp<StackLayerThresholdComponent>(uid, out var threshold)) | ||
{ | ||
ApplyThreshold(threshold, ref data); | ||
return true; | ||
} | ||
break; | ||
} | ||
// No function applied. | ||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// Sets Actual to the number of thresholds that Actual exceeds from the beginning of the list. | ||
/// Sets MaxCount to the total number of thresholds plus one (for values under thresholds). | ||
/// </summary> | ||
private static void ApplyThreshold(StackLayerThresholdComponent comp, ref StackLayerData data) | ||
{ | ||
// We must stop before we run out of thresholds or layers, whichever's smaller. | ||
data.MaxCount = Math.Min(comp.Thresholds.Count + 1, data.MaxCount); | ||
int newActual = 0; | ||
foreach (var threshold in comp.Thresholds) | ||
{ | ||
//If our value exceeds threshold, the next layer should be displayed. | ||
//Note: we must ensure actual <= MaxCount. | ||
if (data.Actual >= threshold && newActual < data.MaxCount) | ||
newActual++; | ||
else | ||
break; | ||
} | ||
data.Actual = newActual; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling for missing prototypes
The current implementation silently returns if the prototype is not found. Consider logging an error or showing a user-friendly message.