maniaControl = $maniaControl; $this->addDefaultIcons(); // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect'); } /** * Add the Set of default Icons */ private function addDefaultIcons() { $this->addIcon(self::MX_ICON); $this->addIcon(self::MX_ICON_MOVER); $this->addIcon(self::MX_ICON_GREEN, "http://www.pictures.esc-clan.net/upload/"); //TODO mc website $this->addIcon(self::MX_ICON_GREEN_MOVER , " http://www.pictures.esc-clan.net/upload/"); } /** * Add an Icon * * @param string $iconName * @param string $iconLink */ public function addIcon($iconName, $iconLink = self::DEFAULT_IMG_URL) { $this->icons[$iconName] = $iconLink . '/' . $iconName; } /** * Get an Icon by its name * * @param $iconName * @return string */ public function getIcon($iconName) { if(!isset($this->icons[$iconName])) { return null; } return $this->icons[$iconName]; } /** * Handle OnInit Callback * * @param array $callback */ public function handleOnInit(array $callback) { $this->preloadIcons(); } /** * Handle PlayerConnect Callback * * @param array $callback */ public function handlePlayerConnect(array $callback) { $login = $callback[1]; $this->preloadIcons($login); } /** * Preload Icons * * @param string $login */ private function preloadIcons($login = false) { $maniaLink = new ManiaLink(self::PRELOAD_MLID); $frame = new Frame(); $maniaLink->add($frame); $frame->setPosition(500, 500); foreach($this->icons as $iconUrl) { $iconQuad = new Quad(); $iconQuad->setImage($iconUrl); $iconQuad->setSize(1, 1); $frame->add($iconQuad); } // Send manialink $manialinkText = $maniaLink->render()->saveXML(); $this->maniaControl->manialinkManager->sendManialink($manialinkText, $login); } }