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 V4 #1164

Merged
merged 53 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8bf3a5b
some base selector additions
DEATHB4DEFEAT Oct 29, 2024
8a817de
more ui and kinda works
DEATHB4DEFEAT Oct 29, 2024
144f983
saving works, horrific performance though?
DEATHB4DEFEAT Oct 29, 2024
fde2fd4
server function to put failed equips in storage
DEATHB4DEFEAT Oct 30, 2024
8d9d7f8
fix guidebook
DEATHB4DEFEAT Oct 30, 2024
e7aeb4d
Revert "Revert Paint (#26593)"
metalgearsloth Mar 31, 2024
6a80dd2
apply loadout effects
DEATHB4DEFEAT Oct 30, 2024
0b585bc
move Special menu and implement toggleable Specials
DEATHB4DEFEAT Oct 30, 2024
467323d
Special menu button is Customize and a real Button
DEATHB4DEFEAT Oct 30, 2024
c7ff9a7
styled button groups
DEATHB4DEFEAT Oct 30, 2024
35c8f86
loadout comps and fix null colors making things white
DEATHB4DEFEAT Nov 1, 2024
f281ed6
cache prefs, improve performance by too much to count
DEATHB4DEFEAT Nov 1, 2024
58ea0f5
big performance boost, use strings instead of converting requirement …
DEATHB4DEFEAT Nov 1, 2024
fede4b3
req fixes
DEATHB4DEFEAT Nov 2, 2024
bb26a93
idk
DEATHB4DEFEAT Nov 2, 2024
13924b1
cleanup
DEATHB4DEFEAT Nov 2, 2024
7f07e61
preview loadout colors
DEATHB4DEFEAT Nov 6, 2024
c0bc891
switching profile changes loadout customization
DEATHB4DEFEAT Nov 6, 2024
0a36528
toggleable color
DEATHB4DEFEAT Nov 6, 2024
bd085e8
localize customize
DEATHB4DEFEAT Nov 6, 2024
8bf596c
rm migration scripts
DEATHB4DEFEAT Nov 6, 2024
a070d7f
barely functional Heirloom toggle
DEATHB4DEFEAT Nov 6, 2024
c2362e7
this should work but isn't?
DEATHB4DEFEAT Nov 8, 2024
a8c14a1
Merge branch 'master' of https://github.com/Simple-Station/Einstein-E…
DEATHB4DEFEAT Nov 14, 2024
b2547d2
fix trait component removal
DEATHB4DEFEAT Nov 14, 2024
f26cc97
fix heirloom moodlet
DEATHB4DEFEAT Nov 14, 2024
b898851
fix live character preview
DEATHB4DEFEAT Nov 14, 2024
6d55ff1
example loadout guidebook
DEATHB4DEFEAT Nov 14, 2024
61125b0
remove some temporary things
DEATHB4DEFEAT Nov 14, 2024
d237304
Revert "Revert Paint (#26593)"
metalgearsloth Mar 31, 2024
c3584be
fix shader not reapplying
DEATHB4DEFEAT Nov 14, 2024
de00169
lots of cleaning
DEATHB4DEFEAT Nov 14, 2024
e43d539
expression body
DEATHB4DEFEAT Nov 15, 2024
b82d97c
review changes
DEATHB4DEFEAT Nov 15, 2024
474191f
more style config changes
DEATHB4DEFEAT Nov 15, 2024
7616431
whitelist
DEATHB4DEFEAT Nov 15, 2024
b5fda12
Merge branch 'master' of https://github.com/Simple-Station/Einstein-E…
DEATHB4DEFEAT Nov 15, 2024
9659956
Merge branch 'spray-paint' of https://github.com/DEATHB4DEFEAT/Einste…
DEATHB4DEFEAT Nov 15, 2024
773e90f
Merge branch 'master' of https://github.com/Simple-Station/Einstein-E…
DEATHB4DEFEAT Nov 16, 2024
84796c0
Update Content.Client/Lobby/UI/LoadoutPreferenceSelector.xaml.cs
DEATHB4DEFEAT Nov 16, 2024
18f68a2
fix imports/exports
DEATHB4DEFEAT Nov 17, 2024
982b4fa
heirlooms and colors
DEATHB4DEFEAT Nov 17, 2024
ddbae36
Merge branch 'master' of https://github.com/Simple-Station/Einstein-E…
DEATHB4DEFEAT Nov 17, 2024
b23c567
heirloom update timer
DEATHB4DEFEAT Nov 20, 2024
284d129
Merge remote-tracking branch 'origin/master' into pr/1164
VMSolidus Nov 25, 2024
400070c
Updates
VMSolidus Nov 25, 2024
b160003
Update Submodule
VMSolidus Nov 25, 2024
e3ae522
Revert "Update Submodule"
VMSolidus Nov 25, 2024
9e515aa
Revert "Updates"
VMSolidus Nov 25, 2024
2f865dd
Reapply "Update Submodule"
VMSolidus Nov 25, 2024
fab4a5e
Reapply "Updates"
VMSolidus Nov 25, 2024
6e866e1
Update uncategorized.yml
VMSolidus Nov 25, 2024
d6aff6c
Last few stuff
VMSolidus Nov 25, 2024
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
24 changes: 11 additions & 13 deletions Content.Client/Lobby/LobbyUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
[Dependency] private readonly JobRequirementsManager _jobRequirements = default!;
[UISystemDependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
[UISystemDependency] private readonly ClientInventorySystem _inventory = default!;
[UISystemDependency] private readonly LoadoutSystem _loadouts = default!;
[UISystemDependency] private readonly SharedLoadoutSystem _loadouts = default!;

private CharacterSetupGui? _characterSetup;
private HumanoidProfileEditor? _profileEditor;
Expand Down Expand Up @@ -159,7 +159,7 @@ private void RefreshLobbyPreview()
return;
}

var dummy = LoadProfileEntity(humanoid, true);
var dummy = LoadProfileEntity(humanoid, true, true);
PreviewPanel.SetSprite(dummy);
PreviewPanel.SetSummaryText(humanoid.Summary);
}
Expand Down Expand Up @@ -262,14 +262,6 @@ public void RemoveDummyClothes(EntityUid dummy)
EntityManager.DeleteEntity(unequippedItem.Value);
}

/// Applies the highest priority job's clothes and loadouts to the dummy.
public void GiveDummyJobClothesLoadout(EntityUid dummy, HumanoidCharacterProfile profile)
{
var job = GetPreferredJob(profile);
GiveDummyJobClothes(dummy, job, profile);
_loadouts.ApplyCharacterLoadout(dummy, job, profile, _jobRequirements.GetRawPlayTimeTrackers(), _jobRequirements.IsWhitelisted());
}

/// Applies the specified job's clothes to the dummy.
public void GiveDummyJobClothes(EntityUid dummy, JobPrototype job, HumanoidCharacterProfile profile)
{
Expand All @@ -295,7 +287,7 @@ public void GiveDummyJobClothes(EntityUid dummy, JobPrototype job, HumanoidChara
}

/// Loads the profile onto a dummy entity
public EntityUid LoadProfileEntity(HumanoidCharacterProfile? humanoid, bool jobClothes)
public EntityUid LoadProfileEntity(HumanoidCharacterProfile? humanoid, bool jobClothes, bool loadouts)
{
EntityUid dummyEnt;

Expand All @@ -311,8 +303,14 @@ public EntityUid LoadProfileEntity(HumanoidCharacterProfile? humanoid, bool jobC

_humanoid.LoadProfile(dummyEnt, humanoid);

if (humanoid != null && jobClothes)
GiveDummyJobClothesLoadout(dummyEnt, humanoid);
if (humanoid != null)
{
var job = GetPreferredJob(humanoid);
if (jobClothes)
GiveDummyJobClothes(dummyEnt, job, humanoid);
if (loadouts)
_loadouts.ApplyCharacterLoadout(dummyEnt, job, humanoid, _jobRequirements.GetRawPlayTimeTrackers(), _jobRequirements.IsWhitelisted(), out _);
}

return dummyEnt;
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Lobby/UI/CharacterPickerButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public CharacterPickerButton(
else
{
_previewDummy = UserInterfaceManager.GetUIController<LobbyUIController>()
.LoadProfileEntity(humanoid, true);
.LoadProfileEntity(humanoid, true, true);

var highPriorityJob = humanoid.JobPriorities.SingleOrDefault(p => p.Value == JobPriority.High).Key;
if (highPriorityJob != null)
Expand Down
73 changes: 39 additions & 34 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Content.Shared.CCVar;
using Content.Shared.Clothing.Components;
using Content.Shared.Clothing.Loadouts.Prototypes;
using Content.Shared.Clothing.Loadouts.Systems;
using Content.Shared.Customization.Systems;
using Content.Shared.GameTicking;
using Content.Shared.Humanoid;
Expand Down Expand Up @@ -76,7 +77,7 @@ public sealed partial class HumanoidProfileEditor : BoxContainer
private Dictionary<Button, ConfirmationData> _confirmationData = new();
private List<TraitPreferenceSelector> _traitPreferences = new();
private int _traitCount;
private List<LoadoutPreferenceSelector> _loadoutPreferences = new();
private HashSet<LoadoutPreferenceSelector> _loadoutPreferences = new();

private Direction _previewRotation = Direction.North;
private ColorSelectorSliders _rgbSkinColorSelector;
Expand Down Expand Up @@ -427,7 +428,7 @@ public HumanoidProfileEditor(
// Set up the loadouts tab
LoadoutsTab.Orphan();
CTabContainer.AddTab(LoadoutsTab, Loc.GetString("humanoid-profile-editor-loadouts-tab"));
_loadoutPreferences = new List<LoadoutPreferenceSelector>();
_loadoutPreferences = new();

// Show/Hide the loadouts tab if they ever get enabled/disabled
var loadoutsEnabled = cfgManager.GetCVar(CCVars.GameLoadoutsEnabled);
Expand Down Expand Up @@ -473,7 +474,8 @@ public HumanoidProfileEditor(

#endregion Left

ShowClothes.OnToggled += args => { ReloadProfilePreview(); };
ShowClothes.OnToggled += _ => { SetProfile(Profile, CharacterSlot); };
ShowLoadouts.OnToggled += _ => { SetProfile(Profile, CharacterSlot); };

SpeciesInfoButton.OnPressed += OnSpeciesInfoButtonPressed;
UpdateSpeciesGuidebookIcon();
Expand Down Expand Up @@ -614,7 +616,7 @@ private void ReloadPreview()
if (Profile == null || !_prototypeManager.HasIndex<SpeciesPrototype>(Profile.Species))
return;

PreviewDummy = _controller.LoadProfileEntity(Profile, ShowClothes.Pressed);
PreviewDummy = _controller.LoadProfileEntity(Profile, ShowClothes.Pressed, ShowLoadouts.Pressed);
SpriteView.SetEntity(PreviewDummy);
}

Expand Down Expand Up @@ -823,20 +825,6 @@ public void RefreshJobs()
UpdateJobPriorities();
}

private void ToggleClothes(BaseButton.ButtonEventArgs _)
{
//TODO: Optimization
// _controller.ShowClothes = ShowClothes.Pressed;
// _controller.UpdateCharacterUI();
}

private void ToggleLoadouts(BaseButton.ButtonEventArgs _)
{
//TODO: Optimization
// _controller.ShowLoadouts = ShowLoadouts.Pressed;
// _controller.UpdateCharacterUI();
}

private void UpdateRoleRequirements()
{
JobList.DisposeAllChildren();
Expand Down Expand Up @@ -959,7 +947,7 @@ private void UpdateRoleRequirements()
Profile = Profile?.WithJobPriority(job.ID, (JobPriority) priority);
ReloadPreview();
SetDirty();
UpdateCharacterRequired();
SetProfile(Profile, CharacterSlot);
};

_jobPriorities.Add((job.ID, selector));
Expand Down Expand Up @@ -1610,7 +1598,7 @@ private async void ExportProfile()
}
catch (Exception exc)
{
Logger.Error($"Error when exporting profile\n{exc.StackTrace}");
Logger.Error($"Error when exporting profile: {exc.Message}\n{exc.StackTrace}");
}
finally
{
Expand Down Expand Up @@ -1882,7 +1870,7 @@ void AddSelector(TraitPreferenceSelector selector)
Profile = Profile?.WithTraitPreference(selector.Trait.ID, preference);
IsDirty = true;
UpdateTraitPreferences();
UpdateCharacterRequired();
SetProfile(Profile, CharacterSlot);
};
}

Expand Down Expand Up @@ -1969,11 +1957,18 @@ private void UpdateLoadoutPreferences()
foreach (var preferenceSelector in _loadoutPreferences)
{
var loadoutId = preferenceSelector.Loadout.ID;
var preference = Profile?.LoadoutPreferences.Contains(loadoutId) ?? false;
var loadoutPreference = Profile?.LoadoutPreferences.FirstOrDefault(l => l.LoadoutName == loadoutId) ?? preferenceSelector.Preference;
var preference = new LoadoutPreference(
loadoutPreference.LoadoutName,
loadoutPreference.CustomName,
loadoutPreference.CustomDescription,
loadoutPreference.CustomColorTint,
loadoutPreference.CustomHeirloom)
{ Selected = loadoutPreference.Selected };

preferenceSelector.Preference = preference;

if (preference)
if (preference.Selected)
{
points -= preferenceSelector.Loadout.Cost;
LoadoutPointsBar.Value = points;
Expand All @@ -1985,14 +1980,12 @@ private void UpdateLoadoutPreferences()
LoadoutsRemoveUnusableButton.Text = Loc.GetString("humanoid-profile-editor-loadouts-remove-unusable-button",
("count", _loadouts
.Where(l => _loadoutPreferences
.Where(lps => lps.Preference).Select(lps => lps.Loadout).Contains(l.Key))
.Where(lps => lps.Preference.Selected).Select(lps => lps.Loadout).Contains(l.Key))
.Count(l => !l.Value
|| !_loadoutPreferences.Find(lps => lps.Loadout == l.Key)!.Wearable)));
|| !_loadoutPreferences.First(lps => lps.Loadout == l.Key).Wearable)));
AdminUIHelpers.RemoveConfirm(LoadoutsRemoveUnusableButton, _confirmationData);

IsDirty = true;
//TODO: Optimization
// _controller.UpdateClothes = true;
ReloadProfilePreview();
}

Expand Down Expand Up @@ -2039,10 +2032,11 @@ out _
);
_loadouts.Add(loadout, usable);

if (_loadoutPreferences.FindIndex(lps => lps.Loadout.ID == loadout.ID) is not (not -1 and var i))
var list = _loadoutPreferences.ToList();
if (list.FindIndex(lps => lps.Loadout.ID == loadout.ID) is not (not -1 and var i))
continue;

var selector = _loadoutPreferences[i];
var selector = list[i];
UpdateSelector(selector, usable);
}

Expand Down Expand Up @@ -2108,14 +2102,17 @@ out _
if (_loadoutPreferences.Select(lps => lps.Loadout.ID).Contains(loadout.ID))
{
var first = _loadoutPreferences.First(lps => lps.Loadout.ID == loadout.ID);
var prof = Profile?.LoadoutPreferences.FirstOrDefault(lp => lp.LoadoutName == loadout.ID);
first.Preference = new(loadout.ID, prof?.CustomName, prof?.CustomDescription, prof?.CustomColorTint, prof?.CustomHeirloom);
UpdateSelector(first, usable);
continue;
}

var selector = new LoadoutPreferenceSelector(
loadout, highJob ?? new JobPrototype(),
Profile ?? HumanoidCharacterProfile.DefaultWithSpecies(), ref _dummyLoadouts,
_entManager, _prototypeManager, _cfgManager, _characterRequirementsSystem, _requirements);
_entManager, _prototypeManager, _cfgManager, _characterRequirementsSystem, _requirements)
{ Preference = new(loadout.ID) };
UpdateSelector(selector, usable);
AddSelector(selector);

Expand Down Expand Up @@ -2226,13 +2223,21 @@ void AddSelector(LoadoutPreferenceSelector selector)
selector.PreferenceChanged += preference =>
{
// Make sure they have enough loadout points
preference = preference ? CheckPoints(-selector.Loadout.Cost, preference) : CheckPoints(selector.Loadout.Cost, preference);
var selected = preference.Selected
? CheckPoints(-selector.Loadout.Cost, preference.Selected)
: CheckPoints(selector.Loadout.Cost, preference.Selected);

// Update Preferences
Profile = Profile?.WithLoadoutPreference(selector.Loadout.ID, preference);
Profile = Profile?.WithLoadoutPreference(
selector.Loadout.ID,
selected,
preference.CustomName,
preference.CustomDescription,
preference.CustomColorTint,
preference.CustomHeirloom);
IsDirty = true;
UpdateLoadoutPreferences();
UpdateCharacterRequired();
SetProfile(Profile, CharacterSlot);
};
}

Expand Down Expand Up @@ -2320,7 +2325,7 @@ private void TryRemoveUnusableLoadouts()
// Remove unusable and unwearable loadouts
foreach (var (loadout, _) in
_loadouts.Where(l =>
!l.Value || !_loadoutPreferences.Find(lps => lps.Loadout.ID == l.Key.ID)!.Wearable).ToList())
!l.Value || !_loadoutPreferences.First(lps => lps.Loadout.ID == l.Key.ID).Wearable).ToList())
Profile = Profile?.WithLoadoutPreference(loadout.ID, false);
UpdateCharacterRequired();
}
Expand Down
81 changes: 74 additions & 7 deletions Content.Client/Lobby/UI/LoadoutPreferenceSelector.xaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,77 @@
<Control xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<BoxContainer Name="Container" Orientation="Horizontal">
<Button
Name="PreferenceButton"
ToggleMode="True"
VerticalAlignment="Center"
StyleClasses="OpenLeft" />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
<BoxContainer Name="Container" Orientation="Vertical" HorizontalExpand="True">
<controls:StyledButtonGroup Name="ButtonGroup" Orientation="Horizontal" HorizontalExpand="True">
<Button
Name="PreferenceButton"
Access="Public"
ToggleMode="True"
VerticalAlignment="Center" />

<Button
Name="HeirloomButton"
Access="Public"
Text="{Loc 'humanoid-profile-editor-loadouts-heirloom'}"
ToolTip="{Loc 'humanoid-profile-editor-loadouts-heirloom-tooltip'}"
ToggleMode="True"
VerticalAlignment="Center" />

<!-- Yes I know I can use a TextureButton, but I'm doing this for style -->
<Button
Name="GuidebookButton"
ToolTip="{Loc 'humanoid-profile-editor-loadouts-guidebook-button-tooltip'}"
VerticalAlignment="Center"
StyleClasses="OpenLeft">
<TextureRect
Name="GuidebookButtonIcon"
TexturePath="/Textures/Interface/VerbIcons/information.svg.192dpi.png"
TextureScale="0.4 0.4"
VerticalAlignment="Center"
Margin="5" />
</Button>
</controls:StyledButtonGroup>


<Collapsible Name="SpecialMenu" HorizontalExpand="True">
<Button Name="HeadingButton" Text="{Loc 'humanoid-profile-editor-loadouts-customize'}" ToggleMode="True" />

<CollapsibleBody HorizontalExpand="True" Margin="0 0 0 5">
<PanelContainer HorizontalExpand="True">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#2f2f2f" BorderColor="#2f2f2faf" BorderThickness="1" />
</PanelContainer.PanelOverride>

<BoxContainer Orientation="Vertical" Margin="3" HorizontalExpand="True">
<BoxContainer Name="SpecialName" Orientation="Vertical" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-loadouts-customize-name'}" />
<LineEdit Name="NameEdit" HorizontalExpand="True" />
</BoxContainer>

<BoxContainer Name="SpecialDescription" Orientation="Vertical" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-loadouts-customize-description'}" />
<PanelContainer HorizontalExpand="True">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#222222" />
</PanelContainer.PanelOverride>

<controls:ResizableControl
AllowedResizeDirection="Vertical"
HorizontalExpand="True"
MinSize="128 64">
<TextEdit Name="DescriptionEdit" HorizontalExpand="True" VerticalExpand="True" Margin="3" />
</controls:ResizableControl>
</PanelContainer>
</BoxContainer>

<Button Name="SpecialColorTintToggle" Text="{Loc 'humanoid-profile-editor-loadouts-customize-color'}" ToggleMode="True" Margin="0 3 0 0" StyleClasses="OpenBoth" />
<ColorSelectorSliders Name="ColorEdit" Color="#fff" HorizontalExpand="True" />

<Button Name="SaveButton" Text="{Loc 'humanoid-profile-editor-loadouts-customize-save'}" HorizontalExpand="True" Margin="0 3 0 0" StyleClasses="OpenBoth" />
</BoxContainer>
</PanelContainer>
</CollapsibleBody>
</Collapsible>
</BoxContainer>
</Control>
Loading