diff --git a/application/core/Manialinks/IconManager.php b/application/core/Manialinks/IconManager.php index 1248e391..bc85c81a 100644 --- a/application/core/Manialinks/IconManager.php +++ b/application/core/Manialinks/IconManager.php @@ -19,14 +19,14 @@ class IconManager implements CallbackListener { * Constants */ const DEFAULT_IMG_URL = 'http://images.maniacontrol.com/icons/'; - const PRELOAD_MLID = 'IconManager.Preload.MLID'; - + const PRELOAD_MLID = 'IconManager.Preload.MLID'; + /** * Some Default icons */ - const MX_ICON = 'ManiaExchange.png'; + const MX_ICON = 'ManiaExchange.png'; const MX_ICON_MOVER = 'ManiaExchange_logo_press.png'; - + /** * Private Properties */ @@ -41,7 +41,7 @@ class IconManager implements CallbackListener { public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; $this->addDefaultIcons(); - + // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect'); @@ -72,7 +72,7 @@ class IconManager implements CallbackListener { * @return string */ public function getIcon($iconName) { - if (!isset($this->icons[$iconName])) { + if(!isset($this->icons[$iconName])) { return null; } return $this->icons[$iconName]; @@ -104,17 +104,17 @@ class IconManager implements CallbackListener { */ private function preloadIcons($login = false) { $maniaLink = new ManiaLink(self::PRELOAD_MLID); - $frame = new Frame(); + $frame = new Frame(); $maniaLink->add($frame); $frame->setPosition(500, 500); - - foreach ($this->icons as $iconUrl) { + + foreach($this->icons as $iconUrl) { $iconQuad = new Quad(); $iconQuad->setImage($iconUrl); $iconQuad->setSize(1, 1); $frame->add($iconQuad); } - + // Send manialink $manialinkText = $maniaLink->render()->saveXML(); $this->maniaControl->manialinkManager->sendManialink($manialinkText, $login); diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index a9111bb6..f92a388e 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -34,17 +34,18 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { /** * Constants */ - const ACTION_ADD_MAP = 'MapList.AddMap'; - const ACTION_SEARCH_MAPNAME = 'MapList.SearchMapName'; - const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor'; - const ACTION_ERASE_MAP = 'MapList.EraseMap'; - const ACTION_SWITCH_MAP = 'MapList.SwitchMap'; - const ACTION_QUEUED_MAP = 'MapList.QueueMap'; - const MAX_MAPS_PER_PAGE = 15; - const MAX_MX_MAPS_PER_PAGE = 14; - const SHOW_MX_LIST = 1; - const SHOW_MAP_LIST = 2; - const DEFAULT_KARMA_PLUGIN = 'KarmaPlugin'; + const ACTION_ADD_MAP = 'MapList.AddMap'; + const ACTION_SEARCH_MAPNAME = 'MapList.SearchMapName'; + const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor'; + const ACTION_GET_MAPS_FROM_AUTHOR = 'MapList.GetMapsFromAuthor'; + const ACTION_ERASE_MAP = 'MapList.EraseMap'; + const ACTION_SWITCH_MAP = 'MapList.SwitchMap'; + const ACTION_QUEUED_MAP = 'MapList.QueueMap'; + const MAX_MAPS_PER_PAGE = 15; + const MAX_MX_MAPS_PER_PAGE = 14; + const SHOW_MX_LIST = 1; + const SHOW_MAP_LIST = 2; + const DEFAULT_KARMA_PLUGIN = 'KarmaPlugin'; /** * Private Properties @@ -138,22 +139,41 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $headFrame = new Frame(); $frame->add($headFrame); $headFrame->setY($y - 5); - $array = array('Id' => $x + 5, 'Name' => $x + 17, 'Author' => $x + 65, 'Type' => $x + 100, 'Mood' => $x + 115, 'Updated' => $x + 130); + $array = array('Id' => $x + 5, 'Name' => $x + 17, 'Author' => $x + 65, 'Type' => $x + 100, 'Mood' => $x + 115, 'Last Update' => $x + 130); $this->maniaControl->manialinkManager->labelLine($headFrame, $array); $i = 0; $y -= 10; foreach($maps as $map) { //TODO pagers, click on nickname... /** @var MxMapInfo $map */ - $time = Formatter::time_elapsed_string(strtotime($map->updated)); $mapFrame = new Frame(); $frame->add($mapFrame); - $array = array($map->id => $x + 5, $map->name => $x + 17, $map->author => $x + 65, str_replace("Arena", "", $map->maptype) => $x + 100, $map->mood => $x + 115, $time => $x + 130); - $this->maniaControl->manialinkManager->labelLine($mapFrame, $array); + $array = array($map->id => $x + 5, $map->name => $x + 17, $map->author => $x + 65, str_replace("Arena", "", $map->maptype) => $x + 100, $map->mood => $x + 115, $time => $x + 130); + $labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array); + /** @var Label_Text $authorLabel */ + $authorLabel = $labels[2]; + $authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author); + $mapFrame->setY($y); + if($map->awards > 0) { + $awardQuad = new Quad_Icons64x64_1(); + $mapFrame->add($awardQuad); + $awardQuad->setSize(3, 3); + $awardQuad->setSubStyle($awardQuad::SUBSTYLE_OfficialRace); + $awardQuad->setX($x + 93); + + $awardLabel = new Label_Text(); + $mapFrame->add($awardLabel); + $awardLabel->setX($x + 94.5); + $awardLabel->setHAlign(Control::LEFT); + $awardLabel->setText($map->awards); + $awardLabel->setTextSize(1.3); + } + + if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { // TODO: SET as setting who can add maps Add-Map-Button $addQuad = new Quad_Icons64x64_1(); @@ -605,6 +625,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $mapId = (int)$actionArray[2]; switch($action) { + case self::ACTION_GET_MAPS_FROM_AUTHOR: + $callback[1][2] = 'auth:' . $actionArray[2]; + $this->showManiaExchangeList($callback, $player); + break; case self::ACTION_ADD_MAP: $this->maniaControl->mapManager->addMapFromMx($mapId, $player->login); break;