diff options
-rw-r--r-- | crawl-ref/source/tilefont.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.cc | 41 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.h | 8 | ||||
-rw-r--r-- | crawl-ref/source/tilesdl.cc | 6 |
4 files changed, 47 insertions, 16 deletions
diff --git a/crawl-ref/source/tilefont.cc b/crawl-ref/source/tilefont.cc index 94cbaf8e2f..720ac7b310 100644 --- a/crawl-ref/source/tilefont.cc +++ b/crawl-ref/source/tilefont.cc @@ -496,18 +496,18 @@ void FTFont::render_string(unsigned int px, unsigned int py, // box with extra buffer to test against min_pos/max_pos window size int sx = tx - buffer; int sy = ty - buffer; - int ex = sx + wx + buffer; - int ey = sy + wy + buffer; + int ex = tx + wx + buffer; + int ey = ty + wy + buffer; if (ex > max_pos.x) tx += max_pos.x - ex; else if (sx < min_pos.x) - tx -= sx; + tx -= sx - min_pos.x; if (ey > max_pos.y) ty += max_pos.y - ey; else if (sy < min_pos.y) - ty -= sy; + ty -= sy - min_pos.y; if (box_alpha != 0) _draw_box(tx, ty, wx, wy, outline, box_colour, box_alpha); diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index efde8ba154..699a6d2095 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -183,12 +183,15 @@ bool Region::mouse_pos(int mouse_x, int mouse_y, int &cx, int &cy) return valid; } -TileRegion::TileRegion(ImageManager* im, unsigned int tile_x, unsigned int tile_y) +TileRegion::TileRegion(ImageManager* im, FTFont *tag_font, unsigned int tile_x, unsigned int tile_y) { ASSERT(im); + ASSERT(tag_font); + m_image = im; dx = tile_x; dy = tile_y; + m_tag_font = tag_font; } TileRegion::~TileRegion() @@ -197,12 +200,10 @@ TileRegion::~TileRegion() DungeonRegion::DungeonRegion(ImageManager* im, FTFont *tag_font, unsigned int tile_x, unsigned int tile_y) : - TileRegion(im, tile_x, tile_y), + TileRegion(im, tag_font, tile_x, tile_y), m_cx_to_gx(0), - m_cy_to_gy(0), - m_tag_font(tag_font) + m_cy_to_gy(0) { - ASSERT(tag_font); for (unsigned int i = 0; i < CURSOR_MAX; i++) m_cursor[i] = NO_CURSOR; } @@ -1029,8 +1030,8 @@ bool InventoryTile::empty() const return (idx == -1); } -InventoryRegion::InventoryRegion(ImageManager* im, unsigned tile_x, unsigned int tile_y) : - TileRegion(im, tile_x, tile_y), +InventoryRegion::InventoryRegion(ImageManager* im, FTFont *tag_font, unsigned tile_x, unsigned int tile_y) : + TileRegion(im, tag_font, tile_x, tile_y), m_flavour(NULL), m_cursor(NO_CURSOR), m_need_to_pack(false) { } @@ -1109,6 +1110,32 @@ void InventoryRegion::render() m_image->m_textures[TEX_DEFAULT].bind(); glDrawArrays(GL_QUADS, m_base_verts, m_verts.size() - m_base_verts); + + if (m_cursor != NO_CURSOR) + { + unsigned int curs_index = cursor_index(); + int idx = m_items[curs_index].idx; + if (idx == -1) + return; + + bool floor = m_items[curs_index].flag & TILEI_FLAG_FLOOR; + + float x = m_cursor.x * dx + sx + ox + dx / 2; + float y = m_cursor.y * dy + sy + oy; + + const coord_def min_pos(sx, sy - dy); + const coord_def max_pos(ex, ey); + + std::string desc; + if (floor) + desc = mitm[idx].name(DESC_PLAIN); + else + desc = you.inv[idx].name(DESC_INVENTORY_EQUIP); + + m_tag_font->render_string(x, y, desc.c_str(), + min_pos, max_pos, WHITE, true, + 200, BLACK); + } } void InventoryRegion::add_quad_char(char c, unsigned int x, unsigned int y, int ofs_x, int ofs_y) diff --git a/crawl-ref/source/tilereg.h b/crawl-ref/source/tilereg.h index 74a14b42e8..4c1913b5a8 100644 --- a/crawl-ref/source/tilereg.h +++ b/crawl-ref/source/tilereg.h @@ -182,7 +182,8 @@ public: class TileRegion : public Region { public: - TileRegion(ImageManager *im, unsigned int tile_x, unsigned int tile_y); + TileRegion(ImageManager *im, FTFont *tag_font, + unsigned int tile_x, unsigned int tile_y); ~TileRegion(); protected: @@ -199,6 +200,7 @@ protected: }; std::vector<tile_vert> m_verts; + FTFont *m_tag_font; }; struct TextTag @@ -261,7 +263,6 @@ protected: int m_cy_to_gy; coord_def m_cursor[CURSOR_MAX]; std::vector<TextTag> m_tags[TAG_MAX]; - FTFont *m_tag_font; }; class InventoryTile @@ -286,7 +287,8 @@ public: class InventoryRegion : public TileRegion { public: - InventoryRegion(ImageManager *im, unsigned int tile_x, unsigned int tile_y); + InventoryRegion(ImageManager *im, FTFont *tag_font, + unsigned int tile_x, unsigned int tile_y); virtual ~InventoryRegion(); virtual void clear(); diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index 1ad7036a98..d6a6153090 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -185,12 +185,14 @@ bool TilesFramework::initialise() m_region_tile = new DungeonRegion(&m_image, m_fonts[lbl_font].font, TILE_X, TILE_Y); m_region_map = new MapRegion(Options.tile_map_pixels); - m_region_self_inv = new InventoryRegion(&m_image, TILE_X, TILE_Y); + m_region_self_inv = new InventoryRegion(&m_image, m_fonts[lbl_font].font, + TILE_X, TILE_Y); m_region_msg = new MessageRegion(m_fonts[msg_font].font); m_region_stat = new StatRegion(m_fonts[stat_font].font); m_region_crt = new CRTRegion(m_fonts[crt_font].font); - m_region_menu_inv = new InventoryRegion(&m_image, TILE_X, TILE_Y); + m_region_menu_inv = new InventoryRegion(&m_image, m_fonts[lbl_font].font, + TILE_X, TILE_Y); m_layers[LAYER_NORMAL].m_regions.push_back(m_region_tile); m_layers[LAYER_NORMAL].m_regions.push_back(m_region_map); |