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) private Image<Rgba32> ConvertImage(MtrlFile.Texture texture, CancellationToken cancel)
{ {
// Work out the texture's path - the DX11 material flag controls a file name prefix. // Work out the texture's path - the DX11 material flag controls a file name prefix.
var texturePath = texture.Path; GamePaths.Tex.HandleDx11Path(texture, out var texturePath);
if (texture.DX11)
{
var fileName = Path.GetFileName(texturePath);
if (!fileName.StartsWith("--"))
texturePath = $"{Path.GetDirectoryName(texturePath)}/--{fileName}";
}
using var textureData = new MemoryStream(read(texturePath)); using var textureData = new MemoryStream(read(texturePath));
var image = TexFileParser.Parse(textureData); var image = TexFileParser.Parse(textureData);
var pngImage = TextureManager.ConvertToPng(image, cancel).AsPng; 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, public static FileSwap CreateTex(MetaFileManager manager, Func<Utf8GamePath, FullPath> redirections, BodySlot slot, GenderRace race,
PrimaryId idFrom, ref MtrlFile.Texture texture, PrimaryId idFrom, ref MtrlFile.Texture texture, ref bool dataWasChanged)
ref bool dataWasChanged)
{ {
var path = texture.Path; var addedDashes = GamePaths.Tex.HandleDx11Path(texture, out var 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.ReplaceAnyRace(path, race); var newPath = ItemSwap.ReplaceAnyRace(path, race);
newPath = ItemSwap.ReplaceAnyBody(newPath, slot, idFrom); newPath = ItemSwap.ReplaceAnyBody(newPath, slot, idFrom);
newPath = ItemSwap.AddSuffix(newPath, ".tex", $"_{Path.GetFileName(texture.Path).GetStableHashCode():x8}", true); newPath = ItemSwap.AddSuffix(newPath, ".tex", $"_{Path.GetFileName(texture.Path).GetStableHashCode():x8}", true);

View file

@ -402,21 +402,9 @@ public static class EquipmentSwap
=> CreateTex(manager, redirections, prefix, EquipSlot.Unknown, EquipSlot.Unknown, idFrom, idTo, ref texture, ref dataWasChanged); => 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, public static FileSwap CreateTex(MetaFileManager manager, Func<Utf8GamePath, FullPath> redirections, char prefix, EquipSlot slotFrom,
EquipSlot slotTo, PrimaryId idFrom, EquipSlot slotTo, PrimaryId idFrom, PrimaryId idTo, ref MtrlFile.Texture texture, ref bool dataWasChanged)
PrimaryId idTo, ref MtrlFile.Texture texture, ref bool dataWasChanged)
{ {
var path = texture.Path; var addedDashes = GamePaths.Tex.HandleDx11Path(texture, out var 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 newPath = ItemSwap.ReplaceAnyId(path, prefix, idFrom);
newPath = ItemSwap.ReplaceSlot(newPath, slotTo, slotFrom, slotTo != slotFrom); newPath = ItemSwap.ReplaceSlot(newPath, slotTo, slotFrom, slotTo != slotFrom);
newPath = ItemSwap.AddSuffix(newPath, ".tex", $"_{Path.GetFileName(texture.Path).GetStableHashCode():x8}"); newPath = ItemSwap.AddSuffix(newPath, ".tex", $"_{Path.GetFileName(texture.Path).GetStableHashCode():x8}");