From ff7ad783806e32778b1dcc78465827f4964dac0d Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Wed, 17 Jun 2020 18:49:09 -0700
Subject: [PATCH] Custom label stuff

---
 .../nursery/widgets/children/childSummary.js  |  2 +-
 .../widgets/children/longChildDescription.js  |  4 +--
 .../widgets/infants/longInfantDescription.js  |  4 +--
 src/facilities/statistics.css                 |  7 +----
 src/facilities/statistics.js                  | 29 +++++++++++++++----
 src/gui/css/mainStyleSheet.css                |  5 ++++
 src/js/slaveSummaryWidgets.js                 |  2 +-
 src/npc/descriptions/longSlave.js             |  2 +-
 8 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/src/facilities/nursery/widgets/children/childSummary.js b/src/facilities/nursery/widgets/children/childSummary.js
index 10fa981d65c..8a0322fc34b 100644
--- a/src/facilities/nursery/widgets/children/childSummary.js
+++ b/src/facilities/nursery/widgets/children/childSummary.js
@@ -224,7 +224,7 @@ App.Facilities.Nursery.ChildSummary = function(child) {
 			longSexQuirk(child);
 		}
 		if (child.custom.label) {
-			r += `<strong><span class="yellow">${capFirstChar(child.custom.label)}</span></strong> `;
+			r += `<span class="custom-label">${capFirstChar(child.custom.label)}</span> `;
 		}
 		if ((child.relationship !== 0) || (abbreviate.clothes === 2) || (abbreviate.rulesets === 2)) {
 			r += `<br> `;
diff --git a/src/facilities/nursery/widgets/children/longChildDescription.js b/src/facilities/nursery/widgets/children/longChildDescription.js
index 66ca127dd85..78e5d86fc11 100644
--- a/src/facilities/nursery/widgets/children/longChildDescription.js
+++ b/src/facilities/nursery/widgets/children/longChildDescription.js
@@ -6066,10 +6066,10 @@ App.Facilities.Nursery.LongChildDescription = function(child, {market = 0, event
 
 	r += `&nbsp;&nbsp;&nbsp;&nbsp; `;
 
-	r += `<span id="childName"><strong><span class="pink">${SlaveFullName(child)}</span></strong></span> `;
+	r += `<span id="childName" class="slave name simple">${SlaveFullName(child)}</span> `;
 
 	if (child.custom.label) {
-		r += ` (<strong><span class="yellow">${child.custom.label}</span></strong>) `;
+		r += ` (<span class="custom-label">${child.custom.label}</span>) `;
 	}
 
 	r += ` is `;
diff --git a/src/facilities/nursery/widgets/infants/longInfantDescription.js b/src/facilities/nursery/widgets/infants/longInfantDescription.js
index 47303ce6e87..f229127e0f3 100644
--- a/src/facilities/nursery/widgets/infants/longInfantDescription.js
+++ b/src/facilities/nursery/widgets/infants/longInfantDescription.js
@@ -55,11 +55,11 @@ App.Facilities.Nursery.LongInfantDescription = function(child, {market = 0, even
 
 	r += `&nbsp;&nbsp;&nbsp;&nbsp; `;
 
-	r += `<span id="childName"><strong><span class="pink">${SlaveFullName(child)}</span></strong></span> `;
+	r += `<span id="childName" class="slave name simple">${SlaveFullName(child)}</span> `;
 
 	if (jsDef(child.custom)) {
 		if (child.custom.label) {
-			r += ` (<strong><span class="yellow">${child.custom.label}</span></strong>) `;
+			r += ` (<span class="custom-label">${child.custom.label}</span>) `;
 		}
 	}
 
diff --git a/src/facilities/statistics.css b/src/facilities/statistics.css
index ff051f66e5d..91320c60544 100644
--- a/src/facilities/statistics.css
+++ b/src/facilities/statistics.css
@@ -22,11 +22,6 @@ table.stats > tr > th.wide {
 	text-align: right;
 }
 
-table.stats > tr > td.value {
-	padding-right: 3px;
-	text-align: right;
-}
-
 table.stats-slave {
 	width: 100%;
 	font-size: 90%;
@@ -50,7 +45,7 @@ table.stats-slave > tr > th.wide {
 	text-align: right;
 }
 
-table.stats-slave > tr > td.value {
+td.value {
 	padding-right: 3px;
 	text-align: right;
 }
diff --git a/src/facilities/statistics.js b/src/facilities/statistics.js
index 19cd4a92d32..4343717cc4c 100644
--- a/src/facilities/statistics.js
+++ b/src/facilities/statistics.js
@@ -18,7 +18,7 @@ App.Facilities.StatsHelper = class {
 
 	/** Adds a value row to a stats table, with the given label and value cells
 	 * @param {HTMLTableElement} table
-	 * @param {string} label
+	 * @param {string|Node} label
 	 * @param {HTMLTableCellElement[]} valueCells
 	 * @param {boolean} [totals]
 	 */
@@ -33,6 +33,23 @@ App.Facilities.StatsHelper = class {
 		}
 	}
 
+	/** Makes a slave label
+	 * @param {string} slaveName
+	 * @param {string} customLabel
+	 * @returns {Node}
+	 */
+	makeSlaveLabel(slaveName, customLabel) {
+		if (!customLabel) {
+			return document.createTextNode(slaveName);
+		} else {
+			const frag = document.createDocumentFragment();
+			const label = App.UI.DOM.appendNewElement("span", frag, `(${customLabel}) `, "custom-label");
+			frag.appendChild(label);
+			frag.appendChild(document.createTextNode(slaveName));
+			return frag;
+		}
+	}
+
 	/** Makes a value cell
 	 * @param {string} type - "reputation" or "cash"
 	 * @param {number} value - numeric value
@@ -212,7 +229,7 @@ App.Facilities.Brothel.Stats = (function() {
 			for (const record of b.income.values()) {
 				const revenue = record.income + record.adsIncome;
 				const netIncome = revenue - record.cost;
-				H.addValueRow(slaveStats, record.slaveName, [
+				H.addValueRow(slaveStats, H.makeSlaveLabel(record.slaveName, record.customLabel), [
 					H.makeCustomersCell(record.customers),
 					makeRevenueCell(revenue, record.adsIncome),
 					H.makeValueCell("cash", record.cost, {forceNeg: true}),
@@ -311,7 +328,7 @@ App.Facilities.Club.Stats = (function() {
 			const slaveStats = H.makeSlaveStatsTable(stats, "Public slut details", ["Slut", "Customers", "Rep. Gain", "Expenses", "Rep/Expenses", "Extra Income"]);
 			for (const record of b.income.values()) {
 				const netIncome = record.income / record.cost;
-				H.addValueRow(slaveStats, record.slaveName, [
+				H.addValueRow(slaveStats, H.makeSlaveLabel(record.slaveName, record.customLabel), [
 					H.makeCustomersCell(record.customers),
 					H.makeValueCell("reputation", record.income, {showSign: true, showZero: true}),
 					H.makeValueCell("cash", record.cost, {forceNeg: true}),
@@ -393,7 +410,7 @@ App.Facilities.Arcade.Stats = (function() {
 			for (const record of b.income.values()) {
 				const revenue = record.income + record.adsIncome;
 				const netIncome = revenue - record.cost;
-				H.addValueRow(slaveStats, record.slaveName, [
+				H.addValueRow(slaveStats, H.makeSlaveLabel(record.slaveName, record.customLabel), [
 					H.makeCustomersCell(record.customers),
 					H.makeValueCell("cash", revenue),
 					H.makeValueCell("cash", record.cost, {forceNeg: true}),
@@ -458,7 +475,7 @@ App.Facilities.Dairy.Stats = (function() {
 			const slaveStats = H.makeSlaveStatsTable(stats, "Cow details", ["Cow", "Milk/Cum/Fluids", "Revenue", "Expenses", "Net Income", "Rep. Change"]);
 			for (const record of b.income.values()) {
 				const netIncome = record.income - record.cost;
-				H.addValueRow(slaveStats, record.slaveName, [
+				H.addValueRow(slaveStats, H.makeSlaveLabel(record.slaveName, record.customLabel), [
 					H.makeProductionCell(record.milk, record.cum, record.fluid),
 					H.makeValueCell("cash", record.income),
 					H.makeValueCell("cash", record.cost, {forceNeg: true}),
@@ -523,7 +540,7 @@ App.Facilities.Farmyard.Stats = (function() {
 			const slaveStats = H.makeSlaveStatsTable(stats, "Farmhand details", ["Farmhand", "Milk/Cum/Fluids", "Revenue", "Expenses", "Net Income", "Rep. Change"]);
 			for (const record of b.income.values()) {
 				const netIncome = record.income - record.cost;
-				H.addValueRow(slaveStats, record.slaveName, [
+				H.addValueRow(slaveStats, H.makeSlaveLabel(record.slaveName, record.customLabel), [
 					H.makeProductionCell(record.milk, record.cum, record.fluid),
 					H.makeValueCell("cash", record.income),
 					H.makeValueCell("cash", record.cost, {forceNeg: true}),
diff --git a/src/gui/css/mainStyleSheet.css b/src/gui/css/mainStyleSheet.css
index e380ff8791f..47af08439aa 100644
--- a/src/gui/css/mainStyleSheet.css
+++ b/src/gui/css/mainStyleSheet.css
@@ -355,6 +355,11 @@ div.double-choices, p.double-choices {
 	font-weight: bold;
 }
 
+.custom-label {
+	color: yellow;
+	font-weight: bold;
+}
+
 div.cheat-menu {
 	font-style: italic;
 	position: absolute;
diff --git a/src/js/slaveSummaryWidgets.js b/src/js/slaveSummaryWidgets.js
index 748d642bc29..e0adc5cbe33 100644
--- a/src/js/slaveSummaryWidgets.js
+++ b/src/js/slaveSummaryWidgets.js
@@ -931,7 +931,7 @@ App.UI.SlaveSummary = function() {
 		delegates.skills(slave, para);
 		delegates.mental(slave, para);
 		if (slave.custom.label) {
-			helpers.makeSpan(res, `${capFirstChar(slave.custom.label)}.`, ["yellow", "strong"]);
+			helpers.makeSpan(res, `${capFirstChar(slave.custom.label)}.`, ["custom-label"]);
 		}
 		if ((slave.relationship !== 0) || (slave.relationship !== 0) || (abbrSettings.clothes === 2) || (abbrSettings.rulesets === 2)) {
 			para = helpers.makeParagraph(res);
diff --git a/src/npc/descriptions/longSlave.js b/src/npc/descriptions/longSlave.js
index 1dfe8a00ec7..aebac2d7193 100644
--- a/src/npc/descriptions/longSlave.js
+++ b/src/npc/descriptions/longSlave.js
@@ -42,7 +42,7 @@ App.Desc.longSlave = function(slave = V.activeSlave, {market = 0, eventDescripti
 		frag = new DocumentFragment();
 		frag.append("(");
 		span = document.createElement('span');
-		span.style.fontWeight = "bold";
+		span.classList.add("custom-label");
 		span.textContent = slave.custom.label;
 		frag.append(span);
 		frag.append(") ");
-- 
GitLab