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\Plugins\Plugin;
use ManiaControl\Callbacks\CallbackManager;
use FML\Script\Script;
/**
* ManiaControl Widget Plugin
@ -67,7 +67,9 @@ class WidgetPlugin implements CallbackListener, Plugin {
/**
* Private Properties
*/
/** @var maniaControl $maniaControl */
/**
* @var maniaControl $maniaControl
*/
private $maniaControl = null;
/**
@ -126,6 +128,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
/**
* Displays the Clock Widget
*
* @param bool $login
*/
public function displayClockWidget($login = false) {
@ -198,7 +201,9 @@ class WidgetPlugin implements CallbackListener, Plugin {
// Check if the Next Map is a juked Map
$jukedMap = $this->maniaControl->mapManager->jukebox->getNextMap();
/** @var Player $requester */
/**
* @var Player $requester
*/
$requester = null;
// if the nextmap is not a juked map, get it from map info
if ($jukedMap == null) {
@ -287,7 +292,6 @@ class WidgetPlugin implements CallbackListener, Plugin {
$frame->setSize($width, $height);
$frame->setPosition($pos_x, $pos_y);
// Background Quad
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
@ -305,7 +309,9 @@ class WidgetPlugin implements CallbackListener, Plugin {
$players = $this->maniaControl->playerManager->getPlayers();
$playerCount = 0;
$spectatorCount = 0;
/** @var Player $player */
/**
* @var Player $player
*/
foreach ($players as $player) {
if ($player->isSpectator)
$spectatorCount++;
@ -331,7 +337,6 @@ class WidgetPlugin implements CallbackListener, Plugin {
$label->setText($playerCount . " / " . $maxPlayers['NextValue']);
$label->setTextColor("FFF");
$quad = new Quad_Icons128x128_1();
$frame->add($quad);
$quad->setSubStyle($quad::SUBSTYLE_Multiplayer);
@ -386,6 +391,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
$maniaLink = new ManiaLink(self::MLID_MAPWIDGET);
$script = new Script();
$maniaLink->setScript($script);
// mainframe
$frame = new Frame();
@ -398,6 +405,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
$frame->add($backgroundQuad);
$backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$script->addMapInfoButton($backgroundQuad);
$map = $this->maniaControl->mapManager->getCurrentMap();
@ -424,9 +432,10 @@ class WidgetPlugin implements CallbackListener, Plugin {
$label->setTextColor("FFF");
if (isset($map->mx->pageurl)) {
$quad = new Quad;
$quad = new 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->setSize(4, 4);
$quad->setHAlign(Control::CENTER);
@ -441,8 +450,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
/**
* Closes a Widget
*
* @param
* $widgetId
* @param $widgetId
*/
public function closeWidget($widgetId) {
$emptyManialink = new ManiaLink($widgetId);