changed direct public property access to using getter methods

phpdoc improvements
This commit is contained in:
Steffen Schröder
2014-08-02 22:31:46 +02:00
parent 58a668cf65
commit e560919096
70 changed files with 450 additions and 271 deletions

View File

@@ -43,10 +43,11 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
/*
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
/**
* Create a new directory browser instance
* Construct a new directory browser instance
*
* @param ManiaControl $maniaControl
*/
@@ -93,7 +94,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$oldFolderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
$isInMapsFolder = false;
if (!$oldFolderPath) {
$oldFolderPath = $this->maniaControl->server->directory->getMapsFolder();
$oldFolderPath = $this->maniaControl->server->getDirectory()->getMapsFolder();
$isInMapsFolder = true;
}
$folderPath = $oldFolderPath;
@@ -104,12 +105,12 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$folderName = basename($newFolderPath);
switch ($folderName) {
case 'Maps':
$mapsDir = dirname($this->maniaControl->server->directory->getMapsFolder());
$mapsDir = dirname($this->maniaControl->server->getDirectory()->getMapsFolder());
$folderDir = dirname($folderPath);
$isInMapsFolder = ($mapsDir === $folderDir);
break;
case 'UserData':
$dataDir = dirname($this->maniaControl->server->directory->getGameDataFolder());
$dataDir = dirname($this->maniaControl->server->getDirectory()->getGameDataFolder());
$folderDir = dirname($folderPath);
if ($dataDir === $folderDir) {
// Prevent navigation out of maps directory
@@ -125,11 +126,11 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$script = $maniaLink->getScript();
$paging = new Paging();
$script->addFeature($paging);
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $paging);
$frame = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultListFrame($script, $paging);
$maniaLink->add($frame);
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
$width = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsHeight();
$index = 0;
$posY = $height / 2 - 10;
$pageFrame = null;
@@ -153,7 +154,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$directoryLabel = new Label_Text();
$frame->add($directoryLabel);
$dataFolder = $this->maniaControl->server->directory->getGameDataFolder();
$dataFolder = $this->maniaControl->server->getDirectory()->getGameDataFolder();
$directoryText = substr($folderPath, strlen($dataFolder));
$directoryLabel->setPosition($width * -0.41, $height * 0.45)
->setSize($width * 0.85, 4)
@@ -368,7 +369,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
$filePath = $folderPath . $fileName;
$mapsFolder = $this->maniaControl->server->directory->getMapsFolder();
$mapsFolder = $this->maniaControl->server->getDirectory()->getMapsFolder();
$relativeFilePath = substr($filePath, strlen($mapsFolder));
// Check for valid map
@@ -401,7 +402,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$this->maniaControl->log($message, true);
// Queue requested Map
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($player, $map);
$this->maniaControl->mapManager->getMapQueue()->addMapToMapQueue($player, $map);
}
/**

View File

@@ -16,6 +16,7 @@ class MapActions {
/*
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
/**
@@ -32,10 +33,10 @@ class MapActions {
*/
public function skipMap() {
//Force a EndMap on the MapQueue to set the next Map
$this->maniaControl->mapManager->mapQueue->endMap(null);
$this->maniaControl->mapManager->getMapQueue()->endMap(null);
//ignore EndMap on MapQueue
$this->maniaControl->mapManager->mapQueue->dontQueueNextMapChange();
$this->maniaControl->mapManager->getMapQueue()->dontQueueNextMapChange();
//Switch The Map
try {

View File

@@ -36,6 +36,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
/*
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
/**
@@ -77,8 +78,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
private function initActionsMenuButtons() {
// Menu Open xList
$itemQuad = new Quad();
$itemQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON));
$itemQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER));
$itemQuad->setImage($this->maniaControl->manialinkManager->getIconManager()->getIcon(IconManager::MX_ICON));
$itemQuad->setImageFocus($this->maniaControl->manialinkManager->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
$itemQuad->setAction(self::ACTION_OPEN_XLIST);
$this->maniaControl->actionsMenu->addPlayerMenuItem($itemQuad, 5, 'Open MX List');
@@ -108,7 +109,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
public function command_ShowNextMap(array $chatCallback, Player $player) {
$nextQueued = $this->maniaControl->mapManager->mapQueue->getNextQueuedMap();
$nextQueued = $this->maniaControl->mapManager->getMapQueue()->getNextQueuedMap();
if ($nextQueued) {
/** @var Player $requester */
$requester = $nextQueued[0];
@@ -216,7 +217,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
return;
}
$this->maniaControl->mapManager->mapActions->skipMap();
$this->maniaControl->mapManager->getMapActions()->skipMap();
$message = '$<' . $player->nickname . '$> skipped the current Map!';
$this->maniaControl->chat->sendSuccess($message);
@@ -260,7 +261,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$this->maniaControl->chat->sendSuccess($message);
$this->maniaControl->log($message, true);
$this->maniaControl->mapManager->mapQueue->addFirstMapToMapQueue($player, $this->maniaControl->mapManager->getCurrentMap());
$this->maniaControl->mapManager->getMapQueue()->addFirstMapToMapQueue($player, $this->maniaControl->mapManager->getCurrentMap());
}
/**
@@ -347,7 +348,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
if (strstr($actionId, self::ACTION_SHOW_AUTHOR)) {
$login = str_replace(self::ACTION_SHOW_AUTHOR, '', $actionId);
$this->maniaControl->mapManager->mapList->playerCloseWidget($player);
$this->maniaControl->mapManager->getMapList()->playerCloseWidget($player);
$this->showMapListAuthor($login, $player);
}
}
@@ -373,7 +374,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
return;
}
$this->maniaControl->mapManager->mapList->showMapList($player, $mapList);
$this->maniaControl->mapManager->getMapList()->showMapList($player, $mapList);
}
/**
@@ -384,7 +385,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
*/
public function command_List(array $chatCallback, Player $player) {
$chatCommands = explode(' ', $chatCallback[1][2]);
$this->maniaControl->mapManager->mapList->playerCloseWidget($player);
$this->maniaControl->mapManager->getMapList()->playerCloseWidget($player);
if (isset($chatCommands[1])) {
$listParam = strtolower($chatCommands[1]);
@@ -409,11 +410,11 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
}
break;
default:
$this->maniaControl->mapManager->mapList->showMapList($player);
$this->maniaControl->mapManager->getMapList()->showMapList($player);
break;
}
} else {
$this->maniaControl->mapManager->mapList->showMapList($player);
$this->maniaControl->mapManager->getMapList()->showMapList($player);
}
}
@@ -462,7 +463,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$mapList = array_reverse($mapList);
}
$this->maniaControl->mapManager->mapList->showMapList($player, $mapList);
$this->maniaControl->mapManager->getMapList()->showMapList($player, $mapList);
} else {
$this->maniaControl->chat->sendError('KarmaPlugin is not enabled!', $player->login);
}
@@ -484,7 +485,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$maps = array_reverse($maps);
}
$this->maniaControl->mapManager->mapList->showMapList($player, $maps);
$this->maniaControl->mapManager->getMapList()->showMapList($player, $maps);
}
/**
@@ -494,6 +495,6 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
public function command_xList(array $chatCallback, Player $player) {
$this->maniaControl->mapManager->mxList->showList($chatCallback, $player);
$this->maniaControl->mapManager->getMXList()->showList($chatCallback, $player);
}
}

View File

@@ -59,6 +59,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
/*
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
/**
@@ -90,7 +91,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
*/
public function clearMapQueue(array $chatCallback, Player $player) {
// Clears the Map Queue
$this->maniaControl->mapManager->mapQueue->clearMapQueue($player);
$this->maniaControl->mapManager->getMapQueue()
->clearMapQueue($player);
}
/**
@@ -101,7 +103,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
*/
public function checkUpdates(array $chatCallback, Player $player) {
// Update Mx Infos
$this->maniaControl->mapManager->mxManager->fetchManiaExchangeMapInformation();
$this->maniaControl->mapManager->getMXManager()->fetchManiaExchangeMapInformation();
// Reshow the Maplist
$this->showMapList($player);
@@ -115,14 +117,17 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
* @param int $pageIndex
*/
public function showMapList(Player $player, $mapList = null, $pageIndex = -1) {
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
$width = $this->maniaControl->manialinkManager->getStyleManager()
->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->getStyleManager()
->getListWidgetsHeight();
if ($pageIndex < 0) {
$pageIndex = (int)$player->getCache($this, self::CACHE_CURRENT_PAGE);
}
$player->setCache($this, self::CACHE_CURRENT_PAGE, $pageIndex);
$queueBuffer = $this->maniaControl->mapManager->mapQueue->getQueueBuffer();
$queueBuffer = $this->maniaControl->mapManager->getMapQueue()
->getQueueBuffer();
$chunkIndex = $this->getChunkIndexFromPageNumber($pageIndex);
$mapsBeginIndex = $this->getChunkMapsBeginIndex($chunkIndex);
@@ -146,7 +151,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$paging->setChunkActions(self::ACTION_PAGING_CHUNKS);
// Main frame
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $paging);
$frame = $this->maniaControl->manialinkManager->getStyleManager()
->getDefaultListFrame($script, $paging);
$maniaLink->add($frame);
// Admin Buttons
@@ -188,8 +194,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mxQuad = new Quad();
$frame->add($mxQuad);
$mxQuad->setSize(3, 3);
$mxQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN));
$mxQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN_MOVER));
$mxQuad->setImage($this->maniaControl->manialinkManager->getIconManager()
->getIcon(IconManager::MX_ICON_GREEN));
$mxQuad->setImageFocus($this->maniaControl->manialinkManager->getIconManager()
->getIcon(IconManager::MX_ICON_GREEN_MOVER));
$mxQuad->setPosition($width / 2 - 67, -$height / 2 + 9);
$mxQuad->setZ(0.01);
$mxQuad->setAction(self::ACTION_CHECK_UPDATE);
@@ -220,10 +228,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
// Predefine description Label
$descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel();
$descriptionLabel = $this->maniaControl->manialinkManager->getStyleManager()
->getDefaultDescriptionLabel();
$frame->add($descriptionLabel);
$queuedMaps = $this->maniaControl->mapManager->mapQueue->getQueuedMapsRanking();
$queuedMaps = $this->maniaControl->mapManager->getMapQueue()
->getQueuedMapsRanking();
/** @var KarmaPlugin $karmaPlugin */
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_KARMA_PLUGIN);
@@ -236,10 +246,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$pageFrame = null;
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
$mxIcon = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON);
$mxIconHover = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER);
$mxIconGreen = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN);
$mxIconGreenHover = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN_MOVER);
$mxIcon = $this->maniaControl->manialinkManager->getIconManager()
->getIcon(IconManager::MX_ICON);
$mxIconHover = $this->maniaControl->manialinkManager->getIconManager()
->getIcon(IconManager::MX_ICON_MOVER);
$mxIconGreen = $this->maniaControl->manialinkManager->getIconManager()
->getIcon(IconManager::MX_ICON_GREEN);
$mxIconGreenHover = $this->maniaControl->manialinkManager->getIconManager()
->getIcon(IconManager::MX_ICON_GREEN_MOVER);
foreach ($mapList as $map) {
/** @var Map $map */
@@ -332,7 +346,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$label->setTextColor('fff');
// Checks if the Player who opened the Widget has queued the map
$queuer = $this->maniaControl->mapManager->mapQueue->getQueuer($map->uid);
$queuer = $this->maniaControl->mapManager->getMapQueue()
->getQueuer($map->uid);
if ($queuer->login == $player->login) {
$description = 'Remove $<' . $map->name . '$> from the Map Queue';
$label->addTooltipLabelFeature($descriptionLabel, $description);
@@ -520,9 +535,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// TODO: get rid of the confirm frame to decrease xml size & network usage
// SUGGESTION: just send them as own manialink again on clicking?
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
$width = $this->maniaControl->manialinkManager->getStyleManager()
->getListWidgetsWidth();
$quadStyle = $this->maniaControl->manialinkManager->getStyleManager()
->getDefaultMainWindowStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->getStyleManager()
->getDefaultMainWindowSubStyle();
$confirmFrame = new Frame();
$maniaLink->add($confirmFrame);
@@ -615,7 +633,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
break;
case self::ACTION_SWITCH_MAP:
// Don't queue on Map-Change
$this->maniaControl->mapManager->mapQueue->dontQueueNextMapChange();
$this->maniaControl->mapManager->getMapQueue()->dontQueueNextMapChange();
try {
$this->maniaControl->client->jumpToMapIdent($mapUid);
} catch (NextMapException $exception) {
@@ -649,7 +667,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$votesPlugin->undefineVote('switchmap');
//Don't queue on Map-Change
$this->maniaControl->mapManager->mapQueue->dontQueueNextMapChange();
$this->maniaControl->mapManager->getMapQueue()->dontQueueNextMapChange();
try {
$this->maniaControl->client->JumpToMapIdent($map->uid);
@@ -666,11 +684,13 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
});
break;
case self::ACTION_QUEUED_MAP:
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($callback[1][1], $mapUid);
$this->maniaControl->mapManager->getMapQueue()
->addMapToMapQueue($callback[1][1], $mapUid);
$this->showMapList($player);
break;
case self::ACTION_UNQUEUE_MAP:
$this->maniaControl->mapManager->mapQueue->removeFromMapQueue($player, $mapUid);
$this->maniaControl->mapManager->getMapQueue()
->removeFromMapQueue($player, $mapUid);
$this->showMapList($player);
break;
default:

View File

@@ -51,18 +51,25 @@ class MapManager implements CallbackListener {
* Public properties
*/
/** @var MapQueue $mapQueue */
/** @deprecated see getMapQueue() */
public $mapQueue = null;
/** @var MapCommands $mapCommands */
/** @deprecated see getMapCommands() */
public $mapCommands = null;
/** @var MapActions $mapActions */
/** @deprecated see getMapActions() */
public $mapActions = null;
/** @var MapList $mapList */
/** @deprecated see getMapList() */
public $mapList = null;
/** @var DirectoryBrowser $directoryBrowser */
/** @deprecated see getDirectoryBrowser() */
public $directoryBrowser = null;
/** @var ManiaExchangeList $mxList */
/** @deprecated see getMXList() */
public $mxList = null;
/** @var ManiaExchangeManager $mxManager */
/** @deprecated see getMXManager() */
public $mxManager = null;
/*
@@ -275,10 +282,10 @@ class MapManager implements CallbackListener {
$map = $this->maps[$uid];
// Unset the Map everywhere
$this->mapQueue->removeFromMapQueue($admin, $map->uid);
$this->getMapQueue()->removeFromMapQueue($admin, $map->uid);
if ($map->mx) {
$this->mxManager->unsetMap($map->mx->id);
$this->getMXManager()->unsetMap($map->mx->id);
}
// Remove map
@@ -323,7 +330,7 @@ class MapManager implements CallbackListener {
public function addMapFromMx($mapId, $login, $update = false) {
if (is_numeric($mapId)) {
// Check if map exists
$this->maniaControl->mapManager->mxManager->fetchMapInfo($mapId, function (MXMapInfo $mapInfo = null) use (
$this->maniaControl->mapManager->getMXManager()->fetchMapInfo($mapId, function (MXMapInfo $mapInfo = null) use (
&$login, &$update
) {
if (!$mapInfo || !isset($mapInfo->uploaded)) {
@@ -369,7 +376,8 @@ class MapManager implements CallbackListener {
$downloadFolderName = $this->maniaControl->settingManager->getSettingValue($this, 'MapDownloadDirectory', 'MX');
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
$mapDir = $this->maniaControl->server->directory->getMapsFolder();
$mapDir = $this->maniaControl->server->getDirectory()
->getMapsFolder();
$downloadDirectory = $mapDir . $downloadFolderName . DIRECTORY_SEPARATOR;
$fullMapFileName = $downloadDirectory . $fileName;
@@ -421,7 +429,7 @@ class MapManager implements CallbackListener {
$this->updateFullMapList();
// Update Mx MapInfo
$this->maniaControl->mapManager->mxManager->updateMapObjectsWithManiaExchangeIds(array($mapInfo));
$this->maniaControl->mapManager->getMXManager()->updateMapObjectsWithManiaExchangeIds(array($mapInfo));
// Update last updated time
$map = $this->getMapByUid($mapInfo->uid);
@@ -441,7 +449,7 @@ class MapManager implements CallbackListener {
$this->maniaControl->chat->sendSuccess($message);
$this->maniaControl->log($message, true);
// Queue requested Map
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($login, $mapInfo->uid);
$this->maniaControl->mapManager->getMapQueue()->addMapToMapQueue($login, $mapInfo->uid);
} else {
$message = '$<' . $player->nickname . '$> updated $<' . $mapInfo->name . '$>!';
$this->maniaControl->chat->sendSuccess($message);
@@ -721,7 +729,7 @@ class MapManager implements CallbackListener {
*/
public function handleAfterInit() {
// Fetch MX infos
$this->mxManager->fetchManiaExchangeMapInformation();
$this->getMXManager()->fetchManiaExchangeMapInformation();
}
/**
@@ -766,7 +774,7 @@ class MapManager implements CallbackListener {
$this->restructureMapList();
// Update the mx of the map (for update checks, etc.)
$this->mxManager->fetchManiaExchangeMapInformation($this->currentMap);
$this->getMXManager()->fetchManiaExchangeMapInformation($this->currentMap);
// Trigger own BeginMap callback
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMAP, $this->currentMap);

View File

@@ -38,6 +38,7 @@ class MapQueue implements CallbackListener, CommandListener {
/*
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
private $queuedMaps = array();
private $nextMap = null;
@@ -192,7 +193,7 @@ class MapQueue implements CallbackListener, CommandListener {
array_push($maps, $queuedMap[1]);
}
$this->maniaControl->mapManager->mapList->showMapList($player, $maps);
$this->maniaControl->mapManager->getMapList()->showMapList($player, $maps);
}
/**