1 /* 2 * Copyright (C) 2005-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_LOGIC_MAP_OBJECTS_TRIBES_WORKAREA_INFO_H 21 #define WL_LOGIC_MAP_OBJECTS_TRIBES_WORKAREA_INFO_H 22 23 #include <map> 24 #include <string> 25 26 /** The WorkareaInfo stores radii and for each radius a set of strings. 27 * 28 * A Workarea is a "circle" around a building that this building affects 29 * or is needed by this buildingr., e.g. Areas for Mines, Fields of a Farm. 30 * Worareas are shown on the Map when clicking on or placing a building. 31 * 32 * Each string contains a description of an activity (or similar) 33 * that can be performed within the radius. Examples are buldings 34 * that can be upgraded like a Fortress, and will have a bigger 35 * workarea then. 36 * 37 * See LuaBuildingDescription::get_workarea_radius, InteractiveBase::show_workarea 38 */ 39 40 // TODO(Hasi50): We could just use a unit8 as base for the map? We should 41 // document (as const) the expected stings. 42 43 using WorkareaInfo = std::map<uint32_t, std::set<std::string>>; 44 45 // Visualization-related structs 46 struct WorkareaPreviewData { WorkareaPreviewDataWorkareaPreviewData47 WorkareaPreviewData(Widelands::TCoords<> c, uint8_t i) 48 : coords(c), index(i), use_special_coloring(false), special_coloring(0) { 49 } WorkareaPreviewDataWorkareaPreviewData50 WorkareaPreviewData(Widelands::TCoords<> c, uint8_t i, uint32_t col) 51 : coords(c), index(i), use_special_coloring(true), special_coloring(col) { 52 } WorkareaPreviewDataWorkareaPreviewData53 WorkareaPreviewData() 54 : coords(Widelands::TCoords<>(Widelands::Coords::null(), Widelands::TriangleIndex::D)), 55 index(0), 56 use_special_coloring(false), 57 special_coloring(0) { 58 } 59 WorkareaPreviewData(const WorkareaPreviewData& other) = default; 60 WorkareaPreviewData& operator=(const WorkareaPreviewData&) = default; 61 62 bool operator==(const WorkareaPreviewData& d) const { 63 return index == d.index && coords == d.coords && 64 use_special_coloring == d.use_special_coloring && 65 (!use_special_coloring || special_coloring == d.special_coloring); 66 } 67 68 // The triangle this data is applied to 69 Widelands::TCoords<> coords; 70 // The underlying workarea color 71 uint8_t index; 72 // If a "special coloring" is specified, its RGB will be overlayed over the base color as 73 // strongly as if it had full alpha, and the final transparency of the entire triangle will be 74 // set to this color's alpha 75 bool use_special_coloring; 76 uint32_t special_coloring; 77 }; 78 // Pair of interior information and a per-circle list of border coords 79 using WorkareasEntry = 80 std::pair<std::vector<WorkareaPreviewData>, std::vector<std::vector<Widelands::Coords>>>; 81 using Workareas = std::vector<WorkareasEntry>; 82 83 #endif // end of include guard: WL_LOGIC_MAP_OBJECTS_TRIBES_WORKAREA_INFO_H 84