diff options
author | Enne Walker <ennewalker@users.sourceforge.net> | 2010-04-19 20:00:06 -0400 |
---|---|---|
committer | Enne Walker <ennewalker@users.sourceforge.net> | 2010-04-25 19:33:13 -0400 |
commit | 8305dc11a61b732984b4bf2a2f8c8f48af84630e (patch) | |
tree | 9f605e327b60ab79111ae7c25bec938ed2261a0b /crawl-ref/source/tilereg-msg.cc | |
parent | edacdc0db313c0f5385631dfcf560f1fdf8e7c8a (diff) | |
download | crawl-ref-8305dc11a61b732984b4bf2a2f8c8f48af84630e.tar.gz crawl-ref-8305dc11a61b732984b4bf2a2f8c8f48af84630e.zip |
Split tilereg.h/cc into multiple files.
No functional changes, just rearranging and exposing functions where
needed.
Diffstat (limited to 'crawl-ref/source/tilereg-msg.cc')
-rw-r--r-- | crawl-ref/source/tilereg-msg.cc | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/crawl-ref/source/tilereg-msg.cc b/crawl-ref/source/tilereg-msg.cc new file mode 100644 index 0000000000..b6ddd49f01 --- /dev/null +++ b/crawl-ref/source/tilereg-msg.cc @@ -0,0 +1,126 @@ +/* + * File: tilereg-msg.cc + * + * Created by: ennewalker on Sat Jan 5 01:33:53 2008 UTC + */ + +#include "AppHdr.h" + +#ifdef USE_TILE + +#include "tilereg-msg.h" + +#include <SDL_opengl.h> + +#include "libutil.h" +#include "macro.h" +#include "tilefont.h" + +MessageRegion::MessageRegion(FontWrapper *font) : + TextRegion(font), + m_overlay(false) +{ +} + +int MessageRegion::handle_mouse(MouseEvent &event) +{ + // TODO enne - mouse scrolling here should mouse scroll up through + // the message history in the message pane, without going to the CRT. + + if (!inside(event.px, event.py)) + return 0; + + if (event.event != MouseEvent::PRESS || event.button != MouseEvent::LEFT) + return 0; + + if (mouse_control::current_mode() != MOUSE_MODE_COMMAND) + return 0; + + return command_to_key(CMD_REPLAY_MESSAGES); +} + +bool MessageRegion::update_tip_text(std::string& tip) +{ + if (mouse_control::current_mode() != MOUSE_MODE_COMMAND) + return (false); + + tip = "[L-Click] Browse message history"; + return (true); +} + +void MessageRegion::set_overlay(bool is_overlay) +{ + m_overlay = is_overlay; +} + +void MessageRegion::render() +{ +#ifdef DEBUG_TILES_REDRAW + cprintf("rendering MessageRegion\n"); +#endif + int idx = -1; + unsigned char char_back = 0; + unsigned char col_back = 0; + + if (!m_overlay && !m_alt_text.empty()) + { + coord_def min_pos(sx, sy); + coord_def max_pos(ex, ey); + m_font->render_string(sx + ox, sy + oy, m_alt_text.c_str(), + min_pos, max_pos, WHITE, false); + return; + } + + if (this == TextRegion::cursor_region && cursor_x > 0 && cursor_y > 0) + { + idx = cursor_x + mx * cursor_y; + char_back = cbuf[idx]; + col_back = abuf[idx]; + + cbuf[idx] = '_'; + abuf[idx] = WHITE; + } + + if (m_overlay) + { + int height; + bool found = false; + for (height = my; height > 0; height--) + { + unsigned char *buf = &cbuf[mx * (height - 1)]; + for (int x = 0; x < mx; x++) + { + if (buf[x] != ' ') + { + found = true; + break; + } + } + + if (found) + break; + } + + if (height > 0) + { + height *= m_font->char_height(); + + glmanager->set_transform(); + + ShapeBuffer buff; + VColour col(100, 100, 100, 100); + buff.add(sx, sy, ex, sy + height, col); + buff.draw(NULL, NULL); + } + } + + m_font->render_textblock(sx + ox, sy + oy, cbuf, abuf, mx, my, m_overlay); + + if (idx >= 0) + { + cbuf[idx] = char_back; + abuf[idx] = col_back; + } +} + +#endif |