From 3e290cbabc9a797fb425e7e30977f3c2ab0cfe6f Mon Sep 17 00:00:00 2001 From: RisaDev <151885272+RisaDev@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:34:35 +0300 Subject: [PATCH] Rename CompareIgnoringOwnership and FindActorsByIdentifier --- .../Extensions/ActorIdentifierExtensions.cs | 4 ++-- CustomizePlus/Api/CustomizePlusIpc.Profile.cs | 2 +- CustomizePlus/Armatures/Services/ArmatureManager.cs | 2 +- .../Configuration/Data/PluginConfiguration.cs | 5 +++++ CustomizePlus/Game/Services/GameObjectService.cs | 6 +++--- CustomizePlus/Profiles/ProfileManager.cs | 13 +++++++------ CustomizePlus/Templates/TemplateEditorManager.cs | 2 +- .../Tabs/Profiles/ProfileFileSystemSelector.cs | 4 ++-- 8 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CustomizePlus.GameData/Extensions/ActorIdentifierExtensions.cs b/CustomizePlus.GameData/Extensions/ActorIdentifierExtensions.cs index 8e3d834..42d7eb1 100644 --- a/CustomizePlus.GameData/Extensions/ActorIdentifierExtensions.cs +++ b/CustomizePlus.GameData/Extensions/ActorIdentifierExtensions.cs @@ -29,9 +29,9 @@ public static class ActorIdentifierExtensions } /// - /// Compares two actor identifiers while ignoring ownership for owned objects. For all other identifier types will use Matches() method. + /// Matches() method but ignoring ownership for owned objects. /// - public static bool CompareIgnoringOwnership(this ActorIdentifier identifier, ActorIdentifier other) + public static bool MatchesIgnoringOwnership(this ActorIdentifier identifier, ActorIdentifier other) { if (identifier.Type != other.Type) return false; diff --git a/CustomizePlus/Api/CustomizePlusIpc.Profile.cs b/CustomizePlus/Api/CustomizePlusIpc.Profile.cs index 439150e..6dca450 100644 --- a/CustomizePlus/Api/CustomizePlusIpc.Profile.cs +++ b/CustomizePlus/Api/CustomizePlusIpc.Profile.cs @@ -261,7 +261,7 @@ public partial class CustomizePlusIpc //warn: intended limitation - ignores default profiles because why you would use default profile on your own character private void OnArmatureChanged(ArmatureChanged.Type type, Armature armature, object? arg3) { - if (!armature.ActorIdentifier.CompareIgnoringOwnership(_gameObjectService.GetCurrentPlayerActorIdentifier())) + if (armature.ActorIdentifier != _gameObjectService.GetCurrentPlayerActorIdentifier()) return; if (armature.ActorIdentifier.HomeWorld == WorldId.AnyWorld) //Only Cutscene/GPose actors have world set to AnyWorld diff --git a/CustomizePlus/Armatures/Services/ArmatureManager.cs b/CustomizePlus/Armatures/Services/ArmatureManager.cs index be87665..dd0f707 100644 --- a/CustomizePlus/Armatures/Services/ArmatureManager.cs +++ b/CustomizePlus/Armatures/Services/ArmatureManager.cs @@ -539,7 +539,7 @@ public unsafe sealed class ArmatureManager : IDisposable { (var armatureActorIdentifier, _) = _gameObjectService.GetTrueActorForSpecialTypeActor(kvPair.Key); - if (actorIdentifier.IsValid && armatureActorIdentifier.CompareIgnoringOwnership(actorIdentifier) && + if (actorIdentifier.IsValid && armatureActorIdentifier.MatchesIgnoringOwnership(actorIdentifier) && (armatureActorIdentifier.Type != IdentifierType.Owned || armatureActorIdentifier.IsOwnedByLocalPlayer())) yield return kvPair.Value; } diff --git a/CustomizePlus/Configuration/Data/PluginConfiguration.cs b/CustomizePlus/Configuration/Data/PluginConfiguration.cs index 7d3e4e7..39de743 100644 --- a/CustomizePlus/Configuration/Data/PluginConfiguration.cs +++ b/CustomizePlus/Configuration/Data/PluginConfiguration.cs @@ -32,6 +32,11 @@ public class PluginConfiguration : IPluginConfiguration, ISavable /// public Guid DefaultProfile { get; set; } = Guid.Empty; + /// + /// Id of the profile applied to any character user logins with. Can be set to Empty to disable this feature. + /// + public Guid DefaultLocalPlayerProfile { get; set; } = Guid.Empty; + [Serializable] public class ChangelogSettingsEntries { diff --git a/CustomizePlus/Game/Services/GameObjectService.cs b/CustomizePlus/Game/Services/GameObjectService.cs index 6cd9677..627cc1c 100644 --- a/CustomizePlus/Game/Services/GameObjectService.cs +++ b/CustomizePlus/Game/Services/GameObjectService.cs @@ -85,9 +85,9 @@ public class GameObjectService } /// - /// Searches using CompareIgnoringOwnership + /// Searches using MatchesIgnoringOwnership /// - public IEnumerable<(ActorIdentifier, Actor)> FindActorsByIdentifier(ActorIdentifier identifier) + public IEnumerable<(ActorIdentifier, Actor)> FindActorsByIdentifierIgnoringOwnership(ActorIdentifier identifier) { if (!identifier.IsValid) yield break; @@ -103,7 +103,7 @@ public class GameObjectService if (!objectIdentifier.IsValid) continue; - if (identifier.CompareIgnoringOwnership(objectIdentifier)) + if (identifier.MatchesIgnoringOwnership(objectIdentifier)) { if (kvPair.Value.Objects.Count > 1) //in gpose we can have more than a single object for one actor foreach (var obj in kvPair.Value.Objects) diff --git a/CustomizePlus/Profiles/ProfileManager.cs b/CustomizePlus/Profiles/ProfileManager.cs index 6836a69..f08056a 100644 --- a/CustomizePlus/Profiles/ProfileManager.cs +++ b/CustomizePlus/Profiles/ProfileManager.cs @@ -172,7 +172,7 @@ public partial class ProfileManager : IDisposable /// public void ChangeCharacter(Profile profile, ActorIdentifier actorIdentifier) { - if (!actorIdentifier.IsValid || actorIdentifier.CompareIgnoringOwnership(profile.Character)) + if (!actorIdentifier.IsValid || actorIdentifier.MatchesIgnoringOwnership(profile.Character)) return; var oldCharacter = profile.Character; @@ -227,7 +227,7 @@ public partial class ProfileManager : IDisposable _logger.Debug($"Setting {profile} as enabled..."); foreach (var otherProfile in Profiles - .Where(x => x.Character.CompareIgnoringOwnership(profile.Character) && x != profile && x.Enabled && !x.IsTemporary)) + .Where(x => x.Character.MatchesIgnoringOwnership(profile.Character) && x != profile && x.Enabled && !x.IsTemporary)) { _logger.Debug($"\t-> {otherProfile} disabled"); SetEnabled(otherProfile, false); @@ -257,6 +257,7 @@ public partial class ProfileManager : IDisposable public void SetApplyToCurrentlyActiveCharacter(Profile profile, bool value) { + //todo: only one profile is allowed to be active for that setting if (profile.ApplyToCurrentlyActiveCharacter != value) { profile.ApplyToCurrentlyActiveCharacter = value; @@ -351,7 +352,7 @@ public partial class ProfileManager : IDisposable profile.ProfileType = ProfileType.Temporary; profile.Character = identifier.CreatePermanent(); //warn: identifier must not be AnyWorld or stuff will break! - var existingProfile = Profiles.FirstOrDefault(x => x.Character.CompareIgnoringOwnership(profile.Character) && x.IsTemporary); + var existingProfile = Profiles.FirstOrDefault(x => x.Character.MatchesIgnoringOwnership(profile.Character) && x.IsTemporary); if (existingProfile != null) { _logger.Debug($"Temporary profile for {existingProfile.Character.Incognito(null)} already exists, removing..."); @@ -409,7 +410,7 @@ public partial class ProfileManager : IDisposable if (!actorIdentifier.IsValid) return null; - var query = Profiles.Where(x => x.Character.CompareIgnoringOwnership(actorIdentifier) && !x.IsTemporary); + var query = Profiles.Where(x => x.Character.MatchesIgnoringOwnership(actorIdentifier) && !x.IsTemporary); if (enabledOnly) query = query.Where(x => x.Enabled); @@ -458,13 +459,13 @@ public partial class ProfileManager : IDisposable return true; var currentPlayer = _actorManager.GetCurrentPlayer(); - return currentPlayer.IsValid && currentPlayer.CompareIgnoringOwnership(actorIdentifier); + return currentPlayer.IsValid && currentPlayer.MatchesIgnoringOwnership(actorIdentifier); } if (actorIdentifier.Type == IdentifierType.Owned && !actorIdentifier.IsOwnedByLocalPlayer()) return false; - return profile.CharacterName.Text == name || profile.Character.CompareIgnoringOwnership(actorIdentifier); + return profile.CharacterName.Text == name || profile.Character.MatchesIgnoringOwnership(actorIdentifier); } if (_templateEditorManager.IsEditorActive && _templateEditorManager.EditorProfile.Enabled && IsProfileAppliesToCurrentActor(_templateEditorManager.EditorProfile)) diff --git a/CustomizePlus/Templates/TemplateEditorManager.cs b/CustomizePlus/Templates/TemplateEditorManager.cs index 1f9780c..c16aab5 100644 --- a/CustomizePlus/Templates/TemplateEditorManager.cs +++ b/CustomizePlus/Templates/TemplateEditorManager.cs @@ -76,7 +76,7 @@ public class TemplateEditorManager : IDisposable { //todo: check with mounts/companions var playerName = _gameObjectService.GetCurrentPlayerName(); - return _gameObjectService.FindActorsByIdentifier(Character) + return _gameObjectService.FindActorsByIdentifierIgnoringOwnership(Character) .Where(x => x.Item1.Type != Penumbra.GameData.Enums.IdentifierType.Owned || x.Item1.IsOwnedByLocalPlayer()) .Any(); } diff --git a/CustomizePlus/UI/Windows/MainWindow/Tabs/Profiles/ProfileFileSystemSelector.cs b/CustomizePlus/UI/Windows/MainWindow/Tabs/Profiles/ProfileFileSystemSelector.cs index 87b1c46..03019d8 100644 --- a/CustomizePlus/UI/Windows/MainWindow/Tabs/Profiles/ProfileFileSystemSelector.cs +++ b/CustomizePlus/UI/Windows/MainWindow/Tabs/Profiles/ProfileFileSystemSelector.cs @@ -240,9 +240,9 @@ public class ProfileFileSystemSelector : FileSystemSelector