diff options
-rw-r--r-- | crawl-ref/source/directn.cc | 62 | ||||
-rw-r--r-- | crawl-ref/source/directn.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/terrain.cc | 22 | ||||
-rw-r--r-- | crawl-ref/source/terrain.h | 6 | ||||
-rw-r--r-- | crawl-ref/source/tilepick.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.cc | 57 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/tilesdl.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 25 |
9 files changed, 130 insertions, 52 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 4e9ce1daf3..22e77a4540 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -1221,6 +1221,68 @@ void direction(dist& moves, targeting_type restricts, _extend_move_to_edge(moves); } +std::string get_terse_square_desc(const coord_def &gc) +{ + std::string desc; + const char *unseen_desc = "[unseen terrain]"; + bool is_feature = false; + if (gc == you.pos()) + { + desc = you.your_name; + } + else if (!map_bounds(gc)) + { + desc = unseen_desc; + } + else if (!see_grid(gc)) + { + if (is_terrain_seen(gc)) + { + desc = feature_description(gc, false, DESC_PLAIN, false); + if (!see_grid(gc)) + { + desc = "[" + desc + "]"; + } + is_feature = true; + } + else + { + desc = unseen_desc; + } + } + else if (mgrd(gc) != NON_MONSTER) + { + const monsters &mons = menv[mgrd(gc)]; + + if (mons_is_mimic(mons.type) && !(mons.flags & MF_KNOWN_MIMIC)) + { + item_def item; + get_mimic_item(&mons, item); + desc = item.name(DESC_PLAIN); + } + else + { + desc = mons.name(DESC_PLAIN); + if (mons.has_base_name()) + { + desc += ", "; + desc += mons.base_name(DESC_NOCAP_THE, false); + } + } + } + else if (igrd(gc) != NON_ITEM) + { + desc = mitm[igrd(gc)].name(DESC_PLAIN); + } + else + { + desc = feature_description(gc, false, DESC_PLAIN, false); + is_feature = true; + } + + return desc; +} + void terse_describe_square(const coord_def &c) { if (!see_grid(c)) diff --git a/crawl-ref/source/directn.h b/crawl-ref/source/directn.h index ed0bfd2484..029077bf3c 100644 --- a/crawl-ref/source/directn.h +++ b/crawl-ref/source/directn.h @@ -160,6 +160,7 @@ bool in_los(const coord_def &pos); bool in_vlos(int x, int y); bool in_vlos(const coord_def &pos); +std::string get_terse_square_desc(const coord_def &gc); void terse_describe_square(const coord_def &c); void full_describe_square(const coord_def &c); void describe_floor(); diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc index 7ca50696e5..95c2286643 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -301,7 +301,27 @@ void get_door_description(int door_size, const char** adjective, const char** no *noun = descriptions[idx+1]; } -dungeon_feature_type grid_secret_door_appearance( const coord_def& where ) +unsigned int show_appearance(const coord_def &ep) +{ + unsigned int object = env.show(ep); + const coord_def gc = view2grid(show2view(ep)); + + if (object == DNGN_SECRET_DOOR) + object = grid_secret_door_appearance(gc); + + return object; +} + +dungeon_feature_type grid_appearance(const coord_def &gc) +{ + dungeon_feature_type grid = grd(gc); + if (grid == DNGN_SECRET_DOOR) + grid = grid_secret_door_appearance(gc); + + return grid; +} + +dungeon_feature_type grid_secret_door_appearance(const coord_def &where) { dungeon_feature_type ret = DNGN_FLOOR; diff --git a/crawl-ref/source/terrain.h b/crawl-ref/source/terrain.h index aad1a080e0..429c26a32c 100644 --- a/crawl-ref/source/terrain.h +++ b/crawl-ref/source/terrain.h @@ -50,8 +50,10 @@ void find_connected_range(coord_def d, dungeon_feature_type ft_min, dungeon_feature_type ft_max, std::set<coord_def>& out); void get_door_description(int door_size, const char** adjective, const char** noun); -dungeon_feature_type grid_secret_door_appearance( const coord_def& where ); -bool grid_destroys_items( dungeon_feature_type grid ); +dungeon_feature_type grid_secret_door_appearance(const coord_def &where); +dungeon_feature_type grid_appearance(const coord_def &gc); +unsigned int show_appearance(const coord_def &ep); +bool grid_destroys_items(dungeon_feature_type grid); const char *grid_item_destruction_message( dungeon_feature_type grid ); diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index d5625c2b9a..f7d1bac148 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -3985,12 +3985,9 @@ void tile_draw_floor() const coord_def gc = view2grid(show2view(ep)); int bg = TILE_DNGN_UNSEEN | tile_unseen_flag(gc); - int object = env.show(ep); + int object = show_appearance(ep); if (in_bounds(gc) && object != 0) { - if (object == DNGN_SECRET_DOOR) - object = (int)grid_secret_door_appearance(gc); - bg = tileidx_feature(object, gc.x, gc.y); if (is_travelable_stair((dungeon_feature_type)object) diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index 6c27a06055..d320c2431b 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -25,6 +25,7 @@ #include "terrain.h" #include "transfor.h" #include "travel.h" +#include "view.h" #include "tilereg.h" #include "tiles.h" @@ -786,6 +787,15 @@ void DungeonRegion::draw_foreground(unsigned int bg, unsigned int fg, unsigned i } } +void DungeonRegion::draw_cursor(cursor_type type, unsigned int tile) +{ + const coord_def &gc = m_cursor[type]; + if (gc == NO_CURSOR || !on_screen(gc)) + return; + + add_quad(TEX_DEFAULT, tile, gc.x - m_cx_to_gx, gc.y - m_cy_to_gy); +} + void DungeonRegion::render() { if (m_tileb.size() == 0) @@ -891,6 +901,18 @@ void DungeonRegion::render() tile += 2; } + draw_cursor(CURSOR_TUTORIAL, TILE_TUTORIAL_CURSOR); + draw_cursor(CURSOR_MOUSE, see_grid(m_cursor[CURSOR_MOUSE]) ? TILE_CURSOR + : TILE_CURSOR2); + + if (m_cursor[CURSOR_TUTORIAL] != NO_CURSOR + && on_screen(m_cursor[CURSOR_TUTORIAL])) + { + add_quad(TEX_DEFAULT, TILE_TUTORIAL_CURSOR, + m_cursor[CURSOR_TUTORIAL].x, + m_cursor[CURSOR_TUTORIAL].y); + } + if (m_verts.size() > 0) { m_image->m_textures[TEX_DEFAULT].bind(); @@ -934,6 +956,8 @@ void DungeonRegion::on_resize() int DungeonRegion::handle_mouse(MouseEvent &event) { + tiles.clear_text_tags(TAG_CELL_DESC); + if (mouse_control::current_mode() == MOUSE_MODE_NORMAL || mouse_control::current_mode() == MOUSE_MODE_MACRO || mouse_control::current_mode() == MOUSE_MODE_MORE) @@ -952,10 +976,13 @@ int DungeonRegion::handle_mouse(MouseEvent &event) const coord_def gc(cx + m_cx_to_gx, cy + m_cy_to_gy); tiles.place_cursor(CURSOR_MOUSE, gc); - // TODO enne - can we handle this through tooltips - // Destroying the message area is such bad behaviour. - // mesclr(); - // terse_describe_square(gc); + if (event.event == MouseEvent::MOVE) + { + const std::string &desc = get_terse_square_desc(gc); + // Suppress floor description + if (desc != "floor") + tiles.add_text_tag(TAG_CELL_DESC, desc, gc); + } if (!on_map) return 0; @@ -1073,18 +1100,6 @@ int DungeonRegion::get_buffer_index(const coord_def &gc) void DungeonRegion::place_cursor(cursor_type type, const coord_def &gc) { - unsigned int unmask = ~((type == CURSOR_MOUSE) ? TILE_FLAG_CURSOR : - TILE_FLAG_TUT_CURSOR); - unsigned int mask = (type == CURSOR_MOUSE) ? TILE_FLAG_CURSOR1 : - TILE_FLAG_TUT_CURSOR; - - // Remove cursor from previous location - if (on_screen(m_cursor[type])) - { - unsigned int idx = get_buffer_index(m_cursor[type]) + 1; - m_tileb[idx] &= unmask; - } - // If we're only looking for a direction, put the mouse // cursor next to the player to let them know that their // spell/wand will only go one square. @@ -1113,16 +1128,6 @@ void DungeonRegion::place_cursor(cursor_type type, const coord_def &gc) { m_cursor[type] = gc; } - - // Add cursor to new location - if ((m_cursor[type] != NO_CURSOR) && on_screen(m_cursor[type])) - { - unsigned int idx = get_buffer_index(m_cursor[type]) + 1; - m_tileb[idx] &= unmask; - - // TODO enne - specify type of cursor in place_cursor? or determine type based on grd? - m_tileb[idx] |= mask; - } } bool DungeonRegion::update_tip_text(std::string& tip) diff --git a/crawl-ref/source/tilereg.h b/crawl-ref/source/tilereg.h index dcc8b92606..50c6317526 100644 --- a/crawl-ref/source/tilereg.h +++ b/crawl-ref/source/tilereg.h @@ -212,6 +212,7 @@ enum text_tag_type { TAG_NAMED_MONSTER, TAG_TUTORIAL, + TAG_CELL_DESC, TAG_MAX }; @@ -246,6 +247,7 @@ protected: void draw_foreground(unsigned int bg, unsigned int fg, unsigned int x, unsigned int y); void draw_doll(dolls_data &doll, unsigned int x, unsigned int y); void draw_draco(int colour, int mon_idx, int equ_tile, unsigned int x, unsigned int y); + void draw_cursor(cursor_type type, unsigned int tile); void add_quad_doll(unsigned int part, unsigned int idx, int ymax, unsigned int x, unsigned int y, int ox, int oy); diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index f09ece9c1d..4cc1f9c12a 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -512,6 +512,7 @@ int TilesFramework::getch_ck() if (SDL_PollEvent(&event)) { + tiles.clear_text_tags(TAG_CELL_DESC); switch(event.type) { case SDL_KEYDOWN: @@ -587,6 +588,7 @@ int TilesFramework::getch_ck() if (show_tooltip) { + tiles.clear_text_tags(TAG_CELL_DESC); if (m_tooltip.empty()) { for (unsigned int i = 0; diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 816c615991..3a5e936481 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -2631,9 +2631,8 @@ void losight(env_show_grid &sh, if (realx < 0 || realx > 79 || realy < 0 || realy > 69) continue; - dungeon_feature_type dfeat = gr[realx][realy]; - if (dfeat == DNGN_SECRET_DOOR) - dfeat = grid_secret_door_appearance(coord_def(realx, realy)); + coord_def real(realx, realy); + dungeon_feature_type dfeat = grid_appearance(real); // if this cell is opaque... if ( grid_is_opaque(dfeat) @@ -4579,16 +4578,13 @@ unsigned get_screen_glyph( int x, int y ) { const coord_def ep = view2show(grid2view(coord_def(x,y))); - int object = env.show(ep); + int object = show_appearance(ep); unsigned short colour = env.show_col(ep); unsigned ch; if (!object) return get_envmap_char(x, y); - if (object == DNGN_SECRET_DOOR) - object = grid_secret_door_appearance(coord_def(x, y)); - _get_symbol( x, y, object, &ch, &colour ); return (ch); } @@ -4648,13 +4644,10 @@ std::string screenshot( bool fullscreen ) if (ch && !isprint(ch)) { // [ds] Evil hack time again. Peek at grid, use that character. - int object = grd(gc); + int object = grid_appearance(gc); unsigned glych; unsigned short glycol = 0; - if (object == DNGN_SECRET_DOOR) - object = grid_secret_door_appearance( gc ); - _get_symbol( gc.x, gc.y, object, &glych, &glycol ); ch = glych; } @@ -4743,7 +4736,7 @@ void view_update_at(const coord_def &pos) const coord_def ep = view2show(vp); _update_env_show(pos, ep); - int object = env.show(ep); + int object = show_appearance(ep); if (!object) return; @@ -4751,9 +4744,6 @@ void view_update_at(const coord_def &pos) unsigned short colour = env.show_col(ep); unsigned ch = 0; - if (object == DNGN_SECRET_DOOR) - object = grid_secret_door_appearance( pos ); - _get_symbol( pos.x, pos.y, object, &ch, &colour ); int flash_colour = you.flash_colour; @@ -4994,13 +4984,10 @@ void viewwindow(bool draw_it, bool do_updates) } else { - int object = env.show(ep); + int object = show_appearance(ep); unsigned short colour = env.show_col(ep); unsigned ch; - if (object == DNGN_SECRET_DOOR) - object = grid_secret_door_appearance( gc ); - _get_symbol( gc.x, gc.y, object, &ch, &colour ); buffy[bufcount] = ch; |