New SidebarMenuManager Version

This commit is contained in:
Jocy 2017-05-19 18:36:41 +02:00
parent 6193787ee5
commit e3a365f187
8 changed files with 228 additions and 179 deletions

View File

@ -15,7 +15,7 @@ use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Manialinks\SidebarMenuEntryRenderable;
use ManiaControl\Manialinks\SidebarMenuEntryListener;
use ManiaControl\Manialinks\SidebarMenuManager;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
@ -30,7 +30,7 @@ use ManiaControl\Settings\SettingManager;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ActionsMenu implements SidebarMenuEntryRenderable, CallbackListener, ManialinkPageAnswerListener, UsageInformationAble {
class ActionsMenu implements SidebarMenuEntryListener, CallbackListener, ManialinkPageAnswerListener, UsageInformationAble {
use UsageInformationTrait;
/*
@ -45,6 +45,8 @@ class ActionsMenu implements SidebarMenuEntryRenderable, CallbackListener, Mania
const ACTION_OPEN_PLAYER_MENU = 'ActionsMenu.OpenPlayerMenu';
const ADMIN_MENU_ID = 'ActionsMenu.AdminMenu';
const PLAYER_MENU_ID = 'ActionsMenu.PlayerMenu';
const MLID_ADMIN_MENU = 'ActionsMenu.AdminMenuMLID';
const MLID_PLAYER_MENU = 'ActionsMenu.PlayerMenuMLID';
/*
* Private properties
@ -75,8 +77,20 @@ class ActionsMenu implements SidebarMenuEntryRenderable, CallbackListener, Mania
$this->maniaControl->getCallbackManager()->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined');
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged');
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry($this,SidebarMenuManager::ORDER_ADMIN_MENU, self::ADMIN_MENU_ID);
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry($this,SidebarMenuManager::ORDER_PLAYER_MENU, self::PLAYER_MENU_ID);
}
/**
* Handle ManiaControl AfterInit callback
*
* @internal
*/
public function handleAfterInit() {
$this->initCompleted = true;
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_ADMIN_MENU, self::ADMIN_MENU_ID, $this, 'rebuildAndShowAdminMenu');
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_PLAYER_MENU, self::PLAYER_MENU_ID, $this, 'rebuildAndShowPlayerMenu');
$this->rebuildAndShowMenu();
}
/**
@ -124,104 +138,49 @@ class ActionsMenu implements SidebarMenuEntryRenderable, CallbackListener, Mania
}
//Send Menu to Admins
$admins = $this->maniaControl->getAuthenticationManager()->getConnectedAdmins(AuthenticationManager::AUTH_LEVEL_MODERATOR);
if (!empty($admins)) {
$manialink = $this->buildMenuIconsManialink(true);
$this->maniaControl->getManialinkManager()->sendManialink($manialink, $admins);
}
$this->rebuildAndShowAdminMenu();
//Send Menu to Players - Players with No Admin Permisssions
$players = $this->maniaControl->getAuthenticationManager()->getConnectedPlayers();
$this->rebuildAndShowPlayerMenu();
}
/**
* @internal
*/
public function rebuildAndShowAdminMenu() {
$admins = $this->maniaControl->getAuthenticationManager()->getConnectedAdmins(AuthenticationManager::AUTH_LEVEL_MODERATOR);
if (!empty($admins)) {
$manialink = $this->buildAdminMenuManiaLink();
$this->maniaControl->getManialinkManager()->sendManialink($manialink, $admins);
}
}
/**
* @internal
*/
public function rebuildAndShowPlayerMenu() {
$players = $this->maniaControl->getPlayerManager()->getPlayers();
if (!empty($players)) {
$manialink = $this->buildMenuIconsManialink(false);
$manialink = $this->buildPlayerMenuManiaLink();
$this->maniaControl->getManialinkManager()->sendManialink($manialink, $players);
}
}
/**
* Builds the Manialink
*
* @param bool $admin
* @return \FML\ManiaLink
*/
private function buildMenuIconsManialink($admin = false) {
$adminPos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::ADMIN_MENU_ID);
$playerPos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::PLAYER_MENU_ID);
private function buildPlayerMenuManiaLink() {
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
$itemMarginFactorX = 1.3;
$itemMarginFactorY = 1.2;
$maniaLink = new ManiaLink(self::MLID_MENU);
$maniaLink = new ManiaLink(self::MLID_PLAYER_MENU);
$frame = new Frame();
$maniaLink->addChild($frame);
$frame->setZ(ManialinkManager::MAIN_MANIALINK_Z_VALUE);
/*
* Admin Menu
*/
if ($admin) {
// Admin Menu Icon Frame
$iconFrame = new Frame();
$frame->addChild($iconFrame);
$iconFrame->setPosition($adminPos->getX(), $adminPos->getY());
$backgroundQuad = new Quad();
$iconFrame->addChild($backgroundQuad);
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$itemQuad = new Quad_Icons64x64_1();
$iconFrame->addChild($itemQuad);
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconServers);
$itemQuad->setSize($itemSize, $itemSize);
// Admin Menu Description
$descriptionLabel = new Label();
$frame->addChild($descriptionLabel);
$descriptionLabel->setPosition($adminPos->getX() - count($this->adminMenuItems) * $itemSize * 1.05 - 5, $adminPos->getY());
$descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP);
$descriptionLabel->setSize(40, 4);
$descriptionLabel->setTextSize(1.4);
$descriptionLabel->setTextColor('fff');
// Admin Menu
$popoutFrame = new Frame();
$frame->addChild($popoutFrame);
$popoutFrame->setPosition($adminPos->getX() - $itemSize * 0.5, $adminPos->getY());
$popoutFrame->setHorizontalAlign($popoutFrame::RIGHT);
$popoutFrame->setVisible(false);
$backgroundQuad = new Quad();
$popoutFrame->addChild($backgroundQuad);
$backgroundQuad->setHorizontalAlign($backgroundQuad::RIGHT);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$backgroundQuad->setSize(count($this->adminMenuItems) * $itemSize * 1.05 + 2, $itemSize * $itemMarginFactorY);
$itemQuad->addToggleFeature($popoutFrame);
// Add items
$itemPosX = -1;
foreach ($this->adminMenuItems as $menuItems) {
foreach ($menuItems as $menuItem) {
$menuQuad = $menuItem[0];
/** @var Quad $menuQuad */
$popoutFrame->addChild($menuQuad);
$menuQuad->setSize($itemSize, $itemSize);
$menuQuad->setX($itemPosX);
$menuQuad->setHorizontalAlign($menuQuad::RIGHT);
$itemPosX -= $itemSize * 1.05;
if ($menuItem[1]) {
$menuQuad->removeAllScriptFeatures();
$description = '$s' . $menuItem[1];
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
}
}
}
}
$playerPos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::PLAYER_MENU_ID);
/*
* Player Menu
*/
@ -287,6 +246,82 @@ class ActionsMenu implements SidebarMenuEntryRenderable, CallbackListener, Mania
return $maniaLink;
}
private function buildAdminMenuManiaLink() {
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
$itemMarginFactorX = 1.3;
$itemMarginFactorY = 1.2;
$maniaLink = new ManiaLink(self::MLID_ADMIN_MENU);
$frame = new Frame();
$maniaLink->addChild($frame);
$frame->setZ(ManialinkManager::MAIN_MANIALINK_Z_VALUE);
$adminPos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::ADMIN_MENU_ID);
// Admin Menu Icon Frame
$iconFrame = new Frame();
$frame->addChild($iconFrame);
$iconFrame->setPosition($adminPos->getX(), $adminPos->getY());
$backgroundQuad = new Quad();
$iconFrame->addChild($backgroundQuad);
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$itemQuad = new Quad_Icons64x64_1();
$iconFrame->addChild($itemQuad);
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconServers);
$itemQuad->setSize($itemSize, $itemSize);
// Admin Menu Description
$descriptionLabel = new Label();
$frame->addChild($descriptionLabel);
$descriptionLabel->setPosition($adminPos->getX() - count($this->adminMenuItems) * $itemSize * 1.05 - 5, $adminPos->getY());
$descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP);
$descriptionLabel->setSize(40, 4);
$descriptionLabel->setTextSize(1.4);
$descriptionLabel->setTextColor('fff');
// Admin Menu
$popoutFrame = new Frame();
$frame->addChild($popoutFrame);
$popoutFrame->setPosition($adminPos->getX() - $itemSize * 0.5, $adminPos->getY());
$popoutFrame->setHorizontalAlign($popoutFrame::RIGHT);
$popoutFrame->setVisible(false);
$backgroundQuad = new Quad();
$popoutFrame->addChild($backgroundQuad);
$backgroundQuad->setHorizontalAlign($backgroundQuad::RIGHT);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$backgroundQuad->setSize(count($this->adminMenuItems) * $itemSize * 1.05 + 2, $itemSize * $itemMarginFactorY);
$itemQuad->addToggleFeature($popoutFrame);
// Add items
$itemPosX = -1;
foreach ($this->adminMenuItems as $menuItems) {
foreach ($menuItems as $menuItem) {
$menuQuad = $menuItem[0];
/** @var Quad $menuQuad */
$popoutFrame->addChild($menuQuad);
$menuQuad->setSize($itemSize, $itemSize);
$menuQuad->setX($itemPosX);
$menuQuad->setHorizontalAlign($menuQuad::RIGHT);
$itemPosX -= $itemSize * 1.05;
if ($menuItem[1]) {
$menuQuad->removeAllScriptFeatures();
$description = '$s' . $menuItem[1];
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
}
}
}
return $maniaLink;
}
/**
* Add a new Admin Menu Item
*
@ -324,16 +359,6 @@ class ActionsMenu implements SidebarMenuEntryRenderable, CallbackListener, Mania
$this->rebuildAndShowMenu();
}
/**
* Handle ManiaControl AfterInit callback
*
* @internal
*/
public function handleAfterInit() {
$this->initCompleted = true;
$this->rebuildAndShowMenu();
}
/**
* Handle PlayerJoined callback
*
@ -342,11 +367,11 @@ class ActionsMenu implements SidebarMenuEntryRenderable, CallbackListener, Mania
*/
public function handlePlayerJoined(Player $player) {
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$maniaLink = $this->buildMenuIconsManialink(true);
} else {
$maniaLink = $this->buildMenuIconsManialink(false);
$maniaLink = $this->buildAdminMenuManiaLink();
$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player);
}
$maniaLink = $this->buildPlayerMenuManiaLink();
$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player);
}

View File

@ -0,0 +1,24 @@
<?php
namespace ManiaControl\Manialinks;
use ManiaControl\Callbacks\Listening;
class SidebarMenuEntry extends Listening {
private $id;
/**
* @return mixed
*/
public function getId() {
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id) {
$this->id = $id;
}
}

View File

@ -12,10 +12,5 @@ namespace ManiaControl\Manialinks;
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
interface SidebarMenuEntryRenderable {
/**
* Call here the function which updates the MenuIcon ManiaLink
*/
public function renderMenuEntry();
interface SidebarMenuEntryListener {
}

View File

@ -28,11 +28,10 @@ class SidebarMenuManager implements UsageInformationAble, CallbackListener {
const ORDER_ADMIN_MENU = 10;
const ORDER_PLAYER_MENU = 20;
/* @var $maniaControl ManiaControl */
/** @var ManiaControl $maniaControl */
private $maniaControl;
/** @var \ManiaControl\Manialinks\SidebarMenuEntry[] $menuEntries */
private $menuEntries = array();
private $yPositions = array();
private $registeredClasses = array();
/**
* SidebarMenuManager constructor.
@ -87,9 +86,9 @@ class SidebarMenuManager implements UsageInformationAble, CallbackListener {
/**
* Returns PositionObject of a menu item of the sidebar, or null if it's not found
*
* @api
* @param string $id
* @return Position|null
* @api
*/
public function getEntryPosition($id) {
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
@ -99,15 +98,8 @@ class SidebarMenuManager implements UsageInformationAble, CallbackListener {
$count = $this->getElementCountBeforeAdminMenu();
$pos->setY($pos->getY() + $itemSize * $itemMarginFactor * $count);
if (isset($this->yPositions[$id])) {
$pos->setY($this->yPositions[$id]);
return $pos;
}
foreach ($this->menuEntries as $entry) {
if ($entry == $id) {
$this->yPositions[$id] = $pos->getY();
if ($entry->getId() == $id) {
return $pos;
}
$pos->setY($pos->getY() - $itemSize * $itemMarginFactor);
@ -123,62 +115,73 @@ class SidebarMenuManager implements UsageInformationAble, CallbackListener {
* Get the associated position with getEntryPosition($id)
*
* @api
* @param SidebarMenuEntryRenderable $render
* @param $order
* @param $id
* @param \ManiaControl\Manialinks\SidebarMenuEntryListener $listener
* @param $renderMethod
* @return bool
*/
public function addMenuEntry(SidebarMenuEntryRenderable $render, $order, $id) {
public function addMenuEntry($order, $id, SidebarMenuEntryListener $listener, $renderMethod) {
if ((!is_string($renderMethod) || !method_exists($listener, $renderMethod)) && !is_callable($renderMethod)) {
trigger_error("Given Listener (" . get_class($listener) . ") can't handle Timer Callback (No Method '{$renderMethod}')!");
return false;
}
if (isset($this->menuEntries[$order])) {
if ($this->menuEntries[$order] != $id) {
return $this->addMenuEntry($render, $order + 1, $id);
if ($this->menuEntries[$order]->getId() != $id) {
return $this->addMenuEntry($order + 1, $id, $listener, $renderMethod);
}
}
$this->menuEntries[$order] = $id;
$this->yPositions = array();
$entry = new SidebarMenuEntry($listener, $renderMethod);
$entry->setId($id);
$this->menuEntries[$order] = $entry;
ksort($this->menuEntries);
$registered = false;
foreach ($this->registeredClasses as $class) {
$class->renderMenuEntry();
if ($class == $render) {
$registered = true;
}
}
if (!$registered) {
array_push($this->registeredClasses, $render);
$render->renderMenuEntry();
}
$this->updateMenuEntries();
return true;
}
/**
* Call all user functions
*/
private function updateMenuEntries() {
foreach ($this->menuEntries as $listening) {
// Call the User Function
$listening->triggerCallback();
}
}
/**
* @api
* @param SidebarMenuEntryRenderable $render
* @param SidebarMenuEntryListener $listener
* @param $id
* @param bool $unregisterClass
*/
public function deleteMenuEntry(SidebarMenuEntryRenderable $render, $id, $unregisterClass = false) {
public function deleteMenuEntry(SidebarMenuEntryListener $listener, $id) {
foreach ($this->menuEntries as $k => $entry) {
if ($entry == $id) {
if ($entry->getId() == $id) {
unset($this->menuEntries[$k]);
}
}
$this->updateMenuEntries();
}
/**
* @api
* @param \ManiaControl\Manialinks\SidebarMenuEntryListener $listener
*/
public function deleteMenuEntries(SidebarMenuEntryListener $listener) {
foreach ($this->menuEntries as $k => $entry) {
if ($entry->listener == $listener) {
unset($this->menuEntries[$k]);
$this->yPositions = array();
}
}
foreach ($this->registeredClasses as $k => $class) {
if ($class == $render && $unregisterClass) {
unset($this->registeredClasses[$k]);
}else{
$class->renderMenuEntry();
}
}
$this->updateMenuEntries();
}
}

View File

@ -564,12 +564,23 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
}
/**
* Get all Players
* Get all Players with or without spectators
*
* @api
* @return Player[]
* @param bool $withoutSpectators
* @return \ManiaControl\Players\Player[]
*/
public function getPlayers() {
public function getPlayers($withoutSpectators = false) {
if($withoutSpectators){
$players = array();
foreach($this->players as $player){
if(!$player->isSpectator){
$players[] = $players;
}
}
return $players;
}
return $this->players;
}

View File

@ -11,6 +11,7 @@ use ManiaControl\Files\FileUtil;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Manialinks\SidebarMenuEntryListener;
use ManiaControl\Update\PluginUpdateManager;
use ManiaControl\Utils\ClassUtil;
use ReflectionClass;
@ -186,6 +187,9 @@ class PluginManager {
if ($plugin instanceof TimerListener) {
$this->maniaControl->getTimerManager()->unregisterTimerListenings($plugin);
}
if($plugin instanceof SidebarMenuEntryListener){
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->deleteMenuEntries($plugin);
}
$this->savePluginStatus($pluginClass, false);

View File

@ -24,7 +24,7 @@ use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Manialinks\SidebarMenuEntryRenderable;
use ManiaControl\Manialinks\SidebarMenuEntryListener;
use ManiaControl\Manialinks\SidebarMenuManager;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
@ -47,7 +47,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CustomVotesPlugin implements SidebarMenuEntryRenderable, CommandListener, CallbackListener, ManialinkPageAnswerListener, TimerListener, Plugin {
class CustomVotesPlugin implements SidebarMenuEntryListener, CommandListener, CallbackListener, ManialinkPageAnswerListener, TimerListener, Plugin {
/*
* Constants
*/
@ -162,8 +162,7 @@ class CustomVotesPlugin implements SidebarMenuEntryRenderable, CommandListener,
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE, true);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_TIME, 40);
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry($this, SidebarMenuManager::ORDER_PLAYER_MENU + 5, self::CUSTOMVOTES_MENU_ID);
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_PLAYER_MENU + 5, self::CUSTOMVOTES_MENU_ID,$this,'showIcon');
//Define Votes
$this->defineVote("teambalance", "Vote for Team Balance");
$this->defineVote("skipmap", "Vote for Skip Map")->setStopCallback(Callbacks::ENDMAP);
@ -268,7 +267,7 @@ class CustomVotesPlugin implements SidebarMenuEntryRenderable, CommandListener,
*
* @param bool $login
*/
private function showIcon($login = false) {
public function showIcon($login = false) {
$pos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::CUSTOMVOTES_MENU_ID);
$width = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getManialinkManager()->getSidebarMenuManager(), SidebarMenuManager::SETTING_MENU_ITEMSIZE);
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
@ -372,7 +371,6 @@ class CustomVotesPlugin implements SidebarMenuEntryRenderable, CommandListener,
$this->destroyVote();
$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_ICON);
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->deleteMenuEntry($this, self::CUSTOMVOTES_MENU_ID, true);
}
/**
@ -799,13 +797,6 @@ class CustomVotesPlugin implements SidebarMenuEntryRenderable, CommandListener,
$this->constructMenu();
}
/**
* Call here the function which updates the MenuIcon Manialink
*/
public function renderMenuEntry() {
$this->showIcon();
}
}
/**

View File

@ -19,7 +19,7 @@ use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\SidebarMenuEntryRenderable;
use ManiaControl\Manialinks\SidebarMenuEntryListener;
use ManiaControl\Manialinks\SidebarMenuManager;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
@ -32,7 +32,7 @@ use ManiaControl\Plugins\Plugin;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class DonationPlugin implements CallbackListener, CommandListener, Plugin, SidebarMenuEntryRenderable {
class DonationPlugin implements CallbackListener, CommandListener, Plugin, SidebarMenuEntryListener {
/*
* Constants
*/
@ -117,7 +117,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb
// Define player stats
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_DONATIONS);
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry($this,SidebarMenuManager::ORDER_PLAYER_MENU, self::DONATIONPLUGIN_MENU_ID);
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_PLAYER_MENU + 5,self::DONATIONPLUGIN_MENU_ID,$this,'displayDonateWidget');
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED, true);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATION_VALUES, "20,50,100,500,1000,2000");
@ -130,6 +130,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb
return true;
}
/**
* Display the widget
*/
@ -234,7 +235,6 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb
*/
public function unload() {
$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_DONATE_WIDGET);
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->deleteMenuEntry($this,self::DONATIONPLUGIN_MENU_ID,true);
}
/**
@ -531,8 +531,4 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb
// Render and display xml
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'TopDons');
}
public function renderMenuEntry() {
$this->displayDonateWidget();
}
}