mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Rename and move and reuse.
This commit is contained in:
parent
9395072bee
commit
a5c1e66916
4 changed files with 31 additions and 71 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Designs;
|
||||
|
|
@ -25,6 +27,9 @@ public partial class GlamourerIpc
|
|||
public const string LabelApplyOnlyCustomizationLock = "Glamourer.ApplyOnlyCustomizationLock";
|
||||
public const string LabelApplyOnlyCustomizationToCharacterLock = "Glamourer.ApplyOnlyCustomizationToCharacterLock";
|
||||
|
||||
public const string LabelApplyByGuid = "Glamourer.ApplyByGuid";
|
||||
public const string LabelApplyByGuidToCharacter = "Glamourer.ApplyByGuidToCharacter";
|
||||
|
||||
private readonly ActionProvider<string, string> _applyAllProvider;
|
||||
private readonly ActionProvider<string, Character?> _applyAllToCharacterProvider;
|
||||
private readonly ActionProvider<string, string> _applyOnlyEquipmentProvider;
|
||||
|
|
@ -39,6 +44,9 @@ public partial class GlamourerIpc
|
|||
private readonly ActionProvider<string, string, uint> _applyOnlyCustomizationProviderLock;
|
||||
private readonly ActionProvider<string, Character?, uint> _applyOnlyCustomizationToCharacterProviderLock;
|
||||
|
||||
private readonly ActionProvider<Guid, string> _applyByGuidProvider;
|
||||
private readonly ActionProvider<Guid, Character?> _applyByGuidToCharacterProvider;
|
||||
|
||||
public static ActionSubscriber<string, string> ApplyAllSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelApplyAll);
|
||||
|
||||
|
|
@ -57,6 +65,12 @@ public partial class GlamourerIpc
|
|||
public static ActionSubscriber<string, Character?> ApplyOnlyCustomizationToCharacterSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelApplyOnlyCustomizationToCharacter);
|
||||
|
||||
public static ActionSubscriber<Guid, string> ApplyByGuidSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelApplyByGuid);
|
||||
|
||||
public static ActionSubscriber<Guid, Character?> ApplyByGuidToCharacterSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelApplyByGuidToCharacter);
|
||||
|
||||
public void ApplyAll(string base64, string characterName)
|
||||
=> ApplyDesign(_designConverter.FromBase64(base64, true, true, out var version), FindActors(characterName), version, 0);
|
||||
|
||||
|
|
@ -95,6 +109,12 @@ public partial class GlamourerIpc
|
|||
=> ApplyDesign(_designConverter.FromBase64(base64, true, false, out var version), FindActors(character), version, lockCode);
|
||||
|
||||
|
||||
public void ApplyByGuid(Guid identifier, string characterName)
|
||||
=> ApplyDesignByGuid(identifier, FindActors(characterName), 0);
|
||||
|
||||
public void ApplyByGuidToCharacter(Guid identifier, Character? character)
|
||||
=> ApplyDesignByGuid(identifier, FindActors(character), 0);
|
||||
|
||||
private void ApplyDesign(DesignBase? design, IEnumerable<ActorIdentifier> actors, byte version, uint lockCode)
|
||||
{
|
||||
if (design == null)
|
||||
|
|
@ -118,4 +138,7 @@ public partial class GlamourerIpc
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyDesignByGuid(Guid identifier, IEnumerable<ActorIdentifier> actors, uint lockCode)
|
||||
=> ApplyDesign(_designManager.Designs.FirstOrDefault(x => x.Identifier == identifier), actors, DesignConverter.Version, lockCode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Events;
|
||||
using Glamourer.Interop.Structs;
|
||||
using Penumbra.Api.Helpers;
|
||||
using Penumbra.GameData.Actors;
|
||||
|
||||
namespace Glamourer.Api;
|
||||
|
||||
public partial class GlamourerIpc
|
||||
{
|
||||
public const string LabelApplyByGuid = "Glamourer.ApplyByGuid";
|
||||
public const string LabelApplyByGuidToCharacter = "Glamourer.ApplyByGuidToCharacter";
|
||||
|
||||
private readonly ActionProvider<Guid, string> _applyByGuidProvider;
|
||||
private readonly ActionProvider<Guid, Character?> _applyByGuidToCharacterProvider;
|
||||
|
||||
public static ActionSubscriber<Guid, string> ApplyByGuidSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelApplyByGuid);
|
||||
|
||||
public static ActionSubscriber<Guid, Character?> ApplyByGuidToCharacterSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelApplyByGuidToCharacter);
|
||||
|
||||
public void ApplyByGuid(Guid Identifier, string characterName)
|
||||
=> ApplyDesignByGuid(Identifier, FindActors(characterName), 0);
|
||||
|
||||
public void ApplyByGuidToCharacter(Guid Identifier, Character? character)
|
||||
=> ApplyDesignByGuid(Identifier, FindActors(character), 0);
|
||||
|
||||
private void ApplyDesignByGuid(Guid Identifier, IEnumerable<ActorIdentifier> actors, uint lockCode)
|
||||
{
|
||||
var design = _designManager.Designs.FirstOrDefault(x => x.Identifier == Identifier);
|
||||
if (design == null)
|
||||
return;
|
||||
|
||||
var hasModelId = true;
|
||||
_objects.Update();
|
||||
foreach (var id in actors)
|
||||
{
|
||||
if (!_stateManager.TryGetValue(id, out var state))
|
||||
{
|
||||
var data = _objects.TryGetValue(id, out var d) ? d : ActorData.Invalid;
|
||||
if (!data.Valid || !_stateManager.GetOrCreate(id, data.Objects[0], out state))
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((hasModelId || state.ModelData.ModelId == 0) && state.CanUnlock(lockCode))
|
||||
{
|
||||
_stateManager.ApplyDesign(design, state, StateChanged.Source.Ipc, lockCode);
|
||||
state.Lock(lockCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,7 @@
|
|||
using System;
|
||||
using System.Buffers.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Customization;
|
||||
using Glamourer.Designs;
|
||||
using Glamourer.Structs;
|
||||
using Penumbra.Api.Helpers;
|
||||
using Penumbra.GameData.Actors;
|
||||
|
||||
namespace Glamourer.Api;
|
||||
|
||||
|
|
@ -28,7 +28,8 @@ public partial class GlamourerIpc : IDisposable
|
|||
private readonly DesignManager _designManager;
|
||||
|
||||
public GlamourerIpc(DalamudPluginInterface pi, StateManager stateManager, ObjectManager objects, ActorService actors,
|
||||
DesignConverter designConverter, StateChanged stateChangedEvent, GPoseService gPose, AutoDesignApplier autoDesignApplier, DesignManager designManager)
|
||||
DesignConverter designConverter, StateChanged stateChangedEvent, GPoseService gPose, AutoDesignApplier autoDesignApplier,
|
||||
DesignManager designManager)
|
||||
{
|
||||
_stateManager = stateManager;
|
||||
_objects = objects;
|
||||
|
|
@ -65,6 +66,9 @@ public partial class GlamourerIpc : IDisposable
|
|||
_applyOnlyCustomizationToCharacterProviderLock =
|
||||
new ActionProvider<string, Character?, uint>(pi, LabelApplyOnlyCustomizationToCharacterLock, ApplyOnlyCustomizationToCharacterLock);
|
||||
|
||||
_applyByGuidProvider = new ActionProvider<Guid, string>(pi, LabelApplyByGuid, ApplyByGuid);
|
||||
_applyByGuidToCharacterProvider = new ActionProvider<Guid, Character?>(pi, LabelApplyByGuidToCharacter, ApplyByGuidToCharacter);
|
||||
|
||||
_revertProvider = new ActionProvider<string>(pi, LabelRevert, Revert);
|
||||
_revertCharacterProvider = new ActionProvider<Character?>(pi, LabelRevertCharacter, RevertCharacter);
|
||||
_revertProviderLock = new ActionProvider<string, uint>(pi, LabelRevertLock, RevertLock);
|
||||
|
|
@ -81,9 +85,6 @@ public partial class GlamourerIpc : IDisposable
|
|||
_stateChangedEvent.Subscribe(OnStateChanged, StateChanged.Priority.GlamourerIpc);
|
||||
_gPose.Subscribe(OnGPoseChanged, GPoseService.Priority.GlamourerIpc);
|
||||
|
||||
_applyByGuidProvider = new ActionProvider<Guid, string>(pi, LabelApplyByGuid, ApplyByGuid);
|
||||
_applyByGuidToCharacterProvider = new ActionProvider<Guid, Character?>(pi, LabelApplyByGuidToCharacter, ApplyByGuidToCharacter);
|
||||
|
||||
_getDesignListProvider = new FuncProvider<(string Name, Guid Identifier)[]>(pi, LabelGetDesignList, GetDesignList);
|
||||
}
|
||||
|
||||
|
|
@ -107,6 +108,8 @@ public partial class GlamourerIpc : IDisposable
|
|||
_applyOnlyEquipmentToCharacterProviderLock.Dispose();
|
||||
_applyOnlyCustomizationProviderLock.Dispose();
|
||||
_applyOnlyCustomizationToCharacterProviderLock.Dispose();
|
||||
_applyByGuidProvider.Dispose();
|
||||
_applyByGuidToCharacterProvider.Dispose();
|
||||
|
||||
_revertProvider.Dispose();
|
||||
_revertCharacterProvider.Dispose();
|
||||
|
|
@ -122,8 +125,6 @@ public partial class GlamourerIpc : IDisposable
|
|||
_gPose.Unsubscribe(OnGPoseChanged);
|
||||
_gPoseChangedProvider.Dispose();
|
||||
|
||||
_applyByGuidProvider.Dispose();
|
||||
_applyByGuidToCharacterProvider.Dispose();
|
||||
_getDesignListProvider.Dispose();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue