22
22
using System . Resources ;
23
23
using System . Text . RegularExpressions ;
24
24
using xivModdingFramework . General . Enums ;
25
+ using xivModdingFramework . Helpers ;
25
26
using xivModdingFramework . Materials . FileTypes ;
26
27
using xivModdingFramework . Textures . DataContainers ;
27
28
using xivModdingFramework . Textures . Enums ;
@@ -34,10 +35,10 @@ namespace xivModdingFramework.Materials.DataContainers
34
35
/// </summary>
35
36
public class XivMtrl
36
37
{
37
- public const string ItemPathToken = "{item_path }" ;
38
+ public const string ItemPathToken = "{item_folder }" ;
38
39
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 }" ;
41
42
42
43
/// <summary>
43
44
/// The MTRL file signature
@@ -670,12 +671,23 @@ public void SetMapInfo(XivTexType MapType, MapInfo info)
670
671
// No path, assign it by default.
671
672
if ( info . path . Trim ( ) == "" )
672
673
{
673
- info . path = rootPath + defaultFileName ;
674
+ info . path = rootPath + "/" + defaultFileName ;
674
675
}
675
676
676
677
// Detokenize paths
677
678
info . path = DetokenizePath ( info . path , info . Usage ) ;
678
679
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
+
679
691
// Ensure .tex or .atex ending for sanity.
680
692
var match = Regex . Match ( info . path , "\\ .a?tex$" ) ;
681
693
if ( ! match . Success )
@@ -1064,7 +1076,7 @@ public string GetTextureRootDirectoy()
1064
1076
var match = Regex . Match ( MTRLPath , "(.*)material/" ) ;
1065
1077
if ( match . Success )
1066
1078
{
1067
- root = match . Groups [ 1 ] . Value + "texture/ " ;
1079
+ root = match . Groups [ 1 ] . Value + "texture" ;
1068
1080
}
1069
1081
} else
1070
1082
{
@@ -1100,7 +1112,7 @@ public string GetVariantString()
1100
1112
var versionString = "" ;
1101
1113
if ( version > 0 )
1102
1114
{
1103
- versionString += 'v' + ( version . ToString ( ) . PadLeft ( 2 , '0' ) ) + '_' ;
1115
+ versionString += 'v' + ( version . ToString ( ) . PadLeft ( 2 , '0' ) ) ;
1104
1116
}
1105
1117
return versionString ;
1106
1118
}
@@ -1117,7 +1129,7 @@ public string GetDefaultTexureName(XivTexType texType, bool includeVersion = tru
1117
1129
// When available, version number prefixes the texture name.
1118
1130
if ( includeVersion )
1119
1131
{
1120
- ret += GetVariantString ( ) ;
1132
+ ret += GetVariantString ( ) + "_" ;
1121
1133
}
1122
1134
1123
1135
// Followed by the character and secondary identifier.
@@ -1150,7 +1162,16 @@ public string GetDefaultTexureName(XivTexType texType, bool includeVersion = tru
1150
1162
}
1151
1163
else if ( texType == XivTexType . Multi )
1152
1164
{
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
+ }
1154
1175
}
1155
1176
else if ( texType == XivTexType . Diffuse )
1156
1177
{
@@ -1185,6 +1206,9 @@ public string GetItemTypeIdentifier()
1185
1206
if ( match . Success )
1186
1207
{
1187
1208
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" ;
1188
1212
}
1189
1213
return "" ;
1190
1214
}
@@ -1211,7 +1235,7 @@ public XivRace GetRace()
1211
1235
/// <returns></returns>
1212
1236
public static string GetCommonTextureDirectory ( )
1213
1237
{
1214
- return "chara/common/texture/ " ;
1238
+ return "chara/common/texture" ;
1215
1239
}
1216
1240
1217
1241
/// <summary>
@@ -1253,7 +1277,7 @@ public string DetokenizePath(string path, XivTexType usage)
1253
1277
// No path, assign it by default.
1254
1278
if ( path == "" )
1255
1279
{
1256
- path = rootPath + defaultFileName ;
1280
+ path = rootPath + "/" + defaultFileName ;
1257
1281
return path ;
1258
1282
}
1259
1283
0 commit comments