summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-26 12:52:59 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-26 12:52:59 +0000
commitff0ecefe2a7e5144776ad262ec501e3c29ba9252 (patch)
tree3c543099e6bdcfebe044aa9cb885f75b6a28e8ef
parent7dff54b82e9751a089128cc512104ddfe40f150d (diff)
downloadcrawl-ref-ff0ecefe2a7e5144776ad262ec501e3c29ba9252.tar.gz
crawl-ref-ff0ecefe2a7e5144776ad262ec501e3c29ba9252.zip
Changed \ to use item-menu code when displaying identified items.
Much cleaner now. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup@143 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/acr.cc3
-rw-r--r--crawl-ref/source/itemname.cc183
-rw-r--r--crawl-ref/source/itemname.h2
-rw-r--r--crawl-ref/source/items.cc2
4 files changed, 37 insertions, 153 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 675109642f..eaf8ffacb6 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1351,8 +1351,7 @@ static void do_action( command_type cmd ) {
break;
case CMD_DISPLAY_KNOWN_OBJECTS:
- check_item_knowledge(); //nothing = check_item_knowledge();
- redraw_screen();
+ check_item_knowledge();
break;
#ifdef ALLOW_DESTROY_ITEM_COMMAND
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 69f46865fb..a8e3d9acea 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -1968,168 +1968,53 @@ char get_ident_type(char cla, int ty)
}
} // end get_ident_type()
-unsigned char check_item_knowledge(void)
+void check_item_knowledge()
{
- char st_pass[ITEMNAME_SIZE] = "";
- int i, j;
- char lines = 0;
- unsigned char anything = 0;
- int ft = 0;
- int max = 0;
- int yps = 0;
- int inv_count = 0;
- unsigned char ki = 0;
-
- const int num_lines = get_number_of_lines();
-
-#ifdef DOS_TERM
- char buffer[2400];
-
- gettext(35, 1, 80, 25, buffer);
-#endif
-
-#ifdef DOS_TERM
- window(35, 1, 80, 25);
-#endif
-
- clrscr();
-
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 30; j++)
- {
- if (id[i][j] == ID_KNOWN_TYPE)
- inv_count++;
+ int i,j;
+
+ std::vector<item_def*> items;
+
+ int idx_to_objtype[4] = { OBJ_WANDS, OBJ_SCROLLS,
+ OBJ_JEWELLERY, OBJ_POTIONS };
+ int idx_to_maxtype[4] = { NUM_WANDS, NUM_SCROLLS,
+ NUM_JEWELLERY, NUM_POTIONS };
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < idx_to_maxtype[i]; j++) {
+ if (id[i][j] == ID_KNOWN_TYPE) {
+ item_def* ptmp = new item_def;
+ if ( ptmp != 0 ) {
+ ptmp->base_type = idx_to_objtype[i];
+ ptmp->sub_type = j;
+ ptmp->colour = 1;
+ items.push_back(ptmp);
+ }
+ }
}
}
- if (inv_count == 0)
- {
- cprintf("You don't recognise anything yet!");
- if (getch() == 0)
- getch();
- goto putty;
- }
-
- textcolor(BLUE);
- cprintf(" You recognise:");
- textcolor(LIGHTGREY);
- lines++;
+ if (items.empty())
+ mpr("You don't recognise anything yet!");
+ else {
- for (i = 0; i < 4; i++)
- {
- switch (i)
- {
- case IDTYPE_WANDS:
- ft = OBJ_WANDS;
- max = NUM_WANDS;
- break;
- case IDTYPE_SCROLLS:
- ft = OBJ_SCROLLS;
- max = NUM_SCROLLS;
- break;
- case IDTYPE_JEWELLERY:
- ft = OBJ_JEWELLERY;
- max = NUM_JEWELLERY;
- break;
- case IDTYPE_POTIONS:
- ft = OBJ_POTIONS;
- max = NUM_POTIONS;
- break;
- }
-
- for (j = 0; j < max; j++)
- {
- if (lines > num_lines - 2 && inv_count > 0)
- {
- gotoxy(1, num_lines);
- cprintf("-more-");
-
- ki = getch();
-
- if (ki == ESCAPE)
- {
#ifdef DOS_TERM
- puttext(35, 1, 80, 25, buffer);
+ char buffer[4800];
+ gettext(1, 1, 80, 25, buffer);
+ window(1, 1, 80, 25);
#endif
- return ESCAPE;
- }
- if (ki >= 'A' && ki <= 'z')
- {
-#ifdef DOS_TERM
- puttext(35, 1, 80, 25, buffer);
-#endif
- return ki;
- }
-
- if (ki == 0)
- ki = getch();
-
- lines = 0;
- clrscr();
- gotoxy(1, 1);
- anything = 0;
- }
-
- int ident_level = get_ident_type( ft, j );
-
- if (ident_level == ID_KNOWN_TYPE)
- {
- anything++;
-
- if (lines > 0)
- cprintf(EOL);
- lines++;
- cprintf(" ");
-
- yps = wherey();
-
- // item_name now requires a "real" item, so we'll create a tmp
- item_def tmp;// = { ft, j, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
- tmp.base_type = ft;
- tmp.sub_type = j;
- tmp.colour = 1;
-
- item_name( tmp, DESC_PLAIN, st_pass );
- cprintf(st_pass);
+ clrscr();
+ select_items( items, "You recognise:", true );
+ for ( std::vector<item_def*>::iterator iter = items.begin();
+ iter != items.end(); ++iter )
+ delete *iter;
- inv_count--;
-
- if (wherey() != yps)
- lines++;
- }
- } // end of j loop
- }
-
- if (anything > 0)
- {
- ki = getch();
- //ki = getch();
- //ki = anything;
-
- if (ki >= 'A' && ki <= 'z')
- {
#ifdef DOS_TERM
- puttext(35, 1, 80, 25, buffer);
+ puttext(1, 1, 80, 25, buffer);
#endif
- return ki;
- }
- if (ki == 0)
- ki = getch();
-#ifdef DOS_TERM
- puttext(35, 1, 80, 25, buffer);
-#endif
- return anything;
+ redraw_screen();
}
-
- putty:
-#ifdef DOS_TERM
- puttext(35, 1, 80, 25, buffer);
-#endif
-
- return ki;
} // end check_item_knowledge()
diff --git a/crawl-ref/source/itemname.h b/crawl-ref/source/itemname.h
index 36a9b6f72d..e61fa3c568 100644
--- a/crawl-ref/source/itemname.h
+++ b/crawl-ref/source/itemname.h
@@ -43,7 +43,7 @@ int property( const item_def &item, int prop_type );
/* ***********************************************************************
* called from: acr
* *********************************************************************** */
-unsigned char check_item_knowledge(void);
+void check_item_knowledge(void);
/* ***********************************************************************
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 2c78c816a7..3198590988 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -477,7 +477,7 @@ static void item_cleanup(item_def &item)
item.quantity = 0;
item.orig_place = 0;
item.orig_monnum = 0;
- item.inscription = std::string();
+ item.inscription.clear();
}
void destroy_item( int dest )