performed code formatting
This commit is contained in:
@ -80,9 +80,11 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||
*/
|
||||
public static function prepare(ManiaControl $maniaControl) {
|
||||
$servers = $maniaControl->getServer()->getAllServers();
|
||||
$servers = $maniaControl->getServer()
|
||||
->getAllServers();
|
||||
foreach ($servers as $server) {
|
||||
$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_DEDIMANIA_CODE . $server->login . '$l', '');
|
||||
$maniaControl->getSettingManager()
|
||||
->initSetting(get_class(), self::SETTING_DEDIMANIA_CODE . $server->login . '$l', '');
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,39 +134,61 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
}
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_ENABLE, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_TITLE, 'Dedimania');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSX, -139);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSY, 7);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 40);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINE_HEIGHT, 4);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINE_COUNT, 12);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_WIDGET_ENABLE, true);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_WIDGET_TITLE, 'Dedimania');
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_WIDGET_POSX, -139);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_WIDGET_POSY, 7);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_WIDGET_WIDTH, 40);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_WIDGET_LINE_HEIGHT, 4);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_WIDGET_LINE_COUNT, 12);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ENDMAP, $this, 'handleMapEnd');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(RecordCallback::CHECKPOINT, $this, 'handleCheckpointCallback');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(RecordCallback::LAPFINISH, $this, 'handleLapFinishCallback');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(RecordCallback::FINISH, $this, 'handleFinishCallback');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::ENDMAP, $this, 'handleMapEnd');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(RecordCallback::CHECKPOINT, $this, 'handleCheckpointCallback');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(RecordCallback::LAPFINISH, $this, 'handleLapFinishCallback');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(RecordCallback::FINISH, $this, 'handleFinishCallback');
|
||||
|
||||
$this->maniaControl->getTimerManager()->registerTimerListening($this, 'updateEverySecond', 1000);
|
||||
$this->maniaControl->getTimerManager()->registerTimerListening($this, 'handleEveryMinute', 1000 * 60);
|
||||
$this->maniaControl->getTimerManager()->registerTimerListening($this, 'updatePlayerList', 1000 * 60 * 3);
|
||||
$this->maniaControl->getTimerManager()
|
||||
->registerTimerListening($this, 'updateEverySecond', 1000);
|
||||
$this->maniaControl->getTimerManager()
|
||||
->registerTimerListening($this, 'handleEveryMinute', 1000 * 60);
|
||||
$this->maniaControl->getTimerManager()
|
||||
->registerTimerListening($this, 'updatePlayerList', 1000 * 60 * 3);
|
||||
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('dedirecs', 'dedirecords'), $this, 'showDediRecordsList', false, 'Shows a list of Dedimania records of the current map.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('dedirecs', 'dedirecords'), $this, 'showDediRecordsList', false, 'Shows a list of Dedimania records of the current map.');
|
||||
|
||||
// Open session
|
||||
$serverInfo = $this->maniaControl->getServer()->getInfo();
|
||||
$serverInfo = $this->maniaControl->getServer()
|
||||
->getInfo();
|
||||
$packMask = $this->maniaControl->getServer()->titleId;
|
||||
$serverVersion = $this->maniaControl->getClient()->getVersion();
|
||||
$serverVersion = $this->maniaControl->getClient()
|
||||
->getVersion();
|
||||
if ($packMask !== 'Trackmania_2@nadeolabs') {
|
||||
$packMask = substr($this->maniaControl->getServer()->titleId, 2);
|
||||
}
|
||||
|
||||
$dedimaniaCode = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DEDIMANIA_CODE . $serverInfo->login . '$l');
|
||||
$dedimaniaCode = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_DEDIMANIA_CODE . $serverInfo->login . '$l');
|
||||
if (!$dedimaniaCode) {
|
||||
throw new \Exception("No Dedimania Code Specified, check the settings!");
|
||||
}
|
||||
@ -195,7 +219,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
|
||||
|
||||
//$this->maniaControl->fileReader->postDataTest($this->request, self::DEDIMANIA_URL, function ($data, $error) {
|
||||
$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
$this->maniaControl->getFileReader()
|
||||
->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
Logger::log("Try to connect on Dedimania");
|
||||
|
||||
if (!$data || $error) {
|
||||
@ -294,7 +319,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$content = $this->encode_request(self::DEDIMANIA_GET_RECORDS, $data);
|
||||
//var_dump("get recs");
|
||||
//$this->maniaControl->fileReader->postDataTest($this->request,self::DEDIMANIA_URL, function ($data, $error) {
|
||||
$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
$this->maniaControl->getFileReader()
|
||||
->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
if ($error) {
|
||||
Logger::logError('Dedimania Error: ' . $error);
|
||||
}
|
||||
@ -312,7 +338,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
|
||||
$responseData = $methodResponse[0];
|
||||
if (!isset($responseData['Players']) || !isset($responseData['Records'])) {
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('Invalid Dedimania response!', $responseData);
|
||||
$this->maniaControl->getErrorHandler()
|
||||
->triggerDebugNotice('Invalid Dedimania response!', $responseData);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -331,7 +358,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
}
|
||||
|
||||
$this->updateManialink = true;
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
||||
}, $content, true);
|
||||
|
||||
return true;
|
||||
@ -341,17 +369,22 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
* Build server info Structure for callbacks
|
||||
*/
|
||||
private function getServerInfo() {
|
||||
$server = $this->maniaControl->getClient()->getServerOptions();
|
||||
$server = $this->maniaControl->getClient()
|
||||
->getServerOptions();
|
||||
if (!$server) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getPlayerManager()->getPlayerCount(false) <= 0) {
|
||||
if ($this->maniaControl->getPlayerManager()
|
||||
->getPlayerCount(false) <= 0
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$playerCount = $this->maniaControl->getPlayerManager()->getPlayerCount();
|
||||
$spectatorCount = $this->maniaControl->getPlayerManager()->getSpectatorCount();
|
||||
$playerCount = $this->maniaControl->getPlayerManager()
|
||||
->getPlayerCount();
|
||||
$spectatorCount = $this->maniaControl->getPlayerManager()
|
||||
->getSpectatorCount();
|
||||
|
||||
return array('SrvName' => $server->name, 'Comment' => $server->comment, 'Private' => (strlen($server->password) > 0), 'NumPlayers' => $playerCount, 'MaxPlayers' => $server->currentMaxPlayers, 'NumSpecs' => $spectatorCount, 'MaxSpecs' => $server->currentMaxSpectators);
|
||||
}
|
||||
@ -360,7 +393,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
* Build simple player list for callbacks
|
||||
*/
|
||||
private function getPlayerList() {
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
$players = $this->maniaControl->getPlayerManager()
|
||||
->getPlayers();
|
||||
|
||||
if (empty($players)) {
|
||||
return null;
|
||||
@ -378,7 +412,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
* @return array
|
||||
*/
|
||||
private function getMapInfo() {
|
||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
$map = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap();
|
||||
if (!$map) {
|
||||
return null;
|
||||
}
|
||||
@ -398,7 +433,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
* @return String
|
||||
*/
|
||||
private function getGameModeString() {
|
||||
$gameMode = $this->maniaControl->getServer()->getGameMode();
|
||||
$gameMode = $this->maniaControl->getServer()
|
||||
->getGameMode();
|
||||
if ($gameMode === null) {
|
||||
Logger::logError("Couldn't retrieve game mode.");
|
||||
return null;
|
||||
@ -406,7 +442,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
switch ($gameMode) {
|
||||
case 0:
|
||||
{
|
||||
$scriptNameResponse = $this->maniaControl->getClient()->getScriptName();
|
||||
$scriptNameResponse = $this->maniaControl->getClient()
|
||||
->getScriptName();
|
||||
$scriptName = str_replace('.Script.txt', '', $scriptNameResponse['CurrentValue']);
|
||||
switch ($scriptName) {
|
||||
case 'Rounds':
|
||||
@ -450,9 +487,12 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
var_dump("Dedimania Debug: Update Manialink");
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
|
||||
if ($this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_WIDGET_ENABLE)
|
||||
) {
|
||||
$manialink = $this->buildManialink();
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($manialink);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->sendManialink($manialink);
|
||||
}
|
||||
}
|
||||
|
||||
@ -464,15 +504,27 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
private function buildManialink() {
|
||||
$records = $this->dedimaniaData->records;
|
||||
|
||||
$title = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_TITLE);
|
||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSX);
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSY);
|
||||
$width = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_WIDTH);
|
||||
$lines = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_LINE_COUNT);
|
||||
$lineHeight = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_LINE_HEIGHT);
|
||||
$labelStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultLabelStyle();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
|
||||
$title = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_WIDGET_TITLE);
|
||||
$posX = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_WIDGET_POSX);
|
||||
$posY = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_WIDGET_POSY);
|
||||
$width = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_WIDGET_WIDTH);
|
||||
$lines = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_WIDGET_LINE_COUNT);
|
||||
$lineHeight = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_WIDGET_LINE_HEIGHT);
|
||||
$labelStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultLabelStyle();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultQuadSubstyle();
|
||||
|
||||
|
||||
$manialink = new ManiaLink(self::MLID_DEDIMANIA);
|
||||
@ -570,7 +622,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$content = $this->encode_request(self::DEDIMANIA_CHECK_SESSION, array($this->dedimaniaData->sessionId));
|
||||
//var_dump("check session"); //TODO remove
|
||||
//$this->maniaControl->fileReader->postDataTest($this->request, self::DEDIMANIA_URL, function ($data, $error) {
|
||||
$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
$this->maniaControl->getFileReader()
|
||||
->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
if ($error) {
|
||||
Logger::logError("Dedimania Error: " . $error);
|
||||
}
|
||||
@ -614,7 +667,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$data = array($this->dedimaniaData->sessionId, $player->login, $player->rawNickname, $player->path, $player->isSpectator);
|
||||
$content = $this->encode_request(self::DEDIMANIA_PLAYERCONNECT, $data);
|
||||
|
||||
$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$player) {
|
||||
$this->maniaControl->getFileReader()
|
||||
->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$player) {
|
||||
if ($error) {
|
||||
Logger::logError("Dedimania Error: " . $error);
|
||||
}
|
||||
@ -635,13 +689,18 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$this->dedimaniaData->addPlayer($dediPlayer);
|
||||
|
||||
// Fetch records if he is the first who joined the server
|
||||
if ($this->maniaControl->getPlayerManager()->getPlayerCount(false) === 1) {
|
||||
if ($this->maniaControl->getPlayerManager()
|
||||
->getPlayerCount(false) === 1
|
||||
) {
|
||||
$this->fetchDedimaniaRecords(true);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
|
||||
if ($this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_WIDGET_ENABLE)
|
||||
) {
|
||||
$manialink = $this->buildManialink();
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($manialink, $player->login);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->sendManialink($manialink, $player->login);
|
||||
}
|
||||
}, $content, true);
|
||||
}
|
||||
@ -661,7 +720,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$data = array($this->dedimaniaData->sessionId, $player->login, '');
|
||||
$content = $this->encode_request(self::DEDIMANIA_PLAYERDISCONNECT, $data);
|
||||
|
||||
$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
$this->maniaControl->getFileReader()
|
||||
->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
if ($error) {
|
||||
Logger::logError("Dedimania Error: " . $error);
|
||||
}
|
||||
@ -731,7 +791,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
var_dump("Dedimania Debug: Submitting Times at End-Map", $content);
|
||||
}
|
||||
|
||||
$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
$this->maniaControl->getFileReader()
|
||||
->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
if ($error) {
|
||||
Logger::logError("Dedimania Error: " . $error);
|
||||
}
|
||||
@ -781,7 +842,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$data = array($this->dedimaniaData->sessionId, $serverInfo, $votesInfo, $playerList);
|
||||
$content = $this->encode_request(self::DEDIMANIA_UPDATE_SERVER_PLAYERS, $data);
|
||||
|
||||
$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
$this->maniaControl->getFileReader()
|
||||
->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
if ($error) {
|
||||
Logger::logError("Dedimania Error: " . $error);
|
||||
}
|
||||
@ -802,7 +864,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
* Build Votes Info Array for Callbacks
|
||||
*/
|
||||
private function getVotesInfo() {
|
||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
$map = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap();
|
||||
if (!$map) {
|
||||
return null;
|
||||
}
|
||||
@ -856,7 +919,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
return;
|
||||
}
|
||||
|
||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
$map = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap();
|
||||
if (!$map) {
|
||||
return;
|
||||
}
|
||||
@ -876,7 +940,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
break;
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_DEDIMANIA_CHANGED, $newRecord);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_DEDIMANIA_CHANGED, $newRecord);
|
||||
|
||||
// Announce record
|
||||
if ($oldRecord->nullRecord || $newRecord->rank < $oldRecord->rank) {
|
||||
@ -890,7 +955,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
if (!$oldRecord->nullRecord) {
|
||||
$message .= ' ($<$ff0' . $oldRecord->rank . '.$> $<$fff-' . Formatter::formatTime(($oldRecord->best - $callback->lapTime)) . '$>)';
|
||||
}
|
||||
$this->maniaControl->getChat()->sendInformation($message . '!');
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($message . '!');
|
||||
|
||||
$this->updateManialink = true;
|
||||
}
|
||||
@ -1026,7 +1092,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
*/
|
||||
private function updateDedimaniaRecordRanks() {
|
||||
if ($this->dedimaniaData->getRecordCount() === 0) {
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1038,7 +1105,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$record->rank = $rank;
|
||||
$rank++;
|
||||
}
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1048,23 +1116,28 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
*/
|
||||
private function setRecordReplays(RecordData &$record) {
|
||||
// Set validation replay
|
||||
$validationReplay = $this->maniaControl->getServer()->getValidationReplay($record->login);
|
||||
$validationReplay = $this->maniaControl->getServer()
|
||||
->getValidationReplay($record->login);
|
||||
if ($validationReplay) {
|
||||
$record->vReplay = $validationReplay;
|
||||
}
|
||||
|
||||
// Set ghost replay
|
||||
if ($record->rank <= 1) {
|
||||
$dataDirectory = $this->maniaControl->getServer()->getDirectory()->getGameDataFolder();
|
||||
$dataDirectory = $this->maniaControl->getServer()
|
||||
->getDirectory()
|
||||
->getGameDataFolder();
|
||||
if (!isset($this->dedimaniaData->directoryAccessChecked)) {
|
||||
$access = $this->maniaControl->getServer()->checkAccess($dataDirectory);
|
||||
$access = $this->maniaControl->getServer()
|
||||
->checkAccess($dataDirectory);
|
||||
if (!$access) {
|
||||
trigger_error("No access to the servers data directory. Can't retrieve ghost replays.");
|
||||
}
|
||||
$this->dedimaniaData->directoryAccessChecked = $access;
|
||||
}
|
||||
if ($this->dedimaniaData->directoryAccessChecked) {
|
||||
$ghostReplay = $this->maniaControl->getServer()->getGhostReplay($record->login);
|
||||
$ghostReplay = $this->maniaControl->getServer()
|
||||
->getGhostReplay($record->login);
|
||||
if ($ghostReplay) {
|
||||
$record->top1GReplay = $ghostReplay;
|
||||
}
|
||||
@ -1081,7 +1154,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$actionId = $callback[1][2];
|
||||
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
|
||||
if ($actionId === self::ACTION_SHOW_DEDIRECORDSLIST) {
|
||||
$this->showDediRecordsList(array(), $player);
|
||||
@ -1095,13 +1169,18 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showDediRecordsList(array $chat, Player $player) {
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
|
||||
// get PlayerList
|
||||
$records = $this->dedimaniaData->records;
|
||||
if (!$records) {
|
||||
$this->maniaControl->getChat()->sendInformation('There are no Dedimania records on this map!');
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation('There are no Dedimania records on this map!');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1112,7 +1191,9 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$script->addFeature($paging);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Start offsets
|
||||
@ -1120,7 +1201,9 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$posY = $height / 2;
|
||||
|
||||
// Predefine Description Label
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
// Headline
|
||||
@ -1128,7 +1211,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($posY - 5);
|
||||
$array = array('Rank' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Time' => $posX + 101);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($headFrame, $array);
|
||||
|
||||
$index = 0;
|
||||
$posY = $height / 2 - 10;
|
||||
@ -1157,7 +1241,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$listRecord->nickName = $listRecord->login;
|
||||
}
|
||||
$array = array($listRecord->rank => $posX + 5, '$fff' . $listRecord->nickName => $posX + 18, $listRecord->login => $posX + 70, Formatter::formatTime($listRecord->best) => $posX + 101);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($recordFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($recordFrame, $array);
|
||||
|
||||
$recordFrame->setY($posY);
|
||||
|
||||
@ -1166,7 +1251,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
}
|
||||
|
||||
// Render and display xml
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'DediRecordsList');
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, 'DediRecordsList');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user