feat: add image coordinates to meta

This commit is contained in:
Anna 2024-02-18 00:43:22 -05:00
parent a260c62f5d
commit ffabe0ba0e
Signed by: anna
GPG Key ID: D0943384CD9F87D1
2 changed files with 18 additions and 5 deletions

View File

@ -28,6 +28,12 @@ internal class Command : IDisposable {
private void OnCommand(string command, string arguments) {
// TODO: offload as much of this as possible onto a new thread.
// probably want to keep the bitmap stuff on main thread so that
// thread start delay doesn't make a screenshot be delayed.
// TODO: eventually be able to do like /screenie --no-ui --format png
// etc.
if (arguments == "config") {
this.Plugin.Ui.Visible ^= true;
return;

View File

@ -81,7 +81,8 @@ public class ScreenshotMetadata {
World? world = null;
if (plugin.ClientState.LocalPlayer is { } player) {
world = plugin.DataManager.GetExcelSheet<World>()?.GetRow(player.CurrentWorld.Id);
active = new Character(player, scale, offsetX, offsetY);
plugin.GameGui.WorldToScreen(player.Position, out var screenPos);
active = new Character(player, screenPos, scale, offsetX, offsetY);
}
var timeUtc = DateTime.UtcNow;
@ -95,8 +96,12 @@ public class ScreenshotMetadata {
return draw != null && draw->IsVisible;
}
})
.Where(chara => plugin.GameGui.WorldToScreen(chara.Position, out _, out var inView) && inView)
.Select(chara => new Character(chara, scale, offsetX, offsetY))
.Select(chara => {
var visible = plugin.GameGui.WorldToScreen(chara.Position, out var screenPos, out var inView);
return (chara, screenPos, visible: visible && inView);
})
.Where(tuple => tuple.visible)
.Select(tuple => new Character(tuple.chara, tuple.screenPos, scale, offsetX, offsetY))
.ToArray();
return new ScreenshotMetadata {
@ -126,13 +131,14 @@ public class Character {
public string Name;
public string? HomeWorld;
public uint HomeWorldId;
public Vector3 MapPosition;
public Vector3 RawPosition;
public Vector3 MapPosition;
public Vector2 ImagePosition;
public uint Level;
public string? Job;
public uint JobId;
public Character(PlayerCharacter player, float scale, short offsetX, short offsetY) {
public Character(PlayerCharacter player, Vector2 screenPos, float scale, short offsetX, short offsetY) {
this.Name = player.Name.TextValue;
this.HomeWorld = player.HomeWorld.GameData?.Name.ToDalamudString().TextValue.WhitespaceToNull();
this.HomeWorldId = player.HomeWorld.Id;
@ -142,6 +148,7 @@ public class Character {
ConvertRawPositionToMapCoordinate(player.Position.Z, scale, offsetY),
player.Position.Y // TODO: how does map Z coord work
);
this.ImagePosition = screenPos;
this.Level = player.Level;
this.Job = player.ClassJob.GameData?.Name.ToDalamudString().TextValue.WhitespaceToNull();
this.JobId = player.ClassJob.Id;