File: tilereg-grid.h

package info (click to toggle)
crawl 2%3A0.7.1-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 30,420 kB
  • ctags: 23,018
  • sloc: cpp: 244,317; ansic: 16,144; perl: 2,214; makefile: 984; python: 488; objc: 250; ruby: 200; sh: 140
file content (73 lines) | stat: -rw-r--r-- 1,744 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 *  File:       tilereg_grid.h
 *  Created by: ennewalker on Sat Jan 5 01:33:53 2008 UTC
 */

#ifdef USE_TILE
#ifndef TILEREG_GRID_H
#define TILEREG_GRID_H

#include "tiledgnbuf.h"
#include "tilereg.h"

class InventoryTile
{
public:
    InventoryTile();

    // tile index
    tileidx_t tile;
    // mitm/you.inv idx (depends on flag & TILEI_FLAG_FLOOR)
    int idx;
    // quantity of this item (0-999 valid, >999 shows as 999, <0 shows nothing)
    short quantity;
    // bitwise-or of TILEI_FLAG enumeration
    unsigned short flag;
    // for inventory items, the slot
    char key;
    // a special property, such as for brands
    int special;

    bool empty() const;
};

class GridRegion : public TileRegion
{
public:
    GridRegion(const TileRegionInit &init);
    virtual ~GridRegion();

    virtual void clear();
    virtual void render();
    virtual void on_resize();

    virtual void update() = 0;
    void place_cursor(const coord_def &cursor);

    virtual const std::string name() const = 0;
    virtual bool update_tab_tip_text(std::string &tip, bool active) = 0;
    virtual void activate() = 0;

protected:
    virtual void pack_buffers() = 0;
    virtual void draw_tag() = 0;

    // Place the cursor and set idx with the index into m_items of the click.
    // If click was invalid, return false.
    bool place_cursor(MouseEvent &event, unsigned int &idx);
    unsigned int cursor_index() const;
    void add_quad_char(char c, int x, int y, int ox, int oy);
    void draw_number(int x, int y, int number);
    void draw_desc(const char *desc);

    unsigned char *m_flavour;
    coord_def m_cursor;
    int m_last_clicked_item;

    std::vector<InventoryTile> m_items;

    DungeonCellBuffer m_buf;
};

#endif
#endif