/** {@inheritdoc} */ public function export(array $data, $sheet) { $cache = array(); foreach ($data as $slot => $sheets) { foreach ($sheets as $index => $sheetid) { $cache[$slot][$index] = $this->sheetIds->getSheetIdName($sheetid); } } $this->_serializeInto($cache, 'visual_slot'); }
function findById($id) { // get sheet name where $id belongs to $key = $this->sheetId->getSheetIdName($id); // load PackedSheet file $ps = $this->load($key); if (!empty($ps)) { // return sheet record return $ps->get($id); } }
/** * Parse <race>.race_stats packed sheets * * @return string */ private function genRaceStats() { $raceStats = new RaceDefaultsModel(); $raceStats->clear(); $races = array('fyros', 'matis', 'tryker', 'zorai'); foreach ($races as $race) { $sheet = $race . '.race_stats'; echo "-- {$sheet}\n"; $id = $this->sheetIds->getSheetId($sheet); /** @var $stats RaceStatsSheet */ $stats = $this->sheets->findById($id); foreach ($stats->GenderInfos as $gender => $genderInfos) { $result = array(); foreach ($genderInfos->Items as $sheetName) { $slot = $this->findSheetSlot($sheetName); $result[$slot] = $sheetName; } $raceStats->setRaceItems($stats->People, $gender, $result); } } return $raceStats->save(); }
function __construct() { $app = $this; // leveldesign.bnp has 'sheet_id.bin' */ $this['bnp.leveldesign'] = $app->share(function () use($app) { return new BnpFile($app['data.path'] . '/leveldesign.bnp'); }); // gamedev.bnp has translations (<sheet>_words_<lang>.txt, <lang>.uxt) $this['bnp.gamedev'] = $app->share(function () use($app) { return new BnpFile($app['data.path'] . '/gamedev.bnp'); }); $this['bnp.data_common'] = $app->share(function () use($app) { return new BnpFile($app['data.path'] . '/data_common.bnp'); }); // SheetIds collection, sheet_id.bin reader $this['sheetid'] = $app->share(function () use($app) { $sheetIds = new SheetId(); $file = 'sheet_id.bin'; /** @var $bnp BnpFile */ $bnp = $app['bnp.leveldesign']; if ($bnp->hasFile($file)) { $app->debug('loading %s', $file); $data = $bnp->readFile($file); $sheetIds->load($data); } return $sheetIds; }); // packed sheets collection // - depends on SheetId and PackedSheetsLoader $this['sheets'] = $this->share(function () use($app) { return new SheetsManager($app['sheetid'], $app['load.packed_sheets']); }); // Packed sheets loader $this['load.packed_sheets'] = $this->share(function () use($app) { return new PackedSheetsLoader($app['data.path']); }); // <sheet>_words_<lang>.txt reader $this['load.words'] = $this->share(function () use($app) { return new WordsLoader(); }); // Reader for <lang>.uxt files $this['load.uxt'] = $this->share(function () use($app) { return new UxtLoader(); }); // Save SheetId collection into cache files $this['export.sheetid'] = $this->share(function () use($app) { return new SheetIdExport($app['sheetid'], $app['cache.path']); }); // Save words and uxt translations into cache files $this['export.words'] = $this->share(function () use($app) { return new WordsExport($app['cache.path']); }); // Save loaded sheets to cache files $this['export.packed_sheets'] = $this->share(function () use($app) { return new PackedSheetsExport($app['sheetid'], $app['sheets'], $app['cache.path']); }); // Save visual_slot.tab to cache file $this['export.visual_slot'] = $this->share(function () use($app) { return new VisualSlotExport($app['sheetid'], $app['cache.path']); }); }