From 0d2fd7a12bdc1fba93f2ee1cb5b35abad877ade5 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sun, 2 Sep 2007 12:40:44 +0000 Subject: Implemented patch 1773718 (improved wizard commands) and patch 1783003 (ímproved menu sorting), both by zelgadis. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2041 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/invent.cc | 102 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 95 insertions(+), 7 deletions(-) (limited to 'crawl-ref/source/invent.cc') diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index 057f4c8e7b..c1cc52102c 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -39,6 +39,7 @@ #include "stuff.h" #include "view.h" #include "menu.h" +#include "randart.h" /////////////////////////////////////////////////////////////////////////////// // Inventory menu shenanigans @@ -108,6 +109,62 @@ const bool InvEntry::is_item_cursed() const return (item_ident(*item, ISFLAG_KNOW_CURSE) && item_cursed(*item)); } +const bool InvEntry::is_item_glowing() const +{ + return (!item_ident(*item, ISFLAG_KNOW_TYPE) + && (get_equip_desc(*item) + || (is_artefact(*item) + && (item->base_type == OBJ_WEAPONS + || item->base_type == OBJ_MISSILES + || item->base_type == OBJ_ARMOUR)))); +} + +const bool InvEntry::is_item_ego() const +{ + return (item_ident(*item, ISFLAG_KNOW_TYPE) && !is_artefact(*item) + && item->special != 0 + && (item->base_type == OBJ_WEAPONS + || item->base_type == OBJ_MISSILES + || item->base_type == OBJ_ARMOUR)); +} + +const bool InvEntry::is_item_art() const +{ + return (item_ident(*item, ISFLAG_KNOW_TYPE) && is_artefact(*item)); +} + +const bool InvEntry::is_item_equipped() const +{ + if (item->link == -1 || item->x != -1 || item->y != -1) + return(false); + + for (int i = 0; i < NUM_EQUIP; i++) + if (item->link == you.equip[i]) + return (true); + + return (false); +} + +const int InvEntry::item_freshness() const +{ + if (item->base_type != OBJ_FOOD || item->sub_type != FOOD_CHUNK) + return 0; + + int freshness = item->special - 100; + + // Ensure that chunk freshness is never zero, since zero means + // that the item isn't a chunk. + if (freshness >= 0) + freshness++; + + // Invert if not a ghoul, so that the freshest chunks will go + // at the top. + if (you.species != SP_GHOUL) + freshness *= -1; + + return freshness; +} + std::string InvEntry::get_text() const { std::ostringstream tstr; @@ -323,11 +380,37 @@ int sort_item_slot(const InvEntry *a) { return a->item->link; } + +int sort_item_freshness(const InvEntry *a) +{ + return a->item_freshness(); +} + bool sort_item_curse(const InvEntry *a) { return a->is_item_cursed(); } +bool sort_item_glowing(const InvEntry *a) +{ + return !a->is_item_glowing(); +} + +bool sort_item_ego(const InvEntry *a) +{ + return !a->is_item_ego(); +} + +bool sort_item_art(const InvEntry *a) +{ + return !a->is_item_art(); +} + +bool sort_item_equipped(const InvEntry *a) +{ + return !a->is_item_equipped(); +} + static bool compare_invmenu_items(const InvEntry *a, const InvEntry *b, const item_sort_comparators *cmps) { @@ -368,14 +451,19 @@ void init_item_sort_comparators(item_sort_comparators &list, item_sort_fn cmp; } cmp_map[] = { - { "basename", compare_item_str }, - { "qualname", compare_item_str }, - { "fullname", compare_item_str }, - { "curse", compare_item }, - { "qty", compare_item }, - { "slot", compare_item }, + { "basename", compare_item_str }, + { "qualname", compare_item_str }, + { "fullname", compare_item_str }, + { "curse", compare_item }, + { "glowing", compare_item }, + { "ego", compare_item }, + { "art", compare_item }, + { "equipped", compare_item }, + { "qty", compare_item }, + { "slot", compare_item }, + { "freshness", compare_item } }; - + list.clear(); std::vector cmps = split_string(",", set); for (int i = 0, size = cmps.size(); i < size; ++i) -- cgit v1.2.3-54-g00ecf