Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Nov 2, 2024
1 parent bb26a93 commit 13924b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 32 deletions.
22 changes: 10 additions & 12 deletions Content.Client/Lobby/LobbyUIController.cs
Original file line number Diff line number Diff line change
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());
}

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
27 changes: 8 additions & 19 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,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 @@ -824,20 +824,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 @@ -1970,8 +1956,13 @@ private void UpdateLoadoutPreferences()
foreach (var preferenceSelector in _loadoutPreferences)
{
var loadoutId = preferenceSelector.Loadout.ID;
var d = Profile?.LoadoutPreferences.FirstOrDefault(l => l.LoadoutName == loadoutId) ?? preferenceSelector.Preference;
var preference = new LoadoutPreference(d.LoadoutName, d.CustomName, d.CustomDescription, d.CustomColorTint) { Selected = d.Selected };
var loadoutPreference = Profile?.LoadoutPreferences.FirstOrDefault(l => l.LoadoutName == loadoutId) ?? preferenceSelector.Preference;
var preference = new LoadoutPreference(
loadoutPreference.LoadoutName,
loadoutPreference.CustomName,
loadoutPreference.CustomDescription,
loadoutPreference.CustomColorTint)
{ Selected = loadoutPreference.Selected };

preferenceSelector.Preference = preference;

Expand All @@ -1993,8 +1984,6 @@ private void UpdateLoadoutPreferences()
AdminUIHelpers.RemoveConfirm(LoadoutsRemoveUnusableButton, _confirmationData);

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

Expand Down

0 comments on commit 13924b1

Please sign in to comment.