2013-11-28 03:47:08 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Configurators;
|
|
|
|
|
2013-11-28 04:48:04 +01:00
|
|
|
use FML\Controls\Frame;
|
2013-11-28 17:36:39 +01:00
|
|
|
use FML\Controls\Label;
|
|
|
|
use FML\Controls\Labels\Label_Text;
|
|
|
|
use FML\Controls\Quad;
|
2013-11-28 04:48:04 +01:00
|
|
|
use FML\Controls\Quads\Quad_BgRaceScore2;
|
2013-12-14 23:32:21 +01:00
|
|
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
2014-01-05 19:00:11 +01:00
|
|
|
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
|
|
|
use FML\ManiaLink;
|
2013-11-28 17:36:39 +01:00
|
|
|
use FML\Script\Script;
|
2014-01-05 19:00:11 +01:00
|
|
|
use ManiaControl\Callbacks\CallbackListener;
|
|
|
|
use ManiaControl\Callbacks\CallbackManager;
|
2013-12-31 13:21:45 +01:00
|
|
|
use ManiaControl\Commands\CommandListener;
|
2014-01-05 19:00:11 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
use ManiaControl\Manialinks\ManialinkManager;
|
|
|
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
|
|
|
use ManiaControl\Players\Player;
|
2013-11-28 17:36:39 +01:00
|
|
|
|
2013-11-28 03:47:08 +01:00
|
|
|
/**
|
|
|
|
* Class managing ingame ManiaControl configuration
|
|
|
|
*
|
|
|
|
* @author steeffeen & kremsy
|
|
|
|
*/
|
2013-12-31 13:21:45 +01:00
|
|
|
class Configurator implements CallbackListener, CommandListener, ManialinkPageAnswerListener {
|
2013-11-28 03:47:08 +01:00
|
|
|
/**
|
|
|
|
* Constants
|
|
|
|
*/
|
2014-01-05 19:00:11 +01:00
|
|
|
const ACTION_TOGGLEMENU = 'Configurator.ToggleMenuAction';
|
|
|
|
const ACTION_SAVECONFIG = 'Configurator.SaveConfigAction';
|
2014-01-05 20:02:38 +01:00
|
|
|
const ACTION_SELECTMENU = 'Configurator.SelectMenu';
|
2014-01-05 19:00:11 +01:00
|
|
|
const SETTING_MENU_POSX = 'Menu Widget Position: X';
|
|
|
|
const SETTING_MENU_POSY = 'Menu Widget Position: Y';
|
|
|
|
const SETTING_MENU_WIDTH = 'Menu Widget Width';
|
|
|
|
const SETTING_MENU_HEIGHT = 'Menu Widget Height';
|
|
|
|
const SETTING_MENU_STYLE = 'Menu Widget BackgroundQuad Style';
|
2013-11-28 17:36:39 +01:00
|
|
|
const SETTING_MENU_SUBSTYLE = 'Menu Widget BackgroundQuad Substyle';
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 03:47:08 +01:00
|
|
|
/**
|
|
|
|
* Private properties
|
|
|
|
*/
|
|
|
|
private $maniaControl = null;
|
2013-11-28 17:36:39 +01:00
|
|
|
private $scriptSettings = null;
|
2014-01-02 23:49:21 +01:00
|
|
|
private $serverSettings = null;
|
2014-01-05 19:00:11 +01:00
|
|
|
private $maniaControlSettings = null;
|
2013-11-28 17:36:39 +01:00
|
|
|
private $menus = array();
|
2013-11-28 04:48:04 +01:00
|
|
|
private $playersMenuShown = array();
|
2013-11-28 03:47:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new Configurator
|
|
|
|
*
|
2013-12-31 12:42:07 +01:00
|
|
|
* @param ManiaControl $maniaControl
|
2013-11-28 03:47:08 +01:00
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
2013-12-31 13:21:45 +01:00
|
|
|
$this->addActionsMenuItem();
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
// Init settings
|
|
|
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSX, 0.);
|
2013-12-09 09:07:55 +01:00
|
|
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSY, 3.);
|
2013-11-28 17:36:39 +01:00
|
|
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_WIDTH, 170.);
|
2013-12-09 09:07:55 +01:00
|
|
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_HEIGHT, 81.);
|
2013-11-28 17:36:39 +01:00
|
|
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_STYLE, Quad_BgRaceScore2::STYLE);
|
2014-01-05 12:56:34 +01:00
|
|
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_SUBSTYLE, Quad_BgRaceScore2::SUBSTYLE_HandleSelectable);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 04:48:04 +01:00
|
|
|
// Register for page answers
|
2014-01-05 12:56:34 +01:00
|
|
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_TOGGLEMENU, $this, 'handleToggleMenuAction');
|
|
|
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SAVECONFIG, $this, 'handleSaveConfigAction');
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 04:48:04 +01:00
|
|
|
// Register for callbacks
|
2014-01-05 12:56:34 +01:00
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
2014-01-05 20:02:38 +01:00
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
2014-01-11 17:36:46 +01:00
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
// Create server settings
|
|
|
|
$this->serverSettings = new ServerSettings($maniaControl);
|
|
|
|
$this->addMenu($this->serverSettings);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
|
|
|
// Create script settings
|
|
|
|
$this->scriptSettings = new ScriptSettings($maniaControl);
|
|
|
|
$this->addMenu($this->scriptSettings);
|
|
|
|
|
|
|
|
// Create Mania Control Settings
|
2014-01-05 19:01:48 +01:00
|
|
|
$this->maniaControlSettings = new ManiaControlSettings($maniaControl);
|
2014-01-05 19:00:11 +01:00
|
|
|
$this->addMenu($this->maniaControlSettings);
|
|
|
|
|
2013-12-31 13:21:45 +01:00
|
|
|
// Register for commands
|
|
|
|
$this->maniaControl->commandManager->registerCommandListener('config', $this, 'handleConfigCommand', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Config Admin Aommand
|
|
|
|
*
|
|
|
|
* @param array $callback
|
|
|
|
*/
|
|
|
|
public function handleConfigCommand(array $callback, Player $player) {
|
|
|
|
$this->showMenu($player);
|
2013-11-28 17:36:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a configurator menu
|
|
|
|
*
|
2013-12-31 12:42:07 +01:00
|
|
|
* @param ConfiguratorMenu $menu
|
2013-11-28 17:36:39 +01:00
|
|
|
*/
|
|
|
|
public function addMenu(ConfiguratorMenu $menu) {
|
|
|
|
array_push($this->menus, $menu);
|
2013-11-28 04:48:04 +01:00
|
|
|
}
|
|
|
|
|
2013-12-30 20:12:53 +01:00
|
|
|
/**
|
|
|
|
* Reopens the Menu
|
2013-12-31 12:42:07 +01:00
|
|
|
*
|
2013-12-30 20:12:53 +01:00
|
|
|
* @param array $callback
|
|
|
|
*/
|
2014-01-18 21:05:45 +01:00
|
|
|
public function reopenMenu($player, $menuId = 0) {
|
|
|
|
$this->showMenu($player, $menuId);
|
2013-12-30 20:12:53 +01:00
|
|
|
}
|
2013-12-31 12:42:07 +01:00
|
|
|
|
2013-11-28 04:48:04 +01:00
|
|
|
/**
|
|
|
|
* Handle toggle menu action
|
|
|
|
*
|
2014-01-05 19:00:11 +01:00
|
|
|
* @param array $callback
|
2013-12-31 12:42:07 +01:00
|
|
|
* @param Player $player
|
2013-11-28 04:48:04 +01:00
|
|
|
*/
|
|
|
|
public function handleToggleMenuAction(array $callback, Player $player) {
|
2013-12-31 13:21:45 +01:00
|
|
|
$this->toggleMenu($player);
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
/**
|
|
|
|
* Save the config data received from the manialink
|
|
|
|
*
|
2014-01-05 19:00:11 +01:00
|
|
|
* @param array $callback
|
2013-12-31 12:42:07 +01:00
|
|
|
* @param Player $player
|
2013-11-28 17:36:39 +01:00
|
|
|
*/
|
|
|
|
public function handleSaveConfigAction(array $callback, Player $player) {
|
2014-01-05 19:00:11 +01:00
|
|
|
foreach($this->menus as $menu) {
|
2014-01-11 17:36:46 +01:00
|
|
|
/** @var ConfiguratorMenu $menu */
|
2013-11-28 17:36:39 +01:00
|
|
|
$menu->saveConfigData($callback[1], $player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-28 03:47:08 +01:00
|
|
|
/**
|
2013-11-28 04:48:04 +01:00
|
|
|
* Handle PlayerDisconnect callback
|
2013-11-28 03:47:08 +01:00
|
|
|
*
|
2013-12-31 12:42:07 +01:00
|
|
|
* @param array $callback
|
2013-11-28 04:48:04 +01:00
|
|
|
*/
|
|
|
|
public function handlePlayerDisconnect(array $callback) {
|
|
|
|
$login = $callback[1][0];
|
2013-11-28 17:36:39 +01:00
|
|
|
unset($this->playersMenuShown[$login]);
|
2013-11-28 04:48:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 13:21:45 +01:00
|
|
|
* Show the Menu to the Player
|
2013-11-28 04:48:04 +01:00
|
|
|
*
|
2013-12-31 12:42:07 +01:00
|
|
|
* @param Player $player
|
2014-01-05 20:02:38 +01:00
|
|
|
* @param int $menuId
|
2013-11-28 04:48:04 +01:00
|
|
|
*/
|
2014-01-05 20:02:38 +01:00
|
|
|
public function showMenu(Player $player, $menuId = 0) {
|
2014-01-11 17:36:46 +01:00
|
|
|
$manialink = $this->buildManialink($menuId);
|
|
|
|
$this->maniaControl->manialinkManager->displayWidget($manialink, $player, "Configurator");
|
2013-11-28 04:48:04 +01:00
|
|
|
$this->playersMenuShown[$player->login] = true;
|
|
|
|
}
|
|
|
|
|
2014-01-11 17:36:46 +01:00
|
|
|
/**
|
|
|
|
* Unset the player if he opened another Main Widget
|
|
|
|
*
|
|
|
|
* @param array $callback
|
|
|
|
*/
|
|
|
|
public function handleWidgetOpened(array $callback) {
|
|
|
|
$player = $callback[1];
|
|
|
|
$openedWidget = $callback[2];
|
|
|
|
//unset when another main widget got opened
|
|
|
|
if($openedWidget != 'Configurator') {
|
|
|
|
unset($this->playersMenuShown[$player->login]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Widget get closed -> unset player
|
|
|
|
*
|
|
|
|
* @param array $callback
|
|
|
|
*/
|
|
|
|
public function closeWidget(array $callback) {
|
|
|
|
$player = $callback[1];
|
|
|
|
unset($this->playersMenuShown[$player->login]);
|
|
|
|
}
|
|
|
|
|
2013-11-28 04:48:04 +01:00
|
|
|
/**
|
2013-12-31 13:21:45 +01:00
|
|
|
* Hide the Menu for the Player
|
2013-11-28 04:48:04 +01:00
|
|
|
*
|
2013-12-31 12:42:07 +01:00
|
|
|
* @param Player $player
|
2013-11-28 03:47:08 +01:00
|
|
|
*/
|
2013-12-14 23:32:21 +01:00
|
|
|
public function hideMenu(Player $player) {
|
2013-11-28 04:48:04 +01:00
|
|
|
unset($this->playersMenuShown[$player->login]);
|
2014-01-11 17:36:46 +01:00
|
|
|
$this->maniaControl->manialinkManager->closeWidget($player);
|
2013-11-28 04:48:04 +01:00
|
|
|
}
|
|
|
|
|
2013-12-31 13:21:45 +01:00
|
|
|
/**
|
|
|
|
* Toggle the Menu for the Player
|
|
|
|
*
|
|
|
|
* @param Player $player
|
|
|
|
*/
|
|
|
|
public function toggleMenu(Player $player) {
|
2014-01-05 19:00:11 +01:00
|
|
|
if(isset($this->playersMenuShown[$player->login])) {
|
2013-12-31 13:21:45 +01:00
|
|
|
$this->hideMenu($player);
|
2014-01-05 19:00:11 +01:00
|
|
|
} else {
|
2013-12-31 13:21:45 +01:00
|
|
|
$this->showMenu($player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-05 20:34:48 +01:00
|
|
|
/**
|
|
|
|
* Gets the Menu Id
|
|
|
|
*
|
|
|
|
* @param $name
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getMenuId($name) {
|
|
|
|
$i = 0;
|
|
|
|
foreach($this->menus as $menu) {
|
|
|
|
/** @var ConfiguratorMenu $menu */
|
|
|
|
if($menu->getTitle() == $name) {
|
|
|
|
return $i;
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-11-28 04:48:04 +01:00
|
|
|
/**
|
|
|
|
* Build menu manialink if necessary
|
|
|
|
*
|
2014-01-05 20:02:38 +01:00
|
|
|
* @param int $menuIdShown
|
|
|
|
* @internal param bool $forceBuild
|
|
|
|
* @return \FML\ManiaLink
|
2013-11-28 04:48:04 +01:00
|
|
|
*/
|
2014-01-05 20:02:38 +01:00
|
|
|
private function buildManialink($menuIdShown = 0) {
|
2014-01-05 19:00:11 +01:00
|
|
|
$menuPosX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSX);
|
|
|
|
$menuPosY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSY);
|
|
|
|
$menuWidth = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_WIDTH);
|
|
|
|
$menuHeight = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_HEIGHT);
|
|
|
|
$quadStyle = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_STYLE);
|
2013-11-28 17:36:39 +01:00
|
|
|
$quadSubstyle = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_SUBSTYLE);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
|
|
|
$menuListWidth = $menuWidth * 0.3;
|
2013-11-28 17:36:39 +01:00
|
|
|
$menuItemHeight = 10.;
|
2014-01-05 19:00:11 +01:00
|
|
|
$subMenuWidth = $menuWidth - $menuListWidth;
|
|
|
|
$subMenuHeight = $menuHeight;
|
|
|
|
|
2013-12-15 12:41:43 +01:00
|
|
|
$manialink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 04:48:04 +01:00
|
|
|
$frame = new Frame();
|
|
|
|
$manialink->add($frame);
|
2013-11-28 17:36:39 +01:00
|
|
|
$frame->setPosition($menuPosX, $menuPosY);
|
2014-01-09 19:29:25 +01:00
|
|
|
$frame->setZ(10);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
$backgroundQuad = new Quad();
|
2013-11-28 04:48:04 +01:00
|
|
|
$frame->add($backgroundQuad);
|
2013-11-28 17:36:39 +01:00
|
|
|
$backgroundQuad->setSize($menuWidth, $menuHeight);
|
|
|
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
$menuItemsFrame = new Frame();
|
|
|
|
$frame->add($menuItemsFrame);
|
|
|
|
$menuItemsFrame->setX($menuWidth * -0.5 + $menuListWidth * 0.5);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
$itemsBackgroundQuad = new Quad();
|
|
|
|
$menuItemsFrame->add($itemsBackgroundQuad);
|
|
|
|
$itemsBackgroundQuad->setSize($menuListWidth, $menuHeight);
|
|
|
|
$itemsBackgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
$menusFrame = new Frame();
|
|
|
|
$frame->add($menusFrame);
|
|
|
|
$menusFrame->setX($menuWidth * -0.5 + $menuListWidth + $subMenuWidth * 0.5);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
// Create script and features
|
|
|
|
$script = new Script();
|
|
|
|
$manialink->setScript($script);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2014-01-05 20:34:48 +01:00
|
|
|
$menuItemY = $menuHeight * 0.42;
|
|
|
|
$menuId = 0;
|
2014-01-05 19:00:11 +01:00
|
|
|
foreach($this->menus as $index => $menu) {
|
2014-01-05 20:02:38 +01:00
|
|
|
/** @var ConfiguratorMenu $menu */
|
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
// Add title
|
|
|
|
$menuItemLabel = new Label();
|
|
|
|
$menuItemsFrame->add($menuItemLabel);
|
|
|
|
$menuItemLabel->setY($menuItemY);
|
|
|
|
$menuItemLabel->setSize($menuListWidth * 0.9, $menuItemHeight * 0.9);
|
|
|
|
$menuItemLabel->setStyle(Label_Text::STYLE_TextCardRaceRank);
|
2013-12-31 15:09:48 +01:00
|
|
|
$menuItemLabel->setText('$z' . $menu->getTitle() . '$z');
|
2014-01-05 20:02:38 +01:00
|
|
|
$menuItemLabel->setAction(self::ACTION_SELECTMENU . '.' . $menuId);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2014-01-05 20:02:38 +01:00
|
|
|
//Show a Menu
|
|
|
|
if($menuId == $menuIdShown) {
|
|
|
|
$menuControl = $menu->getMenu($subMenuWidth, $subMenuHeight, $script);
|
|
|
|
$menusFrame->add($menuControl);
|
|
|
|
$script->addMenu($menuItemLabel, $menuControl);
|
2013-12-12 19:41:37 +01:00
|
|
|
}
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
$menuItemY -= $menuItemHeight * 1.1;
|
2014-01-05 20:02:38 +01:00
|
|
|
$menuId++;
|
2013-11-28 17:36:39 +01:00
|
|
|
}
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-12-04 00:40:37 +01:00
|
|
|
// Add Close Quad (X)
|
|
|
|
$closeQuad = new Quad_Icons64x64_1();
|
|
|
|
$frame->add($closeQuad);
|
2013-12-09 09:07:55 +01:00
|
|
|
$closeQuad->setPosition($menuWidth * 0.483, $menuHeight * 0.467, 3);
|
2013-12-04 00:40:37 +01:00
|
|
|
$closeQuad->setSize(6, 6);
|
|
|
|
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
2014-01-18 21:05:45 +01:00
|
|
|
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
// Add close button
|
|
|
|
$closeButton = new Label();
|
|
|
|
$frame->add($closeButton);
|
|
|
|
$closeButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.29, $menuHeight * -0.43);
|
|
|
|
$closeButton->setSize($menuListWidth * 0.3, $menuListWidth * 0.1);
|
|
|
|
$closeButton->setStyle(Label_Text::STYLE_TextButtonNavBack);
|
|
|
|
$closeButton->setTextPrefix('$999');
|
|
|
|
$closeButton->setTranslate(true);
|
2013-12-14 23:32:21 +01:00
|
|
|
$closeButton->setText('$zClose$z');
|
2013-11-28 17:36:39 +01:00
|
|
|
$closeButton->setAction(self::ACTION_TOGGLEMENU);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2013-11-28 17:36:39 +01:00
|
|
|
// Add save button
|
|
|
|
$saveButton = new Label();
|
|
|
|
$frame->add($saveButton);
|
|
|
|
$saveButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.71, $menuHeight * -0.43);
|
|
|
|
$saveButton->setSize($menuListWidth * 0.3, $menuListWidth * 0.1);
|
|
|
|
$saveButton->setStyle(Label_Text::STYLE_TextButtonNavBack);
|
|
|
|
$saveButton->setTextPrefix('$0f5');
|
|
|
|
$saveButton->setTranslate(true);
|
2013-12-14 23:32:21 +01:00
|
|
|
$saveButton->setText('$zSave$z');
|
2013-11-28 17:36:39 +01:00
|
|
|
$saveButton->setAction(self::ACTION_SAVECONFIG);
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2014-01-05 20:02:38 +01:00
|
|
|
return $manialink;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle ManialinkPageAnswer Callback
|
|
|
|
*
|
|
|
|
* @param array $callback
|
|
|
|
*/
|
|
|
|
public function handleManialinkPageAnswer(array $callback) {
|
|
|
|
$actionId = $callback[1][2];
|
|
|
|
$boolSelectMenu = (strpos($actionId, self::ACTION_SELECTMENU) === 0);
|
|
|
|
if(!$boolSelectMenu) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$login = $callback[1][1];
|
|
|
|
$actionArray = explode(".", $callback[1][2]);
|
|
|
|
|
|
|
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
2014-01-05 20:05:28 +01:00
|
|
|
$this->showMenu($player, intval($actionArray[2]));
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 13:21:45 +01:00
|
|
|
* Add Menu Item to the Actions Menu
|
2013-11-28 03:47:08 +01:00
|
|
|
*/
|
2013-12-31 13:21:45 +01:00
|
|
|
private function addActionsMenuItem() {
|
2014-01-05 01:29:49 +01:00
|
|
|
$itemQuad = new Quad_UIConstruction_Buttons();
|
|
|
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Tools);
|
2013-11-28 04:48:04 +01:00
|
|
|
$itemQuad->setAction(self::ACTION_TOGGLEMENU);
|
2014-01-31 20:12:01 +01:00
|
|
|
$this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 100, 'Settings');
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|
|
|
|
}
|