update serverwidget on player connect / disconnect
This commit is contained in:
parent
f555af5f4a
commit
98dfae02bd
@ -73,7 +73,6 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* Load the plugin
|
||||||
*
|
*
|
||||||
@ -91,6 +90,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleOnBeginMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleOnBeginMap');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ENDMAP, $this, 'handleOnEndMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ENDMAP, $this, 'handleOnEndMap');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
|
||||||
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handleEveryMinute');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handleEveryMinute');
|
||||||
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true);
|
||||||
@ -136,13 +136,13 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
public function handleOnInit(array $callback) {
|
public function handleOnInit(array $callback) {
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||||
$this->displayMapWidget();
|
$this->displayMapWidget();
|
||||||
}
|
}
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
||||||
$this->displayClockWidget();
|
$this->displayClockWidget();
|
||||||
}
|
}
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
||||||
$this->displayServerInfoWidget();
|
$this->displayServerInfoWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$label->setText($map->authorLogin);
|
$label->setText($map->authorLogin);
|
||||||
$label->setTextColor("FFF");
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
if (isset($map->mx->pageurl)) {
|
if(isset($map->mx->pageurl)) {
|
||||||
$quad = new Quad();
|
$quad = new Quad();
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON));
|
$quad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON));
|
||||||
@ -302,11 +302,10 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*
|
*
|
||||||
* @var Player $player
|
* @var Player $player
|
||||||
*/
|
*/
|
||||||
foreach ($players as $player) {
|
foreach($players as $player) {
|
||||||
if ($player->isSpectator) {
|
if($player->isSpectator) {
|
||||||
$spectatorCount++;
|
$spectatorCount++;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$playerCount++;
|
$playerCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -375,7 +374,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
public function handleOnBeginMap(array $callback) {
|
public function handleOnBeginMap(array $callback) {
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||||
$this->displayMapWidget();
|
$this->displayMapWidget();
|
||||||
}
|
}
|
||||||
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
||||||
@ -399,7 +398,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
public function handleOnEndMap(array $callback) {
|
public function handleOnEndMap(array $callback) {
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
|
||||||
$this->displayNextMapWidget();
|
$this->displayNextMapWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,13 +440,12 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
$requester = null;
|
$requester = null;
|
||||||
// if the nextmap is not a queued map, get it from map info
|
// if the nextmap is not a queued map, get it from map info
|
||||||
if ($queuedMap == null) {
|
if($queuedMap == null) {
|
||||||
$this->maniaControl->client->query("GetNextMapInfo");
|
$this->maniaControl->client->query("GetNextMapInfo");
|
||||||
$map = $this->maniaControl->client->getResponse();
|
$map = $this->maniaControl->client->getResponse();
|
||||||
$name = $map['Name'];
|
$name = $map['Name'];
|
||||||
$author = $map['Author'];
|
$author = $map['Author'];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$requester = $queuedMap[0];
|
$requester = $queuedMap[0];
|
||||||
$map = $queuedMap[1];
|
$map = $queuedMap[1];
|
||||||
$name = $map->name;
|
$name = $map->name;
|
||||||
@ -487,7 +485,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$label->setText($author);
|
$label->setText($author);
|
||||||
$label->setTextColor("FFF");
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
if ($requester != null) {
|
if($requester != null) {
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
@ -514,14 +512,25 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
public function handlePlayerConnect(array $callback) {
|
public function handlePlayerConnect(array $callback) {
|
||||||
$player = $callback[1];
|
$player = $callback[1];
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||||
$this->displayMapWidget($player->login);
|
$this->displayMapWidget($player->login);
|
||||||
}
|
}
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
||||||
$this->displayClockWidget($player->login);
|
$this->displayClockWidget($player->login);
|
||||||
}
|
}
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
||||||
$this->displayServerInfoWidget($player->login);
|
$this->displayServerInfoWidget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle PlayerConnect callback
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
*/
|
||||||
|
public function handlePlayerDisconnect(array $callback) {
|
||||||
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
||||||
|
$this->displayServerInfoWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,7 +540,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handleEveryMinute(array $callback) {
|
public function handleEveryMinute(array $callback) {
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
||||||
$this->displayClockWidget();
|
$this->displayClockWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user