diff options
author | ennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-10 16:23:13 +0000 |
---|---|---|
committer | ennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-10 16:23:13 +0000 |
commit | abec3e39f39b3f598c90b645a45bb43097b8e5cb (patch) | |
tree | 6050a955d8385bd0c2d46d12776702c62d585b4e /crawl-ref | |
parent | 87616cef0d3617cd349edb6641d32d71cdd96b22 (diff) | |
download | crawl-ref-abec3e39f39b3f598c90b645a45bb43097b8e5cb.tar.gz crawl-ref-abec3e39f39b3f598c90b645a45bb43097b8e5cb.zip |
[2495836] Show names for friendly uniques during arena mode. Also, add a tile_tag_pref option.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8383 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/docs/options_guide.txt | 21 | ||||
-rw-r--r-- | crawl-ref/settings/tiles_options.txt | 2 | ||||
-rw-r--r-- | crawl-ref/source/Kills.cc | 30 | ||||
-rw-r--r-- | crawl-ref/source/Kills.h | 6 | ||||
-rw-r--r-- | crawl-ref/source/directn.h | 5 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 25 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/terrain.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/tilepick.cc | 72 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.cc | 64 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.h | 15 | ||||
-rw-r--r-- | crawl-ref/source/tiles.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/tutorial.cc | 1 |
14 files changed, 213 insertions, 41 deletions
diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index 3aa82df368..383a61b8ff 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -92,7 +92,8 @@ The contents of this text are: tile_feature_col, tile_trap_col, tile_water_col, tile_lava_col, tile_excluded_col, tile_excl_centre_col, tile_key_repeat, tile_tooltip_ms, tile_window_width, - tile_window_height, tile_map_pixels, tile_full_screen + tile_window_height, tile_map_pixels, tile_full_screen, + tile_tag_pref 5- Character Dump. 5-a Items and Kills. kill_map, dump_kill_places, dump_item_origins, @@ -198,6 +199,7 @@ are as follows: book = random, for Conjurers and, for Tiles, tile_show_items = !?/%=([)x}+\_. + tile_tag_pref = tutorial 0-c Aliases and variables. ------------------------------ @@ -1601,9 +1603,10 @@ tile_tooltip_ms = 1000 The number of milliseconds before a tooltip appears when hovering the mouse over part of the screen. -tile_window_width = 1024 -tile_window_height = 768 - The width and height of the window, in pixels. +tile_window_width = 0 +tile_window_height = 0 + The width and height of the window, in pixels. If set to zero, it + will auto-size the window. tile_map_pixels = 4 The number of pixels each minimap square should take up. @@ -1611,6 +1614,16 @@ tile_map_pixels = 4 tile_full_screen = false Setting this option to true will start Crawl in full screen mode. +tile_tag_pref = (none | tutorial | named | enemy) + This option defaults to "enemy" normally and "tutorial" in tutorial + modes. This settings determines which monsters receive text tag + labels above them, describing what kind of monster they are. + The "none" option turns off all tags. The "tutorial" option + shows the name of all monsters that the player has only killed + a few times. The "named" options shows the names for all monsters + with names, friendly and enemy. The "enemy" option only shows the + name of enemy monsters with names (such as uniques and ghosts.) + 5- Character Dump. =================== diff --git a/crawl-ref/settings/tiles_options.txt b/crawl-ref/settings/tiles_options.txt index ad4750396d..8fdbfebbcb 100644 --- a/crawl-ref/settings/tiles_options.txt +++ b/crawl-ref/settings/tiles_options.txt @@ -31,6 +31,8 @@ # tile_tooltip_ms = 1000 +# tile_tag_pref = enemy + ### Note: setting window, map, or font sizes to '0' implies auto-sizing. # tile_window_width = 1024 diff --git a/crawl-ref/source/Kills.cc b/crawl-ref/source/Kills.cc index 6da4e56a28..b40e6b3a39 100644 --- a/crawl-ref/source/Kills.cc +++ b/crawl-ref/source/Kills.cc @@ -229,6 +229,20 @@ void KillMaster::add_kill_info(std::string &killtext, } } +long KillMaster::num_kills(const monsters *mon, kill_category cat) const +{ + return categorized_kills[cat].num_kills(mon); +} + +long KillMaster::num_kills(const monsters *mon) const +{ + long total = 0; + for (int cat = 0; cat < KC_NCATEGORIES; cat++) + total += categorized_kills[cat].num_kills(mon); + + return total; +} + /////////////////////////////////////////////////////////////////////////// bool Kills::empty() const @@ -344,6 +358,22 @@ void Kills::record_ghost_kill(const struct monsters *mon) ghosts.push_back(ghostk); } +int Kills::num_kills(const monsters *mon) const +{ + kill_monster_desc desc(mon); + kill_map::const_iterator iter = kills.find(desc); + int total = (iter == kills.end() ? 0 : iter->second.kills); + + if (desc.modifier == kill_monster_desc::M_SHAPESHIFTER) + { + desc.modifier = kill_monster_desc::M_NORMAL; + iter = kills.find(desc); + total += (iter == kills.end() ? 0 : iter->second.kills); + } + + return total; +} + kill_def::kill_def(const struct monsters *mon) : kills(0), exp(0) { exp = exper_value(mon); diff --git a/crawl-ref/source/Kills.h b/crawl-ref/source/Kills.h index 0dd4cb9550..71cab6bd45 100644 --- a/crawl-ref/source/Kills.h +++ b/crawl-ref/source/Kills.h @@ -145,6 +145,7 @@ public: void load(reader&); long get_kills(std::vector<kill_exp> &v) const; + int num_kills(const monsters *mon) const; private: typedef std::map<kill_monster_desc, kill_def, @@ -170,6 +171,11 @@ public: void save(writer&) const; void load(reader&); + // Number of kills, by category. + long num_kills(const monsters *mon, kill_category cat) const; + // Number of kills, any category. + long num_kills(const monsters *mon) const; + std::string kill_info() const; private: const char *category_name(kill_category kc) const; diff --git a/crawl-ref/source/directn.h b/crawl-ref/source/directn.h index 1759496612..6d71cfa0b5 100644 --- a/crawl-ref/source/directn.h +++ b/crawl-ref/source/directn.h @@ -241,6 +241,11 @@ inline coord_def grid2show(const coord_def &pos) return (view2show(grid2view(pos))); } +inline coord_def show2grid(const coord_def &pos) +{ + return (view2grid(show2view(pos))); +} + extern const struct coord_def Compass[8]; #endif diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 15b24ce7fe..951bf81c1d 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -3104,6 +3104,31 @@ enum screen_mode SCREENMODE_FULL = 1, SCREENMODE_AUTO = 2 }; + +enum cursor_type +{ + CURSOR_MOUSE, + CURSOR_TUTORIAL, + CURSOR_MAX +}; + +// Ordering of tags is important: higher values cover up lower ones. +enum text_tag_type +{ + TAG_NAMED_MONSTER = 0, + TAG_TUTORIAL = 1, + TAG_CELL_DESC = 2, + TAG_MAX +}; + +enum tag_pref +{ + TAGPREF_NONE, // never display text tags + TAGPREF_TUTORIAL, // display text tags on "new" monsters + TAGPREF_NAMED, // display text tags on named monsters (incl. friendlies) + TAGPREF_ENEMY, // display text tags on enemy named monsters + TAGPREF_MAX +}; #endif #ifdef WIZARD diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 1956e6bd76..d1dfcf0b64 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -2196,6 +2196,7 @@ public: int tile_window_height; int tile_map_pixels; int tile_tooltip_ms; + tag_pref tile_tag_pref; #endif typedef std::map<std::string, std::string> opt_map; diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 3bf7c2f180..0d63416dbe 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -73,7 +73,7 @@ god_type str_to_god(std::string god) } #ifdef USE_TILE -const std::string tile_cols[24] = +static std::string tile_cols[24] = { "black", "darkgrey", "grey", "lightgrey", "white", "blue", "lightblue", "darkblue", @@ -879,6 +879,7 @@ void game_options::reset_options() tile_window_height = 0; tile_map_pixels = 0; tile_tooltip_ms = 1000; + tile_tag_pref = crawl_state.arena ? TAGPREF_NAMED : TAGPREF_ENEMY; #endif // map each colour to itself as default @@ -3064,6 +3065,10 @@ void game_options::read_option_line(const std::string &str, bool runscript) else INT_OPTION(tile_window_height, 1, INT_MAX); else INT_OPTION(tile_map_pixels, 1, INT_MAX); else INT_OPTION(tile_tooltip_ms, 0, INT_MAX); + else if (key == "tile_tag_pref") + { + tile_tag_pref = string2tag_pref(field.c_str()); + } #endif else if(key == "bindkey") diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc index 082c4a4191..9daea9e765 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -319,7 +319,7 @@ void get_door_description(int door_size, const char** adjective, const char** no unsigned int show_appearance(const coord_def &ep) { unsigned int object = env.show(ep); - const coord_def gc = view2grid(show2view(ep)); + const coord_def gc = show2grid(ep); if (object == DNGN_SECRET_DOOR) object = grid_secret_door_appearance(gc); diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index ddaac223fd..1575a4a355 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -17,6 +17,7 @@ REVISION("$Rev$"); #include "itemname.h" #include "items.h" #include "itemprop.h" +#include "Kills.h" #include "macro.h" #include "monstuff.h" #include "mon-util.h" @@ -4394,20 +4395,46 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground, bool detected) if (foreground) { env.tile_fg[ep.x-1][ep.y-1] = t; - if (menv[idx].is_named() && !mons_friendly_real(&menv[idx]) - && menv[idx].type != MONS_PANDEMONIUM_DEMON) + const monsters *mon = &menv[idx]; + + if (!player_monster_visible(mon) + || mons_is_lurking(mon) + || (mons_is_mimic(mon->type) && !mons_is_known_mimic(mon)) + || mons_class_flag(mon->type, M_NO_EXP_GAIN)) { - if (menv[idx].type == MONS_PLAYER_GHOST) - { - // Beautification hack. "Foo's ghost" is a little bit - // verbose as a tag. "Foo" on its own should be sufficient. - tiles.add_text_tag(TAG_NAMED_MONSTER, menv[idx].mname, gc); - } - else - { - tiles.add_text_tag(TAG_NAMED_MONSTER, - menv[idx].name(DESC_CAP_A), gc); - } + return; + } + + const tag_pref pref = Options.tile_tag_pref; + if (pref == TAGPREF_NONE) + return; + else if (pref == TAGPREF_TUTORIAL) + { + const long kills = you.kills->num_kills(mon); + const int limit = 3; + + if (!mon->is_named() && kills > limit) + return; + } + else if (!mon->is_named()) + return; + + if (pref != TAGPREF_NAMED && mons_friendly_real(mon)) + return; + + // HACK. Names cover up pan demons in a weird way. + if (mon->type == MONS_PANDEMONIUM_DEMON) + return; + + if (mon->type == MONS_PLAYER_GHOST) + { + // Beautification hack. "Foo's ghost" is a little bit + // verbose as a tag. "Foo" on its own should be sufficient. + tiles.add_text_tag(TAG_NAMED_MONSTER, mon->mname, gc); + } + else + { + tiles.add_text_tag(TAG_NAMED_MONSTER, mon->name(DESC_PLAIN), gc); } } else @@ -4517,4 +4544,23 @@ void tile_finish_dngn(unsigned int *tileb, int cx, int cy) } } +static FixedVector<const char*, TAGPREF_MAX> + tag_prefs("none", "tutorial", "named", "enemy"); + +tag_pref string2tag_pref(const char *opt) +{ + for (int i = 0; i < TAGPREF_MAX; i++) + { + if (!stricmp(opt, tag_prefs[i])) + return ((tag_pref)i); + } + + return TAGPREF_ENEMY; +} + +const char *tag_pref2string(tag_pref pref) +{ + return tag_prefs[pref]; +} + #endif diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index 19a712cbbe..ecc065f66d 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -685,6 +685,15 @@ void DungeonRegion::pack_buffers() } } +struct tag_def +{ + tag_def() { text = NULL; left = right = 0; } + + const char* text; + char left, right; + char type; +}; + void DungeonRegion::render() { if (m_dirty) @@ -698,24 +707,65 @@ void DungeonRegion::render() m_buf_doll.draw(); m_buf_main.draw(); - // Draw text labels - // TODO enne - add an option for this - // TODO enne - be more intelligent about not covering stuff up - for (unsigned int t = 0; t < TAG_MAX; t++) + FixedArray<tag_def, ENV_SHOW_DIAMETER, ENV_SHOW_DIAMETER> tag_show; + + int total_tags = 0; + + for (int t = TAG_MAX - 1; t >= 0; t--) { for (unsigned int i = 0; i < m_tags[t].size(); i++) { - if (!on_screen(m_tags[t][i].gc)) + if (!crawl_view.in_grid_los(m_tags[t][i].gc)) + continue; + + const coord_def ep = grid2show(m_tags[t][i].gc); + + if (tag_show(ep).text) + continue; + + const char *str = m_tags[t][i].tag.c_str(); + + int width = m_tag_font->string_width(str); + tag_def &def = tag_show(ep); + + const int buffer = 2; + + def.left = -width / 2 - buffer; + def.right = width / 2 + buffer; + def.text = str; + def.type = t; + + total_tags++; + } + + if (total_tags) + break; + } + + if (!total_tags) + return; + + // Draw text tags. + // TODO enne - be more intelligent about not covering stuff up + for (int y = 0; y < ENV_SHOW_DIAMETER; y++) + { + for (int x = 0; x < ENV_SHOW_DIAMETER; x++) + { + coord_def ep(x, y); + tag_def &def = tag_show(ep); + + if (!def.text) continue; + const coord_def gc = show2grid(ep); coord_def pc; - to_screen_coords(m_tags[t][i].gc, pc); + to_screen_coords(gc, pc); // center this coord, which is at the top left of gc's cell pc.x += dx / 2; const coord_def min_pos(sx, sy); const coord_def max_pos(ex, ey); - m_tag_font->render_string(pc.x, pc.y, m_tags[t][i].tag.c_str(), + m_tag_font->render_string(pc.x, pc.y, def.text, min_pos, max_pos, WHITE, false); } } diff --git a/crawl-ref/source/tilereg.h b/crawl-ref/source/tilereg.h index 72a9f35c6c..293896f31e 100644 --- a/crawl-ref/source/tilereg.h +++ b/crawl-ref/source/tilereg.h @@ -245,21 +245,6 @@ struct TextTag coord_def gc; }; -enum cursor_type -{ - CURSOR_MOUSE, - CURSOR_TUTORIAL, - CURSOR_MAX -}; - -enum text_tag_type -{ - TAG_NAMED_MONSTER, - TAG_TUTORIAL, - TAG_CELL_DESC, - TAG_MAX -}; - class DungeonRegion : public TileRegion { public: diff --git a/crawl-ref/source/tiles.h b/crawl-ref/source/tiles.h index 923a34b96b..2c6460d819 100644 --- a/crawl-ref/source/tiles.h +++ b/crawl-ref/source/tiles.h @@ -108,6 +108,9 @@ void tile_floor_halo(dungeon_feature_type target, int tile); void tile_set_force_redraw_tiles(bool redraw); void tile_set_force_redraw_inv(bool redraw); +tag_pref string2tag_pref(const char *opt); +const char *tag_pref2string(tag_pref pref); + /**************************************/ /* tile2.cc image manipulation */ /**************************************/ diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc index 691dc8296f..1a0e67cca8 100644 --- a/crawl-ref/source/tutorial.cc +++ b/crawl-ref/source/tutorial.cc @@ -112,6 +112,7 @@ void init_tutorial_options() // Unfortunately I can't think of a remotely non-hacky way // to do this. strncpy(Options.tile_show_items, "!?/%=([)x}+\\_.", 18); + Options.tile_tag_pref = TAGPREF_TUTORIAL; #endif } |