Пример #1
0
 function index($path = '')
 {
     $service = new \DedicatedManager\Services\MapService();
     $files = $service->getList($path);
     usort($files, function (\DedicatedManager\Services\File $a, \DedicatedManager\Services\File $b) {
         $order = $b->isDirectory - $a->isDirectory;
         if (!$order) {
             $order = strcmp($a->filename, $b->filename);
         }
         return $order;
     });
     $this->response->path = $path;
     $this->response->parentPath = preg_replace('/([^\\/]*\\/)$/iu', '', $path);
     $this->response->files = $files;
 }
Пример #2
0
 /**
  * @norelay
  * @local
  */
 function addMaps()
 {
     $maps = $this->server->connection->getMapList(-1, 0);
     $selected = \ManiaLib\Utils\Arrays::getProperty($maps, 'fileName');
     $selected = array_map(function ($s) {
         $s = preg_replace('/^\\xEF\\xBB\\xBF/', '', $s);
         return str_replace('\\', '/', $s);
     }, $selected);
     $matchSettings = $this->server->connection->getNextGameInfo();
     if ($matchSettings->gameMode == GameInfos::GAMEMODE_SCRIPT) {
         $scriptInfo = $this->server->connection->getModeScriptInfo();
         $type = explode(',', $scriptInfo->compatibleMapTypes);
         $isLaps = false;
     } else {
         $type = array('Race');
         $isLaps = $matchSettings->gameMode == GameInfos::GAMEMODE_LAPS;
     }
     $service = new \DedicatedManager\Services\MapService();
     $files = $service->getList('', true, $isLaps, $type, $this->currentMap->environnement);
     $this->response->files = $files;
     $this->response->selected = $selected;
     $header = \DedicatedManager\Helpers\Header::getInstance();
     $header->rightText = _('Back to maps list');
     $header->rightLink = $this->request->createLinkArgList('../maps', 'host', 'port');
 }
 function maps()
 {
     set_time_limit(0);
     list(, , $system) = $this->fetchAndAssertConfig(_('selecting maps'));
     $gameInfos = $this->fetchAndAssertSettings(_('selecting maps'));
     $service = new \DedicatedManager\Services\TitleService();
     $environment = $service->getEnvironment($system->title);
     if ($gameInfos->gameMode == GameInfos::GAMEMODE_SCRIPT) {
         $service = new \DedicatedManager\Services\ScriptService();
         $type = $service->getFileMapType($gameInfos->scriptName, $system->title);
     } else {
         $type = array('Race');
     }
     $isLaps = $gameInfos->gameMode == GameInfos::GAMEMODE_LAPS;
     $service = new \DedicatedManager\Services\MapService();
     $this->response->files = $service->getList('', true, $isLaps, $type, $environment);
     $this->response->selected = $this->session->get('selected', array());
     $this->response->randomize = $this->session->get('randomize', false);
     $header = \DedicatedManager\Helpers\Header::getInstance();
     $header->rightText = _('Back to game settings');
     $header->rightIcon = 'back';
     $header->rightLink = $this->request->createLinkArgList('../rules');
 }