From 4674392336223283fc040fc5b9672132632063af Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 5 Jan 2014 00:43:46 +0100 Subject: [PATCH] design improvements --- application/core/Admin/ActionsMenu.php | 21 ++++++++++++-- application/core/Manialinks/IconManager.php | 1 + application/core/Maps/MapCommands.php | 32 +++++++++++++++------ application/core/Players/PlayerCommands.php | 7 +++-- application/core/Players/PlayerList.php | 8 ++++-- application/plugins/WidgetPlugin.php | 2 ++ 6 files changed, 56 insertions(+), 15 deletions(-) diff --git a/application/core/Admin/ActionsMenu.php b/application/core/Admin/ActionsMenu.php index d1832786..2e56ce6c 100644 --- a/application/core/Admin/ActionsMenu.php +++ b/application/core/Admin/ActionsMenu.php @@ -36,7 +36,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { private $maniaControl = null; private $adminMenuItems = array(); private $playerMenuItems = array(); - + private $initCompleted = false; /** * Create a new Actions Menu * @@ -68,8 +68,10 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { if($playerAction) { $this->addPlayerMenuItem($control, $order, $description); } else { - $this->addAdminMenuItem($control, $order,$description); + $this->addAdminMenuItem($control, $order, $description); } + + $this->rebuildAndShowMenu(); } /** @@ -112,6 +114,21 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { $manialinkText = $this->buildMenuIconsManialink($player)->render()->saveXML(); $this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login); } + + $this->initCompleted = true; + } + + /** + * Build and show the menus to everyone (if a menu get made after the init) + */ + public function rebuildAndShowMenu() { + if($this->initCompleted){ + $players = $this->maniaControl->playerManager->getPlayers(); + foreach($players as $player) { + $manialinkText = $this->buildMenuIconsManialink($player)->render()->saveXML(); + $this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login); + } + } } /** diff --git a/application/core/Manialinks/IconManager.php b/application/core/Manialinks/IconManager.php index d4420230..f399ff4a 100644 --- a/application/core/Manialinks/IconManager.php +++ b/application/core/Manialinks/IconManager.php @@ -26,6 +26,7 @@ class IconManager implements CallbackListener { * Some Default icons */ const MX_ICON = 'ManiaExchange.png'; + const MX_ICON_MOVER = 'ManiaExchange_logo_press.png'; /** * Private Properties diff --git a/application/core/Maps/MapCommands.php b/application/core/Maps/MapCommands.php index e24e79b8..3fc309d0 100644 --- a/application/core/Maps/MapCommands.php +++ b/application/core/Maps/MapCommands.php @@ -2,19 +2,24 @@ namespace ManiaControl\Maps; +use FML\Controls\Quad; use FML\Controls\Quads\Quad_Icons64x64_1; use ManiaControl\Admin\AuthenticationManager; +use ManiaControl\Callbacks\CallbackListener; +use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Commands\CommandListener; use ManiaControl\ManiaControl; +use ManiaControl\Manialinks\IconManager; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; +use WidgetPlugin; /** * Class offering commands to manage maps * * @author steeffeen & kremsy */ -class MapCommands implements CommandListener, ManialinkPageAnswerListener { +class MapCommands implements CommandListener, ManialinkPageAnswerListener,CallbackListener { /** * Constants */ @@ -50,35 +55,46 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener { $this->mapList = new MapList($this->maniaControl); - //Menu Open xList + //Menus Buttons + $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_XLIST, $this, 'command_xList'); - $itemQuad = new Quad_Icons64x64_1(); - $itemQuad->setSubStyle($itemQuad::SUBSTYLE_Browser); + $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_MAPLIST, $this, 'command_List'); + $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_RESTART_MAP, $this, 'command_RestartMap'); + $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SKIP_MAP, $this, 'command_NextMap'); + } + + /** + * Handle on Init + * @param array $callback + */ + public function handleOnInit(array $callback){ + //Menu Open xList + $itemQuad = new Quad(); + $itemQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON)); + $itemQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER)); //TODO move the button to the image manager $itemQuad->setAction(self::ACTION_OPEN_XLIST); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 3, 'Open MX List'); //Menu Open List - $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_MAPLIST, $this, 'command_List'); $itemQuad = new Quad_Icons64x64_1(); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_Browser); $itemQuad->setAction(self::ACTION_OPEN_MAPLIST); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 4,'Open MapList'); //Menu RestartMap - $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_RESTART_MAP, $this, 'command_RestartMap'); $itemQuad = new Quad_Icons64x64_1(); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowFastPrev); $itemQuad->setAction(self::ACTION_RESTART_MAP); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 0, 'Restart Map'); //Menu NextMap - $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SKIP_MAP, $this, 'command_NextMap'); $itemQuad = new Quad_Icons64x64_1(); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowFastNext); $itemQuad->setAction(self::ACTION_SKIP_MAP); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 1, 'Skip Map'); - } + + } /** * Handle removemap command * diff --git a/application/core/Players/PlayerCommands.php b/application/core/Players/PlayerCommands.php index f52d4ca9..d480a478 100644 --- a/application/core/Players/PlayerCommands.php +++ b/application/core/Players/PlayerCommands.php @@ -5,6 +5,7 @@ namespace ManiaControl\Players; use FML\Controls\Quads\Quad_Icons128x128_1; use FML\Controls\Quads\Quad_Icons128x32_1; use FML\Controls\Quads\Quad_Icons64x64_1; +use FML\Controls\Quads\Quad_UIConstruction_Buttons; use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Commands\CommandListener; use ManiaControl\ManiaControl; @@ -72,10 +73,10 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener { $itemQuad->setAction(self::ACTION_CANCEL_VOTE); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 6); - //Action Balance Teams + //Action Open Playerlist $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList'); - $itemQuad = new Quad_Icons128x128_1(); - $itemQuad->setSubStyle($itemQuad::SUBSTYLE_Buddies); + $itemQuad = new Quad_UIConstruction_Buttons(); + $itemQuad->setSubStyle($itemQuad::SUBSTYLE_Author); $itemQuad->setAction(self::ACTION_OPEN_PLAYERLIST); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 9); } diff --git a/application/core/Players/PlayerList.php b/application/core/Players/PlayerList.php index b213ceae..e9618378 100644 --- a/application/core/Players/PlayerList.php +++ b/application/core/Players/PlayerList.php @@ -48,6 +48,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator'; const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights'; const ACTION_OPEN_PLAYER_DETAILED = 'PlayerList.OpenPlayerDetailed'; + const ACTION_SPECTATE_PLAYER = 'PlayerList.SpectatePlayer'; const SHOWN_MAIN_WINDOW = -1; /** * Private properties @@ -252,8 +253,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { $playerQuad->setSubStyle($playerQuad::SUBSTYLE_Camera); $playerQuad->setSize(3.8, 3.8); $script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Spectate " . $listPlayer->nickname)); - $script->addProfileButton($playerQuad, $listPlayer->login); //TODO real action - + $playerQuad->setAction(self::ACTION_SPECTATE_PLAYER); // Player Profile Quad $playerQuad = new Quad_UIConstruction_Buttons(); @@ -585,6 +585,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { $targetLogin = $actionArray[2]; switch($action) { + case self::ACTION_SPECTATE_PLAYER: //TODO not working yet + $this->maniaControl->client->query('ForceSpectator', $adminLogin, PlayerActions::SPECTATOR_SPECTATOR); + $this->maniaControl->client->query('ForceSpectatorTarget', $adminLogin, $targetLogin, 1); + break; case self::ACTION_OPEN_PLAYER_DETAILED: $player = $this->maniaControl->playerManager->getPlayer($adminLogin); $this->maniaControl->playerManager->playerDetailed->showPlayerDetailed($player, $targetLogin); diff --git a/application/plugins/WidgetPlugin.php b/application/plugins/WidgetPlugin.php index b7db66cc..496e472d 100644 --- a/application/plugins/WidgetPlugin.php +++ b/application/plugins/WidgetPlugin.php @@ -118,6 +118,7 @@ class WidgetPlugin implements CallbackListener, Plugin { $this->maniaControl->settingManager->initSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT, 5.5); $this->maniaControl->manialinkManager->iconManager->addIcon(IconManager::MX_ICON); + $this->maniaControl->manialinkManager->iconManager->addIcon(IconManager::MX_ICON_MOVER, "http://www.pictures.esc-clan.net/upload"); //TODO to mc website, icon manager return true; } @@ -204,6 +205,7 @@ class WidgetPlugin implements CallbackListener, Plugin { if(isset($map->mx->pageurl)) { $quad = new Quad(); $frame->add($quad); + $quad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER)); $quad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON)); $quad->setPosition(-$width / 2 + 4, -1.5, -0.5); $quad->setSize(4, 4);