Quest/Detail Page

* display mail attachments besides the actual mail instead of extra tab
This commit is contained in:
Sarjuuk
2018-04-30 10:57:57 +02:00
parent 35dc835c62
commit 9609c93f8c
4 changed files with 44 additions and 22 deletions

View File

@@ -210,9 +210,7 @@ class Game
);
// return list of integers, not strings
array_walk($data, function (&$v, $k) {
$v = intVal($v);
});
$data = array_map('intVal', $data);
return $data;
}

View File

@@ -891,7 +891,7 @@ class QuestPage extends GenericPage
/****************/
$this->gains = $this->createGains();
$this->mail = $this->createMail($maTab, $startEnd);
$this->mail = $this->createMail($startEnd);
$this->rewards = $this->createRewards($_side);
$this->objectives = $this->subject->parseText('objectives', false);
$this->details = $this->subject->parseText('details', false);
@@ -912,9 +912,6 @@ class QuestPage extends GenericPage
)
);
if ($maTab)
$this->lvTabs[] = $maTab;
// factionchange-equivalent
if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_quests WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId))
{
@@ -1210,14 +1207,14 @@ class QuestPage extends GenericPage
return $rewards;
}
private function createMail(&$attachmentTab, $startEnd)
private function createMail($startEnd)
{
$mail = [];
if ($_ = $this->subject->getField('rewardMailTemplateId'))
if ($rmtId = $this->subject->getField('rewardMailTemplateId'))
{
$delay = $this->subject->getField('rewardMailDelay');
$letter = DB::Aowow()->selectRow('SELECT * FROM ?_mailtemplate WHERE id = ?d', $_);
$letter = DB::Aowow()->selectRow('SELECT * FROM ?_mailtemplate WHERE id = ?d', $rmtId);
$mail = array(
'delay' => $delay ? sprintf(Lang::quest('mailIn'), Util::formatTime($delay * 1000)) : null,
@@ -1238,19 +1235,23 @@ class QuestPage extends GenericPage
}
}
$extraCols = ['$Listview.extraCols.percent'];
// while mail attachemnts are handled as loot, it has no variance. Always 100% chance, always one item.
$mailLoot = new Loot();
if ($mailLoot->getByContainer(LOOT_MAIL, $_))
if ($mailLoot->getByContainer(LOOT_MAIL, $rmtId))
{
$mail['attachments'] = [];
$this->extendGlobalData($mailLoot->jsGlobals);
$attachmentTab = ['item', array(
'data' => array_values($mailLoot->getResult()),
'name' => Lang::quest('attachment'),
'id' => 'mail-attachments',
'extraCols' => array_merge($extraCols, $mailLoot->extraCols),
'hiddenCols' => ['side', 'slot', 'reqlevel']
)];
foreach ($mailLoot->getResult() as $loot)
{
$mail['attachments'][] = array(
'typeStr' => Util::$typeStrings[TYPE_ITEM],
'id' => $loot['id'],
'name' => substr($loot['name'], 1),
'quality' => 7 - $loot['name'][0],
'qty' => $loot['stack'][0],
'globalStr' => 'g_items'
);
}
}
}

View File

@@ -1,5 +1,8 @@
<?php
if ($m = $this->mail):
if (!isset($offset)) // in case we have multiple icons on the page (prominently quest-rewards)
$offset = 0;
echo ' <h3>'.sprintf(Lang::quest('mailDelivery'), $m['sender'], $m['delay'])."</h3>\n";
if ($m['subject']):
@@ -7,7 +10,27 @@ if ($m = $this->mail):
endif;
if ($m['text']):
echo ' <div class="book"><div class="page">'.$m['text']."</div></div>\n";
echo ' <div class="book" style="float:left; margin-bottom:26px;"><div class="page">'.$m['text']."</div></div>\n";
endif;
if ($m['attachments']):
?>
<table class="icontab icontab-box" style="padding-left:10px;">
<?php
foreach ($m['attachments'] as $k => $i):
echo '<tr><th id="icontab-icon'.($k + 1 + $offset).'"></th><td><span class="q'.(isset($i['quality']) ? $i['quality'] : null).'"><a href="?'.$i['typeStr'].'='.$i['id'].'">'.$i['name']."</a></span></td></tr>\n";
endforeach;
?>
</table>
<script type="text/javascript">//<![CDATA[
<?php
foreach ($m['attachments'] as $k => $i):
echo ' $WH.ge(\'icontab-icon'.($k + 1 + $offset).'\').appendChild('.$i['globalStr'].'.createIcon('.$i['id'].', 1, '.(empty($i['qty']) ? 0 : $i['qty'])."));\n";
endforeach;
?>
//]]></script>
<?php
endif;
endif;
?>

View File

@@ -200,7 +200,7 @@ if ($g = $this->gains):
echo " </ul>\n";
endif;
$this->brick('mail');
$this->brick('mail', ['offset' => ++$offset]);
if (!empty($this->transfer)):
echo " <div class=\"pad\"></div>\n ".$this->transfer."\n";