Skip to content

Commit afc5b8c

Browse files
committed
- Added Colorset Highlight for Model Viewing.
- Bugfixes for Enable/Disable button not being turned on when using Colorset Editor.
1 parent d0d3b36 commit afc5b8c

File tree

1 file changed

+49
-11
lines changed

1 file changed

+49
-11
lines changed

xivModdingFramework/Models/ModelTextures/ModelTexture.cs

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@ public static CustomModelColors GetCustomColors()
116116
/// <param name="mtrl"></param>
117117
/// <param name="colors"></param>
118118
/// <returns></returns>
119-
public static async Task<ModelTextureData> GetModelMaps(DirectoryInfo gameDirectory, XivMtrl mtrl, CustomModelColors colors = null)
119+
public static async Task<ModelTextureData> GetModelMaps(DirectoryInfo gameDirectory, XivMtrl mtrl, CustomModelColors colors = null, int highlightedRow = -1)
120120
{
121121
var tex = new Tex(gameDirectory);
122-
return await GetModelMaps(tex, mtrl);
122+
return await GetModelMaps(tex, mtrl, colors, highlightedRow);
123123
}
124124

125125
/// <summary>
126126
/// Gets the texture maps for the model
127127
/// </summary>
128128
/// <returns>The texture maps in byte arrays inside a ModelTextureData class</returns>
129-
public static async Task<ModelTextureData> GetModelMaps(Tex tex, XivMtrl mtrl, CustomModelColors colors = null)
129+
public static async Task<ModelTextureData> GetModelMaps(Tex tex, XivMtrl mtrl, CustomModelColors colors = null, int highlightedRow = -1)
130130
{
131131

132132
// Use static values as needed.
@@ -233,7 +233,7 @@ await Task.Run(() =>
233233
{
234234
var cs = texMapData.ColorSet.Data;
235235
Color finalDiffuseColor, finalSpecularColor;
236-
ComputeColorsetBlending(mtrl, colorsetValue, cs, diffuseColor, specularColor, out finalDiffuseColor, out finalSpecularColor, out emissiveColor);
236+
ComputeColorsetBlending(mtrl, colorsetValue, cs, diffuseColor, specularColor, out finalDiffuseColor, out finalSpecularColor, out emissiveColor, highlightedRow);
237237
diffuseColor = finalDiffuseColor;
238238
specularColor = finalSpecularColor;
239239
}
@@ -644,7 +644,7 @@ private static void ComputeShaderColors(CustomModelColors colors, ShaderInfo in
644644
}
645645
}
646646

647-
private static void ComputeColorsetBlending(XivMtrl mtrl, byte colorsetByte, byte[] colorSetData, Color baseDiffuse, Color baseSpecular, out Color newDiffuse, out Color newSpecular, out Color emissiveColor)
647+
private static void ComputeColorsetBlending(XivMtrl mtrl, byte colorsetByte, byte[] colorSetData, Color baseDiffuse, Color baseSpecular, out Color newDiffuse, out Color newSpecular, out Color emissiveColor, int highlightRow = -1)
648648
{
649649
int rowNumber = colorsetByte / 17;
650650
int nextRow = rowNumber >= 15 ? 15 : rowNumber + 1;
@@ -659,14 +659,52 @@ private static void ComputeColorsetBlending(XivMtrl mtrl, byte colorsetByte, byt
659659
var row1Offset = Clamp(rowNumber * 16);
660660
var row2Offset = Clamp(nextRow * 16);
661661

662-
diffuse1 = new Color(colorSetData[row1Offset + 0], colorSetData[row1Offset + 1], colorSetData[row1Offset + 2], (byte)255);
663-
diffuse2 = new Color(colorSetData[row2Offset + 0], colorSetData[row2Offset + 1], colorSetData[row2Offset + 2], (byte)255);
662+
if (highlightRow >= 0)
663+
{
664+
if (rowNumber == highlightRow)
665+
{
666+
diffuse1 = new Color((byte)255, (byte)255, (byte)255, (byte)255);
667+
diffuse2 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
668+
669+
spec1 = new Color((byte)255, (byte)255, (byte)255, (byte)255);
670+
spec2 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
664671

665-
spec1 = new Color(colorSetData[row1Offset + 4], colorSetData[row1Offset + 5], colorSetData[row1Offset + 6], (byte)255);
666-
spec2 = new Color(colorSetData[row2Offset + 4], colorSetData[row2Offset + 5], colorSetData[row2Offset + 6], (byte)255);
672+
emiss1 = new Color((byte)255, (byte)255, (byte)255, (byte)255);
673+
emiss2 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
674+
}
675+
else if (nextRow == highlightRow)
676+
{
677+
diffuse1 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
678+
diffuse2 = new Color((byte)255, (byte)255, (byte)255, (byte)255);
679+
680+
spec1 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
681+
spec2 = new Color((byte)255, (byte)255, (byte)255, (byte)255);
682+
683+
emiss1 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
684+
emiss2 = new Color((byte)255, (byte)255, (byte)255, (byte)255);
685+
} else
686+
{
687+
diffuse1 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
688+
diffuse2 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
667689

668-
emiss1 = new Color(colorSetData[row1Offset + 8], colorSetData[row1Offset + 9], colorSetData[row1Offset + 10], (byte)255);
669-
emiss2 = new Color(colorSetData[row2Offset + 8], colorSetData[row2Offset + 9], colorSetData[row2Offset + 10], (byte)255);
690+
spec1 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
691+
spec2 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
692+
693+
emiss1 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
694+
emiss2 = new Color((byte)0, (byte)0, (byte)0, (byte)255);
695+
}
696+
}
697+
else
698+
{
699+
diffuse1 = new Color(colorSetData[row1Offset + 0], colorSetData[row1Offset + 1], colorSetData[row1Offset + 2], (byte)255);
700+
diffuse2 = new Color(colorSetData[row2Offset + 0], colorSetData[row2Offset + 1], colorSetData[row2Offset + 2], (byte)255);
701+
702+
spec1 = new Color(colorSetData[row1Offset + 4], colorSetData[row1Offset + 5], colorSetData[row1Offset + 6], (byte)255);
703+
spec2 = new Color(colorSetData[row2Offset + 4], colorSetData[row2Offset + 5], colorSetData[row2Offset + 6], (byte)255);
704+
705+
emiss1 = new Color(colorSetData[row1Offset + 8], colorSetData[row1Offset + 9], colorSetData[row1Offset + 10], (byte)255);
706+
emiss2 = new Color(colorSetData[row2Offset + 8], colorSetData[row2Offset + 9], colorSetData[row2Offset + 10], (byte)255);
707+
}
670708

671709

672710
// These are now our base values to multiply the base values by.

0 commit comments

Comments
 (0)