big clean up in progress 1
This commit is contained in:
@@ -2,7 +2,6 @@ using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Utility;
|
||||
using LightlessSync.API.Dto.Group;
|
||||
using LightlessSync.LightlessConfiguration;
|
||||
using LightlessSync.Services;
|
||||
|
||||
@@ -2,8 +2,6 @@ using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Utility;
|
||||
using LightlessSync.API.Data.Enum;
|
||||
using LightlessSync.API.Data.Extensions;
|
||||
using LightlessSync.API.Dto.Group;
|
||||
using LightlessSync.Interop.Ipc;
|
||||
@@ -24,11 +22,9 @@ using LightlessSync.WebAPI.Files;
|
||||
using LightlessSync.WebAPI.Files.Models;
|
||||
using LightlessSync.WebAPI.SignalR.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Immutable;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
@@ -12,16 +12,14 @@ using LightlessSync.Services;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using LightlessSync.Services.TextureCompression;
|
||||
using LightlessSync.Utils;
|
||||
using Penumbra.Api.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OtterTex;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using ImageSharpImage = SixLabors.ImageSharp.Image;
|
||||
|
||||
namespace LightlessSync.UI;
|
||||
|
||||
@@ -810,11 +808,11 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
var primaryGamePath = entry.GamePaths.FirstOrDefault() ?? string.Empty;
|
||||
var classificationPath = string.IsNullOrEmpty(primaryGamePath) ? primaryFile : primaryGamePath;
|
||||
var mapKind = _textureMetadataHelper.DetermineMapKind(primaryGamePath, primaryFile);
|
||||
var category = _textureMetadataHelper.DetermineCategory(classificationPath);
|
||||
var slot = _textureMetadataHelper.DetermineSlot(category, classificationPath);
|
||||
var category = TextureMetadataHelper.DetermineCategory(classificationPath);
|
||||
var slot = TextureMetadataHelper.DetermineSlot(category, classificationPath);
|
||||
var format = entry.Format.Value;
|
||||
var suggestion = _textureMetadataHelper.GetSuggestedTarget(format, mapKind);
|
||||
TextureCompressionTarget? currentTarget = _textureMetadataHelper.TryMapFormatToTarget(format, out var mappedTarget)
|
||||
var suggestion = TextureMetadataHelper.GetSuggestedTarget(format, mapKind);
|
||||
TextureCompressionTarget? currentTarget = TextureMetadataHelper.TryMapFormatToTarget(format, out var mappedTarget)
|
||||
? mappedTarget
|
||||
: null;
|
||||
var displayName = Path.GetFileName(primaryFile);
|
||||
@@ -2014,23 +2012,43 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
|
||||
private async Task<IDalamudTextureWrap?> BuildPreviewAsync(TextureRow row, CancellationToken token)
|
||||
{
|
||||
if (!_ipcManager.Penumbra.APIAvailable)
|
||||
const int PreviewMaxDimension = 1024;
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
if (!File.Exists(row.PrimaryFilePath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var tempFile = Path.Combine(Path.GetTempPath(), $"lightless_preview_{Guid.NewGuid():N}.png");
|
||||
try
|
||||
{
|
||||
var job = new TextureConversionJob(row.PrimaryFilePath, tempFile, TextureType.Png, IncludeMipMaps: false);
|
||||
await _ipcManager.Penumbra.ConvertTextureFiles(_logger, new[] { job }, null, token).ConfigureAwait(false);
|
||||
if (!File.Exists(tempFile))
|
||||
using var scratch = TexFileHelper.Load(row.PrimaryFilePath);
|
||||
using var rgbaScratch = scratch.GetRGBA(out var rgbaInfo).ThrowIfError(rgbaInfo);
|
||||
|
||||
var meta = rgbaInfo.Meta;
|
||||
var width = meta.Width;
|
||||
var height = meta.Height;
|
||||
var bytesPerPixel = meta.Format.BitsPerPixel() / 8;
|
||||
var requiredLength = width * height * bytesPerPixel;
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
var rgbaPixels = rgbaScratch.Pixels[..requiredLength].ToArray();
|
||||
using var image = ImageSharpImage.LoadPixelData<Rgba32>(rgbaPixels, width, height);
|
||||
|
||||
if (Math.Max(width, height) > PreviewMaxDimension)
|
||||
{
|
||||
return null;
|
||||
var dominant = Math.Max(width, height);
|
||||
var scale = PreviewMaxDimension / (float)dominant;
|
||||
var targetWidth = Math.Max(1, (int)MathF.Round(width * scale));
|
||||
var targetHeight = Math.Max(1, (int)MathF.Round(height * scale));
|
||||
image.Mutate(ctx => ctx.Resize(targetWidth, targetHeight, KnownResamplers.Lanczos3));
|
||||
}
|
||||
|
||||
var data = await File.ReadAllBytesAsync(tempFile, token).ConfigureAwait(false);
|
||||
return _uiSharedService.LoadImage(data);
|
||||
using var ms = new MemoryStream();
|
||||
await image.SaveAsPngAsync(ms, cancellationToken: token).ConfigureAwait(false);
|
||||
return _uiSharedService.LoadImage(ms.ToArray());
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@@ -2041,20 +2059,6 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
_logger.LogDebug(ex, "Preview generation failed for {File}", row.PrimaryFilePath);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(tempFile))
|
||||
{
|
||||
File.Delete(tempFile);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogTrace(ex, "Failed to clean up preview temp file {File}", tempFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetPreview(string key)
|
||||
@@ -2291,7 +2295,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
_textureSelections[row.Key] = selectedTarget;
|
||||
}
|
||||
var hasSelectedInfo = _textureMetadataHelper.TryGetRecommendationInfo(selectedTarget, out var selectedInfo);
|
||||
var hasSelectedInfo = TextureMetadataHelper.TryGetRecommendationInfo(selectedTarget, out var selectedInfo);
|
||||
|
||||
using (ImRaii.Child("textureDetailInfo", new Vector2(-1, 0), true, ImGuiWindowFlags.AlwaysVerticalScrollbar))
|
||||
{
|
||||
@@ -2425,7 +2429,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
if (row.SuggestedTarget.HasValue)
|
||||
{
|
||||
var recommendedTarget = row.SuggestedTarget.Value;
|
||||
var hasRecommendationInfo = _textureMetadataHelper.TryGetRecommendationInfo(recommendedTarget, out var recommendedInfo);
|
||||
var hasRecommendationInfo = TextureMetadataHelper.TryGetRecommendationInfo(recommendedTarget, out var recommendedInfo);
|
||||
var recommendedTitle = hasRecommendationInfo ? recommendedInfo!.Title : recommendedTarget.ToString();
|
||||
var recommendedDescription = hasRecommendationInfo
|
||||
? recommendedInfo!.Description
|
||||
@@ -2634,4 +2638,4 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
namespace LightlessSync.UI
|
||||
{
|
||||
public enum ProfileTags
|
||||
{
|
||||
SFW = 0,
|
||||
NSFW = 1,
|
||||
|
||||
RP = 2,
|
||||
ERP = 3,
|
||||
No_RP = 4,
|
||||
No_ERP = 5,
|
||||
|
||||
Venues = 6,
|
||||
Gpose = 7,
|
||||
|
||||
Limsa = 8,
|
||||
Gridania = 9,
|
||||
Ul_dah = 10,
|
||||
|
||||
WUT = 11,
|
||||
|
||||
PVP = 1001,
|
||||
Ultimate = 1002,
|
||||
Raids = 1003,
|
||||
Roulette = 1004,
|
||||
Crafting = 1005,
|
||||
Casual = 1006,
|
||||
Hardcore = 1007,
|
||||
Glamour = 1008,
|
||||
Mentor = 1009,
|
||||
|
||||
}
|
||||
}
|
||||
@@ -28,23 +28,16 @@ using LightlessSync.WebAPI;
|
||||
using LightlessSync.WebAPI.Files;
|
||||
using LightlessSync.WebAPI.Files.Models;
|
||||
using LightlessSync.WebAPI.SignalR.Utils;
|
||||
using DalamudObjectKind = Dalamud.Game.ClientState.Objects.Enums.ObjectKind;
|
||||
using Microsoft.AspNetCore.Http.Connections;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Object;
|
||||
using FfxivCharacter = FFXIVClientStructs.FFXIV.Client.Game.Character.Character;
|
||||
using FfxivCharacterBase = FFXIVClientStructs.FFXIV.Client.Graphics.Scene.CharacterBase;
|
||||
|
||||
namespace LightlessSync.UI;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.ImGuiSeStringRenderer;
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using Dalamud.Interface.Utility;
|
||||
using LightlessSync.API.Data;
|
||||
@@ -13,9 +12,6 @@ using LightlessSync.UI.Services;
|
||||
using LightlessSync.UI.Tags;
|
||||
using LightlessSync.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace LightlessSync.UI;
|
||||
|
||||
@@ -4,21 +4,16 @@ using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.ImGuiFileDialog;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using LightlessSync.API.Data;
|
||||
using LightlessSync.API.Data.Enum;
|
||||
using LightlessSync.API.Data.Extensions;
|
||||
using LightlessSync.API.Dto.Group;
|
||||
using LightlessSync.API.Dto.User;
|
||||
using LightlessSync.Services;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using LightlessSync.UI.Handlers;
|
||||
using LightlessSync.PlayerData.Pairs;
|
||||
using LightlessSync.WebAPI;
|
||||
using LightlessSync.UI.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace LightlessSync.UI;
|
||||
|
||||
|
||||
@@ -13,10 +13,7 @@ using LightlessSync.Utils;
|
||||
using LightlessSync.WebAPI;
|
||||
using LightlessSync.UI.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LightlessSync.UI;
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ using Dalamud.Interface.Textures.TextureWraps;
|
||||
using Dalamud.Interface.Utility;
|
||||
using LightlessSync.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
|
||||
namespace LightlessSync.UI.Tags;
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
using LightlessSync.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
|
||||
namespace LightlessSync.UI.Tags;
|
||||
@@ -35,16 +32,16 @@ public sealed class ProfileTagService
|
||||
|
||||
private static IReadOnlyDictionary<int, ProfileTagDefinition> CreateTagLibrary()
|
||||
{
|
||||
var dictionary = new Dictionary<int, ProfileTagDefinition>
|
||||
return new Dictionary<int, ProfileTagDefinition>
|
||||
{
|
||||
[(int)ProfileTags.SFW] = ProfileTagDefinition.FromIconAndText(
|
||||
[0] = ProfileTagDefinition.FromIconAndText(
|
||||
230419,
|
||||
"SFW",
|
||||
background: new Vector4(0.16f, 0.24f, 0.18f, 0.95f),
|
||||
border: new Vector4(0.32f, 0.52f, 0.34f, 0.85f),
|
||||
textColor: new Vector4(0.78f, 0.94f, 0.80f, 1f)),
|
||||
|
||||
[(int)ProfileTags.NSFW] = ProfileTagDefinition.FromIconAndText(
|
||||
[1] = ProfileTagDefinition.FromIconAndText(
|
||||
230419,
|
||||
"NSFW",
|
||||
background: new Vector4(0.32f, 0.18f, 0.22f, 0.95f),
|
||||
@@ -52,28 +49,28 @@ public sealed class ProfileTagService
|
||||
textColor: new Vector4(1f, 0.82f, 0.86f, 1f)),
|
||||
|
||||
|
||||
[(int)ProfileTags.RP] = ProfileTagDefinition.FromIconAndText(
|
||||
[2] = ProfileTagDefinition.FromIconAndText(
|
||||
61545,
|
||||
"RP",
|
||||
background: new Vector4(0.20f, 0.20f, 0.30f, 0.95f),
|
||||
border: new Vector4(0.42f, 0.42f, 0.66f, 0.85f),
|
||||
textColor: new Vector4(0.80f, 0.84f, 1f, 1f)),
|
||||
|
||||
[(int)ProfileTags.ERP] = ProfileTagDefinition.FromIconAndText(
|
||||
[3] = ProfileTagDefinition.FromIconAndText(
|
||||
61545,
|
||||
"ERP",
|
||||
background: new Vector4(0.20f, 0.20f, 0.30f, 0.95f),
|
||||
border: new Vector4(0.42f, 0.42f, 0.66f, 0.85f),
|
||||
textColor: new Vector4(0.80f, 0.84f, 1f, 1f)),
|
||||
|
||||
[(int)ProfileTags.No_RP] = ProfileTagDefinition.FromIconAndText(
|
||||
[4] = ProfileTagDefinition.FromIconAndText(
|
||||
230420,
|
||||
"No RP",
|
||||
background: new Vector4(0.30f, 0.18f, 0.30f, 0.95f),
|
||||
border: new Vector4(0.69f, 0.40f, 0.65f, 0.85f),
|
||||
textColor: new Vector4(1f, 0.84f, 1f, 1f)),
|
||||
|
||||
[(int)ProfileTags.No_ERP] = ProfileTagDefinition.FromIconAndText(
|
||||
[5] = ProfileTagDefinition.FromIconAndText(
|
||||
230420,
|
||||
"No ERP",
|
||||
background: new Vector4(0.30f, 0.18f, 0.30f, 0.95f),
|
||||
@@ -81,14 +78,14 @@ public sealed class ProfileTagService
|
||||
textColor: new Vector4(1f, 0.84f, 1f, 1f)),
|
||||
|
||||
|
||||
[(int)ProfileTags.Venues] = ProfileTagDefinition.FromIconAndText(
|
||||
[6] = ProfileTagDefinition.FromIconAndText(
|
||||
60756,
|
||||
"Venues",
|
||||
background: new Vector4(0.18f, 0.24f, 0.28f, 0.95f),
|
||||
border: new Vector4(0.33f, 0.55f, 0.63f, 0.85f),
|
||||
textColor: new Vector4(0.78f, 0.90f, 0.97f, 1f)),
|
||||
|
||||
[(int)ProfileTags.Gpose] = ProfileTagDefinition.FromIconAndText(
|
||||
[7] = ProfileTagDefinition.FromIconAndText(
|
||||
61546,
|
||||
"GPose",
|
||||
background: new Vector4(0.18f, 0.18f, 0.26f, 0.95f),
|
||||
@@ -96,36 +93,33 @@ public sealed class ProfileTagService
|
||||
textColor: new Vector4(0.80f, 0.82f, 0.96f, 1f)),
|
||||
|
||||
|
||||
[(int)ProfileTags.Limsa] = ProfileTagDefinition.FromIconAndText(
|
||||
[8] = ProfileTagDefinition.FromIconAndText(
|
||||
60572,
|
||||
"Limsa"),
|
||||
|
||||
[(int)ProfileTags.Gridania] = ProfileTagDefinition.FromIconAndText(
|
||||
[9] = ProfileTagDefinition.FromIconAndText(
|
||||
60573,
|
||||
"Gridania"),
|
||||
|
||||
[(int)ProfileTags.Ul_dah] = ProfileTagDefinition.FromIconAndText(
|
||||
[10] = ProfileTagDefinition.FromIconAndText(
|
||||
60574,
|
||||
"Ul'dah"),
|
||||
|
||||
|
||||
[(int)ProfileTags.WUT] = ProfileTagDefinition.FromIconAndText(
|
||||
[11] = ProfileTagDefinition.FromIconAndText(
|
||||
61397,
|
||||
"WU/T"),
|
||||
|
||||
|
||||
[(int)ProfileTags.PVP] = ProfileTagDefinition.FromIcon(61806),
|
||||
[(int)ProfileTags.Ultimate] = ProfileTagDefinition.FromIcon(61832),
|
||||
[(int)ProfileTags.Raids] = ProfileTagDefinition.FromIcon(61802),
|
||||
[(int)ProfileTags.Roulette] = ProfileTagDefinition.FromIcon(61807),
|
||||
[(int)ProfileTags.Crafting] = ProfileTagDefinition.FromIcon(61816),
|
||||
[(int)ProfileTags.Casual] = ProfileTagDefinition.FromIcon(61753),
|
||||
[(int)ProfileTags.Hardcore] = ProfileTagDefinition.FromIcon(61754),
|
||||
[(int)ProfileTags.Glamour] = ProfileTagDefinition.FromIcon(61759),
|
||||
[(int)ProfileTags.Mentor] = ProfileTagDefinition.FromIcon(61760)
|
||||
|
||||
[1001] = ProfileTagDefinition.FromIcon(61806), // PVP
|
||||
[1002] = ProfileTagDefinition.FromIcon(61832), // Ultimate
|
||||
[1003] = ProfileTagDefinition.FromIcon(61802), // Raids
|
||||
[1004] = ProfileTagDefinition.FromIcon(61807), // Roulette
|
||||
[1005] = ProfileTagDefinition.FromIcon(61816), // Crafting
|
||||
[1006] = ProfileTagDefinition.FromIcon(61753), // Casual
|
||||
[1007] = ProfileTagDefinition.FromIcon(61754), // Hardcore
|
||||
[1008] = ProfileTagDefinition.FromIcon(61759), // Glamour
|
||||
[1009] = ProfileTagDefinition.FromIcon(61760) // Mentor
|
||||
};
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user