--- C:/Users/pmcilroy/AppData/Local/Temp/store-revBASE.svn002.tmp.c Sat Jul 10 18:04:10 2010 +++ C:/Projects/Exp/angband/src/store.c Sat Jul 10 18:00:58 2010 @@ -48,21 +48,13 @@ /* State flags */ -#define STORE_GOLD_CHANGE 0x01 -#define STORE_FRAME_CHANGE 0x02 #define STORE_SHOW_HELP 0x04 -#define STORE_KEEP_PROMPT 0x08 -/* Compound flag for the initial display of a store */ -#define STORE_INIT_CHANGE (STORE_FRAME_CHANGE | STORE_GOLD_CHANGE) - - - /* Some local constants */ #define STORE_TURNOVER 9 /* Normal shop turnover, per day */ #define STORE_OBJ_LEVEL 5 /* Magic Level for normal stores */ @@ -1854,24 +1846,15 @@ */ static void store_redraw(void) { - if (store_flags & (STORE_FRAME_CHANGE)) - { - store_display_frame(); + store_display_frame(); - if (store_flags & STORE_SHOW_HELP) - store_display_help(); - else - prt("Press '?' for help.", scr_places_y[LOC_HELP_PROMPT], 1); + if (store_flags & STORE_SHOW_HELP) + store_display_help(); + else + prt("Press '?' for help.", scr_places_y[LOC_HELP_PROMPT], 1); - store_flags &= ~(STORE_FRAME_CHANGE); - } - - if (store_flags & (STORE_GOLD_CHANGE)) - { - prt(format("Gold Remaining: %9ld", (long)p_ptr->au), + prt(format("Gold Remaining: %9ld", (long)p_ptr->au), scr_places_y[LOC_AU], scr_places_x[LOC_AU]); - store_flags &= ~(STORE_GOLD_CHANGE); - } } @@ -2095,9 +2078,6 @@ /* Spend the money */ p_ptr->au -= price; - /* Update the display */ - store_flags |= STORE_GOLD_CHANGE; - /* ID objects on buy */ object_notice_everything(i_ptr); @@ -2148,7 +2128,6 @@ /* Shuffle the store */ store_shuffle(this_store); - store_flags |= STORE_FRAME_CHANGE; } /* Maintain */ @@ -2280,7 +2259,6 @@ { /* Tell the user */ msg_print("You do not have enough gold for this item."); - store_flags |= STORE_KEEP_PROMPT; /* Abort now */ return FALSE; @@ -2319,7 +2297,6 @@ if (!inven_carry_okay(i_ptr)) { msg_print("You cannot carry that many items."); - store_flags |= STORE_KEEP_PROMPT; return FALSE; } @@ -2348,14 +2325,12 @@ if (!response) return FALSE; cmd_insert(CMD_BUY, item, amt); - store_flags |= STORE_KEEP_PROMPT; } /* Home is much easier */ else { cmd_insert(CMD_RETRIEVE, item, amt); - store_flags |= STORE_KEEP_PROMPT; } /* Not kicked out */ @@ -2426,9 +2401,6 @@ /* Get some money */ p_ptr->au += price; - /* Update the display */ - store_flags |= STORE_GOLD_CHANGE; - /* Update the auto-history if selling an artifact that was previously un-IDed. (Ouch!) */ if (artifact_p(o_ptr)) history_add_artifact(o_ptr->name1, TRUE); @@ -2590,7 +2562,6 @@ p_ptr->command_cmd = 'd'; if (!get_item(&item, prompt, reject, get_mode)) { - store_flags |= STORE_KEEP_PROMPT; return; } @@ -2602,7 +2573,6 @@ { /* Oops */ msg_print("Hmmm, it seems to be cursed."); - store_flags |= STORE_KEEP_PROMPT; /* Nope */ return; @@ -2619,7 +2589,6 @@ if (!store_check_num(this_store, i_ptr)) { - store_flags |= STORE_KEEP_PROMPT; if (this_store == STORE_HOME) msg_print("Your home is full."); @@ -2655,7 +2624,6 @@ cmd_insert(CMD_SELL, item, amt); - store_flags |= STORE_KEEP_PROMPT; } /* Player is at home */ @@ -2746,7 +2714,6 @@ /* Give a message */ msg_print("Your pack overflows!"); - store_flags |= STORE_KEEP_PROMPT; /* Get local object */ i_ptr = &object_type_body; @@ -2830,7 +2797,6 @@ case KTRL('R'): { Term_clear(); - store_flags |= (STORE_FRAME_CHANGE | STORE_GOLD_CHANGE); command_processed = TRUE; break; } @@ -2961,9 +2927,6 @@ else store_flags |= STORE_SHOW_HELP; - /* Redisplay */ - store_flags |= STORE_INIT_CHANGE; - command_processed = TRUE; break; } @@ -3058,8 +3021,6 @@ p_ptr->command_new = 0; - - /*** Display ***/ /* Save current screen (ie. dungeon) */ @@ -3073,17 +3034,32 @@ const menu_iter *cur_menu = &store_menu; menu_type menu; - ui_event_data evt = EVENT_EMPTY; int cursor = 0; store_type *st_ptr = &store[this_store]; /* Wipe the menu and set it up */ WIPE(&menu, menu); - menu.flags = MN_DBL_TAP; - /* Calculate the positions of things and redraw */ - store_flags = STORE_INIT_CHANGE; + /* Roguelike */ + if (OPT(rogue_like_commands)) + { + /* These two can't intersect! */ + menu.cmd_keys = "\n\x04\x10\r?={}~CEIPTdegilpswx\x8B\x8C"; /* \x10 = ^p , \x04 = ^D */ + menu.selections = "abcfmnoqrtuvyz13456790ABDFGH"; + } + + /* Original */ + else + { + /* These two can't intersect! */ + menu.cmd_keys = "\n\x010\r?={}~CEIbdegiklpstw\x8B\x8C"; /* \x10 = ^p */ + menu.selections = "acfhmnoqruvxyz13456790ABDFGH"; + } + + /* Init the menu structure */ + menu_init(&menu, MN_SKIN_SCROLL, cur_menu, &items_region); + store_display_recalc(); store_redraw(); @@ -3094,84 +3070,48 @@ /* Loop */ while (!leave) { - /* As many rows in the menus as there are items in the store */ - menu.count = st_ptr->stock_num; + ui_event_type evt = EVT_MOVE; - /* Roguelike */ - if (OPT(rogue_like_commands)) - { - /* These two can't intersect! */ - menu.cmd_keys = "\n\x04\x10\r?={}~CEIPTdegilpswx\x8B\x8C"; /* \x10 = ^p , \x04 = ^D */ - menu.selections = "abcfmnoqrtuvyz13456790ABDFGH"; - } + items_region.page_rows = scr_places_y[LOC_MORE] - scr_places_y[LOC_ITEMS_START]; + menu_layout(&menu, &items_region); - /* Original */ - else + if (menu.count != st_ptr->stock_num) { - /* These two can't intersect! */ - menu.cmd_keys = "\n\x010\r?={}~CEIbdegiklpstw\x8B\x8C"; /* \x10 = ^p */ - menu.selections = "acfhmnoqruvxyz13456790ABDFGH"; + /* As many rows in the menus as there are items in the store */ + menu.count = st_ptr->stock_num; + if (menu.count > items_region.page_rows) + menu.prompt = " -more-"; + else + menu.prompt = NULL; + /* Keep the cursor in range of the stock */ + if (cursor < 0 || cursor >= menu.count) + cursor = menu.count - 1; } - /* Keep the cursor in range of the stock */ - if (cursor < 0 || cursor >= menu.count) - cursor = menu.count - 1; - - items_region.page_rows = scr_places_y[LOC_MORE] - scr_places_y[LOC_ITEMS_START]; - - /* Init the menu structure */ - menu_init(&menu, MN_SKIN_SCROLL, cur_menu, &items_region); - - if (menu.count > items_region.page_rows) - menu.prompt = " -more-"; - else - menu.prompt = NULL; - - menu_layout(&menu, &menu.boundary); - - evt.type = EVT_MOVE; - /* Get a selection/action */ - while (evt.type == EVT_MOVE) + while (evt & (EVT_MOVE | EVT_SELECT)) { - evt = menu_select(&menu, &cursor, EVT_MOVE); - if (store_flags & STORE_KEEP_PROMPT) - { - /* Unset so that the prompt is cleared next time */ - store_flags &= ~STORE_KEEP_PROMPT; - } - else - { - /* Clear the prompt */ - prt("", 0, 0); - } + /* Clear the prompt */ + prt("", 0, 0); + evt = menu_select(&menu, &cursor, EVT_MOVE).type; } - if (evt.key == ESCAPE || evt.type == EVT_BACK) + if (evt == EVT_ESCAPE || evt == EVT_BACK) { leave = TRUE; } - else if (evt.type == EVT_RESIZE) - { - /* Resize event */ - store_display_recalc(); - store_redraw(); - } - else - { - /* Display the store */ - store_display_recalc(); - store_redraw(); - /* Notice and handle stuff */ - notice_stuff(); - handle_stuff(); + /* Notice and handle stuff */ + notice_stuff(); + handle_stuff(); - /* XXX Pack Overflow */ - if (inventory[INVEN_MAX_PACK].k_idx) - leave = store_overflow(); - } + /* XXX Pack Overflow */ + if (inventory[INVEN_MAX_PACK].k_idx) + leave = store_overflow(); + store_display_recalc(); + store_redraw(); + msg_flag = FALSE; }