00001 /* $Id: portrait.cpp 53324 2012-02-29 09:11:28Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2008 - 2012 by mark de wever <koraq@xs4all.nl> 00004 Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY. 00012 00013 See the COPYING file for more details. 00014 */ 00015 00016 #include "portrait.hpp" 00017 00018 #include "config.hpp" 00019 #include "log.hpp" 00020 #include "util.hpp" 00021 #include "wml_exception.hpp" 00022 00023 static lg::log_domain log_config("config"); 00024 #define WRN_CF LOG_STREAM(warn, log_config) 00025 00026 static tportrait::tside get_side(const std::string& side) 00027 { 00028 if(side == "both") { 00029 return tportrait::BOTH; 00030 } else if(side == "right") { 00031 return tportrait::RIGHT; 00032 } else if(side == "left") { 00033 return tportrait::LEFT; 00034 } else { 00035 WRN_CF << "Unknown portrait side '" << side << "' defaulting to left.\n"; 00036 return tportrait::LEFT; 00037 } 00038 } 00039 00040 tportrait::tportrait(const config& cfg) : 00041 image(cfg["image"]), 00042 side(get_side(cfg["side"])), 00043 size(lexical_cast_default<unsigned>(cfg["size"])), 00044 mirror(cfg["mirror"].to_bool()) 00045 { 00046 VALIDATE(!image.empty(), missing_mandatory_wml_key("portrait", "image")); 00047 VALIDATE(size != 0, missing_mandatory_wml_key("portrait", "size")); 00048 } 00049
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:08 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |