2013-11-13 01:43:12 +01:00
|
|
|
<?php
|
|
|
|
|
2013-11-28 03:47:08 +01:00
|
|
|
namespace ManiaControl\Admin;
|
2013-11-13 01:43:12 +01:00
|
|
|
|
2013-11-28 03:47:08 +01:00
|
|
|
use FML\Controls\Control;
|
|
|
|
use FML\Controls\Frame;
|
2014-01-05 01:29:49 +01:00
|
|
|
use FML\Controls\Label;
|
2013-11-28 03:47:08 +01:00
|
|
|
use FML\Controls\Quad;
|
2014-01-02 17:21:01 +01:00
|
|
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
|
|
|
use FML\ManiaLink;
|
|
|
|
use ManiaControl\Callbacks\CallbackListener;
|
2014-05-24 16:39:12 +02:00
|
|
|
use ManiaControl\Callbacks\Callbacks;
|
2017-03-26 19:44:55 +02:00
|
|
|
use ManiaControl\General\UsageInformationAble;
|
|
|
|
use ManiaControl\General\UsageInformationTrait;
|
2014-01-02 17:21:01 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
2017-04-11 11:56:27 +02:00
|
|
|
use ManiaControl\Manialinks\ManialinkManager;
|
2013-12-29 15:52:01 +01:00
|
|
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
2017-05-11 22:35:16 +02:00
|
|
|
use ManiaControl\Manialinks\SidebarMenuEntryRenderable;
|
2017-05-11 20:02:28 +02:00
|
|
|
use ManiaControl\Manialinks\SidebarMenuManager;
|
2013-11-28 03:47:08 +01:00
|
|
|
use ManiaControl\Players\Player;
|
|
|
|
use ManiaControl\Players\PlayerManager;
|
2017-05-07 20:22:59 +02:00
|
|
|
use ManiaControl\Settings\Setting;
|
|
|
|
use ManiaControl\Settings\SettingManager;
|
2013-11-28 03:47:08 +01:00
|
|
|
|
|
|
|
/**
|
2013-12-31 12:42:07 +01:00
|
|
|
* Class managing Actions Menus
|
2013-11-28 03:47:08 +01:00
|
|
|
*
|
2017-04-07 23:38:18 +02:00
|
|
|
* @api
|
2014-05-02 17:31:10 +02:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2017-02-04 11:49:23 +01:00
|
|
|
* @copyright 2014-2017 ManiaControl Team
|
2014-05-02 17:31:10 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2013-11-28 03:47:08 +01:00
|
|
|
*/
|
2017-05-11 22:35:16 +02:00
|
|
|
class ActionsMenu implements SidebarMenuEntryRenderable, CallbackListener, ManialinkPageAnswerListener, UsageInformationAble {
|
2017-03-26 19:44:55 +02:00
|
|
|
use UsageInformationTrait;
|
2017-04-07 23:38:18 +02:00
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2013-11-28 03:47:08 +01:00
|
|
|
* Constants
|
|
|
|
*/
|
2017-05-08 12:31:14 +02:00
|
|
|
const MLID_MENU = 'ActionsMenu.MLID';
|
|
|
|
const SETTING_MENU_POSX = 'Menu Position: X';
|
|
|
|
const SETTING_MENU_POSY_SHOOTMANIA = 'Shootmania Menu Position: Y';
|
|
|
|
const SETTING_MENU_POSY_TRACKMANIA = 'Trackmania Menu Position: Y';
|
|
|
|
const SETTING_MENU_ITEMSIZE = 'Menu Item Size';
|
|
|
|
const ACTION_OPEN_ADMIN_MENU = 'ActionsMenu.OpenAdminMenu';
|
|
|
|
const ACTION_OPEN_PLAYER_MENU = 'ActionsMenu.OpenPlayerMenu';
|
2017-05-11 20:02:28 +02:00
|
|
|
const ADMIN_MENU_ID = 'ActionsMenu.AdminMenu';
|
|
|
|
const PLAYER_MENU_ID = 'ActionsMenu.PlayerMenu';
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2014-08-02 22:31:46 +02:00
|
|
|
* Private properties
|
2013-11-28 03:47:08 +01:00
|
|
|
*/
|
2014-08-02 22:31:46 +02:00
|
|
|
/** @var ManiaControl $maniaControl */
|
2014-10-24 20:19:57 +02:00
|
|
|
private $maniaControl = null;
|
|
|
|
private $adminMenuItems = array();
|
2013-12-31 12:42:07 +01:00
|
|
|
private $playerMenuItems = array();
|
2014-10-24 20:19:57 +02:00
|
|
|
private $initCompleted = false;
|
2014-01-05 01:29:49 +01:00
|
|
|
|
2013-11-28 03:47:08 +01:00
|
|
|
/**
|
2014-08-02 22:31:46 +02:00
|
|
|
* Construct a new Actions Menu instance
|
2013-11-28 03:47:08 +01:00
|
|
|
*
|
2013-12-31 12:24:54 +01:00
|
|
|
* @param ManiaControl $maniaControl
|
2013-11-28 03:47:08 +01:00
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-08-03 01:34:18 +02:00
|
|
|
// Settings
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_POSX, 156.);
|
2017-05-08 12:31:14 +02:00
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_POSY_SHOOTMANIA, -37.);
|
2017-05-08 12:32:35 +02:00
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_POSY_TRACKMANIA, 17.);
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
|
2014-08-03 01:34:18 +02:00
|
|
|
|
|
|
|
// Callbacks
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
|
|
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
|
|
|
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined');
|
2017-05-07 20:22:59 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged');
|
|
|
|
|
2017-05-11 22:35:16 +02:00
|
|
|
$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);
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 12:42:07 +01:00
|
|
|
* Add a new Menu Item
|
2013-11-28 03:47:08 +01:00
|
|
|
*
|
2017-04-07 23:38:18 +02:00
|
|
|
* @api
|
2013-12-09 19:45:40 +01:00
|
|
|
* @param Control $control
|
2014-05-02 17:31:10 +02:00
|
|
|
* @param bool $playerAction
|
|
|
|
* @param int $order
|
|
|
|
* @param string $description
|
2013-11-28 03:47:08 +01:00
|
|
|
*/
|
2014-01-05 12:56:47 +01:00
|
|
|
public function addMenuItem(Control $control, $playerAction = true, $order = 0, $description = null) {
|
2014-04-27 18:59:21 +02:00
|
|
|
if ($playerAction) {
|
2014-01-04 21:54:40 +01:00
|
|
|
$this->addPlayerMenuItem($control, $order, $description);
|
2014-05-02 17:31:10 +02:00
|
|
|
} else {
|
2014-01-05 00:43:46 +01:00
|
|
|
$this->addAdminMenuItem($control, $order, $description);
|
2013-12-31 12:42:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new Player Menu Item
|
|
|
|
*
|
2017-04-07 23:38:18 +02:00
|
|
|
* @api
|
2013-12-31 12:42:07 +01:00
|
|
|
* @param Control $control
|
2014-05-02 17:31:10 +02:00
|
|
|
* @param int $order
|
|
|
|
* @param string $description
|
2013-12-31 12:42:07 +01:00
|
|
|
*/
|
2014-01-05 12:56:47 +01:00
|
|
|
public function addPlayerMenuItem(Control $control, $order = 0, $description = null) {
|
2014-04-27 18:59:21 +02:00
|
|
|
if (!isset($this->playerMenuItems[$order])) {
|
2013-12-31 12:42:07 +01:00
|
|
|
$this->playerMenuItems[$order] = array();
|
|
|
|
}
|
2014-01-05 12:56:47 +01:00
|
|
|
array_push($this->playerMenuItems[$order], array($control, $description));
|
2014-01-05 13:44:04 +01:00
|
|
|
krsort($this->playerMenuItems);
|
2014-01-05 12:56:47 +01:00
|
|
|
$this->rebuildAndShowMenu();
|
2013-12-31 12:42:07 +01:00
|
|
|
}
|
|
|
|
|
2014-01-05 00:43:46 +01:00
|
|
|
/**
|
|
|
|
* Build and show the menus to everyone (if a menu get made after the init)
|
2017-04-07 23:38:18 +02:00
|
|
|
*
|
|
|
|
* @api
|
2014-01-05 00:43:46 +01:00
|
|
|
*/
|
|
|
|
public function rebuildAndShowMenu() {
|
2014-04-27 18:59:21 +02:00
|
|
|
if (!$this->initCompleted) {
|
2014-01-09 18:19:37 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-05-09 13:15:16 +02:00
|
|
|
|
|
|
|
//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);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Send Menu to Players - Players with No Admin Permisssions
|
|
|
|
$players = $this->maniaControl->getAuthenticationManager()->getConnectedPlayers();
|
|
|
|
if (!empty($players)) {
|
|
|
|
$manialink = $this->buildMenuIconsManialink(false);
|
|
|
|
$this->maniaControl->getManialinkManager()->sendManialink($manialink, $players);
|
2014-01-05 00:43:46 +01:00
|
|
|
}
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2014-01-04 18:49:33 +01:00
|
|
|
/**
|
|
|
|
* Builds the Manialink
|
|
|
|
*
|
2017-05-11 20:02:28 +02:00
|
|
|
* @param Player $player
|
2014-01-04 18:49:33 +01:00
|
|
|
* @return ManiaLink
|
|
|
|
*/
|
2017-05-09 13:15:16 +02:00
|
|
|
private function buildMenuIconsManialink($admin = false) {
|
2017-05-11 20:02:28 +02:00
|
|
|
$adminPos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::ADMIN_MENU_ID);
|
|
|
|
$playerPos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::PLAYER_MENU_ID);
|
2014-08-13 11:05:52 +02:00
|
|
|
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
|
|
|
|
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
|
|
|
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
|
2013-12-29 15:52:01 +01:00
|
|
|
$itemMarginFactorX = 1.3;
|
|
|
|
$itemMarginFactorY = 1.2;
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2017-04-11 11:56:27 +02:00
|
|
|
$maniaLink = new ManiaLink(self::MLID_MENU);
|
2017-05-08 12:31:14 +02:00
|
|
|
$frame = new Frame();
|
2017-04-11 11:56:27 +02:00
|
|
|
$maniaLink->addChild($frame);
|
|
|
|
$frame->setZ(ManialinkManager::MAIN_MANIALINK_Z_VALUE);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-01-05 12:56:47 +01:00
|
|
|
/*
|
|
|
|
* Admin Menu
|
|
|
|
*/
|
2017-05-09 13:15:16 +02:00
|
|
|
if ($admin) {
|
2014-01-05 12:56:47 +01:00
|
|
|
// Admin Menu Icon Frame
|
|
|
|
$iconFrame = new Frame();
|
2017-04-11 11:56:27 +02:00
|
|
|
$frame->addChild($iconFrame);
|
2017-05-11 20:02:28 +02:00
|
|
|
$iconFrame->setPosition($adminPos['x'], $adminPos['y']);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-01-05 12:56:47 +01:00
|
|
|
$backgroundQuad = new Quad();
|
2017-03-25 19:15:50 +01:00
|
|
|
$iconFrame->addChild($backgroundQuad);
|
2014-01-05 12:56:47 +01:00
|
|
|
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
|
|
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-01-05 12:56:47 +01:00
|
|
|
$itemQuad = new Quad_Icons64x64_1();
|
2017-03-25 19:15:50 +01:00
|
|
|
$iconFrame->addChild($itemQuad);
|
2014-01-05 12:56:47 +01:00
|
|
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconServers);
|
|
|
|
$itemQuad->setSize($itemSize, $itemSize);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-04-27 19:22:20 +02:00
|
|
|
// Admin Menu Description
|
2014-01-05 12:56:47 +01:00
|
|
|
$descriptionLabel = new Label();
|
2017-04-11 11:56:27 +02:00
|
|
|
$frame->addChild($descriptionLabel);
|
2017-05-11 20:02:28 +02:00
|
|
|
$descriptionLabel->setPosition($adminPos['x'] - count($this->adminMenuItems) * $itemSize * 1.05 - 5, $adminPos['y']);
|
2014-06-22 19:02:18 +02:00
|
|
|
$descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP);
|
2014-01-05 12:56:47 +01:00
|
|
|
$descriptionLabel->setSize(40, 4);
|
|
|
|
$descriptionLabel->setTextSize(1.4);
|
|
|
|
$descriptionLabel->setTextColor('fff');
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-01-05 12:56:47 +01:00
|
|
|
// Admin Menu
|
2014-01-04 18:49:33 +01:00
|
|
|
$popoutFrame = new Frame();
|
2017-04-11 11:56:27 +02:00
|
|
|
$frame->addChild($popoutFrame);
|
2017-05-11 20:02:28 +02:00
|
|
|
$popoutFrame->setPosition($adminPos['x'] - $itemSize * 0.5, $adminPos['y']);
|
2017-03-25 19:15:50 +01:00
|
|
|
$popoutFrame->setHorizontalAlign($popoutFrame::RIGHT);
|
2014-01-12 01:59:23 +01:00
|
|
|
$popoutFrame->setVisible(false);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-01-05 12:56:47 +01:00
|
|
|
$backgroundQuad = new Quad();
|
2017-03-25 19:15:50 +01:00
|
|
|
$popoutFrame->addChild($backgroundQuad);
|
|
|
|
$backgroundQuad->setHorizontalAlign($backgroundQuad::RIGHT);
|
2014-01-05 12:56:47 +01:00
|
|
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
2017-04-07 23:38:18 +02:00
|
|
|
$backgroundQuad->setSize(count($this->adminMenuItems) * $itemSize * 1.05 + 2, $itemSize * $itemMarginFactorY);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-04-27 18:59:21 +02:00
|
|
|
$itemQuad->addToggleFeature($popoutFrame);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-01-04 18:49:33 +01:00
|
|
|
// Add items
|
2014-06-17 23:55:59 +02:00
|
|
|
$itemPosX = -1;
|
2014-04-27 18:59:21 +02:00
|
|
|
foreach ($this->adminMenuItems as $menuItems) {
|
|
|
|
foreach ($menuItems as $menuItem) {
|
2014-01-05 12:56:47 +01:00
|
|
|
$menuQuad = $menuItem[0];
|
2014-06-17 23:55:59 +02:00
|
|
|
/** @var Quad $menuQuad */
|
2017-03-25 19:15:50 +01:00
|
|
|
$popoutFrame->addChild($menuQuad);
|
2014-01-05 12:56:47 +01:00
|
|
|
$menuQuad->setSize($itemSize, $itemSize);
|
2014-06-17 23:55:59 +02:00
|
|
|
$menuQuad->setX($itemPosX);
|
2017-03-25 19:15:50 +01:00
|
|
|
$menuQuad->setHorizontalAlign($menuQuad::RIGHT);
|
2014-06-17 23:55:59 +02:00
|
|
|
$itemPosX -= $itemSize * 1.05;
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-04-27 18:59:21 +02:00
|
|
|
if ($menuItem[1]) {
|
2017-03-25 19:15:50 +01:00
|
|
|
$menuQuad->removeAllScriptFeatures();
|
2014-01-05 12:56:47 +01:00
|
|
|
$description = '$s' . $menuItem[1];
|
2014-04-27 18:59:21 +02:00
|
|
|
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
2014-01-05 12:56:47 +01:00
|
|
|
}
|
|
|
|
}
|
2014-01-04 18:18:46 +01:00
|
|
|
}
|
|
|
|
}
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-01-05 12:56:47 +01:00
|
|
|
/*
|
|
|
|
* Player Menu
|
|
|
|
*/
|
2013-12-31 13:34:10 +01:00
|
|
|
// Player Menu Icon Frame
|
2014-01-05 12:56:47 +01:00
|
|
|
$iconFrame = new Frame();
|
2017-04-11 11:56:27 +02:00
|
|
|
$frame->addChild($iconFrame);
|
2017-05-11 20:02:28 +02:00
|
|
|
$iconFrame->setPosition($playerPos['x'], $playerPos['y']);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2013-12-29 15:57:11 +01:00
|
|
|
$backgroundQuad = new Quad();
|
2017-03-25 19:15:50 +01:00
|
|
|
$iconFrame->addChild($backgroundQuad);
|
2013-12-29 15:57:11 +01:00
|
|
|
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
|
|
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2013-12-31 13:21:45 +01:00
|
|
|
$itemQuad = new Quad_Icons64x64_1();
|
2017-03-25 19:15:50 +01:00
|
|
|
$iconFrame->addChild($itemQuad);
|
2013-12-31 13:34:10 +01:00
|
|
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconPlayers);
|
2013-12-29 15:57:11 +01:00
|
|
|
$itemQuad->setSize($itemSize, $itemSize);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-04-27 19:22:20 +02:00
|
|
|
// Player Menu Description
|
2014-01-05 12:56:47 +01:00
|
|
|
$descriptionLabel = new Label();
|
2017-04-11 11:56:27 +02:00
|
|
|
$frame->addChild($descriptionLabel);
|
2017-05-11 20:02:28 +02:00
|
|
|
$descriptionLabel->setPosition($playerPos['x'] - count($this->playerMenuItems) * $itemSize * 1.05 - 5, $playerPos['y']);
|
2014-06-22 19:02:18 +02:00
|
|
|
$descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP);
|
2014-01-05 12:56:47 +01:00
|
|
|
$descriptionLabel->setSize(40, 4);
|
|
|
|
$descriptionLabel->setTextSize(1.4);
|
|
|
|
$descriptionLabel->setTextColor('fff');
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-01-05 12:56:47 +01:00
|
|
|
// Player Menu
|
2014-01-04 17:55:42 +01:00
|
|
|
$popoutFrame = new Frame();
|
2017-04-11 11:56:27 +02:00
|
|
|
$frame->addChild($popoutFrame);
|
2017-05-11 20:02:28 +02:00
|
|
|
$popoutFrame->setPosition($playerPos['x'] - $itemSize * 0.5, $playerPos['y']);
|
2017-03-25 19:15:50 +01:00
|
|
|
$popoutFrame->setHorizontalAlign($popoutFrame::RIGHT);
|
2014-01-12 01:59:23 +01:00
|
|
|
$popoutFrame->setVisible(false);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-01-05 12:56:47 +01:00
|
|
|
$backgroundQuad = new Quad();
|
2017-03-25 19:15:50 +01:00
|
|
|
$popoutFrame->addChild($backgroundQuad);
|
|
|
|
$backgroundQuad->setHorizontalAlign($backgroundQuad::RIGHT);
|
2014-01-05 12:56:47 +01:00
|
|
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
2017-03-28 16:44:41 +02:00
|
|
|
$backgroundQuad->setSize(count($this->playerMenuItems) * $itemSize * 1.05 + 2, $itemSize * $itemMarginFactorY);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-04-27 18:59:21 +02:00
|
|
|
$itemQuad->addToggleFeature($popoutFrame);
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-01-04 17:55:42 +01:00
|
|
|
// Add items
|
2014-06-17 23:55:59 +02:00
|
|
|
$itemPosX = -1;
|
2014-04-27 18:59:21 +02:00
|
|
|
foreach ($this->playerMenuItems as $menuItems) {
|
|
|
|
foreach ($menuItems as $menuItem) {
|
2014-01-05 12:56:47 +01:00
|
|
|
$menuQuad = $menuItem[0];
|
2014-06-17 23:55:59 +02:00
|
|
|
/** @var Quad $menuQuad */
|
2017-03-25 19:15:50 +01:00
|
|
|
$popoutFrame->addChild($menuQuad);
|
2014-01-05 12:56:47 +01:00
|
|
|
$menuQuad->setSize($itemSize, $itemSize);
|
2014-06-17 23:55:59 +02:00
|
|
|
$menuQuad->setX($itemPosX);
|
2017-03-25 19:15:50 +01:00
|
|
|
$menuQuad->setHorizontalAlign($menuQuad::RIGHT);
|
2014-06-17 23:55:59 +02:00
|
|
|
$itemPosX -= $itemSize * 1.05;
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2014-04-27 18:59:21 +02:00
|
|
|
if ($menuItem[1]) {
|
2017-03-25 19:15:50 +01:00
|
|
|
$menuQuad->removeAllScriptFeatures();
|
2014-01-05 12:56:47 +01:00
|
|
|
$description = '$s' . $menuItem[1];
|
2014-04-27 18:59:21 +02:00
|
|
|
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
2014-01-05 12:56:47 +01:00
|
|
|
}
|
|
|
|
}
|
2014-01-04 17:55:42 +01:00
|
|
|
}
|
2014-05-02 17:31:10 +02:00
|
|
|
|
2017-04-11 11:56:27 +02:00
|
|
|
return $maniaLink;
|
2013-12-29 15:52:01 +01:00
|
|
|
}
|
2014-05-02 17:31:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new Admin Menu Item
|
|
|
|
*
|
2017-04-07 23:38:18 +02:00
|
|
|
* @api
|
2014-05-02 17:31:10 +02:00
|
|
|
* @param Control $control
|
|
|
|
* @param int $order
|
|
|
|
* @param string $description
|
|
|
|
*/
|
|
|
|
public function addAdminMenuItem(Control $control, $order = 0, $description = null) {
|
|
|
|
if (!isset($this->adminMenuItems[$order])) {
|
|
|
|
$this->adminMenuItems[$order] = array();
|
|
|
|
}
|
|
|
|
array_push($this->adminMenuItems[$order], array($control, $description));
|
|
|
|
krsort($this->adminMenuItems);
|
|
|
|
$this->rebuildAndShowMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a Menu Item
|
|
|
|
*
|
2017-04-07 23:38:18 +02:00
|
|
|
* @api
|
2014-07-19 23:12:20 +02:00
|
|
|
* @param int $order
|
2014-05-02 17:31:10 +02:00
|
|
|
* @param bool $playerAction
|
|
|
|
*/
|
|
|
|
public function removeMenuItem($order, $playerAction = true) {
|
|
|
|
if ($playerAction) {
|
2014-10-24 20:19:57 +02:00
|
|
|
if (isset($this->playerMenuItems[$order])) {
|
2014-07-04 18:25:09 +02:00
|
|
|
unset($this->playerMenuItems[$order]);
|
|
|
|
}
|
2014-05-02 17:31:10 +02:00
|
|
|
} else {
|
2015-02-04 23:16:52 +01:00
|
|
|
if (isset($this->adminMenuItems[$order])) {
|
2014-07-04 18:25:09 +02:00
|
|
|
unset($this->adminMenuItems[$order]);
|
|
|
|
}
|
2014-05-02 17:31:10 +02:00
|
|
|
}
|
|
|
|
$this->rebuildAndShowMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle ManiaControl AfterInit callback
|
2017-04-07 23:38:18 +02:00
|
|
|
*
|
|
|
|
* @internal
|
2014-05-02 17:31:10 +02:00
|
|
|
*/
|
|
|
|
public function handleAfterInit() {
|
|
|
|
$this->initCompleted = true;
|
|
|
|
$this->rebuildAndShowMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle PlayerJoined callback
|
|
|
|
*
|
2017-04-07 23:38:18 +02:00
|
|
|
* @internal
|
2014-05-02 17:31:10 +02:00
|
|
|
* @param Player $player
|
|
|
|
*/
|
|
|
|
public function handlePlayerJoined(Player $player) {
|
2017-05-11 20:02:28 +02:00
|
|
|
$maniaLink = $this->buildMenuIconsManialink($player);
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player);
|
2014-05-02 17:31:10 +02:00
|
|
|
}
|
2017-05-07 20:22:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Setting Changed Callback
|
|
|
|
*
|
|
|
|
* @param Setting $setting
|
|
|
|
*/
|
|
|
|
public function handleSettingChanged(Setting $setting) {
|
|
|
|
if (!$setting->belongsToClass($this)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->rebuildAndShowMenu();
|
|
|
|
}
|
2017-05-11 22:35:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Call here the function which updates the MenuIcon Manialink
|
|
|
|
*/
|
2017-05-11 22:37:17 +02:00
|
|
|
public function renderMenuEntry() {
|
2017-05-11 22:35:16 +02:00
|
|
|
$this->rebuildAndShowMenu();
|
|
|
|
}
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|