Profile.GetList now also returns virtual path

This commit is contained in:
RisaDev
2024-03-25 01:53:57 +03:00
parent 6777f9db6e
commit b4a086ec3a
3 changed files with 15 additions and 10 deletions

View File

@@ -5,21 +5,18 @@ using System.Linq;
using ECommons.EzIpcManager; using ECommons.EzIpcManager;
using Newtonsoft.Json; using Newtonsoft.Json;
using CustomizePlus.Api.Data; using CustomizePlus.Api.Data;
using CustomizePlus.GameData.Data;
using CustomizePlus.Api.Enums; using CustomizePlus.Api.Enums;
using CustomizePlus.Profiles.Exceptions; using CustomizePlus.Profiles.Exceptions;
using CustomizePlus.Profiles.Data; using CustomizePlus.Profiles.Data;
using CustomizePlus.Core.Extensions; using CustomizePlus.Core.Extensions;
using CustomizePlus.Profiles.Events;
using CustomizePlus.Armatures.Data; using CustomizePlus.Armatures.Data;
using CustomizePlus.Armatures.Events; using CustomizePlus.Armatures.Events;
using CustomizePlus.GameData.Extensions; using CustomizePlus.GameData.Extensions;
using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Game.ClientState.Objects.Types;
using Penumbra.GameData.Actors;
using IPCProfileDataTuple = (System.Guid UniqueId, string Name, string CharacterName, bool IsEnabled);
using Penumbra.GameData.Interop; using Penumbra.GameData.Interop;
//using OnUpdateTuple = (Dalamud.Game.ClientState.Objects.Types.Character Character, System.Guid? ProfileUniqueId, string? ProfileJson);
//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);
namespace CustomizePlus.Api; namespace CustomizePlus.Api;
@@ -37,6 +34,7 @@ public partial class CustomizePlusIpc
/// <summary> /// <summary>
/// Retrieve list of all user profiles /// Retrieve list of all user profiles
/// /!\ This might be somewhat heavy method to call, so please use with caution.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[EzIPC("Profile.GetList")] [EzIPC("Profile.GetList")]
@@ -44,7 +42,11 @@ public partial class CustomizePlusIpc
{ {
return _profileManager.Profiles return _profileManager.Profiles
.Where(x => x.ProfileType == ProfileType.Normal) .Where(x => x.ProfileType == ProfileType.Normal)
.Select(x => (x.UniqueId, x.Name.Text, x.CharacterName.Text, x.Enabled)) .Select(x =>
{
string path = _profileFileSystem.FindLeaf(x, out var leaf) ? leaf.FullName() : x.Name.Text;
return (x.UniqueId, x.Name.Text, path, x.CharacterName.Text, x.Enabled);
})
.ToList(); .ToList();
} }
@@ -285,7 +287,7 @@ public partial class CustomizePlusIpc
type == ArmatureChanged.Type.Updated) type == ArmatureChanged.Type.Updated)
{ {
if (armature.Profile == null) if (armature.Profile == null)
_logger.Fatal("INTEGRITY ERROR: Armature created/rebound and profile is null"); _logger.Fatal("INTEGRITY ERROR: Armature created/updated and profile is null");
(Profile? activeProfile, Profile? oldProfile) = (null, null); (Profile? activeProfile, Profile? oldProfile) = (null, null);
if (type == ArmatureChanged.Type.Created) if (type == ArmatureChanged.Type.Created)

View File

@@ -17,6 +17,7 @@ public partial class CustomizePlusIpc : IDisposable
private readonly HookingService _hookingService; private readonly HookingService _hookingService;
private readonly ProfileManager _profileManager; private readonly ProfileManager _profileManager;
private readonly GameObjectService _gameObjectService; private readonly GameObjectService _gameObjectService;
private readonly ProfileFileSystem _profileFileSystem;
private readonly ArmatureChanged _armatureChangedEvent; private readonly ArmatureChanged _armatureChangedEvent;
@@ -31,6 +32,7 @@ public partial class CustomizePlusIpc : IDisposable
HookingService hookingService, HookingService hookingService,
ProfileManager profileManager, ProfileManager profileManager,
GameObjectService gameObjectService, GameObjectService gameObjectService,
ProfileFileSystem profileFileSystem,
ArmatureChanged armatureChangedEvent) ArmatureChanged armatureChangedEvent)
{ {
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
@@ -38,6 +40,7 @@ public partial class CustomizePlusIpc : IDisposable
_hookingService = hookingService; _hookingService = hookingService;
_profileManager = profileManager; _profileManager = profileManager;
_gameObjectService = gameObjectService; _gameObjectService = gameObjectService;
_profileFileSystem = profileFileSystem;
_armatureChangedEvent = armatureChangedEvent; _armatureChangedEvent = armatureChangedEvent;

View File

@@ -16,7 +16,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using IPCProfileDataTuple = (System.Guid UniqueId, string Name, string CharacterName, bool IsEnabled); using IPCProfileDataTuple = (System.Guid UniqueId, string Name, string VirtualPath, string CharacterName, bool IsEnabled);
using OtterGui.Log; using OtterGui.Log;
using CustomizePlus.Core.Extensions; using CustomizePlus.Core.Extensions;
@@ -223,7 +223,7 @@ public class IPCTestTab //: IDisposable
if (ImGui.Button("Copy user profile list to clipboard")) if (ImGui.Button("Copy user profile list to clipboard"))
{ {
ImGui.SetClipboardText(string.Join("\n", _getProfileListIpcFunc().Select(x => $"{x.UniqueId}, {x.Name}, {x.CharacterName}, {x.IsEnabled}"))); ImGui.SetClipboardText(string.Join("\n", _getProfileListIpcFunc().Select(x => $"{x.UniqueId}, {x.Name}, {x.VirtualPath}, {x.CharacterName}, {x.IsEnabled}")));
_popupSystem.ShowPopup(PopupSystem.Messages.IPCCopiedToClipboard); _popupSystem.ShowPopup(PopupSystem.Messages.IPCCopiedToClipboard);
} }