Skip to content

Commit 71355bd

Browse files
committed
- Added some logic for correctly identifying default texture names in the character folder.
- (Fixes some errors with Material Creation not acting as users expected for hair/faces/tails) - Updated Material Editor tokens to be a little more layman-friendly. - {item_path} -> {item_folder} - {common_path} -> {shared_folder} - {texture_name} -> {default_name} - Putting in just a texture name (no path) will now default use the same texture name in the item's folder, rather than error-ing.
1 parent 23b131d commit 71355bd

File tree

1 file changed

+34
-10
lines changed
  • xivModdingFramework/Materials/DataContainers

1 file changed

+34
-10
lines changed

xivModdingFramework/Materials/DataContainers/XivMtrl.cs

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Resources;
2323
using System.Text.RegularExpressions;
2424
using xivModdingFramework.General.Enums;
25+
using xivModdingFramework.Helpers;
2526
using xivModdingFramework.Materials.FileTypes;
2627
using xivModdingFramework.Textures.DataContainers;
2728
using xivModdingFramework.Textures.Enums;
@@ -34,10 +35,10 @@ namespace xivModdingFramework.Materials.DataContainers
3435
/// </summary>
3536
public class XivMtrl
3637
{
37-
public const string ItemPathToken = "{item_path}";
38+
public const string ItemPathToken = "{item_folder}";
3839
public const string VariantToken = "{variant}";
39-
public const string TextureNameToken = "{texture_name}";
40-
public const string CommonPathToken = "{common_path}";
40+
public const string TextureNameToken = "{default_name}";
41+
public const string CommonPathToken = "{shared_folder}";
4142

4243
/// <summary>
4344
/// The MTRL file signature
@@ -670,12 +671,23 @@ public void SetMapInfo(XivTexType MapType, MapInfo info)
670671
// No path, assign it by default.
671672
if (info.path.Trim() == "")
672673
{
673-
info.path = rootPath + defaultFileName;
674+
info.path = rootPath + "/" + defaultFileName;
674675
}
675676

676677
// Detokenize paths
677678
info.path = DetokenizePath(info.path, info.Usage);
678679

680+
// Test the path goes to a legitimate DAT file.
681+
try
682+
{
683+
IOUtil.GetDataFileFromPath(info.path);
684+
} catch
685+
{
686+
// Prefix the item's personal path onto it.
687+
info.path = "{item_path}/" + info.path;
688+
info.path = DetokenizePath(info.path, info.Usage);
689+
}
690+
679691
// Ensure .tex or .atex ending for sanity.
680692
var match = Regex.Match(info.path, "\\.a?tex$");
681693
if(!match.Success)
@@ -1064,7 +1076,7 @@ public string GetTextureRootDirectoy()
10641076
var match = Regex.Match(MTRLPath, "(.*)material/");
10651077
if(match.Success)
10661078
{
1067-
root = match.Groups[1].Value + "texture/";
1079+
root = match.Groups[1].Value + "texture";
10681080
}
10691081
} else
10701082
{
@@ -1100,7 +1112,7 @@ public string GetVariantString()
11001112
var versionString = "";
11011113
if (version > 0)
11021114
{
1103-
versionString += 'v' + (version.ToString().PadLeft(2, '0')) + '_';
1115+
versionString += 'v' + (version.ToString().PadLeft(2, '0'));
11041116
}
11051117
return versionString;
11061118
}
@@ -1117,7 +1129,7 @@ public string GetDefaultTexureName(XivTexType texType, bool includeVersion = tru
11171129
// When available, version number prefixes the texture name.
11181130
if (includeVersion)
11191131
{
1120-
ret += GetVariantString();
1132+
ret += GetVariantString() + "_";
11211133
}
11221134

11231135
// Followed by the character and secondary identifier.
@@ -1150,7 +1162,16 @@ public string GetDefaultTexureName(XivTexType texType, bool includeVersion = tru
11501162
}
11511163
else if (texType == XivTexType.Multi)
11521164
{
1153-
ret += "_m";
1165+
var path = MTRLPath;
1166+
if (path.Contains("chara/human/c"))
1167+
{
1168+
// The character folder uses _s instead of _m despite the textures being multis.
1169+
ret += "_s";
1170+
}
1171+
else
1172+
{
1173+
ret += "_m";
1174+
}
11541175
}
11551176
else if (texType == XivTexType.Diffuse)
11561177
{
@@ -1185,6 +1206,9 @@ public string GetItemTypeIdentifier()
11851206
if (match.Success)
11861207
{
11871208
return "_" + match.Groups[1].Value;
1209+
} else if (MTRLPath.Contains("/obj/tail/t")) {
1210+
// Tails have their textures (but not materials) listed as _etc parts.
1211+
return "_etc";
11881212
}
11891213
return "";
11901214
}
@@ -1211,7 +1235,7 @@ public XivRace GetRace()
12111235
/// <returns></returns>
12121236
public static string GetCommonTextureDirectory()
12131237
{
1214-
return "chara/common/texture/";
1238+
return "chara/common/texture";
12151239
}
12161240

12171241
/// <summary>
@@ -1253,7 +1277,7 @@ public string DetokenizePath(string path, XivTexType usage)
12531277
// No path, assign it by default.
12541278
if (path == "")
12551279
{
1256-
path = rootPath + defaultFileName;
1280+
path = rootPath + "/" + defaultFileName;
12571281
return path;
12581282
}
12591283

0 commit comments

Comments
 (0)