1 /* 2 * Copyright (C) 2007-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_UI_FSMENU_CAMPAIGNS_H 21 #define WL_UI_FSMENU_CAMPAIGNS_H 22 23 #include <memory> 24 25 #include "graphic/image.h" 26 #include "wui/mapauthordata.h" 27 28 /** 29 * Data about a campaign or tutorial scenario that we're interested in. 30 */ 31 struct ScenarioData { 32 std::string path; 33 std::string descname; 34 std::string description; 35 MapAuthorData authors; 36 bool is_tutorial; 37 bool playable; 38 bool visible; 39 40 ScenarioData() = default; 41 }; 42 43 /** 44 * Data about a campaign that we're interested in. 45 */ 46 struct CampaignData { 47 std::string descname; 48 std::string tribename; 49 uint32_t difficulty_level; 50 const Image* difficulty_image; 51 std::string difficulty_description; 52 std::string description; 53 std::set<std::string> prerequisites; 54 bool visible; 55 std::vector<std::unique_ptr<ScenarioData>> scenarios; 56 std::vector<std::string> difficulties; 57 uint32_t default_difficulty; 58 59 CampaignData() = default; 60 }; 61 62 struct Campaigns { 63 Campaigns(); 64 no_of_campaignsCampaigns65 size_t no_of_campaigns() const { 66 return campaigns_.size(); 67 } 68 get_campaignCampaigns69 CampaignData* get_campaign(size_t campaign_index) const { 70 assert(campaign_index < campaigns_.size()); 71 return campaigns_.at(campaign_index).get(); 72 } 73 74 private: 75 void update_visibility_info(); 76 static void update_legacy_campvis(); 77 78 std::vector<std::unique_ptr<CampaignData>> campaigns_; 79 std::unordered_set<std::string> solved_scenarios_; 80 }; 81 82 #endif // end of include guard: WL_UI_FSMENU_CAMPAIGNS_H 83