maniaControl = $maniaControl; $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SIDEBAR_POSX, 156); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SIDEBAR_POSY_SHOOTMANIA, -37); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SIDEBAR_POSY_TRACKMANIA, 17); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6); } public function addMenuEntry(SidebarMenuEntry $entry, $order) { if (isset($this->menuEntries[$order])) { $this->addMenuEntry($entry, $order + 1); } array_push($menuEntries, $entry); ksort($this->menuEntries); $this->updateManiaLink(); } private function itemsBeforeAdmin() { $count = 0; foreach ($this->menuEntries as $key => $entry) { if ($key < self::ADMIN_MENU_ORDER) { $count++; } } return $count; } private function updateManiaLink() { $itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE); $posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SIDEBAR_POSX); if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'sm') { $posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SIDEBAR_POSY_SHOOTMANIA); } else { $posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SIDEBAR_POSY_TRACKMANIA); } $quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); $quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); $itemMarginFactorX = 1.3; $itemMarginFactorY = 1.2; //Calculate X relative to AdminMenu $posX -= $itemSize * 1.05 * $this->itemsBeforeAdmin(); $maniaLink = new ManiaLink(self::SIDEBAR_MANIALINK_ID); $frame = new Frame(); $maniaLink->addChild($frame); $frame->setZ(ManialinkManager::MAIN_MANIALINK_Z_VALUE); $frame->setPosition($posX, $posY); $posX = 0; /** @var SidebarMenuEntry $entry */ foreach ($this->menuEntries as $entry) { $iconFrame = new Frame(); $frame->addChild($iconFrame); $iconFrame->setX($posX); $background = new Quad(); $frame->addChild($background); $background->setStyles($quadStyle, $quadSubstyle); $background->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY); $icon = $entry->getIcon(); $frame->addChild($icon); if($entry->getDescription()){ } } $this->maniaControl->getManialinkManager()->sendManialink($maniaLink); } }