From 2c8eeb2bbd535e296cce2bb04dc21d19a5cd3d32 Mon Sep 17 00:00:00 2001 From: kremsy Date: Tue, 24 Dec 2013 13:05:10 +0100 Subject: [PATCH] close main widget callback by manialinkmanager --- application/core/Manialinks/ManialinkManager.php | 10 +++++++--- application/core/Players/PlayerList.php | 11 +++-------- application/core/Players/PlayerManager.php | 1 - 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/application/core/Manialinks/ManialinkManager.php b/application/core/Manialinks/ManialinkManager.php index cdf33ce2..56588135 100644 --- a/application/core/Manialinks/ManialinkManager.php +++ b/application/core/Manialinks/ManialinkManager.php @@ -27,6 +27,8 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener { */ const MAIN_MLID = 'Main.ManiaLinkId'; const ACTION_CLOSEWIDGET = 'ManiaLinkManager.CloseWidget'; + const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed'; + /** * Public properties */ @@ -183,7 +185,7 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener { //render and display xml $maniaLinkText = $maniaLink->render()->saveXML(); $this->maniaControl->manialinkManager->sendManialink($maniaLinkText, $player->login); - $this->maniaControl->manialinkManager->disableAltMenu($player); + $this->disableAltMenu($player); } @@ -204,8 +206,10 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener { $emptyManialink = new ManiaLink(self::MAIN_MLID); $manialinkText = $emptyManialink->render()->saveXML(); $this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login); - $this->maniaControl->manialinkManager->enableAltMenu($player); - //unset($this->playersMenuShown[$player->login]); + $this->enableAltMenu($player); + + // Trigger callback + $this->maniaControl->callbackManager->triggerCallback(self::CB_MAIN_WINDOW_CLOSED, array(self::CB_MAIN_WINDOW_CLOSED, $player)); } /** diff --git a/application/core/Players/PlayerList.php b/application/core/Players/PlayerList.php index 7eae2515..d08310a0 100644 --- a/application/core/Players/PlayerList.php +++ b/application/core/Players/PlayerList.php @@ -2,7 +2,6 @@ namespace ManiaControl\Players; - use FML\Controls\Control; use FML\Controls\Frame; use FML\Controls\Label; @@ -10,12 +9,9 @@ use FML\Controls\Labels\Label_Button; use FML\Controls\Labels\Label_Text; use FML\Controls\Quad; use FML\Controls\Quads\Quad_BgRaceScore2; -use FML\Controls\Quads\Quad_Bgs1; use FML\Controls\Quads\Quad_BgsPlayerCard; use FML\Controls\Quads\Quad_Emblems; use FML\Controls\Quads\Quad_Icons64x64_1; -use FML\Controls\Quads\Quad_Icons64x64_2; -use FML\Controls\Quads\Quad_UIConstruction_Buttons; use FML\ManiaLink; use FML\Script\Script; use FML\Script\Tooltips; @@ -31,7 +27,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { /** * Constants */ - const ACTION_CLOSEWIDGET = 'PlayerList.CloseWidget'; const ACTION_FORCE_RED = 'PlayerList.ForceRed'; const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue'; const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec'; @@ -63,7 +58,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; - $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSEWIDGET , $this, + $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV , $this, 'closePlayerAdvancedWidget'); @@ -111,7 +106,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { $closeQuad->setPosition($this->width * 0.483, $this->height * 0.467, 3); $closeQuad->setSize(6, 6); $closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace); - $closeQuad->setAction(self::ACTION_CLOSEWIDGET ); + $closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET); //Start offsets $x = -$this->width / 2; @@ -492,7 +487,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { */ public function closeWidget(array $callback, Player $player) { $this->playersListShown[$player->login] = false; //TODO unset - $this->maniaControl->manialinkManager->closeWidget($player); } @@ -503,6 +497,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { */ public function closePlayerAdvancedWidget(array $callback, Player $player) { $this->showPlayerList($player); //overwrite the manialink + //TODO remove double rendering } diff --git a/application/core/Players/PlayerManager.php b/application/core/Players/PlayerManager.php index f66a10f8..1d3898e8 100644 --- a/application/core/Players/PlayerManager.php +++ b/application/core/Players/PlayerManager.php @@ -162,7 +162,6 @@ class PlayerManager implements CallbackListener { if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) { - //$this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $ff0left the game. Played:$fff ' . $played); $this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $s$0f0has left the game'); } }