Hopefully this doesn't break anything, I can't test this properly on my free trial account

Removed "Limit to my creatures", the code now automatically detects this for all owned actors. If you liked to apply edits to minions and stuff of other players... too bad.
Implemented UI for setting profiles to NPC, minions and mounts (still WIP, will probably have to implement multiple characters per profile)
This commit is contained in:
RisaDev
2024-10-08 00:32:58 +03:00
parent d088550574
commit 7a0ee53756
17 changed files with 141 additions and 216 deletions

View File

@@ -28,6 +28,35 @@ public static class ActorIdentifierExtensions
return PenumbraExtensions.Manager.Data.ToName(identifier.Kind, identifier.DataId); return PenumbraExtensions.Manager.Data.ToName(identifier.Kind, identifier.DataId);
} }
/// <summary>
/// Compares two actor identifiers while ignoring ownership for owned objects. For all other identifier types will use Matches() method.
/// </summary>
public static bool CompareIgnoringOwnership(this ActorIdentifier identifier, ActorIdentifier other)
{
if (identifier.Type != other.Type)
return false;
return identifier.Type switch
{
IdentifierType.Owned => PenumbraExtensions.Manager.DataIdEquals(identifier, other),
_ => identifier.Matches(other)
};
}
/// <summary>
/// Check if owned actor is owned by local player. Will return false if Type is not Owned.
/// </summary>
public static bool IsOwnedByLocalPlayer(this ActorIdentifier identifier)
{
if (identifier.Type != IdentifierType.Owned)
return false;
if (PenumbraExtensions.Manager == null)
return false;
return identifier.PlayerName == PenumbraExtensions.Manager.GetCurrentPlayer().PlayerName;
}
/// <summary> /// <summary>
/// Wrapper around Incognito which returns non-incognito name in debug builds /// Wrapper around Incognito which returns non-incognito name in debug builds
/// </summary> /// </summary>

View File

@@ -53,7 +53,6 @@ public class IPCCharacterProfile
CreationDate = DateTimeOffset.UtcNow, CreationDate = DateTimeOffset.UtcNow,
ModifiedDate = DateTimeOffset.UtcNow, ModifiedDate = DateTimeOffset.UtcNow,
Enabled = true, Enabled = true,
LimitLookupToOwnedObjects = false,
UniqueId = Guid.NewGuid(), UniqueId = Guid.NewGuid(),
Templates = new List<Template>(1), Templates = new List<Template>(1),
ProfileType = isTemporary ? Profiles.Enums.ProfileType.Temporary : Profiles.Enums.ProfileType.Normal ProfileType = isTemporary ? Profiles.Enums.ProfileType.Temporary : Profiles.Enums.ProfileType.Normal

View File

@@ -359,7 +359,6 @@ public unsafe sealed class ArmatureManager : IDisposable
if (type is not TemplateChanged.Type.NewBone && if (type is not TemplateChanged.Type.NewBone &&
type is not TemplateChanged.Type.DeletedBone && type is not TemplateChanged.Type.DeletedBone &&
type is not TemplateChanged.Type.EditorCharacterChanged && type is not TemplateChanged.Type.EditorCharacterChanged &&
type is not TemplateChanged.Type.EditorLimitLookupToOwnedChanged &&
type is not TemplateChanged.Type.EditorEnabled && type is not TemplateChanged.Type.EditorEnabled &&
type is not TemplateChanged.Type.EditorDisabled) type is not TemplateChanged.Type.EditorDisabled)
return; return;
@@ -405,21 +404,6 @@ public unsafe sealed class ArmatureManager : IDisposable
return; return;
} }
if(type == TemplateChanged.Type.EditorLimitLookupToOwnedChanged)
{
var profile = (Profile)arg3!;
if (profile.Armatures.Count == 0)
return;
foreach (var armature in profile.Armatures)
armature.IsPendingProfileRebind = true;
_logger.Debug($"ArmatureManager.OnTemplateChange Editor profile limit lookup setting changed, armature rebind scheduled: {type}, profile: {profile.Name.Text.Incognify()}->{profile.Enabled}");
return;
}
if (type == TemplateChanged.Type.EditorEnabled || if (type == TemplateChanged.Type.EditorEnabled ||
type == TemplateChanged.Type.EditorDisabled) type == TemplateChanged.Type.EditorDisabled)
{ {
@@ -445,7 +429,6 @@ public unsafe sealed class ArmatureManager : IDisposable
type is not ProfileChanged.Type.TemporaryProfileDeleted && type is not ProfileChanged.Type.TemporaryProfileDeleted &&
type is not ProfileChanged.Type.ChangedCharacter && type is not ProfileChanged.Type.ChangedCharacter &&
type is not ProfileChanged.Type.ChangedDefaultProfile && type is not ProfileChanged.Type.ChangedDefaultProfile &&
type is not ProfileChanged.Type.LimitLookupToOwnedChanged &&
type is not ProfileChanged.Type.ApplyToCurrentlyActiveCharacterChanged) type is not ProfileChanged.Type.ApplyToCurrentlyActiveCharacterChanged)
return; return;
@@ -522,7 +505,6 @@ public unsafe sealed class ArmatureManager : IDisposable
if (type == ProfileChanged.Type.ChangedCharacter || if (type == ProfileChanged.Type.ChangedCharacter ||
type == ProfileChanged.Type.Deleted || type == ProfileChanged.Type.Deleted ||
type == ProfileChanged.Type.TemporaryProfileDeleted || type == ProfileChanged.Type.TemporaryProfileDeleted ||
type == ProfileChanged.Type.LimitLookupToOwnedChanged ||
type == ProfileChanged.Type.ApplyToCurrentlyActiveCharacterChanged) type == ProfileChanged.Type.ApplyToCurrentlyActiveCharacterChanged)
{ {
if (profile.Armatures.Count == 0) if (profile.Armatures.Count == 0)
@@ -536,7 +518,7 @@ public unsafe sealed class ArmatureManager : IDisposable
armature.IsPendingProfileRebind = true; armature.IsPendingProfileRebind = true;
} }
_logger.Debug($"ArmatureManager.OnProfileChange CC/DEL/TPD/LLTOC/ATCACC, armature rebind scheduled: {type}, data payload: {arg3?.ToString()?.Incognify()}, profile: {profile.Name.Text.Incognify()}->{profile.Enabled}"); _logger.Debug($"ArmatureManager.OnProfileChange CC/DEL/TPD/ATCACC, armature rebind scheduled: {type}, data payload: {arg3?.ToString()?.Incognify()}, profile: {profile.Name.Text.Incognify()}->{profile.Enabled}");
return; return;
} }
@@ -567,7 +549,8 @@ public unsafe sealed class ArmatureManager : IDisposable
{ {
(var armatureActorIdentifier, _) = _gameObjectService.GetTrueActorForSpecialTypeActor(kvPair.Key); (var armatureActorIdentifier, _) = _gameObjectService.GetTrueActorForSpecialTypeActor(kvPair.Key);
if (armatureActorIdentifier.IsValid && armatureActorIdentifier.Matches(armatureActorIdentifier)) if (actorIdentifier.IsValid && armatureActorIdentifier.CompareIgnoringOwnership(actorIdentifier) &&
(armatureActorIdentifier.Type != IdentifierType.Owned || armatureActorIdentifier.IsOwnedByLocalPlayer()))
yield return kvPair.Value; yield return kvPair.Value;
} }
} }

View File

@@ -18,7 +18,6 @@ internal static class V3ProfileToV4Converter
CreationDate = v3Profile.CreationDate, CreationDate = v3Profile.CreationDate,
ModifiedDate = DateTimeOffset.UtcNow, ModifiedDate = DateTimeOffset.UtcNow,
Enabled = v3Profile.Enabled, Enabled = v3Profile.Enabled,
LimitLookupToOwnedObjects = v3Profile.OwnedOnly,
UniqueId = Guid.NewGuid(), UniqueId = Guid.NewGuid(),
Templates = new List<Template>(1) Templates = new List<Template>(1)
}; };

View File

@@ -206,8 +206,7 @@ public static class ServiceManagerBuilder
.AddSingleton<CutsceneService>() .AddSingleton<CutsceneService>()
.AddSingleton<GameEventManager>() .AddSingleton<GameEventManager>()
.AddSingleton(p => new CutsceneResolver(idx => (short)p.GetRequiredService<CutsceneService>().GetParentIndex(idx))) .AddSingleton(p => new CutsceneResolver(idx => (short)p.GetRequiredService<CutsceneService>().GetParentIndex(idx)))
.AddSingleton<ObjectManager>() .AddSingleton<ObjectManager>();
.AddSingleton<DictBNpcENpc>();
return services; return services;
} }

View File

@@ -74,7 +74,6 @@ public class SupportLogBuilderService
sb.Append($"> > **`Name: `** {profile.Name.Text.Incognify()}\n"); sb.Append($"> > **`Name: `** {profile.Name.Text.Incognify()}\n");
sb.Append($"> > **`Type: `** {profile.ProfileType} \n"); sb.Append($"> > **`Type: `** {profile.ProfileType} \n");
sb.Append($"> > **`Character name: `** {profile.CharacterName.Text.Incognify()}\n"); sb.Append($"> > **`Character name: `** {profile.CharacterName.Text.Incognify()}\n");
sb.Append($"> > **`Limit to my creatures: `** {profile.LimitLookupToOwnedObjects}\n");
sb.Append($"> > **`Templates:`**\n"); sb.Append($"> > **`Templates:`**\n");
sb.Append($"> > > **`Count: `** {profile.Templates.Count}\n"); sb.Append($"> > > **`Count: `** {profile.Templates.Count}\n");
foreach (var template in profile.Templates) foreach (var template in profile.Templates)

View File

@@ -40,7 +40,7 @@ public sealed class Profile : ISavable
/// <summary> /// <summary>
/// Whether to search only through local player owned characters or all characters when searching for game object by name /// Whether to search only through local player owned characters or all characters when searching for game object by name
/// </summary> /// </summary>
public bool LimitLookupToOwnedObjects { get; set; } = false; //public bool LimitLookupToOwnedObjects { get; set; } = false;
public bool Enabled { get; set; } public bool Enabled { get; set; }
public DateTimeOffset CreationDate { get; set; } = DateTime.UtcNow; public DateTimeOffset CreationDate { get; set; } = DateTime.UtcNow;
@@ -80,7 +80,6 @@ public sealed class Profile : ISavable
public Profile(Profile original) : this() public Profile(Profile original) : this()
{ {
Character = original.Character; Character = original.Character;
LimitLookupToOwnedObjects = original.LimitLookupToOwnedObjects;
ApplyToCurrentlyActiveCharacter = original.ApplyToCurrentlyActiveCharacter; ApplyToCurrentlyActiveCharacter = original.ApplyToCurrentlyActiveCharacter;
foreach (var template in original.Templates) foreach (var template in original.Templates)
@@ -108,7 +107,6 @@ public sealed class Profile : ISavable
["Character"] = Character.ToJson(), ["Character"] = Character.ToJson(),
["ApplyToCurrentlyActiveCharacter"] = ApplyToCurrentlyActiveCharacter, ["ApplyToCurrentlyActiveCharacter"] = ApplyToCurrentlyActiveCharacter,
["Name"] = Name.Text, ["Name"] = Name.Text,
["LimitLookupToOwnedObjects"] = LimitLookupToOwnedObjects,
["Enabled"] = Enabled, ["Enabled"] = Enabled,
["IsWriteProtected"] = IsWriteProtected, ["IsWriteProtected"] = IsWriteProtected,
["Templates"] = SerializeTemplates() ["Templates"] = SerializeTemplates()

View File

@@ -22,7 +22,6 @@ public sealed class ProfileChanged() : EventWrapper<ProfileChanged.Type, Profile
ChangedTemplate, ChangedTemplate,
ReloadedAll, ReloadedAll,
WriteProtection, WriteProtection,
LimitLookupToOwnedChanged,
ApplyToCurrentlyActiveCharacterChanged, ApplyToCurrentlyActiveCharacterChanged,
ChangedDefaultProfile, ChangedDefaultProfile,
TemporaryProfileAdded, TemporaryProfileAdded,

View File

@@ -119,7 +119,6 @@ public partial class ProfileManager : IDisposable
CreationDate = creationDate, CreationDate = creationDate,
UniqueId = obj["UniqueId"]?.ToObject<Guid>() ?? throw new ArgumentNullException("UniqueId"), UniqueId = obj["UniqueId"]?.ToObject<Guid>() ?? throw new ArgumentNullException("UniqueId"),
Name = new LowerString(obj["Name"]?.ToObject<string>()?.Trim() ?? throw new ArgumentNullException("Name")), Name = new LowerString(obj["Name"]?.ToObject<string>()?.Trim() ?? throw new ArgumentNullException("Name")),
LimitLookupToOwnedObjects = obj["LimitLookupToOwnedObjects"]?.ToObject<bool>() ?? throw new ArgumentNullException("LimitLookupToOwnedObjects"),
Enabled = obj["Enabled"]?.ToObject<bool>() ?? throw new ArgumentNullException("Enabled"), Enabled = obj["Enabled"]?.ToObject<bool>() ?? throw new ArgumentNullException("Enabled"),
ModifiedDate = obj["ModifiedDate"]?.ToObject<DateTimeOffset>() ?? creationDate, ModifiedDate = obj["ModifiedDate"]?.ToObject<DateTimeOffset>() ?? creationDate,
IsWriteProtected = obj["IsWriteProtected"]?.ToObject<bool>() ?? false, IsWriteProtected = obj["IsWriteProtected"]?.ToObject<bool>() ?? false,

View File

@@ -172,7 +172,7 @@ public partial class ProfileManager : IDisposable
/// </summary> /// </summary>
public void ChangeCharacter(Profile profile, ActorIdentifier actorIdentifier) public void ChangeCharacter(Profile profile, ActorIdentifier actorIdentifier)
{ {
if (!actorIdentifier.IsValid || actorIdentifier.Matches(profile.Character)) if (!actorIdentifier.IsValid || actorIdentifier.CompareIgnoringOwnership(profile.Character))
return; return;
var oldCharacter = profile.Character; var oldCharacter = profile.Character;
@@ -227,7 +227,7 @@ public partial class ProfileManager : IDisposable
_logger.Debug($"Setting {profile} as enabled..."); _logger.Debug($"Setting {profile} as enabled...");
foreach (var otherProfile in Profiles foreach (var otherProfile in Profiles
.Where(x => x.Character.Matches(profile.Character) && x != profile && x.Enabled && !x.IsTemporary)) .Where(x => x.Character.CompareIgnoringOwnership(profile.Character) && x != profile && x.Enabled && !x.IsTemporary))
{ {
_logger.Debug($"\t-> {otherProfile} disabled"); _logger.Debug($"\t-> {otherProfile} disabled");
SetEnabled(otherProfile, false); SetEnabled(otherProfile, false);
@@ -254,17 +254,6 @@ public partial class ProfileManager : IDisposable
else else
throw new ProfileNotFoundException(); throw new ProfileNotFoundException();
} }
public void SetLimitLookupToOwned(Profile profile, bool value)
{
if (profile.LimitLookupToOwnedObjects != value)
{
profile.LimitLookupToOwnedObjects = value;
SaveProfile(profile);
_event.Invoke(ProfileChanged.Type.LimitLookupToOwnedChanged, profile, value);
}
}
public void SetApplyToCurrentlyActiveCharacter(Profile profile, bool value) public void SetApplyToCurrentlyActiveCharacter(Profile profile, bool value)
{ {
@@ -361,9 +350,8 @@ public partial class ProfileManager : IDisposable
profile.Enabled = true; profile.Enabled = true;
profile.ProfileType = ProfileType.Temporary; profile.ProfileType = ProfileType.Temporary;
profile.Character = identifier; profile.Character = identifier;
profile.LimitLookupToOwnedObjects = false;
var existingProfile = Profiles.FirstOrDefault(x => x.Character.Matches(profile.Character) && x.IsTemporary); var existingProfile = Profiles.FirstOrDefault(x => x.Character.CompareIgnoringOwnership(profile.Character) && x.IsTemporary);
if (existingProfile != null) if (existingProfile != null)
{ {
_logger.Debug($"Temporary profile for {existingProfile.Character.Incognito(null)} already exists, removing..."); _logger.Debug($"Temporary profile for {existingProfile.Character.Incognito(null)} already exists, removing...");
@@ -421,11 +409,19 @@ public partial class ProfileManager : IDisposable
if (!actorIdentifier.IsValid) if (!actorIdentifier.IsValid)
return null; return null;
var query = Profiles.Where(x => x.Character.Matches(actorIdentifier) && !x.IsTemporary); var query = Profiles.Where(x => x.Character.CompareIgnoringOwnership(actorIdentifier) && !x.IsTemporary);
if (enabledOnly) if (enabledOnly)
query = query.Where(x => x.Enabled); query = query.Where(x => x.Enabled);
return query.FirstOrDefault(); var profile = query.FirstOrDefault();
if (profile == null)
return null;
if (actorIdentifier.Type == IdentifierType.Owned && !actorIdentifier.IsOwnedByLocalPlayer())
return null;
return profile;
} }
//todo: replace with dictionary //todo: replace with dictionary
@@ -462,13 +458,13 @@ public partial class ProfileManager : IDisposable
return true; return true;
var currentPlayer = _actorManager.GetCurrentPlayer(); var currentPlayer = _actorManager.GetCurrentPlayer();
return currentPlayer.IsValid && _actorManager.GetCurrentPlayer().Matches(actorIdentifier); return currentPlayer.IsValid && _actorManager.GetCurrentPlayer().CompareIgnoringOwnership(actorIdentifier);
} }
return (profile.CharacterName.Text == name || profile.Character.Matches(actorIdentifier)) && if (actorIdentifier.Type == IdentifierType.Owned && !actorIdentifier.IsOwnedByLocalPlayer())
(!profile.LimitLookupToOwnedObjects || return false;
(actorIdentifier.Type == IdentifierType.Owned &&
actorIdentifier.PlayerName == _actorManager.GetCurrentPlayer().PlayerName)); return profile.CharacterName.Text == name || profile.Character.CompareIgnoringOwnership(actorIdentifier);
} }
if (_templateEditorManager.IsEditorActive && _templateEditorManager.EditorProfile.Enabled && IsProfileAppliesToCurrentActor(_templateEditorManager.EditorProfile)) if (_templateEditorManager.IsEditorActive && _templateEditorManager.EditorProfile.Enabled && IsProfileAppliesToCurrentActor(_templateEditorManager.EditorProfile))
@@ -479,6 +475,7 @@ public partial class ProfileManager : IDisposable
if(IsProfileAppliesToCurrentActor(profile)) if(IsProfileAppliesToCurrentActor(profile))
{ {
//todo: temp for migrations to v5 //todo: temp for migrations to v5
//todo: make sure this works for minions and stuff
if (!profile.Character.IsValid) if (!profile.Character.IsValid)
{ {
_logger.Warning($"No character for profile {profile}, but character has been found as: {actorIdentifier}, will set."); _logger.Warning($"No character for profile {profile}, but character has been found as: {actorIdentifier}, will set.");

View File

@@ -20,7 +20,6 @@ public class TemplateChanged() : EventWrapper<TemplateChanged.Type, Template?, o
EditorEnabled, EditorEnabled,
EditorDisabled, EditorDisabled,
EditorCharacterChanged, EditorCharacterChanged,
EditorLimitLookupToOwnedChanged,
ReloadedAll, ReloadedAll,
WriteProtection WriteProtection
} }

View File

@@ -194,18 +194,6 @@ public class TemplateEditorManager : IDisposable
return true; return true;
} }
public bool SetLimitLookupToOwned(bool value)
{
if (!IsEditorActive || IsEditorPaused || value == EditorProfile.LimitLookupToOwnedObjects)
return false;
//_profileManager.SetLimitLookupToOwned(EditorProfile, value);
EditorProfile.LimitLookupToOwnedObjects = value;
_event.Invoke(TemplateChanged.Type.EditorLimitLookupToOwnedChanged, CurrentlyEditedTemplate, EditorProfile);
return true;
}
/// <summary> /// <summary>
/// Resets changes in currently edited template to default values /// Resets changes in currently edited template to default values
/// </summary> /// </summary>

View File

@@ -13,8 +13,10 @@ using OtterGui.Custom;
using OtterGui.Log; using OtterGui.Log;
using Penumbra.GameData.Actors; using Penumbra.GameData.Actors;
using Penumbra.GameData.Data; using Penumbra.GameData.Data;
using Penumbra.GameData.DataContainers;
using Penumbra.GameData.DataContainers.Bases; using Penumbra.GameData.DataContainers.Bases;
using Penumbra.GameData.Gui; using Penumbra.GameData.Gui;
using Penumbra.GameData.Interop;
using Penumbra.GameData.Structs; using Penumbra.GameData.Structs;
using Penumbra.String; using Penumbra.String;
@@ -23,22 +25,18 @@ namespace CustomizePlus.UI.Windows.Controls;
public class ActorAssignmentUi public class ActorAssignmentUi
{ {
private readonly ActorManager _actorManager; private readonly ActorManager _actorManager;
private readonly DictBNpcENpc _dictBnpcEnpc;
private WorldCombo _worldCombo = null!; private WorldCombo _worldCombo = null!;
private Penumbra.GameData.Gui.NpcCombo _mountCombo = null!; private NpcCombo _mountCombo = null!;
private Penumbra.GameData.Gui.NpcCombo _companionCombo = null!; private NpcCombo _companionCombo = null!;
//private BattleEventNpcCombo _npcCombo = null!; private NpcCombo _bnpcCombo = null!;
private Penumbra.GameData.Gui.NpcCombo _npcCombo = null!; private NpcCombo _enpcCombo = null!;
private bool _ready; private bool _ready;
private string _newCharacterName = string.Empty; private string _newCharacterName = string.Empty;
private ObjectKind _newKind = ObjectKind.BattleNpc; private ObjectKind _newKind = ObjectKind.BattleNpc;
/* public string CharacterName { get => _newCharacterName; }
public WorldId SelectedWorld { get => _worldCombo.CurrentSelection.Key; }
*/
public ActorIdentifier NpcIdentifier { get; private set; } = ActorIdentifier.Invalid; public ActorIdentifier NpcIdentifier { get; private set; } = ActorIdentifier.Invalid;
public ActorIdentifier PlayerIdentifier { get; private set; } = ActorIdentifier.Invalid; public ActorIdentifier PlayerIdentifier { get; private set; } = ActorIdentifier.Invalid;
public ActorIdentifier RetainerIdentifier { get; private set; } = ActorIdentifier.Invalid; public ActorIdentifier RetainerIdentifier { get; private set; } = ActorIdentifier.Invalid;
@@ -56,12 +54,11 @@ public class ActorAssignmentUi
public bool CanSetNpc public bool CanSetNpc
=> NpcIdentifier.IsValid; => NpcIdentifier.IsValid;
public ActorAssignmentUi(ActorManager actorManager, DictBNpcENpc dictBnpcEnpc) public ActorAssignmentUi(ActorManager actorManager, DictModelChara dictModelChara, DictBNpcNames bNpcNames, DictBNpc bNpc)
{ {
_actorManager = actorManager; _actorManager = actorManager;
_dictBnpcEnpc = dictBnpcEnpc;
_actorManager.Awaiter.ContinueWith(_ => dictBnpcEnpc.Awaiter.ContinueWith(_ => SetupCombos(), TaskScheduler.Default), TaskScheduler.Default); _actorManager.Awaiter.ContinueWith(_ => SetupCombos(), TaskScheduler.Default);
} }
public void DrawWorldCombo(float width) public void DrawWorldCombo(float width)
@@ -92,12 +89,6 @@ public class ActorAssignmentUi
if (!_ready) if (!_ready)
return; return;
/* if(_newKind == ObjectKind.BattleNpc || _newKind == ObjectKind.EventNpc)
{
if (_npcCombo.Draw(width))
UpdateIdentifiersInternal();
}*/
var combo = GetNpcCombo(_newKind); var combo = GetNpcCombo(_newKind);
if (combo.Draw(width)) if (combo.Draw(width))
UpdateIdentifiersInternal(); UpdateIdentifiersInternal();
@@ -114,8 +105,8 @@ public class ActorAssignmentUi
private Penumbra.GameData.Gui.NpcCombo GetNpcCombo(ObjectKind kind) private Penumbra.GameData.Gui.NpcCombo GetNpcCombo(ObjectKind kind)
=> kind switch => kind switch
{ {
ObjectKind.BattleNpc => _npcCombo, ObjectKind.BattleNpc => _bnpcCombo,
ObjectKind.EventNpc => _npcCombo, ObjectKind.EventNpc => _enpcCombo,
ObjectKind.MountType => _mountCombo, ObjectKind.MountType => _mountCombo,
ObjectKind.Companion => _companionCombo, ObjectKind.Companion => _companionCombo,
_ => throw new NotImplementedException(), _ => throw new NotImplementedException(),
@@ -127,9 +118,8 @@ public class ActorAssignmentUi
_worldCombo = new WorldCombo(_actorManager.Data.Worlds, Plugin.Logger); _worldCombo = new WorldCombo(_actorManager.Data.Worlds, Plugin.Logger);
_mountCombo = new Penumbra.GameData.Gui.NpcCombo("##mountCombo", _actorManager.Data.Mounts, Plugin.Logger); _mountCombo = new Penumbra.GameData.Gui.NpcCombo("##mountCombo", _actorManager.Data.Mounts, Plugin.Logger);
_companionCombo = new Penumbra.GameData.Gui.NpcCombo("##companionCombo", _actorManager.Data.Companions, Plugin.Logger); _companionCombo = new Penumbra.GameData.Gui.NpcCombo("##companionCombo", _actorManager.Data.Companions, Plugin.Logger);
//_bnpcCombo = new Penumbra.GameData.Gui.NpcCombo("##bnpcCombo", _actorManager.Data.BNpcs, Plugin.Logger); _bnpcCombo = new Penumbra.GameData.Gui.NpcCombo("##bnpcCombo", _actorManager.Data.BNpcs, Plugin.Logger);
//_enpcCombo = new Penumbra.GameData.Gui.NpcCombo("##enpcCombo", _actorManager.Data.ENpcs, Plugin.Logger); _enpcCombo = new Penumbra.GameData.Gui.NpcCombo("##enpcCombo", _actorManager.Data.ENpcs, Plugin.Logger);
_npcCombo = new Penumbra.GameData.Gui.NpcCombo("##npcCombo", _dictBnpcEnpc, Plugin.Logger);
_ready = true; _ready = true;
} }
@@ -141,41 +131,21 @@ public class ActorAssignmentUi
RetainerIdentifier = _actorManager.CreateRetainer(byteName, ActorIdentifier.RetainerType.Bell); RetainerIdentifier = _actorManager.CreateRetainer(byteName, ActorIdentifier.RetainerType.Bell);
MannequinIdentifier = _actorManager.CreateRetainer(byteName, ActorIdentifier.RetainerType.Mannequin); MannequinIdentifier = _actorManager.CreateRetainer(byteName, ActorIdentifier.RetainerType.Mannequin);
} }
}
}
//Todo: Temp var npcCombo = GetNpcCombo(_newKind);
/// <summary> A dictionary that matches BNpcNameId to names. </summary> switch(_newKind)
public sealed class DictBNpcENpc(IDalamudPluginInterface pluginInterface, Logger log, IDataManager gameData)
: NameDictionary(pluginInterface, log, gameData, "BNpcsENpcs", 7, () => CreateData(gameData))
{
/// <summary> Create the data. </summary>
private static IReadOnlyDictionary<uint, string> CreateData(IDataManager gameData)
{ {
case ObjectKind.BattleNpc:
var sheet = gameData.GetExcelSheet<BNpcName>(gameData.Language)!; case ObjectKind.EventNpc:
var sheet2 = gameData.GetExcelSheet<ENpcResident>(gameData.Language)!; NpcIdentifier = _actorManager.CreateNpc(_newKind, npcCombo.CurrentSelection.Ids[0]);
break;
var dict = new Dictionary<uint, string>((int)sheet.RowCount + (int)sheet2.RowCount); case ObjectKind.MountType:
case ObjectKind.Companion:
foreach (var n in sheet.Where(n => n.Singular.RawData.Length > 0)) var currentPlayer = _actorManager.GetCurrentPlayer();
dict.TryAdd(n.RowId, DataUtility.ToTitleCaseExtended(n.Singular, n.Article)); NpcIdentifier = _actorManager.CreateOwned(currentPlayer.PlayerName, currentPlayer.HomeWorld, _newKind, npcCombo.CurrentSelection.Ids[0]);
foreach (var n in sheet2.Where(e => e.Singular.RawData.Length > 0)) break;
dict.TryAdd(n.RowId, DataUtility.ToTitleCaseExtended(n.Singular, n.Article)); default:
throw new NotImplementedException();
return dict.ToFrozenDictionary(); }
} }
/// <inheritdoc cref="NameDictionary.ContainsKey"/>
public bool ContainsKey(BNpcNameId key)
=> Value.ContainsKey(key.Id);
/// <inheritdoc cref="NameDictionary.TryGetValue"/>
public bool TryGetValue(BNpcNameId key, [NotNullWhen(true)] out string? value)
=> Value.TryGetValue(key.Id, out value);
/// <inheritdoc cref="NameDictionary.this"/>
public string this[BNpcNameId key]
=> Value[key.Id];
} }

View File

@@ -149,7 +149,6 @@ public class StateMonitoringTab
ImGui.Text($"ID: {profile.UniqueId}"); ImGui.Text($"ID: {profile.UniqueId}");
ImGui.Text($"Enabled: {(profile.Enabled ? "Enabled" : "Disabled")}"); ImGui.Text($"Enabled: {(profile.Enabled ? "Enabled" : "Disabled")}");
ImGui.Text($"State : {(profile.IsTemporary ? "Temporary" : "Permanent")}"); ImGui.Text($"State : {(profile.IsTemporary ? "Temporary" : "Permanent")}");
ImGui.Text($"Lookup: {(profile.LimitLookupToOwnedObjects ? "Limited lookup" : "Global lookup")}");
var showTemplates = ImGui.CollapsingHeader($"Templates###{prefix}-profile-{profile.UniqueId}-templates"); var showTemplates = ImGui.CollapsingHeader($"Templates###{prefix}-profile-{profile.UniqueId}-templates");
if (showTemplates) if (showTemplates)

View File

@@ -16,6 +16,7 @@ using CustomizePlus.Configuration.Data;
using CustomizePlus.Profiles.Data; using CustomizePlus.Profiles.Data;
using CustomizePlus.Game.Services; using CustomizePlus.Game.Services;
using CustomizePlus.Profiles.Events; using CustomizePlus.Profiles.Events;
using CustomizePlus.GameData.Extensions;
namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Profiles; namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Profiles;
@@ -239,9 +240,9 @@ public class ProfileFileSystemSelector : FileSystemSelector<Profile, ProfileStat
} }
if (leaf.Value.Enabled) if (leaf.Value.Enabled)
state.Color = leaf.Value.Character.Matches(_gameObjectService.GetCurrentPlayerActorIdentifier()) ? ColorId.LocalCharacterEnabledProfile : ColorId.EnabledProfile; state.Color = leaf.Value.Character.CompareIgnoringOwnership(_gameObjectService.GetCurrentPlayerActorIdentifier()) ? ColorId.LocalCharacterEnabledProfile : ColorId.EnabledProfile;
else else
state.Color = leaf.Value.Character.Matches(_gameObjectService.GetCurrentPlayerActorIdentifier()) ? ColorId.LocalCharacterDisabledProfile : ColorId.DisabledProfile; state.Color = leaf.Value.Character.CompareIgnoringOwnership(_gameObjectService.GetCurrentPlayerActorIdentifier()) ? ColorId.LocalCharacterDisabledProfile : ColorId.DisabledProfile;
return ApplyStringFilters(leaf, leaf.Value); return ApplyStringFilters(leaf, leaf.Value);
} }

View File

@@ -16,6 +16,7 @@ using CustomizePlus.Templates.Events;
using Penumbra.GameData.Actors; using Penumbra.GameData.Actors;
using Penumbra.String; using Penumbra.String;
using static FFXIVClientStructs.FFXIV.Client.LayoutEngine.ILayoutInstance; using static FFXIVClientStructs.FFXIV.Client.LayoutEngine.ILayoutInstance;
using CustomizePlus.GameData.Extensions;
namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Profiles; namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Profiles;
@@ -216,24 +217,9 @@ public class ProfilePanel
if (!_selector.IncognitoMode) if (!_selector.IncognitoMode)
{ {
bool showMultipleMessage = false; bool showMultipleMessage = false;
if (_manager.DefaultProfile != _selector.Selected) if (_manager.DefaultProfile != _selector.Selected && !_selector.Selected!.ApplyToCurrentlyActiveCharacter)
{ {
if (!_selector.Selected!.ApplyToCurrentlyActiveCharacter) ImGui.Text(_selector.Selected!.Character.IsValid ? $"Applies to {_selector.Selected?.Character.ToNameWithoutOwnerName()}" : "No valid character selected for the profile");
{
/* if (ImGui.InputText("##CharacterName", ref name, 128))
{
_newCharacterName = name;
_changedProfile = _selector.Selected;
}
if (ImGui.IsItemDeactivatedAfterEdit() && _changedProfile != null)
{
_manager.ChangeCharacterName(_changedProfile, name);
_newCharacterName = null;
_changedProfile = null;
}
ImGui.Separator();*/
ImGui.Text(_selector.Selected!.Character.IsValid ? $"Applies to {_selector.Selected?.Character.ToString()}" : "No valid character selected for the profile");
ImGui.Text($"Legacy: {_selector.Selected!.CharacterName.Text ?? "None"}"); ImGui.Text($"Legacy: {_selector.Selected!.CharacterName.Text ?? "None"}");
ImGui.Separator(); ImGui.Separator();
@@ -266,18 +252,11 @@ public class ProfilePanel
ImGui.SameLine(); ImGui.SameLine();
_actorAssignmentUi.DrawNpcInput(width.X / 2); _actorAssignmentUi.DrawNpcInput(width.X / 2);
if (ImGui.Button("Apply to selected non-player character")) if (ImGuiUtil.DrawDisabledButton("Apply to selected NPC", buttonWidth, string.Empty, !_actorAssignmentUi.CanSetNpc))
{ _manager.ChangeCharacter(_selector.Selected!, _actorAssignmentUi.NpcIdentifier);
} }
}
else else
showMultipleMessage = true;
}
else
showMultipleMessage = true;
if(showMultipleMessage)
ImGui.TextUnformatted("Applies to multiple targets"); ImGui.TextUnformatted("Applies to multiple targets");
} }
else else
@@ -308,13 +287,6 @@ public class ProfilePanel
ImGui.PopStyleColor(); ImGui.PopStyleColor();
ImGuiUtil.HoverTooltip("Can only be changed when both currently selected and profile where this checkbox is checked are disabled."); ImGuiUtil.HoverTooltip("Can only be changed when both currently selected and profile where this checkbox is checked are disabled.");
} }
//ImGui.SameLine();
var enabled = _selector.Selected?.LimitLookupToOwnedObjects ?? false;
if (ImGui.Checkbox("##LimitLookupToOwnedObjects", ref enabled))
_manager.SetLimitLookupToOwned(_selector.Selected!, enabled);
ImGuiUtil.LabeledHelpMarker("Limit to my creatures",
"When enabled limits the character search to only your own summons, mounts and minions.\nUseful when there is possibility there will be another character with that name owned by another player.\n* For battle chocobo use \"Chocobo\" as character name.");
} }
} }
} }

View File

@@ -65,7 +65,7 @@ public class BoneEditorPanel
{ {
if (_editorManager.EnableEditor(template)) if (_editorManager.EnableEditor(template))
{ {
_editorManager.SetLimitLookupToOwned(_configuration.EditorConfiguration.LimitLookupToOwnedObjects); //_editorManager.SetLimitLookupToOwned(_configuration.EditorConfiguration.LimitLookupToOwnedObjects);
return true; return true;
} }
@@ -96,18 +96,22 @@ public class BoneEditorPanel
using (var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f))) using (var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)))
{ {
using (var table = ImRaii.Table("BasicSettings", 2)) //using (var table = ImRaii.Table("BasicSettings", 2))
{ //{
ImGui.TableSetupColumn("BasicCol1", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Show editor preview on").X); /* ImGui.TableSetupColumn("BasicCol1", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Show editor preview on").X);
ImGui.TableSetupColumn("BasicCol2", ImGuiTableColumnFlags.WidthStretch); ImGui.TableSetupColumn("BasicCol2", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableNextRow(); ImGui.TableNextRow();
ImGuiUtil.DrawFrameColumn("Show editor preview on"); ImGuiUtil.DrawFrameColumn("Show editor preview on");
ImGui.TableNextColumn(); ImGui.TableNextColumn();*/
var width = new Vector2(ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize("Limit to my creatures").X - 68, 0); var width = new Vector2(ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize("Limit to my creatures").X - 68, 0);
var name = _newCharacterName ?? _editorManager.CharacterName; var name = _newCharacterName ?? _editorManager.CharacterName;
ImGui.SetNextItemWidth(width.X); //ImGui.SetNextItemWidth(width.X);
var isShouldDraw = ImGui.CollapsingHeader("Preview settings");
if (isShouldDraw)
{
using (var disabled = ImRaii.Disabled(!IsEditorActive || IsEditorPaused)) using (var disabled = ImRaii.Disabled(!IsEditorActive || IsEditorPaused))
{ {
if (!_templateFileSystemSelector.IncognitoMode) if (!_templateFileSystemSelector.IncognitoMode)
@@ -129,20 +133,11 @@ public class BoneEditorPanel
} }
else else
ImGui.TextUnformatted("Incognito active"); ImGui.TextUnformatted("Incognito active");
}
ImGui.SameLine();
var enabled = _editorManager.EditorProfile.LimitLookupToOwnedObjects;
if (ImGui.Checkbox("##LimitLookupToOwnedObjects", ref enabled))
{
_editorManager.SetLimitLookupToOwned(enabled);
_configuration.EditorConfiguration.LimitLookupToOwnedObjects = enabled;
_configuration.Save();
}
ImGuiUtil.LabeledHelpMarker("Limit to my creatures",
"When enabled limits the character search to only your own summons, mounts and minions.\nUseful when there is possibility there will be another character with that name owned by another player.\n* For battle chocobo use \"Chocobo\" as character name.");
}
} }
//}
ImGui.Separator();
using (var table = ImRaii.Table("BoneEditorMenu", 2)) using (var table = ImRaii.Table("BoneEditorMenu", 2))
{ {