Renamed AdminMenu to ActionsMenu

This commit is contained in:
Steffen Schröder 2013-12-31 12:42:07 +01:00
parent f23001e1fc
commit 17f18a2cdb
3 changed files with 108 additions and 64 deletions

View File

@ -14,30 +14,31 @@ use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
/**
* Class offering and managing the admin menu
* Class managing Actions Menus
*
* @author steeffeen & kremsy
*/
class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { // TODO rename class, its not only an admin menu
class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
/**
* Constants
*/
const MLID_MENU = 'AdminMenu.MLID';
const MLID_MENU = 'ActionsMenu.MLID';
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';
const ACTION_OPEN_ADMIN_MENU = 'ActionsMenu.OpenAdminMenu';
const ACTION_OPEN_PLAYER_MENU = 'ActionsMenu.OpenPlayerMenu';
/**
* Private properties
* Private Properties
*/
private $maniaControl = null;
private $manialink = null;
private $menuItems = array();
private $adminMenuItems = array();
private $playerMenuItems = array();
/**
* Create a new admin menu
* Create a new Actions Menu
*
* @param ManiaControl $maniaControl
*/
@ -50,22 +51,54 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { // TO
$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->callbackManager->registerCallbackListener(PlayerManager::CB_ONINIT, $this, 'handleOnInit');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_ADMIN_MENU, $this,
'openAdminMenu');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYER_MENU, $this,
'openPlayerMenu');
}
/**
* Add a new menu item
* Add a new Menu Item
*
* @param Control $control
* @param bool $playerAction
* @param int $order
*/
public function addMenuItem(Control $control, $playerAction = true, $order = 0) {
if ($playerAction) {
$this->addPlayerMenuItem($control, $order);
}
else {
$this->addAdminMenuItem($control, $order);
}
}
/**
* Add a new Player Menu Item
*
* @param Control $control
* @param int $order
*/
public function addMenuItem(Control $control, $order = 0) {
if (!isset($this->menuItems[$order])) {
$this->menuItems[$order] = array();
public function addPlayerMenuItem(Control $control, $order = 0) {
if (!isset($this->playerMenuItems[$order])) {
$this->playerMenuItems[$order] = array();
}
array_push($this->menuItems[$order], $control);
array_push($this->playerMenuItems[$order], $control);
}
/**
* Add a new Admin Menu Item
*
* @param Control $control
* @param int $order
*/
public function addAdminMenuItem(Control $control, $order = 0) {
if (!isset($this->adminMenuItems[$order])) {
$this->adminMenuItems[$order] = array();
}
array_push($this->adminMenuItems[$order], $control);
}
/**
@ -97,7 +130,7 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { // TO
}
/**
* Called on ManialinkPageAnswer
* Handle OpenAdminMenu Action
*
* @param array $callback
*/
@ -107,6 +140,17 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { // TO
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
}
/**
* Handle OpenPlayerMenu Action
*
* @param array $callback
*/
public function openPlayerMenu(array $callback, Player $player) {
$this->buildManialink(true);
$manialinkText = $this->manialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
}
/**
* Check if the player has access to the admin menu
*
@ -153,7 +197,7 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { // TO
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Options);
$itemQuad->setSize($itemSize, $itemSize);
$iconFrame->add($itemQuad);
$itemQuad->setAction(self::ACTION_OPEN_ADMIN_MEN);
$itemQuad->setAction(self::ACTION_OPEN_ADMIN_MENU);
// Admin Menu Icon Frame
$frame = new Frame();
@ -173,7 +217,7 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { // TO
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Custom);
$itemQuad->setSize($itemSize, $itemSize);
$iconFrame->add($itemQuad);
$itemQuad->setAction(self::ACTION_OPEN_PLAYER_MEN);
$itemQuad->setAction(self::ACTION_OPEN_PLAYER_MENU);
$this->manialink = $manialink;
}

View File

@ -98,6 +98,7 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
/**
* Reopens the Menu
*
* @param array $callback
*/
public function reopenMenu(array $callback) {
@ -108,6 +109,7 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
}
}
}
/**
* Handle toggle menu action
*
@ -220,18 +222,13 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
$manialink->setScript($script);
$pages = null;
/*$pages = new Pages();
$script->addFeature($pages);
$tooltips = new Tooltips();
$script->addFeature($tooltips);
$menus = new Menus();
$script->addFeature($menus);*/
/*
* $pages = new Pages(); $script->addFeature($pages); $tooltips = new Tooltips(); $script->addFeature($tooltips); $menus = new
* Menus(); $script->addFeature($menus);
*/
// $script->addPager()
$menuRelationships = array();
$menuItemY = $menuHeight * 0.42;
foreach ($this->menus as $index => $menu) {
@ -298,6 +295,6 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
$itemQuad = new Quad();
$itemQuad->setStyles('Icons128x32_1', 'Settings');
$itemQuad->setAction(self::ACTION_TOGGLEMENU);
$this->maniaControl->adminMenu->addMenuItem($itemQuad, 5);
$this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 10);
}
}

View File

@ -3,7 +3,7 @@
namespace ManiaControl;
use IXR_Client_Gbx;
use ManiaControl\Admin\AdminMenu;
use ManiaControl\Admin\ActionsMenu;
use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Commands\CommandListener;
@ -15,10 +15,11 @@ use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\PluginManager;
use ManiaControl\Server\Server;
require_once __DIR__ . '/Callbacks/CallbackListener.php';
require_once __DIR__ . '/Commands/CommandListener.php';
require_once __DIR__ . '/Manialinks/ManialinkPageAnswerListener.php';
require_once __DIR__ . '/Admin/AdminMenu.php';
require_once __DIR__ . '/Admin/ActionsMenu.php';
require_once __DIR__ . '/Admin/AuthenticationManager.php';
require_once __DIR__ . '/Callbacks/CallbackManager.php';
require_once __DIR__ . '/Chat.php';
@ -67,12 +68,14 @@ class ManiaControl implements CommandListener {
/**
* Public properties
*/
public $adminMenu = null;
public $actionsMenu = null;
public $authenticationManager = null;
public $callbackManager = null;
public $chat = null;
public $configurator = null;
/** @var IXR_Client_Gbx */
/**
* @var IXR_Client_Gbx
*/
public $client = null;
public $commandManager = null;
public $database = null;
@ -100,7 +103,7 @@ class ManiaControl implements CommandListener {
$this->callbackManager = new CallbackManager($this);
$this->settingManager = new SettingManager($this);
$this->manialinkManager = new ManialinkManager($this);
$this->adminMenu = new AdminMenu($this);
$this->actionsMenu = new ActionsMenu($this);
$this->chat = new Chat($this);
$this->commandManager = new CommandManager($this);
$this->server = new Server($this);