7 #include "inventory/floor-item-getter.h"
8 #include "core/stuff-handler.h"
9 #include "floor/floor-object.h"
10 #include "floor/floor.h"
11 #include "game-option/input-options.h"
12 #include "game-option/option-flags.h"
13 #include "game-option/text-display-options.h"
14 #include "grid/grid.h"
15 #include "inventory/inventory-util.h"
16 #include "inventory/player-inventory.h" // todo 相互依存している.
17 #include "io/command-repeater.h"
18 #include "io/input-key-acceptor.h"
19 #include "io/input-key-requester.h"
20 #include "main/sound-of-music.h"
21 #include "object/item-tester-hooker.h"
22 #include "object/item-use-flags.h"
23 #include "object/object-info.h"
24 #include "term/gameterm.h"
25 #include "term/screen-processor.h"
26 #include "util/int-char-converter.h"
27 #include "view/display-messages.h"
30 * @brief オブジェクト選択の汎用関数(床上アイテム用) /
31 * Let the user select an item, save its "index"
32 * @param cp 選択したオブジェクトのIDを返す。
33 * @param pmt 選択目的のメッセージ
34 * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
35 * @param mode オプションフラグ
36 * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
38 bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode, tval_type tval)
40 char n1 = ' ', n2 = ' ', which = ' ';
48 bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
49 bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
50 bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
51 bool force = (mode & USE_FORCE) ? TRUE : FALSE;
52 bool allow_equip = FALSE;
53 bool allow_inven = FALSE;
54 bool allow_floor = FALSE;
58 ITEM_NUMBER floor_num;
59 OBJECT_IDX floor_list[23];
61 TERM_LEN min_width = 0;
62 int menu_line = (use_menu ? 1 : 0);
65 static char prev_tag = '\0';
67 if (repeat_pull(cp)) {
68 if (force && (*cp == INVEN_FORCE)) {
70 item_tester_hook = NULL;
73 } else if (floor && (*cp < 0)) {
74 if (prev_tag && command_cmd) {
75 floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval);
76 if (get_tag_floor(owner_ptr->current_floor_ptr, &k, prev_tag, floor_list, floor_num)) {
77 (*cp) = 0 - floor_list[k];
79 item_tester_hook = NULL;
85 } else if (item_tester_okay(owner_ptr, &owner_ptr->current_floor_ptr->o_list[0 - (*cp)], tval) || (mode & USE_FULL)) {
87 item_tester_hook = NULL;
91 } else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) || (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL))) {
92 if (prev_tag && command_cmd) {
93 if (!get_tag(owner_ptr, &k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN, tval)) /* Reject */
95 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */
97 else if (!get_item_okay(owner_ptr, k, tval)) /* Reject */
102 item_tester_hook = NULL;
108 } else if (get_item_okay(owner_ptr, *cp, tval)) {
110 item_tester_hook = NULL;
125 for (j = 0; j < INVEN_PACK; j++)
126 if (item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], tval) || (mode & USE_FULL))
129 while ((i1 <= i2) && (!get_item_okay(owner_ptr, i1, tval)))
132 while ((i1 <= i2) && (!get_item_okay(owner_ptr, i2, tval)))
136 e2 = INVEN_TOTAL - 1;
140 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
141 if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], tval) || (mode & USE_FULL))
143 if (owner_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
146 while ((e1 <= e2) && (!get_item_okay(owner_ptr, e1, tval)))
149 while ((e1 <= e2) && (!get_item_okay(owner_ptr, e2, tval)))
152 if (equip && owner_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) {
153 if (owner_ptr->migite) {
156 } else if (owner_ptr->hidarite)
162 floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval);
173 if (!allow_inven && !allow_equip && !allow_floor) {
183 if (command_see && (command_wrk == (USE_EQUIP)) && allow_equip)
184 command_wrk = (USE_EQUIP);
185 else if (allow_inven)
186 command_wrk = (USE_INVEN);
187 else if (allow_equip)
188 command_wrk = (USE_EQUIP);
189 else if (allow_floor)
190 command_wrk = (USE_FLOOR);
194 * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
196 if ((always_show_list == TRUE) || use_menu)
203 COMMAND_CODE get_item_label = 0;
206 for (j = 0; j < 8; j++) {
207 if (!angband_term[j])
210 if (window_flag[j] & (PW_INVEN))
213 if (window_flag[j] & (PW_EQUIP))
217 if ((command_wrk == (USE_EQUIP) && ni && !ne) || (command_wrk == (USE_INVEN) && !ni && ne)) {
218 toggle_inventory_equipment(owner_ptr);
222 owner_ptr->window |= (PW_INVEN | PW_EQUIP);
223 handle_stuff(owner_ptr);
224 if (command_wrk == (USE_INVEN)) {
228 get_item_label = show_inventory(owner_ptr, menu_line, mode, tval);
229 } else if (command_wrk == (USE_EQUIP)) {
230 n1 = I2A(e1 - INVEN_RARM);
231 n2 = I2A(e2 - INVEN_RARM);
233 get_item_label = show_equipment(owner_ptr, menu_line, mode, tval);
234 } else if (command_wrk == (USE_FLOOR)) {
236 k = MIN(floor_top + 23, floor_num) - 1;
237 n1 = I2A(j - floor_top);
238 n2 = I2A(k - floor_top);
240 get_item_label = show_floor(owner_ptr, menu_line, owner_ptr->y, owner_ptr->x, &min_width, tval);
243 if (command_wrk == (USE_INVEN)) {
244 sprintf(out_val, _("持ち物:", "Inven:"));
246 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), index_to_label(i1), index_to_label(i2));
247 strcat(out_val, tmp_val);
250 if (!command_see && !use_menu)
251 strcat(out_val, _(" '*'一覧,", " * to see,"));
255 strcat(out_val, _(" '/' 装備品,", " / for Equip,"));
256 else if (allow_floor)
257 strcat(out_val, _(" '6' 装備品,", " 6 for Equip,"));
259 strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
264 strcat(out_val, _(" '-'床上,", " - for floor,"));
265 else if (allow_equip)
266 strcat(out_val, _(" '4' 床上,", " 4 for floor,"));
268 strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
270 } else if (command_wrk == (USE_EQUIP)) {
271 sprintf(out_val, _("装備品:", "Equip:"));
273 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), index_to_label(e1), index_to_label(e2));
274 strcat(out_val, tmp_val);
277 if (!command_see && !use_menu)
278 strcat(out_val, _(" '*'一覧,", " * to see,"));
282 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
283 else if (allow_floor)
284 strcat(out_val, _(" '4' 持ち物,", " 4 for Inven,"));
286 strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
291 strcat(out_val, _(" '-'床上,", " - for floor,"));
292 else if (allow_inven)
293 strcat(out_val, _(" '6' 床上,", " 6 for floor,"));
295 strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
297 } else if (command_wrk == (USE_FLOOR)) {
298 sprintf(out_val, _("床上:", "Floor:"));
300 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
301 strcat(out_val, tmp_val);
304 if (!command_see && !use_menu)
305 strcat(out_val, _(" '*'一覧,", " * to see,"));
308 if (allow_inven && allow_equip) {
309 strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
310 } else if (allow_inven) {
311 strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
312 } else if (allow_equip) {
313 strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
315 } else if (allow_inven) {
316 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
317 } else if (allow_equip) {
318 strcat(out_val, _(" '/'装備品,", " / for Equip,"));
321 if (command_see && !use_menu) {
322 strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
327 strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
329 strcat(out_val, " ESC");
330 sprintf(tmp_val, "(%s) %s", out_val, pmt);
335 if (command_wrk == USE_INVEN)
336 max_line = max_inven;
337 else if (command_wrk == USE_EQUIP)
338 max_line = max_equip;
339 else if (command_wrk == USE_FLOOR)
340 max_line = MIN(23, floor_num);
352 menu_line += (max_line - 1);
364 if (command_wrk == (USE_INVEN)) {
366 command_wrk = USE_FLOOR;
367 else if (allow_equip)
368 command_wrk = USE_EQUIP;
373 } else if (command_wrk == (USE_EQUIP)) {
375 command_wrk = USE_INVEN;
376 else if (allow_floor)
377 command_wrk = USE_FLOOR;
382 } else if (command_wrk == (USE_FLOOR)) {
384 command_wrk = USE_EQUIP;
385 else if (allow_inven)
386 command_wrk = USE_INVEN;
401 if (command_wrk == USE_INVEN)
402 max_line = max_inven;
403 else if (command_wrk == USE_EQUIP)
404 max_line = max_equip;
405 else if (command_wrk == USE_FLOOR)
406 max_line = MIN(23, floor_num);
408 if (menu_line > max_line)
409 menu_line = max_line;
416 if (command_wrk == (USE_INVEN)) {
418 command_wrk = USE_EQUIP;
419 else if (allow_floor)
420 command_wrk = USE_FLOOR;
425 } else if (command_wrk == (USE_EQUIP)) {
427 command_wrk = USE_FLOOR;
428 else if (allow_inven)
429 command_wrk = USE_INVEN;
434 } else if (command_wrk == (USE_FLOOR)) {
436 command_wrk = USE_INVEN;
437 else if (allow_equip)
438 command_wrk = USE_EQUIP;
453 if (command_wrk == USE_INVEN)
454 max_line = max_inven;
455 else if (command_wrk == USE_EQUIP)
456 max_line = max_equip;
457 else if (command_wrk == USE_FLOOR)
458 max_line = MIN(23, floor_num);
460 if (menu_line > max_line)
461 menu_line = max_line;
469 if (command_wrk == USE_FLOOR)
470 (*cp) = -get_item_label;
472 if (!get_item_okay(owner_ptr, get_item_label, tval)) {
477 if (!get_item_allow(owner_ptr, get_item_label)) {
482 (*cp) = get_item_label;
499 if (menu_line > max_line)
500 menu_line -= max_line;
528 grid_type *g_ptr = &owner_ptr->current_floor_ptr->grid_array[owner_ptr->y][owner_ptr->x];
529 if (command_wrk != (USE_FLOOR))
532 o_idx = g_ptr->o_idx;
533 if (!(o_idx && owner_ptr->current_floor_ptr->o_list[o_idx].next_o_idx))
536 excise_object_idx(owner_ptr->current_floor_ptr, o_idx);
538 while (owner_ptr->current_floor_ptr->o_list[i].next_o_idx)
539 i = owner_ptr->current_floor_ptr->o_list[i].next_o_idx;
541 owner_ptr->current_floor_ptr->o_list[i].next_o_idx = o_idx;
542 floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval);
551 if (command_wrk == (USE_INVEN)) {
556 command_wrk = (USE_EQUIP);
557 } else if (command_wrk == (USE_EQUIP)) {
562 command_wrk = (USE_INVEN);
563 } else if (command_wrk == (USE_FLOOR)) {
565 command_wrk = (USE_INVEN);
566 } else if (allow_equip) {
567 command_wrk = (USE_EQUIP);
587 if (floor_num == 1) {
588 if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag)) {
589 k = 0 - floor_list[0];
590 if (!get_item_allow(owner_ptr, k)) {
607 command_wrk = (USE_FLOOR);
620 if (command_wrk != USE_FLOOR) {
621 if (!get_tag(owner_ptr, &k, which, command_wrk, tval)) {
626 if ((k < INVEN_RARM) ? !inven : !equip) {
631 if (!get_item_okay(owner_ptr, k, tval)) {
636 if (get_tag_floor(owner_ptr->current_floor_ptr, &k, which, floor_list, floor_num)) {
637 k = 0 - floor_list[k];
644 if (!get_item_allow(owner_ptr, k)) {
666 if (command_wrk != USE_FLOOR) {
667 bool not_found = FALSE;
668 if (!get_tag(owner_ptr, &k, which, command_wrk, tval))
670 else if ((k < INVEN_RARM) ? !inven : !equip)
672 else if (!get_item_okay(owner_ptr, k, tval))
683 if (get_tag_floor(owner_ptr->current_floor_ptr, &k, which, floor_list, floor_num)) {
684 k = 0 - floor_list[k];
693 ver = isupper(which);
694 which = (char)tolower(which);
695 if (command_wrk == (USE_INVEN)) {
698 else if (which == ')')
701 k = label_to_inventory(owner_ptr, which);
702 } else if (command_wrk == (USE_EQUIP)) {
705 else if (which == ')')
708 k = label_to_equipment(owner_ptr, which);
709 } else if (command_wrk == USE_FLOOR) {
712 else if (which == ')')
715 k = islower(which) ? A2I(which) : -1;
716 if (k < 0 || k >= floor_num || k >= 23) {
721 k = 0 - floor_list[k];
724 if ((command_wrk != USE_FLOOR) && !get_item_okay(owner_ptr, k, tval)) {
729 if (ver && !verify(owner_ptr, _("本当に", "Try"), k)) {
734 if (!get_item_allow(owner_ptr, k)) {
753 item_tester_hook = NULL;
755 toggle_inventory_equipment(owner_ptr);
757 owner_ptr->window |= (PW_INVEN | PW_EQUIP);
758 handle_stuff(owner_ptr);