actions menu sorting fixed

This commit is contained in:
Steffen Schröder 2014-01-05 13:44:04 +01:00
parent 85c293965b
commit 2c1aa09734
2 changed files with 8 additions and 10 deletions

View File

@ -84,6 +84,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
$this->playerMenuItems[$order] = array(); $this->playerMenuItems[$order] = array();
} }
array_push($this->playerMenuItems[$order], array($control, $description)); array_push($this->playerMenuItems[$order], array($control, $description));
krsort($this->playerMenuItems);
$this->rebuildAndShowMenu(); $this->rebuildAndShowMenu();
} }
@ -98,6 +99,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
$this->adminMenuItems[$order] = array(); $this->adminMenuItems[$order] = array();
} }
array_push($this->adminMenuItems[$order], array($control, $description)); array_push($this->adminMenuItems[$order], array($control, $description));
krsort($this->adminMenuItems);
$this->rebuildAndShowMenu(); $this->rebuildAndShowMenu();
} }
@ -107,14 +109,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
* @param array $callback * @param array $callback
*/ */
public function handleOnInit(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->initCompleted = true;
$this->rebuildAndShowMenu();
} }
/** /**
@ -122,9 +118,11 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
*/ */
public function rebuildAndShowMenu() { public function rebuildAndShowMenu() {
if (!$this->initCompleted) return; if (!$this->initCompleted) return;
// TODO: Render only once
$players = $this->maniaControl->playerManager->getPlayers(); $players = $this->maniaControl->playerManager->getPlayers();
foreach ($players as $player) { 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); $this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
} }
} }
@ -208,7 +206,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
// Add items // Add items
$x = -1; $x = -1;
foreach ($this->adminMenuItems as $menuItems) { foreach ($this->adminMenuItems as $order => $menuItems) {
foreach ($menuItems as $menuItem) { foreach ($menuItems as $menuItem) {
$menuQuad = $menuItem[0]; $menuQuad = $menuItem[0];
/** /**

View File

@ -307,6 +307,6 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
$itemQuad = new Quad_UIConstruction_Buttons(); $itemQuad = new Quad_UIConstruction_Buttons();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Tools); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_Tools);
$itemQuad->setAction(self::ACTION_TOGGLEMENU); $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');
} }
} }