1 /* 2 Copyright (C) 2008 - 2018 by Mark de Wever <koraq@xs4all.nl> 3 Part of the Battle for Wesnoth Project https://www.wesnoth.org/ 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY. 11 12 See the COPYING file for more details. 13 */ 14 15 #include "linked_group_definition.hpp" 16 17 #include "formula/string_utils.hpp" 18 #include "wml_exception.hpp" 19 20 namespace gui2 21 { 22 parse_linked_group_definitions(const config & cfg)23std::vector<linked_group_definition> parse_linked_group_definitions(const config& cfg) 24 { 25 std::vector<linked_group_definition> definitions; 26 27 for(const auto& lg : cfg.child_range("linked_group")) { 28 definitions.emplace_back(); 29 linked_group_definition& linked_group = definitions.back(); 30 31 linked_group.id = lg["id"].str(); 32 linked_group.fixed_width = lg["fixed_width"].to_bool(); 33 linked_group.fixed_height = lg["fixed_height"].to_bool(); 34 35 VALIDATE(!linked_group.id.empty(), missing_mandatory_wml_key("linked_group", "id")); 36 37 if(!linked_group.fixed_width && !linked_group.fixed_height) { 38 const t_string msg = VGETTEXT( 39 "Linked group '$id' needs a 'fixed_width' or 'fixed_height' key.", {{"id", linked_group.id}}); 40 41 FAIL(msg); 42 } 43 } 44 45 return definitions; 46 } 47 48 } 49