map widget map info feature

This commit is contained in:
Steffen Schröder 2013-12-31 12:06:13 +01:00
parent 5fd8c2cf1b
commit 84b12967af

View File

@ -15,7 +15,7 @@ use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager; use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\Plugin; use ManiaControl\Plugins\Plugin;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use FML\Script\Script;
/** /**
* ManiaControl Widget Plugin * ManiaControl Widget Plugin
@ -67,7 +67,9 @@ class WidgetPlugin implements CallbackListener, Plugin {
/** /**
* Private Properties * Private Properties
*/ */
/** @var maniaControl $maniaControl */ /**
* @var maniaControl $maniaControl
*/
private $maniaControl = null; private $maniaControl = null;
/** /**
@ -126,6 +128,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
/** /**
* Displays the Clock Widget * Displays the Clock Widget
*
* @param bool $login * @param bool $login
*/ */
public function displayClockWidget($login = false) { public function displayClockWidget($login = false) {
@ -198,7 +201,9 @@ class WidgetPlugin implements CallbackListener, Plugin {
// Check if the Next Map is a juked Map // Check if the Next Map is a juked Map
$jukedMap = $this->maniaControl->mapManager->jukebox->getNextMap(); $jukedMap = $this->maniaControl->mapManager->jukebox->getNextMap();
/** @var Player $requester */ /**
* @var Player $requester
*/
$requester = null; $requester = null;
// if the nextmap is not a juked map, get it from map info // if the nextmap is not a juked map, get it from map info
if ($jukedMap == null) { if ($jukedMap == null) {
@ -287,7 +292,6 @@ class WidgetPlugin implements CallbackListener, Plugin {
$frame->setSize($width, $height); $frame->setSize($width, $height);
$frame->setPosition($pos_x, $pos_y); $frame->setPosition($pos_x, $pos_y);
// Background Quad // Background Quad
$backgroundQuad = new Quad(); $backgroundQuad = new Quad();
$frame->add($backgroundQuad); $frame->add($backgroundQuad);
@ -300,20 +304,22 @@ class WidgetPlugin implements CallbackListener, Plugin {
$this->maniaControl->client->query('GetMaxSpectators'); $this->maniaControl->client->query('GetMaxSpectators');
$maxSpectators = $this->maniaControl->client->getResponse(); $maxSpectators = $this->maniaControl->client->getResponse();
$serverName= $this->maniaControl->server->getName(); $serverName = $this->maniaControl->server->getName();
$players = $this->maniaControl->playerManager->getPlayers(); $players = $this->maniaControl->playerManager->getPlayers();
$playerCount = 0; $playerCount = 0;
$spectatorCount = 0; $spectatorCount = 0;
/** @var Player $player */ /**
foreach($players as $player){ * @var Player $player
if($player->isSpectator) */
foreach ($players as $player) {
if ($player->isSpectator)
$spectatorCount++; $spectatorCount++;
else else
$playerCount++; $playerCount++;
} }
//Player Quad / Label // Player Quad / Label
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
$label->setPosition(0, 1.5, 0.2); $label->setPosition(0, 1.5, 0.2);
@ -331,7 +337,6 @@ class WidgetPlugin implements CallbackListener, Plugin {
$label->setText($playerCount . " / " . $maxPlayers['NextValue']); $label->setText($playerCount . " / " . $maxPlayers['NextValue']);
$label->setTextColor("FFF"); $label->setTextColor("FFF");
$quad = new Quad_Icons128x128_1(); $quad = new Quad_Icons128x128_1();
$frame->add($quad); $frame->add($quad);
$quad->setSubStyle($quad::SUBSTYLE_Multiplayer); $quad->setSubStyle($quad::SUBSTYLE_Multiplayer);
@ -339,7 +344,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
$quad->setSize(2.5, 2.5); $quad->setSize(2.5, 2.5);
$quad->setHAlign(Control::CENTER); $quad->setHAlign(Control::CENTER);
//Spectator Quad / Label // Spectator Quad / Label
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
$label->setPosition(8.5, -1.5, 0.2); $label->setPosition(8.5, -1.5, 0.2);
@ -353,19 +358,19 @@ class WidgetPlugin implements CallbackListener, Plugin {
$frame->add($quad); $frame->add($quad);
$quad->setSubStyle($quad::SUBSTYLE_Camera); $quad->setSubStyle($quad::SUBSTYLE_Camera);
$quad->setPosition(3.5, -1.6, 0.2); $quad->setPosition(3.5, -1.6, 0.2);
$quad->setSize(3.3,2.5); $quad->setSize(3.3, 2.5);
$quad->setHAlign(Control::CENTER); $quad->setHAlign(Control::CENTER);
//Favorite quad // Favorite quad
//$quad = new Quad_Icons64x64_1(); // $quad = new Quad_Icons64x64_1();
$quad = new Quad_Icons128x128_1(); $quad = new Quad_Icons128x128_1();
$frame->add($quad); $frame->add($quad);
//$quad->setSubStyle($quad::SUBSTYLE_StateFavourite); // $quad->setSubStyle($quad::SUBSTYLE_StateFavourite);
$quad->setSubStyle($quad::SUBSTYLE_ServersFavorites); $quad->setSubStyle($quad::SUBSTYLE_ServersFavorites);
$quad->setPosition($width / 2 - 4, -1.5, -0.5); $quad->setPosition($width / 2 - 4, -1.5, -0.5);
$quad->setSize(4,4); $quad->setSize(4, 4);
$quad->setHAlign(Control::CENTER); $quad->setHAlign(Control::CENTER);
//$TODO add server to favorite // $TODO add server to favorite
// Send manialink // Send manialink
$manialinkText = $maniaLink->render()->saveXML(); $manialinkText = $maniaLink->render()->saveXML();
@ -386,6 +391,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
$maniaLink = new ManiaLink(self::MLID_MAPWIDGET); $maniaLink = new ManiaLink(self::MLID_MAPWIDGET);
$script = new Script();
$maniaLink->setScript($script);
// mainframe // mainframe
$frame = new Frame(); $frame = new Frame();
@ -398,6 +405,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
$frame->add($backgroundQuad); $frame->add($backgroundQuad);
$backgroundQuad->setSize($width, $height); $backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle); $backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$script->addMapInfoButton($backgroundQuad);
$map = $this->maniaControl->mapManager->getCurrentMap(); $map = $this->maniaControl->mapManager->getCurrentMap();
@ -423,12 +431,13 @@ 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("http://wiki.maniaplanet.com/pool/images/b/bf/ManiaExchange_logo.png"); //TODO include image into maniacontrol $quad->setImage("http://wiki.maniaplanet.com/pool/images/b/bf/ManiaExchange_logo.png"); // TODO include image into
// maniacontrol
$quad->setPosition(-$width / 2 + 4, -1.5, -0.5); $quad->setPosition(-$width / 2 + 4, -1.5, -0.5);
$quad->setSize(4,4); $quad->setSize(4, 4);
$quad->setHAlign(Control::CENTER); $quad->setHAlign(Control::CENTER);
$quad->setUrl($map->mx->pageurl); $quad->setUrl($map->mx->pageurl);
} }
@ -441,8 +450,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
/** /**
* Closes a Widget * Closes a Widget
* *
* @param * @param $widgetId
* $widgetId
*/ */
public function closeWidget($widgetId) { public function closeWidget($widgetId) {
$emptyManialink = new ManiaLink($widgetId); $emptyManialink = new ManiaLink($widgetId);