mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-01-02 05:43:42 +01:00
Add working links.
This commit is contained in:
parent
282d6df165
commit
5992b86e4f
9 changed files with 31 additions and 11 deletions
|
|
@ -262,7 +262,8 @@ public sealed class AutoDesignApplier : IDisposable
|
||||||
if (!_humans.IsHuman((uint)actor.AsCharacter->CharacterData.ModelCharaId))
|
if (!_humans.IsHuman((uint)actor.AsCharacter->CharacterData.ModelCharaId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var mergedDesign = _designMerger.Merge(set.Designs.Where(d => d.IsActive(actor)).Select(d => ((DesignBase?)d.Design, d.Type)),
|
var mergedDesign = _designMerger.Merge(
|
||||||
|
set.Designs.Where(d => d.IsActive(actor)).SelectMany(d => d.Design?.AllLinks ?? [(d.Design, d.Type)]),
|
||||||
state.ModelData, true, false);
|
state.ModelData, true, false);
|
||||||
_state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false));
|
_state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,9 @@ public sealed class Design : DesignBase, ISavable
|
||||||
public string Incognito
|
public string Incognito
|
||||||
=> Identifier.ToString()[..8];
|
=> Identifier.ToString()[..8];
|
||||||
|
|
||||||
|
public IEnumerable<(DesignBase? Design, ApplicationType Flags)> AllLinks
|
||||||
|
=> LinkContainer.GetAllLinks(this).Select(t => ((DesignBase?)t.Link.Link, t.Link.Type));
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Serialization
|
#region Serialization
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ public readonly record struct ApplySettings(
|
||||||
StateSource Source = StateSource.Manual,
|
StateSource Source = StateSource.Manual,
|
||||||
bool RespectManual = false,
|
bool RespectManual = false,
|
||||||
bool FromJobChange = false,
|
bool FromJobChange = false,
|
||||||
bool UseSingleSource = false)
|
bool UseSingleSource = false,
|
||||||
|
bool MergeLinks = false)
|
||||||
{
|
{
|
||||||
public static readonly ApplySettings Manual = new()
|
public static readonly ApplySettings Manual = new()
|
||||||
{
|
{
|
||||||
|
|
@ -20,6 +21,7 @@ public readonly record struct ApplySettings(
|
||||||
FromJobChange = false,
|
FromJobChange = false,
|
||||||
RespectManual = false,
|
RespectManual = false,
|
||||||
UseSingleSource = false,
|
UseSingleSource = false,
|
||||||
|
MergeLinks = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly ApplySettings Game = new()
|
public static readonly ApplySettings Game = new()
|
||||||
|
|
@ -29,6 +31,7 @@ public readonly record struct ApplySettings(
|
||||||
FromJobChange = false,
|
FromJobChange = false,
|
||||||
RespectManual = false,
|
RespectManual = false,
|
||||||
UseSingleSource = false,
|
UseSingleSource = false,
|
||||||
|
MergeLinks = false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ public class DesignMerger(
|
||||||
ItemUnlockManager _itemUnlocks,
|
ItemUnlockManager _itemUnlocks,
|
||||||
CustomizeUnlockManager _customizeUnlocks) : IService
|
CustomizeUnlockManager _customizeUnlocks) : IService
|
||||||
{
|
{
|
||||||
|
public MergedDesign Merge(LinkContainer designs, in DesignData baseRef, bool respectOwnership, bool modAssociations)
|
||||||
|
=> Merge(designs.Select(d => ((DesignBase?) d.Link, d.Type)), baseRef, respectOwnership, modAssociations);
|
||||||
|
|
||||||
public MergedDesign Merge(IEnumerable<(DesignBase?, ApplicationType)> designs, in DesignData baseRef, bool respectOwnership,
|
public MergedDesign Merge(IEnumerable<(DesignBase?, ApplicationType)> designs, in DesignData baseRef, bool respectOwnership,
|
||||||
bool modAssociations)
|
bool modAssociations)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ public class ActorPanel(
|
||||||
var text = ImGui.GetClipboardText();
|
var text = ImGui.GetClipboardText();
|
||||||
var design = _converter.FromBase64(text, applyCustomize, applyGear, out _)
|
var design = _converter.FromBase64(text, applyCustomize, applyGear, out _)
|
||||||
?? throw new Exception("The clipboard did not contain valid data.");
|
?? throw new Exception("The clipboard did not contain valid data.");
|
||||||
_stateManager.ApplyDesign(_state!, design, ApplySettings.Manual);
|
_stateManager.ApplyDesign(_state!, design, ApplySettings.Manual with { MergeLinks = true });
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -438,7 +438,7 @@ public class DesignPanel(
|
||||||
{
|
{
|
||||||
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
|
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
|
||||||
using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest, applyParameters);
|
using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest, applyParameters);
|
||||||
_state.ApplyDesign(state, _selector.Selected!, ApplySettings.Manual);
|
_state.ApplyDesign(state, _selector.Selected!, ApplySettings.Manual with { MergeLinks = true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -457,7 +457,7 @@ public class DesignPanel(
|
||||||
{
|
{
|
||||||
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
|
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
|
||||||
using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest, applyParameters);
|
using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest, applyParameters);
|
||||||
_state.ApplyDesign(state, _selector.Selected!, ApplySettings.Manual);
|
_state.ApplyDesign(state, _selector.Selected!, ApplySettings.Manual with {MergeLinks = true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -419,7 +419,7 @@ public class CommandService : IDisposable
|
||||||
if (!_objects.TryGetValue(identifier, out var actors))
|
if (!_objects.TryGetValue(identifier, out var actors))
|
||||||
{
|
{
|
||||||
if (_stateManager.TryGetValue(identifier, out var state))
|
if (_stateManager.TryGetValue(identifier, out var state))
|
||||||
_stateManager.ApplyDesign(state, design, ApplySettings.Manual);
|
_stateManager.ApplyDesign(state, design, ApplySettings.Manual with { MergeLinks = true });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -428,7 +428,7 @@ public class CommandService : IDisposable
|
||||||
if (_stateManager.GetOrCreate(actor.GetIdentifier(_actors), actor, out var state))
|
if (_stateManager.GetOrCreate(actor.GetIdentifier(_actors), actor, out var state))
|
||||||
{
|
{
|
||||||
ApplyModSettings(design, actor, applyMods);
|
ApplyModSettings(design, actor, applyMods);
|
||||||
_stateManager.ApplyDesign(state, design, ApplySettings.Manual);
|
_stateManager.ApplyDesign(state, design, ApplySettings.Manual with { MergeLinks = true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ public class StateEditor(
|
||||||
StateChanged stateChanged,
|
StateChanged stateChanged,
|
||||||
JobChangeState jobChange,
|
JobChangeState jobChange,
|
||||||
Configuration config,
|
Configuration config,
|
||||||
ItemManager items) : IDesignEditor
|
ItemManager items,
|
||||||
|
DesignMerger merger) : IDesignEditor
|
||||||
{
|
{
|
||||||
protected readonly InternalStateEditor Editor = editor;
|
protected readonly InternalStateEditor Editor = editor;
|
||||||
protected readonly StateApplier Applier = applier;
|
protected readonly StateApplier Applier = applier;
|
||||||
|
|
@ -293,12 +294,19 @@ public class StateEditor(
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplyDesign(object data, DesignBase design, ApplySettings settings)
|
public void ApplyDesign(object data, DesignBase design, ApplySettings settings)
|
||||||
=> ApplyDesign(data, new MergedDesign(design), settings with
|
{
|
||||||
|
var merged = settings.MergeLinks && design is Design d
|
||||||
|
? merger.Merge(d.AllLinks, ((ActorState)data).ModelData, false, false)
|
||||||
|
: new MergedDesign(design);
|
||||||
|
|
||||||
|
ApplyDesign(data, merged, settings with
|
||||||
{
|
{
|
||||||
FromJobChange = false,
|
FromJobChange = false,
|
||||||
RespectManual = false,
|
RespectManual = false,
|
||||||
UseSingleSource = true,
|
UseSingleSource = true,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary> Apply offhand item and potentially gauntlets if configured. </summary>
|
/// <summary> Apply offhand item and potentially gauntlets if configured. </summary>
|
||||||
private void ApplyMainhandPeriphery(ActorState state, EquipItem? newMainhand, ApplySettings settings)
|
private void ApplyMainhandPeriphery(ActorState state, EquipItem? newMainhand, ApplySettings settings)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using Glamourer.Designs;
|
using Glamourer.Designs;
|
||||||
|
using Glamourer.Designs.Links;
|
||||||
using Glamourer.Events;
|
using Glamourer.Events;
|
||||||
using Glamourer.GameData;
|
using Glamourer.GameData;
|
||||||
using Glamourer.Interop;
|
using Glamourer.Interop;
|
||||||
|
|
@ -21,8 +22,9 @@ public sealed class StateManager(
|
||||||
HumanModelList _humans,
|
HumanModelList _humans,
|
||||||
IClientState _clientState,
|
IClientState _clientState,
|
||||||
Configuration config,
|
Configuration config,
|
||||||
JobChangeState jobChange)
|
JobChangeState jobChange,
|
||||||
: StateEditor(editor, applier, @event, jobChange, config, items), IReadOnlyDictionary<ActorIdentifier, ActorState>
|
DesignMerger merger)
|
||||||
|
: StateEditor(editor, applier, @event, jobChange, config, items, merger), IReadOnlyDictionary<ActorIdentifier, ActorState>
|
||||||
{
|
{
|
||||||
private readonly Dictionary<ActorIdentifier, ActorState> _states = [];
|
private readonly Dictionary<ActorIdentifier, ActorState> _states = [];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue