Added character info and priority to Profile.GetList IPC, bump of major IPC version, IPCCharacterProfile cleanup, some fixes which should hopefully fix temporary profiles for minions

This commit is contained in:
RisaDev
2024-10-22 21:03:50 +03:00
parent 17e09a8d26
commit 9061138cf1
8 changed files with 101 additions and 27 deletions

View File

@@ -4,7 +4,7 @@ namespace CustomizePlus.Api;
public partial class CustomizePlusIpc
{
private readonly (int Breaking, int Feature) _apiVersion = (5, 2);
private readonly (int Breaking, int Feature) _apiVersion = (6, 0);
/// <summary>
/// When there are breaking changes the first number is bumped up and second one is reset.

View File

@@ -13,11 +13,8 @@ using CustomizePlus.Armatures.Data;
using CustomizePlus.Armatures.Events;
using CustomizePlus.GameData.Extensions;
using Dalamud.Game.ClientState.Objects.Types;
using Penumbra.GameData.Interop;
//Virtual path is full path to the profile in the virtual folders created by user in the profile list UI
using IPCProfileDataTuple = (System.Guid UniqueId, string Name, string VirtualPath, string CharacterName, bool IsEnabled);
using Penumbra.GameData.Structs;
using Penumbra.GameData.Enums;
namespace CustomizePlus.Api;
@@ -46,7 +43,20 @@ public partial class CustomizePlusIpc
.Select(x =>
{
string path = _profileFileSystem.FindLeaf(x, out var leaf) ? leaf.FullName() : x.Name.Text;
return (x.UniqueId, x.Name.Text, path, x.Characters.Count > 0 ? x.Characters[0].ToNameWithoutOwnerName() : "", x.Enabled); //todo: proper update to v5
var charactersList = new List<IPCCharacterDataTuple>(x.Characters.Count);
foreach (var character in x.Characters)
{
var tuple = new IPCCharacterDataTuple();
tuple.Name = character.ToNameWithoutOwnerName();
tuple.CharacterType = (byte)character.Type;
tuple.WorldId = character.Type == IdentifierType.Player || character.Type == IdentifierType.Owned ? character.HomeWorld.Id : WorldId.AnyWorld.Id;
tuple.CharacterSubType = character.Type == IdentifierType.Retainer ? (ushort)character.Retainer : (ushort)0;
charactersList.Add(tuple);
}
return (x.UniqueId, x.Name.Text, path, charactersList, x.Priority, x.Enabled);
})
.ToList();
}

View File

@@ -4,6 +4,8 @@ using CustomizePlus.Game.Services;
using CustomizePlus.GameData.Extensions;
using CustomizePlus.Profiles.Data;
using CustomizePlus.Templates.Data;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -18,20 +20,24 @@ namespace CustomizePlus.Api.Data;
/// </summary>
public class IPCCharacterProfile
{
/// <summary>
/// Used only for display purposes
/// </summary>
public string CharacterName { get; set; } = "Invalid";
// public List<IPCCharacter> Characters { get; set; } = new();
public Dictionary<string, IPCBoneTransform> Bones { get; init; } = new();
public static IPCCharacterProfile FromFullProfile(Profile profile)
{
var ipcProfile = new IPCCharacterProfile
var ipcProfile = new IPCCharacterProfile();
/* foreach (var character in profile.Characters)
{
CharacterName = profile.Characters.FirstOrDefault().ToNameWithoutOwnerName(),
Bones = new Dictionary<string, IPCBoneTransform>()
};
//todo: unify with tuple?
var ipcCharacter = new IPCCharacter();
ipcCharacter.Name = character.ToNameWithoutOwnerName();
ipcCharacter.CharacterType = (byte)character.Type;
ipcCharacter.WorldId = character.Type == IdentifierType.Player || character.Type == IdentifierType.Owned ? character.HomeWorld.Id : WorldId.AnyWorld.Id;
ipcCharacter.CharacterSubType = character.Type == IdentifierType.Retainer ? (ushort)character.Retainer : (ushort)0;
ipcProfile.Characters.Add(ipcCharacter);
}*/
foreach (var template in profile.Templates)
{
@@ -53,7 +59,6 @@ public class IPCCharacterProfile
{
var fullProfile = new Profile
{
Name = $"IPC profile for {profile.CharacterName}",
//Character should be set manually
CreationDate = DateTimeOffset.UtcNow,
ModifiedDate = DateTimeOffset.UtcNow,
@@ -63,9 +68,11 @@ public class IPCCharacterProfile
ProfileType = isTemporary ? Profiles.Enums.ProfileType.Temporary : Profiles.Enums.ProfileType.Normal
};
fullProfile.Name = $"IPC Profile {fullProfile.UniqueId}";
var template = new Template
{
Name = $"{fullProfile.Name}'s template",
Name = $"{fullProfile.Name} - template",
CreationDate = fullProfile.CreationDate,
ModifiedDate = fullProfile.ModifiedDate,
UniqueId = Guid.NewGuid(),
@@ -137,3 +144,11 @@ public class IPCBoneTransform
return rotVec;
}
}
/*
public class IPCCharacter
{
public string Name { get; set; }
public ushort WorldId { get; set; }
public byte CharacterType { get; set; }
public ushort CharacterSubType { get; set; }
}*/

View File

@@ -0,0 +1,28 @@
global using IPCCharacterDataTuple = (string Name, ushort WorldId, byte CharacterType, ushort CharacterSubType);
//Virtual path is full path to the profile in the virtual folders created by user in the profile list UI
//Character.WorldId is value of Penumbra.GameData.Structs.WorldId. ushort.MaxValue if AnyWorld or if CharacterType != Player/Owned.
//Does not bear any meaning for CharacterType = Owned right now.
//CharacterType represents Penumbra.GameData.Enums.IdentifierType and can be one of the following:
//0 = Invalid (should never be returned in normal circumstances)
//1 = Player
//2 = Owned (companion, minion)
//3 = Unused
//4 = NPC
//5 = Retainer
//6 = Unused
//CharacterSubType represents Penumbra.GameData.Actors.ActorIdentifier.RetainerType and only used by CharacterType = Retainer and can be:
//0 = Both
//1 = Bell
//2 = Mannequin
global using IPCProfileDataTuple = (
System.Guid UniqueId,
string Name,
string VirtualPath,
System.Collections.Generic.List<(string Name, ushort WorldId, byte CharacterType, ushort CharacterSubType)> Characters,
int Priority,
bool IsEnabled);