Skip to content

Commit bbd213b

Browse files
committed
Update v3.0.6.0
2 parents caf5f0e + 02a871b commit bbd213b

File tree

5 files changed

+102
-20
lines changed

5 files changed

+102
-20
lines changed

xivModdingFramework/Cache/XivCache.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using xivModdingFramework.General.Enums;
11+
using xivModdingFramework.Helpers;
1112
using xivModdingFramework.Items;
1213
using xivModdingFramework.Items.Categories;
1314
using xivModdingFramework.Items.DataContainers;
1415
using xivModdingFramework.Items.Enums;
1516
using xivModdingFramework.Items.Interfaces;
1617
using xivModdingFramework.Models.DataContainers;
18+
using xivModdingFramework.Models.FileTypes;
1719
using xivModdingFramework.Mods;
1820
using xivModdingFramework.Resources;
1921
using xivModdingFramework.SqPack.FileTypes;
@@ -75,7 +77,7 @@ public static class XivCache
7577
private static GameInfo _gameInfo;
7678
private static DirectoryInfo _dbPath;
7779
private static DirectoryInfo _rootCachePath;
78-
public static readonly Version CacheVersion = new Version("1.0.3.1");
80+
public static readonly Version CacheVersion = new Version("1.0.3.3");
7981
private const string dbFileName = "mod_cache.db";
8082
private const string rootCacheFileName = "item_sets.db";
8183
private const string creationScript = "CreateCacheDB.sql";
@@ -585,7 +587,17 @@ private static void CreateCache()
585587

586588
private static async Task MigrateCache(Version lastCacheVersion) {
587589

588-
// No migration tasks currently.
590+
if (lastCacheVersion == null) return;
591+
if (lastCacheVersion == new Version("0.0.0.0")) return;
592+
if (lastCacheVersion == new Version()) return;
593+
594+
if (lastCacheVersion < new Version("1.0.3.3"))
595+
{
596+
// Clear user's Skeletons folder from Pre-DT.
597+
var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
598+
var skelFolder = Path.Combine(cwd, "Skeletons");
599+
IOUtil.RecursiveDeleteDirectory(skelFolder);
600+
}
589601

590602
}
591603

xivModdingFramework/Models/ModelTextures/ModelTexture.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -830,12 +830,6 @@ private static ShaderMapperDelegate GetShaderMapper(CustomModelColors colors, Xi
830830
var metalness = metalnessConst;
831831
var occlusion = 1.0f;
832832

833-
// HACKHACK - This is wrong, both according to Shader Decomp and logic/sanity.
834-
// The incoming diffuse *SHOULD* be coming in as sRGB encoded, and get Linear-converted previously.
835-
// But instead, the diffuse appears to be coming in already linear encoded, and gets double converted.
836-
// This effectively undoes one of those conversions.
837-
diffuse = LinearToSrgb(diffuse);
838-
839833
float skinInfluence = (float)normal.Blue;// * normal.Blue;
840834
var sColor = Color4.Lerp(new Color4(1.0f), skinColor, skinInfluence);
841835
diffuse *= sColor;
@@ -872,8 +866,6 @@ private static ShaderMapperDelegate GetShaderMapper(CustomModelColors colors, Xi
872866

873867

874868
//diffuse *= diffuseColorMul;
875-
// This is a bit of a hack here and probably not correct.
876-
diffuse *= LinearToSrgb(diffuseColorMul);
877869

878870
if (!settings.GeneratePbrMaps)
879871
{

xivModdingFramework/Mods/EndwalkerUpgrade.cs

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ public struct UpgradeInfo
6262
/// Returns a collection of file upgrade information.
6363
/// </summary>
6464
/// <param name="filePaths"></param>
65-
/// <param name="source"></param>
65+
/// <param name="sourceApplication"></param>
6666
/// <param name="states"></param>
6767
/// <param name="progress"></param>
6868
/// <param name="tx"></param>
6969
/// <returns></returns>
70-
public static async Task<Dictionary<string, UpgradeInfo>> UpdateEndwalkerFiles(IEnumerable<string> paths, string source, bool includePartials = true, IProgress<(int current, int total, string message)> progress = null, ModTransaction tx = null)
70+
public static async Task<Dictionary<string, UpgradeInfo>> UpdateEndwalkerFiles(IEnumerable<string> paths, string sourceApplication, bool includePartials = true, IProgress<(int current, int total, string message)> progress = null, ModTransaction tx = null)
7171
{
72-
var filePaths = paths.ToList();
72+
var filePaths = new HashSet<string>(paths);
7373
var ret = new Dictionary<string, UpgradeInfo>();
7474

7575
HashSet<string> _ConvertedTextures = new HashSet<string>();
@@ -80,34 +80,44 @@ public static async Task<Dictionary<string, UpgradeInfo>> UpdateEndwalkerFiles(I
8080
var fixableMtrlsRegex = new Regex("chara\\/.*\\.mtrl");
8181
var fixableMtrls = filePaths.Where(x => fixableMtrlsRegex.Match(x).Success).ToList();
8282

83-
ret = await EndwalkerUpgrade.UpdateEndwalkerMaterials(fixableMtrls, source, tx, progress, _ConvertedTextures);
83+
ret = await EndwalkerUpgrade.UpdateEndwalkerMaterials(fixableMtrls, sourceApplication, tx, progress, _ConvertedTextures);
8484

8585
var idx = 0;
8686
var total = fixableMdls.Count;
8787
foreach (var path in fixableMdls)
8888
{
8989
progress?.Report((idx, total, "Updating Endwalker Models..."));
9090
idx++;
91-
await EndwalkerUpgrade.UpdateEndwalkerModel(path, source, tx);
91+
await EndwalkerUpgrade.UpdateEndwalkerModel(path, sourceApplication, tx);
9292
}
9393

9494
if (includePartials)
9595
{
9696
progress?.Report((0, total, "Updating Endwalker partial Hair Mods..."));
97-
await EndwalkerUpgrade.UpdateUnclaimedHairTextures(filePaths, source, tx, _ConvertedTextures);
97+
await EndwalkerUpgrade.UpdateUnclaimedHairTextures(filePaths.ToList(), sourceApplication, tx, _ConvertedTextures);
9898

9999
progress?.Report((0, total, "Updating Endwalker partial Eye Mods..."));
100100
foreach (var path in filePaths)
101101
{
102102
try
103103
{
104-
await EndwalkerUpgrade.UpdateEyeMask(path, source, tx, _ConvertedTextures);
104+
await EndwalkerUpgrade.UpdateEyeMask(path, sourceApplication, tx, _ConvertedTextures);
105105
}
106106
catch(Exception ex)
107107
{
108108
Trace.WriteLine(ex);
109109
}
110110
}
111+
112+
progress?.Report((0, total, "Updating Endwalker partial Skin Mods..."));
113+
foreach(var path in filePaths)
114+
{
115+
if (SkinRepathDict.ContainsKey(path))
116+
{
117+
var target = SkinRepathDict[path];
118+
await Dat.CopyFile(path, target, sourceApplication, true, null, tx);
119+
}
120+
}
111121
}
112122

113123

@@ -2050,5 +2060,50 @@ public static async Task<FileStorageInformation> ValidateTextureSizes(FileStorag
20502060
return info;
20512061
}
20522062

2063+
2064+
public static readonly Dictionary<string, string> SkinRepathDict = new Dictionary<string, string>()
2065+
{
2066+
// Base Game
2067+
{ "chara/human/c0201/obj/body/b0001/texture/--c0201b0001_d.tex", "chara/human/c0201/obj/body/b0001/texture/c0201b0001_base.tex" },
2068+
{ "chara/human/c0401/obj/body/b0001/texture/--c0401b0001_d.tex", "chara/human/c0401/obj/body/b0001/texture/c0401b0001_base.tex" },
2069+
{ "chara/human/c1401/obj/body/b0001/texture/--c1401b0001_d.tex", "chara/human/c1401/obj/body/b0001/texture/c1401b0001_base.tex" },
2070+
{ "chara/human/c1401/obj/body/b0101/texture/--c1401b0101_d.tex", "chara/human/c1401/obj/body/b0101/texture/c1401b0101_base.tex" },
2071+
{ "chara/human/c1801/obj/body/b0001/texture/--c1801b0001_d.tex", "chara/human/c1801/obj/body/b0001/texture/c1801b0001_base.tex" },
2072+
2073+
// Base Game Norms
2074+
{ "chara/human/c0201/obj/body/b0001/texture/--c0201b0001_n.tex", "chara/human/c0201/obj/body/b0001/texture/c0201b0001_norm.tex" },
2075+
{ "chara/human/c0401/obj/body/b0001/texture/--c0401b0001_n.tex", "chara/human/c0401/obj/body/b0001/texture/c0401b0001_norm.tex" },
2076+
{ "chara/human/c1401/obj/body/b0001/texture/--c1401b0001_n.tex", "chara/human/c1401/obj/body/b0001/texture/c1401b0001_norm.tex" },
2077+
{ "chara/human/c1401/obj/body/b0101/texture/--c1401b0101_n.tex", "chara/human/c1401/obj/body/b0101/texture/c1401b0101_norm.tex" },
2078+
{ "chara/human/c1801/obj/body/b0001/texture/--c1801b0001_n.tex", "chara/human/c1801/obj/body/b0001/texture/c1801b0001_norm.tex" },
2079+
2080+
// Bibo
2081+
{ "chara/bibo/midlander_d.tex", "chara/bibo_mid_base.tex" },
2082+
{ "chara/bibo/raen_d.tex", "chara/bibo_raen_base.tex" },
2083+
{ "chara/bibo/xaela_d.tex", "chara/bibo_xaela_base.tex" },
2084+
{ "chara/bibo/viera_d.tex", "chara/bibo_viera_base.tex" },
2085+
{ "chara/bibo/highlander_d.tex", "chara/bibo_high_base.tex" },
2086+
2087+
// Bibo Norms
2088+
{ "chara/bibo/midlander_n.tex", "chara/bibo_mid_norm.tex" },
2089+
{ "chara/bibo/raen_n.tex", "chara/bibo_raen_norm.tex" },
2090+
{ "chara/bibo/xaela_n.tex", "chara/bibo_xaela_norm.tex" },
2091+
{ "chara/bibo/viera_n.tex", "chara/bibo_viera_norm.tex" },
2092+
{ "chara/bibo/highlander_n.tex", "chara/bibo_high_norm.tex" },
2093+
2094+
// TBSE
2095+
{ "chara/human/c0101/obj/body/b0001/texture/--c0101b0001_b_d.tex", "chara/human/c0101/obj/body/b0001/texture/c0101b0001_b_d.tex" },
2096+
{ "chara/human/c1301/obj/body/b0001/texture/--c1301b0001_b_d.tex", "chara/human/c1301/obj/body/b0001/texture/c1301b0001_b_d.tex" },
2097+
{ "chara/human/c1301/obj/body/b0101/texture/--c1301b0101_b_d.tex", "chara/human/c1301/obj/body/b0101/texture/c1301b0101_b_d.tex" },
2098+
{ "chara/human/c1701/obj/body/b0001/texture/--c1701b0001_b_d.tex", "chara/human/c1701/obj/body/b0001/texture/c1701b0001_b_d.tex" },
2099+
{ "chara/human/c0301/obj/body/b0001/texture/--c0301b0001_b_d.tex", "chara/human/c0301/obj/body/b0001/texture/c0301b0001_b_d.tex" },
2100+
2101+
// TBSE Norms
2102+
{ "chara/human/c0101/obj/body/b0001/texture/--c0101b0001_b_n.tex", "chara/human/c0101/obj/body/b0001/texture/c0101b0001_b_n.tex" },
2103+
{ "chara/human/c1301/obj/body/b0001/texture/--c1301b0001_b_n.tex", "chara/human/c1301/obj/body/b0001/texture/c1301b0001_b_n.tex" },
2104+
{ "chara/human/c1301/obj/body/b0101/texture/--c1301b0101_b_n.tex", "chara/human/c1301/obj/body/b0101/texture/c1301b0101_b_n.tex" },
2105+
{ "chara/human/c1701/obj/body/b0001/texture/--c1701b0001_b_n.tex", "chara/human/c1701/obj/body/b0001/texture/c1701b0001_b_n.tex" },
2106+
{ "chara/human/c0301/obj/body/b0001/texture/--c0301b0001_b_n.tex", "chara/human/c0301/obj/body/b0001/texture/c0301b0001_b_n.tex" },
2107+
};
20532108
}
20542109
}

xivModdingFramework/Mods/Modpack Upgrader.cs renamed to xivModdingFramework/Mods/ModpackUpgrader.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ private static bool AnyChanges(Dictionary<string, FileStorageInformation> origin
155155
)));
156156

157157

158+
await ForAllOptions(data, UpdateSkinPaths);
159+
158160
// Third Round Upgrade - This inspects as-of-yet unupgraded textures for possible jank-upgrades,
159161
// Which is to say, upgrades where we can infer their usage and pairing, but the base mtrl was not included.
160162
foreach (var p in data.DataPages)
@@ -173,6 +175,7 @@ private static bool AnyChanges(Dictionary<string, FileStorageInformation> origin
173175
{
174176
await EndwalkerUpgrade.UpdateEyeMask(possibleMask, "Unused", null, null, o.StandardData.Files);
175177
}
178+
176179
}
177180
}
178181
}
@@ -184,9 +187,11 @@ private static bool AnyChanges(Dictionary<string, FileStorageInformation> origin
184187
{
185188
foreach(var g in p.Groups)
186189
{
187-
foreach(var o in g.Options)
190+
if (g == null) continue;
191+
foreach (var o in g.Options)
188192
{
189-
if(o.StandardData != null)
193+
if (o == null) continue;
194+
if (o.StandardData != null)
190195
{
191196
if (!anyChanges)
192197
{
@@ -472,5 +477,23 @@ await ForAllOptions(data, async (o) =>
472477
});
473478
}
474479

480+
public static async Task UpdateSkinPaths(WizardStandardOptionData opt)
481+
{
482+
483+
var clone = new Dictionary<string, FileStorageInformation>(opt.Files);
484+
foreach(var fkv in clone)
485+
{
486+
var file = fkv.Key;
487+
if (EndwalkerUpgrade.SkinRepathDict.ContainsKey(file))
488+
{
489+
var target = SkinRepathDict[file];
490+
if (opt.Files.ContainsKey(target)) continue;
491+
492+
// Duplicate the pointer.
493+
opt.Files.Add(target, fkv.Value);
494+
}
495+
}
496+
}
497+
475498
}
476499
}

xivModdingFramework/Textures/FileTypes/Tex.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ public static async Task<string> ConvertToDDS(string externalPath, string intern
502502
using (var surface = Surface.LoadFromFile(externalPath))
503503
{
504504
if (surface == null)
505-
throw new FormatException($"Unsupported texture format");
505+
throw new FormatException($"Unsupported texture format or unable to load file: " + externalPath);
506506

507507
surface.FlipVertically();
508508

0 commit comments

Comments
 (0)