fix: use nulls in metadata
This commit is contained in:
parent
f5fac8c8ad
commit
28b994e0ab
|
@ -12,7 +12,7 @@ public class Configuration : IPluginConfiguration {
|
|||
public string SaveDirectory = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "Screenie");
|
||||
public Format SaveFormat = Format.Png;
|
||||
public int SaveFormatData = 90;
|
||||
public string SaveFileNameFormat = "{{ captured_at_local | date.to_string '%Y/%m/[%H.%M.%S]' }} {{ active_character.name }} - {{ location }}";
|
||||
public string SaveFileNameFormat = "{{ captured_at_local | date.to_string '%Y/%m/[%H.%M.%S]' }} {{ active_character.name }} - {{ location }}{{ if area }}({{ area }}){{ end }}";
|
||||
|
||||
private int _templateHashCode;
|
||||
private Template? _template;
|
||||
|
|
|
@ -16,21 +16,21 @@ namespace Screenie;
|
|||
public class ScreenshotMetadata {
|
||||
public required string Blake3Hash;
|
||||
public required Character? ActiveCharacter;
|
||||
public required string Location;
|
||||
public required string LocationSub;
|
||||
public required string? Location;
|
||||
public required string? LocationSub;
|
||||
public required string? Area;
|
||||
public required string? AreaSub;
|
||||
public required uint TerritoryType;
|
||||
public required string World;
|
||||
public required string? World;
|
||||
public required uint WorldId;
|
||||
public required DateTime CapturedAtLocal;
|
||||
public required DateTime CapturedAtUtc;
|
||||
public required string EorzeaTime;
|
||||
public required string Weather;
|
||||
public required string? Weather;
|
||||
public required uint Ward;
|
||||
public required uint Plot;
|
||||
public required Character[] VisibleCharacters;
|
||||
|
||||
internal const string Unknown = "Unknown";
|
||||
|
||||
internal static ScreenshotMetadata Capture(Plugin plugin) {
|
||||
EorzeaTime eorzea;
|
||||
uint ward;
|
||||
|
@ -40,6 +40,8 @@ public class ScreenshotMetadata {
|
|||
float scale;
|
||||
Weather? weather;
|
||||
Map? map;
|
||||
PlaceName? area;
|
||||
PlaceName? areaSub;
|
||||
unsafe {
|
||||
var framework = Framework.Instance();
|
||||
eorzea = new EorzeaTime((ulong) framework->ClientTime.EorzeaTime);
|
||||
|
@ -69,8 +71,8 @@ public class ScreenshotMetadata {
|
|||
map = plugin.DataManager.GetExcelSheet<Map>()?.GetRow(mapId);
|
||||
|
||||
var territoryInfo = TerritoryInfo.Instance();
|
||||
Plugin.Log.Info(plugin.DataManager.GetExcelSheet<PlaceName>()?.GetRow(territoryInfo->AreaPlaceNameID)?.Name.ToDalamudString().TextValue ?? "???");
|
||||
Plugin.Log.Info(plugin.DataManager.GetExcelSheet<PlaceName>()?.GetRow(territoryInfo->SubAreaPlaceNameID)?.Name.ToDalamudString().TextValue ?? "???");
|
||||
area = plugin.DataManager.GetExcelSheet<PlaceName>()?.GetRow(territoryInfo->AreaPlaceNameID);
|
||||
areaSub = plugin.DataManager.GetExcelSheet<PlaceName>()?.GetRow(territoryInfo->SubAreaPlaceNameID);
|
||||
}
|
||||
|
||||
var territory = plugin.DataManager.GetExcelSheet<TerritoryType>()?.GetRow(plugin.ClientState.TerritoryType);
|
||||
|
@ -99,17 +101,18 @@ public class ScreenshotMetadata {
|
|||
return new ScreenshotMetadata {
|
||||
Blake3Hash = "",
|
||||
ActiveCharacter = active,
|
||||
Location = map?.PlaceName.Value?.Name.ToDalamudString().TextValue
|
||||
?? territory?.PlaceName.Value?.Name.ToDalamudString().TextValue
|
||||
?? Unknown,
|
||||
LocationSub = map?.PlaceNameSub.Value?.Name.ToDalamudString().TextValue ?? Unknown,
|
||||
Location = map?.PlaceName.Value?.Name.ToDalamudString().TextValue.WhitespaceToNull()
|
||||
?? territory?.PlaceName.Value?.Name.ToDalamudString().TextValue.WhitespaceToNull(),
|
||||
LocationSub = map?.PlaceNameSub.Value?.Name.ToDalamudString().TextValue.WhitespaceToNull(),
|
||||
Area = area?.Name.ToDalamudString().TextValue.WhitespaceToNull(),
|
||||
AreaSub = areaSub?.Name.ToDalamudString().TextValue.WhitespaceToNull(),
|
||||
TerritoryType = plugin.ClientState.TerritoryType,
|
||||
World = world?.Name.ToDalamudString().TextValue ?? Unknown,
|
||||
World = world?.Name.ToDalamudString().TextValue.WhitespaceToNull(),
|
||||
WorldId = world?.RowId ?? 0,
|
||||
CapturedAtLocal = timeUtc.ToLocalTime(),
|
||||
CapturedAtUtc = timeUtc,
|
||||
EorzeaTime = $"{eorzea.Hour:00}:{eorzea.Minute:00}",
|
||||
Weather = weather?.Name.ToDalamudString().TextValue ?? Unknown,
|
||||
Weather = weather?.Name.ToDalamudString().TextValue.WhitespaceToNull(),
|
||||
Ward = ward,
|
||||
Plot = plot,
|
||||
VisibleCharacters = visible,
|
||||
|
@ -120,17 +123,17 @@ public class ScreenshotMetadata {
|
|||
[Serializable]
|
||||
public class Character {
|
||||
public string Name;
|
||||
public string HomeWorld;
|
||||
public string? HomeWorld;
|
||||
public uint HomeWorldId;
|
||||
public Vector3 MapPosition;
|
||||
public Vector3 RawPosition;
|
||||
public uint Level;
|
||||
public string Job;
|
||||
public string? Job;
|
||||
public uint JobId;
|
||||
|
||||
public Character(PlayerCharacter player, float scale, short offsetX, short offsetY) {
|
||||
this.Name = player.Name.TextValue;
|
||||
this.HomeWorld = player.HomeWorld.GameData?.Name.ToDalamudString().TextValue ?? ScreenshotMetadata.Unknown;
|
||||
this.HomeWorld = player.HomeWorld.GameData?.Name.ToDalamudString().TextValue.WhitespaceToNull();
|
||||
this.HomeWorldId = player.HomeWorld.Id;
|
||||
this.RawPosition = player.Position;
|
||||
this.MapPosition = new Vector3(
|
||||
|
@ -139,7 +142,7 @@ public class Character {
|
|||
player.Position.Y // TODO: how does map Z coord work
|
||||
);
|
||||
this.Level = player.Level;
|
||||
this.Job = player.ClassJob.GameData?.Name.ToDalamudString().TextValue ?? ScreenshotMetadata.Unknown;
|
||||
this.Job = player.ClassJob.GameData?.Name.ToDalamudString().TextValue.WhitespaceToNull();
|
||||
this.JobId = player.ClassJob.Id;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
namespace Screenie;
|
||||
|
||||
internal static class StringExt {
|
||||
internal static string? EmptyToNull(this string? text) {
|
||||
return string.IsNullOrEmpty(text) ? null : text;
|
||||
}
|
||||
|
||||
internal static string? WhitespaceToNull(this string? text) {
|
||||
return string.IsNullOrWhiteSpace(text) ? null : text;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue