updated maplist confirmations
This commit is contained in:
parent
f8ba365af5
commit
5e798f6fa1
@ -40,8 +40,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
const ACTION_ERASE_MAP = 'MapList.EraseMap';
|
const ACTION_ERASE_MAP = 'MapList.EraseMap';
|
||||||
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
|
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
|
||||||
const ACTION_QUEUED_MAP = 'MapList.QueueMap';
|
const ACTION_QUEUED_MAP = 'MapList.QueueMap';
|
||||||
const ACTION_CONFIRM_ERASE_MAP = 'MapList.ConfirmEraseMap';
|
|
||||||
const ACTION_CONFIRM_SWITCHTO_MAP = 'MapList.ConfirmSwitchToMap';
|
|
||||||
const MAX_MAPS_PER_PAGE = 15;
|
const MAX_MAPS_PER_PAGE = 15;
|
||||||
const SHOW_MX_LIST = 1;
|
const SHOW_MX_LIST = 1;
|
||||||
const SHOW_MAP_LIST = 2;
|
const SHOW_MAP_LIST = 2;
|
||||||
@ -240,7 +238,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function showMapList(Player $player, $confirmAction = null, $confirmMapId = '') {
|
public function showMapList(Player $player) {
|
||||||
|
|
||||||
//Get Maplist
|
//Get Maplist
|
||||||
$mapList = $this->maniaControl->mapManager->getMapList();
|
$mapList = $this->maniaControl->mapManager->getMapList();
|
||||||
@ -402,8 +400,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$eraseQuad->setTextSize(1);
|
$eraseQuad->setTextSize(1);
|
||||||
$eraseQuad->setText("x");
|
$eraseQuad->setText("x");
|
||||||
$eraseQuad->setTextColor("A00");
|
$eraseQuad->setTextColor("A00");
|
||||||
//$eraseQuad->setAction(self::ACTION_ERASE_MAP . "." . ($id - 1) . "." . $map->uid);
|
|
||||||
$eraseQuad->setAction(self::ACTION_CONFIRM_ERASE_MAP . "." . ($id));
|
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id, $map->uid);
|
||||||
|
$script->addTooltip($eraseQuad, $confirmFrame, Script::OPTION_TOOLTIP_STAYONCLICK);
|
||||||
|
|
||||||
//Description Label
|
//Description Label
|
||||||
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
||||||
@ -422,7 +421,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$switchToQuad->setText("»");
|
$switchToQuad->setText("»");
|
||||||
$switchToQuad->setTextColor("0F0");
|
$switchToQuad->setTextColor("0F0");
|
||||||
|
|
||||||
$switchToQuad->setAction(self::ACTION_CONFIRM_SWITCHTO_MAP . "." . ($id));
|
//$switchToQuad->setAction(self::ACTION_CONFIRM_SWITCHTO_MAP . "." . ($id));
|
||||||
|
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id);
|
||||||
|
$script->addTooltip($switchToQuad, $confirmFrame, Script::OPTION_TOOLTIP_STAYONCLICK);
|
||||||
|
|
||||||
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
@ -460,8 +461,31 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Confirm Frame
|
$y -= 4;
|
||||||
if($id == $confirmMapId && ($confirmAction == self::ACTION_CONFIRM_SWITCHTO_MAP || $confirmAction == self::ACTION_CONFIRM_ERASE_MAP)) {
|
|
||||||
|
if($id % self::MAX_MAPS_PER_PAGE == 0) {
|
||||||
|
unset($pageFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
$id++;
|
||||||
|
}
|
||||||
|
//TODO page 0 bug?
|
||||||
|
//render and display xml
|
||||||
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the confirmation frame
|
||||||
|
*
|
||||||
|
* @param ManiaLink $maniaLink
|
||||||
|
* @param $y
|
||||||
|
* @param $id
|
||||||
|
* @param bool $mapUid
|
||||||
|
* @return Frame
|
||||||
|
*/
|
||||||
|
public function buildConfirmFrame(Manialink $maniaLink, $y, $id, $mapUid = false) {
|
||||||
|
|
||||||
$confirmFrame = new Frame();
|
$confirmFrame = new Frame();
|
||||||
$maniaLink->add($confirmFrame);
|
$maniaLink->add($confirmFrame);
|
||||||
$confirmFrame->setPosition($this->width / 2 + 6, $y);
|
$confirmFrame->setPosition($this->width / 2 + 6, $y);
|
||||||
@ -492,7 +516,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
// $buttLabel->setTextSize(1);
|
// $buttLabel->setTextSize(1);
|
||||||
$buttLabel->setAlign(Control::CENTER, Control::CENTER);
|
$buttLabel->setAlign(Control::CENTER, Control::CENTER);
|
||||||
|
|
||||||
if($confirmAction == self::ACTION_CONFIRM_SWITCHTO_MAP) {
|
if(!$mapUid) {
|
||||||
$quad->setAction(self::ACTION_SWITCH_MAP . "." . ($id - 1));
|
$quad->setAction(self::ACTION_SWITCH_MAP . "." . ($id - 1));
|
||||||
$buttLabel->setText("»");
|
$buttLabel->setText("»");
|
||||||
$buttLabel->setTextColor("0F0");
|
$buttLabel->setTextColor("0F0");
|
||||||
@ -501,25 +525,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$buttLabel->setTextSize(1);
|
$buttLabel->setTextSize(1);
|
||||||
$buttLabel->setText("x");
|
$buttLabel->setText("x");
|
||||||
$buttLabel->setTextColor("A00");
|
$buttLabel->setTextColor("A00");
|
||||||
$quad->setAction(self::ACTION_ERASE_MAP . "." . ($id - 1) . "." . $map->uid);
|
$quad->setAction(self::ACTION_ERASE_MAP . "." . ($id - 1) . "." . $mapUid);
|
||||||
}
|
}
|
||||||
|
return $confirmFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$y -= 4;
|
|
||||||
|
|
||||||
if($id % self::MAX_MAPS_PER_PAGE == 0) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
$id++;
|
|
||||||
}
|
|
||||||
//TODO page 0 bug?
|
|
||||||
//render and display xml
|
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the widget
|
* Closes the widget
|
||||||
*
|
*
|
||||||
@ -527,7 +537,18 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function closeWidget(array $callback) {
|
public function closeWidget(array $callback) {
|
||||||
$player = $callback[1];
|
$player = $callback[1];
|
||||||
|
$this->playerCloseWidget($player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the widget
|
||||||
|
*
|
||||||
|
* @param \ManiaControl\Players\Player $player
|
||||||
|
* @internal param $login
|
||||||
|
*/
|
||||||
|
public function playerCloseWidget(Player $player) {
|
||||||
unset($this->mapListShown[$player->login]);
|
unset($this->mapListShown[$player->login]);
|
||||||
|
$this->maniaControl->manialinkManager->closeWidget($player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -544,25 +565,21 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1]);
|
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1]);
|
||||||
|
|
||||||
switch($action) {
|
switch($action) {
|
||||||
case self::ACTION_CONFIRM_SWITCHTO_MAP:
|
|
||||||
$this->showMapList($player, self::ACTION_CONFIRM_SWITCHTO_MAP, $actionArray[2]);
|
|
||||||
break;
|
|
||||||
case self::ACTION_CONFIRM_ERASE_MAP:
|
|
||||||
$this->showMapList($player, self::ACTION_CONFIRM_ERASE_MAP, $actionArray[2]);
|
|
||||||
break;
|
|
||||||
case self::ACTION_ADD_MAP:
|
case self::ACTION_ADD_MAP:
|
||||||
$this->maniaControl->mapManager->addMapFromMx(intval($actionArray[2]), $callback[1][1]); //TODO bestätigung
|
$this->maniaControl->mapManager->addMapFromMx(intval($actionArray[2]), $callback[1][1]);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ERASE_MAP:
|
case self::ACTION_ERASE_MAP:
|
||||||
$this->maniaControl->mapManager->eraseMap(intval($actionArray[2]), $actionArray[3]); //TODO bestätigung
|
$this->maniaControl->mapManager->eraseMap(intval($actionArray[2]), $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', intval($actionArray[2])); //TODO bestätigung
|
$this->maniaControl->client->query('JumpToMapIndex', intval($actionArray[2]));
|
||||||
$mapList = $this->maniaControl->mapManager->getMapList();
|
$mapList = $this->maniaControl->mapManager->getMapList();
|
||||||
|
|
||||||
$this->maniaControl->chat->sendSuccess('Map switched to $z$<' . $mapList[$actionArray[2]]->name . '$>!'); //TODO specified message, who done it?
|
$this->maniaControl->chat->sendSuccess('Map switched to $z$<' . $mapList[$actionArray[2]]->name . '$>!'); //TODO specified message, who done it?
|
||||||
$this->maniaControl->log(Formatter::stripCodes('Skipped to $z$<' . $mapList[$actionArray[2]]->name . '$>!'));
|
$this->maniaControl->log(Formatter::stripCodes('Skipped to $z$<' . $mapList[$actionArray[2]]->name . '$>!'));
|
||||||
|
|
||||||
|
$this->playerCloseWidget($player);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_QUEUED_MAP:
|
case self::ACTION_QUEUED_MAP:
|
||||||
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($callback[1][1], $actionArray[2]);
|
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($callback[1][1], $actionArray[2]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user