*** store_org.c Fri Nov 16 00:07:37 2007 --- store.c Wed Nov 21 10:40:40 2007 *************** *** 299,305 **** --- 299,313 ---- }; + #define STORE_GOLD_OFFSET 5 + static int get_items_per_page() + { + int w, h, ipp; + Term_get_size(&w, &h); + ipp = min(h-6-2-4, 'z'-'a'+1);/*6:top, 1:more, 1:money, 4:commands*/ + return ipp; + } /* * Successful haggle. *************** *** 2218,2228 **** int maxwid = 75; /* Get the item */ o_ptr = &st_ptr->stock[pos]; /* Get the "offset" */ ! i = (pos % 12); /* Label it, clear the line --(-- */ (void)sprintf(out_val, "%c) ", I2A(i)); --- 2226,2243 ---- int maxwid = 75; + int w, h; + int ipp; + /* Get Screen size*/ + Term_get_size(&w, &h); + ipp = get_items_per_page(); + /* Get the item */ o_ptr = &st_ptr->stock[pos]; + /* Get the "offset" */ ! i = (pos-store_top) % ipp; /* Label it, clear the line --(-- */ (void)sprintf(out_val, "%c) ", I2A(i)); *************** *** 2248,2254 **** /* Describe an item in the home */ if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) { ! maxwid = 75; /* Leave room for weights, if necessary -DRS- */ if (show_weights) maxwid -= 10; --- 2263,2269 ---- /* Describe an item in the home */ if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) { ! maxwid = w;/*extend width*/ /* Leave room for weights, if necessary -DRS- */ if (show_weights) maxwid -= 10; *************** *** 2265,2274 **** int wgt = o_ptr->weight; #ifdef JP sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) ); ! put_str(out_val, i+6, 67); #else (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10); ! put_str(out_val, i+6, 68); #endif } --- 2280,2289 ---- int wgt = o_ptr->weight; #ifdef JP sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) ); ! put_str(out_val, i+6, w-9); #else (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10); ! put_str(out_val, i+6, w-9); #endif } *************** *** 2354,2362 **** static void display_inventory(void) { int i, k; ! /* Display the next 12 items */ ! for (k = 0; k < 12; k++) { /* Do not display "dead" items */ if (store_top + k >= st_ptr->stock_num) break; --- 2369,2380 ---- static void display_inventory(void) { int i, k; + int ipp; + + ipp = get_items_per_page(); ! /* Display the next items */ ! for (k = 0; k < ipp; k++) { /* Do not display "dead" items */ if (store_top + k >= st_ptr->stock_num) break; *************** *** 2366,2372 **** } /* Erase the extra lines and the "more" prompt */ ! for (i = k; i < 13; i++) prt("", i + 6, 0); /* Assume "no current page" */ #ifdef JP --- 2384,2390 ---- } /* Erase the extra lines and the "more" prompt */ ! for (i = k; i < ipp+1; i++) prt("", i + 6, 0); /* Assume "no current page" */ #ifdef JP *************** *** 2377,2383 **** /* Visual reminder of "more items" */ ! if (st_ptr->stock_num > 12) { /* Show "more" reminder (after the last item) */ #ifdef JP --- 2395,2401 ---- /* Visual reminder of "more items" */ ! if (st_ptr->stock_num > ipp) { /* Show "more" reminder (after the last item) */ #ifdef JP *************** *** 2390,2398 **** /* Indicate the "current page" */ /* Trailing spaces are to display (Page xx) and (Page x) */ #ifdef JP ! put_str(format("(%dページ) ", store_top/12 + 1), 5, 20); #else ! put_str(format("(Page %d) ", store_top/12 + 1), 5, 20); #endif } --- 2408,2416 ---- /* Indicate the "current page" */ /* Trailing spaces are to display (Page xx) and (Page x) */ #ifdef JP ! put_str(format("(%dページ) ", store_top/ipp + 1), 5, 20); #else ! put_str(format("(Page %d) ", store_top/ipp + 1), 5, 20); #endif } *************** *** 2405,2420 **** static void store_prt_gold(void) { char out_val[64]; #ifdef JP ! prt("手持ちのお金: ", 19, 53); #else ! prt("Gold Remaining: ", 19, 53); #endif sprintf(out_val, "%9ld", (long)p_ptr->au); ! prt(out_val, 19, 68); } --- 2423,2440 ---- static void store_prt_gold(void) { char out_val[64]; + int w, h; + Term_get_size(&w, &h); #ifdef JP ! prt("手持ちのお金: ", h-STORE_GOLD_OFFSET, w-25); #else ! prt("Gold Remaining: ", h-STORE_GOLD_OFFSET, w-25); #endif sprintf(out_val, "%9ld", (long)p_ptr->au); ! prt(out_val, h-STORE_GOLD_OFFSET, w-10); } *************** *** 2424,2429 **** --- 2444,2450 ---- static void display_store(void) { char buf[80]; + int w, h; /* Clear screen */ *************** *** 2451,2460 **** /* If showing weights, show label */ if (show_weights) { #ifdef JP ! put_str("重さ", 5, 72); #else ! put_str("Weight", 5, 70); #endif } --- 2472,2482 ---- /* If showing weights, show label */ if (show_weights) { + Term_get_size(&w, &h); #ifdef JP ! put_str("重さ", 5, w-5); #else ! put_str("Weight", 5, w-7); #endif } *************** *** 3346,3351 **** --- 3368,3376 ---- char out_val[160]; + int ipp; + ipp = get_items_per_page(); + if (cur_store_num == STORE_MUSEUM) { *************** *** 3382,3388 **** i = (st_ptr->stock_num - store_top); /* And then restrict it to the current page */ ! if (i > 12) i = 12; /* Prompt */ #ifdef JP --- 3407,3413 ---- i = (st_ptr->stock_num - store_top); /* And then restrict it to the current page */ ! i = min(i, get_items_per_page()); /* Prompt */ #ifdef JP *************** *** 3685,3691 **** else if (st_ptr->stock_num != i) { /* Pick the correct screen */ ! if (store_top >= st_ptr->stock_num) store_top -= 12; /* Redraw everything */ display_inventory(); --- 3710,3716 ---- else if (st_ptr->stock_num != i) { /* Pick the correct screen */ ! if (store_top >= st_ptr->stock_num) store_top -= ipp; /* Redraw everything */ display_inventory(); *************** *** 3764,3770 **** if (st_ptr->stock_num == 0) store_top = 0; /* Nothing left on that screen */ ! else if (store_top >= st_ptr->stock_num) store_top -= 12; /* Redraw everything */ display_inventory(); --- 3789,3795 ---- if (st_ptr->stock_num == 0) store_top = 0; /* Nothing left on that screen */ ! else if (store_top >= st_ptr->stock_num) store_top -= ipp; /* Redraw everything */ display_inventory(); *************** *** 3786,3791 **** --- 3811,3817 ---- int choice; int item, item_pos; int amt; + int ipp; s32b price, value, dummy; *************** *** 3798,3803 **** --- 3824,3830 ---- char o_name[MAX_NLEN]; + ipp = get_items_per_page(); /* Prepare a prompt */ if (cur_store_num == STORE_HOME) *************** *** 4070,4076 **** /* Re-display if item is now in store */ if (item_pos >= 0) { ! store_top = (item_pos / 12) * 12; display_inventory(); } } --- 4097,4103 ---- /* Re-display if item is now in store */ if (item_pos >= 0) { ! store_top = (item_pos / ipp) * ipp; display_inventory(); } } *************** *** 4134,4140 **** /* Update store display */ if (item_pos >= 0) { ! store_top = (item_pos / 12) * 12; display_inventory(); } } --- 4161,4167 ---- /* Update store display */ if (item_pos >= 0) { ! store_top = (item_pos / ipp) * ipp; display_inventory(); } } *************** *** 4167,4173 **** /* Update store display */ if (item_pos >= 0) { ! store_top = (item_pos / 12) * 12; display_inventory(); } } --- 4194,4200 ---- /* Update store display */ if (item_pos >= 0) { ! store_top = (item_pos / ipp) * ipp; display_inventory(); } } *************** *** 4224,4230 **** i = (st_ptr->stock_num - store_top); /* And then restrict it to the current page */ ! if (i > 12) i = 12; /* Prompt */ #ifdef JP --- 4251,4258 ---- i = (st_ptr->stock_num - store_top); /* And then restrict it to the current page */ ! i = min(i, get_items_per_page()); ! /* Prompt */ #ifdef JP *************** *** 4307,4313 **** i = st_ptr->stock_num - store_top; /* And then restrict it to the current page */ ! if (i > 12) i = 12; /* Prompt */ #ifdef JP --- 4335,4342 ---- i = st_ptr->stock_num - store_top; /* And then restrict it to the current page */ ! i = min(i, get_items_per_page()); ! /* Prompt */ #ifdef JP *************** *** 4355,4361 **** if (st_ptr->stock_num == 0) store_top = 0; /* Nothing left on that screen */ ! else if (store_top >= st_ptr->stock_num) store_top -= 12; /* Redraw everything */ display_inventory(); --- 4384,4390 ---- if (st_ptr->stock_num == 0) store_top = 0; /* Nothing left on that screen */ ! else if (store_top >= st_ptr->stock_num) store_top -= get_items_per_page(); /* Redraw everything */ display_inventory(); *************** *** 4380,4385 **** --- 4409,4415 ---- */ static void store_process_command(void) { + int ipp = get_items_per_page(); #ifdef ALLOW_REPEAT /* TNB */ /* Handle repeating the last command */ *************** *** 4406,4412 **** /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */ case '-': { ! if (st_ptr->stock_num <= 12) { #ifdef JP msg_print("これで全部です。"); #else --- 4436,4442 ---- /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */ case '-': { ! if (st_ptr->stock_num <= ipp) { #ifdef JP msg_print("これで全部です。"); #else *************** *** 4414,4424 **** #endif } else{ ! store_top -= 12; if ( store_top < 0 ) ! store_top = ((st_ptr->stock_num - 1 )/12) * 12; if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) ) ! if ( store_top >= 12 ) store_top = 12; display_inventory(); } break; --- 4444,4454 ---- #endif } else{ ! store_top -= ipp; if ( store_top < 0 ) ! store_top = ((st_ptr->stock_num - 1 )/ipp) * ipp; if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) ) ! if ( store_top >= ipp ) store_top = ipp; display_inventory(); } break; *************** *** 4427,4433 **** /* Browse */ case ' ': { ! if (st_ptr->stock_num <= 12) { #ifdef JP msg_print("これで全部です。"); --- 4457,4463 ---- /* Browse */ case ' ': { ! if (st_ptr->stock_num <= ipp) { #ifdef JP msg_print("これで全部です。"); *************** *** 4438,4444 **** } else { ! store_top += 12; /* * 隠しオプション(powerup_home)がセットされていないときは * 我が家では 2 ページまでしか表示しない --- 4468,4474 ---- } else { ! store_top += ipp; /* * 隠しオプション(powerup_home)がセットされていないときは * 我が家では 2 ページまでしか表示しない *************** *** 4772,4777 **** --- 4802,4809 ---- int i; cave_type *c_ptr; bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */ + int w,h,row,ipp; + ipp = get_items_per_page(); /* Access the player grid */ *************** *** 4871,4900 **** /* Interact with player */ while (!leave_store) { /* Hack -- Clear line 1 */ prt("", 1, 0); /* Clear */ ! clear_from(20); /* Basic commands */ #ifdef JP ! prt(" ESC) 建物から出る", 21, 0); #else ! prt(" ESC) Exit from Building.", 21, 0); #endif /* Browse if necessary */ ! if (st_ptr->stock_num > 12) { #ifdef JP ! prt(" -)前ページ", 22, 0); ! prt(" スペース) 次ページ", 23, 0); #else ! prt(" -) Previous page", 22, 0); ! prt(" SPACE) Next page", 23, 0); #endif } --- 4903,4934 ---- /* Interact with player */ while (!leave_store) { + Term_get_size(&w, &h); /* Hack -- Clear line 1 */ prt("", 1, 0); /* Clear */ ! row = h-4;/* use 4 lines for commands */ ! clear_from(row); /* Basic commands */ #ifdef JP ! prt(" ESC) 建物から出る", row+1, 0); #else ! prt(" ESC) Exit from Building.", row+1, 0); #endif /* Browse if necessary */ ! if (st_ptr->stock_num > ipp) { #ifdef JP ! prt(" -)前ページ", row+2, 0); ! prt(" スペース) 次ページ", row+3, 0); #else ! prt(" -) Previous page", row+2, 0); ! prt(" SPACE) Next page", row+3, 0); #endif } *************** *** 4903,4915 **** if (cur_store_num == STORE_HOME) { #ifdef JP ! prt("g) アイテムを取る", 21, 27); ! prt("d) アイテムを置く", 22, 27); ! prt("x) 家のアイテムを調べる", 23,27); ! #else ! prt("g) Get an item.", 21, 27); ! prt("d) Drop an item.", 22, 27); ! prt("x) eXamine an item in the home.", 23,27); #endif } --- 4937,4949 ---- if (cur_store_num == STORE_HOME) { #ifdef JP ! prt("g) アイテムを取る", row+1, 27); ! prt("d) アイテムを置く", row+2, 27); ! prt("x) 家のアイテムを調べる", row+3,27); ! #else ! prt("g) Get an item.", row+1, 27); ! prt("d) Drop an item.", row+2, 27); ! prt("x) eXamine an item in the home.", row+3,27); #endif } *************** *** 4917,4929 **** else if (cur_store_num == STORE_MUSEUM) { #ifdef JP ! prt("d) アイテムを置く", 21, 27); ! prt("r) アイテムの展示をやめる", 22, 27); ! prt("x) 博物館のアイテムを調べる", 23, 27); ! #else ! prt("d) Drop an item.", 21, 27); ! prt("r) order to Remove an item.", 22, 27); ! prt("x) eXamine an item in the museum.", 23, 27); #endif } --- 4951,4963 ---- else if (cur_store_num == STORE_MUSEUM) { #ifdef JP ! prt("d) アイテムを置く", row+1, 27); ! prt("r) アイテムの展示をやめる", row+2, 27); ! prt("x) 博物館のアイテムを調べる", row+3, 27); ! #else ! prt("d) Drop an item.", row+1, 27); ! prt("r) order to Remove an item.", row+2, 27); ! prt("x) eXamine an item in the museum.", row+3, 27); #endif } *************** *** 4931,4976 **** else { #ifdef JP ! prt("p) 商品を買う", 21, 30); ! prt("s) アイテムを売る", 22, 30); ! prt("x) 商品を調べる", 23,30); ! #else ! prt("p) Purchase an item.", 21, 30); ! prt("s) Sell an item.", 22, 30); ! prt("x) eXamine an item in the shop", 23,30); #endif } #ifdef JP /* 基本的なコマンドの追加表示 */ ! prt("i/e) 持ち物/装備の一覧", 21, 56); if (rogue_like_commands) { ! prt("w/T) 装備する/はずす", 22, 56); } else { ! prt("w/t) 装備する/はずす", 22, 56); } #else ! prt("i/e) Inventry/Equipment list", 21, 56); if (rogue_like_commands) { ! prt("w/T) Wear/Take off equipment", 22, 56); } else { ! prt("w/t) Wear/Take off equipment", 22, 56); } #endif /* Prompt */ #ifdef JP ! prt("コマンド:", 20, 0); #else ! prt("You may: ", 20, 0); #endif --- 4965,5010 ---- else { #ifdef JP ! prt("p) 商品を買う", row+1, 30); ! prt("s) アイテムを売る", row+2, 30); ! prt("x) 商品を調べる", row+3,30); ! #else ! prt("p) Purchase an item.", row+1, 30); ! prt("s) Sell an item.", row+2, 30); ! prt("x) eXamine an item in the shop", row+3,30); #endif } #ifdef JP /* 基本的なコマンドの追加表示 */ ! prt("i/e) 持ち物/装備の一覧", row+1, 56); if (rogue_like_commands) { ! prt("w/T) 装備する/はずす", row+2, 56); } else { ! prt("w/t) 装備する/はずす", row+2, 56); } #else ! prt("i/e) Inventry/Equipment list", row+1, 56); if (rogue_like_commands) { ! prt("w/T) Wear/Take off equipment", row+2, 56); } else { ! prt("w/t) Wear/Take off equipment", row+2, 56); } #endif /* Prompt */ #ifdef JP ! prt("コマンド:", row+0, 0); #else ! prt("You may: ", row+0, 0); #endif *************** *** 5088,5094 **** /* Redraw the home */ if (item_pos >= 0) { ! store_top = (item_pos / 12) * 12; display_inventory(); } } --- 5122,5128 ---- /* Redraw the home */ if (item_pos >= 0) { ! store_top = (item_pos / ipp) * ipp; display_inventory(); } }