test
This commit is contained in:
@@ -48,6 +48,7 @@ public class TemplateFileSystemSelector : FileSystemSelector<Template, TemplateS
|
||||
private string? _clipboardText;
|
||||
private Template? _cloneTemplate;
|
||||
private string _newName = string.Empty;
|
||||
private string _playerNameSteal = string.Empty;
|
||||
|
||||
public bool IncognitoMode
|
||||
{
|
||||
@@ -97,6 +98,7 @@ public class TemplateFileSystemSelector : FileSystemSelector<Template, TemplateS
|
||||
AddButton(NewButton, 0);
|
||||
AddButton(AnamnesisImportButton, 10);
|
||||
AddButton(ClipboardImportButton, 20);
|
||||
AddButton(StealButton, 25);
|
||||
AddButton(CloneButton, 30);
|
||||
AddButton(DeleteButton, 1000);
|
||||
SetFilterTooltip();
|
||||
@@ -147,6 +149,7 @@ public class TemplateFileSystemSelector : FileSystemSelector<Template, TemplateS
|
||||
|
||||
//DrawEditorWarningPopup();
|
||||
DrawNewTemplatePopup();
|
||||
DrawStealTemplatePopup();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.FileImport.ToIconString(), size, "Import a template from anamnesis pose file (scaling only)", false,
|
||||
|
||||
Reference in New Issue
Block a user