Listviews/AddIns

* AddIns must be output directly before the listview it is used by
This commit is contained in:
Sarjuuk
2025-10-26 17:24:27 +01:00
parent cf2ace805b
commit 3a25c2390f
4 changed files with 47 additions and 47 deletions

View File

@@ -164,10 +164,11 @@ class Listview implements \JsonSerializable
public function __toString() : string
{
$addIn = '';
if ($this->__addIn)
include($this->__addIn);
$addIn = file_get_contents($this->__addIn).PHP_EOL;
return "new Listview(".Util::toJSON($this).");\n";
return $addIn.'new Listview('.Util::toJSON($this).');'.PHP_EOL;
}
}

View File

@@ -19,6 +19,41 @@ if (!defined('AOWOW_REVISION'))
quest_mail_loot_template entry quest_template RewMailTemplateId
reference_loot_template entry many <- many *_loot_template reference
*/
/* 4.3 loot-example
template: 'item',
id: 'drops',
name: LANG.tab_drops,
tabs: tabsRelated,
parent: 'lkljbjkb574',
extraCols: [Listview.extraCols.count, Listview.extraCols.percent],
sort:['-percent', 'name'],
_totalCount: 448092, // total # creature killed/looted
computeDataFunc: Listview.funcBox.initLootTable,
onAfterCreate: Listview.funcBox.addModeIndicator,
data: [
{
"classs":15, // Tab Type
"commondrop":true, // loot filtered as "not noteworthy"
"id":25445,
"level":1,
"name":"7Wretched Ichor",
"slot":0,
"source":[2],
"sourcemore":[{"z":3520}],
"subclass":0, // Tab:Type
modes:{
"mode":4, // &1: heroic; &4: noteworthy(?); &8: reg10; &16: reg25; &32: hc10; &64: hc25; &128: RaidFinder
"4":{"count":363318,"outof":448092} // calculate pct chance
},
count:363318,
stack:[1,1],
pctstack:'{1: 50.0123, 2: 49.9877}'
}
]
});
*/
class Loot
{

View File

@@ -14,7 +14,7 @@ if (($this->lvTabs && count($this->lvTabs)) || $this->charactersLvData || $this-
<div id="lv-generic" class="listview">
<?php
foreach ($this->lvTabs?->getDataContainer() ?? [] as $container):
echo ' '.$container."\n";
echo ' '.$container.PHP_EOL;
endforeach;
?>
</div>
@@ -23,31 +23,31 @@ if (($this->lvTabs && count($this->lvTabs)) || $this->charactersLvData || $this-
// seems like WH keeps their modules separated, as fi_gemScores should be with the other fi_ items but are here instead and originally the dbtype globals used by the listviews were also here)
// May 2025: WH no longer calculates gems into item scores. Dude .. why?
if ($this->gemScores) // set by ItemsBaseResponse
echo ' var fi_gemScores = '.$this->json($this->gemScores).";\n";
echo ' var fi_gemScores = '.$this->json($this->gemScores).';'.PHP_EOL;
// g_items, g_spells, etc required by the listviews used to be here
echo $this->lvTabs;
if ($this->charactersLvData):
echo ' us_addCharactersTab('.$this->json('charactersLvData').");\n";
echo ' us_addCharactersTab('.$this->json('charactersLvData').');'.PHP_EOL;
endif;
if ($this->profilesLvData):
echo ' us_addProfilesTab('.$this->json('profilesLvData').");\n";
echo ' us_addProfilesTab('.$this->json('profilesLvData').');'.PHP_EOL;
endif;
if ($this->contribute & CONTRIBUTE_CO):
echo " new Listview({template: 'comment', id: 'comments', name: LANG.tab_comments".($this->lvTabs ? ", tabs: ".$this->lvTabs->__tabVar : '').", parent: 'lv-generic', data: lv_comments});\n";
echo " new Listview({template: 'comment', id: 'comments', name: LANG.tab_comments".($this->lvTabs ? ", tabs: ".$this->lvTabs->__tabVar : '').", parent: 'lv-generic', data: lv_comments});".PHP_EOL;
endif;
if ($this->contribute & CONTRIBUTE_SS):
echo " new Listview({template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots".($this->lvTabs ? ", tabs: ".$this->lvTabs->__tabVar : '').", parent: 'lv-generic', data: lv_screenshots});\n";
echo " new Listview({template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots".($this->lvTabs ? ", tabs: ".$this->lvTabs->__tabVar : '').", parent: 'lv-generic', data: lv_screenshots});".PHP_EOL;
endif;
if ($this->contribute & CONTRIBUTE_VI):
echo " if (lv_videos.length || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)))\n";
echo " new Listview({template: 'video', id: 'videos', name: LANG.tab_videos".($this->lvTabs ? ", tabs: ".$this->lvTabs->__tabVar : '').", parent: 'lv-generic', data: lv_videos});\n";
echo " if (lv_videos.length || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)))".PHP_EOL;
echo " new Listview({template: 'video', id: 'videos', name: LANG.tab_videos".($this->lvTabs ? ", tabs: ".$this->lvTabs->__tabVar : '').", parent: 'lv-generic', data: lv_videos});".PHP_EOL;
endif;
if ($flushTabs = $this->lvTabs?->getFlush()):
echo " ".$flushTabs."\n";
echo " ".$flushTabs.PHP_EOL;
endif;
?>
//]]></script>

View File

@@ -16,39 +16,3 @@ var _ = [
}
}
];
<?php
// 4.3 loot-example
// template: 'item',
// id: 'drops',
// name: LANG.tab_drops,
// tabs: tabsRelated,
// parent: 'lkljbjkb574',
// extraCols: [Listview.extraCols.count, Listview.extraCols.percent],
// sort:['-percent', 'name'],
// _totalCount: 448092, /* total # creature killed/looted */
// computeDataFunc: Listview.funcBox.initLootTable,
// onAfterCreate: Listview.funcBox.addModeIndicator,
// data: [
// {
// "classs":15, /* Tab Type */
// "commondrop":true, /* loot filtered as "not noteworthy" */
// "id":25445,
// "level":1,
// "name":"7Wretched Ichor",
// "slot":0,
// "source":[2], /* 1: crafted; 2:zonedrop; 3:pvp; 4:quest; 5: Vendors; 6:Trainer; 7:Discovery; 8:Redemption; 9: Talent; 10:Starter; 11: Event; 12:Achievement; */
// "sourcemore":[{"z":3520}], /* z: zone... */
// "subclass":0, /* Tab:Type */
// modes:{
// "mode":4, /* &1: heroic; &4: noteworthy(?); &8: reg10; &16: reg25; &32: hc10; &64: hc25; &128: RaidFinder */
// "4":{"count":363318,"outof":448092} /* calculate pct chance */
// },
// count:363318,
// stack:[1,1], /* [min, max] */
// pctstack:'{1: 50.0123, 2: 49.9877}' /* {dropCount: relChanceForThisStack} */
// }
// ]
// });
?>