Spells/Tooltips

* htmlify \n in spell tooltips & buffs
 * allow recursion of Util::parseHtmlText()
This commit is contained in:
Sarjuuk
2022-04-05 18:28:45 +02:00
parent 8425eeb685
commit 6594d6fa42
2 changed files with 18 additions and 3 deletions

View File

@@ -1800,6 +1800,13 @@ class SpellList extends BaseType
} }
} }
// this should be 0 if all went well
if ($condBrktCnt > 0)
{
trigger_error('SpellList::handleConditions() - string contains unbalanced condition', E_USER_WARNING);
$condParts[3] = $condParts[3] ?? '';
}
// check if it is know-compatible // check if it is know-compatible
$know = 0; $know = 0;
if (preg_match('/\(?(\!?)[as](\d+)\)?$/i', $condParts[0], $m)) if (preg_match('/\(?(\!?)[as](\d+)\)?$/i', $condParts[0], $m))
@@ -1889,7 +1896,7 @@ class SpellList extends BaseType
// scaling information - spellId:min:max:curr // scaling information - spellId:min:max:curr
$x .= '<!--?'.$this->id.':1:'.($scaling ? MAX_LEVEL : 1).':'.$level.'-->'; $x .= '<!--?'.$this->id.':1:'.($scaling ? MAX_LEVEL : 1).':'.$level.'-->';
return [$x, $btt[1]]; return [$x, Util::parseHtmlText($btt[1])];
} }
public function renderTooltip($level = MAX_LEVEL, $interactive = false) public function renderTooltip($level = MAX_LEVEL, $interactive = false)
@@ -2038,7 +2045,7 @@ class SpellList extends BaseType
// scaling information - spellId:min:max:curr // scaling information - spellId:min:max:curr
$x .= '<!--?'.$this->id.':1:'.($scaling ? MAX_LEVEL : 1).':'.$level.'-->'; $x .= '<!--?'.$this->id.':1:'.($scaling ? MAX_LEVEL : 1).':'.$level.'-->';
return [$x, $desc[1]]; return [$x, Util::parseHtmlText($desc[1])];
} }
public function getTalentHeadForCurrent() public function getTalentHeadForCurrent()

View File

@@ -671,8 +671,16 @@ abstract class Util
} }
// pageText for Books (Item or GO) and questText // pageText for Books (Item or GO) and questText
public static function parseHtmlText(string $text, bool $markdown = false) : string public static function parseHtmlText(/*string|array*/ $text, bool $markdown = false) // : /*string|array*/
{ {
if (is_array($text))
{
foreach ($text as &$t)
$t = self::parseHtmlText($t, $markdown);
return $text;
}
if (stristr($text, '<HTML>')) // text is basically a html-document with weird linebreak-syntax if (stristr($text, '<HTML>')) // text is basically a html-document with weird linebreak-syntax
{ {
$pairs = array( $pairs = array(