switch directly to a map

This commit is contained in:
kremsy 2013-12-16 12:41:14 +01:00
parent e72c03a609
commit 11d966a6ca

View File

@ -32,6 +32,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
const ACTION_CLOSEWIDGET = 'MapList.CloseWidget'; const ACTION_CLOSEWIDGET = 'MapList.CloseWidget';
const ACTION_ADD_MAP = 'MapList.AddMap'; const ACTION_ADD_MAP = 'MapList.AddMap';
const ACTION_ERASE_MAP = 'MapList.EraseMap';
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
const MAX_MAPS_PER_PAGE = 15; const MAX_MAPS_PER_PAGE = 15;
@ -243,45 +245,49 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$this->displayMap($id, $map, $mapFrame, $tooltips); $this->displayMap($id, $map, $mapFrame, $tooltips);
$mapFrame->setY($y); $mapFrame->setY($y);
//erase map quad if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)){ //todoSET as setting who can add maps
$eraseQuad = new Quad_UIConstruction_Buttons(); //erase map quad
$mapFrame->add($eraseQuad); $eraseQuad = new Quad_UIConstruction_Buttons();
$eraseQuad->setX($this->width/2 - 5); $mapFrame->add($eraseQuad);
$eraseQuad->setZ(0.2); $eraseQuad->setX($this->width/2 - 5);
$eraseQuad->setSize(4,4); $eraseQuad->setZ(0.2);
$eraseQuad->setSubStyle($eraseQuad::SUBSTYLE_Erase); $eraseQuad->setSize(4,4);
//TODO bestätigung? $eraseQuad->setSubStyle($eraseQuad::SUBSTYLE_Erase);
$eraseQuad->setAction(self::ACTION_ERASE_MAP . "." .($id-1));
//TODO bestätigung?
//switch to map quad //Description Label
$switchToQuad = new Quad_Icons64x64_1(); $descriptionLabel = new Label();
$mapFrame->add($switchToQuad); $frame->add($descriptionLabel);
$switchToQuad->setX($this->width/2 - 10); $descriptionLabel->setAlign(Control::LEFT, Control::TOP);
$switchToQuad->setZ(0.2); $descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5);
$switchToQuad->setSize(4, 4); $descriptionLabel->setSize($this->width * 0.7, 4);
$switchToQuad->setSubStyle($switchToQuad::SUBSTYLE_ArrowFastNext); $descriptionLabel->setTextSize(2);
//TODO bestätigung? $descriptionLabel->setVisible(false);
$descriptionLabel->setText("Remove Map: {$map->name}");
//Description Label $tooltips->add($eraseQuad, $descriptionLabel);
$descriptionLabel = new Label(); }
$frame->add($descriptionLabel); if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)){ //todoSET as setting who can add maps
$descriptionLabel->setAlign(Control::LEFT, Control::TOP); //switch to map quad
$descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5); $switchToQuad = new Quad_Icons64x64_1();
$descriptionLabel->setSize($this->width * 0.7, 4); $mapFrame->add($switchToQuad);
$descriptionLabel->setTextSize(2); $switchToQuad->setX($this->width/2 - 10);
$descriptionLabel->setVisible(false); $switchToQuad->setZ(0.2);
$descriptionLabel->setText("Remove Map: {$map->name}"); $switchToQuad->setSize(4, 4);
$tooltips->add($eraseQuad, $descriptionLabel); $switchToQuad->setSubStyle($switchToQuad::SUBSTYLE_ArrowFastNext);
$switchToQuad->setAction(self::ACTION_SWITCH_MAP . "." .($id-1));
$descriptionLabel = new Label(); //TODO bestätigung?
$frame->add($descriptionLabel);
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
$descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5);
$descriptionLabel->setSize($this->width * 0.7, 4);
$descriptionLabel->setTextSize(2);
$descriptionLabel->setVisible(false);
$descriptionLabel->setText("Switch Directly to Map: {$map->name}");
$tooltips->add($switchToQuad, $descriptionLabel);
$descriptionLabel = new Label();
$frame->add($descriptionLabel);
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
$descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5);
$descriptionLabel->setSize($this->width * 0.7, 4);
$descriptionLabel->setTextSize(2);
$descriptionLabel->setVisible(false);
$descriptionLabel->setText("Switch Directly to Map: {$map->name}");
$tooltips->add($switchToQuad, $descriptionLabel);
}
$y -= 4; $y -= 4;
$id++; $id++;
if($id == self::MAX_MAPS_PER_PAGE - 1) if($id == self::MAX_MAPS_PER_PAGE - 1)
@ -344,11 +350,21 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
public function handleManialinkPageAnswer(array $callback){ public function handleManialinkPageAnswer(array $callback){
$actionId = $callback[1][2]; $actionId = $callback[1][2];
$addMap = (strpos($actionId, self::ACTION_ADD_MAP) === 0); $addMap = (strpos($actionId, self::ACTION_ADD_MAP) === 0);
if(!$addMap) $eraseMap = (strpos($actionId, self::ACTION_ERASE_MAP) === 0);
$switchMap = (strpos($actionId, self::ACTION_SWITCH_MAP) === 0);
if(!$addMap && !$eraseMap && !$switchMap)
return; return;
$actionArray = explode(".", $actionId); $actionArray = explode(".", $actionId);
var_dump($actionArray);
$this->maniaControl->mapManager->addMapFromMx($actionArray[2],$callback[1][1]); if($addMap){ //TODO log and chat message
$this->maniaControl->mapManager->addMapFromMx($actionArray[2],$callback[1][1]);
}else if($eraseMap){
}else if($switchMap){ //TODO log and chat message
$this->maniaControl->client->query('JumpToMapIndex', intval($actionArray[2]));
}
} }
} }