Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef MAP_LABEL_HPP_INCLUDED
00017 #define MAP_LABEL_HPP_INCLUDED
00018
00019 #include "map_location.hpp"
00020 #include "font.hpp"
00021 #include "tstring.hpp"
00022 #include "team.hpp"
00023
00024 class config;
00025 class display;
00026
00027 class terrain_label;
00028
00029
00030 class map_labels
00031 {
00032 public:
00033 typedef std::map<map_location, terrain_label *> label_map;
00034 typedef std::map<std::string,label_map> team_label_map;
00035
00036 map_labels(const map_labels&);
00037 map_labels(const display& disp, const team*);
00038 ~map_labels();
00039
00040 map_labels& operator=(const map_labels&);
00041
00042 void write(config& res) const;
00043 void read(const config &cfg);
00044
00045 const terrain_label* get_label(const map_location& loc, const std::string& team_name) const;
00046
00047 const terrain_label* get_label(const map_location& loc) const;
00048 const terrain_label* set_label(const map_location& loc,
00049 const t_string& text,
00050 const std::string& team = "",
00051 const SDL_Color color = font::NORMAL_COLOR,
00052 const bool visible_in_fog = true,
00053 const bool visible_in_shroud = false,
00054 const bool immutable = false);
00055
00056 void add_label(const map_location &, terrain_label *);
00057
00058 void clear(const std::string&, bool force);
00059
00060 void recalculate_labels();
00061 bool visible_global_label(const map_location&) const;
00062
00063 void recalculate_shroud();
00064
00065 const display& disp() const;
00066
00067 const std::string& team_name() const;
00068
00069 void set_team(const team*);
00070
00071 void clear_all();
00072
00073 private:
00074 void clear_map(label_map &, bool);
00075
00076 const display& disp_;
00077 const team* team_;
00078
00079 team_label_map labels_;
00080 };
00081
00082
00083
00084 class terrain_label
00085 {
00086 public:
00087 terrain_label(const t_string&,
00088 const std::string&,
00089 const map_location&,
00090 const map_labels&,
00091 const SDL_Color color = font::NORMAL_COLOR,
00092 const bool visible_in_fog = true,
00093 const bool visible_in_shroud = false,
00094 const bool immutable = false);
00095
00096 terrain_label(const map_labels &, const config &);
00097
00098 ~terrain_label();
00099
00100 void write(config& res) const;
00101 void read(const config &cfg);
00102
00103 const t_string& text() const;
00104 const std::string& team_name() const;
00105 bool visible_in_fog() const;
00106 bool visible_in_shroud() const;
00107 bool immutable() const;
00108 const map_location& location() const;
00109 const SDL_Color& color() const;
00110
00111 void set_text(const t_string&);
00112
00113 void update_info(const t_string&,
00114 const std::string&,
00115 const SDL_Color);
00116
00117 void recalculate();
00118 void calculate_shroud() const;
00119
00120 private:
00121 terrain_label(const terrain_label&);
00122 const terrain_label& operator=(const terrain_label&);
00123 void clear();
00124 void draw();
00125 bool visible() const;
00126 std::string cfg_color() const;
00127
00128 int handle_;
00129
00130 t_string text_;
00131 std::string team_name_;
00132 bool visible_in_fog_;
00133 bool visible_in_shroud_;
00134 bool immutable_;
00135
00136 SDL_Color color_;
00137
00138 const map_labels* parent_;
00139 map_location loc_;
00140
00141 };
00142
00143 #endif