refactor: update for api 10

This commit is contained in:
Anna 2024-07-01 00:38:58 -04:00
parent 72f675c5f7
commit 52ac341c93
Signed by: anna
GPG Key ID: D0943384CD9F87D1
7 changed files with 100 additions and 33 deletions

View File

@ -1,4 +1,4 @@
using XivCommon.Functions.Housing;
using OrangeGuidanceTomestone.Util;
namespace OrangeGuidanceTomestone;

View File

@ -5,6 +5,7 @@ using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets;
using Newtonsoft.Json;
using OrangeGuidanceTomestone.Helpers;
using OrangeGuidanceTomestone.Util;
namespace OrangeGuidanceTomestone;
@ -178,7 +179,7 @@ internal class Messages : IDisposable {
return;
}
var housing = this.Plugin.Common.Functions.Housing.Location;
var housing = HousingLocation.Current();
var ward = housing?.Ward;
var plot = housing?.CombinedPlot();

View File

@ -54,10 +54,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12"/>
<PackageReference Include="Fody" Version="6.8.0" PrivateAssets="all"/>
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference Include="Fody" Version="6.8.1" PrivateAssets="all" />
<PackageReference Include="Resourcer.Fody" Version="1.8.1" PrivateAssets="all"/>
<PackageReference Include="XivCommon" Version="9.0.0" PrivateAssets="all"/>
</ItemGroup>
<ItemGroup>

View File

@ -2,7 +2,6 @@
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using OrangeGuidanceTomestone.MiniPenumbra;
using XivCommon;
namespace OrangeGuidanceTomestone;
@ -13,7 +12,7 @@ public class Plugin : IDalamudPlugin {
internal static IPluginLog Log { get; private set; }
[PluginService]
internal DalamudPluginInterface Interface { get; init; }
internal IDalamudPluginInterface Interface { get; init; }
[PluginService]
internal IChatGui ChatGui { get; init; }
@ -39,8 +38,10 @@ public class Plugin : IDalamudPlugin {
[PluginService]
internal IGameInteropProvider GameInteropProvider { get; init; }
[PluginService]
internal ITextureProvider TextureProvider { get; init; }
internal Configuration Config { get; }
internal XivCommonBase Common { get; }
internal Vfx Vfx { get; }
internal PluginUi Ui { get; }
internal Messages Messages { get; }
@ -54,7 +55,6 @@ public class Plugin : IDalamudPlugin {
this.AvfxFilePath = this.CopyAvfxFile();
this.Config = this.Interface!.GetPluginConfig() as Configuration ?? new Configuration();
this.Common = new XivCommonBase(this.Interface);
this.Vfx = new Vfx(this);
this.Messages = new Messages(this);
this.Ui = new PluginUi(this);
@ -74,7 +74,6 @@ public class Plugin : IDalamudPlugin {
this.Ui.Dispose();
this.Messages.Dispose();
this.Vfx.Dispose();
this.Common.Dispose();
}
internal void SaveConfig() {
@ -96,7 +95,7 @@ public class Plugin : IDalamudPlugin {
internal void GetApiKey() {
Task.Run(async () => {
var resp = await new HttpClient().PostAsync("https://tryfingerbuthole.anna.lgbt/account", null);
var resp = await new HttpClient().PostAsync("http://192.168.174.246:8080/account", null);
var key = await resp.Content.ReadAsStringAsync();
this.Config.ApiKey = key;
this.SaveConfig();

View File

@ -1,7 +1,7 @@
using System.Numerics;
using System.Text;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures.TextureWraps;
using ImGuiNET;
using Newtonsoft.Json;
using OrangeGuidanceTomestone.Helpers;
@ -58,13 +58,15 @@ internal class Write : ITab {
private List<IDalamudTextureWrap> GlyphImages { get; } = [];
private void LoadSignImages() {
for (var i = 0; i < Messages.VfxPaths.Length; i++) {
var stream = Resourcer.Resource.AsStreamUnChecked($"OrangeGuidanceTomestone.img.sign_{i}.jpg");
using var mem = new MemoryStream();
stream.CopyTo(mem);
var wrap = this.Plugin.Interface.UiBuilder.LoadImage(mem.ToArray());
this.GlyphImages.Add(wrap);
}
Task.Run(async () => {
for (var i = 0; i < Messages.VfxPaths.Length; i++) {
var stream = Resourcer.Resource.AsStreamUnChecked($"OrangeGuidanceTomestone.img.sign_{i}.jpg");
using var mem = new MemoryStream();
await stream.CopyToAsync(mem);
var wrap = await this.Plugin.TextureProvider.CreateFromImageAsync(mem.ToArray());
this.GlyphImages.Add(wrap);
}
});
}
internal Write(Plugin plugin) {
@ -310,11 +312,12 @@ internal class Write : ITab {
|| this.Plugin.Condition[ConditionFlag.Jumping61]
|| this.Plugin.Condition[ConditionFlag.InFlight];
if (ImGui.Button("Write") && valid && !inAir && this.Plugin.ClientState.LocalPlayer is { } player) {
var location = HousingLocation.Current();
var req = new MessageRequest {
Territory = this.Plugin.ClientState.TerritoryType,
World = this.Plugin.ClientState.LocalPlayer?.CurrentWorld.Id ?? 0,
Ward = this.Plugin.Common.Functions.Housing.Location?.Ward,
Plot = this.Plugin.Common.Functions.Housing.Location?.CombinedPlot(),
Ward = location?.Ward,
Plot = location?.CombinedPlot(),
X = player.Position.X,
Y = player.Position.Y,
Z = player.Position.Z,

71
client/Util/HousingLocation.cs Executable file
View File

@ -0,0 +1,71 @@
using FFXIVClientStructs.FFXIV.Client.Game;
namespace OrangeGuidanceTomestone.Util;
/// <summary>
/// Information about a player's current location in a housing ward.
/// </summary>
public class HousingLocation {
/// <summary>
/// The housing ward that the player is in.
/// </summary>
public ushort? Ward;
/// <summary>
/// <para>
/// The yard that the player is in.
/// </para>
/// <para>
/// This is the same as plot number but indicates that the player is in
/// the exterior area (the yard) of that plot.
/// </para>
/// </summary>
public ushort? Yard;
/// <summary>
/// The plot that the player is in.
/// </summary>
public ushort? Plot;
/// <summary>
/// The apartment wing (1 or 2 for normal or subdivision) that the
/// player is in.
/// </summary>
public ushort? ApartmentWing;
/// <summary>
/// The apartment that the player is in.
/// </summary>
public ushort? Apartment;
internal static unsafe HousingLocation? Current() {
var manager = HousingManager.Instance();
return manager == null ? null : new HousingLocation(manager);
}
private unsafe HousingLocation(HousingManager* manager) {
var ward = manager->GetCurrentWard();
var currentPlot = manager->GetCurrentPlot();
if (currentPlot < -1) {
// the struct is in apartment mode
this.ApartmentWing = (ushort?) ((unchecked((byte) currentPlot) & ~0x80) + 1);
this.Apartment = (ushort) manager->GetCurrentRoom();
if (this.Apartment == 0) {
this.Apartment = null;
}
} else if (currentPlot > 0) {
if (manager->GetCurrentHouseId() == -1) {
// not inside a plot
// yard is 0xFF when not in one
this.Yard = (ushort?) (currentPlot + 1);
} else {
// inside a plot
this.Plot = (ushort?) (currentPlot + 1);
}
}
if (ward > -1) {
this.Ward = (ushort) (ward + 1);
}
}
}

18
client/packages.lock.json Normal file → Executable file
View File

@ -4,15 +4,15 @@
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.12, )",
"resolved": "2.1.12",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
"requested": "[2.1.13, )",
"resolved": "2.1.13",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
},
"Fody": {
"type": "Direct",
"requested": "[6.8.0, )",
"resolved": "6.8.0",
"contentHash": "hfZ/f8Mezt8aTkgv9nsvFdYoQ809/AqwsJlOGOPYIfBcG2aAIG3v3ex9d8ZqQuFYyMoucjRg4eKy3VleeGodKQ=="
"requested": "[6.8.1, )",
"resolved": "6.8.1",
"contentHash": "pwk2/No1kL1ft+zMT2y0MvzB6W5cpkdOTj+0+T2u7LGJMTw37qtlnHzCSCyvwRiZVoJ/V/DE78eQ/WEcutUVDw=="
},
"Resourcer.Fody": {
"type": "Direct",
@ -22,12 +22,6 @@
"dependencies": {
"Fody": "6.6.4"
}
},
"XivCommon": {
"type": "Direct",
"requested": "[9.0.0, )",
"resolved": "9.0.0",
"contentHash": "avaBp3FmSCi/PiQhntCeBDYOHejdyTWmFtz4pRBVQQ8vHkmRx+YTk1la9dkYBMlXxRXKckEdH1iI1Fu61JlE7w=="
}
}
}