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

Loadouts: add overrides for name, description, and preview entity #1491

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
19 changes: 15 additions & 4 deletions Content.Client/Preferences/UI/LoadoutContainer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,28 @@ public LoadoutContainer(ProtoId<LoadoutPrototype> proto, bool disabled, Formatte

if (_protoManager.TryIndex(proto, out var loadProto))
{
var ent = _entManager.System<LoadoutSystem>().GetFirstOrNull(loadProto);
// Frontier: overrideable prototype fields (description, name, icon [via entity])
Price.Text = "$" + loadProto.Price;
if (ent != null)

bool hasDescription = !string.IsNullOrEmpty(loadProto.Description);
bool hasEntity = !string.IsNullOrEmpty(loadProto.PreviewEntity?.Id);

EntProtoId? ent = null;
if (!hasEntity || !hasDescription) {
ent = _entManager.System<LoadoutSystem>().GetFirstOrNull(loadProto);
}
var finalEnt = hasEntity ? loadProto.PreviewEntity : ent;
if (finalEnt != null)
{
_entity = _entManager.SpawnEntity(ent, MapCoordinates.Nullspace);
_entity = _entManager.SpawnEntity(finalEnt, MapCoordinates.Nullspace);
Sprite.SetEntity(_entity);

var spriteTooltip = new Tooltip();
spriteTooltip.SetMessage(FormattedMessage.FromUnformatted(_entManager.GetComponent<MetaDataComponent>(_entity.Value).EntityDescription));
var description = hasDescription ? loadProto.Description : _entManager.GetComponent<MetaDataComponent>(_entity.Value).EntityDescription;
spriteTooltip.SetMessage(FormattedMessage.FromUnformatted(description));
Sprite.TooltipSupplier = _ => spriteTooltip;
}
// End Frontier
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void RefreshLoadouts(RoleLoadout loadout, ICommonSession session, IDepend
var enabled = loadout.IsValid(session, loadoutProto, collection, out var reason);
var loadoutContainer = new LoadoutContainer(loadoutProto, !enabled, reason);
loadoutContainer.Select.Pressed = pressed;
loadoutContainer.Text = loadoutSystem.GetName(loadProto);
loadoutContainer.Text = string.IsNullOrEmpty(loadProto.Name) ? loadoutSystem.GetName(loadProto) : loadProto.Name; // Frontier: allow overriding loadout names

loadoutContainer.Select.OnPressed += args =>
{
Expand Down
22 changes: 22 additions & 0 deletions Content.Shared/Preferences/Loadouts/LoadoutPrototype.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Shared.Preferences.Loadouts.Effects;
using Content.Shared.Roles;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

namespace Content.Shared.Preferences.Loadouts;

Expand Down Expand Up @@ -29,4 +30,25 @@ public sealed partial class LoadoutPrototype : IPrototype
/// </summary>
[DataField]
public int Price = 0;

/// <summary>
/// Frontier - optional name of the loadout as it appears in the menu
/// </summary>
[DataField]
public string Name = "";

/// <summary>
/// Frontier - optional description of the loadout as it appears in the menu
/// </summary>
[DataField]
public string Description = "";

/// <summary>
/// Frontier - optional entity to use for its sprite in the loadout as it appears in the menu
/// </summary>
/// <remarks>
/// Currently, if not defaulted, this will be the fallback entity used to get the description if an override is not provided here.
/// </remarks>
[DataField]
public EntProtoId? PreviewEntity = default!;
}
8 changes: 8 additions & 0 deletions Resources/Prototypes/_NF/Loadouts/Jobs/Contractor/belt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- type: loadout
id: ContractorClothingBeltPlantFilled
equipment: ContractorClothingBeltPlantFilled
name: botanical belt (filled)
price: 1500

- type: startingGear
Expand All @@ -31,6 +32,7 @@
- type: loadout
id: ContractorClothingBeltChefFilled
equipment: ContractorClothingBeltChefFilled
name: chef belt (filled)
price: 1500

- type: startingGear
Expand Down Expand Up @@ -61,6 +63,7 @@
- type: loadout
id: ContractorClothingBeltMedicalFilled
equipment: ContractorClothingBeltMedicalFilled
name: medical belt (filled)
price: 2000

- type: startingGear
Expand All @@ -81,6 +84,7 @@
- type: loadout
id: ContractorClothingBeltMedicalEMTFilled
equipment: ContractorClothingBeltMedicalEMTFilled
name: EMT belt (filled)
price: 2000

- type: startingGear
Expand All @@ -101,6 +105,7 @@
- type: loadout
id: ContractorClothingBeltUtilityFilled
equipment: ContractorClothingBeltUtilityFilled
name: utility belt (filled)
price: 1500

- type: startingGear
Expand All @@ -121,6 +126,7 @@
- type: loadout
id: ContractorClothingBeltSalvageWebbingFilledNF
equipment: ContractorClothingBeltSalvageWebbingFilledNF
name: salvage rig (filled)
price: 1500

- type: startingGear
Expand Down Expand Up @@ -158,6 +164,7 @@
- type: loadout
id: ContractorClothingBeltPilotFilled
equipment: ContractorClothingBeltPilotFilled
name: pilot webbing (filled)
effects:
- !type:GroupLoadoutEffect
proto: ContractorT1
Expand Down Expand Up @@ -210,6 +217,7 @@
- type: loadout
id: ContractorClothingBeltChaplainSashFilled
equipment: ContractorClothingBeltChaplainSashFilled
name: chaplain sash (filled)
effects:
- !type:GroupLoadoutEffect
proto: ContractorT1
Expand Down
Loading