00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef GAME_DISPLAY_H_INCLUDED
00019 #define GAME_DISPLAY_H_INCLUDED
00020
00021 class config;
00022 class tod_manager;
00023 class team;
00024 class unit;
00025 class unit_map;
00026
00027 #include "animated.hpp"
00028 #include "chat_events.hpp"
00029 #include "display.hpp"
00030 #include "pathfind/pathfind.hpp"
00031
00032 #include <deque>
00033
00034
00035
00036
00037
00038 class game_display : public display
00039 {
00040 public:
00041 game_display(unit_map& units, CVideo& video,
00042 const gamemap& map, const tod_manager& tod_manager,
00043 const std::vector<team>& t, const config& theme_cfg,
00044 const config& level);
00045
00046 static game_display* create_dummy_display(CVideo& video);
00047
00048 ~game_display();
00049 static game_display* get_singleton()
00050 {
00051 return static_cast<game_display*>(singleton_);
00052 }
00053
00054
00055
00056
00057
00058
00059 void new_turn();
00060
00061
00062
00063
00064
00065
00066 void scroll_to_leader(unit_map& units, int side, SCROLL_TYPE scroll_type = ONSCREEN,bool force = true);
00067
00068
00069
00070
00071
00072
00073
00074 virtual void select_hex(map_location hex);
00075
00076
00077
00078
00079
00080
00081
00082
00083 virtual void highlight_hex(map_location hex);
00084
00085
00086
00087
00088
00089
00090 void display_unit_hex(map_location hex);
00091
00092
00093
00094
00095
00096
00097 void highlight_reach(const pathfind::paths &paths_list);
00098
00099
00100
00101
00102
00103 void highlight_another_reach(const pathfind::paths &paths_list);
00104
00105
00106 void unhighlight_reach();
00107
00108
00109
00110
00111
00112
00113 void set_route(const pathfind::marked_route *route);
00114
00115
00116 void float_label(const map_location& loc, const std::string& text,
00117 int red, int green, int blue);
00118
00119
00120
00121
00122
00123 std::vector<surface> footsteps_images(const map_location& loc);
00124
00125
00126 void draw_movement_info(const map_location& loc);
00127
00128 void draw_report(const std::string &report_name);
00129
00130
00131 void invalidate_unit() { invalidateGameStatus_ = true; }
00132
00133
00134 void invalidate_unit_after_move(const map_location& src, const map_location& dst);
00135
00136 const time_of_day& get_time_of_day(const map_location& loc) const;
00137
00138 bool has_time_area() const;
00139
00140 protected:
00141
00142
00143
00144
00145 void pre_draw();
00146
00147
00148
00149 void post_draw();
00150
00151 void draw_invalidated();
00152
00153 void post_commit();
00154
00155 void draw_hex(const map_location& loc);
00156
00157
00158
00159
00160 void invalidate_animations();
00161
00162
00163
00164
00165 void invalidate_animations_location(const map_location& loc);
00166
00167
00168 public:
00169
00170
00171
00172
00173
00174
00175
00176
00177 class fake_unit : public unit {
00178 public:
00179 explicit fake_unit(unit const & u);
00180 fake_unit(fake_unit const & u);
00181 fake_unit & operator=(fake_unit const & u);
00182
00183 fake_unit & operator=(unit const & u);
00184
00185
00186 ~fake_unit();
00187
00188
00189
00190
00191 void place_on_game_display(game_display * d);
00192
00193
00194
00195 int remove_from_game_display();
00196 private :
00197 game_display * my_display_;
00198 };
00199
00200
00201 friend class game_display::fake_unit;
00202
00203 private:
00204
00205
00206
00207
00208
00209 void place_temporary_unit(unit *u);
00210
00211
00212
00213
00214 int remove_temporary_unit(unit *u);
00215 public:
00216
00217
00218
00219
00220 void set_attack_indicator(const map_location& src, const map_location& dst);
00221 void clear_attack_indicator();
00222
00223
00224 std::string attack_indicator_direction() const {
00225 return map_location::write_direction(
00226 attack_indicator_src_.get_relative_dir(attack_indicator_dst_));
00227 }
00228
00229
00230
00231
00232
00233
00234
00235 void add_overlay(const map_location& loc, const std::string& image,
00236 const std::string& halo="", const std::string& team_name="",
00237 bool visible_under_fog = true);
00238
00239
00240 void remove_overlay(const map_location& loc);
00241
00242
00243 void remove_single_overlay(const map_location& loc, const std::string& toDelete);
00244
00245
00246
00247
00248
00249 void parse_team_overlays();
00250
00251
00252
00253
00254 t_translation::t_terrain get_terrain_on(int palx, int paly, int x, int y);
00255
00256 void send_notification(const std::string& owner, const std::string& message);
00257
00258
00259
00260
00261
00262
00263
00264 void set_team(size_t team, bool observe=false);
00265 void set_playing_team(size_t team);
00266
00267
00268 const map_location &displayed_unit_hex() const { return displayedUnitHex_; }
00269
00270
00271
00272
00273
00274 static int& debug_highlight(const map_location& loc);
00275 static void clear_debug_highlights() { debugHighlights_.clear(); }
00276
00277
00278
00279 int playing_side() const { return activeTeam_ + 1; }
00280
00281
00282 std::string current_team_name() const;
00283
00284 void add_observer(const std::string& name) { observers_.insert(name); }
00285 void remove_observer(const std::string& name) { observers_.erase(name); }
00286 const std::set<std::string>& observers() const { return observers_; }
00287
00288 void add_chat_message(const time_t& time, const std::string& speaker,
00289 int side, const std::string& msg, events::chat_handler::MESSAGE_TYPE type, bool bell);
00290 void clear_chat_messages() { prune_chat_messages(true); }
00291
00292 void begin_game();
00293
00294 virtual bool in_game() const { return in_game_; }
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 enum tgame_mode {
00307 RUNNING,
00308 LINGER_SP,
00309 LINGER_MP };
00310
00311 void set_game_mode(const tgame_mode game_mode);
00312
00313 private:
00314 game_display(const game_display&);
00315 void operator=(const game_display&);
00316
00317 void draw_sidebar();
00318
00319
00320 surface get_flag(const map_location& loc);
00321
00322
00323 std::deque<unit*> fake_units_;
00324
00325
00326 map_location attack_indicator_src_;
00327 map_location attack_indicator_dst_;
00328
00329
00330
00331 pathfind::marked_route route_;
00332
00333 const tod_manager& tod_manager_;
00334
00335 const config& level_;
00336
00337 void invalidate_route();
00338
00339 map_location displayedUnitHex_;
00340
00341 struct overlay {
00342 overlay(const std::string& img, const std::string& halo_img,
00343 int handle, const std::string& overlay_team_name, const bool fogged) : image(img), halo(halo_img),
00344 team_name(overlay_team_name), halo_handle(handle) , visible_in_fog(fogged){}
00345 std::string image;
00346 std::string halo;
00347 std::string team_name;
00348 int halo_handle;
00349 bool visible_in_fog;
00350 };
00351
00352 typedef std::multimap<map_location,overlay> overlay_map;
00353
00354 overlay_map overlays_;
00355
00356
00357
00358 double sidebarScaling_;
00359
00360 bool first_turn_, in_game_;
00361
00362 std::set<std::string> observers_;
00363
00364 struct chat_message
00365 {
00366 chat_message(int speaker, int h) : speaker_handle(speaker), handle(h), created_at(SDL_GetTicks())
00367 {}
00368
00369 int speaker_handle;
00370 int handle;
00371 Uint32 created_at;
00372 };
00373
00374 void prune_chat_messages(bool remove_all=false);
00375
00376 std::vector<chat_message> chat_messages_;
00377
00378
00379 typedef std::map<map_location,unsigned int> reach_map;
00380 reach_map reach_map_;
00381 reach_map reach_map_old_;
00382 bool reach_map_changed_;
00383 void process_reachmap_changes();
00384
00385 tgame_mode game_mode_;
00386
00387
00388 static std::map<map_location, int> debugHighlights_;
00389
00390
00391 std::vector<animated<image::locator> > flags_;
00392
00393
00394 };
00395
00396 #endif