Skip to content

Commit ccb4e5f

Browse files
committed
Initial working pass on Colorset Editor.
1 parent 241d661 commit ccb4e5f

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

xivModdingFramework/Materials/DataContainers/XivMtrl.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class XivMtrl
6262
/// </remarks>
6363
public ushort ColorSetDataSize { get {
6464
var size = ColorSetData.Count * 2;
65-
size += ColorSetExtraData == null ? 0 : ColorSetExtraData.Length;
65+
size += ColorSetDyeData == null ? 0 : ColorSetDyeData.Length;
6666
return (ushort) size;
6767
} }
6868

@@ -168,7 +168,7 @@ public ushort ColorSetDataSize { get {
168168
/// <summary>
169169
/// The byte array containing the extra ColorSet data
170170
/// </summary>
171-
public byte[] ColorSetExtraData { get; set; }
171+
public byte[] ColorSetDyeData { get; set; }
172172

173173
/// <summary>
174174
/// The size of the additional MTRL Data
@@ -534,17 +534,17 @@ public void SetShaderInfo(ShaderInfo info, bool forced = false)
534534
// ColorSetCount seems to always be 1, even when the data is empty.
535535
ColorSetCount = 1;
536536
ColorSetData = new List<Half>();
537-
ColorSetExtraData = null;
537+
ColorSetDyeData = null;
538538
} else
539539
{
540540
if(ColorSetCount == 0 || ColorSetData == null || ColorSetData.Count != 256)
541541
{
542542
// Get default Colorset Data.
543543
ColorSetData = Tex.GetColorsetDataFromDDS(Tex.GetDefaultTexturePath(XivTexType.ColorSet));
544544
}
545-
if(ColorSetExtraData == null || ColorSetExtraData.Length != 32)
545+
if(ColorSetDyeData == null || ColorSetDyeData.Length != 32)
546546
{
547-
ColorSetExtraData = Tex.GetColorsetExtraDataFromDDS(Tex.GetDefaultTexturePath(XivTexType.ColorSet));
547+
ColorSetDyeData = Tex.GetColorsetExtraDataFromDDS(Tex.GetDefaultTexturePath(XivTexType.ColorSet));
548548
}
549549
}
550550

xivModdingFramework/Materials/FileTypes/Mtrl.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ await Task.Run((Func<Task>)(async () =>
542542
xivMtrl.Unknown2 = br.ReadBytes(xivMtrl.UnknownDataSize);
543543

544544
xivMtrl.ColorSetData = new List<Half>();
545-
xivMtrl.ColorSetExtraData = null;
545+
xivMtrl.ColorSetDyeData = null;
546546
if (colorSetDataSize > 0)
547547
{
548548
// Color Data is always 512 (6 x 14 = 64 x 8bpp = 512)
@@ -556,7 +556,7 @@ await Task.Run((Func<Task>)(async () =>
556556
// If the color set is 544 in length, it has an extra 32 bytes at the end
557557
if (colorSetDataSize == 544)
558558
{
559-
xivMtrl.ColorSetExtraData = br.ReadBytes(32);
559+
xivMtrl.ColorSetDyeData = br.ReadBytes(32);
560560
}
561561
}
562562

@@ -681,7 +681,7 @@ public Task<XivTex> MtrlToXivTex(XivMtrl xivMtrl, TexTypePath ttp)
681681
/// <param name="race">The selected race for the item</param>
682682
public void SaveColorSetExtraData(IItem item, XivMtrl xivMtrl, DirectoryInfo saveDirectory, XivRace race)
683683
{
684-
var toWrite = xivMtrl.ColorSetExtraData != null ? xivMtrl.ColorSetExtraData : new byte[32];
684+
var toWrite = xivMtrl.ColorSetDyeData != null ? xivMtrl.ColorSetDyeData : new byte[32];
685685
var path = IOUtil.MakeItemSavePath(item, saveDirectory, race);
686686

687687
Directory.CreateDirectory(path);
@@ -868,7 +868,7 @@ public byte[] CreateMtrlFile(XivMtrl xivMtrl, IItem item)
868868

869869
if (xivMtrl.ColorSetDataSize == 544)
870870
{
871-
mtrlBytes.AddRange(xivMtrl.ColorSetExtraData);
871+
mtrlBytes.AddRange(xivMtrl.ColorSetDyeData);
872872
}
873873

874874

xivModdingFramework/Materials/FileTypes/STM.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static async Task<StainingTemplateFile> GetStainingTemplateFile(bool forc
4040

4141
public static async Task SaveStainingTemplateFile(StainingTemplateFile file, string applicationSource, IndexFile index = null, ModList modlist = null)
4242
{
43+
throw new NotImplementedException();
4344
var data = new byte[0];//file.GetBytes();
4445

4546
var _dat = new Dat(XivCache.GameInfo.GameDirectory);
@@ -64,19 +65,11 @@ public enum StainingTemplateArrayType
6465

6566
public class StainingTemplateEntry
6667
{
67-
public int Size
68-
{
69-
get
70-
{
71-
return 0;
72-
}
73-
}
74-
75-
List<Half[]> DiffuseEntries = new List<Half[]>();
76-
List<Half[]> SpecularEntries = new List<Half[]>();
77-
List<Half[]> EmissiveEntries = new List<Half[]>();
78-
List<Half> TileMaterialEntries = new List<Half>();
79-
List<Half> GlossEntries = new List<Half>();
68+
public readonly List<Half[]> DiffuseEntries = new List<Half[]>();
69+
public readonly List<Half[]> SpecularEntries = new List<Half[]>();
70+
public readonly List<Half[]> EmissiveEntries = new List<Half[]>();
71+
public readonly List<Half> TileMaterialEntries = new List<Half>();
72+
public readonly List<Half> GlossEntries = new List<Half>();
8073

8174
public StainingTemplateEntry(byte[] data, int offset)
8275
{
@@ -243,7 +236,11 @@ public void SetTemplate(ushort key, StainingTemplateEntry entry)
243236
}
244237
public StainingTemplateEntry GetTemplate(ushort key)
245238
{
246-
return Templates[key];
239+
if (Templates.ContainsKey(key))
240+
{
241+
return Templates[key];
242+
}
243+
return null;
247244
}
248245
public StainingTemplateFile(byte[] data)
249246
{

xivModdingFramework/Textures/FileTypes/Tex.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ public async Task<long> TexColorImporter(XivMtrl xivMtrl, DirectoryInfo ddsFileD
882882

883883
// Replace the color set data with the imported data
884884
xivMtrl.ColorSetData = colorSetData;
885-
xivMtrl.ColorSetExtraData = colorSetExtraData;
885+
xivMtrl.ColorSetDyeData = colorSetExtraData;
886886
if (xivMtrl.Unknown2.Length > 0)
887887
{
888888
// This byte enables the dye set if it's not already enabled.
@@ -994,7 +994,7 @@ public byte[] DDStoMtrlData(XivMtrl xivMtrl, DirectoryInfo ddsFileDirectory, IIt
994994

995995
// Replace the color set data with the imported data
996996
xivMtrl.ColorSetData = colorSetData;
997-
xivMtrl.ColorSetExtraData = colorSetExtraData;
997+
xivMtrl.ColorSetDyeData = colorSetExtraData;
998998

999999
if (xivMtrl.Unknown2.Length > 0)
10001000
{

0 commit comments

Comments
 (0)