• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision3b90dd34bb27f8eac73f8c24ba5d6bc14363aff1 (tree)
Time2019-06-13 23:40:47
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #37353 object1.c/object.h から player-inventory.c/h を分離.

Change Summary

Incremental Difference

--- a/Hengband_vcs2017/Hengband/Hengband.vcxproj
+++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj
@@ -182,6 +182,7 @@
182182 <ClCompile Include="..\..\src\player-class.c" />
183183 <ClCompile Include="..\..\src\player-damage.c" />
184184 <ClCompile Include="..\..\src\player-effects.c" />
185+ <ClCompile Include="..\..\src\player-inventory.c" />
185186 <ClCompile Include="..\..\src\player-personality.c" />
186187 <ClCompile Include="..\..\src\player-race.c" />
187188 <ClCompile Include="..\..\src\player-sex.c" />
@@ -293,6 +294,7 @@
293294 <ClCompile Include="..\..\src\z-virt.c" />
294295 <ClInclude Include="..\..\src\english.h" />
295296 <ClInclude Include="..\..\src\object-flavor.h" />
297+ <ClInclude Include="..\..\src\player-inventory.h" />
296298 <ClInclude Include="japanese.h" />
297299 </ItemGroup>
298300 <ItemGroup>
--- a/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
+++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
@@ -397,6 +397,9 @@
397397 <ClCompile Include="..\..\src\object-flavor.c">
398398 <Filter>object</Filter>
399399 </ClCompile>
400+ <ClCompile Include="..\..\src\player-inventory.c">
401+ <Filter>player</Filter>
402+ </ClCompile>
400403 </ItemGroup>
401404 <ItemGroup>
402405 <ClInclude Include="..\..\src\gamevalue.h" />
@@ -776,6 +779,9 @@
776779 <ClInclude Include="..\..\src\object-flavor.h">
777780 <Filter>object</Filter>
778781 </ClInclude>
782+ <ClInclude Include="..\..\src\player-inventory.h">
783+ <Filter>player</Filter>
784+ </ClInclude>
779785 </ItemGroup>
780786 <ItemGroup>
781787 <None Include="..\..\src\wall.bmp" />
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,6 +60,7 @@ hengband_SOURCES = \
6060 player-move.c player-move.h player-damage.c player-damage.h player-status.c player-status.h \
6161 player-effects.c player-effects.h player-skill.c player-skill.h player-class.c player-class.h \
6262 player-race.c player-race.h player-pesonality.c player-pesonality.h player-sex.c player-sex.h \
63+ player-inventory.c player-inventory.h \
6364 \
6465 quest.h quest.c\
6566 \
--- a/src/object.h
+++ b/src/object.h
@@ -522,6 +522,7 @@ extern s32b flag_cost(object_type *o_ptr, int plusses);
522522
523523 extern bool get_item_floor(COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode);
524524 extern void py_pickup_floor(bool pickup);
525+extern void prepare_label_string(char *label, BIT_FLAGS mode);
525526
526527 /*
527528 * Return the "attr" for a given item.
--- a/src/object1.c
+++ b/src/object1.c
@@ -24,6 +24,7 @@
2424 #include "object-hook.h"
2525 #include "player-move.h"
2626 #include "player-class.h"
27+#include "player-inventory.h"
2728 #include "monster.h"
2829 #include "files.h"
2930 #include "term.h"
@@ -1342,48 +1343,6 @@ INVENTORY_IDX label_to_inven(int c)
13421343 return (i);
13431344 }
13441345
1345-
1346-/*! See cmd5.c */
1347-extern bool select_ring_slot;
1348-
1349-
1350-/*!
1351- * @brief プレイヤーの所持/装備オブジェクトIDが指輪枠かを返す /
1352- * @param i プレイヤーの所持/装備オブジェクトID
1353- * @return 指輪枠ならばTRUEを返す。
1354- */
1355-static bool is_ring_slot(int i)
1356-{
1357- return (i == INVEN_RIGHT) || (i == INVEN_LEFT);
1358-}
1359-
1360-
1361-/*!
1362- * @brief 選択アルファベットラベルからプレイヤーの装備オブジェクトIDを返す /
1363- * Convert a label into the index of a item in the "equip"
1364- * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1365- */
1366-INVENTORY_IDX label_to_equip(int c)
1367-{
1368- INVENTORY_IDX i;
1369-
1370- /* Convert */
1371- i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1) + INVEN_RARM;
1372-
1373- /* Verify the index */
1374- if ((i < INVEN_RARM) || (i >= INVEN_TOTAL)) return (-1);
1375-
1376- if (select_ring_slot) return is_ring_slot(i) ? i : -1;
1377-
1378- /* Empty slots can never be chosen */
1379- if (!p_ptr->inventory_list[i].k_idx) return (-1);
1380-
1381- /* Return the index */
1382- return (i);
1383-}
1384-
1385-
1386-
13871346 /*!
13881347 * @brief オブジェクトの該当装備部位IDを返す /
13891348 * Determine which equipment slot (if any) an item likes
@@ -1702,81 +1661,6 @@ void display_inven(void)
17021661 }
17031662 }
17041663
1705-
1706-
1707-/*!
1708- * @brief 装備アイテム一覧を表示する /
1709- * Choice window "shadow" of the "show_equip()" function
1710- * @return なし
1711- */
1712-void display_equip(void)
1713-{
1714- register int i, n;
1715- object_type *o_ptr;
1716- TERM_COLOR attr = TERM_WHITE;
1717- char tmp_val[80];
1718- GAME_TEXT o_name[MAX_NLEN];
1719- TERM_LEN wid, hgt;
1720-
1721- Term_get_size(&wid, &hgt);
1722-
1723- for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1724- {
1725- o_ptr = &p_ptr->inventory_list[i];
1726- tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1727- if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr))
1728- {
1729- tmp_val[0] = index_to_label(i);
1730- tmp_val[1] = ')';
1731- }
1732-
1733- Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
1734- if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
1735- {
1736- strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
1737- attr = TERM_WHITE;
1738- }
1739- else
1740- {
1741- object_desc(o_name, o_ptr, 0);
1742- attr = tval_to_attr[o_ptr->tval % 128];
1743- }
1744-
1745- n = strlen(o_name);
1746- if (o_ptr->timeout)
1747- {
1748- attr = TERM_L_DARK;
1749- }
1750- Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
1751-
1752- Term_erase(3 + n, i - INVEN_RARM, 255);
1753-
1754- if (show_weights)
1755- {
1756- int wgt = o_ptr->weight * o_ptr->number;
1757-#ifdef JP
1758- sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
1759-#else
1760- sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1761-#endif
1762-
1763- prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
1764- }
1765-
1766- if (show_labels)
1767- {
1768- Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
1769- prt(mention_use(i), i - INVEN_RARM, wid - 15);
1770- }
1771- }
1772-
1773- for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
1774- {
1775- Term_erase(0, i, 255);
1776- }
1777-}
1778-
1779-
17801664 /*!
17811665 * @brief 所持/装備オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
17821666 * Find the "first" p_ptr->inventory_list object with the given "tag".
@@ -2001,7 +1885,7 @@ static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], IT
20011885 * @param mode 所持品リストか装備品リストかの切り替え
20021886 * @return なし
20031887 */
2004-static void prepare_label_string(char *label, BIT_FLAGS mode)
1888+void prepare_label_string(char *label, BIT_FLAGS mode)
20051889 {
20061890 concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
20071891 int offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
@@ -2229,227 +2113,6 @@ COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode)
22292113
22302114
22312115 /*!
2232- * @brief 装備アイテムの表示を行う /
2233- * Display the equipment.
2234- * @param target_item アイテムの選択処理を行うか否か。
2235- * @return 選択したアイテムのタグ
2236- */
2237-COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode)
2238-{
2239- COMMAND_CODE i;
2240- int j, k, l;
2241- int col, cur_col, len;
2242- object_type *o_ptr;
2243- char tmp_val[80];
2244- GAME_TEXT o_name[MAX_NLEN];
2245- COMMAND_CODE out_index[23];
2246- TERM_COLOR out_color[23];
2247- char out_desc[23][MAX_NLEN];
2248- COMMAND_CODE target_item_label = 0;
2249- TERM_LEN wid, hgt;
2250- char equip_label[52 + 1];
2251-
2252- /* Starting column */
2253- col = command_gap;
2254-
2255- Term_get_size(&wid, &hgt);
2256-
2257- /* Maximal length */
2258- len = wid - col - 1;
2259-
2260-
2261- /* Scan the equipment list */
2262- for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2263- {
2264- o_ptr = &p_ptr->inventory_list[i];
2265-
2266- /* Is this item acceptable? */
2267- if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr) || (mode & USE_FULL)) &&
2268- (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
2269- (mode & IGNORE_BOTHHAND_SLOT))) continue;
2270-
2271- object_desc(o_name, o_ptr, 0);
2272-
2273- if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
2274- {
2275- (void)strcpy(out_desc[k],_("(武器を両手持ち)", "(wielding with two-hands)"));
2276- out_color[k] = TERM_WHITE;
2277- }
2278- else
2279- {
2280- (void)strcpy(out_desc[k], o_name);
2281- out_color[k] = tval_to_attr[o_ptr->tval % 128];
2282- }
2283-
2284- out_index[k] = i;
2285- /* Grey out charging items */
2286- if (o_ptr->timeout)
2287- {
2288- out_color[k] = TERM_L_DARK;
2289- }
2290-
2291- /* Extract the maximal length (see below) */
2292-#ifdef JP
2293- l = strlen(out_desc[k]) + (2 + 1);
2294-#else
2295- l = strlen(out_desc[k]) + (2 + 3);
2296-#endif
2297-
2298-
2299- /* Increase length for labels (if needed) */
2300-#ifdef JP
2301- if (show_labels) l += (7 + 2);
2302-#else
2303- if (show_labels) l += (14 + 2);
2304-#endif
2305-
2306-
2307- /* Increase length for weight (if needed) */
2308- if (show_weights) l += 9;
2309-
2310- if (show_item_graph) l += 2;
2311-
2312- /* Maintain the max-length */
2313- if (l > len) len = l;
2314-
2315- /* Advance the entry */
2316- k++;
2317- }
2318-
2319- /* Hack -- Find a column to start in */
2320-#ifdef JP
2321- col = (len > wid - 6) ? 0 : (wid - len - 1);
2322-#else
2323- col = (len > wid - 4) ? 0 : (wid - len - 1);
2324-#endif
2325-
2326- prepare_label_string(equip_label, USE_EQUIP);
2327-
2328- /* Output each entry */
2329- for (j = 0; j < k; j++)
2330- {
2331- i = out_index[j];
2332- o_ptr = &p_ptr->inventory_list[i];
2333-
2334- /* Clear the line */
2335- prt("", j + 1, col ? col - 2 : col);
2336-
2337- if (use_menu && target_item)
2338- {
2339- if (j == (target_item-1))
2340- {
2341- strcpy(tmp_val, _("》", "> "));
2342- target_item_label = i;
2343- }
2344- else strcpy(tmp_val, " ");
2345- }
2346- else if (i >= INVEN_RARM)
2347- {
2348- /* Prepare an index --(-- */
2349- sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
2350- }
2351- else
2352- {
2353- /* Prepare an index --(-- */
2354- sprintf(tmp_val, "%c)", index_to_label(i));
2355- }
2356-
2357- /* Clear the line with the (possibly indented) index */
2358- put_str(tmp_val, j+1, col);
2359-
2360- cur_col = col + 3;
2361-
2362- /* Display graphics for object, if desired */
2363- if (show_item_graph)
2364- {
2365- TERM_COLOR a = object_attr(o_ptr);
2366- SYMBOL_CODE c = object_char(o_ptr);
2367- Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2368- if (use_bigtile) cur_col++;
2369-
2370- cur_col += 2;
2371- }
2372-
2373- /* Use labels */
2374- if (show_labels)
2375- {
2376- /* Mention the use */
2377- (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
2378-
2379- put_str(tmp_val, j+1, cur_col);
2380-
2381- /* Display the entry itself */
2382- c_put_str(out_color[j], out_desc[j], j+1, _(cur_col + 9, cur_col + 16));
2383- }
2384-
2385- /* No labels */
2386- else
2387- {
2388- /* Display the entry itself */
2389- c_put_str(out_color[j], out_desc[j], j+1, cur_col);
2390- }
2391-
2392- /* Display the weight if needed */
2393- if (show_weights)
2394- {
2395- int wgt = o_ptr->weight * o_ptr->number;
2396-#ifdef JP
2397- (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2398-#else
2399- (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
2400-#endif
2401-
2402- prt(tmp_val, j + 1, wid - 9);
2403- }
2404- }
2405-
2406- /* Make a "shadow" below the list (only if needed) */
2407- if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2408-
2409- /* Save the new column */
2410- command_gap = col;
2411-
2412- return target_item_label;
2413-}
2414-
2415-/*!
2416- * @brief サブウィンドウに所持品、装備品リストの表示を行う /
2417- * Flip "inven" and "equip" in any sub-windows
2418- * @return なし
2419- */
2420-void toggle_inven_equip(void)
2421-{
2422- int j;
2423-
2424- /* Scan windows */
2425- for (j = 0; j < 8; j++)
2426- {
2427- /* Unused */
2428- if (!angband_term[j]) continue;
2429-
2430- /* Flip inven to equip */
2431- if (window_flag[j] & (PW_INVEN))
2432- {
2433- /* Flip flags */
2434- window_flag[j] &= ~(PW_INVEN);
2435- window_flag[j] |= (PW_EQUIP);
2436-
2437- p_ptr->window |= (PW_EQUIP);
2438- }
2439-
2440- /* Flip inven to equip */
2441- else if (window_flag[j] & (PW_EQUIP))
2442- {
2443- /* Flip flags */
2444- window_flag[j] &= ~(PW_EQUIP);
2445- window_flag[j] |= (PW_INVEN);
2446-
2447- p_ptr->window |= (PW_INVEN);
2448- }
2449- }
2450-}
2451-
2452-/*!
24532116 * @brief 選択したアイテムの確認処理の補助 /
24542117 * Verify the choice of an item.
24552118 * @param prompt メッセージ表示の一部
@@ -2536,49 +2199,6 @@ static bool get_item_allow(INVENTORY_IDX item)
25362199
25372200
25382201 /*!
2539- * @brief プレイヤーの所持/装備オブジェクトが正規のものかを返す /
2540- * Auxiliary function for "get_item()" -- test an index
2541- * @param i 選択アイテムID
2542- * @return 正規のIDならばTRUEを返す。
2543- */
2544-static bool get_item_okay(OBJECT_IDX i)
2545-{
2546- /* Illegal items */
2547- if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
2548-
2549- if (select_ring_slot) return is_ring_slot(i);
2550-
2551- /* Verify the item */
2552- if (!item_tester_okay(&p_ptr->inventory_list[i])) return (FALSE);
2553-
2554- /* Assume okay */
2555- return (TRUE);
2556-}
2557-
2558-/*!
2559- * @brief プレイヤーがオブジェクトを拾うことができる状態かを返す /
2560- * Determine whether get_item() can get some item or not
2561- * @return アイテムを拾えるならばTRUEを返す。
2562- * @details assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
2563- */
2564-bool can_get_item(void)
2565-{
2566- int j;
2567- OBJECT_IDX floor_list[23];
2568- ITEM_NUMBER floor_num = 0;
2569-
2570- for (j = 0; j < INVEN_TOTAL; j++)
2571- if (item_tester_okay(&p_ptr->inventory_list[j]))
2572- return TRUE;
2573-
2574- floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2575- if (floor_num)
2576- return TRUE;
2577-
2578- return FALSE;
2579-}
2580-
2581-/*!
25822202 * @brief オブジェクト選択の汎用関数 /
25832203 * Let the user select an item, save its "index"
25842204 * @param cp 選択したオブジェクトのIDを返す。
--- /dev/null
+++ b/src/player-inventory.c
@@ -0,0 +1,387 @@
1+#include "angband.h"
2+#include "core.h"
3+#include "util.h"
4+#include "term.h"
5+#include "object.h"
6+#include "objectkind.h"
7+#include "object-flavor.h"
8+
9+#include "view-mainwindow.h"
10+
11+bool select_ring_slot;
12+
13+/*!
14+ * @brief プレイヤーの所持/装備オブジェクトIDが指輪枠かを返す /
15+ * @param i プレイヤーの所持/装備オブジェクトID
16+ * @return 指輪枠ならばTRUEを返す。
17+ */
18+bool is_ring_slot(int i)
19+{
20+ return (i == INVEN_RIGHT) || (i == INVEN_LEFT);
21+}
22+
23+
24+/*!
25+ * @brief 選択アルファベットラベルからプレイヤーの装備オブジェクトIDを返す /
26+ * Convert a label into the index of a item in the "equip"
27+ * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
28+ */
29+INVENTORY_IDX label_to_equip(int c)
30+{
31+ INVENTORY_IDX i;
32+
33+ /* Convert */
34+ i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1) + INVEN_RARM;
35+
36+ /* Verify the index */
37+ if ((i < INVEN_RARM) || (i >= INVEN_TOTAL)) return (-1);
38+
39+ if (select_ring_slot) return is_ring_slot(i) ? i : -1;
40+
41+ /* Empty slots can never be chosen */
42+ if (!p_ptr->inventory_list[i].k_idx) return (-1);
43+
44+ /* Return the index */
45+ return (i);
46+}
47+
48+
49+
50+
51+/*!
52+ * @brief 装備アイテム一覧を表示する /
53+ * Choice window "shadow" of the "show_equip()" function
54+ * @return なし
55+ */
56+void display_equip(void)
57+{
58+ register int i, n;
59+ object_type *o_ptr;
60+ TERM_COLOR attr = TERM_WHITE;
61+ char tmp_val[80];
62+ GAME_TEXT o_name[MAX_NLEN];
63+ TERM_LEN wid, hgt;
64+
65+ Term_get_size(&wid, &hgt);
66+
67+ for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
68+ {
69+ o_ptr = &p_ptr->inventory_list[i];
70+ tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
71+ if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr))
72+ {
73+ tmp_val[0] = index_to_label(i);
74+ tmp_val[1] = ')';
75+ }
76+
77+ Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
78+ if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
79+ {
80+ strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
81+ attr = TERM_WHITE;
82+ }
83+ else
84+ {
85+ object_desc(o_name, o_ptr, 0);
86+ attr = tval_to_attr[o_ptr->tval % 128];
87+ }
88+
89+ n = strlen(o_name);
90+ if (o_ptr->timeout)
91+ {
92+ attr = TERM_L_DARK;
93+ }
94+ Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
95+
96+ Term_erase(3 + n, i - INVEN_RARM, 255);
97+
98+ if (show_weights)
99+ {
100+ int wgt = o_ptr->weight * o_ptr->number;
101+#ifdef JP
102+ sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
103+#else
104+ sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
105+#endif
106+
107+ prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
108+ }
109+
110+ if (show_labels)
111+ {
112+ Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
113+ prt(mention_use(i), i - INVEN_RARM, wid - 15);
114+ }
115+ }
116+
117+ for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
118+ {
119+ Term_erase(0, i, 255);
120+ }
121+}
122+
123+
124+/*!
125+ * @brief 装備アイテムの表示を行う /
126+ * Display the equipment.
127+ * @param target_item アイテムの選択処理を行うか否か。
128+ * @return 選択したアイテムのタグ
129+ */
130+COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode)
131+{
132+ COMMAND_CODE i;
133+ int j, k, l;
134+ int col, cur_col, len;
135+ object_type *o_ptr;
136+ char tmp_val[80];
137+ GAME_TEXT o_name[MAX_NLEN];
138+ COMMAND_CODE out_index[23];
139+ TERM_COLOR out_color[23];
140+ char out_desc[23][MAX_NLEN];
141+ COMMAND_CODE target_item_label = 0;
142+ TERM_LEN wid, hgt;
143+ char equip_label[52 + 1];
144+
145+ /* Starting column */
146+ col = command_gap;
147+
148+ Term_get_size(&wid, &hgt);
149+
150+ /* Maximal length */
151+ len = wid - col - 1;
152+
153+
154+ /* Scan the equipment list */
155+ for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
156+ {
157+ o_ptr = &p_ptr->inventory_list[i];
158+
159+ /* Is this item acceptable? */
160+ if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr) || (mode & USE_FULL)) &&
161+ (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
162+ (mode & IGNORE_BOTHHAND_SLOT))) continue;
163+
164+ object_desc(o_name, o_ptr, 0);
165+
166+ if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
167+ {
168+ (void)strcpy(out_desc[k], _("(武器を両手持ち)", "(wielding with two-hands)"));
169+ out_color[k] = TERM_WHITE;
170+ }
171+ else
172+ {
173+ (void)strcpy(out_desc[k], o_name);
174+ out_color[k] = tval_to_attr[o_ptr->tval % 128];
175+ }
176+
177+ out_index[k] = i;
178+ /* Grey out charging items */
179+ if (o_ptr->timeout)
180+ {
181+ out_color[k] = TERM_L_DARK;
182+ }
183+
184+ /* Extract the maximal length (see below) */
185+#ifdef JP
186+ l = strlen(out_desc[k]) + (2 + 1);
187+#else
188+ l = strlen(out_desc[k]) + (2 + 3);
189+#endif
190+
191+
192+ /* Increase length for labels (if needed) */
193+#ifdef JP
194+ if (show_labels) l += (7 + 2);
195+#else
196+ if (show_labels) l += (14 + 2);
197+#endif
198+
199+
200+ /* Increase length for weight (if needed) */
201+ if (show_weights) l += 9;
202+
203+ if (show_item_graph) l += 2;
204+
205+ /* Maintain the max-length */
206+ if (l > len) len = l;
207+
208+ /* Advance the entry */
209+ k++;
210+ }
211+
212+ /* Hack -- Find a column to start in */
213+#ifdef JP
214+ col = (len > wid - 6) ? 0 : (wid - len - 1);
215+#else
216+ col = (len > wid - 4) ? 0 : (wid - len - 1);
217+#endif
218+
219+ prepare_label_string(equip_label, USE_EQUIP);
220+
221+ /* Output each entry */
222+ for (j = 0; j < k; j++)
223+ {
224+ i = out_index[j];
225+ o_ptr = &p_ptr->inventory_list[i];
226+
227+ /* Clear the line */
228+ prt("", j + 1, col ? col - 2 : col);
229+
230+ if (use_menu && target_item)
231+ {
232+ if (j == (target_item - 1))
233+ {
234+ strcpy(tmp_val, _("》", "> "));
235+ target_item_label = i;
236+ }
237+ else strcpy(tmp_val, " ");
238+ }
239+ else if (i >= INVEN_RARM)
240+ {
241+ /* Prepare an index --(-- */
242+ sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
243+ }
244+ else
245+ {
246+ /* Prepare an index --(-- */
247+ sprintf(tmp_val, "%c)", index_to_label(i));
248+ }
249+
250+ /* Clear the line with the (possibly indented) index */
251+ put_str(tmp_val, j + 1, col);
252+
253+ cur_col = col + 3;
254+
255+ /* Display graphics for object, if desired */
256+ if (show_item_graph)
257+ {
258+ TERM_COLOR a = object_attr(o_ptr);
259+ SYMBOL_CODE c = object_char(o_ptr);
260+ Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
261+ if (use_bigtile) cur_col++;
262+
263+ cur_col += 2;
264+ }
265+
266+ /* Use labels */
267+ if (show_labels)
268+ {
269+ /* Mention the use */
270+ (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
271+
272+ put_str(tmp_val, j + 1, cur_col);
273+
274+ /* Display the entry itself */
275+ c_put_str(out_color[j], out_desc[j], j + 1, _(cur_col + 9, cur_col + 16));
276+ }
277+
278+ /* No labels */
279+ else
280+ {
281+ /* Display the entry itself */
282+ c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
283+ }
284+
285+ /* Display the weight if needed */
286+ if (show_weights)
287+ {
288+ int wgt = o_ptr->weight * o_ptr->number;
289+#ifdef JP
290+ (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
291+#else
292+ (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
293+#endif
294+
295+ prt(tmp_val, j + 1, wid - 9);
296+ }
297+ }
298+
299+ /* Make a "shadow" below the list (only if needed) */
300+ if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
301+
302+ /* Save the new column */
303+ command_gap = col;
304+
305+ return target_item_label;
306+}
307+
308+/*!
309+ * @brief サブウィンドウに所持品、装備品リストの表示を行う /
310+ * Flip "inven" and "equip" in any sub-windows
311+ * @return なし
312+ */
313+void toggle_inven_equip(void)
314+{
315+ int j;
316+
317+ /* Scan windows */
318+ for (j = 0; j < 8; j++)
319+ {
320+ /* Unused */
321+ if (!angband_term[j]) continue;
322+
323+ /* Flip inven to equip */
324+ if (window_flag[j] & (PW_INVEN))
325+ {
326+ /* Flip flags */
327+ window_flag[j] &= ~(PW_INVEN);
328+ window_flag[j] |= (PW_EQUIP);
329+
330+ p_ptr->window |= (PW_EQUIP);
331+ }
332+
333+ /* Flip inven to equip */
334+ else if (window_flag[j] & (PW_EQUIP))
335+ {
336+ /* Flip flags */
337+ window_flag[j] &= ~(PW_EQUIP);
338+ window_flag[j] |= (PW_INVEN);
339+
340+ p_ptr->window |= (PW_INVEN);
341+ }
342+ }
343+}
344+
345+
346+/*!
347+ * @brief プレイヤーの所持/装備オブジェクトが正規のものかを返す /
348+ * Auxiliary function for "get_item()" -- test an index
349+ * @param i 選択アイテムID
350+ * @return 正規のIDならばTRUEを返す。
351+ */
352+bool get_item_okay(OBJECT_IDX i)
353+{
354+ /* Illegal items */
355+ if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
356+
357+ if (select_ring_slot) return is_ring_slot(i);
358+
359+ /* Verify the item */
360+ if (!item_tester_okay(&p_ptr->inventory_list[i])) return (FALSE);
361+
362+ /* Assume okay */
363+ return (TRUE);
364+}
365+
366+/*!
367+ * @brief プレイヤーがオブジェクトを拾うことができる状態かを返す /
368+ * Determine whether get_item() can get some item or not
369+ * @return アイテムを拾えるならばTRUEを返す。
370+ * @details assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
371+ */
372+bool can_get_item(void)
373+{
374+ int j;
375+ OBJECT_IDX floor_list[23];
376+ ITEM_NUMBER floor_num = 0;
377+
378+ for (j = 0; j < INVEN_TOTAL; j++)
379+ if (item_tester_okay(&p_ptr->inventory_list[j]))
380+ return TRUE;
381+
382+ floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
383+ if (floor_num)
384+ return TRUE;
385+
386+ return FALSE;
387+}
--- /dev/null
+++ b/src/player-inventory.h
@@ -0,0 +1,6 @@
1+#pragma once
2+
3+extern bool select_ring_slot;
4+
5+extern bool is_ring_slot(int i);
6+extern bool get_item_okay(OBJECT_IDX i);
Show on old repository browser