Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
17 changes: 17 additions & 0 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,23 @@
<Label Text="{Loc 'humanoid-profile-editor-loadouts-tab'}" />
<Control Margin="5"/>
<loadouts:LoadoutPicker Name="Loadouts" HorizontalExpand="True" HorizontalAlignment="Stretch" Access="Public"/>
<BoxContainer HorizontalExpand="True" Margin="0 0 0 5">
<Button
Name="LoadoutsShowUnusableButton"
Text="{Loc 'humanoid-profile-editor-loadouts-show-unusable-button'}"
ToolTip="{Loc 'humanoid-profile-editor-loadouts-show-unusable-button-tooltip'}"
ToggleMode="True"
HorizontalAlignment="Stretch"
HorizontalExpand="True"
StyleClasses="OpenRight" />
<Button
Name="LoadoutsRemoveUnusableButton"
Text="You shouldn't see this"
ToolTip="{Loc 'humanoid-profile-editor-loadouts-remove-unusable-button-tooltip'}"
HorizontalAlignment="Stretch"
HorizontalExpand="True"
StyleClasses="OpenLeft" />
</BoxContainer>
</BoxContainer>
</BoxContainer>
<Control Margin="5"/>
Expand Down
98 changes: 97 additions & 1 deletion Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public sealed partial class HumanoidProfileEditor : BoxContainer
// EE - Contractor System Changes End

private Dictionary<Button, ConfirmationData> _confirmationData = new();
private Dictionary<LoadoutPrototype, bool> _loadouts = new(); // WD EDIT
private List<TraitPreferenceSelector> _traitPreferences = new();
private int _traitCount;

Expand Down Expand Up @@ -593,6 +594,14 @@ IRobustRandom random

TraitsShowUnusableButton.OnToggled += args => UpdateTraits(args.Pressed);
TraitsRemoveUnusableButton.OnPressed += _ => TryRemoveUnusableTraits();
// WWDP EDIT START
LoadoutsShowUnusableButton.OnToggled += args =>
{
Loadouts.ShowUnusable = args.Pressed;
UpdateLoadouts();
};
LoadoutsRemoveUnusableButton.OnPressed += _ => TryRemoveUnusableLoadouts();
// WWDP EDIT END

UpdateTraits(false);

Expand Down Expand Up @@ -2391,10 +2400,46 @@ private Dictionary<string, object> CreateTree(List<TraitCategoryPrototype> cats)
return tree;
}

// WWDP EDIT START
private void HideEmptyTabs(List<TraitCategoryPrototype> cats)
{
// TODO: HIDE LOGIC LATER
void CheckAndHideTabs(NeoTabContainer container)
{
foreach (var tabId in container.TakenIds.ToList())
{
var tabControl = container.GetControl<Control>(tabId);
if (tabControl == null) continue;

var shouldHide = tabControl switch
{
NeoTabContainer nested => CheckNestedContainer(nested),
BoxContainer box => !HasVisibleTraits(box),
_ => false
};

if (shouldHide)
container.SetTabVisible(tabId, false);
}
}

bool CheckNestedContainer(NeoTabContainer nested)
{
CheckAndHideTabs(nested);
return !nested.TakenIds.Any(id => nested.GetControl<Control>(id)?.Visible ?? false);
}

bool HasVisibleTraits(BoxContainer box)
{
return box.Children
.OfType<ScrollContainer>()
.SelectMany(scroll => scroll.Children.OfType<BoxContainer>())
.SelectMany(inner => inner.Children.OfType<TraitPreferenceSelector>())
.Any(selector => selector.Visible);
}

CheckAndHideTabs(TraitsTabs);
}
// WWDP EDIT END

private void TryRemoveUnusableTraits()
{
Expand All @@ -2408,6 +2453,57 @@ private void TryRemoveUnusableTraits()
UpdateCharacterRequired();
}

// WWDP EDIT START
private void TryRemoveUnusableLoadouts()
{
if (!AdminUIHelpers.TryConfirm(LoadoutsRemoveUnusableButton, _confirmationData))
return;

if (Profile == null)
return;

var unusableLoadouts = _loadouts.Where(l => !l.Value).Select(l => l.Key.ID).ToList();

var currentProfile = Profile;
foreach (var loadoutId in unusableLoadouts)
{
var loadout = currentProfile.LoadoutPreferencesList.FirstOrDefault(l => l.LoadoutName == loadoutId);
if (loadout != null)
{
var newList = currentProfile.LoadoutPreferencesList.Where(l => l.LoadoutName != loadoutId).ToList();
currentProfile = currentProfile.WithLoadoutPreference(newList);
}
}

Profile = currentProfile;
UpdateLoadouts();
}

private void UpdateLoadoutsRemoveButton()
{
var unusableCount = _loadouts.Count(l => !l.Value);

if (unusableCount > 0)
{
LoadoutsRemoveUnusableButton.Text = Loc.GetString(
"humanoid-profile-editor-loadouts-remove-unusable-button",
("count", unusableCount));
LoadoutsRemoveUnusableButton.RemoveStyleClass(StyleBase.ButtonOpenRight);
LoadoutsRemoveUnusableButton.AddStyleClass(StyleBase.ButtonDanger);
LoadoutsRemoveUnusableButton.Disabled = false;
}
else
{
LoadoutsRemoveUnusableButton.Text = Loc.GetString(
"humanoid-profile-editor-loadouts-remove-unusable-button",
("count", 0));
LoadoutsRemoveUnusableButton.RemoveStyleClass(StyleBase.ButtonDanger);
LoadoutsRemoveUnusableButton.AddStyleClass(StyleBase.ButtonOpenRight);
LoadoutsRemoveUnusableButton.Disabled = true;
}
}
// WWDP EDIT END

#endregion

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Clothing.Loadouts.Systems;
using Content.Shared.Clothing.Loadouts.Prototypes;


namespace Content.Client.Lobby.UI;
Expand All @@ -18,15 +19,36 @@ private void UpdateLoadouts()

var highJob = _controller.GetPreferredJob(Profile);

Loadouts.SetData(
Profile.LoadoutPreferencesList,
new(
_loadouts.Clear();

foreach (var loadout in Profile.LoadoutPreferencesList)
{
if (!_prototypeManager.TryIndex<LoadoutPrototype>(loadout.LoadoutName, out var loadoutProto))
continue;

var usable = _characterRequirementsSystem.CheckRequirementsValid(
loadoutProto.Requirements,
highJob,
Profile,
_requirements.GetRawPlayTimeTrackers(),
_requirements.IsWhitelisted()
)
_requirements.IsWhitelisted(),
loadoutProto,
_entManager,
_prototypeManager,
_cfgManager,
out _
);

_loadouts.Add(loadoutProto, usable);
}

UpdateLoadoutsRemoveButton();

Loadouts.SetData(
Profile.LoadoutPreferencesList,
new(highJob, Profile, _requirements.GetRawPlayTimeTrackers(), _requirements.IsWhitelisted()));

Loadouts.ShowUnusable = LoadoutsShowUnusableButton.Pressed;
}

private void CheckpointLoadouts()
Expand Down
33 changes: 29 additions & 4 deletions Content.Client/_White/Loadouts/LoadoutEntry.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ public string LoadoutName
private set => LoadoutNameLabel.Text = value;
}

private bool _showUnusable;
public bool ShowUnusable
{
get => _showUnusable;
set
{
_showUnusable = value;
Visible = CanWear || _showUnusable;

PreferenceButton.RemoveStyleClass(StyleBase.ButtonDanger);
if (!CanWear)
PreferenceButton.AddStyleClass(StyleBase.ButtonDanger);
}
}

public string LoadoutDescription { get; private set; } = string.Empty;

private Tooltip _reasonTooltip = new();
Expand Down Expand Up @@ -104,16 +119,26 @@ public bool EnsureIsWearable(CharacterRequirementsArgs args, int loadoutPoint)

PreferenceButton.AddStyleClass(StyleBase.ButtonDanger);
CanWear = false;
PreferenceButton.Disabled = true;

if (Selected)
{
PreferenceButton.Disabled = false;
PreferenceButton.MouseFilter = MouseFilterMode.Pass;
}
else
{
PreferenceButton.Disabled = true;
PreferenceButton.MouseFilter = MouseFilterMode.Ignore;
}

HeirloomButton.Visible = false;
HeadingButton.Visible = false;
PreferenceButton.MouseFilter = MouseFilterMode.Ignore;
_reasonTooltip.SetMessage(FormattedMessage.FromMarkupPermissive(reason));

return false;
}

public bool CheckIsWearable(CharacterRequirementsArgs characterRequirementsArgs, int loadoutPoint,[NotNullWhen(false)] out string? reason)
public bool CheckIsWearable(CharacterRequirementsArgs characterRequirementsArgs, int loadoutPoint, [NotNullWhen(false)] out string? reason)
{
ProtoId<LoadoutPrototype> loadoutPrototype = Loadout.LoadoutName;
reason = null;
Expand All @@ -124,7 +149,7 @@ public bool CheckIsWearable(CharacterRequirementsArgs characterRequirementsArgs,
return false;
}

if(prototype.Cost > loadoutPoint)
if (!Selected && prototype.Cost > loadoutPoint)
{
reason = Loc.GetString("loadout-error-too-expensive");
return false;
Expand Down
16 changes: 16 additions & 0 deletions Content.Client/_White/Loadouts/LoadoutPicker.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ public bool LoadCategoryButtons(ProtoId<LoadoutCategoryPrototype> loadoutCategor
loadoutEntry.OnLoadoutDirty += OnEntryLoadoutDirty;
loadoutEntry.EnsureIsWearable(CharacterRequirementsArgs, LoadoutPoint);

loadoutEntry.ShowUnusable = _showUnusable;

_loadoutEntries.Add(loadoutEntry);
}

Expand Down Expand Up @@ -309,6 +311,20 @@ private bool TryFreeLoadout(Loadout loadout)
return true;
}

private bool _showUnusable;
public bool ShowUnusable
{
get => _showUnusable;
set
{
_showUnusable = value;
foreach (var entry in _loadoutEntries)
{
entry.ShowUnusable = value;
}
}
}

private void OnEntryEditLoadoutRequired(LoadoutEntry entry)
{
EditLoadout(entry);
Expand Down
Loading