From 03949091952ba52e46b7ad7d83fd903f56198393 Mon Sep 17 00:00:00 2001
From: FCGudder <-@->
Date: Thu, 3 Aug 2017 23:03:47 +0200
Subject: [PATCH] Adding custom hair vector field (issue #3)

---
 slave variables documentation - Pregmod.txt | 21 +++++++++++++++++----
 src/init/dummy.tw                           |  2 +-
 src/uncategorized/addCustomDescriptors.tw   | 13 ++++++++++++-
 src/utility/artWidgets.tw                   |  8 ++++++--
 4 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/slave variables documentation - Pregmod.txt b/slave variables documentation - Pregmod.txt
index 259dcf0f983..f16faca7be2 100644
--- a/slave variables documentation - Pregmod.txt	
+++ b/slave variables documentation - Pregmod.txt	
@@ -760,7 +760,7 @@ accepts string
 "braided"
 "dreadlocks"
 "permed"
-"curled"
+"curls"
 "luxurious"
 "bald"
 
@@ -915,7 +915,7 @@ accepts string
 
 nipplesPiercing:
 
-nipple are pierced
+nipple are peirced
 0 - none
 1 - yes
 2 - heavily
@@ -2091,7 +2091,21 @@ Does this slave refer to you rudely?
 
 customImage:
 
-hold custom img link?
+holds the custom slave image file name (used if images are enabled)
+accepts string
+default 0 (no custom image)
+
+customImageFormat:
+
+holds the custom slave image file format.
+one of "png", "jpg", "gif" or "webm"
+default "png"
+
+customHairVector:
+
+holds the custom hair vector base file name (used if vector images are enabled)
+accepts string
+default 0 (use hardcoded hair styles)
 
 currentRules: []
 
@@ -2174,7 +2188,6 @@ Slave's internals have ruptured. Used with poor health and overinflation.
 bellyImplant:
 
 Does the slave have a fillable abdominal implant.
--1	no
 0+ 	yes
 2000+ 	Early pregnancy
 4000+	looks pregnant
diff --git a/src/init/dummy.tw b/src/init/dummy.tw
index 49de2bb24ce..ef8aca46adc 100644
--- a/src/init/dummy.tw
+++ b/src/init/dummy.tw
@@ -21,7 +21,7 @@ $belarusianSlaveNames, $dominicanSlaveNames, $scottishSlaveNames
 $ArcologyNamesEugenics, $ArcologyNamesRepopulationist, $ArcologyNamesHedonisticDecadence
 $hare1, $hare2, $hare3, $hareSpeed, $hareSpeed1, $hareSpeed2, $hareSpeed3, $origin1, $origin2, $origin3, $LurcherSpeed
 $$i
-$activeSlave.bodySwap, $activeSlave.customImageFormat
+$activeSlave.bodySwap, $activeSlave.customImageFormat, $activeSlave.customHairVector
 $drugs
 $PC.origRace, $PC.origSkin
 */
diff --git a/src/uncategorized/addCustomDescriptors.tw b/src/uncategorized/addCustomDescriptors.tw
index a00876ec992..8ee47b6f472 100644
--- a/src/uncategorized/addCustomDescriptors.tw
+++ b/src/uncategorized/addCustomDescriptors.tw
@@ -155,4 +155,15 @@ jQuery(function() {
 			jQuery("#customImageFormatValue").text(this.value);
 		});
 });
-<</script>>
\ No newline at end of file
+<</script>>
+<<if $seeImages == 1 && $imageChoice == 1>>
+	<br><br>
+	<<if ndef $activeSlave.customHairVector>><<set $activeSlave.customHairVector = 0>><</if>>
+	Assign her a custom hair SVG image:
+	<<if $activeSlave.customHairVector != 0>>
+		<<textbox "$activeSlave.customHairVector" $activeSlave.customHairVector "Add custom descriptors">>
+	<<else>>
+		<<textbox "$activeSlave.customHairVector" "" "Add custom descriptors">>
+	<</if>>
+	<<link "Reset">><<set $activeSlave.customHairVector = 0>><<goto "Add custom descriptors">><</link>>
+<</if>>
\ No newline at end of file
diff --git a/src/utility/artWidgets.tw b/src/utility/artWidgets.tw
index 8202cc0a42c..4bd2721427e 100644
--- a/src/utility/artWidgets.tw
+++ b/src/utility/artWidgets.tw
@@ -50,7 +50,7 @@ $args[2]: icon UI Display for vector art, 1 for on.
 %/
 <<widget "SlaveArt">>
 /* This is a nasty workaround for Chrome not rendering overlaid SVG images properly */
-<<run setTimeout(function() { jQuery('.imageRef').fadeTo(1, 0.999); }, 1000)>>
+<<run jQuery(function() { jQuery('.imageRef').imagesLoaded().always(function() { jQuery('.imageRef').fadeTo(1, 0.999); }); })>>
 <<if ndef $args[0].customImage>><<set $args[0].customImage = 0>><</if>>
 <<if $args[0].customImage != 0>>
 
@@ -88,7 +88,11 @@ $args[2]: icon UI Display for vector art, 1 for on.
 <<set _hairFilter = "filter: url(#hair-" + _.kebabCase($args[0].hColor) + ");">>
 <<set _pubesFilter = "filter: url(#hair-" + _.kebabCase($args[0].pubicHColor) + ");">>
 <<set _axillaryFilter = "filter: url(#hair-" + _.kebabCase($args[0].underArmHColor) + ");">>
-<<set _hairStyle = ["neat", "ponytail", "messy"].includes($args[0].hStyle) ? $args[0].hStyle : "neat">>
+<<if $args[0].customHairVector>>
+	<<set _hairStyle = $args[0].customHairVector>>
+<<else>>
+	<<set _hairStyle = ["neat", "ponytail", "messy"].includes($args[0].hStyle) ? $args[0].hStyle : "neat">>
+<</if>>
 
 <<set _imgSkinLoc = _folderLoc + "/body/white">>
 
-- 
GitLab