コード例 #1
0
ファイル: BuildJsonFiles.php プロジェクト: nimetu/ryzom_maps
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var ResourceHelper $helper */
     $helper = $this->getHelper('resource');
     $ryzomDataPath = $input->getOption('ryzom');
     if (empty($ryzomDataPath) || !file_exists($ryzomDataPath . '/gamedev.bnp') || !file_exists($ryzomDataPath . '/lmconts.packed') || !file_exists($ryzomDataPath . '/world.packed_sheets')) {
         throw new \InvalidArgumentException("Invalid Ryzom data path. gamedev.bnp, lmconts.packed or world.packed_sheets not found");
     }
     $psLoader = new PackedSheetsLoader($ryzomDataPath);
     // labels.json
     $output->write('<info>building labels.json</info>...');
     /** @var TranslateHelper $translator */
     $translator = $this->getHelper('translator');
     /** @var StringsManager $sm */
     $sm = $translator->load($ryzomDataPath);
     $lmconts = $psLoader->load('lmconts');
     $continents = $lmconts->get('continents');
     $this->buildLabels($continents, $sm, $helper->get('labels.json.file'));
     $output->writeln('');
     // server.json
     $output->write('<info>building server.json</info>...');
     $ps = $psLoader->load('world');
     // 6 == sheetid for 'ryzom.world'
     $world = $ps->get(6);
     if (!$world) {
         throw new \RuntimeException("Failed to load world.packed_sheets");
     }
     $this->buildServerZones($world, $helper->get('server.json.file'));
     $output->writeln('');
 }
コード例 #2
0
ファイル: SheetsManager.php プロジェクト: nimetu/ryzom_sheets
 /**
  * @param string $sheet 'name.sheet' or just 'sheet'
  *
  * @return PackedSheets
  */
 function load($sheet)
 {
     $pos = strrpos($sheet, '.');
     if ($pos !== false) {
         $sheet = substr($sheet, $pos + 1);
     }
     if (!isset($this->sheets[$sheet])) {
         $this->sheets[$sheet] = $this->loader->load($sheet);
     }
     return $this->sheets[$sheet];
 }
コード例 #3
0
ファイル: example.php プロジェクト: nimetu/ryzom_sheets
// all keys are in lowercase
$key = 'languagename';
$value = $strings[$key];
printf("%s = [%s]\n", $key, $value['name']);
// loading outpost_words_en.txt
$buffer = $leveldesign->readFile('outpost_words_en.txt');
$sm->load('outpost', $buffer, 'en');
$strings = $sm->getStrings('outpost', 'en');
$key = 'fyros_outpost_04';
$value = $strings[$key];
printf("%s\n  name = %s\n  description = %s\n", $key, $value['name'], $value['description']);
/*****************************************************************************/
echo "\n";
$psLoader = new PackedSheetsLoader('/srv/home2/ryzom/data');
printf("+ loading sitem.packed_sheets file...\n");
$sitem = $psLoader->load('sitem');
$sheetId = 5603886;
/** @var $item \Ryzom\Sheets\Client\ItemSheet */
$item = $sitem->get($sheetId);
printf("+ %d: item type: %d, variant: %d, icons: (%s, %s), maleShape: %s\n", $sheetId, $item->ItemType, $item->MapVariant, $item->Icon[0], $item->Icon[1], $item->MaleShape);
/*****************************************************************************/
$world = $psLoader->load('world');
//print_r($world);
/** @var \Ryzom\Sheets\ContinentLandmarks $lmconts */
$lmconts = $psLoader->load('lmconts');
/** @var \Ryzom\Sheets\Client\CContinent[] $continents */
$continents = $lmconts->get('continents');
foreach ($continents as $key => $cont) {
    echo "+ [{$cont->Name}]\n";
    foreach ($cont->ContLandMarks as $lm) {
        echo "  > {{$lm->TitleText}} {{$lm->Pos->X}, {$lm->Pos->Y}}\n";