Skip to content

Commit

Permalink
Update for new api
Browse files Browse the repository at this point in the history
  • Loading branch information
Limiana committed Jun 1, 2024
1 parent 2b081b9 commit cc2faf4
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 84 deletions.
20 changes: 20 additions & 0 deletions DynamicBridge.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ECommons", "ECommons\ECommo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OtterGui", "OtterGui\OtterGui.csproj", "{A924F32A-B518-41BF-83A8-E3D9B8EBED9A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Glamourer.Api", "Glamourer.Api\Glamourer.Api.csproj", "{A276E081-CD2F-479E-91A0-8F2A76F93BD6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.Api", "Penumbra.Api\Penumbra.Api.csproj", "{087C5947-318B-492C-B9E2-6B3DAC29C870}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -41,6 +45,22 @@ Global
{A924F32A-B518-41BF-83A8-E3D9B8EBED9A}.Release|Any CPU.Build.0 = Release|Any CPU
{A924F32A-B518-41BF-83A8-E3D9B8EBED9A}.Release|x64.ActiveCfg = Release|Any CPU
{A924F32A-B518-41BF-83A8-E3D9B8EBED9A}.Release|x64.Build.0 = Release|Any CPU
{A276E081-CD2F-479E-91A0-8F2A76F93BD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A276E081-CD2F-479E-91A0-8F2A76F93BD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A276E081-CD2F-479E-91A0-8F2A76F93BD6}.Debug|x64.ActiveCfg = Debug|Any CPU
{A276E081-CD2F-479E-91A0-8F2A76F93BD6}.Debug|x64.Build.0 = Debug|Any CPU
{A276E081-CD2F-479E-91A0-8F2A76F93BD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A276E081-CD2F-479E-91A0-8F2A76F93BD6}.Release|Any CPU.Build.0 = Release|Any CPU
{A276E081-CD2F-479E-91A0-8F2A76F93BD6}.Release|x64.ActiveCfg = Release|Any CPU
{A276E081-CD2F-479E-91A0-8F2A76F93BD6}.Release|x64.Build.0 = Release|Any CPU
{087C5947-318B-492C-B9E2-6B3DAC29C870}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{087C5947-318B-492C-B9E2-6B3DAC29C870}.Debug|Any CPU.Build.0 = Debug|Any CPU
{087C5947-318B-492C-B9E2-6B3DAC29C870}.Debug|x64.ActiveCfg = Debug|Any CPU
{087C5947-318B-492C-B9E2-6B3DAC29C870}.Debug|x64.Build.0 = Debug|Any CPU
{087C5947-318B-492C-B9E2-6B3DAC29C870}.Release|Any CPU.ActiveCfg = Release|Any CPU
{087C5947-318B-492C-B9E2-6B3DAC29C870}.Release|Any CPU.Build.0 = Release|Any CPU
{087C5947-318B-492C-B9E2-6B3DAC29C870}.Release|x64.ActiveCfg = Release|Any CPU
{087C5947-318B-492C-B9E2-6B3DAC29C870}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions DynamicBridge/DynamicBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using DynamicBridge.IPC.Moodles;
using DynamicBridge.IPC.Penumbra;
using ECommons.Automation;
using ECommons.Automation.LegacyTaskManager;
using ECommons.ChatMethods;
using ECommons.Configuration;
using ECommons.Events;
Expand Down
4 changes: 3 additions & 1 deletion DynamicBridge/DynamicBridge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>NightmareXIV</Authors>
<Version>1.0.5.8</Version>
<Version>1.0.5.9</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -34,7 +34,9 @@

<ItemGroup>
<ProjectReference Include="..\ECommons\ECommons\ECommons.csproj" />
<ProjectReference Include="..\Glamourer.Api\Glamourer.Api.csproj" />
<ProjectReference Include="..\OtterGui\OtterGui.csproj" />
<ProjectReference Include="..\Penumbra.Api\Penumbra.Api.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions DynamicBridge/Gui/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static unsafe class Debug

public static void Draw()
{
if(ImGui.CollapsingHeader("IPC Tester"))
if (ImGui.CollapsingHeader("IPC Tester"))
{
if (ImGui.Button("Register AnyException"))
{
Expand Down Expand Up @@ -167,7 +167,7 @@ public static void Draw()
if (ImGui.SmallButton($"Remove##{x.ID}")) P.MoodlesManager.RemovePreset(x.ID);
}
}
if (ImGui.CollapsingHeader("Penumbra"))
/*if (ImGui.CollapsingHeader("Penumbra"))
{
ImGuiEx.Text(EColor.Green, $"Current: {P.PenumbraManager.GetCollectionForType(PenumbraManager.ApiCollectionType.Yourself) ?? "(null)"}");
foreach(var x in P.PenumbraManager.GetCollections())
Expand All @@ -178,7 +178,7 @@ public static void Draw()
DuoLog.Information($"Error: {ret.Error}, old: {ret.OldCollection}");
}
}
}
}*/
/*if(ImGui.CollapsingHeader("Pathes"))
{
foreach(var x in Utils.GetCombinedPathes())
Expand Down
2 changes: 1 addition & 1 deletion DynamicBridge/Gui/GuiPresets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ void FiltersSelection()
if (preset.PenumbraType == SpecialPenumbraAssignment.Use_Named_Collection)
{
FiltersSelection();
var collections = P.PenumbraManager.GetCollections().Order();
var collections = P.PenumbraManager.GetCollectionNames().Order();
var index = 0;
List<(string[], Action)> items = [];
foreach (var x in collections)
Expand Down
4 changes: 2 additions & 2 deletions DynamicBridge/Gui/GuiSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void Draw()
//glam

ImGui.Checkbox("Glamourer", ref C.EnableGlamourer);
DrawPluginCheck("Glamourer", "1.2.0.2");
DrawPluginCheck("Glamourer", "1.2.2.2");
ImGuiEx.Spacing();
ImGuiEx.TextV($"DynamicBridge behavior when no Glamourer rule is found:");
ImGui.SameLine();
Expand Down Expand Up @@ -141,7 +141,7 @@ public static void Draw()

//penumbra
ImGui.Checkbox("Penumbra", ref C.EnablePenumbra);
DrawPluginCheck("Penumbra", "1.0.0.4");
DrawPluginCheck("Penumbra", "1.0.1.0");

//moodles
ImGui.Checkbox("Moodles", ref C.EnableMoodles);
Expand Down
5 changes: 3 additions & 2 deletions DynamicBridge/Gui/UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using DynamicBridge.IPC.Glamourer;
using ECommons;
using ECommons.Configuration;
using ECommons.Funding;
using ECommons.GameHelpers;
using ECommons.Reflection;
using ECommons.SimpleGui;
Expand Down Expand Up @@ -39,8 +40,8 @@ public static void DrawMain()
foreach (var x in Svc.Data.GetExcelSheet<Weather>()) ThreadLoadImageHandler.TryGetIconTextureWrap((uint)x.Icon, false, out _);
foreach (var x in Svc.Data.GetExcelSheet<Emote>()) ThreadLoadImageHandler.TryGetIconTextureWrap(x.Icon, false, out _);
}
KoFiButton.DrawRight();
ImGuiEx.EzTabBar("TabsNR2", true, RequestTab, [
PatreonBanner.DrawRight();
ImGuiEx.EzTabBar("TabsNR2", PatreonBanner.Text, RequestTab, ImGuiTabBarFlags.Reorderable, [
//("Settings", Settings, null, true),
(C.ShowTutorial?"Tutorial":null, GuiTutorial.Draw, null, true),
("Dynamic Rules", GuiRules.Draw, Colors.TabGreen, true),
Expand Down
45 changes: 22 additions & 23 deletions DynamicBridge/IPC/Glamourer/GlamourerManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Dalamud.Game.ClientState.Objects.Types;
using DynamicBridge.Configuration;
using DynamicBridge.Configuration;
using ECommons.EzIpcManager;
using ECommons.GameHelpers;
using Glamourer.Api.IpcSubscribers;

namespace DynamicBridge.IPC.Glamourer;

Expand All @@ -10,20 +9,14 @@ public unsafe class GlamourerManager
public GlamourerReflector Reflector;
public GlamourerCommands Commands;

[EzIPC] Func<Character, string> GetAllCustomizationFromCharacter;
[EzIPC] Action<string, Character> ApplyAllOnceToCharacter;
[EzIPC] Action<Character> RevertCharacter;
[EzIPC] Action<Guid, Character> ApplyByGuidOnceToCharacter;
[EzIPC] Func<GlamourerDesignInfo[]> GetDesignList;

public GlamourerManager()
{
EzIPC.Init(this, "Glamourer");
Reflector = new();
Commands = new();
}

List<PathInfo> PathInfos = null;
private List<PathInfo> PathInfos = null;
public List<PathInfo> GetCombinedPathes()
{
PathInfos ??= Utils.BuildPathes(GetRawPathes());
Expand All @@ -35,23 +28,26 @@ public void RevertToAutomation()
Commands.RevertToAutomation();
}

private ApplyDesign ApplyDesign = new(Svc.PluginInterface);
public void ApplyByGuid(Guid guid)
{
try
{
ApplyByGuidOnceToCharacter(guid, Player.Object);
ApplyDesign.Invoke(guid, 0);
}
catch (Exception ex)
{
ex.Log();
}
}

GlamourerDesignInfo[] GetDesignListIPC()
private GetDesignList GetDesignList = new(Svc.PluginInterface);

private GlamourerDesignInfo[] GetDesignListIPC()
{
try
{
return GetDesignList();
return GetDesignList.Invoke().Select(x => (x.Value, x.Key)).ToArray();
}
catch (Exception ex)
{
Expand All @@ -60,11 +56,12 @@ GlamourerDesignInfo[] GetDesignListIPC()
return [];
}

private GetStateBase64 GetStateBase64 = new(Svc.PluginInterface);
public string GetMyCustomization()
{
try
{
return GetAllCustomizationFromCharacter(Player.Object);
return GetStateBase64.Invoke(0).Item2;
}
catch (Exception e)
{
Expand All @@ -73,11 +70,12 @@ public string GetMyCustomization()
}
}

private ApplyState ApplyState = new(Svc.PluginInterface);
public void SetMyCustomization(string customization)
{
try
{
ApplyAllOnceToCharacter(customization, Player.Object);
ApplyState.Invoke(customization, 0);
}
catch (Exception e)
{
Expand All @@ -98,11 +96,12 @@ public void ApplyToSelf(GlamourerDesignInfo design)
}
}

private RevertState RevertState = new(Svc.PluginInterface);
public void Revert()
{
try
{
RevertCharacter(Player.Object);
RevertState.Invoke(0);
}
catch (Exception e)
{
Expand All @@ -111,8 +110,8 @@ public void Revert()
}
}

GlamourerDesignInfo[] CachedDesignInfo = [];
ulong ValidCacheFrame = 0;
private GlamourerDesignInfo[] CachedDesignInfo = [];
private ulong ValidCacheFrame = 0;
public GlamourerDesignInfo[] GetDesigns()
{
var fc = CSFramework.Instance()->FrameCounter;
Expand All @@ -124,14 +123,14 @@ public GlamourerDesignInfo[] GetDesigns()
return CachedDesignInfo;
}

Dictionary<string, string> TransformNameCache = [];
private Dictionary<string, string> TransformNameCache = [];
public string TransformName(string originalName)
{
if(TransformNameCache.TryGetValue(originalName, out var ret))
if (TransformNameCache.TryGetValue(originalName, out var ret))
{
return ret;
}
if (Guid.TryParse(originalName, out Guid guid))
if (Guid.TryParse(originalName, out var guid))
{
if (GetDesigns().TryGetFirst(x => x.Identifier == guid, out var entry))
{
Expand Down Expand Up @@ -165,14 +164,14 @@ public List<string> GetRawPathes()
}
}
}
catch(Exception e)
catch (Exception e)
{
e.LogInternal();
}
return ret;
}

public void ResetCache()
public void ResetCache()
{
TransformNameCache.Clear();
PathInfos = null;
Expand Down
1 change: 1 addition & 0 deletions DynamicBridge/IPC/Glamourer/GlamourerReflector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public bool GetAutomationGlobalState()
}
return false;
}

public void SetAutomationGlobalState(bool state)
{
try
Expand Down
Loading

0 comments on commit cc2faf4

Please sign in to comment.