summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-30 14:25:22 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-30 14:25:22 +0000
commita8878308615ed621f4e0f3d041c3bd13403258e3 (patch)
treec9f57d16fcc2b23f3d087db7a19fd6a2119ef61d
parentcbd9791cd0bd50b017312d12d8110580b90873ec (diff)
downloadcrawl-ref-a8878308615ed621f4e0f3d041c3bd13403258e3.tar.gz
crawl-ref-a8878308615ed621f4e0f3d041c3bd13403258e3.zip
Implemented 1633998: summary line for large stacks, controlled by the
item_stack_summary_minimum option. Artefacts and glowing/runed items get yellow and white, respectively. Also, the entire item list on the floor will be displayed if it fits onto the screen (and not if there are five or less items, as before.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1699 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/docs/crawl_options.txt11
-rw-r--r--crawl-ref/init.txt1
-rw-r--r--crawl-ref/source/externs.h4
-rw-r--r--crawl-ref/source/initfile.cc7
-rw-r--r--crawl-ref/source/items.cc173
-rw-r--r--crawl-ref/source/items.h2
6 files changed, 139 insertions, 59 deletions
diff --git a/crawl-ref/docs/crawl_options.txt b/crawl-ref/docs/crawl_options.txt
index 0b45edb5ab..c1164b0d59 100644
--- a/crawl-ref/docs/crawl_options.txt
+++ b/crawl-ref/docs/crawl_options.txt
@@ -55,7 +55,7 @@ The contents of this text are:
hp_warning, mp_warning, hp_colour, mp_colour, always_greet,
terse_hand, delay_message_clear, menu_colour, message_colour,
increasing_skill_progress, show_inventory_weights,
- show_turns
+ show_turns, item_stack_summary_minimum
4-k Missiles.
fire_items_start, fire_order
4-l Message Channels.
@@ -905,6 +905,15 @@ show_turns = false
This option controls whether the turn counter (of turns elapsed) is
displayed in the main view.
+item_stack_summary_minimum = 5
+ If you step over a stack with this number or more of items in it,
+ the first description line will contain a summary of all the
+ items in the stack (up to 50 items), in a format which looks
+ like this:
+ Items here: !! """ % ( )))))) [[[
+ Known artefacts will be coloured in yellow; glowing or runed
+ items will be in white.
+
4-k Missiles.
-----------------
diff --git a/crawl-ref/init.txt b/crawl-ref/init.txt
index c1569ffb13..e1c9a7c794 100644
--- a/crawl-ref/init.txt
+++ b/crawl-ref/init.txt
@@ -173,6 +173,7 @@ stab_brand = hi:blue
# increasing_skill_progress = false
# show_inventory_weights = true
# show_turns = true
+# item_stack_summary_minimum = 500
# Colouring for the inventory
menu_colour = lightred: cursed.*(worn|neck|hand|weapon)\)
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index fe87cc2560..2a4cbd362b 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1620,6 +1620,10 @@ public:
unsigned may_stab_brand; // Highlight potential stab candidates
unsigned stair_item_brand; // Highlight stairs covered by items.
+ // What is the minimum number of items in a stack for which
+ // you show summary (one-line) information
+ int item_stack_summary_minimum;
+
int explore_stop; // Stop exploring if a previously unseen
// item comes into view
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 1c6d28bac8..0b4c918362 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -719,6 +719,8 @@ void game_options::reset_options()
fire_order[1] = FIRE_DART; // then only consider darts
fire_order[2] = FIRE_STONE; // and then chuck stones
+ item_stack_summary_minimum = 5;
+
#ifdef WIZARD
fsim_rounds = 40000L;
fsim_mons = "worm";
@@ -775,6 +777,7 @@ void game_options::reset_options()
mp_colour.push_back(std::pair<int, int>(100, LIGHTGREY));
mp_colour.push_back(std::pair<int, int>(50, YELLOW));
mp_colour.push_back(std::pair<int, int>(25, RED));
+
never_pickup.clear();
always_pickup.clear();
note_monsters.clear();
@@ -2265,6 +2268,10 @@ void game_options::read_option_line(const std::string &str, bool runscript)
dos_use_background_intensity =
read_bool(field, dos_use_background_intensity);
}
+ else if (key == "item_stack_summary_minimum")
+ {
+ item_stack_summary_minimum = atoi(field.c_str());
+ }
else if (key == "explore_stop")
{
if (!plus_equal && !minus_equal)
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 6928a4ff58..80d9edbc56 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -63,6 +63,7 @@
#include "stuff.h"
#include "stash.h"
#include "tutorial.h"
+#include "view.h"
static bool invisible_to_player( const item_def& item );
static void item_list_on_square( std::vector<const item_def*>& items,
@@ -559,89 +560,147 @@ void request_autopickup(bool do_pickup)
will_autopickup = do_pickup;
}
-/*
- * Takes keyin as an argument because it will only display a long list of items
- * if ; is pressed.
- */
-void item_check(char keyin)
+// 2 - artifact, 1 - glowing/runed, 0 - mundane
+static int item_name_specialness(const item_def& item)
{
- char item_show[50][ITEMNAME_SIZE];
- char temp_quant[10];
+ // All jewellery is worth looking at.
+ // And we can always tell from the name if it's an artefact.
+ if (item.base_type == OBJ_JEWELLERY )
+ return ( is_artefact(item) ? 2 : 1 );
- int counter = 0;
- int counter_max = 0;
-
- describe_floor();
-
- if (igrd[you.x_pos][you.y_pos] == NON_ITEM && keyin == ';')
+ if (item.base_type != OBJ_WEAPONS && item.base_type != OBJ_ARMOUR &&
+ item.base_type != OBJ_MISSILES)
+ return 0;
+ if (item_type_known(item))
{
- mpr("There are no items here.");
- return;
+ if ( is_artefact(item) )
+ return 2;
+
+ // XXX Unite with l_item_branded() in clua.cc
+ bool branded = false;
+ switch (item.base_type)
+ {
+ case OBJ_WEAPONS:
+ branded = get_weapon_brand(item) != SPWPN_NORMAL;
+ break;
+ case OBJ_ARMOUR:
+ branded = get_armour_ego_type(item) != SPARM_NORMAL;
+ break;
+ case OBJ_MISSILES:
+ branded = get_ammo_brand(item) != SPMSL_NORMAL;
+ break;
+ default:
+ break;
+ }
+ return ( branded ? 1 : 0 );
}
+
+ if ( item.base_type == OBJ_MISSILES )
+ return 0; // missiles don't get name descriptors
+
+ std::string itname = item.name(DESC_PLAIN, false, false, false);
+ lowercase(itname);
- autoinscribe_items();
+ const bool item_runed = itname.find("runed ") != std::string::npos;
+ const bool heav_runed = itname.find("heavily ") != std::string::npos;
+ const bool item_glows = itname.find("glowing") != std::string::npos;
- origin_set(you.x_pos, you.y_pos);
+ if ( item_glows || (item_runed && !heav_runed) )
+ return 1;
- for ( int objl = igrd[you.x_pos][you.y_pos]; objl != NON_ITEM;
- objl = mitm[objl].link )
- {
- if ( invisible_to_player(mitm[objl]) )
- continue;
+ // You can tell artefacts, because they'll have a description which
+ // rules out anything else.
+ // XXX Fixedarts and unrandarts might upset the apple-cart, though.
+ if ( is_artefact(item) )
+ return 2;
- counter++;
+ return 0;
+}
- if (counter > 45)
- {
- strcpy(item_show[counter], "Too many items.");
- break;
- }
+/*
+ * Takes keyin as an argument because it will only display a long list of items
+ * if ; is pressed.
+ */
+void item_check(bool verbose)
+{
- if (mitm[objl].base_type == OBJ_GOLD)
- {
- itoa(mitm[objl].quantity, temp_quant, 10);
- strcpy(item_show[counter], temp_quant);
- strcat(item_show[counter], " gold piece");
- if (mitm[objl].quantity > 1)
- strcat(item_show[counter], "s");
+ describe_floor();
+ autoinscribe_items();
+ origin_set(you.x_pos, you.y_pos);
- }
- else
- {
- strcpy(item_show[counter], mitm[objl].name(DESC_NOCAP_A).c_str());
- }
+ std::ostream& strm = msg::streams(MSGCH_FLOOR_ITEMS);
- }
+ std::vector<const item_def*> items;
- counter_max = counter;
- counter = 0;
+ item_list_on_square( items, igrd[you.x_pos][you.y_pos], true );
- if (counter_max == 1)
+ if (items.size() == 0)
{
- mprf("You see here %s.", item_show[counter_max]); // remember 'an'.
+ if ( verbose )
+ strm << "There are no items here." << std::endl;
+ return;
+ }
- counter++;
- counter_max = 0; // to skip next part.
+ if (items.size() == 1 )
+ {
+ strm << "You see here " << items[0]->name(DESC_NOCAP_A)
+ << '.' << std::endl;
+ return;
}
- if ((counter_max > 0 && counter_max < 6)
- || (counter_max > 1 && keyin == ';'))
+ bool done_init_line = false;
+
+ if (static_cast<int>(items.size()) >= Options.item_stack_summary_minimum)
{
- mpr("Things that are here:");
+ std::vector<unsigned short int> item_chars;
+ for ( unsigned int i = 0; i < items.size() && i < 50; ++i )
+ {
+ unsigned glyph_char;
+ unsigned short glyph_col;
+ get_item_glyph( items[i], &glyph_char, &glyph_col );
+ item_chars.push_back( glyph_char * 0x100 +
+ (10 - item_name_specialness(*(items[i]))) );
+ }
+ std::sort(item_chars.begin(), item_chars.end());
- while (counter < counter_max)
+ std::string out_string = "Items here: ";
+ int cur_state = -1;
+ for ( unsigned int i = 0; i < item_chars.size(); ++i )
{
- // this is before the strcpy because item_show start at 1, not 0.
- counter++;
- mpr(item_show[counter]);
+ const int specialness = 10 - (item_chars[i] % 0x100);
+ if ( specialness != cur_state )
+ {
+ switch ( specialness )
+ {
+ case 2: out_string += "<yellow>"; break; // artefact
+ case 1: out_string += "<white>"; break; // glowing/runed
+ case 0: out_string += "<darkgrey>"; break; // mundane
+ }
+ cur_state = specialness;
+ }
+
+ out_string += static_cast<unsigned char>(item_chars[i] / 0x100);
+ if (i + 1 < item_chars.size() &&
+ (item_chars[i] / 0x100) != (item_chars[i+1] / 0x100))
+ out_string += ' ';
}
+ formatted_mpr(formatted_string::parse_string(out_string),
+ MSGCH_FLOOR_ITEMS);
+ done_init_line = true;
}
- if (counter_max > 5 && keyin != ';')
+ if ( verbose || static_cast<int>(items.size() + 1) < crawl_view.msgsz.y )
{
- mpr("There are several objects here.");
+ if ( !done_init_line )
+ strm << "Things that are here:" << std::endl;
+ for ( unsigned int i = 0; i < items.size(); ++i )
+ strm << items[i]->name(DESC_NOCAP_A) << std::endl;
+ }
+ else if ( !done_init_line )
+ strm << "There are many items here." << std::endl;
+
+ if ( items.size() > 5 )
learned_something_new(TUT_MULTI_PICKUP);
- }
}
void show_items()
diff --git a/crawl-ref/source/items.h b/crawl-ref/source/items.h
index fbcfe4339f..e16d756ee3 100644
--- a/crawl-ref/source/items.h
+++ b/crawl-ref/source/items.h
@@ -69,7 +69,7 @@ void destroy_item_stack( int x, int y );
/* ***********************************************************************
* called from: acr
* *********************************************************************** */
-void item_check(char keyin);
+void item_check(bool verbose);
void request_autopickup(bool do_pickup = true);
// last updated: 08jun2000 {dlb}