Jocy 2017-05-07 20:46:12 +02:00
parent fd743a08d9
commit f0adaed999
2 changed files with 34 additions and 3 deletions

View File

@ -12,6 +12,7 @@ use FML\Controls\Quads\Quad_BgRaceScore2;
use FML\Controls\Quads\Quad_Bgs1InRace; use FML\Controls\Quads\Quad_Bgs1InRace;
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\Controls\Quads\Quad_UIConstruction_Buttons;
use FML\Script\Features\Paging; use FML\Script\Features\Paging;
use FML\Script\Script; use FML\Script\Script;
use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationAble;
@ -128,7 +129,7 @@ class StyleManager implements UsageInformationAble {
* @param string $actionAuthorSearch * @param string $actionAuthorSearch
* @return \FML\Controls\Frame * @return \FML\Controls\Frame
*/ */
public function getDefaultMapSearch($actionMapNameSearch, $actionAuthorSearch){ public function getDefaultMapSearch($actionMapNameSearch, $actionAuthorSearch, $actionReset = null) {
$width = $this->getListWidgetsWidth(); $width = $this->getListWidgetsWidth();
$frame = new Frame(); $frame = new Frame();
@ -149,6 +150,17 @@ class StyleManager implements UsageInformationAble {
$entry->setSize($width * 0.25, 4); $entry->setSize($width * 0.25, 4);
$entry->setName('SearchString'); $entry->setName('SearchString');
if ($actionReset) {
$quad = new Quad_Icons64x64_1();;
$frame->addChild($quad);
$quad->setSubStyle($quad::SUBSTYLE_QuitRace);
$quad->setColorize('aaa');
$quad->setSize(5, 5);
$quad->setPosition(-$width / 2 + 15 + $width * 0.25 - 2, 0);
$quad->setZ(1);
$quad->setAction($actionReset);
}
//Search for Map-Name //Search for Map-Name
$label = new Label_Button(); $label = new Label_Button();
$frame->addChild($label); $frame->addChild($label);

View File

@ -54,6 +54,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
const ACTION_PAGING_CHUNKS = 'MapList.PagingChunk.'; const ACTION_PAGING_CHUNKS = 'MapList.PagingChunk.';
const ACTION_SEARCH_MAP_NAME = 'MapList.SearchMapName'; const ACTION_SEARCH_MAP_NAME = 'MapList.SearchMapName';
const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor'; const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor';
const ACTION_RESET = 'MapList.ResetMapList';
const MAX_MAPS_PER_PAGE = 13; const MAX_MAPS_PER_PAGE = 13;
const MAX_PAGES_PER_CHUNK = 2; const MAX_PAGES_PER_CHUNK = 2;
const DEFAULT_KARMA_PLUGIN = 'MCTeam\KarmaPlugin'; const DEFAULT_KARMA_PLUGIN = 'MCTeam\KarmaPlugin';
@ -88,6 +89,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_CLEAR_MAPQUEUE, $this, 'clearMapQueue'); $this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_CLEAR_MAPQUEUE, $this, 'clearMapQueue');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAP_NAME, $this, 'searchByMapName'); $this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAP_NAME, $this, 'searchByMapName');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'searchByAuthor'); $this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'searchByAuthor');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_RESET, $this, 'resetMapList');
} }
@ -239,7 +241,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$labelLine->setY(-7); $labelLine->setY(-7);
$labelLine->render(); $labelLine->render();
$searchFrame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMapSearch(self::ACTION_SEARCH_MAP_NAME, self::ACTION_SEARCH_AUTHOR); $searchFrame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMapSearch(self::ACTION_SEARCH_MAP_NAME, self::ACTION_SEARCH_AUTHOR, self::ACTION_RESET);
$headFrame->addChild($searchFrame); $headFrame->addChild($searchFrame);
// Predefine description Label // Predefine description Label
@ -732,6 +734,18 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
} }
} }
/**
* Resets the Maplist to the original view, clears previous search results
*
* @param array $callback
* @internal
*/
public function resetMapList(array $callback) {
$login = $callback[1][1];
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
$this->showMapList($player);
}
/** /**
* Listener for search button * Listener for search button
* *
@ -743,9 +757,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$player = $this->maniaControl->getPlayerManager()->getPlayer($login); $player = $this->maniaControl->getPlayerManager()->getPlayer($login);
$searchString = $callback[1][3][0]['Value']; $searchString = $callback[1][3][0]['Value'];
$maps = $this->maniaControl->getMapManager()->searchMapsByMapName($searchString);
if ($searchString) {
$maps = $this->maniaControl->getMapManager()->searchMapsByMapName($searchString);
} else {
$maps = null;
}
$this->showMapList($player, $maps); $this->showMapList($player, $maps);
} }
/** /**