00001
00002
00003
00004
00005
00006
00007 #ifdef USE_TILE
00008 #ifndef TILESDL_H
00009 #define TILESDL_H
00010
00011 #include "externs.h"
00012 #include "tilereg.h"
00013 #include "tiletex.h"
00014
00015 class Region;
00016 class CRTRegion;
00017 class CRTRegionSingleSelect;
00018 class MenuRegion;
00019 class TileRegion;
00020 class DungeonRegion;
00021 class GridRegion;
00022 class InventoryRegion;
00023 class SpellRegion;
00024 class MemoriseRegion;
00025 class ActorRegion;
00026 class MonsterRegion;
00027 class SkillRegion;
00028 class CommandRegion;
00029 class ActorRegion;
00030 class TabbedRegion;
00031 class MapRegion;
00032 class ControlRegion;
00033 class TitleRegion;
00034 class DollEditRegion;
00035 class StatRegion;
00036 class MessageRegion;
00037
00038 struct map_cell;
00039
00040 typedef std::map<int, TabbedRegion*>::iterator tab_iterator;
00041
00042 enum key_mod
00043 {
00044 MOD_NONE = 0x0,
00045 MOD_SHIFT = 0x1,
00046 MOD_CTRL = 0x2,
00047 MOD_ALT = 0x4,
00048 };
00049
00050 struct MouseEvent
00051 {
00052 enum mouse_event_type
00053 {
00054 PRESS,
00055 RELEASE,
00056 MOVE,
00057 };
00058
00059 enum mouse_event_button
00060 {
00061 NONE = 0x00,
00062 LEFT = 0x01,
00063 MIDDLE = 0x02,
00064 RIGHT = 0x04,
00065 SCROLL_UP = 0x08,
00066 SCROLL_DOWN = 0x10,
00067 };
00068
00069
00070 unsigned char type;
00071
00072
00073 mouse_event_type event;
00074
00075 mouse_event_button button;
00076
00077 unsigned short held;
00078
00079 unsigned char mod;
00080
00081 unsigned int px;
00082 unsigned int py;
00083 };
00084
00085 class FontWrapper;
00086 class crawl_view_buffer;
00087
00088 class TilesFramework
00089 {
00090 public:
00091 TilesFramework();
00092 virtual ~TilesFramework();
00093
00094 bool initialise();
00095 void shutdown();
00096 void load_dungeon(const crawl_view_buffer &vbuf, const coord_def &gc);
00097 void load_dungeon(const coord_def &gc);
00098 int getch_ck();
00099 void resize();
00100 void layout_statcol();
00101 void calculate_default_options();
00102 void clrscr();
00103
00104 void cgotoxy(int x, int y, GotoRegion region = GOTO_CRT);
00105 GotoRegion get_cursor_region() const;
00106 int get_number_of_lines();
00107 int get_number_of_cols();
00108
00109 void update_minimap(const coord_def &gc);
00110 void clear_minimap();
00111 void update_minimap_bounds();
00112 void toggle_inventory_display();
00113 void update_tabs();
00114
00115 void set_need_redraw(unsigned int min_tick_delay = 0);
00116 bool need_redraw() const;
00117 void redraw();
00118
00119 void place_cursor(cursor_type type, const coord_def &gc);
00120 void clear_text_tags(text_tag_type type);
00121 void add_text_tag(text_tag_type type, const std::string &tag,
00122 const coord_def &gc);
00123 void add_text_tag(text_tag_type type, const monster* mon);
00124
00125 bool initialise_items();
00126
00127 const coord_def &get_cursor() const;
00128
00129 void add_overlay(const coord_def &gc, tileidx_t idx);
00130 void clear_overlays();
00131
00132 void draw_title();
00133 void update_title_msg(std::string load_msg);
00134 void hide_title();
00135
00136 void draw_doll_edit();
00137
00138 MenuRegion *get_menu() { return m_region_menu; }
00139 bool is_fullscreen() { return m_fullscreen; }
00140
00141 FontWrapper* get_crt_font() { return m_fonts.at(m_crt_font).font; }
00142 CRTRegion* get_crt() { return m_region_crt; }
00143 const ImageManager* get_image_manager() { return m_image; }
00144 int to_lines(int num_tiles);
00145 protected:
00146 int load_font(const char *font_file, int font_size,
00147 bool default_on_fail, bool outline);
00148 int handle_mouse(MouseEvent &event);
00149
00150 void use_control_region(ControlRegion *region);
00151
00152
00153 coord_def m_windowsz;
00154
00155 coord_def m_viewsc;
00156
00157 bool m_fullscreen;
00158 bool m_need_redraw;
00159
00160 enum TabID
00161 {
00162 TAB_ITEM,
00163 TAB_SPELL,
00164 TAB_MEMORISE,
00165 TAB_MONSTER,
00166 TAB_SKILL,
00167 TAB_COMMAND,
00168 TAB_MAX,
00169 };
00170
00171 enum LayerID
00172 {
00173 LAYER_NORMAL,
00174 LAYER_CRT,
00175 LAYER_TILE_CONTROL,
00176 LAYER_MAX,
00177 };
00178
00179 class Layer
00180 {
00181 public:
00182
00183 std::vector<Region*> m_regions;
00184 };
00185 Layer m_layers[LAYER_MAX];
00186 LayerID m_active_layer;
00187
00188
00189 TileRegionInit m_init;
00190 DungeonRegion *m_region_tile;
00191 StatRegion *m_region_stat;
00192 MessageRegion *m_region_msg;
00193 MapRegion *m_region_map;
00194 TabbedRegion *m_region_tab;
00195 InventoryRegion *m_region_inv;
00196 SpellRegion *m_region_spl;
00197 MemoriseRegion *m_region_mem;
00198 MonsterRegion *m_region_mon;
00199 SkillRegion *m_region_skl;
00200 CommandRegion *m_region_cmd;
00201
00202 std::map<int, TabbedRegion*> m_tabs;
00203
00204
00205 CRTRegion *m_region_crt;
00206 MenuRegion *m_region_menu;
00207
00208 struct font_info
00209 {
00210 std::string name;
00211 int size;
00212 bool outline;
00213 FontWrapper *font;
00214 };
00215 std::vector<font_info> m_fonts;
00216 int m_crt_font;
00217 int m_msg_font;
00218 int m_tip_font;
00219 int m_lbl_font;
00220
00221 int m_tab_margin;
00222 int m_stat_col;
00223 int m_stat_x_divider;
00224 int m_statcol_top;
00225 int m_statcol_bottom;
00226 int m_map_pixels;
00227
00228 void do_layout();
00229 int calc_tab_lines(const int num_elements);
00230 void place_tab(int idx);
00231 void autosize_minimap();
00232 void place_minimap();
00233 void resize_inventory();
00234 void place_gold_turns();
00235
00236 ImageManager *m_image;
00237
00238
00239 unsigned short m_buttons_held;
00240 unsigned char m_key_mod;
00241 coord_def m_mouse;
00242 unsigned int m_last_tick_moved;
00243 unsigned int m_last_tick_redraw;
00244
00245 std::string m_tooltip;
00246
00247 int m_screen_width;
00248 int m_screen_height;
00249
00250 struct cursor_loc
00251 {
00252 cursor_loc() { reset(); }
00253 void reset() { reg = NULL; cx = cy = -1; mode = MOUSE_MODE_MAX; }
00254 bool operator==(const cursor_loc &rhs) const
00255 {
00256 return (rhs.reg == reg
00257 && rhs.cx == cx
00258 && rhs.cy == cy
00259 && rhs.mode == mode);
00260 }
00261 bool operator!=(const cursor_loc &rhs) const
00262 {
00263 return !(*this == rhs);
00264 }
00265
00266 Region *reg;
00267 int cx, cy;
00268 mouse_mode mode;
00269 };
00270 cursor_loc m_cur_loc;
00271 };
00272
00273
00274 extern TilesFramework tiles;
00275
00276 #ifdef TARGET_COMPILER_MINGW
00277 #ifndef alloca
00278
00279 void *alloca(size_t);
00280 #endif
00281 #endif
00282
00283 #endif
00284 #endif