Fixed editor's "limit to my creatures" setting not updating properly, fixed mirror mode not working on reset buttons

This commit is contained in:
RisaDev
2024-01-09 22:14:41 +03:00
parent 44607e10d7
commit b979751ca4
9 changed files with 83 additions and 30 deletions

View File

@@ -18,6 +18,7 @@ using CustomizePlus.Core.Extensions;
using CustomizePlus.GameData.Data; using CustomizePlus.GameData.Data;
using CustomizePlus.GameData.Services; using CustomizePlus.GameData.Services;
using CustomizePlus.GameData.Extensions; using CustomizePlus.GameData.Extensions;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
namespace CustomizePlus.Armatures.Services; namespace CustomizePlus.Armatures.Services;
@@ -345,6 +346,7 @@ public unsafe sealed class ArmatureManager : IDisposable
if (type is not TemplateChanged.Type.NewBone && if (type is not TemplateChanged.Type.NewBone &&
type is not TemplateChanged.Type.DeletedBone && type is not TemplateChanged.Type.DeletedBone &&
type is not TemplateChanged.Type.EditorCharacterChanged && type is not TemplateChanged.Type.EditorCharacterChanged &&
type is not TemplateChanged.Type.EditorLimitLookupToOwnedChanged &&
type is not TemplateChanged.Type.EditorEnabled && type is not TemplateChanged.Type.EditorEnabled &&
type is not TemplateChanged.Type.EditorDisabled) type is not TemplateChanged.Type.EditorDisabled)
return; return;
@@ -390,6 +392,21 @@ public unsafe sealed class ArmatureManager : IDisposable
return; return;
} }
if(type == TemplateChanged.Type.EditorLimitLookupToOwnedChanged)
{
var profile = (Profile)arg3!;
if (profile.Armatures.Count == 0)
return;
foreach (var armature in profile.Armatures)
armature.IsPendingProfileRebind = true;
_logger.Debug($"ArmatureManager.OnTemplateChange Editor profile limit lookup setting changed, armature rebind scheduled: {type}, profile: {profile.Name.Text.Incognify()}->{profile.Enabled}");
return;
}
if (type == TemplateChanged.Type.EditorEnabled || if (type == TemplateChanged.Type.EditorEnabled ||
type == TemplateChanged.Type.EditorDisabled) type == TemplateChanged.Type.EditorDisabled)
{ {

View File

@@ -5,6 +5,7 @@ using CustomizePlus.Armatures.Data;
using CustomizePlus.Core.Data; using CustomizePlus.Core.Data;
using CustomizePlus.Core.Extensions; using CustomizePlus.Core.Extensions;
using CustomizePlus.Core.Services; using CustomizePlus.Core.Services;
using CustomizePlus.Profiles.Enums;
using CustomizePlus.Templates; using CustomizePlus.Templates;
using CustomizePlus.Templates.Data; using CustomizePlus.Templates.Data;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -46,11 +47,13 @@ public sealed class Profile : ISavable
public bool IsWriteProtected { get; internal set; } public bool IsWriteProtected { get; internal set; }
public ProfileType ProfileType { get; set; }
/// <summary> /// <summary>
/// Specifies if this profile is not persistent (ex. was made via IPC calls) and should not be displayed in UI. /// Tells us if this profile is not persistent (ex. was made via IPC calls) and should have specific treatement like not being shown in UI, etc.
/// WARNING, TEMPLATES FOR TEMPORARY PROFILES *ARE NOT* STORED IN TemplateManager /// WARNING, TEMPLATES FOR TEMPORARY PROFILES *ARE NOT* STORED IN TemplateManager
/// </summary> /// </summary>
public bool IsTemporary { get; set; } public bool IsTemporary => ProfileType == ProfileType.Temporary;
/// <summary> /// <summary>
/// Identificator specifying specific actor this profile applies to, only works for temporary profiles /// Identificator specifying specific actor this profile applies to, only works for temporary profiles

View File

@@ -0,0 +1,8 @@
namespace CustomizePlus.Profiles.Enums;
public enum ProfileType
{
Normal,
Temporary,
Editor
}

View File

@@ -21,6 +21,7 @@ using CustomizePlus.Templates.Data;
using CustomizePlus.GameData.Data; using CustomizePlus.GameData.Data;
using CustomizePlus.GameData.Services; using CustomizePlus.GameData.Services;
using CustomizePlus.GameData.Extensions; using CustomizePlus.GameData.Extensions;
using CustomizePlus.Profiles.Enums;
namespace CustomizePlus.Profiles; namespace CustomizePlus.Profiles;
@@ -378,7 +379,7 @@ public class ProfileManager : IDisposable
return; return;
profile.Enabled = true; profile.Enabled = true;
profile.IsTemporary = true; profile.ProfileType = ProfileType.Temporary;
profile.TemporaryActor = identifier; profile.TemporaryActor = identifier;
profile.CharacterName = identifier.ToNameWithoutOwnerName(); profile.CharacterName = identifier.ToNameWithoutOwnerName();
profile.LimitLookupToOwnedObjects = false; profile.LimitLookupToOwnedObjects = false;
@@ -500,6 +501,10 @@ public class ProfileManager : IDisposable
private void SaveProfile(Profile profile) private void SaveProfile(Profile profile)
{ {
//disallow saving special profiles
if (profile.ProfileType != ProfileType.Normal)
return;
profile.ModifiedDate = DateTimeOffset.UtcNow; profile.ModifiedDate = DateTimeOffset.UtcNow;
_saveService.QueueSave(profile); _saveService.QueueSave(profile);
} }

View File

@@ -20,6 +20,7 @@ public class TemplateChanged() : EventWrapper<TemplateChanged.Type, Template?, o
EditorEnabled, EditorEnabled,
EditorDisabled, EditorDisabled,
EditorCharacterChanged, EditorCharacterChanged,
EditorLimitLookupToOwnedChanged,
ReloadedAll, ReloadedAll,
WriteProtection WriteProtection
} }

View File

@@ -1,9 +1,12 @@
using CustomizePlus.Core.Data; using CustomizePlus.Core.Data;
using CustomizePlus.Game.Events; using CustomizePlus.Game.Events;
using CustomizePlus.Game.Services; using CustomizePlus.Game.Services;
using CustomizePlus.Profiles;
using CustomizePlus.Profiles.Data; using CustomizePlus.Profiles.Data;
using CustomizePlus.Profiles.Enums;
using CustomizePlus.Templates.Data; using CustomizePlus.Templates.Data;
using CustomizePlus.Templates.Events; using CustomizePlus.Templates.Events;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using OtterGui.Log; using OtterGui.Log;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -69,7 +72,7 @@ public class TemplateEditorManager : IDisposable
_gposeStateChanged.Subscribe(OnGPoseStateChanged, GPoseStateChanged.Priority.TemplateEditorManager); _gposeStateChanged.Subscribe(OnGPoseStateChanged, GPoseStateChanged.Priority.TemplateEditorManager);
EditorProfile = new Profile() { Templates = new List<Template>(), Enabled = false, Name = "Template editor profile" }; EditorProfile = new Profile() { Templates = new List<Template>(), Enabled = false, Name = "Template editor profile", ProfileType = ProfileType.Editor };
} }
public void Dispose() public void Dispose()
@@ -163,6 +166,18 @@ public class TemplateEditorManager : IDisposable
return true; return true;
} }
public bool SetLimitLookupToOwned(bool value)
{
if (!IsEditorActive || IsEditorPaused || value == EditorProfile.LimitLookupToOwnedObjects)
return false;
//_profileManager.SetLimitLookupToOwned(EditorProfile, value);
EditorProfile.LimitLookupToOwnedObjects = value;
_event.Invoke(TemplateChanged.Type.EditorLimitLookupToOwnedChanged, CurrentlyEditedTemplate, EditorProfile);
return true;
}
/// <summary> /// <summary>
/// Resets changes in currently edited template to default values /// Resets changes in currently edited template to default values
/// </summary> /// </summary>

View File

@@ -134,7 +134,7 @@ public class StateMonitoringTab
characterName = characterName.Incognify(); characterName = characterName.Incognify();
#endif #endif
var show = ImGui.CollapsingHeader($"[{(profile.Enabled ? "E" : "D")}] {name} on {characterName} [{(profile.IsTemporary ? "Temporary" : "Permanent")}] [{profile.UniqueId}]###{prefix}-profile-{profile.UniqueId}"); var show = ImGui.CollapsingHeader($"[{(profile.Enabled ? "E" : "D")}] {name} on {characterName} [{profile.ProfileType}] [{profile.UniqueId}]###{prefix}-profile-{profile.UniqueId}");
if (!show) if (!show)
return; return;

View File

@@ -31,6 +31,14 @@ public class BoneEditorPanel
private bool _isShowLiveBones; private bool _isShowLiveBones;
private bool _isMirrorModeEnabled; private bool _isMirrorModeEnabled;
private string? _newCharacterName;
private Dictionary<BoneData.BoneFamily, bool> _groupExpandedState = new();
private bool _openSavePopup;
private bool _isUnlocked = false;
public bool HasChanges => _editorManager.HasChanges; public bool HasChanges => _editorManager.HasChanges;
public bool IsEditorActive => _editorManager.IsEditorActive; public bool IsEditorActive => _editorManager.IsEditorActive;
public bool IsEditorPaused => _editorManager.IsEditorPaused; public bool IsEditorPaused => _editorManager.IsEditorPaused;
@@ -41,18 +49,6 @@ public class BoneEditorPanel
public bool IsCharacterFound { get; private set; } public bool IsCharacterFound { get; private set; }
public string CharacterName { get; private set; } public string CharacterName { get; private set; }
private ModelBone? _changedBone;
private string? _changedBoneName;
private BoneTransform? _changedBoneTransform;
private string? _newCharacterName;
private Dictionary<BoneData.BoneFamily, bool> _groupExpandedState = new();
private bool _openSavePopup;
private bool _isUnlocked = false;
public BoneEditorPanel( public BoneEditorPanel(
TemplateFileSystemSelector templateFileSystemSelector, TemplateFileSystemSelector templateFileSystemSelector,
TemplateEditorManager editorManager, TemplateEditorManager editorManager,
@@ -75,7 +71,7 @@ public class BoneEditorPanel
{ {
if (_editorManager.EnableEditor(template, CharacterName)) if (_editorManager.EnableEditor(template, CharacterName))
{ {
_editorManager.EditorProfile.LimitLookupToOwnedObjects = _configuration.EditorConfiguration.LimitLookupToOwnedObjects; _editorManager.SetLimitLookupToOwned(_configuration.EditorConfiguration.LimitLookupToOwnedObjects);
return true; return true;
} }
@@ -157,7 +153,7 @@ public class BoneEditorPanel
var enabled = _editorManager.EditorProfile.LimitLookupToOwnedObjects; var enabled = _editorManager.EditorProfile.LimitLookupToOwnedObjects;
if (ImGui.Checkbox("##LimitLookupToOwnedObjects", ref enabled)) if (ImGui.Checkbox("##LimitLookupToOwnedObjects", ref enabled))
{ {
_editorManager.EditorProfile.LimitLookupToOwnedObjects = enabled; _editorManager.SetLimitLookupToOwned(enabled);
_configuration.EditorConfiguration.LimitLookupToOwnedObjects = enabled; _configuration.EditorConfiguration.LimitLookupToOwnedObjects = enabled;
_configuration.Save(); _configuration.Save();
@@ -376,26 +372,34 @@ public class BoneEditorPanel
#region ImGui helper functions #region ImGui helper functions
public bool ResetBoneButton(string codename) private bool ResetBoneButton(EditRowParams bone)
{ {
var output = ImGuiComponents.IconButton(codename, FontAwesomeIcon.Recycle); var output = ImGuiComponents.IconButton(bone.BoneCodeName, FontAwesomeIcon.Recycle);
CtrlHelper.AddHoverText( CtrlHelper.AddHoverText(
$"Reset '{BoneData.GetBoneDisplayName(codename)}' to default {_editingAttribute} values"); $"Reset '{BoneData.GetBoneDisplayName(bone.BoneCodeName)}' to default {_editingAttribute} values");
if (output) if (output)
_editorManager.ResetBoneAttributeChanges(codename, _editingAttribute); {
_editorManager.ResetBoneAttributeChanges(bone.BoneCodeName, _editingAttribute);
if (_isMirrorModeEnabled && bone.Basis?.TwinBone != null) //todo: put it inside manager
_editorManager.ResetBoneAttributeChanges(bone.Basis.TwinBone.BoneName, _editingAttribute);
}
return output; return output;
} }
private bool RevertBoneButton(string codename) private bool RevertBoneButton(EditRowParams bone)
{ {
var output = ImGuiComponents.IconButton(codename, FontAwesomeIcon.ArrowCircleLeft); var output = ImGuiComponents.IconButton(bone.BoneCodeName, FontAwesomeIcon.ArrowCircleLeft);
CtrlHelper.AddHoverText( CtrlHelper.AddHoverText(
$"Revert '{BoneData.GetBoneDisplayName(codename)}' to last saved {_editingAttribute} values"); $"Revert '{BoneData.GetBoneDisplayName(bone.BoneCodeName)}' to last saved {_editingAttribute} values");
if (output) if (output)
_editorManager.RevertBoneAttributeChanges(codename, _editingAttribute); {
_editorManager.RevertBoneAttributeChanges(bone.BoneCodeName, _editingAttribute);
if (_isMirrorModeEnabled && bone.Basis?.TwinBone != null) //todo: put it inside manager
_editorManager.RevertBoneAttributeChanges(bone.Basis.TwinBone.BoneName, _editingAttribute);
}
return output; return output;
} }
@@ -464,9 +468,9 @@ public class BoneEditorPanel
//---------------------------------- //----------------------------------
ImGui.Dummy(new Vector2(CtrlHelper.IconButtonWidth * 0.75f, 0)); ImGui.Dummy(new Vector2(CtrlHelper.IconButtonWidth * 0.75f, 0));
ImGui.SameLine(); ImGui.SameLine();
ResetBoneButton(codename); ResetBoneButton(bone);
ImGui.SameLine(); ImGui.SameLine();
RevertBoneButton(codename); RevertBoneButton(bone);
//---------------------------------- //----------------------------------
ImGui.TableNextColumn(); ImGui.TableNextColumn();

View File

@@ -2,7 +2,7 @@
Customize+ is a Dalamud plugin designed to give you better control over your Final Fantasy XIV character appearance. Namely it allows you to apply character bone manipulations during gameplay. Customize+ is a Dalamud plugin designed to give you better control over your Final Fantasy XIV character appearance. Namely it allows you to apply character bone manipulations during gameplay.
## Installing ## Installing
After doing that add the following URL to the Dalamud Custom Plugin Repositories list: Add the following URL to the Dalamud Custom Plugin Repositories list:
`https://raw.githubusercontent.com/Aether-Tools/DalamudPlugins/main/repo.json` `https://raw.githubusercontent.com/Aether-Tools/DalamudPlugins/main/repo.json`
Alternatively use the Collective repo Sea of Stars which you can get from here: Alternatively use the Collective repo Sea of Stars which you can get from here: