1 #ifdef USE_TILE_LOCAL 2 #pragma once 3 4 #include <vector> 5 6 #include "tiledgnbuf.h" 7 #include "tilereg.h" 8 9 using std::vector; 10 11 class InventoryTile 12 { 13 public: 14 InventoryTile(); 15 16 // tile index 17 tileidx_t tile; 18 // env.item/you.inv idx (depends on flag & TILEI_FLAG_FLOOR) 19 int idx; 20 // quantity of this item (0-999 valid, >999 shows as 999, <0 shows nothing) 21 short quantity; 22 // bitwise-or of TILEI_FLAG enumeration 23 unsigned short flag; 24 // for inventory items, the slot 25 char key; 26 // a special property, such as for brands 27 int special; 28 29 bool empty() const; 30 }; 31 32 class GridRegion : public TileRegion 33 { 34 public: 35 GridRegion(const TileRegionInit &init); 36 37 virtual void clear() override; 38 virtual void render() override; 39 virtual void on_resize() override; 40 41 virtual void update() = 0; 42 void place_cursor(const coord_def &cursor); 43 44 virtual const string name() const = 0; 45 virtual bool update_tab_tip_text(string &tip, bool active) = 0; 46 virtual void activate() = 0; 47 48 protected: 49 virtual void pack_buffers() = 0; 50 virtual void draw_tag() = 0; 51 52 // Place the cursor and set idx with the index into m_items of the click. 53 // If click was invalid, return false. 54 bool place_cursor(wm_mouse_event &event, unsigned int &idx); 55 unsigned int cursor_index() const; 56 int add_quad_char(char c, int x, int y, int ox, int oy); 57 void draw_number(int x, int y, int number); 58 void draw_desc(const char *desc); 59 60 coord_def m_cursor; 61 int m_last_clicked_item; 62 int m_grid_page; 63 64 vector<InventoryTile> m_items; 65 66 DungeonCellBuffer m_buf; 67 }; 68 69 #endif 70