moved menu buttons

This commit is contained in:
Steffen Schröder 2013-12-31 12:24:54 +01:00
parent fd7a229e2c
commit 50f79ddec2

View File

@ -18,7 +18,7 @@ use ManiaControl\Players\PlayerManager;
*
* @author steeffeen & kremsy
*/
class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { //TODO rename class, its not only an admin menu
class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { // TODO rename class, its not only an admin menu
/**
* Constants
*/
@ -26,7 +26,6 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { //TOD
const SETTING_MENU_POSX = 'Menu Position: X';
const SETTING_MENU_POSY = 'Menu Position: Y';
const SETTING_MENU_ITEMSIZE = 'Menu Item Size';
const ACTION_OPEN_ADMIN_MEN = 'AdminMenu.OpenAdminMenu';
const ACTION_OPEN_PLAYER_MEN = 'AdminMenu.OpenPlayerMenu';
@ -47,11 +46,11 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { //TOD
// Init settings
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSX, 156.);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSY, -60.);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSY, -37.);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
// Register for callbacks
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_ADMIN_MEN , $this, 'openAdminMenu');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_ADMIN_MEN, $this, 'openAdminMenu');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_ONINIT, $this, 'handleOnInit');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined');
}
@ -97,9 +96,9 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { //TOD
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
}
/**
* Called on ManialinkPageAnswer
*
* @param array $callback
*/
public function openAdminMenu(array $callback, Player $player) {
@ -107,6 +106,7 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { //TOD
$manialinkText = $this->manialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
}
/**
* Check if the player has access to the admin menu
*
@ -119,6 +119,7 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { //TOD
/**
* Build the icons
*
* @param bool $forceBuild
*/
private function buildIcons($forceBuild = false) {
@ -134,7 +135,7 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { //TOD
$manialink = new ManiaLink(self::MLID_MENU);
//Player Menu Icon Frame
// Player Menu Icon Frame
$frame = new Frame();
$manialink->add($frame);
$frame->setPosition($posX, $posY);
@ -144,7 +145,6 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { //TOD
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$iconFrame = new Frame();
$frame->add($iconFrame);
@ -155,7 +155,7 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { //TOD
$iconFrame->add($itemQuad);
$itemQuad->setAction(self::ACTION_OPEN_ADMIN_MEN);
//Admin Menu Icon Frame
// Admin Menu Icon Frame
$frame = new Frame();
$manialink->add($frame);
$frame->setPosition($posX, $posY - $itemSize * $itemMarginFactorY);
@ -176,8 +176,8 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { //TOD
$itemQuad->setAction(self::ACTION_OPEN_PLAYER_MEN);
$this->manialink = $manialink;
}
/**
* Build the menu manialink if necessary
*