summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/shopping.cc
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-27 02:47:16 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-27 02:47:16 -0800
commit2579ebdc853d91e78e58e65c134eff1a18d738e2 (patch)
treec42cf7dfea329d48a7c09cf2f6b38ef5ccc7753a /crawl-ref/source/shopping.cc
parent14f12cc4f9883646957b8acd04d86396d1096685 (diff)
downloadcrawl-ref-2579ebdc853d91e78e58e65c134eff1a18d738e2.tar.gz
crawl-ref-2579ebdc853d91e78e58e65c134eff1a18d738e2.zip
Fix deleting entries from shopping list.
Diffstat (limited to 'crawl-ref/source/shopping.cc')
-rw-r--r--crawl-ref/source/shopping.cc70
1 files changed, 35 insertions, 35 deletions
diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc
index 90419c7ab5..74b15d0ed7 100644
--- a/crawl-ref/source/shopping.cc
+++ b/crawl-ref/source/shopping.cc
@@ -2502,31 +2502,8 @@ void ShoppingListMenu::draw_title()
}
}
-void ShoppingList::display()
+void ShoppingList::fill_out_menu(Menu& shopmenu)
{
- if (list->empty())
- return;
-
- const bool travelable = can_travel_interlevel();
-
- ShoppingListMenu shopmenu;
- shopmenu.set_tag("shop");
- shopmenu.menu_action = travelable ? Menu::ACT_EXECUTE : Menu::ACT_EXAMINE;
- shopmenu.action_cycle = travelable ? Menu::CYCLE_CYCLE : Menu::CYCLE_NONE;
- std::string title = "thing";
-
- MenuEntry *mtitle = new MenuEntry(title, MEL_TITLE);
- // Abuse of the quantity field.
- mtitle->quantity = list->size();
- shopmenu.set_title(mtitle);
-
- // Don't make a menu so tall that we recycle hotkeys on the same page.
- if (list->size() > 52
- && (shopmenu.maxpagesize() > 52 || shopmenu.maxpagesize() == 0))
- {
- shopmenu.set_maxpagesize(52);
- }
-
menu_letter hotkey;
for (unsigned i = 0; i < list->size(); ++i, ++hotkey)
{
@@ -2559,6 +2536,32 @@ void ShoppingList::display()
shopmenu.add_entry(me);
}
+}
+
+void ShoppingList::display()
+{
+ if (list->empty())
+ return;
+
+ const bool travelable = can_travel_interlevel();
+
+ ShoppingListMenu shopmenu;
+ shopmenu.set_tag("shop");
+ shopmenu.menu_action = travelable ? Menu::ACT_EXECUTE : Menu::ACT_EXAMINE;
+ shopmenu.action_cycle = travelable ? Menu::CYCLE_CYCLE : Menu::CYCLE_NONE;
+ std::string title = "thing";
+
+ MenuEntry *mtitle = new MenuEntry(title, MEL_TITLE);
+ // Abuse of the quantity field.
+ mtitle->quantity = list->size();
+ shopmenu.set_title(mtitle);
+
+ // Don't make a menu so tall that we recycle hotkeys on the same page.
+ if (list->size() > 52
+ && (shopmenu.maxpagesize() > 52 || shopmenu.maxpagesize() == 0))
+ {
+ shopmenu.set_maxpagesize(52);
+ }
std::string more_str = make_stringf("<yellow>You have %d gp</yellow>",
you.gold);
@@ -2567,6 +2570,8 @@ void ShoppingList::display()
shopmenu.set_flags( MF_SINGLESELECT | MF_ALWAYS_SHOW_MORE
| MF_ALLOW_FORMATTING );
+ fill_out_menu(shopmenu);
+
std::vector<MenuEntry*> sel;
while (true)
{
@@ -2624,17 +2629,12 @@ void ShoppingList::display()
continue;
}
- if (shopmenu.del_entry(sel[0]))
- {
- list->erase(index);
- delete (sel[0]);
- }
- else
- {
- mpr("ERROR: Unable to delete thing from shopping list!",
- MSGCH_ERROR);
- more();
- }
+ list->erase(index);
+ if (list->size() == 0)
+ break;
+
+ shopmenu.clear();
+ fill_out_menu(shopmenu);
}
else
DEBUGSTR("Invalid menu action type");