extra ask on skip to and erase
This commit is contained in:
parent
f37d506867
commit
442b6d1f7b
@ -1,13 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ManiaControl\Maps;
|
namespace ManiaControl\Maps;
|
||||||
|
|
||||||
use FML\Controls\Control;
|
use FML\Controls\Control;
|
||||||
|
use FML\Controls\Frame;
|
||||||
use FML\Controls\Gauge;
|
use FML\Controls\Gauge;
|
||||||
use FML\Controls\Label;
|
use FML\Controls\Label;
|
||||||
use FML\Controls\Labels\Label_Button;
|
use FML\Controls\Labels\Label_Button;
|
||||||
use FML\Controls\Labels\Label_Text;
|
use FML\Controls\Labels\Label_Text;
|
||||||
|
use FML\Controls\Quad;
|
||||||
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
||||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||||
|
use FML\ManiaLink;
|
||||||
use FML\Script\Script;
|
use FML\Script\Script;
|
||||||
use KarmaPlugin;
|
use KarmaPlugin;
|
||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
@ -15,12 +19,9 @@ use ManiaControl\Callbacks\CallbackListener;
|
|||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\ColorUtil;
|
use ManiaControl\ColorUtil;
|
||||||
use ManiaControl\Formatter;
|
use ManiaControl\Formatter;
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use FML\Controls\Frame;
|
|
||||||
use FML\Controls\Quad;
|
|
||||||
use FML\ManiaLink;
|
|
||||||
use ManiaControl\ManiaControl;
|
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use MXInfoSearcher;
|
use MXInfoSearcher;
|
||||||
|
|
||||||
@ -39,6 +40,8 @@ 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;
|
||||||
@ -78,15 +81,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||||
|
|
||||||
/** @var just a test $itemQuad
|
/** @var just a test $itemQuad
|
||||||
$itemQuad = new Quad();
|
* $itemQuad = new Quad();
|
||||||
$itemQuad->setStyles('Icons128x32_1', Quad_Icons128x128_1::SUBSTYLE_Create);
|
* $itemQuad->setStyles('Icons128x32_1', Quad_Icons128x128_1::SUBSTYLE_Create);
|
||||||
$itemQuad->setAction(self::ACTION_ADD_MAP);
|
* $itemQuad->setAction(self::ACTION_ADD_MAP);
|
||||||
$this->maniaControl->adminMenu->addMenuItem($itemQuad, 4);*/
|
* $this->maniaControl->adminMenu->addMenuItem($itemQuad, 4);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the Mania Exchange List
|
* Displays the Mania Exchange List
|
||||||
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
@ -105,19 +109,22 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
if(count($params) > 1) {
|
if(count($params) > 1) {
|
||||||
foreach($params as $param) {
|
foreach($params as $param) {
|
||||||
if($param == '/xlist')
|
if($param == '/xlist') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$recent = false;
|
$recent = false;
|
||||||
}
|
}
|
||||||
@ -128,8 +135,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
//check if there are any results
|
//check if there are any results
|
||||||
if(!$maps->valid()) {
|
if(!$maps->valid()) {
|
||||||
$this->maniaControl->chat->sendError('No maps found, or MX is down!', $player->login);
|
$this->maniaControl->chat->sendError('No maps found, or MX is down!', $player->login);
|
||||||
if($maps->error != '')
|
if($maps->error != '') {
|
||||||
trigger_error($maps->error, E_USER_WARNING);
|
trigger_error($maps->error, E_USER_WARNING);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,9 +195,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
$i++;
|
$i++;
|
||||||
if($i == self::MAX_MAPS_PER_PAGE)
|
if($i == self::MAX_MAPS_PER_PAGE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TODO add MX info screen
|
//TODO add MX info screen
|
||||||
|
|
||||||
@ -199,6 +208,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the mainFrame
|
* Builds the mainFrame
|
||||||
|
*
|
||||||
* @return Frame $frame
|
* @return Frame $frame
|
||||||
*/
|
*/
|
||||||
public function buildMainFrame() {
|
public function buildMainFrame() {
|
||||||
@ -223,11 +233,13 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
return $frame;
|
return $frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displayes a MapList on the screen
|
* Displayes a MapList on the screen
|
||||||
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function showMapList(Player $player){
|
public function showMapList(Player $player, $confirmAction = null, $confirmMapId = '') {
|
||||||
|
|
||||||
$this->mapListShown[$player->login] = self::SHOW_MAP_LIST;
|
$this->mapListShown[$player->login] = self::SHOW_MAP_LIST;
|
||||||
|
|
||||||
@ -235,6 +247,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$frame = $this->buildMainFrame();
|
$frame = $this->buildMainFrame();
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create script and features
|
// Create script and features
|
||||||
$script = new Script();
|
$script = new Script();
|
||||||
$maniaLink->setScript($script);
|
$maniaLink->setScript($script);
|
||||||
@ -275,7 +290,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($this->maniaControl->mapManager->getCurrentMap() === $map) {
|
if($this->maniaControl->mapManager->getCurrentMap() === $map) {
|
||||||
$currentQuad = new Quad_Icons64x64_1();
|
$currentQuad = new Quad_Icons64x64_1();
|
||||||
$mapFrame->add($currentQuad);
|
$mapFrame->add($currentQuad);
|
||||||
@ -286,8 +300,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$mxId = '-';
|
$mxId = '-';
|
||||||
if(isset($map->mx->id))
|
if(isset($map->mx->id)) {
|
||||||
$mxId = $map->mx->id;
|
$mxId = $map->mx->id;
|
||||||
|
}
|
||||||
|
|
||||||
//Display Maps
|
//Display Maps
|
||||||
$array = array($id => $x + 5, $mxId => $x + 10, $map->name => $x + 20, $map->authorNick => $x + 68);
|
$array = array($id => $x + 5, $mxId => $x + 10, $map->name => $x + 20, $map->authorNick => $x + 68);
|
||||||
@ -345,7 +360,8 @@ 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_ERASE_MAP . "." . ($id - 1) . "." . $map->uid);
|
||||||
|
$eraseQuad->setAction(self::ACTION_CONFIRM_ERASE_MAP . "." . ($id));
|
||||||
|
|
||||||
//Description Label
|
//Description Label
|
||||||
$descriptionLabel = new Label();
|
$descriptionLabel = new Label();
|
||||||
@ -366,11 +382,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$switchToQuad->setX($this->width / 2 - 10);
|
$switchToQuad->setX($this->width / 2 - 10);
|
||||||
$switchToQuad->setZ(0.2);
|
$switchToQuad->setZ(0.2);
|
||||||
$switchToQuad->setSize(3, 3);
|
$switchToQuad->setSize(3, 3);
|
||||||
|
$switchToQuad->setTextSize(2);
|
||||||
//$switchToQuad->setSubStyle($switchToQuad::SUBSTYLE_ArrowFastNext);
|
//$switchToQuad->setSubStyle($switchToQuad::SUBSTYLE_ArrowFastNext);
|
||||||
$switchToQuad->setText("»");
|
$switchToQuad->setText("»");
|
||||||
$switchToQuad->setTextColor("0F0");
|
$switchToQuad->setTextColor("0F0");
|
||||||
|
|
||||||
$switchToQuad->setAction(self::ACTION_SWITCH_MAP . "." .($id-1));
|
$switchToQuad->setAction(self::ACTION_CONFIRM_SWITCHTO_MAP . "." . ($id));
|
||||||
|
|
||||||
$descriptionLabel = new Label();
|
$descriptionLabel = new Label();
|
||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
@ -411,11 +428,61 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Confirm Frame
|
||||||
|
if($id == $confirmMapId && ($confirmAction == self::ACTION_CONFIRM_SWITCHTO_MAP || $confirmAction == self::ACTION_CONFIRM_ERASE_MAP)){
|
||||||
|
$confirmFrame = new Frame();
|
||||||
|
$maniaLink->add($confirmFrame);
|
||||||
|
$confirmFrame->setPosition($this->width / 2 + 6, $y);
|
||||||
|
|
||||||
|
$quad = new Quad();
|
||||||
|
$confirmFrame->add($quad);
|
||||||
|
$quad->setStyles($this->quadStyle, $this->quadSubstyle);
|
||||||
|
$quad->setSize(12, 4);
|
||||||
|
|
||||||
|
|
||||||
|
$quad = new Quad_BgsPlayerCard();
|
||||||
|
$confirmFrame->add($quad);
|
||||||
|
//$quad->setX(0);
|
||||||
|
//$quad->setY($y);
|
||||||
|
$quad->setSubStyle($quad::SUBSTYLE_BgCardSystem);
|
||||||
|
$quad->setSize(11,3.5);
|
||||||
|
|
||||||
|
$label = new Label_Button();
|
||||||
|
$confirmFrame->add($label);
|
||||||
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
|
$label->setText("Sure");
|
||||||
|
$label->setTextSize(1);
|
||||||
|
$label->setScale(0.90);
|
||||||
|
$label->setX(-1.3);
|
||||||
|
|
||||||
|
$buttLabel = new Label_Button();
|
||||||
|
$confirmFrame->add($buttLabel);
|
||||||
|
$buttLabel->setPosition(3.2,0.4,0.2);
|
||||||
|
$buttLabel->setSize(3, 3);
|
||||||
|
// $buttLabel->setTextSize(1);
|
||||||
|
$buttLabel->setAlign(Control::CENTER, Control::CENTER);
|
||||||
|
|
||||||
|
if($confirmAction == self::ACTION_CONFIRM_SWITCHTO_MAP){
|
||||||
|
$quad->setAction(self::ACTION_SWITCH_MAP . "." . ($id - 1));
|
||||||
|
$buttLabel->setText("»");
|
||||||
|
$buttLabel->setTextColor("0F0");
|
||||||
|
$buttLabel->setTextSize(2);
|
||||||
|
}else{
|
||||||
|
$buttLabel->setTextSize(1);
|
||||||
|
$buttLabel->setText("x");
|
||||||
|
$buttLabel->setTextColor("A00");
|
||||||
|
$quad->setAction(self::ACTION_ERASE_MAP . "." . ($id - 1) . "." . $map->uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
$id++;
|
$id++;
|
||||||
if($id == self::MAX_MAPS_PER_PAGE + 1)
|
if($id == self::MAX_MAPS_PER_PAGE + 1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TODO pages
|
//TODO pages
|
||||||
|
|
||||||
@ -427,6 +494,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the widget
|
* Closes the widget
|
||||||
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function closeWidget(array $callback) {
|
public function closeWidget(array $callback) {
|
||||||
@ -439,37 +507,45 @@ 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);
|
|
||||||
$eraseMap = (strpos($actionId, self::ACTION_ERASE_MAP) === 0);
|
|
||||||
$switchMap = (strpos($actionId, self::ACTION_SWITCH_MAP) === 0);
|
|
||||||
$queueMap = (strpos($actionId, self::ACTION_QUEUED_MAP) === 0);
|
|
||||||
|
|
||||||
if(!$addMap && !$eraseMap && !$switchMap && !$queueMap)
|
|
||||||
return;
|
|
||||||
|
|
||||||
$actionArray = explode(".", $actionId);
|
$actionArray = explode(".", $actionId);
|
||||||
|
if(count($actionArray) <= 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$action = $actionArray[0] . "." . $actionArray[1];
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1]);
|
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1]);
|
||||||
|
|
||||||
if($addMap){ //TODO log and chat message
|
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:
|
||||||
$this->maniaControl->mapManager->addMapFromMx(intval($actionArray[2]), $callback[1][1]); //TODO bestätigung
|
$this->maniaControl->mapManager->addMapFromMx(intval($actionArray[2]), $callback[1][1]); //TODO bestätigung
|
||||||
}else if($eraseMap){ //TODO log and chat message
|
break;
|
||||||
|
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]); //TODO bestätigung
|
||||||
$this->showMapList($player);
|
$this->showMapList($player);
|
||||||
}else if($switchMap){ //TODO log and chat message
|
break;
|
||||||
|
case self::ACTION_SWITCH_MAP:
|
||||||
$this->maniaControl->client->query('JumpToMapIndex', intval($actionArray[2])); //TODO bestätigung
|
$this->maniaControl->client->query('JumpToMapIndex', intval($actionArray[2])); //TODO bestätigung
|
||||||
$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 . '$>!'));
|
||||||
}else if($queueMap){
|
break;
|
||||||
|
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]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reopen the widget on Map Begin, MapListChanged
|
* Reopen the widget on Map Begin, MapListChanged
|
||||||
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function updateWidget(array $callback) {
|
public function updateWidget(array $callback) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user