From: <ha...@us...> - 2007-06-30 14:25:33
|
Revision: 1699 http://svn.sourceforge.net/crawl-ref/?rev=1699&view=rev Author: haranp Date: 2007-06-30 07:25:22 -0700 (Sat, 30 Jun 2007) Log Message: ----------- 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.) Modified Paths: -------------- trunk/crawl-ref/docs/crawl_options.txt trunk/crawl-ref/init.txt trunk/crawl-ref/source/externs.h trunk/crawl-ref/source/initfile.cc trunk/crawl-ref/source/items.cc trunk/crawl-ref/source/items.h Modified: trunk/crawl-ref/docs/crawl_options.txt =================================================================== --- trunk/crawl-ref/docs/crawl_options.txt 2007-06-30 12:25:35 UTC (rev 1698) +++ trunk/crawl-ref/docs/crawl_options.txt 2007-06-30 14:25:22 UTC (rev 1699) @@ -55,7 +55,7 @@ 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 @@ 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. ----------------- Modified: trunk/crawl-ref/init.txt =================================================================== --- trunk/crawl-ref/init.txt 2007-06-30 12:25:35 UTC (rev 1698) +++ trunk/crawl-ref/init.txt 2007-06-30 14:25:22 UTC (rev 1699) @@ -173,6 +173,7 @@ # 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)\) Modified: trunk/crawl-ref/source/externs.h =================================================================== --- trunk/crawl-ref/source/externs.h 2007-06-30 12:25:35 UTC (rev 1698) +++ trunk/crawl-ref/source/externs.h 2007-06-30 14:25:22 UTC (rev 1699) @@ -1620,6 +1620,10 @@ 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 Modified: trunk/crawl-ref/source/initfile.cc =================================================================== --- trunk/crawl-ref/source/initfile.cc 2007-06-30 12:25:35 UTC (rev 1698) +++ trunk/crawl-ref/source/initfile.cc 2007-06-30 14:25:22 UTC (rev 1699) @@ -719,6 +719,8 @@ 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 @@ 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 @@ 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) Modified: trunk/crawl-ref/source/items.cc =================================================================== --- trunk/crawl-ref/source/items.cc 2007-06-30 12:25:35 UTC (rev 1698) +++ trunk/crawl-ref/source/items.cc 2007-06-30 14:25:22 UTC (rev 1699) @@ -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 @@ will_autopickup = do_pickup; } +// 2 - artifact, 1 - glowing/runed, 0 - mundane +static int item_name_specialness(const item_def& item) +{ + // 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 ); + + if (item.base_type != OBJ_WEAPONS && item.base_type != OBJ_ARMOUR && + item.base_type != OBJ_MISSILES) + return 0; + if (item_type_known(item)) + { + 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); + + 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; + + if ( item_glows || (item_runed && !heav_runed) ) + return 1; + + // 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; + + return 0; +} + /* * Takes keyin as an argument because it will only display a long list of items * if ; is pressed. */ -void item_check(char keyin) +void item_check(bool verbose) { - char item_show[50][ITEMNAME_SIZE]; - char temp_quant[10]; - int counter = 0; - int counter_max = 0; - describe_floor(); - - if (igrd[you.x_pos][you.y_pos] == NON_ITEM && keyin == ';') - { - mpr("There are no items here."); - return; - } - autoinscribe_items(); - origin_set(you.x_pos, you.y_pos); - for ( int objl = igrd[you.x_pos][you.y_pos]; objl != NON_ITEM; - objl = mitm[objl].link ) - { - if ( invisible_to_player(mitm[objl]) ) - continue; + std::ostream& strm = msg::streams(MSGCH_FLOOR_ITEMS); - counter++; + std::vector<const item_def*> items; - if (counter > 45) - { - strcpy(item_show[counter], "Too many items."); - break; - } + item_list_on_square( items, igrd[you.x_pos][you.y_pos], true ); - 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"); - - } - else - { - strcpy(item_show[counter], mitm[objl].name(DESC_NOCAP_A).c_str()); - } - + if (items.size() == 0) + { + if ( verbose ) + strm << "There are no items here." << std::endl; + return; } - counter_max = counter; - counter = 0; - - if (counter_max == 1) + if (items.size() == 1 ) { - mprf("You see here %s.", item_show[counter_max]); // remember 'an'. - - counter++; - counter_max = 0; // to skip next part. + 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() Modified: trunk/crawl-ref/source/items.h =================================================================== --- trunk/crawl-ref/source/items.h 2007-06-30 12:25:35 UTC (rev 1698) +++ trunk/crawl-ref/source/items.h 2007-06-30 14:25:22 UTC (rev 1699) @@ -69,7 +69,7 @@ /* *********************************************************************** * called from: acr * *********************************************************************** */ -void item_check(char keyin); +void item_check(bool verbose); void request_autopickup(bool do_pickup = true); // last updated: 08jun2000 {dlb} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |