mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-14 04:34:19 +01:00
add revert character customization
This commit is contained in:
parent
b78a6266b1
commit
6308a22c1a
1 changed files with 35 additions and 4 deletions
|
|
@ -14,6 +14,7 @@ public class GlamourerIpc : IDisposable
|
||||||
public const string LabelProviderApiVersion = "Glamourer.ApiVersion";
|
public const string LabelProviderApiVersion = "Glamourer.ApiVersion";
|
||||||
public const string LabelProviderGetCharacterCustomization = "Glamourer.GetCharacterCustomization";
|
public const string LabelProviderGetCharacterCustomization = "Glamourer.GetCharacterCustomization";
|
||||||
public const string LabelProviderApplyCharacterCustomization = "Glamourer.ApplyCharacterCustomization";
|
public const string LabelProviderApplyCharacterCustomization = "Glamourer.ApplyCharacterCustomization";
|
||||||
|
public const string LabelProviderRevertCharacterCustomization = "Glamourer.RevertCharacterCustomization";
|
||||||
|
|
||||||
private readonly ClientState _clientState;
|
private readonly ClientState _clientState;
|
||||||
private readonly ObjectTable _objectTable;
|
private readonly ObjectTable _objectTable;
|
||||||
|
|
@ -21,6 +22,7 @@ public class GlamourerIpc : IDisposable
|
||||||
|
|
||||||
internal ICallGateProvider<string>? ProviderGetCharacterCustomization;
|
internal ICallGateProvider<string>? ProviderGetCharacterCustomization;
|
||||||
internal ICallGateProvider<string, string, object>? ProviderApplyCharacterCustomization;
|
internal ICallGateProvider<string, string, object>? ProviderApplyCharacterCustomization;
|
||||||
|
internal ICallGateProvider<string, object>? ProviderRevertCharacterCustomization;
|
||||||
internal ICallGateProvider<int>? ProviderGetApiVersion;
|
internal ICallGateProvider<int>? ProviderGetApiVersion;
|
||||||
|
|
||||||
public GlamourerIpc(ClientState clientState, ObjectTable objectTable, DalamudPluginInterface pluginInterface)
|
public GlamourerIpc(ClientState clientState, ObjectTable objectTable, DalamudPluginInterface pluginInterface)
|
||||||
|
|
@ -39,6 +41,7 @@ public class GlamourerIpc : IDisposable
|
||||||
{
|
{
|
||||||
ProviderApplyCharacterCustomization?.UnregisterFunc();
|
ProviderApplyCharacterCustomization?.UnregisterFunc();
|
||||||
ProviderGetCharacterCustomization?.UnregisterAction();
|
ProviderGetCharacterCustomization?.UnregisterAction();
|
||||||
|
ProviderRevertCharacterCustomization?.UnregisterAction();
|
||||||
ProviderGetApiVersion?.UnregisterFunc();
|
ProviderGetApiVersion?.UnregisterFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,6 +77,17 @@ public class GlamourerIpc : IDisposable
|
||||||
{
|
{
|
||||||
PluginLog.Error(ex, $"Error registering IPC provider for {LabelProviderApplyCharacterCustomization}.");
|
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()
|
private static int GetApiVersion()
|
||||||
|
|
@ -88,8 +102,25 @@ public class GlamourerIpc : IDisposable
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var player = (Character)gameObject;
|
var player = (Character)gameObject;
|
||||||
|
Glamourer.RevertableDesigns.Revert(player);
|
||||||
|
Glamourer.RevertableDesigns.Add(player);
|
||||||
save.Apply(player);
|
save.Apply(player);
|
||||||
Glamourer.Penumbra.UpdateCharacters(player, null);
|
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