From e31ea7d79da677a7cb752d863cdb8f2942984b4f Mon Sep 17 00:00:00 2001 From: Johanna Ploog Date: Mon, 11 Jan 2010 15:25:50 +0100 Subject: Experimentally draw tool tip below the mouse pointer rather than above. It's a bit less distracting this way and doesn't cover up the inventory header line (description). --- crawl-ref/source/tilefont.cc | 24 +++++++++++++++++------- crawl-ref/source/tilefont.h | 3 ++- crawl-ref/source/tilesdl.cc | 3 ++- 3 files changed, 21 insertions(+), 9 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/tilefont.cc b/crawl-ref/source/tilefont.cc index d8cec9c22f..e7e7bde04d 100644 --- a/crawl-ref/source/tilefont.cc +++ b/crawl-ref/source/tilefont.cc @@ -576,7 +576,8 @@ void FTFont::render_string(unsigned int px, unsigned int py, unsigned char font_colour, bool drop_shadow, unsigned char box_alpha, unsigned char box_colour, - unsigned int outline) + unsigned int outline, + bool tooltip) { ASSERT(text); @@ -626,13 +627,22 @@ void FTFont::render_string(unsigned int px, unsigned int py, int wx = string_width(text); int wy = max_rows * char_height(); - // text starting location - int tx = px - wx / 2; - int ty = py - wy - outline; + int sx, sy; // box starting location, uses extra buffer + int tx, ty; // text starting location - // box with extra buffer to test against min_pos/max_pos window size - int sx = tx - buffer; - int sy = ty - buffer; + tx = px - wx / 2; + sx = tx - buffer; + if (tooltip) + { + sy = py + outline; + ty = sy + buffer; + } + else + { + ty = py - wy - outline; + sy = ty - buffer; + } + // box ending position int ex = tx + wx + buffer; int ey = ty + wy + buffer; diff --git a/crawl-ref/source/tilefont.h b/crawl-ref/source/tilefont.h index 8ca50c9d18..8ec1356903 100644 --- a/crawl-ref/source/tilefont.h +++ b/crawl-ref/source/tilefont.h @@ -42,7 +42,8 @@ public: const coord_def &min_pos, const coord_def &max_pos, unsigned char font_colour, bool drop_shadow = false, unsigned char box_alpha = 0, - unsigned char box_colour = 0, unsigned int outline = 0); + unsigned char box_colour = 0, unsigned int outline = 0, + bool tooltip = false); // FontBuffer helper functions void store(FontBuffer &buf, float &x, float &y, diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index 07d36c948b..5610a8341a 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -1313,7 +1313,8 @@ void TilesFramework::redraw() FTFont *font = m_fonts[m_tip_font].font; font->render_string(m_mouse.x, m_mouse.y - 2, m_tooltip.c_str(), - min_pos, m_windowsz, WHITE, false, 220, BLUE, 5); + min_pos, m_windowsz, WHITE, false, 220, BLUE, 5, + true); } SDL_GL_SwapBuffers(); -- cgit v1.2.3-54-g00ecf