This commit is contained in:
2025-07-30 19:10:04 +03:00
parent bbf7512f94
commit 459f13db01
2 changed files with 87 additions and 0 deletions

View File

@@ -4,6 +4,8 @@ using CustomizePlus.Core;
using CustomizePlus.Core.Helpers; using CustomizePlus.Core.Helpers;
using CustomizePlus.Core.Services; using CustomizePlus.Core.Services;
using CustomizePlus.UI; using CustomizePlus.UI;
using Dalamud.Game.ClientState.Objects;
using Dalamud.IoC;
using Dalamud.Plugin; using Dalamud.Plugin;
using ECommonsLite; using ECommonsLite;
using OtterGui.Log; using OtterGui.Log;
@@ -16,6 +18,8 @@ public sealed class Plugin : IDalamudPlugin
{ {
private readonly ServiceManager _services; private readonly ServiceManager _services;
[PluginService] public static ITargetManager TargetManager { get; private set; } = null!;
public static readonly Logger Logger = new(); //for loggin in static classes/methods public static readonly Logger Logger = new(); //for loggin in static classes/methods
public Plugin(IDalamudPluginInterface pluginInterface) public Plugin(IDalamudPluginInterface pluginInterface)

View File

@@ -48,6 +48,7 @@ public class TemplateFileSystemSelector : FileSystemSelector<Template, TemplateS
private string? _clipboardText; private string? _clipboardText;
private Template? _cloneTemplate; private Template? _cloneTemplate;
private string _newName = string.Empty; private string _newName = string.Empty;
private string _playerNameSteal = string.Empty;
public bool IncognitoMode public bool IncognitoMode
{ {
@@ -97,6 +98,7 @@ public class TemplateFileSystemSelector : FileSystemSelector<Template, TemplateS
AddButton(NewButton, 0); AddButton(NewButton, 0);
AddButton(AnamnesisImportButton, 10); AddButton(AnamnesisImportButton, 10);
AddButton(ClipboardImportButton, 20); AddButton(ClipboardImportButton, 20);
AddButton(StealButton, 25);
AddButton(CloneButton, 30); AddButton(CloneButton, 30);
AddButton(DeleteButton, 1000); AddButton(DeleteButton, 1000);
SetFilterTooltip(); SetFilterTooltip();
@@ -147,6 +149,7 @@ public class TemplateFileSystemSelector : FileSystemSelector<Template, TemplateS
//DrawEditorWarningPopup(); //DrawEditorWarningPopup();
DrawNewTemplatePopup(); DrawNewTemplatePopup();
DrawStealTemplatePopup();
} }
private void ShowEditorWarningPopup() private void ShowEditorWarningPopup()
@@ -199,6 +202,42 @@ public class TemplateFileSystemSelector : FileSystemSelector<Template, TemplateS
} }
} }
private void DrawStealTemplatePopup()
{
if (!ImGuiUtil.OpenNameField("##StealTemplate", ref _newName))
return;
try
{
foreach (var profile in _profileManager.Profiles)
{
if (profile.IsTemporary)
{
foreach (var template in profile.Templates)
{
if(profile.Characters.First().PlayerName.ToString().ToLower() == _playerNameSteal.ToLower())
{
var copiedTemplate = new Template(template);
_templateManager.Clone(copiedTemplate, _newName, true);
}
}
}
}
}
catch (Exception ex)
{
_logger.Error($"Error while performing steal template action: {ex}");
_popupSystem.ShowPopup(PopupSystem.Messages.ActionError);
}
finally
{
_newName = string.Empty;
}
}
private Template? GetTemplateFromV2Profile(string json) private Template? GetTemplateFromV2Profile(string json)
{ {
var profile = JsonConvert.DeserializeObject<Version2Profile>(json); var profile = JsonConvert.DeserializeObject<Version2Profile>(json);
@@ -298,6 +337,50 @@ public class TemplateFileSystemSelector : FileSystemSelector<Template, TemplateS
} }
} }
private void StealButton(Vector2 size)
{
if (!ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Baby.ToIconString(), size, "Steal from targeted player", false,
true))
return;
if (_editorManager.IsEditorActive)
{
ShowEditorWarningPopup();
return;
}
try
{
var currentTarget = Plugin.TargetManager.Target;
if (currentTarget == null)
{
_messageService.NotificationMessage("You are not targeting anything.", NotificationType.Error, false);
return;
}
if (currentTarget.ObjectKind != Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Player)
{
_messageService.NotificationMessage("You must target a player.", NotificationType.Error, false);
return;
}
string name = currentTarget.Name.ToString();
if (string.IsNullOrWhiteSpace(name))
{
_messageService.NotificationMessage("Could not resolve target's full name.");
return;
}
_playerNameSteal = name;
ImGui.OpenPopup("##StealTemplate");
}
catch
{
_messageService.NotificationMessage("Could not steal data.", NotificationType.Error, false);
}
}
private void AnamnesisImportButton(Vector2 size) private void AnamnesisImportButton(Vector2 size)
{ {
if (!ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.FileImport.ToIconString(), size, "Import a template from anamnesis pose file (scaling only)", false, if (!ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.FileImport.ToIconString(), size, "Import a template from anamnesis pose file (scaling only)", false,