Added search feature to map list

Enhanced mx list x values
Added setY to LabelLine
Renamed setPosZ to setZ (same as in FML)
This commit is contained in:
Jocy
2017-04-12 17:56:43 +02:00
parent 1ac702f29e
commit 09b974e2cc
6 changed files with 188 additions and 74 deletions

View File

@ -56,6 +56,9 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
const SETTING_MAPLIST_FILE = 'File to write Maplist in';
const SETTING_WRITE_OWN_MAPLIST_FILE = 'Write a own Maplist File for every Server called serverlogin.txt';
const SEARCH_BY_AUTHOR = 'Author';
const SEARCH_BY_MAP_NAME = 'Mapname';
/*
* Private properties
@ -977,25 +980,57 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
});
}
/**
* Search maps by a given String for Author and Name
* Searches the current map list for an author
*
* @param $searchString
* @return array
*/
public function searchMaps($searchString) {
public function searchMapsByAuthor($searchString){
return $this->searchMaps($searchString,self::SEARCH_BY_AUTHOR);
}
/**
* Searches the current map list for a map name
*
* @param $searchString
* @return array
*/
public function searchMapsByMapName($searchString){
return $this->searchMaps($searchString,self::SEARCH_BY_MAP_NAME);
}
/**
* Searches the current map list
*
* @param $searchString
* @param string $searchBy
* @return array
*/
private function searchMaps($searchString, $searchBy = self::SEARCH_BY_MAP_NAME) {
$result = array();
$searchString = strtolower($searchString);
foreach ($this->maps as $map) {
if (strpos($map->name, $searchString) || strpos($map->authorLogin, $searchString)) {
;
}
{
array_push($result, $map);
switch ($searchBy) {
case self::SEARCH_BY_MAP_NAME:
$mapName = strtolower(Formatter::stripCodes($map->name));
if (strpos($mapName, $searchString) !== false) {
array_push($result, $map);
}
break;
case self::SEARCH_BY_AUTHOR:
if (strpos(strtolower($map->authorLogin), $searchString) !== false) {
array_push($result, $map);
}
}
}
return $result;
}
/**
* Initialize necessary database tables
*