Skip to content

Commit 57653e7

Browse files
committed
Update for Dawntrail
1 parent 64d4a77 commit 57653e7

File tree

6 files changed

+121
-155
lines changed

6 files changed

+121
-155
lines changed

Diff for: BDTHPlugin/BDTHPlugin.csproj

+8-33
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,25 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
22
<PropertyGroup>
3-
<Version>1.6.3</Version>
3+
<Version>1.6.4</Version>
44
<TargetFramework>net8.0-windows</TargetFramework>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<LangVersion>latest</LangVersion>
7-
<Platforms>x64</Platforms>
8-
<PlatformTarget>x64</PlatformTarget>
9-
<OutputType>Library</OutputType>
107
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
118
<PreserveCompilationContext>false</PreserveCompilationContext>
129
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1310
</PropertyGroup>
1411

1512
<PropertyGroup>
16-
<DalamudLibPath>$(AppData)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
13+
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
1714
</PropertyGroup>
1815

1916
<ItemGroup>
20-
<Reference Include="Dalamud">
21-
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
22-
<Private>False</Private>
23-
</Reference>
24-
<Reference Include="FFXIVClientStructs">
25-
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
26-
<Private>False</Private>
27-
</Reference>
28-
<Reference Include="ImGui.NET">
29-
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
30-
<Private>False</Private>
31-
</Reference>
32-
<Reference Include="ImGuiScene">
33-
<HintPath>$(DalamudLibPath)ImGuiScene.dll</HintPath>
34-
<Private>False</Private>
35-
</Reference>
36-
<Reference Include="Lumina">
37-
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
38-
<Private>False</Private>
39-
</Reference>
40-
<Reference Include="Lumina">
41-
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
42-
<Private>False</Private>
43-
</Reference>
44-
</ItemGroup>
45-
46-
<ItemGroup>
17+
<PackageReference Include="Dalamud.NET.Sdk" Version="9.0.2" />
4718
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
19+
<Reference Include="SharpDX">
20+
<HintPath>$(DalamudLibPath)SharpDX.dll</HintPath>
21+
<Private>false</Private>
22+
</Reference>
4823
</ItemGroup>
4924

5025
<ItemGroup>

Diff for: BDTHPlugin/BDTHPlugin.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"RepoUrl": "https://github.com/LeonBlade/BDTHPlugin",
99
"ApplicableVersion": "any",
1010
"Tags": ["bdth", "housing", "float", "place", "glitch", "furnishing", "LeonBlade"],
11-
"DalamudApiLevel": 9,
11+
"DalamudApiLevel": 10,
1212
"IconUrl": "https://github.com/LeonBlade/BDTHPlugin/raw/main/icon.png"
1313
}

Diff for: BDTHPlugin/Interface/Gizmo.cs

+47-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System.Numerics;
2-
2+
using Dalamud.Interface.Utility;
33
using ImGuiNET;
44
using ImGuizmoNET;
55

@@ -9,82 +9,101 @@ public class Gizmo
99
{
1010
private static PluginMemory Memory => Plugin.GetMemory();
1111
private static Configuration Configuration => Plugin.GetConfiguration();
12-
12+
1313
private static unsafe bool CanEdit => Configuration.UseGizmo && Memory.CanEditItem() && Memory.HousingStructure->ActiveItem != null;
14-
14+
1515
public MODE Mode = MODE.LOCAL;
1616

1717
private Vector3 translate;
1818
private Vector3 rotation;
1919
private Vector3 scale = Vector3.One;
20-
21-
private Matrix4x4 itemMatrix = Matrix4x4.Identity;
22-
20+
21+
private Matrix4x4 matrix = Matrix4x4.Identity;
22+
23+
private ImGuiIOPtr Io;
24+
private Vector2 Wp;
25+
2326
public void Draw()
2427
{
2528
if (!CanEdit)
2629
return;
27-
28-
var vp = ImGui.GetMainViewport();
29-
ImGui.SetNextWindowSize(vp.Size);
30-
ImGui.SetNextWindowPos(vp.Pos, ImGuiCond.Always);
31-
ImGui.SetNextWindowViewport(vp.ID);
32-
30+
31+
ImGuiHelpers.ForceNextWindowMainViewport();
32+
ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Vector2(0, 0));
33+
34+
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
35+
3336
const ImGuiWindowFlags windowFlags = ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.NoNavFocus | ImGuiWindowFlags.NoNavInputs | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoInputs;
3437
if (!ImGui.Begin("BDTHGizmo", windowFlags))
3538
return;
3639

40+
Io = ImGui.GetIO();
41+
ImGui.SetWindowSize(Io.DisplaySize);
42+
43+
Wp = ImGui.GetWindowPos();
44+
3745
try
3846
{
39-
DrawGizmo(vp.Pos, vp.Size);
47+
DrawGizmo(Wp, new Vector2(Io.DisplaySize.X, Io.DisplaySize.Y));
4048
}
4149
finally
4250
{
51+
ImGui.PopStyleVar();
4352
ImGui.End();
4453
}
4554
}
4655

4756
private unsafe void DrawGizmo(Vector2 pos, Vector2 size)
4857
{
49-
var projMatrix = Memory.Camera->RenderCamera->ProjectionMatrix;
50-
var viewMatrix = Memory.Camera->ViewMatrix;
51-
viewMatrix.M44 = 1.0f;
52-
58+
ImGuizmo.BeginFrame();
59+
60+
var proj = Memory.Camera->RenderCamera->ProjectionMatrix;
61+
var view = Memory.Camera->ViewMatrix;
62+
view.M44 = 1.0f;
63+
5364
ImGuizmo.SetDrawlist();
54-
65+
5566
ImGuizmo.Enable(Memory.HousingStructure->Rotating);
5667
ImGuizmo.SetID((int)ImGui.GetID("BDTHPlugin"));
5768
ImGuizmo.SetOrthographic(false);
58-
69+
5970
ImGuizmo.SetRect(pos.X, pos.Y, size.X, size.Y);
6071

6172
ComposeMatrix();
6273

63-
var drag = Configuration.Drag;
64-
var snap = Configuration.DoSnap ? new Vector3(drag, drag, drag) : Vector3.Zero;
65-
66-
var moved = Manipulate(ref viewMatrix.M11, ref projMatrix.M11, OPERATION.TRANSLATE, Mode, ref itemMatrix.M11, ref snap.X);
67-
if (moved) WriteMatrix();
74+
var snap = Configuration.DoSnap ? Configuration.Drag : 0;
75+
76+
if (Manipulate(
77+
ref view.M11,
78+
ref proj.M11,
79+
OPERATION.TRANSLATE,
80+
Mode,
81+
ref matrix.M11,
82+
ref snap
83+
))
84+
{
85+
WriteMatrix();
86+
}
6887

6988
ImGuizmo.SetID(-1);
7089
}
7190

7291
private void ComposeMatrix()
7392
{
74-
try {
93+
try
94+
{
7595
translate = Memory.ReadPosition();
7696
rotation = Memory.ReadRotation();
77-
ImGuizmo.RecomposeMatrixFromComponents(ref translate.X, ref rotation.X, ref scale.X, ref itemMatrix.M11);
97+
ImGuizmo.RecomposeMatrixFromComponents(ref translate.X, ref rotation.X, ref scale.X, ref matrix.M11);
7898
}
7999
catch
80100
{
81-
// ignored
82101
}
83102
}
84103

85104
private void WriteMatrix()
86105
{
87-
ImGuizmo.DecomposeMatrixToComponents(ref itemMatrix.M11, ref translate.X, ref rotation.X, ref scale.X);
106+
ImGuizmo.DecomposeMatrixToComponents(ref matrix.M11, ref translate.X, ref rotation.X, ref scale.X);
88107
Memory.WritePosition(translate);
89108
}
90109

Diff for: BDTHPlugin/Plugin.cs

+9-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
using System.Numerics;
1515

1616
using BDTHPlugin.Interface;
17+
using Dalamud.Interface.Textures;
1718

1819
namespace BDTHPlugin
1920
{
2021
public class Plugin : IDalamudPlugin
2122
{
2223
private const string commandName = "/bdth";
2324

24-
[PluginService] public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
25+
[PluginService] public static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
2526
[PluginService] public static IDataManager Data { get; private set; } = null!;
2627
[PluginService] public static ICommandManager CommandManager { get; private set; } = null!;
2728
[PluginService] public static IClientState ClientState { get; private set; } = null!;
@@ -38,14 +39,14 @@ public class Plugin : IDalamudPlugin
3839
private static PluginMemory Memory;
3940

4041
// Sheets used to get housing item info.
41-
private static Dictionary<uint, HousingFurniture> FurnitureDict;
42-
private static Dictionary<uint, HousingYardObject> YardObjectDict;
42+
private static Dictionary<uint, HousingFurniture> FurnitureDict = new();
43+
private static Dictionary<uint, HousingYardObject> YardObjectDict = new();
4344

4445
public Plugin()
4546
{
4647
Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
47-
Memory = new();
4848
Ui = new();
49+
Memory = new();
4950

5051
FurnitureDict = Data.GetExcelSheet<HousingFurniture>().ToDictionary(row => row.RowId, row => row);
5152
YardObjectDict = Data.GetExcelSheet<HousingYardObject>().ToDictionary(row => row.RowId, row => row);
@@ -120,15 +121,15 @@ public static void DrawIcon(ushort icon, Vector2 size)
120121
{
121122
if (icon < 65000)
122123
{
123-
var iconTexture = TextureProvider.GetIcon(icon);
124-
ImGui.Image(iconTexture.ImGuiHandle, size);
124+
var iconTexture = TextureProvider.GetFromGameIcon(new GameIconLookup(icon));
125+
ImGui.Image(iconTexture.GetWrapOrEmpty().ImGuiHandle, size);
125126
}
126127
}
127128

128129
public unsafe static bool IsOutdoors() => Memory.HousingModule->OutdoorTerritory != null;
129130

130-
public static bool TryGetFurnishing(uint id, out HousingFurniture furniture) => FurnitureDict.TryGetValue(id, out furniture);
131-
public static bool TryGetYardObject(uint id, out HousingYardObject furniture) => YardObjectDict.TryGetValue(id, out furniture);
131+
public static bool TryGetFurnishing(uint id, out HousingFurniture? furniture) => FurnitureDict.TryGetValue(id, out furniture);
132+
public static bool TryGetYardObject(uint id, out HousingYardObject? furniture) => YardObjectDict.TryGetValue(id, out furniture);
132133

133134
private unsafe void OnCommand(string command, string args)
134135
{

0 commit comments

Comments
 (0)