improved manialink sending code

This commit is contained in:
Steffen Schröder 2014-03-02 13:00:23 +01:00
parent 2f9cab62fa
commit 795366e542
11 changed files with 30 additions and 55 deletions

View File

@ -140,8 +140,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
$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->maniaControl->manialinkManager->sendManialink($manialink, $player->login);
}
}
@ -151,8 +150,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
* @param Player $player
*/
public function handlePlayerJoined(Player $player) {
$manialinkText = $this->buildMenuIconsManialink($player)->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
$maniaLink = $this->buildMenuIconsManialink($player);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $player->login);
}
/**

View File

@ -55,12 +55,11 @@ class CustomUIManager implements CallbackListener, TimerListener {
* @param Player $player
*/
private function updateManialink(Player $player = null) {
$manialinkText = $this->customUI->render()->saveXML();
if ($player) {
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
$this->maniaControl->manialinkManager->sendManialink($this->customUI, $player->login);
return;
}
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
$this->maniaControl->manialinkManager->sendManialink($this->customUI);
}
/**

View File

@ -121,7 +121,6 @@ class IconManager implements CallbackListener {
}
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $player);
}
}

View File

@ -129,7 +129,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
* @return bool
*/
public function sendManialink($manialinkText, $logins = null, $timeout = 0, $hideOnClick = false) {
$manialinkText = (string)$manialinkText;
$manialinkText = (string) $manialinkText;
try {
if (!$logins) {
@ -211,7 +211,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
*/
public function displayWidget($maniaLink, Player $player, $widgetName = '') {
// render and display xml
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $player->login);
$this->sendManialink($maniaLink, $player->login);
if ($widgetName != '') { //TODO make check by manialinkId, getter is needed to avoid uses on non main widgets
$this->disableAltMenu($player);
@ -239,16 +239,14 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
public function closeWidget(Player $player, $widgetId = false) {
if (!$widgetId) {
$emptyManialink = new ManiaLink(self::MAIN_MLID);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
$this->sendManialink($emptyManialink, $player->login);
$this->enableAltMenu($player);
// Trigger callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAIN_WINDOW_CLOSED, $player);
} else {
$emptyManialink = new ManiaLink($widgetId);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
$this->sendManialink($emptyManialink, $player->login);
}
}

View File

@ -181,8 +181,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
$this->destroyVote();
$emptyManialink = new ManiaLink(self::MLID_ICON);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
$this->maniaControl->manialinkManager->sendManialink($emptyManialink);
$this->maniaControl->commandManager->unregisterCommandListener($this);
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
$this->maniaControl->manialinkManager->unregisterManialinkPageAnswerListener($this);
@ -491,8 +490,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
*/
private function destroyVote() {
$emptyManialink = new ManiaLink(self::MLID_WIDGET);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
$this->maniaControl->manialinkManager->sendManialink($emptyManialink);
unset($this->currentVote);
}
@ -624,8 +622,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
$label->setText("F8");
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
$this->maniaControl->manialinkManager->sendManialink($maniaLink);
}
/**
@ -729,8 +726,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
}

View File

@ -85,7 +85,6 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_LINEHEIGHT, 4);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_LINESCOUNT, 12);
//TODO what was CB_IC_ClientUpdated?
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'handleBeginMap');
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_ENDMAP, $this, 'handleMapEnd');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
@ -730,8 +729,6 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
* Build simple player list for callbacks
*/
private function getPlayerList() {
$client = null;
$players = $this->maniaControl->playerManager->getPlayers();
if (count($players) == 0) {
@ -957,9 +954,9 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
$timeLabel->setTextEmboss(true);
}
return $manialink->render()->saveXML();
return $manialink;
}
/**
* Decodes xml rpc response
*

View File

@ -100,8 +100,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
*/
public function unload() {
$emptyManialink = new ManiaLink(self::MLID_DONATE_WIDGET);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
$this->maniaControl->manialinkManager->sendManialink($emptyManialink);
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
$this->maniaControl->commandManager->unregisterCommandListener($this);
@ -284,8 +283,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
}
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
}
/**

View File

@ -117,8 +117,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
*/
public function unload() {
$emptyManialink = new ManiaLink(self::MLID_KARMA);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
$this->maniaControl->manialinkManager->sendManialink($emptyManialink);
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
$this->maniaControl->timerManager->unregisterTimerListenings($this);
unset($this->maniaControl);
@ -210,8 +209,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$votesFrame->removeChildren();
// Send manialink
$manialinkText = $this->manialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
$this->maniaControl->manialinkManager->sendManialink($this->manialink, $login);
}
}

View File

@ -354,7 +354,7 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
$timeLabel->setTextEmboss(true);
}
return $manialink->render()->saveXML();
return $manialink;
}
/**

View File

@ -358,8 +358,7 @@ class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswer
// Send manialink
if ($showSelf) {
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $player->login);
} else {
return $frame;
}
@ -418,8 +417,7 @@ class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswer
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
}
/**
@ -757,12 +755,10 @@ class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswer
*/
public function unload() {
$emptyManialink = new ManiaLink(self::SLOT_MAIN_ML);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
$this->maniaControl->manialinkManager->sendManialink($emptyManialink);
$emptyManialink = new ManiaLink(self::SLOT_ICON_ML);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
$this->maniaControl->manialinkManager->sendManialink($emptyManialink);
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
$this->maniaControl->manialinkManager->unregisterManialinkPageAnswerListener($this);

View File

@ -227,8 +227,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
}
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
}
/**
@ -270,8 +269,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
$script->addTimeLabel($label, true);
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
}
/**
@ -374,8 +372,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
$quad->setManialink('mcontrol?favorite=' . urlencode($this->maniaControl->server->login));
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
}
/**
@ -398,8 +395,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
*/
public function closeWidget($widgetId) {
$emptyManialink = new ManiaLink($widgetId);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
$this->maniaControl->manialinkManager->sendManialink($emptyManialink);
}
/**
@ -509,8 +505,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
}
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
}
/**