Special actor fixes

Remove special actor armatures without waiting (fixes incorrect profile when changing examined character without closing the window)
Fix for special actor armatures not reflecting changes in active profiles
Slight refactoring
This commit is contained in:
RisaDev
2024-04-11 01:34:53 +03:00
parent 076460fbdd
commit 933eb27b5e
3 changed files with 24 additions and 31 deletions

View File

@@ -25,6 +25,7 @@ using CustomizePlus.Profiles.Enums;
using CustomizePlus.Profiles.Exceptions;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Interop;
using System.Runtime.Serialization;
namespace CustomizePlus.Profiles;
@@ -487,17 +488,21 @@ public class ProfileManager : IDisposable
if (name.IsNullOrWhitespace())
yield break;
if (_templateEditorManager.IsEditorActive && _templateEditorManager.EditorProfile.Enabled)
bool IsProfileAppliesToCurrentActor(Profile profile)
{
if (ProfileAppliesTo(_templateEditorManager.EditorProfile, name))
{
yield return _templateEditorManager.EditorProfile;
}
return profile.CharacterName.Text == name &&
(!profile.LimitLookupToOwnedObjects ||
(actorIdentifier.Type == IdentifierType.Owned &&
actorIdentifier.PlayerName != _actorManager.GetCurrentPlayer().PlayerName));
}
if (_templateEditorManager.IsEditorActive && _templateEditorManager.EditorProfile.Enabled && IsProfileAppliesToCurrentActor(_templateEditorManager.EditorProfile))
yield return _templateEditorManager.EditorProfile;
foreach (var profile in Profiles)
{
if (ProfileAppliesTo(profile, name) && profile.Enabled)
if (IsProfileAppliesToCurrentActor(profile) && profile.Enabled)
yield return profile;
}
@@ -520,11 +525,6 @@ public class ProfileManager : IDisposable
yield return _templateEditorManager.EditorProfile;
}
/// <summary>
/// Returns whether or not profile applies to the object with the indicated name.
/// </summary>
public bool ProfileAppliesTo(Profile profile, string objectName) => !string.IsNullOrWhiteSpace(objectName) && objectName == profile.CharacterName.Text;
private void SaveProfile(Profile profile)
{
//disallow saving special profiles