Skip to content

Commit cd853b8

Browse files
committed
Beta v2.3.5.0b
2 parents ee792ec + f3a0e60 commit cd853b8

File tree

33 files changed

+760
-208
lines changed

33 files changed

+760
-208
lines changed

xivModdingFramework/Cache/XivCache.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
using xivModdingFramework.Resources;
1919
using xivModdingFramework.SqPack.FileTypes;
2020

21+
using Index = xivModdingFramework.SqPack.FileTypes.Index;
22+
2123
namespace xivModdingFramework.Cache
2224
{
2325

@@ -145,9 +147,10 @@ public enum CacheRebuildReason
145147
/// <param name="gameDirectory"></param>
146148
/// <param name="language"></param>
147149
/// <param name="validateCache"></param>
148-
public static void SetGameInfo(DirectoryInfo gameDirectory = null, XivLanguage language = XivLanguage.None, int dxMode = 11, bool validateCache = true, bool enableCacheWorker = true)
150+
public static void SetGameInfo(DirectoryInfo gameDirectory = null, XivLanguage language = XivLanguage.None, int dxMode = 11, bool validateCache = true, bool enableCacheWorker = true,
151+
DirectoryInfo luminaDirectory = null, bool useLumina = false)
149152
{
150-
var gi = new GameInfo(gameDirectory, language, dxMode);
153+
var gi = new GameInfo(gameDirectory, language, dxMode, luminaDirectory, useLumina);
151154
SetGameInfo(gi, enableCacheWorker);
152155
}
153156
public static void SetGameInfo(GameInfo gameInfo = null, bool enableCacheWorker = true)

xivModdingFramework/Cache/XivDependencyGraph.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
using xivModdingFramework.Resources;
2323
using xivModdingFramework.SqPack.DataContainers;
2424
using xivModdingFramework.SqPack.FileTypes;
25+
using xivModdingFramework.Textures.FileTypes;
2526
using xivModdingFramework.Variants.FileTypes;
2627
using static xivModdingFramework.Cache.XivCache;
2728

29+
using Index = xivModdingFramework.SqPack.FileTypes.Index;
30+
2831
namespace xivModdingFramework.Cache
2932
{
3033

@@ -490,6 +493,76 @@ public override int GetHashCode()
490493
return Info.ToString().GetHashCode();
491494
}
492495

496+
/// <summary>
497+
/// Retrieves ALL files used by this root.
498+
/// </summary>
499+
/// <param name="index"></param>
500+
/// <param name="modlist"></param>
501+
/// <returns></returns>
502+
public async Task<SortedSet<string>> GetAllFiles(IndexFile index = null, ModList modlist = null)
503+
{
504+
505+
var df = IOUtil.GetDataFileFromPath(Info.GetRootFile());
506+
507+
var _imc = new Imc(XivCache.GameInfo.GameDirectory);
508+
var _mdl = new Mdl(XivCache.GameInfo.GameDirectory, df);
509+
var _dat = new Dat(XivCache.GameInfo.GameDirectory);
510+
var _index = new Index(XivCache.GameInfo.GameDirectory);
511+
var _mtrl = new Mtrl(XivCache.GameInfo.GameDirectory);
512+
var _modding = new Modding(XivCache.GameInfo.GameDirectory);
513+
var _atex = new ATex(XivCache.GameInfo.GameDirectory, df);
514+
515+
var files = new HashSet<string>();
516+
517+
if (index == null)
518+
{
519+
index = await _index.GetIndexFile(df);
520+
modlist = await _modding.GetModListAsync();
521+
}
522+
523+
ItemMetadata originalMetadata = await ItemMetadata.GetFromCachedIndex(this, index);
524+
525+
var originalModelPaths = await GetModelFiles(index, modlist);
526+
var originalMaterialPaths = await GetMaterialFiles(-1, index, modlist);
527+
var originalTexturePaths = await GetTextureFiles(-1, index, modlist);
528+
529+
var originalVfxPaths = new HashSet<string>();
530+
if (Imc.UsesImc(this))
531+
{
532+
var avfxSets = originalMetadata.ImcEntries.Select(x => x.Vfx).Distinct();
533+
foreach (var avfx in avfxSets)
534+
{
535+
var avfxStuff = await ATex.GetVfxPath(Info, avfx);
536+
if (String.IsNullOrEmpty(avfxStuff.Folder) || String.IsNullOrEmpty(avfxStuff.File)) continue;
537+
538+
var path = avfxStuff.Folder + "/" + avfxStuff.File;
539+
if (index.FileExists(path))
540+
{
541+
originalVfxPaths.Add(path);
542+
var ttpaths = await _atex.GetAtexPaths(path);
543+
foreach (var ttp in ttpaths)
544+
{
545+
originalVfxPaths.Add(ttp.Path);
546+
}
547+
}
548+
}
549+
}
550+
551+
var af = originalModelPaths.Select(x => x).Union(
552+
originalMaterialPaths.Select(x => x)).Union(
553+
originalTexturePaths.Select(x => x)).Union(
554+
originalVfxPaths.Select(x => x));
555+
556+
var allFiles = new SortedSet<string>();
557+
foreach (var f in af)
558+
{
559+
allFiles.Add(f);
560+
}
561+
562+
allFiles.Add(Info.GetRootFile());
563+
564+
return allFiles;
565+
}
493566

494567
/// <summary>
495568
/// Gets all the model files in this dependency chain.

xivModdingFramework/Exd/FileTypes/Ex.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
using xivModdingFramework.Helpers;
2424
using xivModdingFramework.SqPack.FileTypes;
2525

26+
using Index = xivModdingFramework.SqPack.FileTypes.Index;
27+
2628
namespace xivModdingFramework.Exd.FileTypes
2729
{
2830
/// <summary>

xivModdingFramework/General/CMP.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,19 @@ internal static async Task ApplyRgspFile(string filePath, IndexFile index = null
4040
var _dat = new Dat(XivCache.GameInfo.GameDirectory);
4141
var rgspData = await _dat.GetType2Data(filePath, false, index, modlist);
4242

43-
var rgsp = new RacialGenderScalingParameter(rgspData);
43+
await ApplyRgspFile(rgspData);
44+
}
45+
46+
/// <summary>
47+
/// Applies a custom .rgsp file to the main Human.CMP file.
48+
/// </summary>
49+
/// <param name="data"></param>
50+
/// <param name="index"></param>
51+
/// <param name="modlist"></param>
52+
/// <returns></returns>
53+
internal static async Task ApplyRgspFile(byte[] data, IndexFile index = null, ModList modlist = null)
54+
{
55+
var rgsp = new RacialGenderScalingParameter(data);
4456

4557
await SetScalingParameter(rgsp, index, modlist);
4658
}

xivModdingFramework/General/Enums/XivRace.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,13 @@ public static XivRace GetSkinRace(this XivRace race)
510510
return XivRace.Hyur_Midlander_Male;
511511
}
512512

513+
// Roe F is very weird and uses Highlander F's skin materials,
514+
// but Midlander F's models. Blame SE hard-coding shit.
515+
if(node.Race == XivRace.Roegadyn_Female)
516+
{
517+
return XivRace.Hyur_Highlander_Female;
518+
}
519+
513520
if (node.HasSkin)
514521
{
515522
return node.Race;

xivModdingFramework/General/GameInfo.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ public class GameInfo
3030
public DirectoryInfo GameDirectory { get; }
3131

3232

33+
// These Lumina settings live here mostly for convenience, as they also should not be highly changeable data.
34+
// In the future, it may make sense to move them into the SQL metadata cache, but for now this is a more known-stable place to keep them.
35+
36+
/// <summary>
37+
/// Lumina output directory.
38+
/// </summary>
39+
public DirectoryInfo LuminaDirectory { get; }
40+
41+
/// <summary>
42+
/// Should mod output be redirected to Lumina?
43+
/// </summary>
44+
public bool UseLumina { get; }
45+
46+
3347
/// <summary>
3448
/// The current version of the game.
3549
/// </summary>
@@ -49,11 +63,13 @@ public class GameInfo
4963
/// </summary>
5064
/// <param name="gameDirectory">The directory in which the game is installed.</param>
5165
/// <param name="xivLanguage">The language to use when parsing the game data.</param>
52-
public GameInfo(DirectoryInfo gameDirectory, XivLanguage xivLanguage, int dxMode = 11)
66+
public GameInfo(DirectoryInfo gameDirectory, XivLanguage xivLanguage, int dxMode = 11, DirectoryInfo luminaDirectory = null, bool useLumina = false)
5367
{
5468
GameDirectory = gameDirectory;
5569
GameLanguage = xivLanguage;
5670
GameVersion = GetGameVersion();
71+
LuminaDirectory = luminaDirectory;
72+
UseLumina = useLumina;
5773
DxMode = dxMode;
5874

5975
if (!gameDirectory.FullName.Contains(Path.Combine("game", "sqpack", "ffxiv")))

xivModdingFramework/HUD/FileTypes/Uld.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
using xivModdingFramework.Helpers;
2626
using xivModdingFramework.SqPack.FileTypes;
2727

28+
using Index = xivModdingFramework.SqPack.FileTypes.Index;
29+
2830
namespace xivModdingFramework.HUD.FileTypes
2931
{
3032
/// <summary>

xivModdingFramework/Helpers/ProblemChecker.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
using xivModdingFramework.Resources;
2626
using xivModdingFramework.Cache;
2727

28+
using Index = xivModdingFramework.SqPack.FileTypes.Index;
29+
2830
namespace xivModdingFramework.Helpers
2931
{
3032
public class ProblemChecker
@@ -333,6 +335,7 @@ public Task<bool> RestoreBackups(DirectoryInfo backupsDirectory)
333335
}
334336
}
335337

338+
var _index = new Index(_gameDirectory);
336339
// Make sure backups exist and are up to date unless called with forceRestore true
337340
if (backupFiles.Length != 0 && !outdated)
338341
{
@@ -344,6 +347,9 @@ public Task<bool> RestoreBackups(DirectoryInfo backupsDirectory)
344347
File.Copy(backupFile, $"{_gameDirectory}/{Path.GetFileName(backupFile)}", true);
345348
}
346349
}
350+
351+
// Update all the index counts to be safe, in case the user's index backups were generated when some mod dats existed.
352+
_index.UpdateAllIndexDatCounts();
347353
return true;
348354
}
349355
return false;

xivModdingFramework/Items/Categories/Character.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ public async Task<List<string>> GetDecalPaths(XivDecalType type)
588588

589589
for (int i = 0; i < decalMax; i++)
590590
{
591-
var file = string.Format(XivStrings.EquipDecalFile, i);
591+
var file = string.Format(XivStrings.EquipDecalFile, i.ToString().PadLeft(3, '0'));
592592

593593
if (fileList.Contains(HashGenerator.GetHash(file)))
594594
{

xivModdingFramework/Items/Categories/Gear.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
using xivModdingFramework.Textures.Enums;
3737
using xivModdingFramework.Variants.FileTypes;
3838

39+
using Index = xivModdingFramework.SqPack.FileTypes.Index;
40+
3941
namespace xivModdingFramework.Items.Categories
4042
{
4143
/// <summary>
@@ -70,16 +72,20 @@ public async Task<List<XivGear>> GetUnCachedGearList()
7072
// These are the offsets to relevant data
7173
// These will need to be changed if data gets added or removed with a patch
7274
const int modelDataCheckOffset = 30;
73-
int dataLength = 160;
75+
int dataLength = 168;
7476
const int nameDataOffset = 14;
7577
const int modelDataOffset = 24;
7678
const int iconDataOffset = 136;
77-
int slotDataOffset = 154;
79+
int slotDataOffset = 156;
7880

79-
if(_xivLanguage == XivLanguage.Chinese || _xivLanguage == XivLanguage.Korean)
81+
if( _xivLanguage == XivLanguage.Korean)
82+
{
83+
dataLength = 160;
84+
slotDataOffset = 154;
85+
} else if (_xivLanguage == XivLanguage.Chinese)
8086
{
81-
dataLength = 168;
82-
slotDataOffset = 156;
87+
dataLength = 160;
88+
slotDataOffset = 154;
8389
}
8490

8591
var xivGearList = new List<XivGear>();

0 commit comments

Comments
 (0)