* Loadouts redux * Loadout window mockup * More workout * rent * validation * Developments * bcs * More cleanup * Rebuild working * Fix model and loading * obsession * efcore * We got a stew goin * Cleanup * Optional + SeniorEngineering fix * Fixes * Update science.yml * add add * Automatic naming * Update nukeops * Coming together * Right now * stargate * rejig the UI * weh * Loadouts tweaks * Merge conflicts + ordering fix * yerba mate * chocolat * More updates * Add multi-selection support * test h * fikss * a * add tech assistant and hazard suit * huh * Latest changes * add medical loadouts * and science * finish security loadouts * cargo * service done * added wildcards * add command * Move restrictions * Finalising * Fix existing work * Localise next batch * clothing fix * Fix storage names * review * the scooping room * Test fixes * Xamlify * Xamlify this too * Update Resources/Prototypes/Loadouts/Jobs/Medical/paramedic.yml Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> * Update Resources/Prototypes/Loadouts/loadout_groups.yml Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> * Update Resources/Prototypes/Loadouts/Jobs/Civilian/clown.yml Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> * Update Resources/Prototypes/Loadouts/Jobs/Civilian/clown.yml Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> * Update Resources/Prototypes/Loadouts/loadout_groups.yml Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> * Update Resources/Prototypes/Loadouts/Jobs/Security/detective.yml Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> * Update Resources/Prototypes/Loadouts/loadout_groups.yml Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> * ben * Margins --------- Co-authored-by: Firewatch <54725557+musicmanvr@users.noreply.github.com> Co-authored-by: Mr. 27 <koolthunder019@gmail.com> Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com>
94 lines
3.4 KiB
C#
94 lines
3.4 KiB
C#
using System.Linq;
|
|
using Content.Shared.Clothing;
|
|
using Content.Shared.Preferences.Loadouts;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Preferences.UI;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class LoadoutGroupContainer : BoxContainer
|
|
{
|
|
private readonly LoadoutGroupPrototype _groupProto;
|
|
|
|
public event Action<ProtoId<LoadoutPrototype>>? OnLoadoutPressed;
|
|
public event Action<ProtoId<LoadoutPrototype>>? OnLoadoutUnpressed;
|
|
|
|
public LoadoutGroupContainer(RoleLoadout loadout, LoadoutGroupPrototype groupProto, ICommonSession session, IDependencyCollection collection)
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
_groupProto = groupProto;
|
|
|
|
RefreshLoadouts(loadout, session, collection);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates button availabilities and buttons.
|
|
/// </summary>
|
|
public void RefreshLoadouts(RoleLoadout loadout, ICommonSession session, IDependencyCollection collection)
|
|
{
|
|
var protoMan = collection.Resolve<IPrototypeManager>();
|
|
var loadoutSystem = collection.Resolve<IEntityManager>().System<LoadoutSystem>();
|
|
RestrictionsContainer.DisposeAllChildren();
|
|
|
|
if (_groupProto.MinLimit > 0)
|
|
{
|
|
RestrictionsContainer.AddChild(new Label()
|
|
{
|
|
Text = Loc.GetString("loadouts-min-limit", ("count", _groupProto.MinLimit)),
|
|
Margin = new Thickness(5, 0, 5, 5),
|
|
});
|
|
}
|
|
|
|
if (_groupProto.MaxLimit > 0)
|
|
{
|
|
RestrictionsContainer.AddChild(new Label()
|
|
{
|
|
Text = Loc.GetString("loadouts-max-limit", ("count", _groupProto.MaxLimit)),
|
|
Margin = new Thickness(5, 0, 5, 5),
|
|
});
|
|
}
|
|
|
|
if (protoMan.TryIndex(loadout.Role, out var roleProto) && roleProto.Points != null && loadout.Points != null)
|
|
{
|
|
RestrictionsContainer.AddChild(new Label()
|
|
{
|
|
Text = Loc.GetString("loadouts-points-limit", ("count", loadout.Points.Value), ("max", roleProto.Points.Value)),
|
|
Margin = new Thickness(5, 0, 5, 5),
|
|
});
|
|
}
|
|
|
|
LoadoutsContainer.DisposeAllChildren();
|
|
// Didn't use options because this is more robust in future.
|
|
|
|
var selected = loadout.SelectedLoadouts[_groupProto.ID];
|
|
|
|
foreach (var loadoutProto in _groupProto.Loadouts)
|
|
{
|
|
if (!protoMan.TryIndex(loadoutProto, out var loadProto))
|
|
continue;
|
|
|
|
var matchingLoadout = selected.FirstOrDefault(e => e.Prototype == loadoutProto);
|
|
var pressed = matchingLoadout != null;
|
|
|
|
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.Select.OnPressed += args =>
|
|
{
|
|
if (args.Button.Pressed)
|
|
OnLoadoutPressed?.Invoke(loadoutProto);
|
|
else
|
|
OnLoadoutUnpressed?.Invoke(loadoutProto);
|
|
};
|
|
|
|
LoadoutsContainer.AddChild(loadoutContainer);
|
|
}
|
|
}
|
|
}
|