Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef EDITOR_EDITOR_MAP_HPP_INCLUDED
00017 #define EDITOR_EDITOR_MAP_HPP_INCLUDED
00018
00019 #include "../editor_common.hpp"
00020
00021 #include "../../map.hpp"
00022 #include "../../map_label.hpp"
00023 #include "unit_map.hpp"
00024 #include "tod_manager.hpp"
00025 #include "gamestatus.hpp"
00026
00027 #include <deque>
00028
00029 namespace editor {
00030
00031 struct editor_map_operation_exception : public editor_exception
00032 {
00033 editor_map_operation_exception()
00034 : editor_exception("Map operation error. Check debug log for details.")
00035 {
00036 }
00037 };
00038
00039 struct editor_map_integrity_error : public editor_exception
00040 {
00041 editor_map_integrity_error()
00042 : editor_exception("Map integrity error. Check debug log for details.")
00043 {
00044 }
00045 };
00046
00047 struct editor_map_load_exception : public editor_exception
00048 {
00049 editor_map_load_exception(const std::string& fn, const std::string& msg)
00050 : editor_exception(msg), filename(fn)
00051 {
00052 }
00053 ~editor_map_load_exception() throw() {}
00054 std::string filename;
00055 };
00056
00057 struct editor_map_save_exception : public editor_exception
00058 {
00059 editor_map_save_exception(const std::string& msg)
00060 : editor_exception(msg)
00061 {
00062 }
00063 ~editor_map_save_exception() throw() {}
00064 };
00065
00066
00067
00068
00069
00070 editor_map_load_exception wrap_exc(const char* type, const std::string& e_msg, const std::string& filename);
00071
00072
00073
00074
00075 class editor_map : public gamemap
00076 {
00077 public:
00078
00079
00080 std::vector<team>& get_teams() {
00081 return teams_;
00082 }
00083
00084
00085 unit_map& get_units() {
00086 return units_;
00087 }
00088
00089 const unit_map& get_units() const {
00090 return units_;
00091 }
00092
00093 tod_manager& get_time_manager() {
00094 return tod_manager_;
00095 }
00096
00097 game_state& get_game_state() {
00098 return state_;
00099 }
00100
00101
00102
00103
00104
00105 explicit editor_map(const config& terrain_cfg, const display& disp);
00106
00107
00108
00109
00110 editor_map(const config& terrain_cfg, const config& level, const display& disp);
00111
00112 editor_map(const config& terrain_cfg, const std::string& data, const display& disp);
00113
00114
00115
00116
00117
00118 static editor_map from_string(const config& terrain_cfg, const std::string& data, const display& disp);
00119
00120
00121
00122
00123 editor_map(const config& terrain_cfg, size_t width, size_t height, t_translation::t_terrain filler, const display& disp);
00124
00125
00126
00127
00128
00129 explicit editor_map(const gamemap& map, const display& disp);
00130
00131
00132
00133
00134 ~editor_map();
00135
00136
00137
00138
00139 void sanity_check();
00140
00141
00142
00143
00144
00145
00146 std::set<map_location> get_contiguous_terrain_tiles(const map_location& start) const;
00147
00148
00149
00150
00151 map_labels& get_map_labels() { return labels_; };
00152
00153
00154 const map_labels& get_map_labels() const { return labels_; };
00155
00156
00157
00158
00159
00160 std::set<map_location> set_starting_position_labels(display& disp);
00161
00162
00163
00164
00165 bool in_selection(const map_location& loc) const;
00166
00167
00168
00169
00170
00171 bool add_to_selection(const map_location& loc);
00172
00173
00174
00175
00176
00177 bool remove_from_selection(const map_location& loc);
00178
00179
00180
00181
00182 const std::set<map_location>& selection() const { return selection_; }
00183
00184
00185
00186
00187 void clear_selection();
00188
00189
00190
00191
00192 void invert_selection();
00193
00194
00195
00196
00197 void select_all();
00198
00199
00200
00201
00202 bool everything_selected() const;
00203
00204
00205
00206
00207
00208 void resize(int width, int height, int x_offset, int y_offset,
00209 t_translation::t_terrain filler = t_translation::NONE_TERRAIN);
00210
00211
00212
00213
00214
00215 editor_map mask_to(const editor_map& target) const;
00216
00217
00218
00219
00220
00221 bool same_size_as(const gamemap& other) const;
00222
00223 void write(config&) const;
00224
00225 protected:
00226 t_translation::t_list clone_column(int x, t_translation::t_terrain filler);
00227
00228
00229 void expand_right(int count, t_translation::t_terrain filler);
00230 void expand_left(int count, t_translation::t_terrain filler);
00231 void expand_top(int count, t_translation::t_terrain filler);
00232 void expand_bottom(int count, t_translation::t_terrain filler);
00233 void shrink_right(int count);
00234 void shrink_left(int count);
00235 void shrink_top(int count);
00236 void shrink_bottom(int count);
00237
00238
00239
00240
00241 std::set<map_location> selection_;
00242
00243 private:
00244
00245
00246
00247
00248 map_labels labels_;
00249
00250
00251
00252
00253 unit_map units_;
00254
00255 std::vector<team> teams_;
00256
00257 tod_manager tod_manager_;
00258
00259 game_state state_;
00260
00261 };
00262
00263
00264 }
00265
00266 #endif