mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Support path substitution to filesystem file (#1920)
This commit is contained in:
parent
2cbb8b9e22
commit
823ec47d67
1 changed files with 34 additions and 3 deletions
|
|
@ -3,11 +3,12 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Dalamud.Data;
|
using Dalamud.Data;
|
||||||
using Dalamud.Interface.Internal;
|
|
||||||
using Dalamud.Interface.Textures.TextureWraps;
|
using Dalamud.Interface.Textures.TextureWraps;
|
||||||
|
|
||||||
using Lumina.Data.Files;
|
using Lumina.Data.Files;
|
||||||
|
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Textures.Internal.SharedImmediateTextures;
|
namespace Dalamud.Interface.Textures.Internal.SharedImmediateTextures;
|
||||||
|
|
||||||
/// <summary>Represents a sharable texture, based on a file in game resources.</summary>
|
/// <summary>Represents a sharable texture, based on a file in game resources.</summary>
|
||||||
|
|
@ -35,9 +36,39 @@ internal sealed class GamePathSharedImmediateTexture : SharedImmediateTexture
|
||||||
{
|
{
|
||||||
var dm = await Service<DataManager>.GetAsync();
|
var dm = await Service<DataManager>.GetAsync();
|
||||||
var tm = await Service<TextureManager>.GetAsync();
|
var tm = await Service<TextureManager>.GetAsync();
|
||||||
|
|
||||||
|
TexFile? file;
|
||||||
|
|
||||||
var substPath = tm.GetSubstitutedPath(this.path);
|
var substPath = tm.GetSubstitutedPath(this.path);
|
||||||
if (dm.GetFile<TexFile>(substPath) is not { } file)
|
if (!string.IsNullOrWhiteSpace(substPath) && substPath != this.path)
|
||||||
throw new FileNotFoundException();
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
file =
|
||||||
|
Path.IsPathRooted(this.path)
|
||||||
|
? dm.GameData.GetFileFromDisk<TexFile>(substPath, this.path)
|
||||||
|
: dm.GetFile<TexFile>(substPath) ??
|
||||||
|
throw new FileNotFoundException("Game file not found.", substPath);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
file = dm.GetFile<TexFile>(this.path);
|
||||||
|
if (file is null)
|
||||||
|
throw;
|
||||||
|
|
||||||
|
Log.Warning(
|
||||||
|
e,
|
||||||
|
"{who}: substitute path {subst} for {orig} failed to load. Using original path instead.",
|
||||||
|
nameof(GamePathSharedImmediateTexture),
|
||||||
|
substPath,
|
||||||
|
this.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
file = dm.GetFile<TexFile>(this.path) ?? throw new FileNotFoundException("Game file not found.", this.path);
|
||||||
|
}
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
var wrap = tm.NoThrottleCreateFromTexFile(file);
|
var wrap = tm.NoThrottleCreateFromTexFile(file);
|
||||||
tm.BlameSetName(wrap, this.ToString());
|
tm.BlameSetName(wrap, this.ToString());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue