Data structure describing all properties a screen tile can have
| 68 | { |
| 69 | /// Data structure describing all properties a screen tile can have |
| 70 | struct Pen { |
| 71 | // Ordinary text symbol |
| 72 | char ch; |
| 73 | int8_t fg, bg; |
| 74 | bool bold; |
| 75 | |
| 76 | // Graphics tile |
| 77 | int tile; |
| 78 | enum TileMode { |
| 79 | AsIs, // Tile colors used without modification |
| 80 | CharColor, // The fg/bg pair is used |
| 81 | TileColor // The fields below are used |
| 82 | } tile_mode; |
| 83 | int8_t tile_fg, tile_bg; |
| 84 | |
| 85 | bool write_to_lower = false; |
| 86 | bool keep_lower = false; |
| 87 | bool top_of_text = false; |
| 88 | bool bottom_of_text = false; |
| 89 | |
| 90 | bool valid() const { return tile >= 0; } |
| 91 | bool empty() const { return ch == 0 && tile == 0; } |
| 92 | |
| 93 | // NOTE: LuaApi.cpp assumes this struct is plain data and has empty destructor |
| 94 | |
| 95 | Pen(char ch = 0, int8_t fg = 7, int8_t bg = 0, int tile = 0, bool color_tile = false) |
| 96 | : ch(ch), fg(fg&7), bg(bg), bold(!!(fg&8)), |
| 97 | tile(tile), tile_mode(color_tile ? CharColor : AsIs), tile_fg(0), tile_bg(0) |
| 98 | {} |
| 99 | Pen(char ch, int8_t fg, int8_t bg, bool bold, int tile = 0, bool color_tile = false) |
| 100 | : ch(ch), fg(fg), bg(bg), bold(bold), |
| 101 | tile(tile), tile_mode(color_tile ? CharColor : AsIs), tile_fg(0), tile_bg(0) |
| 102 | {} |
| 103 | Pen(char ch, int8_t fg, int8_t bg, int tile, int8_t tile_fg, int8_t tile_bg) |
| 104 | : ch(ch), fg(fg&7), bg(bg), bold(!!(fg&8)), |
| 105 | tile(tile), tile_mode(TileColor), tile_fg(tile_fg), tile_bg(tile_bg) |
| 106 | {} |
| 107 | Pen(char ch, int8_t fg, int8_t bg, bool bold, int tile, int8_t tile_fg, int8_t tile_bg) |
| 108 | : ch(ch), fg(fg), bg(bg), bold(bold), |
| 109 | tile(tile), tile_mode(TileColor), tile_fg(tile_fg), tile_bg(tile_bg) |
| 110 | {} |
| 111 | |
| 112 | void adjust(int8_t nfg) { fg = nfg&7; bold = !!(nfg&8); } |
| 113 | void adjust(int8_t nfg, bool nbold) { fg = nfg; bold = nbold; } |
| 114 | void adjust(int8_t nfg, int8_t nbg) { adjust(nfg); bg = nbg; } |
| 115 | void adjust(int8_t nfg, bool nbold, int8_t nbg) { adjust(nfg, nbold); bg = nbg; } |
| 116 | |
| 117 | Pen color(int8_t nfg) const { Pen cp(*this); cp.adjust(nfg); return cp; } |
| 118 | Pen color(int8_t nfg, bool nbold) const { Pen cp(*this); cp.adjust(nfg, nbold); return cp; } |
| 119 | Pen color(int8_t nfg, int8_t nbg) const { Pen cp(*this); cp.adjust(nfg, nbg); return cp; } |
| 120 | Pen color(int8_t nfg, bool nbold, int8_t nbg) const { Pen cp(*this); cp.adjust(nfg, nbold, nbg); return cp; } |
| 121 | |
| 122 | Pen chtile(char ch) { Pen cp(*this); cp.ch = ch; return cp; } |
| 123 | Pen chtile(char ch, int tile) { Pen cp(*this); cp.ch = ch; cp.tile = tile; return cp; } |
| 124 | }; |
| 125 | |
| 126 | class DFHACK_EXPORT PenArray { |
| 127 | Pen *buffer; |