From 2c1aa09734eec249ff21186f98f24da44b2af199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sun, 5 Jan 2014 13:44:04 +0100 Subject: [PATCH] actions menu sorting fixed --- application/core/Admin/ActionsMenu.php | 16 +++++++--------- application/core/Configurators/Configurator.php | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/application/core/Admin/ActionsMenu.php b/application/core/Admin/ActionsMenu.php index 7f9d4a6f..13278a13 100644 --- a/application/core/Admin/ActionsMenu.php +++ b/application/core/Admin/ActionsMenu.php @@ -84,6 +84,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { $this->playerMenuItems[$order] = array(); } array_push($this->playerMenuItems[$order], array($control, $description)); + krsort($this->playerMenuItems); $this->rebuildAndShowMenu(); } @@ -98,6 +99,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { $this->adminMenuItems[$order] = array(); } array_push($this->adminMenuItems[$order], array($control, $description)); + krsort($this->adminMenuItems); $this->rebuildAndShowMenu(); } @@ -107,14 +109,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { * @param array $callback */ public function handleOnInit(array $callback) { - // TODO: Render only once - $players = $this->maniaControl->playerManager->getPlayers(); - foreach ($players as $player) { - $manialink = $this->buildMenuIconsManialink($player); - $manialinkText = $manialink->render()->saveXML(); - $this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login); - } $this->initCompleted = true; + $this->rebuildAndShowMenu(); } /** @@ -122,9 +118,11 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { */ public function rebuildAndShowMenu() { if (!$this->initCompleted) return; + // TODO: Render only once $players = $this->maniaControl->playerManager->getPlayers(); foreach ($players as $player) { - $manialinkText = $this->buildMenuIconsManialink($player)->render()->saveXML(); + $manialink = $this->buildMenuIconsManialink($player); + $manialinkText = $manialink->render()->saveXML(); $this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login); } } @@ -208,7 +206,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { // Add items $x = -1; - foreach ($this->adminMenuItems as $menuItems) { + foreach ($this->adminMenuItems as $order => $menuItems) { foreach ($menuItems as $menuItem) { $menuQuad = $menuItem[0]; /** diff --git a/application/core/Configurators/Configurator.php b/application/core/Configurators/Configurator.php index 1dd48c2d..bc23186d 100644 --- a/application/core/Configurators/Configurator.php +++ b/application/core/Configurators/Configurator.php @@ -307,6 +307,6 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn $itemQuad = new Quad_UIConstruction_Buttons(); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_Tools); $itemQuad->setAction(self::ACTION_TOGGLEMENU); - $this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 20, 'Settings'); // TODO index not really working (this should be the last) + $this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad,20,'Settings'); } }