mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Template/Update (Part 1)
* update TrinityCore components to return new Frontend objects - SmartAI => Markup - Conditions => Data Listview * update template files to accept the new Frontend objects
This commit is contained in:
@@ -345,7 +345,7 @@ class Conditions
|
||||
'name' => ($name ?: '$LANG.tab_conditions') . '+" ('.$nCnd.')"'
|
||||
);
|
||||
|
||||
return [null, $tab];
|
||||
return $tab;
|
||||
}
|
||||
|
||||
// $keyX params are string(ref to lv column) or int(fixed value)
|
||||
|
||||
@@ -651,32 +651,31 @@ class SmartAI
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getMarkdown() : string
|
||||
public function getMarkup() : ?Markup
|
||||
{
|
||||
# id | event (footer phase) | chance | action + target
|
||||
|
||||
if (!$this->rawData)
|
||||
return '';
|
||||
return null;
|
||||
|
||||
$return = '[style]#text-generic .grid { clear:left; } #text-generic .tabbed-contents { padding:0px; clear:left; }[/style][pad][h3][toggler id=sai]SmartAI'.$this->title.'[/toggler][/h3][div id=sai clear=left]%s[/div]';
|
||||
$wrapper = '[table class=grid width=940px]%s[/table]';
|
||||
$return = '[style]#smartai-generic .grid { clear:left; } #smartai-generic .tabbed-contents { padding:0px; clear:left; }[/style][pad][h3][toggler id=sai]SmartAI'.$this->title.'[/toggler][/h3][div id=sai clear=left]%s[/div]';
|
||||
$tabs = '';
|
||||
if (count($this->tabs) > 1)
|
||||
{
|
||||
$wrapper = '[tabs name=sai width=942px]%s[/tabs]';
|
||||
$return = '[script]function TalTabClick(id) { $(\'#dsf67g4d-sai\').find(\\\'[href=\\\\\'#sai-actionlist-\' + id + \'\\\\\']\\\').click(); }[/script]' . $return;
|
||||
$tabs = '';
|
||||
$return = "[script]function TalTabClick(id) { $('#dsf67g4d-sai').find('[href=\'#sai-actionlist-' + id + '\']').click(); }[/script]" . $return;
|
||||
foreach ($this->tabs as $guid => $data)
|
||||
{
|
||||
$buff = '[tab name=\"'.($guid ? 'ActionList #'.$guid : 'Main').'\"][table class=grid width=940px]'.$data.'[/table][/tab]';
|
||||
$buff = '[tab name="'.($guid ? 'ActionList #'.$guid : 'Main').'"][table class=grid width=940px]'.$data.'[/table][/tab]';
|
||||
if ($guid)
|
||||
$tabs .= $buff;
|
||||
else
|
||||
$tabs = $buff . $tabs;
|
||||
}
|
||||
|
||||
return sprintf($return, sprintf($wrapper, $tabs));
|
||||
}
|
||||
else
|
||||
return sprintf($return, '[table class=grid width=940px]'.$this->tabs[0].'[/table]');
|
||||
|
||||
return new Markup(sprintf($return, sprintf($wrapper, $tabs ?: $this->tabs[0])), ['allow' => Markup::CLASS_ADMIN], 'smartai-generic');
|
||||
}
|
||||
|
||||
public function addJsGlobals(array $jsg) : void
|
||||
|
||||
@@ -713,12 +713,12 @@ class SmartAction
|
||||
break;
|
||||
case self::ACTION_TALK: // 1 -> any target
|
||||
case self::ACTION_SIMPLE_TALK: // 84 -> any target
|
||||
$noSrc = false;
|
||||
if ($npcId = $this->smartAI->getTarget()->getTalkSource($noSrc))
|
||||
$playerSrc = false;
|
||||
if ($npcId = $this->smartAI->getTarget()->getTalkSource($playerSrc))
|
||||
{
|
||||
if ($quotes = $this->smartAI->getQuote($npcId, $this->param[0], $npcSrc))
|
||||
foreach ($quotes as ['text' => $text, 'prefix' => $prefix])
|
||||
$this->param[10] .= sprintf($text, $noSrc ? '' : sprintf($prefix, $npcSrc), $npcSrc);
|
||||
foreach ($quotes as ['text' => $text])
|
||||
$this->param[10] .= sprintf($text, $playerSrc ? Lang::main('thePlayer') : $npcSrc);
|
||||
}
|
||||
else
|
||||
trigger_error('SmartAI::action - could not determine talk source for action #'.$this->type);
|
||||
|
||||
@@ -20,7 +20,8 @@ class LocString
|
||||
trigger_error('LocString - is entrirely empty', E_USER_WARNING);
|
||||
|
||||
foreach (Locale::cases() as $l)
|
||||
$this->store[$l] = (string)$callback($data[$key.'_loc'.$l->value] ?? '');
|
||||
if ($l->validate())
|
||||
$this->store[$l] = (string)$callback($data[$key.'_loc'.$l->value] ?? '');
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
|
||||
@@ -191,24 +191,23 @@ class Game
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getPageText($ptId)
|
||||
public static function getBook(int $ptId, ?int $startPage = null) : ?Book
|
||||
{
|
||||
$pages = [];
|
||||
while ($ptId)
|
||||
{
|
||||
if ($row = DB::World()->selectRow('SELECT ptl.Text AS Text_loc?d, pt.* FROM page_text pt LEFT JOIN page_text_locale ptl ON pt.ID = ptl.ID AND locale = ? WHERE pt.ID = ?d', Lang::getLocale()->value, Lang::getLocale()->json(), $ptId))
|
||||
if ($row = DB::World()->selectRow('SELECT ptl.`Text` AS Text_loc?d, pt.* FROM page_text pt LEFT JOIN page_text_locale ptl ON pt.`ID` = ptl.`ID` AND locale = ? WHERE pt.`ID` = ?d', Lang::getLocale()->value, Lang::getLocale()->json(), $ptId))
|
||||
{
|
||||
$ptId = $row['NextPageID'];
|
||||
$pages[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
|
||||
}
|
||||
else
|
||||
{
|
||||
trigger_error('Referenced PageTextId #'.$ptId.' is not in DB', E_USER_WARNING);
|
||||
break;
|
||||
$pages[] = Util::localizedString($row, 'Text');
|
||||
continue;
|
||||
}
|
||||
|
||||
trigger_error('Referenced PageTextId #'.$ptId.' is not in DB', E_USER_WARNING);
|
||||
break;
|
||||
}
|
||||
|
||||
return $pages;
|
||||
return $pages ? new Book($pages, page: $startPage) : null;
|
||||
}
|
||||
|
||||
public static function getQuotesForCreature(int $creatureId, bool $asHTML = false, string $talkSource = '') : array
|
||||
@@ -256,40 +255,33 @@ class Game
|
||||
if ($talkSource)
|
||||
$msg = sprintf($msg, $talkSource);
|
||||
|
||||
// make type css compatible
|
||||
switch ($t['talkType'])
|
||||
// convert [old, new] talkType to css compatible
|
||||
$t['talkType'] = match ((int)$t['talkType'])
|
||||
{
|
||||
case 1: // yell:
|
||||
case 14: $t['talkType'] = 1; break; // - dark red
|
||||
case 2: // emote:
|
||||
case 16: // "
|
||||
case 3: // boss emote:
|
||||
case 41: $t['talkType'] = 4; break; // - orange
|
||||
case 4: // whisper:
|
||||
case 15: // "
|
||||
case 5: // boss whisper:
|
||||
case 42: $t['talkType'] = 3; break; // - pink-ish
|
||||
default: $t['talkType'] = 2; // [type: 0, 12] say: yellow-ish
|
||||
|
||||
}
|
||||
0, 12 => 2, // say - yellow-ish
|
||||
1, 14 => 1, // yell - dark red
|
||||
2, 16, // emote
|
||||
3, 41 => 4, // boss emote - orange
|
||||
4, 15, // whisper
|
||||
5, 42 => 3, // boss whisper - pink-ish
|
||||
default => 2
|
||||
};
|
||||
|
||||
// prefix
|
||||
$pre = '';
|
||||
$prefix = '%s ';
|
||||
if ($t['talkType'] != 4)
|
||||
$pre = ($talkSource ?: '%s').' '.Lang::npc('textTypes', $t['talkType']).Lang::main('colon').($t['lang'] ? '['.Lang::game('languages', $t['lang']).'] ' : null);
|
||||
$prefix = ($talkSource ?: '%s').' '.Lang::npc('textTypes', $t['talkType']).Lang::main('colon').($t['lang'] ? '['.Lang::game('languages', $t['lang']).'] ' : ' ');
|
||||
|
||||
if ($asHTML)
|
||||
$msg = '<div><span class="s'.$t['talkType'].'">%s'.($t['range'] ? sprintf(Util::$dfnString, Lang::npc('textRanges', $t['range']), $msg) : $msg).'</span></div>';
|
||||
$msg = '<div><span class="s'.$t['talkType'].'">'.$prefix.($t['range'] ? sprintf(Util::$dfnString, Lang::npc('textRanges', $t['range']), $msg) : $msg).'</span></div>';
|
||||
else
|
||||
$msg = '[div][span class=s'.$t['talkType'].']%s'.html_entity_decode($msg).'[/span][/div]';
|
||||
$msg = '[div][span class=s'.$t['talkType'].']'.$prefix.html_entity_decode($msg).'[/span][/div]';
|
||||
|
||||
$line = array(
|
||||
'range' => $t['range'],
|
||||
'text' => $msg,
|
||||
'prefix' => $pre
|
||||
'text' => $msg
|
||||
);
|
||||
|
||||
|
||||
$nQuotes++;
|
||||
$group[] = $line;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user