Skip to content

Commit 3af17e1

Browse files
committed
Introduction of framework constants class. Some cleanup of MTRL filename functions.
1 parent c2b9afd commit 3af17e1

File tree

7 files changed

+298
-93
lines changed

7 files changed

+298
-93
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace xivModdingFramework.Helpers
6+
{
7+
// I'm not sure why we didn't have a constants class to refer to before, but oh well.
8+
public static class Constants
9+
{
10+
/// <summary>
11+
/// The alphabet. Now in character array form.
12+
/// </summary>
13+
public static readonly char[] Alphabet = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
14+
}
15+
}

xivModdingFramework/Items/Categories/Character.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public async Task<Dictionary<string, char[]>> GetTypePartForTextures(XivCharacte
234234
var file = "";
235235
var typeDict = HairSlotAbbreviationDictionary;
236236

237-
var parts = new[] { 'a', 'b', 'c', 'd', 'e', 'f' };
237+
var parts = Constants.Alphabet;
238238

239239
if (charaItem.ItemCategory == XivStrings.Hair)
240240
{
@@ -299,7 +299,7 @@ public async Task<char[]> GetPartForTextures(XivCharacter charaItem, XivRace rac
299299
var folder = "";
300300
var file = "";
301301

302-
var parts = new[] { 'a', 'b', 'c', 'd', 'e', 'f' };
302+
var parts = Constants.Alphabet;
303303

304304
if (charaItem.ItemCategory == XivStrings.Body)
305305
{

xivModdingFramework/Items/Categories/Companions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ await Task.Run(() => Parallel.ForEach(petModelIndexList, (petIndex) =>
346346

347347
public async Task<Dictionary<string, char[]>> GetDemiHumanMountTextureEquipPartList(IItemModel itemModel)
348348
{
349-
var parts = new[] { 'a', 'b', 'c', 'd', 'e', 'f' };
349+
var parts = Constants.Alphabet;
350350

351351
var equipPartDictionary = new Dictionary<string, char[]>();
352352

xivModdingFramework/Materials/FileTypes/Mtrl.cs

Lines changed: 183 additions & 88 deletions
Large diffs are not rendered by default.

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
using xivModdingFramework.SqPack.FileTypes;
3737
using BoundingBox = xivModdingFramework.Models.DataContainers.BoundingBox;
3838
using System.Diagnostics;
39+
using xivModdingFramework.Items.Categories;
3940

4041
namespace xivModdingFramework.Models.FileTypes
4142
{
@@ -64,6 +65,86 @@ public Mdl(DirectoryInfo gameDirectory, XivDataFile dataFile)
6465

6566
public byte[] MDLRawData { get; set; }
6667

68+
69+
/// <summary>
70+
/// Retrieves all items that share the same model.
71+
/// </summary>
72+
/// <param name="item"></param>
73+
/// <param name="language"></param>
74+
/// <returns></returns>
75+
public async Task<List<IItemModel>> GetSameModelList(IItemModel item, XivLanguage language = XivLanguage.English)
76+
{
77+
var sameModelItems = new List<IItemModel>();
78+
var gear = new Gear(_gameDirectory, language);
79+
var character = new Character(_gameDirectory, language);
80+
var companions = new Companions(_gameDirectory, language);
81+
var ui = new UI(_gameDirectory, language);
82+
var housing = new Housing(_gameDirectory, language);
83+
84+
if (item.Category.Equals(XivStrings.Gear))
85+
{
86+
87+
// Scan the gear list for anything using the same model ID and slot.
88+
sameModelItems.AddRange(
89+
(await gear.GetGearList())
90+
.Where(it =>
91+
it.ModelInfo.ModelID == item.ModelInfo.ModelID
92+
&& it.ItemCategory == item.ItemCategory).Select(it => it as IItemModel).ToList()
93+
);
94+
}
95+
else if (item.Category.Equals(XivStrings.Character))
96+
{
97+
98+
// Character models are assumed to have no shared models,
99+
// So return a copy of the original item.
100+
sameModelItems.Add(
101+
new XivGenericItemModel
102+
{
103+
Category = item.Category,
104+
ItemCategory = item.ItemCategory,
105+
ItemSubCategory = item.ItemSubCategory,
106+
ModelInfo = new XivModelInfo
107+
{
108+
Body = item.ModelInfo.Body,
109+
ModelID = item.ModelInfo.ModelID,
110+
ModelType = item.ModelInfo.ModelType,
111+
Variant = item.ModelInfo.Variant
112+
},
113+
Name = item.Name
114+
}
115+
as IItemModel
116+
);
117+
}
118+
//companions
119+
//sameModelItems.AddRange(
120+
// (await companions.GetMinionList())
121+
// .Where(it =>
122+
// it.ModelInfo.ModelID == _item.ModelInfo.ModelID
123+
// && it.ItemCategory == _item.ItemCategory).Select(it => it as IItemModel).ToList()
124+
//);
125+
//sameModelItems.AddRange(
126+
// (await companions.GetMountList())
127+
// .Where(it =>
128+
// it.ModelInfo.ModelID == _item.ModelInfo.ModelID
129+
// && it.ItemCategory == _item.ItemCategory).Select(it => it as IItemModel).ToList()
130+
//);
131+
//sameModelItems.AddRange(
132+
// (await companions.GetPetList())
133+
// .Where(it =>
134+
// it.ModelInfo.ModelID == _item.ModelInfo.ModelID
135+
// && it.ItemCategory == _item.ItemCategory).Select(it => it as IItemModel).ToList()
136+
//);
137+
//housing
138+
//sameModelItems.AddRange(
139+
// (await housing.GetFurnitureList())
140+
// .Where(it =>
141+
// it.ModelInfo.ModelID == _item.ModelInfo.ModelID
142+
// && it.ItemCategory == _item.ItemCategory).Select(it => it as IItemModel).ToList()
143+
//);
144+
return sameModelItems;
145+
}
146+
147+
67148
/// <summary>
68149
/// Gets the MDL Data given a model and race
69150
/// </summary>

xivModdingFramework/Textures/FileTypes/Tex.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public async Task<List<string>> GetTexturePartList(IItemModel itemModel, XivRace
222222
}
223223
}
224224

225-
var parts = new[] { 'a', 'b', 'c', 'd', 'e', 'f' };
225+
var parts = Constants.Alphabet;
226226
var race = xivRace.GetRaceCode();
227227

228228
string mtrlFolder = "", mtrlFile = "";

xivModdingFramework/Variants/FileTypes/Imc.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,22 @@ public Imc(DirectoryInfo gameDirectory, XivDataFile dataFile)
5353
/// <param name="item">The item to get the version for</param>
5454
/// <param name="modelInfo">The model info of the item</param>
5555
/// <returns>The XivImc Data</returns>
56-
public async Task<XivImc> GetImcInfo(IItemModel item, XivModelInfo modelInfo)
56+
public async Task<XivImc> GetImcInfo(IItemModel item, XivModelInfo modelInfo = null)
5757
{
5858
var xivImc = new XivImc();
5959

60+
// Set based on item if we don't have one provided directly.
61+
if(modelInfo == null)
62+
{
63+
modelInfo = item.ModelInfo;
64+
}
65+
66+
// If it's still null, error.
67+
if(modelInfo == null)
68+
{
69+
throw new NotSupportedException("Cannot get IMC info.");
70+
}
71+
6072
// These are the offsets to relevant data
6173
// These will need to be changed if data gets added or removed with a patch
6274
const int headerLength = 4;
@@ -90,6 +102,8 @@ public async Task<XivImc> GetImcInfo(IItemModel item, XivModelInfo modelInfo)
90102
throw new Exception($"Could not find offset for {imcPath.Folder}/{imcPath.File}");
91103
}
92104

105+
// This is changing a public GLOBAL variable in the IMC class.
106+
// This is begging to cause really awful to diagnose errors.
93107
ChangedType = true;
94108
}
95109
else

0 commit comments

Comments
 (0)