Add function that handles prepending DX11 dashes.

This commit is contained in:
Ottermandias 2024-01-14 14:15:07 +01:00
parent 574a129772
commit 965f8efd80
4 changed files with 7 additions and 38 deletions

@ -1 +1 @@
Subproject commit 96e95378325ff1533ca41b934fcb712f24d5260b
Subproject commit 135451430344f2f12e8c02fd4c4c6f0875d74e60

View file

@ -244,14 +244,7 @@ public sealed class ModelManager(IFramework framework, ActiveCollections collect
private Image<Rgba32> ConvertImage(MtrlFile.Texture texture, CancellationToken cancel)
{
// Work out the texture's path - the DX11 material flag controls a file name prefix.
var texturePath = texture.Path;
if (texture.DX11)
{
var fileName = Path.GetFileName(texturePath);
if (!fileName.StartsWith("--"))
texturePath = $"{Path.GetDirectoryName(texturePath)}/--{fileName}";
}
GamePaths.Tex.HandleDx11Path(texture, out var texturePath);
using var textureData = new MemoryStream(read(texturePath));
var image = TexFileParser.Parse(textureData);
var pngImage = TextureManager.ConvertToPng(image, cancel).AsPng;

View file

@ -79,21 +79,9 @@ public static class CustomizationSwap
}
public static FileSwap CreateTex(MetaFileManager manager, Func<Utf8GamePath, FullPath> redirections, BodySlot slot, GenderRace race,
PrimaryId idFrom, ref MtrlFile.Texture texture,
ref bool dataWasChanged)
PrimaryId idFrom, ref MtrlFile.Texture texture, ref bool dataWasChanged)
{
var path = texture.Path;
var addedDashes = false;
if (texture.DX11)
{
var fileName = Path.GetFileName(path);
if (!fileName.StartsWith("--"))
{
path = path.Replace(fileName, $"--{fileName}");
addedDashes = true;
}
}
var addedDashes = GamePaths.Tex.HandleDx11Path(texture, out var path);
var newPath = ItemSwap.ReplaceAnyRace(path, race);
newPath = ItemSwap.ReplaceAnyBody(newPath, slot, idFrom);
newPath = ItemSwap.AddSuffix(newPath, ".tex", $"_{Path.GetFileName(texture.Path).GetStableHashCode():x8}", true);

View file

@ -402,22 +402,10 @@ public static class EquipmentSwap
=> CreateTex(manager, redirections, prefix, EquipSlot.Unknown, EquipSlot.Unknown, idFrom, idTo, ref texture, ref dataWasChanged);
public static FileSwap CreateTex(MetaFileManager manager, Func<Utf8GamePath, FullPath> redirections, char prefix, EquipSlot slotFrom,
EquipSlot slotTo, PrimaryId idFrom,
PrimaryId idTo, ref MtrlFile.Texture texture, ref bool dataWasChanged)
EquipSlot slotTo, PrimaryId idFrom, PrimaryId idTo, ref MtrlFile.Texture texture, ref bool dataWasChanged)
{
var path = texture.Path;
var addedDashes = false;
if (texture.DX11)
{
var fileName = Path.GetFileName(path);
if (!fileName.StartsWith("--"))
{
path = path.Replace(fileName, $"--{fileName}");
addedDashes = true;
}
}
var newPath = ItemSwap.ReplaceAnyId(path, prefix, idFrom);
var addedDashes = GamePaths.Tex.HandleDx11Path(texture, out var path);
var newPath = ItemSwap.ReplaceAnyId(path, prefix, idFrom);
newPath = ItemSwap.ReplaceSlot(newPath, slotTo, slotFrom, slotTo != slotFrom);
newPath = ItemSwap.AddSuffix(newPath, ".tex", $"_{Path.GetFileName(texture.Path).GetStableHashCode():x8}");
if (newPath != path)