1 /* 2 * Copyright (C) 2002-2020 by the Widelands Development Team 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 */ 19 20 #ifndef WL_WUI_MAPDATA_H 21 #define WL_WUI_MAPDATA_H 22 23 #include "base/i18n.h" 24 #include "io/filesystem/filesystem.h" 25 #include "logic/map.h" 26 #include "wui/mapauthordata.h" 27 28 /** 29 * Data about a map that we're interested in. 30 */ 31 struct MapData { 32 enum class MapType { kNormal, kDirectory, kScenario, kSettlers2 }; 33 34 enum class DisplayType { kFilenames, kMapnames, kMapnamesLocalized }; 35 36 private: 37 /// For common properties 38 MapData(const std::string& init_filename, 39 const std::string& init_localized_name, 40 const std::string& init_author, 41 const MapData::MapType& init_maptype, 42 const MapData::DisplayType& init_displaytype); 43 44 public: 45 /// For normal maps and scenarios 46 MapData(const Widelands::Map& map, 47 const std::string& init_filename, 48 const MapData::MapType& init_maptype, 49 const MapData::DisplayType& init_displaytype); 50 51 /// For directories 52 MapData(const std::string& init_filename, const std::string& init_localized_name); 53 54 /// The localized name of the parent directory 55 static std::string parent_name(); 56 57 /// Get the ".." directory 58 static MapData create_parent_dir(const std::string& current_dir); 59 60 /// To display if the directory is empty and has no parent 61 static MapData create_empty_dir(const std::string& current_dir); 62 63 /// Create a subdirectory 64 static MapData create_directory(const std::string& directory); 65 66 // Sorting functions to order by different categories. 67 bool compare_names(const MapData& other); 68 bool compare_players(const MapData& other); 69 bool compare_size(const MapData& other); 70 71 std::string filename; 72 std::string name; 73 std::string localized_name; 74 MapAuthorData authors; 75 std::string description; 76 std::string hint; 77 uint32_t nrplayers; 78 uint32_t width; 79 uint32_t height; 80 std::vector<Widelands::SuggestedTeamLineup> suggested_teams; 81 std::set<std::string> tags; 82 MapData::MapType maptype; 83 MapData::DisplayType displaytype; 84 }; 85 86 #endif // end of include guard: WL_WUI_MAPDATA_H 87