using CustomizePlus.Configuration.Data; using CustomizePlus.Core.Data; using CustomizePlus.Game.Events; using CustomizePlus.Game.Services; using CustomizePlus.Profiles; using CustomizePlus.Profiles.Data; using CustomizePlus.Profiles.Enums; using CustomizePlus.Templates.Data; using CustomizePlus.Templates.Events; using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using OtterGui.Classes; using OtterGui.Log; using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace CustomizePlus.Templates; public class TemplateEditorManager : IDisposable { private readonly TemplateChanged _event; private readonly Logger _logger; private readonly GameObjectService _gameObjectService; private readonly TemplateManager _templateManager; private readonly IClientState _clientState; private readonly PluginConfiguration _configuration; /// /// Reference to the original template which is currently being edited, should not be edited! /// private Template _currentlyEditedTemplateOriginal; /// /// Internal profile for the editor /// public Profile EditorProfile { get; private set; } /// /// Original ID of the template which is currently being edited /// public Guid CurrentlyEditedTemplateId { get; private set; } /// /// A copy of currently edited template, all changes must be done on this template /// public Template? CurrentlyEditedTemplate { get; private set; } public bool IsEditorActive { get; private set; } /// /// Is editor currently paused? Happens automatically when editor is not compatible with the current game state. /// Keeps editor state frozen and prevents any changes to it, also sets editor profile as disabled. /// public bool IsEditorPaused { get; private set; } /// /// Indicates if there are any changes in current editing session or not /// public bool HasChanges { get; private set; } /// /// Name of the preview character for the editor /// public string CharacterName => EditorProfile.CharacterName; /// /// Checks if preview character exists at the time of call /// public bool IsCharacterFound => _gameObjectService.FindActorsByName(CharacterName).Count() > 0; public bool IsKeepOnlyEditorProfileActive { get; set; } //todo public TemplateEditorManager( TemplateChanged @event, Logger logger, TemplateManager templateManager, GameObjectService gameObjectService, IClientState clientState, PluginConfiguration configuration) { _event = @event; _logger = logger; _templateManager = templateManager; _gameObjectService = gameObjectService; _clientState = clientState; _configuration = configuration; _clientState.Login += OnLogin; EditorProfile = new Profile() { Templates = new List