small fixes

This commit is contained in:
kremsy 2014-01-08 18:07:09 +01:00
parent 6d2aa1b487
commit a7212c13c5
2 changed files with 199 additions and 210 deletions

View File

@ -59,8 +59,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Register for Callbacks // Register for Callbacks
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget'); $this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
'handleManialinkPageAnswer');
$this->maniaControl->callbackManager->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPS_UPDATED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPS_UPDATED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_KARMA_UPDATED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_KARMA_UPDATED, $this, 'updateWidget');
@ -95,15 +94,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
} }
if(strtolower(substr($param, 0, 5)) == 'auth:') { if(strtolower(substr($param, 0, 5)) == 'auth:') {
$author = substr($param, 5); $author = substr($param, 5);
} } elseif(strtolower(substr($param, 0, 4)) == 'env:') {
elseif (strtolower(substr($param, 0, 4)) == 'env:') {
$environment = substr($param, 4); $environment = substr($param, 4);
} } else {
else {
if($mapName == '') { if($mapName == '') {
$mapName = $param; $mapName = $param;
} } else { // concatenate words in name
else { // concatenate words in name
$mapName .= '%20' . $param; $mapName .= '%20' . $param;
} }
} }
@ -280,8 +276,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$frame->add($headFrame); $frame->add($headFrame);
$headFrame->setY($height / 2 - 5); $headFrame->setY($height / 2 - 5);
$x = -$width / 2; $x = -$width / 2;
$array = array('Id' => $x + 5, 'Mx Id' => $x + 10, 'Map Name' => $x + 20, 'Author' => $x + 68, 'Karma' => $x + 115, $array = array('Id' => $x + 5, 'Mx Id' => $x + 10, 'Map Name' => $x + 20, 'Author' => $x + 68, 'Karma' => $x + 115, 'Actions' => $width / 2 - 15);
'Actions' => $width / 2 - 15);
$this->maniaControl->manialinkManager->labelLine($headFrame, $array); $this->maniaControl->manialinkManager->labelLine($headFrame, $array);
// Predefine Description Label // Predefine Description Label
@ -368,8 +363,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$label->setText($queuedMaps[$map->uid]); $label->setText($queuedMaps[$map->uid]);
$label->setTextColor('fff'); $label->setTextColor('fff');
$descriptionLabel->setText('$<' . $map->name . '$> is on Map-Queue Position: ' . $queuedMaps[$map->uid]); $descriptionLabel->setText('$<' . $map->name . '$> is on Map-Queue Position: ' . $queuedMaps[$map->uid]);
} } else {
else {
// Map-Queue-Map-Button // Map-Queue-Map-Button
$queueLabel = new Label_Button(); $queueLabel = new Label_Button();
$mapFrame->add($queueLabel); $mapFrame->add($queueLabel);
@ -463,7 +457,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
} }
$id++; $id++;
} }
// TODO page 0 bug?
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player); $this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
} }
@ -515,8 +508,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$buttLabel->setText('»'); $buttLabel->setText('»');
$buttLabel->setTextColor('0f0'); $buttLabel->setTextColor('0f0');
$buttLabel->setTextSize(2); $buttLabel->setTextSize(2);
} } else {
else {
$buttLabel->setTextSize(1); $buttLabel->setTextSize(1);
$buttLabel->setText('x'); $buttLabel->setText('x');
$buttLabel->setTextColor('a00'); $buttLabel->setTextColor('a00');
@ -553,7 +545,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
public function handleManialinkPageAnswer(array $callback) { public function handleManialinkPageAnswer(array $callback) {
$actionId = $callback[1][2]; $actionId = $callback[1][2];
$actionArray = explode('.', $actionId); $actionArray = explode('.', $actionId);
if (count($actionArray) <= 2) return; if(count($actionArray) <= 2) {
return;
}
$action = $actionArray[0] . '.' . $actionArray[1]; $action = $actionArray[0] . '.' . $actionArray[1];
$login = $callback[1][1]; $login = $callback[1][1];
@ -565,12 +559,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$this->maniaControl->mapManager->addMapFromMx($mapId, $player->login); $this->maniaControl->mapManager->addMapFromMx($mapId, $player->login);
break; break;
case self::ACTION_ERASE_MAP: case self::ACTION_ERASE_MAP:
$this->maniaControl->mapManager->eraseMap($mapId, $actionArray[3]); $this->maniaControl->mapManager->removeMap($mapId, $actionArray[3]);
$this->showMapList($player); $this->showMapList($player);
break; break;
case self::ACTION_SWITCH_MAP: case self::ACTION_SWITCH_MAP:
$this->maniaControl->client->query('JumpToMapIndex', $mapId); $this->maniaControl->client->query('JumpToMapIndex', $mapId);
$mapList = $this->maniaControl->mapManager->getMapList(); $mapList = $this->maniaControl->mapManager->getMaps();
$map = $mapList[$mapId]; $map = $mapList[$mapId];
$message = '$<' . $player->nickname . '$> skipped to Map $z$<' . $map->name . '$>!'; $message = '$<' . $player->nickname . '$> skipped to Map $z$<' . $map->name . '$>!';
@ -597,12 +591,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
if($player != null) { if($player != null) {
if($shown == self::SHOW_MX_LIST) { if($shown == self::SHOW_MX_LIST) {
//TODO //TODO
} } else if($shown == self::SHOW_MAP_LIST) {
else if ($shown == self::SHOW_MAP_LIST) {
$this->showMapList($player); $this->showMapList($player);
} }
} } else {
else {
unset($this->mapListShown[$login]); unset($this->mapListShown[$login]);
} }
} }

View File

@ -2,11 +2,10 @@
namespace ManiaControl\Maps; namespace ManiaControl\Maps;
use ManiaControl\FileUtil;
use ManiaControl\Formatter;
use ManiaControl\ManiaControl;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\FileUtil;
use ManiaControl\ManiaControl;
require_once __DIR__ . '/Map.php'; require_once __DIR__ . '/Map.php';
require_once __DIR__ . '/MapCommands.php'; require_once __DIR__ . '/MapCommands.php';
@ -131,7 +130,7 @@ class MapManager implements CallbackListener {
* @param string $uid * @param string $uid
* @param bool $eraseFile * @param bool $eraseFile
*/ */
public function removeMap($id, $uid, $eraseFile = false) { public function removeMap($id, $uid, $eraseFile = false) { //TODO erasefile?
$map = $this->mapsUids[$uid]; $map = $this->mapsUids[$uid];
$this->maniaControl->client->query('RemoveMap', $map->fileName); $this->maniaControl->client->query('RemoveMap', $map->fileName);
$this->maniaControl->chat->sendSuccess('Map $<' . $map->name . '$> removed!'); $this->maniaControl->chat->sendSuccess('Map $<' . $map->name . '$> removed!');
@ -157,8 +156,7 @@ class MapManager implements CallbackListener {
if(array_key_exists($rpcMap["UId"], $this->mapsUids)) { if(array_key_exists($rpcMap["UId"], $this->mapsUids)) {
// Map already exists, only update index // Map already exists, only update index
$tempList[] = $this->mapsUids[$rpcMap["UId"]]; $tempList[] = $this->mapsUids[$rpcMap["UId"]];
} } else { // Insert Map Object
else { // Insert Map Object
$map = new Map($this->maniaControl, $rpcMap); $map = new Map($this->maniaControl, $rpcMap);
$this->saveMap($map); $this->saveMap($map);
$tempList[] = $map; $tempList[] = $map;
@ -237,8 +235,7 @@ class MapManager implements CallbackListener {
if(array_key_exists($callback[1][0]["UId"], $this->mapsUids)) { if(array_key_exists($callback[1][0]["UId"], $this->mapsUids)) {
// Map already exists, only update index // Map already exists, only update index
$this->currentMap = $this->mapsUids[$callback[1][0]["UId"]]; $this->currentMap = $this->mapsUids[$callback[1][0]["UId"]];
} } else {
else {
// can this ever happen? // can this ever happen?
$this->fetchCurrentMap(); $this->fetchCurrentMap();
} }