mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
add revert character customization
This commit is contained in:
parent
b78a6266b1
commit
6308a22c1a
1 changed files with 35 additions and 4 deletions
|
|
@ -10,10 +10,11 @@ namespace Glamourer.Api;
|
|||
|
||||
public class GlamourerIpc : IDisposable
|
||||
{
|
||||
public const int CurrentApiVersion = 0;
|
||||
public const string LabelProviderApiVersion = "Glamourer.ApiVersion";
|
||||
public const string LabelProviderGetCharacterCustomization = "Glamourer.GetCharacterCustomization";
|
||||
public const string LabelProviderApplyCharacterCustomization = "Glamourer.ApplyCharacterCustomization";
|
||||
public const int CurrentApiVersion = 0;
|
||||
public const string LabelProviderApiVersion = "Glamourer.ApiVersion";
|
||||
public const string LabelProviderGetCharacterCustomization = "Glamourer.GetCharacterCustomization";
|
||||
public const string LabelProviderApplyCharacterCustomization = "Glamourer.ApplyCharacterCustomization";
|
||||
public const string LabelProviderRevertCharacterCustomization = "Glamourer.RevertCharacterCustomization";
|
||||
|
||||
private readonly ClientState _clientState;
|
||||
private readonly ObjectTable _objectTable;
|
||||
|
|
@ -21,6 +22,7 @@ public class GlamourerIpc : IDisposable
|
|||
|
||||
internal ICallGateProvider<string>? ProviderGetCharacterCustomization;
|
||||
internal ICallGateProvider<string, string, object>? ProviderApplyCharacterCustomization;
|
||||
internal ICallGateProvider<string, object>? ProviderRevertCharacterCustomization;
|
||||
internal ICallGateProvider<int>? ProviderGetApiVersion;
|
||||
|
||||
public GlamourerIpc(ClientState clientState, ObjectTable objectTable, DalamudPluginInterface pluginInterface)
|
||||
|
|
@ -39,6 +41,7 @@ public class GlamourerIpc : IDisposable
|
|||
{
|
||||
ProviderApplyCharacterCustomization?.UnregisterFunc();
|
||||
ProviderGetCharacterCustomization?.UnregisterAction();
|
||||
ProviderRevertCharacterCustomization?.UnregisterAction();
|
||||
ProviderGetApiVersion?.UnregisterFunc();
|
||||
}
|
||||
|
||||
|
|
@ -74,6 +77,17 @@ public class GlamourerIpc : IDisposable
|
|||
{
|
||||
PluginLog.Error(ex, $"Error registering IPC provider for {LabelProviderApplyCharacterCustomization}.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ProviderRevertCharacterCustomization =
|
||||
_pluginInterface.GetIpcProvider<string, object>(LabelProviderRevertCharacterCustomization);
|
||||
ProviderRevertCharacterCustomization.RegisterAction(RevertCharacterCustomization);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PluginLog.Error(ex, $"Error registering IPC provider for {LabelProviderRevertCharacterCustomization}.");
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetApiVersion()
|
||||
|
|
@ -88,8 +102,25 @@ public class GlamourerIpc : IDisposable
|
|||
continue;
|
||||
|
||||
var player = (Character)gameObject;
|
||||
Glamourer.RevertableDesigns.Revert(player);
|
||||
Glamourer.RevertableDesigns.Add(player);
|
||||
save.Apply(player);
|
||||
Glamourer.Penumbra.UpdateCharacters(player, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void RevertCharacterCustomization(string characterName)
|
||||
{
|
||||
foreach (var gameObject in _objectTable)
|
||||
{
|
||||
if (gameObject.Name.ToString() != characterName)
|
||||
continue;
|
||||
|
||||
var player = (Character)gameObject;
|
||||
Glamourer.RevertableDesigns.Revert(player);
|
||||
Glamourer.Penumbra.UpdateCharacters(player, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue