Renamed AdminMenu to ActionsMenu
This commit is contained in:
parent
f23001e1fc
commit
17f18a2cdb
@ -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,8 +130,8 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { // TO
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on ManialinkPageAnswer
|
||||
*
|
||||
* Handle OpenAdminMenu Action
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function openAdminMenu(array $callback, Player $player) {
|
||||
@ -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
|
||||
*
|
||||
@ -119,7 +163,7 @@ class AdminMenu implements CallbackListener, ManialinkPageAnswerListener { // TO
|
||||
|
||||
/**
|
||||
* Build the icons
|
||||
*
|
||||
*
|
||||
* @param bool $forceBuild
|
||||
*/
|
||||
private function buildIcons($forceBuild = false) {
|
||||
@ -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;
|
||||
}
|
@ -54,7 +54,7 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/**
|
||||
* Create a new Configurator
|
||||
*
|
||||
* @param ManiaControl $maniaControl
|
||||
* @param ManiaControl $maniaControl
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
@ -72,16 +72,16 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
// Register for page answers
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_TOGGLEMENU, $this,
|
||||
'handleToggleMenuAction');
|
||||
|
||||
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SAVECONFIG, $this,
|
||||
'handleSaveConfigAction');
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this,
|
||||
'handlePlayerDisconnect');
|
||||
|
||||
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(ScriptSettings::CB_SCRIPTSETTINGS_CHANGED, $this, 'reopenMenu');
|
||||
|
||||
|
||||
// Create script settings
|
||||
$this->scriptSettings = new ScriptSettings($maniaControl);
|
||||
$this->addMenu($this->scriptSettings);
|
||||
@ -90,7 +90,7 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/**
|
||||
* Add a configurator menu
|
||||
*
|
||||
* @param ConfiguratorMenu $menu
|
||||
* @param ConfiguratorMenu $menu
|
||||
*/
|
||||
public function addMenu(ConfiguratorMenu $menu) {
|
||||
array_push($this->menus, $menu);
|
||||
@ -98,21 +98,23 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
|
||||
/**
|
||||
* Reopens the Menu
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function reopenMenu(array $callback){
|
||||
foreach($this->playersMenuShown as $login => $shown){
|
||||
if($shown == true){
|
||||
public function reopenMenu(array $callback) {
|
||||
foreach ($this->playersMenuShown as $login => $shown) {
|
||||
if ($shown == true) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
$this->showMenu($player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle toggle menu action
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handleToggleMenuAction(array $callback, Player $player) {
|
||||
if (isset($this->playersMenuShown[$player->login])) {
|
||||
@ -125,8 +127,8 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/**
|
||||
* Save the config data received from the manialink
|
||||
*
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handleSaveConfigAction(array $callback, Player $player) {
|
||||
foreach ($this->menus as $menu) {
|
||||
@ -137,7 +139,7 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/**
|
||||
* Handle PlayerDisconnect callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handlePlayerDisconnect(array $callback) {
|
||||
$login = $callback[1][0];
|
||||
@ -147,7 +149,7 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/**
|
||||
* Show the menu to the player
|
||||
*
|
||||
* @param Player $player
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showMenu(Player $player) {
|
||||
$this->buildManialink();
|
||||
@ -160,7 +162,7 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/**
|
||||
* Hide the menu for the player
|
||||
*
|
||||
* @param Player $player
|
||||
* @param Player $player
|
||||
*/
|
||||
public function hideMenu(Player $player) {
|
||||
$emptyManialink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
@ -173,7 +175,7 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/**
|
||||
* Build menu manialink if necessary
|
||||
*
|
||||
* @param bool $forceBuild
|
||||
* @param bool $forceBuild
|
||||
*/
|
||||
private function buildManialink($forceBuild = false) {
|
||||
$menuPosX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSX);
|
||||
@ -218,20 +220,15 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
// Create script and features
|
||||
$script = new Script();
|
||||
$manialink->setScript($script);
|
||||
|
||||
$pages = null;
|
||||
/*$pages = new Pages();
|
||||
$script->addFeature($pages);
|
||||
|
||||
$tooltips = new Tooltips();
|
||||
$script->addFeature($tooltips);
|
||||
|
||||
$menus = new Menus();
|
||||
$script->addFeature($menus);*/
|
||||
|
||||
//$script->addPager()
|
||||
|
||||
|
||||
$pages = null;
|
||||
/*
|
||||
* $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) {
|
||||
@ -241,7 +238,7 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
$menuItemLabel->setY($menuItemY);
|
||||
$menuItemLabel->setSize($menuListWidth * 0.9, $menuItemHeight * 0.9);
|
||||
$menuItemLabel->setStyle(Label_Text::STYLE_TextCardRaceRank);
|
||||
//$menuItemLabel->setText('$z' . $menu->getTitle() . '$z');
|
||||
// $menuItemLabel->setText('$z' . $menu->getTitle() . '$z');
|
||||
|
||||
// Add menu
|
||||
$menuControl = $menu->getMenu($subMenuWidth, $subMenuHeight, $pages, $script);
|
||||
@ -251,12 +248,12 @@ class Configurator implements CallbackListener, ManialinkPageAnswerListener {
|
||||
$menusFrame->add($menuControl);
|
||||
|
||||
// Add menu relationship
|
||||
//array_push($menuRelationships, array($menuItemLabel, $menuControl));
|
||||
// array_push($menuRelationships, array($menuItemLabel, $menuControl));
|
||||
$script->addMenu($menuItemLabel, $menuControl);
|
||||
$menuItemY -= $menuItemHeight * 1.1;
|
||||
}
|
||||
|
||||
//$menus->add($menuRelationships);
|
||||
|
||||
// $menus->add($menuRelationships);
|
||||
|
||||
// Add Close Quad (X)
|
||||
$closeQuad = new Quad_Icons64x64_1();
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
@ -117,8 +120,8 @@ class ManiaControl implements CommandListener {
|
||||
|
||||
/**
|
||||
* Print a message to console and log
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function log($message) {
|
||||
logMessage($message);
|
||||
@ -127,7 +130,7 @@ class ManiaControl implements CommandListener {
|
||||
/**
|
||||
* Return message composed of client error message and error code
|
||||
*
|
||||
* @param object $client
|
||||
* @param object $client
|
||||
* @return string
|
||||
*/
|
||||
public function getClientErrorText($client = null) {
|
||||
@ -140,8 +143,8 @@ class ManiaControl implements CommandListener {
|
||||
/**
|
||||
* Send ManiaControl version
|
||||
*
|
||||
* @param array $chat
|
||||
* @param Player $player
|
||||
* @param array $chat
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function command_Version(array $chat, Player $player) {
|
||||
@ -152,7 +155,7 @@ class ManiaControl implements CommandListener {
|
||||
/**
|
||||
* Quit ManiaControl and log the given message
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $message
|
||||
*/
|
||||
public function quit($message = '') {
|
||||
// OnShutdown callback
|
||||
|
Loading…
Reference in New Issue
Block a user