Skip to content

Commit 4a99986

Browse files
authored
Fix loading detail from presets and make backwards compatible (#6)
1 parent a913830 commit 4a99986

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

Source/TexturesUnlimited/Addon/TexturesUnlimitedLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ public RecoloringDataPreset(ConfigNode node)
797797

798798
public RecoloringData getRecoloringData()
799799
{
800-
return new RecoloringData(color, specular, metallic, 1);
800+
return new RecoloringData(color, specular, metallic, detail);
801801
}
802802
}
803803

Source/TexturesUnlimited/GUI/CraftRecolorGUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ private void drawPresetColorArea()
453453
bStr = (editingColor.color.b * 255f).ToString("F0");
454454
aStr = (editingColor.specular * 255f).ToString("F0");
455455
mStr = (editingColor.metallic * 255f).ToString("F0");
456-
//dStr = (editingColor.detail * 100f).ToString("F0");//leave detail mult as pre-specified value (user/config); it does not pull from preset colors at all
456+
dStr = (editingColor.detail * 100f).ToString("F0");
457457
update = true;
458458
}
459459
GUI.color = old;

Source/TexturesUnlimited/Util/Utils.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,13 @@ public static Color GetColor(this ConfigNode node, string name)
486486
public static float GetColorChannelValue(this ConfigNode node, string name)
487487
{
488488
string value = node.GetStringValue(name).Trim();
489+
490+
// Detail was not included in presets originally, so on old presets GetStringValue will return "", which will default to 0.
491+
// Default to 1 instead if trying to access detail, which results in a default detail of 100, as before.
492+
493+
if (value == "" && name == "detail")
494+
return 1f;
495+
489496
float floatValue = safeParseFloat(value);
490497
if (value.Contains(".")) { return floatValue; }
491498
if (name == "detail") { return floatValue / 100; }

0 commit comments

Comments
 (0)