maniaControl = $maniaControl; // TODO: Implement load() method. // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect'); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 4.5); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_WIDTH, 40); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_HEIGHT, 9.); return true; } /** * Unload the plugin and its resources */ public function unload(){ $this->maniaControl->callbackManager->unregisterCallbackListener($this); unset($this->maniaControl); } /** * Displays the Map Widget * @param $login */ public function displayMapWidget($login = false){ $xml = " "; $this->maniaControl->manialinkManager->sendManialink($xml); $pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_POSX); $pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_POSY); $width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_WIDTH); $height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_HEIGHT); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $maniaLink = new ManiaLink(self::MLID_MAPWIDGET); //mainframe $frame = new Frame(); $maniaLink->add($frame); $frame->setSize($width,$height); $frame->setPosition($pos_x, $pos_y); //Background Quad $backgroundQuad = new Quad(); $frame->add($backgroundQuad); $backgroundQuad->setSize($width,$height); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); $map = $this->maniaControl->mapManager->getCurrentMap(); $label = new Label_Text(); $frame->add($label); $label->setY(1.5); $label->setX(0); $label->setAlign(Control::CENTER,Control::CENTER); $label->setZ(0.2); $label->setTextSize(1.3); $label->setText($map->name); $label->setTextColor("FFF"); $label = new Label_Text(); $frame->add($label); $label->setX(0); $label->setY(-1.4); $label->setAlign(Control::CENTER,Control::CENTER); $label->setZ(0.2); $label->setTextSize(1); $label->setScale(0.8); $label->setText($map->authorLogin); $label->setTextColor("FFF"); //Send manialink $manialinkText = $maniaLink->render()->saveXML(); $this->maniaControl->manialinkManager->sendManialink($manialinkText, $login); } /** * Handle ManiaControl OnInit callback * * @param array $callback */ public function handleOnInit(array $callback) { //Display Map Widget if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)){ $this->displayMapWidget(); } } /** * Handle PlayerConnect callback * * @param array $callback */ public function handlePlayerConnect(array $callback) { $player = $callback[1]; //Display Map Widget if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)){ $this->displayMapWidget($player->login); } } /** * Get plugin id * * @return int */ public static function getId(){ return self::PLUGIN_ID; } /** * Get Plugin Name * * @return string */ public static function getName(){ return self::PLUGIN_NAME; } /** * Get Plugin Version * * @return float,, */ public static function getVersion(){ return self::PLUGIN_VERSION; } /** * Get Plugin Author * * @return string */ public static function getAuthor(){ return self::PLUGIN_AUTHOR; } /** * Get Plugin Description * * @return string */ public static function getDescription(){ return null; } }