The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
time_of_day.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://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 /** @file */
16 
17 #ifndef TIME_OF_DAY_HPP_INCLUDED
18 #define TIME_OF_DAY_HPP_INCLUDED
19 
20 #include "global.hpp"
21 
22 #include "tstring.hpp"
23 
24 #include <vector>
25 
26 class config;
27 
28 /** Small struct to store and manipulate ToD colors */
29 
30 struct tod_color{
31  explicit tod_color(int red = 0, int green = 0, int blue = 0) : r(red), g(green), b(blue) {}
32  bool operator==(const tod_color& o) const { return r == o.r && g == o.g && b == o.b; }
33  bool is_zero() const { return r == 0 && g == 0 && b == 0; }
34  bool operator!=(const tod_color& o) const { return !operator==(o); }
35  tod_color operator+(const tod_color& o) const { return tod_color(r+o.r, g+o.g, b+o.b);}
36  void operator*=(float x) { r *= x; g *= x; b *= x;}
37 
38  int r,g,b;
39 };
40 
41 std::ostream &operator<<(std::ostream &s, const tod_color& tod);
42 
43 
44 /**
45  * Object which defines a time of day
46  * with associated bonuses, image, sounds etc.
47  */
49 {
50  /**
51  * A default-constructed time of day object shouldn't really be used
52  * so this only loads some null values. Ideally, there should be
53  * getters for properties that would emit a warning when such an object
54  * is actually used, but it does not seem necessary at the moment.
55  */
56  time_of_day();
57 
58  /** Construct a time of day from config */
59  explicit time_of_day(const config& cfg);
60 
61  bool operator==(const time_of_day& o) const {
63  && image == o.image && name == o.name && id == o.id
64  && image_mask == o.image_mask && color == o.color && sounds == o.sounds;
65  }
66 
67  void write(config& cfg) const;
68 
69  /** The % bonus lawful units receive. Chaotics receive -lawful_bonus. */
72 
73  /** The image to be displayed in the game status. */
78 
79  /**
80  * The image that is to be laid over all images
81  * while this time of day lasts.
82  */
84 
85  /**
86  * The color modifications that should be made
87  * to the game board to reflect the time of day.
88  */
90 
91  /**
92  * List of "ambient" sounds associated with this time_of_day,
93  * Played at the beginning of turn.
94  */
96 
97  /**
98  * Parse config and add time of day entries into passed vector
99  */
100  static void parse_times(const config& cfg, std::vector<time_of_day>& normal_times);
101 };
102 
103 #endif
void operator*=(float x)
Definition: time_of_day.hpp:36
tod_color(int red=0, int green=0, int blue=0)
Definition: time_of_day.hpp:31
Small struct to store and manipulate ToD colors.
Definition: time_of_day.hpp:30
std::string image_mask
The image that is to be laid over all images while this time of day lasts.
Definition: time_of_day.hpp:83
tod_color color
The color modifications that should be made to the game board to reflect the time of day...
Definition: time_of_day.hpp:89
std::string sounds
List of "ambient" sounds associated with this time_of_day, Played at the beginning of turn...
Definition: time_of_day.hpp:95
std::string id
Definition: time_of_day.hpp:77
tod_color operator+(const tod_color &o) const
Definition: time_of_day.hpp:35
int lawful_bonus
The % bonus lawful units receive.
Definition: time_of_day.hpp:70
std::string image
The image to be displayed in the game status.
Definition: time_of_day.hpp:74
GLboolean GLboolean g
Definition: glew.h:7319
std::ostream & operator<<(std::ostream &s, const tod_color &tod)
Definition: time_of_day.cpp:23
bool operator!=(const tod_color &o) const
Definition: time_of_day.hpp:34
bool operator==(const time_of_day &o) const
Definition: time_of_day.hpp:61
GLdouble GLdouble GLdouble b
Definition: glew.h:6966
t_string name
Definition: time_of_day.hpp:75
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:48
GLclampf GLclampf blue
Definition: glew.h:1488
GLclampf green
Definition: glew.h:1488
t_string description
Definition: time_of_day.hpp:76
GLuint color
Definition: glew.h:5801
bool is_zero() const
Definition: time_of_day.hpp:33
time_of_day()
A default-constructed time of day object shouldn't really be used so this only loads some null values...
Definition: time_of_day.cpp:41
GLint GLint GLint GLint GLint x
Definition: glew.h:1220
static void parse_times(const config &cfg, std::vector< time_of_day > &normal_times)
Parse config and add time of day entries into passed vector.
Definition: time_of_day.cpp:68
bool operator==(const tod_color &o) const
Definition: time_of_day.hpp:32
GLdouble GLdouble GLdouble r
Definition: glew.h:1374
GLuint const GLchar * name
Definition: glew.h:1782
this module manages the cache of images.
Definition: image.cpp:75
void write(config &cfg) const
Definition: time_of_day.cpp:54
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLdouble s
Definition: glew.h:1358
int bonus_modified
Definition: time_of_day.hpp:71
GLsizei const GLcharARB ** string
Definition: glew.h:4503