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