From 765ff14b51b2ea39886ffc0cb2301576a14828aa Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Sat, 7 Mar 2020 16:31:02 -0800 Subject: [PATCH] Use a dialog to display the event slave description instead of wedging it into the middle of the event text. --- src/js/utilsSC.js | 22 ++++++++++++++++++++++ src/uncategorized/reSlaveMarriage.tw | 2 +- src/utility/miscWidgets.tw | 28 ++-------------------------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/js/utilsSC.js b/src/js/utilsSC.js index 5e1e5008faf..c25ceb4cf6a 100644 --- a/src/js/utilsSC.js +++ b/src/js/utilsSC.js @@ -270,3 +270,25 @@ App.UI.disabledLink = function(link, reasons) { `<div class="tooltip"><ul>${reasons.map(e => `<li>${e}</li>`).join('')}</ul></div>`; return `<span class="textWithTooltip">${link}${tooltips}</span>`; }; + +/** + * Generates a link which shows a slave description dialog for a specified slave. + * Do not call from within another dialog. + * @param {App.Entity.SlaveState} slave + * @returns {string} link (in SC markup) + */ +App.UI.slaveDescriptionDialog = function(slave) { + function showDialog() { + const oldEventDescription = V.eventDescription; + V.eventDescription = 1; // should be easy enough to use this for non-event cases too, but you'll need to fix the art display + const oldActiveSlave = V.activeSlave; + V.activeSlave = slave; + Dialog.setup(SlaveFullName(slave)); + Dialog.wiki('<div class="imageRef medImg"><<= SlaveArt($activeSlave, 2, 0)>></div><<include "Long Slave Description">>'); + Dialog.open(); + V.activeSlave = oldActiveSlave; + V.eventDescription = oldEventDescription; + } + + return App.UI.link(SlaveFullName(slave), showDialog, []); +}; diff --git a/src/uncategorized/reSlaveMarriage.tw b/src/uncategorized/reSlaveMarriage.tw index 0078bbf9be1..2e305bdb97c 100644 --- a/src/uncategorized/reSlaveMarriage.tw +++ b/src/uncategorized/reSlaveMarriage.tw @@ -25,7 +25,7 @@ /* 000-250-006 */ </span> -<<print "[[_groomSlave.slaveName|Long Slave Description][$nextLink = passage(), $eventDescription = 1,$activeSlave = _groomSlave]]">> and <<print "[[_brideSlave.slaveName|Long Slave Description][$nextLink = passage(), $eventDescription = 1,$activeSlave = _brideSlave]]">> come into your office +<<= App.UI.slaveDescriptionDialog(_groomSlave)>> and <<= App.UI.slaveDescriptionDialog(_brideSlave)>> come into your office <<if hasAnyArms(_groomSlave) && hasAnyArms(_brideSlave)>>holding hands<<else>>doing their best to stay close to one another despite their physical limitations<</if>>. _brideSlave.slaveName looks at _groomSlave.slaveName expectantly, but _he2's terribly nervous and makes several false starts before beginning. Finally _groomSlave.slaveName musters $his courage and <<if !canTalk(_groomSlave)>>asks you with simple gestures to grant the two of them a slave marriage.<<else>>asks with $his voice cracking, "<<Master>>, would you plea<<s>>e grant u<<s>> a <<s>>lave marriage?"<</if>> <br><br> diff --git a/src/utility/miscWidgets.tw b/src/utility/miscWidgets.tw index d29ab3c6e28..baca622d544 100644 --- a/src/utility/miscWidgets.tw +++ b/src/utility/miscWidgets.tw @@ -371,33 +371,9 @@ $args[0]: Slave. /* Call as <<EventNameLink>> */ -<<widget "EventNameLink">> - <span id="name"> - <<link "<<= SlaveFullName($activeSlave)>>">> - <<replace #longSlaveHide>> - <<link "(hide)">> - <<replace #longSlaveHide>> - <</replace>> - <<replace #longSlaveDescription>> - /* Hide */ - <</replace>> - <</link>> - <</replace>> - <<replace #longSlaveDescription>> - <p> - <<set _eventDescription = $eventDescription, $eventDescription = 1>> - <<include "Long Slave Description">> - <<set $eventDescription = _eventDescription>> - </p> - <</replace>> - <</link>> - </span> - <span id="longSlaveHide"></span> - - <span id="longSlaveDescription"></span> -<</widget>> +<<widget "EventNameLink">><<= App.UI.slaveDescriptionDialog($activeSlave)>><</widget>> /* Call as <<EventNameDelink>> */ -<<widget "EventNameDelink">><<replace "#name">><<= SlaveFullName($activeSlave)>><</replace>><</widget>> \ No newline at end of file +<<widget "EventNameDelink">><</widget>> \ No newline at end of file -- GitLab