mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Little bit of cleanup and style application
This commit is contained in:
parent
45f9b2cf8d
commit
b78a6266b1
1 changed files with 78 additions and 77 deletions
|
|
@ -6,16 +6,18 @@ using Dalamud.Plugin;
|
||||||
using Dalamud.Plugin.Ipc;
|
using Dalamud.Plugin.Ipc;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Glamourer.Api
|
namespace Glamourer.Api;
|
||||||
|
|
||||||
|
public class GlamourerIpc : IDisposable
|
||||||
{
|
{
|
||||||
public class GlamourerIpc : IDisposable
|
public const int CurrentApiVersion = 0;
|
||||||
{
|
|
||||||
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";
|
||||||
private readonly ClientState clientState;
|
|
||||||
private readonly ObjectTable objectTable;
|
private readonly ClientState _clientState;
|
||||||
private readonly DalamudPluginInterface pluginInterface;
|
private readonly ObjectTable _objectTable;
|
||||||
|
private readonly DalamudPluginInterface _pluginInterface;
|
||||||
|
|
||||||
internal ICallGateProvider<string>? ProviderGetCharacterCustomization;
|
internal ICallGateProvider<string>? ProviderGetCharacterCustomization;
|
||||||
internal ICallGateProvider<string, string, object>? ProviderApplyCharacterCustomization;
|
internal ICallGateProvider<string, string, object>? ProviderApplyCharacterCustomization;
|
||||||
|
|
@ -23,17 +25,15 @@ namespace Glamourer.Api
|
||||||
|
|
||||||
public GlamourerIpc(ClientState clientState, ObjectTable objectTable, DalamudPluginInterface pluginInterface)
|
public GlamourerIpc(ClientState clientState, ObjectTable objectTable, DalamudPluginInterface pluginInterface)
|
||||||
{
|
{
|
||||||
this.clientState = clientState;
|
_clientState = clientState;
|
||||||
this.objectTable = objectTable;
|
_objectTable = objectTable;
|
||||||
this.pluginInterface = pluginInterface;
|
_pluginInterface = pluginInterface;
|
||||||
|
|
||||||
InitializeProviders();
|
InitializeProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
=> DisposeProviders();
|
||||||
DisposeProviders();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DisposeProviders()
|
private void DisposeProviders()
|
||||||
{
|
{
|
||||||
|
|
@ -46,7 +46,7 @@ namespace Glamourer.Api
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderGetApiVersion = pluginInterface.GetIpcProvider<int>(LabelProviderApiVersion);
|
ProviderGetApiVersion = _pluginInterface.GetIpcProvider<int>(LabelProviderApiVersion);
|
||||||
ProviderGetApiVersion.RegisterFunc(GetApiVersion);
|
ProviderGetApiVersion.RegisterFunc(GetApiVersion);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Glamourer.Api
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderGetCharacterCustomization = pluginInterface.GetIpcProvider<string>(LabelProviderGetCharacterCustomization);
|
ProviderGetCharacterCustomization = _pluginInterface.GetIpcProvider<string>(LabelProviderGetCharacterCustomization);
|
||||||
ProviderGetCharacterCustomization.RegisterFunc(GetCharacterCustomization);
|
ProviderGetCharacterCustomization.RegisterFunc(GetCharacterCustomization);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -66,8 +66,9 @@ namespace Glamourer.Api
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderApplyCharacterCustomization = pluginInterface.GetIpcProvider<string, string, object>(LabelProviderApplyCharacterCustomization);
|
ProviderApplyCharacterCustomization =
|
||||||
ProviderApplyCharacterCustomization.RegisterAction((customization, characterName) => ApplyCharacterCustomization(customization, characterName));
|
_pluginInterface.GetIpcProvider<string, string, object>(LabelProviderApplyCharacterCustomization);
|
||||||
|
ProviderApplyCharacterCustomization.RegisterAction(ApplyCharacterCustomization);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -75,27 +76,27 @@ namespace Glamourer.Api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetApiVersion() => 0;
|
private static int GetApiVersion()
|
||||||
|
=> CurrentApiVersion;
|
||||||
|
|
||||||
private void ApplyCharacterCustomization(string customization, string characterName)
|
private void ApplyCharacterCustomization(string customization, string characterName)
|
||||||
{
|
{
|
||||||
var save = CharacterSave.FromString(customization);
|
var save = CharacterSave.FromString(customization);
|
||||||
foreach (var gameObject in objectTable)
|
foreach (var gameObject in _objectTable)
|
||||||
{
|
|
||||||
if (gameObject.Name.ToString() == characterName)
|
|
||||||
{
|
{
|
||||||
|
if (gameObject.Name.ToString() != characterName)
|
||||||
|
continue;
|
||||||
|
|
||||||
var player = (Character)gameObject;
|
var player = (Character)gameObject;
|
||||||
save.Apply(player);
|
save.Apply(player);
|
||||||
Glamourer.Penumbra.UpdateCharacters(player, null);
|
Glamourer.Penumbra.UpdateCharacters(player, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private string GetCharacterCustomization()
|
private string GetCharacterCustomization()
|
||||||
{
|
{
|
||||||
CharacterSave save = new CharacterSave();
|
var save = new CharacterSave();
|
||||||
save.LoadCharacter(clientState.LocalPlayer!);
|
save.LoadCharacter(_clientState.LocalPlayer!);
|
||||||
return save.ToBase64();
|
return save.ToBase64();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue