Skip to content

Commit b0cf0d9

Browse files
MajorMothmirrorcultEmoGarbage404Brandon-Huuslarticodefast
authored
Contraband Examine Port (#1350)
## About the PR This PR adds the system that's going to allow us to mark items as contraband. Adding the respective contraband parent to items is going to be for another pr. ported: - space-wizards/space-station-14#28688 - space-wizards/space-station-14#30986 - space-wizards/space-station-14#30930 - space-wizards/space-station-14#30942 - space-wizards/space-station-14#31606 - space-wizards/space-station-14#30970 - space-wizards/space-station-14#33385 - space-wizards/space-station-14#32250 - space-wizards/space-station-14#35206 - space-wizards/space-station-14#35228 - space-wizards/space-station-14#36032 ## Why / Balance It'll allow people to definitely discern whether an item is contraband or not and what severity. ## Technical details Look at PR's mentioned. ## Media (this pr does not actually change these items) <img width="628" height="165" alt="image" src="https://github.com/user-attachments/assets/92c7bb4c-0f8f-46cf-9d7f-c9de29a1a473" /> <img width="644" height="268" alt="image" src="https://github.com/user-attachments/assets/053a211c-8f4c-435c-beff-62e3b84a01fe" /> <img width="886" height="170" alt="image" src="https://github.com/user-attachments/assets/09c661aa-b7f8-4e51-bd3d-9110fe22657b" /> ## Requirements - [x] I have read and am following the [Pull Request and Changelog Guidelines](https://docs.spacestation14.com/en/general-development/codebase-info/pull-request-guidelines.html). - [x] I have added media to this PR or it does not require an ingame showcase. - [x] I can confirm this PR contains no AI-generated content, and did not use any AI-generated content. ## Breaking changes None as far as I know. ## Changelog Not needed. --------- Co-authored-by: Kara <lunarautomaton6@gmail.com> Co-authored-by: EmoGarbage404 <retron404@gmail.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Co-authored-by: Brandon Hu <103440971+Brandon-Huu@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Co-authored-by: Plykiya <58439124+Plykiya@users.noreply.github.com> Co-authored-by: Winkarst <74284083+Winkarst-cpu@users.noreply.github.com> Co-authored-by: John <35928781+sporkyz@users.noreply.github.com> Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> Co-authored-by: Killerqu00 <47712032+Killerqu00@users.noreply.github.com>
1 parent 87c04c5 commit b0cf0d9

29 files changed

Lines changed: 645 additions & 29 deletions

Content.Client/Examine/ExamineButton.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Robust.Client.AutoGenerated;
1212
using Robust.Client.Graphics;
1313
using Robust.Client.UserInterface.Controls;
14+
using Robust.Client.UserInterface.CustomControls;
1415
using Robust.Client.UserInterface.XAML;
1516
using Robust.Client.Utility;
1617
using Robust.Shared.Utility;
@@ -47,7 +48,17 @@ public ExamineButton(ExamineVerb verb)
4748
Disabled = true;
4849
}
4950

50-
ToolTip = verb.Message ?? verb.Text;
51+
TooltipSupplier = sender =>
52+
{
53+
var label = new RichTextLabel();
54+
label.SetMessage(FormattedMessage.FromMarkupOrThrow(verb.Message ?? verb.Text));
55+
56+
var tooltip = new Tooltip();
57+
tooltip.GetChild(0).Children.Clear();
58+
tooltip.GetChild(0).Children.Add(label);
59+
60+
return tooltip;
61+
};
5162

5263
Icon = new TextureRect
5364
{

Content.Client/Examine/ExamineSystem.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,28 @@ private void AddVerbsToTooltip(IEnumerable<Verb> verbs)
331331
{
332332
Name = "ExamineButtonsHBox",
333333
Orientation = LayoutOrientation.Horizontal,
334-
HorizontalAlignment = Control.HAlignment.Right,
334+
HorizontalAlignment = Control.HAlignment.Stretch,
335335
VerticalAlignment = Control.VAlignment.Bottom,
336336
};
337337

338+
var hoverExamineBox = new BoxContainer
339+
{
340+
Name = "HoverExamineHBox",
341+
Orientation = LayoutOrientation.Horizontal,
342+
HorizontalAlignment = Control.HAlignment.Left,
343+
VerticalAlignment = Control.VAlignment.Center,
344+
HorizontalExpand = true
345+
};
346+
347+
var clickExamineBox = new BoxContainer
348+
{
349+
Name = "ClickExamineHBox",
350+
Orientation = LayoutOrientation.Horizontal,
351+
HorizontalAlignment = Control.HAlignment.Right,
352+
VerticalAlignment = Control.VAlignment.Center,
353+
HorizontalExpand = true
354+
};
355+
338356
// Examine button time
339357
foreach (var verb in verbs)
340358
{
@@ -349,8 +367,15 @@ private void AddVerbsToTooltip(IEnumerable<Verb> verbs)
349367

350368
var button = new ExamineButton(examine);
351369

352-
button.OnPressed += VerbButtonPressed;
353-
buttonsHBox.AddChild(button);
370+
if (examine.HoverVerb)
371+
{
372+
hoverExamineBox.AddChild(button);
373+
}
374+
else
375+
{
376+
button.OnPressed += VerbButtonPressed;
377+
clickExamineBox.AddChild(button);
378+
}
354379
}
355380

356381
var vbox = _examineTooltipOpen?.GetChild(0).GetChild(0);
@@ -367,6 +392,8 @@ private void AddVerbsToTooltip(IEnumerable<Verb> verbs)
367392
{
368393
vbox.Children.Remove(hbox.First());
369394
}
395+
buttonsHBox.AddChild(hoverExamineBox);
396+
buttonsHBox.AddChild(clickExamineBox);
370397
vbox.AddChild(buttonsHBox);
371398
}
372399

Content.Client/Verbs/UI/VerbMenuElement.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
using Content.Shared.Verbs;
1313
using Robust.Client.GameObjects;
1414
using Robust.Client.UserInterface.Controls;
15+
using Robust.Client.UserInterface.CustomControls;
1516
using Robust.Client.Utility;
1617
using Robust.Shared.GameObjects;
1718
using Robust.Shared.IoC;
1819
using Robust.Shared.Maths;
20+
using Robust.Shared.Utility;
1921

2022
namespace Content.Client.Verbs.UI
2123
{
@@ -36,7 +38,17 @@ public sealed partial class VerbMenuElement : ContextMenuElement
3638

3739
public VerbMenuElement(Verb verb) : base(verb.Text)
3840
{
39-
ToolTip = verb.Message;
41+
TooltipSupplier = sender =>
42+
{
43+
var label = new RichTextLabel();
44+
label.SetMessage(FormattedMessage.FromMarkupOrThrow(verb.Message ?? verb.Text));
45+
46+
var tooltip = new Tooltip();
47+
tooltip.GetChild(0).Children.Clear();
48+
tooltip.GetChild(0).Children.Add(label);
49+
50+
return tooltip;
51+
};
4052
Disabled = verb.Disabled;
4153
Verb = verb;
4254

Content.Client/Verbs/VerbSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public void ExecuteVerb(NetEntity target, Verb verb)
233233
{
234234
// maybe send an informative pop-up message.
235235
if (!string.IsNullOrWhiteSpace(verb.Message))
236-
_popupSystem.PopupEntity(verb.Message, user);
236+
_popupSystem.PopupEntity(FormattedMessage.RemoveMarkupOrThrow(verb.Message), user);
237237

238238
return;
239239
}

Content.Server/Medical/SuitSensors/SuitSensorSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public void SetSensor(Entity<SuitSensorComponent> sensors, SuitSensorMode mode,
428428
userJobIcon = card.Comp.JobIcon;
429429

430430
foreach (var department in card.Comp.JobDepartments)
431-
userJobDepartments.Add(Loc.GetString(department));
431+
userJobDepartments.Add(Loc.GetString($"department-{department}"));
432432
}
433433

434434
// get health mob state

Content.Server/Verbs/VerbSystem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
using Content.Shared.Hands.Components;
3535
using Content.Shared.Inventory.VirtualItem;
3636
using Content.Shared.Verbs;
37+
using Robust.Shared.Utility;
3738

3839
namespace Content.Server.Verbs
3940
{
@@ -102,7 +103,7 @@ public override void ExecuteVerb(Verb verb, EntityUid user, EntityUid target, bo
102103
{
103104
// Send an informative pop-up message
104105
if (!string.IsNullOrWhiteSpace(verb.Message))
105-
_popupSystem.PopupEntity(verb.Message, user, user);
106+
_popupSystem.PopupEntity(FormattedMessage.RemoveMarkupOrThrow(verb.Message), user, user);
106107

107108
return;
108109
}

Content.Shared/Access/Components/IdCardComponent.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
using Content.Shared.Access.Systems;
3232
using Content.Shared.PDA;
33+
using Content.Shared.Roles;
3334
using Content.Shared.StatusIcon;
3435
using Robust.Shared.GameStates;
3536
using Robust.Shared.Prototypes;
@@ -51,6 +52,8 @@ public sealed partial class IdCardComponent : Component
5152
[Access(typeof(SharedIdCardSystem), typeof(SharedPdaSystem), typeof(SharedAgentIdCardSystem), Other = AccessPermissions.ReadWrite)]
5253
public LocId? JobTitle;
5354

55+
[DataField]
56+
[AutoNetworkedField]
5457
private string? _jobTitle;
5558

5659
[Access(typeof(SharedIdCardSystem), typeof(SharedPdaSystem), typeof(SharedAgentIdCardSystem), Other = AccessPermissions.ReadWriteExecute)]
@@ -64,11 +67,11 @@ public sealed partial class IdCardComponent : Component
6467
public ProtoId<JobIconPrototype> JobIcon = "JobIconUnknown";
6568

6669
/// <summary>
67-
/// The unlocalized names of the departments associated with the job
70+
/// The proto IDs of the departments associated with the job
6871
/// </summary>
6972
[DataField]
7073
[AutoNetworkedField]
71-
public List<LocId> JobDepartments = new();
74+
public List<ProtoId<DepartmentPrototype>> JobDepartments = new();
7275

7376
/// <summary>
7477
/// Determines if accesses from this card should be logged by <see cref="AccessReaderComponent"/>

Content.Shared/Access/Systems/SharedIdCardSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public bool TryChangeJobDepartment(EntityUid uid, JobPrototype job, IdCardCompon
185185
foreach (var department in _prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
186186
{
187187
if (department.Roles.Contains(job.ID))
188-
id.JobDepartments.Add("department-" + department.ID);
188+
id.JobDepartments.Add(department.ID);
189189
}
190190

191191
Dirty(uid, id);

Content.Shared/CCVar/CCVars.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,10 @@ public sealed partial class CCVars : CVars
128128
public static readonly CVarDef<bool> GameHostnameInTitlebar =
129129
CVarDef.Create("game.hostname_in_titlebar", true, CVar.SERVER | CVar.REPLICATED);
130130

131+
/// <summary>
132+
/// If true, contraband severity can be viewed in the examine menu
133+
/// </summary>
134+
public static readonly CVarDef<bool> ContrabandExamine =
135+
CVarDef.Create("game.contraband_examine", true, CVar.SERVER | CVar.REPLICATED);
136+
131137
}

Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
using Content.Shared.Access.Components;
1818
using Content.Shared.Clothing.Components;
19+
using Content.Shared.Contraband;
1920
using Content.Shared.Inventory;
2021
using Content.Shared.Inventory.Events;
2122
using Content.Shared.Item;
@@ -29,6 +30,7 @@ public abstract class SharedChameleonClothingSystem : EntitySystem
2930
[Dependency] private readonly IComponentFactory _factory = default!;
3031
[Dependency] private readonly IPrototypeManager _proto = default!;
3132
[Dependency] private readonly ClothingSystem _clothingSystem = default!;
33+
[Dependency] private readonly ContrabandSystem _contraband = default!;
3234
[Dependency] private readonly MetaDataSystem _metaData = default!;
3335
[Dependency] private readonly SharedItemSystem _itemSystem = default!;
3436
[Dependency] private readonly TagSystem _tag = default!;
@@ -84,6 +86,17 @@ protected void UpdateVisuals(EntityUid uid, ChameleonClothingComponent component
8486
{
8587
_clothingSystem.CopyVisuals(uid, otherClothing, clothing);
8688
}
89+
90+
// properly mark contraband
91+
if (proto.TryGetComponent("Contraband", out ContrabandComponent? contra))
92+
{
93+
EnsureComp<ContrabandComponent>(uid, out var current);
94+
_contraband.CopyDetails(uid, contra, current);
95+
}
96+
else
97+
{
98+
RemComp<ContrabandComponent>(uid);
99+
}
87100
}
88101

89102
protected virtual void UpdateSprite(EntityUid uid, EntityPrototype proto) { }

0 commit comments

Comments
 (0)