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.Services;
using CustomizePlus.GameData.Extensions;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
namespace CustomizePlus.Armatures.Services;
@@ -345,6 +346,7 @@ public unsafe sealed class ArmatureManager : IDisposable
if (type is not TemplateChanged.Type.NewBone &&
type is not TemplateChanged.Type.DeletedBone &&
type is not TemplateChanged.Type.EditorCharacterChanged &&
type is not TemplateChanged.Type.EditorLimitLookupToOwnedChanged &&
type is not TemplateChanged.Type.EditorEnabled &&
type is not TemplateChanged.Type.EditorDisabled)
return;
@@ -390,6 +392,21 @@ public unsafe sealed class ArmatureManager : IDisposable
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 ||
type == TemplateChanged.Type.EditorDisabled)
{

View File

@@ -5,6 +5,7 @@ using CustomizePlus.Armatures.Data;
using CustomizePlus.Core.Data;
using CustomizePlus.Core.Extensions;
using CustomizePlus.Core.Services;
using CustomizePlus.Profiles.Enums;
using CustomizePlus.Templates;
using CustomizePlus.Templates.Data;
using Newtonsoft.Json;
@@ -46,11 +47,13 @@ public sealed class Profile : ISavable
public bool IsWriteProtected { get; internal set; }
public ProfileType ProfileType { get; set; }
/// <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
/// </summary>
public bool IsTemporary { get; set; }
public bool IsTemporary => ProfileType == ProfileType.Temporary;
/// <summary>
/// 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.Services;
using CustomizePlus.GameData.Extensions;
using CustomizePlus.Profiles.Enums;
namespace CustomizePlus.Profiles;
@@ -378,7 +379,7 @@ public class ProfileManager : IDisposable
return;
profile.Enabled = true;
profile.IsTemporary = true;
profile.ProfileType = ProfileType.Temporary;
profile.TemporaryActor = identifier;
profile.CharacterName = identifier.ToNameWithoutOwnerName();
profile.LimitLookupToOwnedObjects = false;
@@ -500,6 +501,10 @@ public class ProfileManager : IDisposable
private void SaveProfile(Profile profile)
{
//disallow saving special profiles
if (profile.ProfileType != ProfileType.Normal)
return;
profile.ModifiedDate = DateTimeOffset.UtcNow;
_saveService.QueueSave(profile);
}

View File

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

View File

@@ -1,9 +1,12 @@
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 FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using OtterGui.Log;
using System;
using System.Collections.Generic;
@@ -69,7 +72,7 @@ public class TemplateEditorManager : IDisposable
_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()
@@ -163,6 +166,18 @@ public class TemplateEditorManager : IDisposable
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>
/// Resets changes in currently edited template to default values
/// </summary>

View File

@@ -134,7 +134,7 @@ public class StateMonitoringTab
characterName = characterName.Incognify();
#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)
return;

View File

@@ -31,6 +31,14 @@ public class BoneEditorPanel
private bool _isShowLiveBones;
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 IsEditorActive => _editorManager.IsEditorActive;
public bool IsEditorPaused => _editorManager.IsEditorPaused;
@@ -41,18 +49,6 @@ public class BoneEditorPanel
public bool IsCharacterFound { 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(
TemplateFileSystemSelector templateFileSystemSelector,
TemplateEditorManager editorManager,
@@ -75,7 +71,7 @@ public class BoneEditorPanel
{
if (_editorManager.EnableEditor(template, CharacterName))
{
_editorManager.EditorProfile.LimitLookupToOwnedObjects = _configuration.EditorConfiguration.LimitLookupToOwnedObjects;
_editorManager.SetLimitLookupToOwned(_configuration.EditorConfiguration.LimitLookupToOwnedObjects);
return true;
}
@@ -157,7 +153,7 @@ public class BoneEditorPanel
var enabled = _editorManager.EditorProfile.LimitLookupToOwnedObjects;
if (ImGui.Checkbox("##LimitLookupToOwnedObjects", ref enabled))
{
_editorManager.EditorProfile.LimitLookupToOwnedObjects = enabled;
_editorManager.SetLimitLookupToOwned(enabled);
_configuration.EditorConfiguration.LimitLookupToOwnedObjects = enabled;
_configuration.Save();
@@ -376,26 +372,34 @@ public class BoneEditorPanel
#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(
$"Reset '{BoneData.GetBoneDisplayName(codename)}' to default {_editingAttribute} values");
$"Reset '{BoneData.GetBoneDisplayName(bone.BoneCodeName)}' to default {_editingAttribute} values");
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;
}
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(
$"Revert '{BoneData.GetBoneDisplayName(codename)}' to last saved {_editingAttribute} values");
$"Revert '{BoneData.GetBoneDisplayName(bone.BoneCodeName)}' to last saved {_editingAttribute} values");
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;
}
@@ -464,9 +468,9 @@ public class BoneEditorPanel
//----------------------------------
ImGui.Dummy(new Vector2(CtrlHelper.IconButtonWidth * 0.75f, 0));
ImGui.SameLine();
ResetBoneButton(codename);
ResetBoneButton(bone);
ImGui.SameLine();
RevertBoneButton(codename);
RevertBoneButton(bone);
//----------------------------------
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.
## 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`
Alternatively use the Collective repo Sea of Stars which you can get from here: