Skip to content

Commit

Permalink
add exdsheets
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaksuhn committed Aug 23, 2024
1 parent 93f5413 commit 35e062c
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 32 deletions.
8 changes: 4 additions & 4 deletions SomethingNeedDoing/Interface/MacroWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ private void DrawHeader()
ImGui.SameLine();
if (ImGuiEx.IconButton(FontAwesomeIcon.FileImport, "Import macro from clipboard"))
{
var text = MiscHelpers.ConvertClipboardToSafeString();
var text = Utils.ConvertClipboardToSafeString();
var node = new MacroNode { Name = GetUniqueNodeName("Untitled macro") };
RootFolder.Children.Add(node);

if (MiscHelpers.IsLuaCode(text))
if (Utils.IsLuaCode(text))
node.Language = Language.Lua;

node.Contents = text;
Expand Down Expand Up @@ -449,9 +449,9 @@ private void DisplayMacroEdit()
ImGui.SetCursorPosX(ImGui.GetContentRegionMax().X - buttonSize.X - ImGui.GetStyle().WindowPadding.X);
if (ImGuiEx.IconButton(FontAwesomeIcon.FileImport, "Import from clipboard"))
{
var text = MiscHelpers.ConvertClipboardToSafeString();
var text = Utils.ConvertClipboardToSafeString();

if (MiscHelpers.IsLuaCode(text))
if (Utils.IsLuaCode(text))
node.Language = Language.Lua;

node.Contents = text;
Expand Down
6 changes: 3 additions & 3 deletions SomethingNeedDoing/Misc/Commands/CharacterStateCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public float GetPlayerRawXPos(string character = "")
{
if (int.TryParse(character, out var p))
{
var go = MiscHelpers.GetGameObjectFromPronounID((uint)(p + 42));
var go = Utils.GetGameObjectFromPronounID((uint)(p + 42));
return go != null ? go->Position.X : -1;
}
else return Svc.Objects.Where(x => x.IsTargetable).FirstOrDefault(x => x.Name.ToString().Equals(character))?.Position.X ?? -1;
Expand All @@ -109,7 +109,7 @@ public float GetPlayerRawYPos(string character = "")
{
if (int.TryParse(character, out var p))
{
var go = MiscHelpers.GetGameObjectFromPronounID((uint)(p + 42));
var go = Utils.GetGameObjectFromPronounID((uint)(p + 42));
return go != null ? go->Position.Y : -1;
}
else return Svc.Objects.Where(x => x.IsTargetable).FirstOrDefault(x => x.Name.ToString().Equals(character))?.Position.Y ?? -1;
Expand All @@ -126,7 +126,7 @@ public float GetPlayerRawZPos(string character = "")
{
if (int.TryParse(character, out var p))
{
var go = MiscHelpers.GetGameObjectFromPronounID((uint)(p + 42));
var go = Utils.GetGameObjectFromPronounID((uint)(p + 42));
return go != null ? go->Position.Z : -1;
}
else return Svc.Objects.Where(x => x.IsTargetable).FirstOrDefault(x => x.Name.ToString().Equals(character))?.Position.Z ?? -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using ECommons.Logging;
using Dalamud.Game;
using Dalamud.Utility;
using ECommons.Logging;
using ExdSheets;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using ImGuiNET;
Expand All @@ -7,7 +10,7 @@

namespace SomethingNeedDoing.Misc;

internal class MiscHelpers
internal class Utils
{
private static readonly unsafe nint pronounModule = (nint)Framework.Instance()->GetUIModule()->GetPronounModule();
private static readonly unsafe delegate* unmanaged<nint, uint, GameObject*> getGameObjectFromPronounID = (delegate* unmanaged<nint, uint, GameObject*>)Svc.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 8B D8 48 85 C0 0F 85 ?? ?? ?? ?? 8D 4F DD");
Expand Down Expand Up @@ -61,4 +64,22 @@ public static bool IsLuaCode(string code)

return false;
}

public static Sheet<T> GetSheet<T>(ClientLanguage? language = null) where T : struct, ISheetRow<T>
=> Service.Module.GetSheet<T>((language ?? Svc.ClientState.ClientLanguage).ToLumina());

public static int GetRowCount<T>() where T : struct, ISheetRow<T>
=> GetSheet<T>().Count;

public static T? GetRow<T>(uint rowId, ClientLanguage? language = null) where T : struct, ISheetRow<T>
=> GetSheet<T>(language).TryGetRow(rowId);

public static T? GetRow<T>(uint rowId, ushort subRowId, ClientLanguage? language = null) where T : struct, ISheetRow<T>
=> GetSheet<T>(language).TryGetRow(rowId, subRowId);

public static T? FindRow<T>(Func<T, bool> predicate) where T : struct, ISheetRow<T>
=> GetSheet<T>().FirstOrDefault(predicate);

public static T[] FindRows<T>(Func<T, bool> predicate) where T : struct, ISheetRow<T>
=> GetSheet<T>().Where(predicate).ToArray();
}
2 changes: 2 additions & 0 deletions SomethingNeedDoing/Service.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using ExdSheets;
using SomethingNeedDoing.Managers;

namespace SomethingNeedDoing;
Expand All @@ -9,4 +10,5 @@ internal class Service
internal static ChatManager ChatManager { get; set; } = null!;
internal static GameEventManager GameEventManager { get; set; } = null!;
internal static MacroManager MacroManager { get; set; } = null!;
internal static Module Module = new(Svc.Data.GameData);
}
9 changes: 5 additions & 4 deletions SomethingNeedDoing/SomethingNeedDoing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.10" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.10.0" />
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference Include="ExdSheets" Version="2.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.11.0" />
<PackageReference Include="NLua" Version="1.6.0" />
<Reference Include="Newtonsoft.Json">
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
Expand Down
60 changes: 41 additions & 19 deletions SomethingNeedDoing/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.10, )",
"resolved": "2.1.10",
"contentHash": "S6NrvvOnLgT4GDdgwuKVJjbFo+8ZEj+JsEYk9ojjOR/MMfv1dIFpT8aRJQfI24rtDcw1uF+GnSSMN4WW1yt7fw=="
"requested": "[2.1.13, )",
"resolved": "2.1.13",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
},
"ExdSheets": {
"type": "Direct",
"requested": "[2.1.0, )",
"resolved": "2.1.0",
"contentHash": "SfvLFyL8LYsW4AzPLFVfFwtKPl9xegGraIe9oFar3IlWW8Z4kf5dkM+1CiSr/J+PQt4xt2QZc/ydZ4ibs3RosA==",
"dependencies": {
"Lumina": "4.1.1"
}
},
"Microsoft.CodeAnalysis.Common": {
"type": "Direct",
"requested": "[4.10.0, )",
"resolved": "4.10.0",
"contentHash": "7O4+dn0fNKykPpEB1i8/5EKzwD3fuu/shdbbnnsBmdiHMaBz6telOubDFwPwLQQ/PvOAWTFIWWTyAOmWvXRD2g==",
"requested": "[4.11.0, )",
"resolved": "4.11.0",
"contentHash": "djf8ujmqYImFgB04UGtcsEhHrzVqzHowS+EEl/Yunc5LdrYrZhGBWUTXoCF0NzYXJxtfuD+UVQarWpvrNc94Qg==",
"dependencies": {
"Microsoft.CodeAnalysis.Analyzers": "3.3.4",
"System.Collections.Immutable": "8.0.0",
Expand All @@ -21,27 +30,27 @@
},
"Microsoft.CodeAnalysis.CSharp": {
"type": "Direct",
"requested": "[4.10.0, )",
"resolved": "4.10.0",
"contentHash": "iifqKy3KvCgPABHFbFlSxjEoE+OItZGuZ191NM/TWV750m1jMypr7BtrP65ET+OK2KNVupO8S8xCtxbNqw056A==",
"requested": "[4.11.0, )",
"resolved": "4.11.0",
"contentHash": "6XYi2EusI8JT4y2l/F3VVVS+ISoIX9nqHsZRaG6W5aFeJ5BEuBosHfT/ABb73FN0RZ1Z3cj2j7cL28SToJPXOw==",
"dependencies": {
"Microsoft.CodeAnalysis.Analyzers": "3.3.4",
"Microsoft.CodeAnalysis.Common": "[4.10.0]",
"Microsoft.CodeAnalysis.Common": "[4.11.0]",
"System.Collections.Immutable": "8.0.0",
"System.Reflection.Metadata": "8.0.0"
}
},
"Microsoft.CodeAnalysis.CSharp.Scripting": {
"type": "Direct",
"requested": "[4.10.0, )",
"resolved": "4.10.0",
"contentHash": "B8QflImoUzHSAoSF3bkvX7HmVs1H3KWg5joP3aNl+MNByKhqZsOi1//YUt6ALl9HvO8byB6Z0OC2yaTUpfD0tw==",
"requested": "[4.11.0, )",
"resolved": "4.11.0",
"contentHash": "sNeVeHfGHEPtxYGQIP+0BSTSBuv+dkWP5HEc1FstJpyYlibqKOmFm3y2j1AwEx9sKoRTs01092yrTH9BwZsxFQ==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"Microsoft.CodeAnalysis.Analyzers": "3.3.4",
"Microsoft.CodeAnalysis.CSharp": "[4.10.0]",
"Microsoft.CodeAnalysis.Common": "[4.10.0]",
"Microsoft.CodeAnalysis.Scripting.Common": "[4.10.0]",
"Microsoft.CodeAnalysis.CSharp": "[4.11.0]",
"Microsoft.CodeAnalysis.Common": "[4.11.0]",
"Microsoft.CodeAnalysis.Scripting.Common": "[4.11.0]",
"System.Collections.Immutable": "8.0.0",
"System.Reflection.Metadata": "8.0.0"
}
Expand All @@ -60,18 +69,26 @@
"resolved": "1.3.1",
"contentHash": "DSZkJx3+9YmJONylrJY2xvjmBBT6oPZO1Iv+MBZh4Ta8KsYewKmpp5n+yW2J5vkIxkJ1yxiQuHE+iKw25Kw6GA=="
},
"Lumina": {
"type": "Transitive",
"resolved": "4.1.1",
"contentHash": "Hd+iTtdaPACTpViXaJ/+sQ3ZQ8MEpApCSD+mxTXnUTYDSZOAipuC4LsZqhAkLMeQHSK/R/jiXEXaXS7e0mTXyA==",
"dependencies": {
"Microsoft.Extensions.ObjectPool": "9.0.0-preview.1.24081.5"
}
},
"Microsoft.CodeAnalysis.Analyzers": {
"type": "Transitive",
"resolved": "3.3.4",
"contentHash": "AxkxcPR+rheX0SmvpLVIGLhOUXAKG56a64kV9VQZ4y9gR9ZmPXnqZvHJnmwLSwzrEP6junUF11vuc+aqo5r68g=="
},
"Microsoft.CodeAnalysis.Scripting.Common": {
"type": "Transitive",
"resolved": "4.10.0",
"contentHash": "L+IbItJyxtLcbSxRXvdJRCGMW9IgHXZvNl5VcuFMcb49nFnhqrm79y50GOukSyBccF0WlnalbjRK/Beb2aKJbw==",
"resolved": "4.11.0",
"contentHash": "UHZIAKQcLB00N7AvMoyEYLw8qvFmGcKffEm/M2dEqYz2TWUtQW2j0+nGglbt9VwOId6TrDZGQlGjX90VNFak/w==",
"dependencies": {
"Microsoft.CodeAnalysis.Analyzers": "3.3.4",
"Microsoft.CodeAnalysis.Common": "[4.10.0]",
"Microsoft.CodeAnalysis.Common": "[4.11.0]",
"System.Collections.Immutable": "8.0.0",
"System.Reflection.Metadata": "8.0.0"
}
Expand All @@ -81,6 +98,11 @@
"resolved": "4.7.0",
"contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA=="
},
"Microsoft.Extensions.ObjectPool": {
"type": "Transitive",
"resolved": "9.0.0-preview.1.24081.5",
"contentHash": "aAR7YW+pUUdvHk3vj7GtAi71dWGDIuY9270lsmQ6lKw23zzY+r8pLP3cGNbJdlnA9VWl+S+gnIVkBCqj2ROlEg=="
},
"System.Collections.Immutable": {
"type": "Transitive",
"resolved": "8.0.0",
Expand Down

0 comments on commit 35e062c

Please sign in to comment.