time_of_day.hpp

Go to the documentation of this file.
00001 /* $Id: time_of_day.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
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 /** @file */
00017 
00018 #ifndef TIME_OF_DAY_HPP_INCLUDED
00019 #define TIME_OF_DAY_HPP_INCLUDED
00020 
00021 #include "global.hpp"
00022 
00023 #include "tstring.hpp"
00024 
00025 #include <vector>
00026 
00027 class config;
00028 
00029 /** Small struct to store and manipulate ToD colors */
00030 
00031 struct tod_color{
00032     tod_color(int red = 0, int green = 0, int blue = 0) : r(red), g(green), b(blue) {}
00033     bool operator==(const tod_color& o) const { return r == o.r && g == o.g && b == o.b; }
00034     bool is_zero() const { return r == 0 && g == 0 && b == 0; }
00035     bool operator!=(const tod_color& o) const { return !operator==(o); }
00036     tod_color operator+(const tod_color& o) const { return tod_color(r+o.r, g+o.g, b+o.b);}
00037     void operator*=(float x) { r *= x; g *= x; b *= x;}
00038 
00039     int r,g,b;
00040 };
00041 
00042 std::ostream &operator<<(std::ostream &s, const tod_color& tod);
00043 
00044 
00045 /**
00046  * Object which defines a time of day
00047  * with associated bonuses, image, sounds etc.
00048  */
00049 struct time_of_day
00050 {
00051     /**
00052      * A default-constructed time of day object shouldn't really be used
00053      * so this only loads some null values. Ideally, there should be
00054      * getters for properties that would emit a warning when such an object
00055      * is actually used, but it does not seem necessary at the moment.
00056      */
00057     explicit time_of_day();
00058 
00059     /** Construct a time of day from config */
00060     explicit time_of_day(const config& cfg);
00061 
00062     void write(config& cfg) const;
00063 
00064     /** The % bonus lawful units receive. Chaotics receive -lawful_bonus. */
00065     int lawful_bonus;
00066     int bonus_modified;
00067 
00068     /** The image to be displayed in the game status. */
00069     std::string image;
00070     t_string name;
00071     std::string id;
00072 
00073     /**
00074      * The image that is to be laid over all images
00075      * while this time of day lasts.
00076      */
00077     std::string image_mask;
00078 
00079     /**
00080      * The color modifications that should be made
00081      * to the game board to reflect the time of day.
00082      */
00083     tod_color color;
00084 
00085     /**
00086      * List of "ambient" sounds associated with this time_of_day,
00087      * Played at the beginning of turn.
00088      */
00089     std::string sounds;
00090 
00091     /**
00092      * Parse config and add time of day entries into passed vector
00093      */
00094     static void parse_times(const config& cfg, std::vector<time_of_day>& normal_times);
00095 };
00096 
00097 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:12 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs