• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

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


Commit MetaInfo

Revision5e9e30678e591ae166074e1d85c8e092e7599a94 (tree)
Time2019-06-13 23:48:13
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #37353 object1.c から player-inventory.c にアイテムを拾う処理などを移動.

Change Summary

Incremental Difference

--- a/src/object1.c
+++ b/src/object1.c
@@ -1662,2956 +1662,6 @@ void display_inven(void)
16621662 }
16631663
16641664 /*!
1665- * @brief 所持/装備オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1666- * Find the "first" p_ptr->inventory_list object with the given "tag".
1667- * @param cp 対応するタグIDを与える参照ポインタ
1668- * @param tag 該当するオブジェクトがあるかを調べたいタグ
1669- * @param mode 所持、装備の切り替え
1670- * @return タグに該当するオブジェクトがあるならTRUEを返す
1671- * @details
1672- * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1673- * inscription of an object. Alphabetical characters don't work as a\n
1674- * tag in this form.\n
1675- *\n
1676- * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1677- * and "x" is the "current" command_cmd code.\n
1678- */
1679-static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode)
1680-{
1681- COMMAND_CODE i;
1682- COMMAND_CODE start, end;
1683- concptr s;
1684-
1685- /* Extract index from mode */
1686- switch (mode)
1687- {
1688- case USE_EQUIP:
1689- start = INVEN_RARM;
1690- end = INVEN_TOTAL - 1;
1691- break;
1692-
1693- case USE_INVEN:
1694- start = 0;
1695- end = INVEN_PACK - 1;
1696- break;
1697-
1698- default:
1699- return FALSE;
1700- }
1701-
1702- /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1703-
1704- /* Check every p_ptr->inventory_list object */
1705- for (i = start; i <= end; i++)
1706- {
1707- object_type *o_ptr = &p_ptr->inventory_list[i];
1708- if (!o_ptr->k_idx) continue;
1709-
1710- /* Skip empty inscriptions */
1711- if (!o_ptr->inscription) continue;
1712-
1713- /* Skip non-choice */
1714- if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
1715-
1716- /* Find a '@' */
1717- s = my_strchr(quark_str(o_ptr->inscription), '@');
1718-
1719- /* Process all tags */
1720- while (s)
1721- {
1722- /* Check the special tags */
1723- if ((s[1] == command_cmd) && (s[2] == tag))
1724- {
1725- /* Save the actual p_ptr->inventory_list ID */
1726- *cp = i;
1727-
1728- /* Success */
1729- return (TRUE);
1730- }
1731-
1732- /* Find another '@' */
1733- s = my_strchr(s + 1, '@');
1734- }
1735- }
1736-
1737-
1738- /**** Find a tag in the form of {@#} (allows only numerals) ***/
1739-
1740- /* Don't allow {@#} with '#' being alphabet */
1741- if (tag < '0' || '9' < tag)
1742- {
1743- /* No such tag */
1744- return FALSE;
1745- }
1746-
1747- /* Check every object */
1748- for (i = start; i <= end; i++)
1749- {
1750- object_type *o_ptr = &p_ptr->inventory_list[i];
1751- if (!o_ptr->k_idx) continue;
1752-
1753- /* Skip empty inscriptions */
1754- if (!o_ptr->inscription) continue;
1755-
1756- /* Skip non-choice */
1757- if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
1758-
1759- /* Find a '@' */
1760- s = my_strchr(quark_str(o_ptr->inscription), '@');
1761-
1762- /* Process all tags */
1763- while (s)
1764- {
1765- /* Check the normal tags */
1766- if (s[1] == tag)
1767- {
1768- /* Save the actual p_ptr->inventory_list ID */
1769- *cp = i;
1770-
1771- /* Success */
1772- return (TRUE);
1773- }
1774-
1775- /* Find another '@' */
1776- s = my_strchr(s + 1, '@');
1777- }
1778- }
1779-
1780- /* No such tag */
1781- return (FALSE);
1782-}
1783-
1784-
1785-/*!
1786- * @brief 床オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1787- * Find the "first" p_ptr->inventory_list object with the given "tag".
1788- * @param cp 対応するタグIDを与える参照ポインタ
1789- * @param tag 該当するオブジェクトがあるかを調べたいタグ
1790- * @param floor_list 床上アイテムの配列
1791- * @param floor_num 床上アイテムの配列ID
1792- * @return タグに該当するオブジェクトがあるならTRUEを返す
1793- * @details
1794- * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1795- * inscription of an object. Alphabetical characters don't work as a\n
1796- * tag in this form.\n
1797- *\n
1798- * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1799- * and "x" is the "current" command_cmd code.\n
1800- */
1801-static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
1802-{
1803- COMMAND_CODE i;
1804- concptr s;
1805-
1806- /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1807-
1808- /* Check every object in the grid */
1809- for (i = 0; i < floor_num && i < 23; i++)
1810- {
1811- object_type *o_ptr = &current_floor_ptr->o_list[floor_list[i]];
1812-
1813- /* Skip empty inscriptions */
1814- if (!o_ptr->inscription) continue;
1815-
1816- /* Find a '@' */
1817- s = my_strchr(quark_str(o_ptr->inscription), '@');
1818-
1819- /* Process all tags */
1820- while (s)
1821- {
1822- /* Check the special tags */
1823- if ((s[1] == command_cmd) && (s[2] == tag))
1824- {
1825- /* Save the actual floor object ID */
1826- *cp = i;
1827-
1828- /* Success */
1829- return (TRUE);
1830- }
1831-
1832- /* Find another '@' */
1833- s = my_strchr(s + 1, '@');
1834- }
1835- }
1836-
1837-
1838- /**** Find a tag in the form of {@#} (allows only numerals) ***/
1839-
1840- /* Don't allow {@#} with '#' being alphabet */
1841- if (tag < '0' || '9' < tag)
1842- {
1843- /* No such tag */
1844- return FALSE;
1845- }
1846-
1847- /* Check every object in the grid */
1848- for (i = 0; i < floor_num && i < 23; i++)
1849- {
1850- object_type *o_ptr = &current_floor_ptr->o_list[floor_list[i]];
1851-
1852- /* Skip empty inscriptions */
1853- if (!o_ptr->inscription) continue;
1854-
1855- /* Find a '@' */
1856- s = my_strchr(quark_str(o_ptr->inscription), '@');
1857-
1858- /* Process all tags */
1859- while (s)
1860- {
1861- /* Check the normal tags */
1862- if (s[1] == tag)
1863- {
1864- /* Save the floor object ID */
1865- *cp = i;
1866-
1867- /* Success */
1868- return (TRUE);
1869- }
1870-
1871- /* Find another '@' */
1872- s = my_strchr(s + 1, '@');
1873- }
1874- }
1875-
1876- /* No such tag */
1877- return (FALSE);
1878-}
1879-
1880-
1881-/*!
1882- * @brief タグIDにあわせてタグアルファベットのリストを返す /
1883- * Move around label characters with correspond tags
1884- * @param label ラベルリストを取得する文字列参照ポインタ
1885- * @param mode 所持品リストか装備品リストかの切り替え
1886- * @return なし
1887- */
1888-void prepare_label_string(char *label, BIT_FLAGS mode)
1889-{
1890- concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1891- int offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
1892- int i;
1893-
1894- /* Prepare normal labels */
1895- strcpy(label, alphabet_chars);
1896-
1897- /* Move each label */
1898- for (i = 0; i < 52; i++)
1899- {
1900- COMMAND_CODE index;
1901- SYMBOL_CODE c = alphabet_chars[i];
1902-
1903- /* Find a tag with this label */
1904- if (get_tag(&index, c, mode))
1905- {
1906- /* Delete the overwritten label */
1907- if (label[i] == c) label[i] = ' ';
1908-
1909- /* Move the label to the place of corresponding tag */
1910- label[index - offset] = c;
1911- }
1912- }
1913-}
1914-
1915-
1916-/*!
1917- * @brief タグIDにあわせてタグアルファベットのリストを返す(床上アイテム用) /
1918- * Move around label characters with correspond tags (floor version)
1919- * @param label ラベルリストを取得する文字列参照ポインタ
1920- * @param floor_list 床上アイテムの配列
1921- * @param floor_num 床上アイテムの配列ID
1922- * @return なし
1923- */
1924-/*
1925- */
1926-static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
1927-{
1928- concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1929- int i;
1930-
1931- /* Prepare normal labels */
1932- strcpy(label, alphabet_chars);
1933-
1934- /* Move each label */
1935- for (i = 0; i < 52; i++)
1936- {
1937- COMMAND_CODE index;
1938- SYMBOL_CODE c = alphabet_chars[i];
1939-
1940- /* Find a tag with this label */
1941- if (get_tag_floor(&index, c, floor_list, floor_num))
1942- {
1943- /* Delete the overwritten label */
1944- if (label[i] == c) label[i] = ' ';
1945-
1946- /* Move the label to the place of corresponding tag */
1947- label[index] = c;
1948- }
1949- }
1950-}
1951-
1952-
1953-/*!
1954- * @brief 所持アイテムの表示を行う /
1955- * Display the p_ptr->inventory_list.
1956- * @param target_item アイテムの選択処理を行うか否か。
1957- * @return 選択したアイテムのタグ
1958- * @details
1959- * Hack -- do not display "trailing" empty slots
1960- */
1961-COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode)
1962-{
1963- COMMAND_CODE i;
1964- int j, k, l, z = 0;
1965- int col, cur_col, len;
1966- object_type *o_ptr;
1967- GAME_TEXT o_name[MAX_NLEN];
1968- char tmp_val[80];
1969- COMMAND_CODE out_index[23];
1970- TERM_COLOR out_color[23];
1971- char out_desc[23][MAX_NLEN];
1972- COMMAND_CODE target_item_label = 0;
1973- TERM_LEN wid, hgt;
1974- char inven_label[52 + 1];
1975-
1976- /* Starting column */
1977- col = command_gap;
1978-
1979- Term_get_size(&wid, &hgt);
1980-
1981- /* Default "max-length" */
1982- len = wid - col - 1;
1983-
1984-
1985- /* Find the "final" slot */
1986- for (i = 0; i < INVEN_PACK; i++)
1987- {
1988- o_ptr = &p_ptr->inventory_list[i];
1989- if (!o_ptr->k_idx) continue;
1990-
1991- /* Track */
1992- z = i + 1;
1993- }
1994-
1995- prepare_label_string(inven_label, USE_INVEN);
1996-
1997- /* Display the p_ptr->inventory_list */
1998- for (k = 0, i = 0; i < z; i++)
1999- {
2000- o_ptr = &p_ptr->inventory_list[i];
2001-
2002- /* Is this item acceptable? */
2003- if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
2004-
2005- object_desc(o_name, o_ptr, 0);
2006-
2007- /* Save the object index, color, and description */
2008- out_index[k] = i;
2009- out_color[k] = tval_to_attr[o_ptr->tval % 128];
2010-
2011- /* Grey out charging items */
2012- if (o_ptr->timeout)
2013- {
2014- out_color[k] = TERM_L_DARK;
2015- }
2016-
2017- (void)strcpy(out_desc[k], o_name);
2018-
2019- /* Find the predicted "line length" */
2020- l = strlen(out_desc[k]) + 5;
2021-
2022- /* Be sure to account for the weight */
2023- if (show_weights) l += 9;
2024-
2025- /* Account for icon if displayed */
2026- if (show_item_graph)
2027- {
2028- l += 2;
2029- if (use_bigtile) l++;
2030- }
2031-
2032- /* Maintain the maximum length */
2033- if (l > len) len = l;
2034-
2035- /* Advance to next "line" */
2036- k++;
2037- }
2038-
2039- /* Find the column to start in */
2040- col = (len > wid - 4) ? 0 : (wid - len - 1);
2041-
2042- /* Output each entry */
2043- for (j = 0; j < k; j++)
2044- {
2045- i = out_index[j];
2046- o_ptr = &p_ptr->inventory_list[i];
2047-
2048- /* Clear the line */
2049- prt("", j + 1, col ? col - 2 : col);
2050-
2051- if (use_menu && target_item)
2052- {
2053- if (j == (target_item-1))
2054- {
2055- strcpy(tmp_val, _("》", "> "));
2056- target_item_label = i;
2057- }
2058- else strcpy(tmp_val, " ");
2059- }
2060- else if (i <= INVEN_PACK)
2061- {
2062- /* Prepare an index --(-- */
2063- sprintf(tmp_val, "%c)", inven_label[i]);
2064- }
2065- else
2066- {
2067- /* Prepare an index --(-- */
2068- sprintf(tmp_val, "%c)", index_to_label(i));
2069- }
2070-
2071- /* Clear the line with the (possibly indented) index */
2072- put_str(tmp_val, j + 1, col);
2073-
2074- cur_col = col + 3;
2075-
2076- /* Display graphics for object, if desired */
2077- if (show_item_graph)
2078- {
2079- TERM_COLOR a = object_attr(o_ptr);
2080- SYMBOL_CODE c = object_char(o_ptr);
2081- Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2082- if (use_bigtile) cur_col++;
2083-
2084- cur_col += 2;
2085- }
2086-
2087-
2088- /* Display the entry itself */
2089- c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
2090-
2091- /* Display the weight if needed */
2092- if (show_weights)
2093- {
2094- int wgt = o_ptr->weight * o_ptr->number;
2095-#ifdef JP
2096- (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2097-#else
2098- (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
2099-#endif
2100-
2101- prt(tmp_val, j + 1, wid - 9);
2102- }
2103- }
2104-
2105- /* Make a "shadow" below the list (only if needed) */
2106- if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2107-
2108- /* Save the new column */
2109- command_gap = col;
2110-
2111- return target_item_label;
2112-}
2113-
2114-
2115-/*!
2116- * @brief 選択したアイテムの確認処理の補助 /
2117- * Verify the choice of an item.
2118- * @param prompt メッセージ表示の一部
2119- * @param item 選択アイテムID
2120- * @return 確認がYesならTRUEを返す。
2121- * @details The item can be negative to mean "item on floor".
2122- */
2123-static bool verify(concptr prompt, INVENTORY_IDX item)
2124-{
2125- GAME_TEXT o_name[MAX_NLEN];
2126- char out_val[MAX_NLEN+20];
2127- object_type *o_ptr;
2128-
2129-
2130- /* Inventory */
2131- if (item >= 0)
2132- {
2133- o_ptr = &p_ptr->inventory_list[item];
2134- }
2135-
2136- /* Floor */
2137- else
2138- {
2139- o_ptr = &current_floor_ptr->o_list[0 - item];
2140- }
2141- object_desc(o_name, o_ptr, 0);
2142-
2143- /* Prompt */
2144- (void)sprintf(out_val, _("%s%sですか? ", "%s %s? "), prompt, o_name);
2145-
2146- /* Query */
2147- return (get_check(out_val));
2148-}
2149-
2150-
2151-/*!
2152- * @brief 選択したアイテムの確認処理のメインルーチン /
2153- * @param item 選択アイテムID
2154- * @return 確認がYesならTRUEを返す。
2155- * @details The item can be negative to mean "item on floor".
2156- * Hack -- allow user to "prevent" certain choices
2157- */
2158-static bool get_item_allow(INVENTORY_IDX item)
2159-{
2160- concptr s;
2161- object_type *o_ptr;
2162- if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
2163-
2164- /* Inventory */
2165- if (item >= 0)
2166- {
2167- o_ptr = &p_ptr->inventory_list[item];
2168- }
2169-
2170- /* Floor */
2171- else
2172- {
2173- o_ptr = &current_floor_ptr->o_list[0 - item];
2174- }
2175-
2176- /* No inscription */
2177- if (!o_ptr->inscription) return (TRUE);
2178-
2179- /* Find a '!' */
2180- s = my_strchr(quark_str(o_ptr->inscription), '!');
2181-
2182- /* Process preventions */
2183- while (s)
2184- {
2185- /* Check the "restriction" */
2186- if ((s[1] == command_cmd) || (s[1] == '*'))
2187- {
2188- /* Verify the choice */
2189- if (!verify(_("本当に", "Really try"), item)) return (FALSE);
2190- }
2191-
2192- /* Find another '!' */
2193- s = my_strchr(s + 1, '!');
2194- }
2195-
2196- /* Allow it */
2197- return (TRUE);
2198-}
2199-
2200-
2201-/*!
2202- * @brief オブジェクト選択の汎用関数 /
2203- * Let the user select an item, save its "index"
2204- * @param cp 選択したオブジェクトのIDを返す。
2205- * @param pmt 選択目的のメッセージ
2206- * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
2207- * @param mode オプションフラグ
2208- * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
2209- * Return TRUE only if an acceptable item was chosen by the user.\n
2210- * @details
2211- * The selected item must satisfy the "item_tester_hook()" function,\n
2212- * if that hook is set, and the "item_tester_tval", if that value is set.\n
2213- *\n
2214- * All "item_tester" restrictions are cleared before this function returns.\n
2215- *\n
2216- * The user is allowed to choose acceptable items from the equipment,\n
2217- * p_ptr->inventory_list, or floor, respectively, if the proper flag was given,\n
2218- * and there are any acceptable items in that location.\n
2219- *\n
2220- * The equipment or p_ptr->inventory_list are displayed (even if no acceptable\n
2221- * items are in that location) if the proper flag was given.\n
2222- *\n
2223- * If there are no acceptable items available anywhere, and "str" is\n
2224- * not NULL, then it will be used as the text of a warning message\n
2225- * before the function returns.\n
2226- *\n
2227- * Note that the user must press "-" to specify the item on the floor,\n
2228- * and there is no way to "examine" the item on the floor, while the\n
2229- * use of "capital" letters will "examine" an p_ptr->inventory_list/equipment item,\n
2230- * and prompt for its use.\n
2231- *\n
2232- * If a legal item is selected from the p_ptr->inventory_list, we save it in "cp"\n
2233- * directly (0 to 35), and return TRUE.\n
2234- *\n
2235- * If a legal item is selected from the floor, we save it in "cp" as\n
2236- * a negative (-1 to -511), and return TRUE.\n
2237- *\n
2238- * If no item is available, we do nothing to "cp", and we display a\n
2239- * warning message, using "str" if available, and return FALSE.\n
2240- *\n
2241- * If no item is selected, we do nothing to "cp", and return FALSE.\n
2242- *\n
2243- * Global "p_ptr->command_new" is used when viewing the p_ptr->inventory_list or equipment\n
2244- * to allow the user to enter a command while viewing those screens, and\n
2245- * also to induce "auto-enter" of stores, and other such stuff.\n
2246- *\n
2247- * Global "p_ptr->command_see" may be set before calling this function to start\n
2248- * out in "browse" mode. It is cleared before this function returns.\n
2249- *\n
2250- * Global "p_ptr->command_wrk" is used to choose between equip/inven listings.\n
2251- * If it is TRUE then we are viewing p_ptr->inventory_list, else equipment.\n
2252- *\n
2253- * We always erase the prompt when we are done, leaving a blank line,\n
2254- * or a warning message, if appropriate, if no items are available.\n
2255- */
2256-bool get_item(OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode)
2257-{
2258- OBJECT_IDX this_o_idx, next_o_idx = 0;
2259-
2260- char which = ' ';
2261-
2262- int j;
2263- OBJECT_IDX k;
2264- OBJECT_IDX i1, i2;
2265- OBJECT_IDX e1, e2;
2266-
2267- bool done, item;
2268-
2269- bool oops = FALSE;
2270-
2271- bool equip = FALSE;
2272- bool inven = FALSE;
2273- bool floor = FALSE;
2274-
2275- bool allow_floor = FALSE;
2276-
2277- bool toggle = FALSE;
2278-
2279- char tmp_val[160];
2280- char out_val[160];
2281-
2282- int menu_line = (use_menu ? 1 : 0);
2283- int max_inven = 0;
2284- int max_equip = 0;
2285-
2286- static char prev_tag = '\0';
2287- char cur_tag = '\0';
2288-
2289- if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode);
2290-
2291- /* Extract args */
2292- if (mode & USE_EQUIP) equip = TRUE;
2293- if (mode & USE_INVEN) inven = TRUE;
2294- if (mode & USE_FLOOR) floor = TRUE;
2295-
2296- /* Get the item index */
2297- if (repeat_pull(cp))
2298- {
2299- /* the_force */
2300- if (mode & USE_FORCE && (*cp == INVEN_FORCE))
2301- {
2302- item_tester_tval = 0;
2303- item_tester_hook = NULL;
2304- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2305- return (TRUE);
2306- }
2307-
2308- /* Floor item? */
2309- else if (floor && (*cp < 0))
2310- {
2311- object_type *o_ptr;
2312-
2313- /* Special index */
2314- k = 0 - (*cp);
2315- o_ptr = &current_floor_ptr->o_list[k];
2316-
2317- /* Validate the item */
2318- if (item_tester_okay(o_ptr) || (mode & USE_FULL))
2319- {
2320- /* Forget restrictions */
2321- item_tester_tval = 0;
2322- item_tester_hook = NULL;
2323- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2324-
2325- /* Success */
2326- return TRUE;
2327- }
2328- }
2329-
2330- else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
2331- (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
2332- {
2333- if (prev_tag && command_cmd)
2334- {
2335- /* Look up the tag and validate the item */
2336- if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
2337- else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
2338- else if (!get_item_okay(k)) /* Reject */;
2339- else
2340- {
2341- /* Accept that choice */
2342- (*cp) = k;
2343-
2344- /* Forget restrictions */
2345- item_tester_tval = 0;
2346- item_tester_hook = NULL;
2347- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2348-
2349- /* Success */
2350- return TRUE;
2351- }
2352-
2353- prev_tag = '\0'; /* prev_tag is no longer effective */
2354- }
2355-
2356- /* Verify the item */
2357- else if (get_item_okay(*cp))
2358- {
2359- /* Forget restrictions */
2360- item_tester_tval = 0;
2361- item_tester_hook = NULL;
2362- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2363-
2364- /* Success */
2365- return TRUE;
2366- }
2367- }
2368- }
2369- msg_print(NULL);
2370-
2371- /* Not done */
2372- done = FALSE;
2373-
2374- /* No item selected */
2375- item = FALSE;
2376-
2377-
2378- /* Full p_ptr->inventory_list */
2379- i1 = 0;
2380- i2 = INVEN_PACK - 1;
2381-
2382- /* Forbid p_ptr->inventory_list */
2383- if (!inven) i2 = -1;
2384- else if (use_menu)
2385- {
2386- for (j = 0; j < INVEN_PACK; j++)
2387- if (item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_inven++;
2388- }
2389-
2390- /* Restrict p_ptr->inventory_list indexes */
2391- while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
2392- while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
2393-
2394-
2395- /* Full equipment */
2396- e1 = INVEN_RARM;
2397- e2 = INVEN_TOTAL - 1;
2398-
2399- /* Forbid equipment */
2400- if (!equip) e2 = -1;
2401- else if (use_menu)
2402- {
2403- for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
2404- if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_equip++;
2405- if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
2406- }
2407-
2408- /* Restrict equipment indexes */
2409- while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
2410- while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
2411-
2412- if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
2413- {
2414- if (p_ptr->migite)
2415- {
2416- if (e2 < INVEN_LARM) e2 = INVEN_LARM;
2417- }
2418- else if (p_ptr->hidarite) e1 = INVEN_RARM;
2419- }
2420-
2421-
2422- /* Restrict floor usage */
2423- if (floor)
2424- {
2425- /* Scan all objects in the grid */
2426- for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2427- {
2428- object_type *o_ptr;
2429- o_ptr = &current_floor_ptr->o_list[this_o_idx];
2430- next_o_idx = o_ptr->next_o_idx;
2431-
2432- /* Accept the item on the floor if legal */
2433- if ((item_tester_okay(o_ptr) || (mode & USE_FULL)) && (o_ptr->marked & OM_FOUND)) allow_floor = TRUE;
2434- }
2435- }
2436-
2437- /* Require at least one legal choice */
2438- if (!allow_floor && (i1 > i2) && (e1 > e2))
2439- {
2440- /* Cancel p_ptr->command_see */
2441- command_see = FALSE;
2442- oops = TRUE;
2443- done = TRUE;
2444-
2445- if (mode & USE_FORCE) {
2446- *cp = INVEN_FORCE;
2447- item = TRUE;
2448- }
2449- }
2450-
2451- /* Analyze choices */
2452- else
2453- {
2454- /* Hack -- Start on equipment if requested */
2455- if (command_see && command_wrk && equip)
2456- {
2457- command_wrk = TRUE;
2458- }
2459-
2460- /* Use p_ptr->inventory_list if allowed */
2461- else if (inven)
2462- {
2463- command_wrk = FALSE;
2464- }
2465-
2466- /* Use equipment if allowed */
2467- else if (equip)
2468- {
2469- command_wrk = TRUE;
2470- }
2471-
2472- /* Use p_ptr->inventory_list for floor */
2473- else
2474- {
2475- command_wrk = FALSE;
2476- }
2477- }
2478-
2479-
2480- /*
2481- * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
2482- */
2483- if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
2484-
2485- /* Hack -- start out in "display" mode */
2486- if (command_see)
2487- {
2488- screen_save();
2489- }
2490-
2491-
2492- /* Repeat until done */
2493- while (!done)
2494- {
2495- COMMAND_CODE get_item_label = 0;
2496-
2497- /* Show choices */
2498- int ni = 0;
2499- int ne = 0;
2500-
2501- /* Scan windows */
2502- for (j = 0; j < 8; j++)
2503- {
2504- /* Unused */
2505- if (!angband_term[j]) continue;
2506-
2507- /* Count windows displaying inven */
2508- if (window_flag[j] & (PW_INVEN)) ni++;
2509-
2510- /* Count windows displaying equip */
2511- if (window_flag[j] & (PW_EQUIP)) ne++;
2512- }
2513-
2514- /* Toggle if needed */
2515- if ((command_wrk && ni && !ne) || (!command_wrk && !ni && ne))
2516- {
2517- /* Toggle */
2518- toggle_inven_equip();
2519-
2520- /* Track toggles */
2521- toggle = !toggle;
2522- }
2523-
2524- p_ptr->window |= (PW_INVEN | PW_EQUIP);
2525- handle_stuff();
2526-
2527- /* Inventory screen */
2528- if (!command_wrk)
2529- {
2530- /* Redraw if needed */
2531- if (command_see) get_item_label = show_inven(menu_line, mode);
2532- }
2533-
2534- /* Equipment screen */
2535- else
2536- {
2537- /* Redraw if needed */
2538- if (command_see) get_item_label = show_equip(menu_line, mode);
2539- }
2540-
2541- /* Viewing p_ptr->inventory_list */
2542- if (!command_wrk)
2543- {
2544- /* Begin the prompt */
2545- sprintf(out_val, _("持ち物:", "Inven:"));
2546-
2547- /* Some legal items */
2548- if ((i1 <= i2) && !use_menu)
2549- {
2550- /* Build the prompt */
2551- sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2552- index_to_label(i1), index_to_label(i2));
2553-
2554- /* Append */
2555- strcat(out_val, tmp_val);
2556- }
2557-
2558- /* Indicate ability to "view" */
2559- if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2560-
2561- /* Append */
2562- if (equip) strcat(out_val, format(_(" %s 装備品,", " %s for Equip,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "/")));
2563- }
2564-
2565- /* Viewing equipment */
2566- else
2567- {
2568- /* Begin the prompt */
2569- sprintf(out_val, _("装備品:", "Equip:"));
2570-
2571- /* Some legal items */
2572- if ((e1 <= e2) && !use_menu)
2573- {
2574- /* Build the prompt */
2575- sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2576- index_to_label(e1), index_to_label(e2));
2577-
2578- /* Append */
2579- strcat(out_val, tmp_val);
2580- }
2581-
2582- /* Indicate ability to "view" */
2583- if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2584-
2585- /* Append */
2586- if (inven) strcat(out_val, format(_(" %s 持ち物,", " %s for Inven,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "'/'")));
2587- }
2588-
2589- /* Indicate legality of the "floor" item */
2590- if (allow_floor) strcat(out_val, _(" '-'床上,", " - for floor,"));
2591- if (mode & USE_FORCE) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
2592-
2593- /* Finish the prompt */
2594- strcat(out_val, " ESC");
2595-
2596- /* Build the prompt */
2597- sprintf(tmp_val, "(%s) %s", out_val, pmt);
2598-
2599- /* Show the prompt */
2600- prt(tmp_val, 0, 0);
2601-
2602- /* Get a key */
2603- which = inkey();
2604-
2605- if (use_menu)
2606- {
2607- int max_line = (command_wrk ? max_equip : max_inven);
2608- switch (which)
2609- {
2610- case ESCAPE:
2611- case 'z':
2612- case 'Z':
2613- case '0':
2614- {
2615- done = TRUE;
2616- break;
2617- }
2618-
2619- case '8':
2620- case 'k':
2621- case 'K':
2622- {
2623- menu_line += (max_line - 1);
2624- break;
2625- }
2626-
2627- case '2':
2628- case 'j':
2629- case 'J':
2630- {
2631- menu_line++;
2632- break;
2633- }
2634-
2635- case '4':
2636- case '6':
2637- case 'h':
2638- case 'H':
2639- case 'l':
2640- case 'L':
2641- {
2642- /* Verify legality */
2643- if (!inven || !equip)
2644- {
2645- bell();
2646- break;
2647- }
2648-
2649- /* Hack -- Fix screen */
2650- if (command_see)
2651- {
2652- screen_load();
2653- screen_save();
2654- }
2655-
2656- /* Switch inven/equip */
2657- command_wrk = !command_wrk;
2658- max_line = (command_wrk ? max_equip : max_inven);
2659- if (menu_line > max_line) menu_line = max_line;
2660-
2661- /* Need to redraw */
2662- break;
2663- }
2664-
2665- case 'x':
2666- case 'X':
2667- case '\r':
2668- case '\n':
2669- {
2670- if (command_wrk == USE_FLOOR)
2671- {
2672- /* Special index */
2673- (*cp) = -get_item_label;
2674- }
2675- else
2676- {
2677- /* Validate the item */
2678- if (!get_item_okay(get_item_label))
2679- {
2680- bell();
2681- break;
2682- }
2683-
2684- /* Allow player to "refuse" certain actions */
2685- if (!get_item_allow(get_item_label))
2686- {
2687- done = TRUE;
2688- break;
2689- }
2690-
2691- /* Accept that choice */
2692- (*cp) = get_item_label;
2693- }
2694-
2695- item = TRUE;
2696- done = TRUE;
2697- break;
2698- }
2699- case 'w':
2700- {
2701- if (mode & USE_FORCE) {
2702- *cp = INVEN_FORCE;
2703- item = TRUE;
2704- done = TRUE;
2705- break;
2706- }
2707- }
2708- }
2709- if (menu_line > max_line) menu_line -= max_line;
2710- }
2711- else
2712- {
2713- /* Parse it */
2714- switch (which)
2715- {
2716- case ESCAPE:
2717- {
2718- done = TRUE;
2719- break;
2720- }
2721-
2722- case '*':
2723- case '?':
2724- case ' ':
2725- {
2726- /* Hide the list */
2727- if (command_see)
2728- {
2729- /* Flip flag */
2730- command_see = FALSE;
2731- screen_load();
2732- }
2733-
2734- /* Show the list */
2735- else
2736- {
2737- screen_save();
2738-
2739- /* Flip flag */
2740- command_see = TRUE;
2741- }
2742- break;
2743- }
2744-
2745- case '/':
2746- {
2747- /* Verify legality */
2748- if (!inven || !equip)
2749- {
2750- bell();
2751- break;
2752- }
2753-
2754- /* Hack -- Fix screen */
2755- if (command_see)
2756- {
2757- screen_load();
2758- screen_save();
2759- }
2760-
2761- /* Switch inven/equip */
2762- command_wrk = !command_wrk;
2763-
2764- /* Need to redraw */
2765- break;
2766- }
2767-
2768- case '-':
2769- {
2770- /* Use floor item */
2771- if (allow_floor)
2772- {
2773- /* Scan all objects in the grid */
2774- for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2775- {
2776- object_type *o_ptr;
2777- o_ptr = &current_floor_ptr->o_list[this_o_idx];
2778- next_o_idx = o_ptr->next_o_idx;
2779-
2780- /* Validate the item */
2781- if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
2782-
2783- /* Special index */
2784- k = 0 - this_o_idx;
2785-
2786- /* Verify the item (if required) */
2787- if (other_query_flag && !verify(_("本当に", "Try"), k)) continue;
2788-
2789- /* Allow player to "refuse" certain actions */
2790- if (!get_item_allow(k)) continue;
2791-
2792- /* Accept that choice */
2793- (*cp) = k;
2794- item = TRUE;
2795- done = TRUE;
2796- break;
2797- }
2798-
2799- /* Outer break */
2800- if (done) break;
2801- }
2802-
2803- bell();
2804- break;
2805- }
2806-
2807- case '0':
2808- case '1': case '2': case '3':
2809- case '4': case '5': case '6':
2810- case '7': case '8': case '9':
2811- {
2812- /* Look up the tag */
2813- if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
2814- {
2815- bell();
2816- break;
2817- }
2818-
2819- /* Hack -- Validate the item */
2820- if ((k < INVEN_RARM) ? !inven : !equip)
2821- {
2822- bell();
2823- break;
2824- }
2825-
2826- /* Validate the item */
2827- if (!get_item_okay(k))
2828- {
2829- bell();
2830- break;
2831- }
2832-
2833- /* Allow player to "refuse" certain actions */
2834- if (!get_item_allow(k))
2835- {
2836- done = TRUE;
2837- break;
2838- }
2839-
2840- /* Accept that choice */
2841- (*cp) = k;
2842- item = TRUE;
2843- done = TRUE;
2844- cur_tag = which;
2845- break;
2846- }
2847-
2848-#if 0
2849- case '\n':
2850- case '\r':
2851- {
2852- /* Choose "default" p_ptr->inventory_list item */
2853- if (!command_wrk)
2854- {
2855- k = ((i1 == i2) ? i1 : -1);
2856- }
2857-
2858- /* Choose "default" equipment item */
2859- else
2860- {
2861- k = ((e1 == e2) ? e1 : -1);
2862- }
2863-
2864- /* Validate the item */
2865- if (!get_item_okay(k))
2866- {
2867- bell();
2868- break;
2869- }
2870-
2871- /* Allow player to "refuse" certain actions */
2872- if (!get_item_allow(k))
2873- {
2874- done = TRUE;
2875- break;
2876- }
2877-
2878- /* Accept that choice */
2879- (*cp) = k;
2880- item = TRUE;
2881- done = TRUE;
2882- break;
2883- }
2884-#endif
2885-
2886- case 'w':
2887- {
2888- if (mode & USE_FORCE) {
2889- *cp = INVEN_FORCE;
2890- item = TRUE;
2891- done = TRUE;
2892- break;
2893- }
2894-
2895- /* Fall through */
2896- }
2897-
2898- default:
2899- {
2900- int ver;
2901- bool not_found = FALSE;
2902-
2903- /* Look up the alphabetical tag */
2904- if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
2905- {
2906- not_found = TRUE;
2907- }
2908-
2909- /* Hack -- Validate the item */
2910- else if ((k < INVEN_RARM) ? !inven : !equip)
2911- {
2912- not_found = TRUE;
2913- }
2914-
2915- /* Validate the item */
2916- else if (!get_item_okay(k))
2917- {
2918- not_found = TRUE;
2919- }
2920-
2921- if (!not_found)
2922- {
2923- /* Accept that choice */
2924- (*cp) = k;
2925- item = TRUE;
2926- done = TRUE;
2927- cur_tag = which;
2928- break;
2929- }
2930-
2931- /* Extract "query" setting */
2932- ver = isupper(which);
2933- which = (char)tolower(which);
2934-
2935- /* Convert letter to p_ptr->inventory_list index */
2936- if (!command_wrk)
2937- {
2938- if (which == '(') k = i1;
2939- else if (which == ')') k = i2;
2940- else k = label_to_inven(which);
2941- }
2942-
2943- /* Convert letter to equipment index */
2944- else
2945- {
2946- if (which == '(') k = e1;
2947- else if (which == ')') k = e2;
2948- else k = label_to_equip(which);
2949- }
2950-
2951- /* Validate the item */
2952- if (!get_item_okay(k))
2953- {
2954- bell();
2955- break;
2956- }
2957-
2958- /* Verify the item */
2959- if (ver && !verify(_("本当に", "Try"), k))
2960- {
2961- done = TRUE;
2962- break;
2963- }
2964-
2965- /* Allow player to "refuse" certain actions */
2966- if (!get_item_allow(k))
2967- {
2968- done = TRUE;
2969- break;
2970- }
2971-
2972- /* Accept that choice */
2973- (*cp) = k;
2974- item = TRUE;
2975- done = TRUE;
2976- break;
2977- }
2978- }
2979- }
2980- }
2981-
2982-
2983- /* Fix the screen if necessary */
2984- if (command_see)
2985- {
2986- screen_load();
2987-
2988- /* Hack -- Cancel "display" */
2989- command_see = FALSE;
2990- }
2991-
2992-
2993- /* Forget the item_tester_tval restriction */
2994- item_tester_tval = 0;
2995-
2996- /* Forget the item_tester_hook restriction */
2997- item_tester_hook = NULL;
2998-
2999-
3000- /* Clean up 'show choices' */
3001- /* Toggle again if needed */
3002- if (toggle) toggle_inven_equip();
3003-
3004- p_ptr->window |= (PW_INVEN | PW_EQUIP);
3005- handle_stuff();
3006-
3007- /* Clear the prompt line */
3008- prt("", 0, 0);
3009-
3010- /* Warning if needed */
3011- if (oops && str) msg_print(str);
3012-
3013- if (item)
3014- {
3015- repeat_push(*cp);
3016- if (command_cmd) prev_tag = cur_tag;
3017- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3018- }
3019- return (item);
3020-}
3021-
3022-/*
3023- * Choose an item and get auto-picker entry from it.
3024- */
3025-object_type *choose_object(OBJECT_IDX *idx, concptr q, concptr s, BIT_FLAGS option)
3026-{
3027- OBJECT_IDX item;
3028- if (!get_item(&item, q, s, option)) return NULL;
3029- if (idx) *idx = item;
3030-
3031- if (item == INVEN_FORCE) return NULL;
3032-
3033- /* Get the item (in the pack) */
3034- else if (item >= 0) return &p_ptr->inventory_list[item];
3035-
3036- /* Get the item (on the floor) */
3037- else return &current_floor_ptr->o_list[0 - item];
3038-}
3039-
3040-
3041-/*!
3042- * @brief 床下に落ちているオブジェクトの数を返す / scan_floor
3043- * @param items オブジェクトのIDリストを返すための配列参照ポインタ
3044- * @param y 走査するフロアのY座標
3045- * @param x 走査するフロアのX座標
3046- * @param mode オプションフラグ
3047- * @return 対象のマスに落ちているアイテム数
3048- * @details
3049- * Return a list of o_list[] indexes of items at the given current_floor_ptr->grid_array
3050- * location. Valid flags are:
3051- *
3052- * mode & 0x01 -- Item tester
3053- * mode & 0x02 -- Marked items only
3054- * mode & 0x04 -- Stop after first
3055- */
3056-ITEM_NUMBER scan_floor(OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode)
3057-{
3058- OBJECT_IDX this_o_idx, next_o_idx;
3059-
3060- ITEM_NUMBER num = 0;
3061-
3062- /* Sanity */
3063- if (!in_bounds(y, x)) return 0;
3064-
3065- /* Scan all objects in the grid */
3066- for (this_o_idx = current_floor_ptr->grid_array[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3067- {
3068- object_type *o_ptr;
3069- o_ptr = &current_floor_ptr->o_list[this_o_idx];
3070- next_o_idx = o_ptr->next_o_idx;
3071-
3072- /* Item tester */
3073- if ((mode & 0x01) && !item_tester_okay(o_ptr)) continue;
3074-
3075- /* Marked */
3076- if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
3077-
3078- /* Accept this item */
3079- /* XXX Hack -- Enforce limit */
3080- if (num < 23)
3081- items[num] = this_o_idx;
3082-
3083- num++;
3084-
3085- /* Only one */
3086- if (mode & 0x04) break;
3087- }
3088- return num;
3089-}
3090-
3091-
3092-/*!
3093- * @brief 床下に落ちているアイテムの一覧を返す / Display a list of the items on the floor at the given location.
3094- * @param target_item カーソルの初期値
3095- * @param y 走査するフロアのY座標
3096- * @param x 走査するフロアのX座標
3097- * @param min_width 表示の長さ
3098- * @return 選択したアイテムの添え字
3099- * @details
3100- */
3101-COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_LEN *min_width)
3102-{
3103- COMMAND_CODE i, m;
3104- int j, k, l;
3105- int col, len;
3106-
3107- object_type *o_ptr;
3108-
3109- GAME_TEXT o_name[MAX_NLEN];
3110- char tmp_val[80];
3111-
3112- COMMAND_CODE out_index[23];
3113- TERM_COLOR out_color[23];
3114- char out_desc[23][MAX_NLEN];
3115- COMMAND_CODE target_item_label = 0;
3116-
3117- OBJECT_IDX floor_list[23];
3118- ITEM_NUMBER floor_num;
3119- TERM_LEN wid, hgt;
3120- char floor_label[52 + 1];
3121-
3122- bool dont_need_to_show_weights = TRUE;
3123-
3124- Term_get_size(&wid, &hgt);
3125-
3126- /* Default length */
3127- len = MAX((*min_width), 20);
3128-
3129- /* Scan for objects in the grid, using item_tester_okay() */
3130- floor_num = scan_floor(floor_list, y, x, 0x03);
3131-
3132- /* Display the floor objects */
3133- for (k = 0, i = 0; i < floor_num && i < 23; i++)
3134- {
3135- o_ptr = &current_floor_ptr->o_list[floor_list[i]];
3136-
3137- object_desc(o_name, o_ptr, 0);
3138-
3139- /* Save the index */
3140- out_index[k] = i;
3141-
3142- /* Acquire p_ptr->inventory_list color */
3143- out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
3144-
3145- /* Save the object description */
3146- strcpy(out_desc[k], o_name);
3147-
3148- /* Find the predicted "line length" */
3149- l = strlen(out_desc[k]) + 5;
3150-
3151- /* Be sure to account for the weight */
3152- if (show_weights) l += 9;
3153-
3154- if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
3155-
3156- /* Maintain the maximum length */
3157- if (l > len) len = l;
3158-
3159- /* Advance to next "line" */
3160- k++;
3161- }
3162-
3163- if (show_weights && dont_need_to_show_weights) len -= 9;
3164-
3165- /* Save width */
3166- *min_width = len;
3167-
3168- /* Find the column to start in */
3169- col = (len > wid - 4) ? 0 : (wid - len - 1);
3170-
3171- prepare_label_string_floor(floor_label, floor_list, floor_num);
3172-
3173- /* Output each entry */
3174- for (j = 0; j < k; j++)
3175- {
3176- m = floor_list[out_index[j]];
3177- o_ptr = &current_floor_ptr->o_list[m];
3178-
3179- /* Clear the line */
3180- prt("", j + 1, col ? col - 2 : col);
3181-
3182- if (use_menu && target_item)
3183- {
3184- if (j == (target_item-1))
3185- {
3186- strcpy(tmp_val, _("》", "> "));
3187- target_item_label = m;
3188- }
3189- else strcpy(tmp_val, " ");
3190- }
3191- else
3192- {
3193- /* Prepare an index --(-- */
3194- sprintf(tmp_val, "%c)", floor_label[j]);
3195- }
3196-
3197- /* Clear the line with the (possibly indented) index */
3198- put_str(tmp_val, j + 1, col);
3199-
3200- /* Display the entry itself */
3201- c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
3202-
3203- /* Display the weight if needed */
3204- if (show_weights && (o_ptr->tval != TV_GOLD))
3205- {
3206- int wgt = o_ptr->weight * o_ptr->number;
3207-#ifdef JP
3208- sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
3209-#else
3210- sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
3211-#endif
3212-
3213- prt(tmp_val, j + 1, wid - 9);
3214- }
3215- }
3216-
3217- /* Make a "shadow" below the list (only if needed) */
3218- if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3219-
3220- return target_item_label;
3221-}
3222-
3223-/*!
3224- * @brief オブジェクト選択の汎用関数(床上アイテム用) /
3225- * Let the user select an item, save its "index"
3226- * @param cp 選択したオブジェクトのIDを返す。
3227- * @param pmt 選択目的のメッセージ
3228- * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
3229- * @param mode オプションフラグ
3230- * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
3231- */
3232-bool get_item_floor(COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode)
3233-{
3234- char n1 = ' ', n2 = ' ', which = ' ';
3235-
3236- int j;
3237- COMMAND_CODE i1, i2;
3238- COMMAND_CODE e1, e2;
3239- COMMAND_CODE k;
3240-
3241- bool done, item;
3242-
3243- bool oops = FALSE;
3244-
3245- /* Extract args */
3246- bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
3247- bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
3248- bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
3249- bool force = (mode & USE_FORCE) ? TRUE : FALSE;
3250-
3251- bool allow_equip = FALSE;
3252- bool allow_inven = FALSE;
3253- bool allow_floor = FALSE;
3254-
3255- bool toggle = FALSE;
3256-
3257- char tmp_val[160];
3258- char out_val[160];
3259-
3260- ITEM_NUMBER floor_num;
3261- OBJECT_IDX floor_list[23];
3262- int floor_top = 0;
3263- TERM_LEN min_width = 0;
3264-
3265- int menu_line = (use_menu ? 1 : 0);
3266- int max_inven = 0;
3267- int max_equip = 0;
3268-
3269- static char prev_tag = '\0';
3270- char cur_tag = '\0';
3271-
3272- /* Get the item index */
3273- if (repeat_pull(cp))
3274- {
3275- /* the_force */
3276- if (force && (*cp == INVEN_FORCE))
3277- {
3278- item_tester_tval = 0;
3279- item_tester_hook = NULL;
3280- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3281- return (TRUE);
3282- }
3283-
3284- /* Floor item? */
3285- else if (floor && (*cp < 0))
3286- {
3287- if (prev_tag && command_cmd)
3288- {
3289- /* Scan all objects in the grid */
3290- floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3291-
3292- /* Look up the tag */
3293- if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
3294- {
3295- /* Accept that choice */
3296- (*cp) = 0 - floor_list[k];
3297-
3298- /* Forget restrictions */
3299- item_tester_tval = 0;
3300- item_tester_hook = NULL;
3301- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3302-
3303- /* Success */
3304- return TRUE;
3305- }
3306-
3307- prev_tag = '\0'; /* prev_tag is no longer effective */
3308- }
3309-
3310- /* Validate the item */
3311- else if (item_tester_okay(&current_floor_ptr->o_list[0 - (*cp)]) || (mode & USE_FULL))
3312- {
3313- /* Forget restrictions */
3314- item_tester_tval = 0;
3315- item_tester_hook = NULL;
3316- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3317-
3318- /* Success */
3319- return TRUE;
3320- }
3321- }
3322-
3323- else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
3324- (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
3325- {
3326- if (prev_tag && command_cmd)
3327- {
3328- /* Look up the tag and validate the item */
3329- if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
3330- else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
3331- else if (!get_item_okay(k)) /* Reject */;
3332- else
3333- {
3334- /* Accept that choice */
3335- (*cp) = k;
3336-
3337- /* Forget restrictions */
3338- item_tester_tval = 0;
3339- item_tester_hook = NULL;
3340- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3341-
3342- /* Success */
3343- return TRUE;
3344- }
3345-
3346- prev_tag = '\0'; /* prev_tag is no longer effective */
3347- }
3348-
3349- /* Verify the item */
3350- else if (get_item_okay(*cp))
3351- {
3352- /* Forget restrictions */
3353- item_tester_tval = 0;
3354- item_tester_hook = NULL;
3355- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3356-
3357- /* Success */
3358- return TRUE;
3359- }
3360- }
3361- }
3362-
3363- msg_print(NULL);
3364-
3365-
3366- /* Not done */
3367- done = FALSE;
3368-
3369- /* No item selected */
3370- item = FALSE;
3371-
3372-
3373- /* Full p_ptr->inventory_list */
3374- i1 = 0;
3375- i2 = INVEN_PACK - 1;
3376-
3377- /* Forbid p_ptr->inventory_list */
3378- if (!inven) i2 = -1;
3379- else if (use_menu)
3380- {
3381- for (j = 0; j < INVEN_PACK; j++)
3382- if (item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_inven++;
3383- }
3384-
3385- /* Restrict p_ptr->inventory_list indexes */
3386- while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
3387- while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
3388-
3389-
3390- /* Full equipment */
3391- e1 = INVEN_RARM;
3392- e2 = INVEN_TOTAL - 1;
3393-
3394- /* Forbid equipment */
3395- if (!equip) e2 = -1;
3396- else if (use_menu)
3397- {
3398- for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
3399- if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_equip++;
3400- if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
3401- }
3402-
3403- /* Restrict equipment indexes */
3404- while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
3405- while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
3406-
3407- if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
3408- {
3409- if (p_ptr->migite)
3410- {
3411- if (e2 < INVEN_LARM) e2 = INVEN_LARM;
3412- }
3413- else if (p_ptr->hidarite) e1 = INVEN_RARM;
3414- }
3415-
3416-
3417- /* Count "okay" floor items */
3418- floor_num = 0;
3419-
3420- /* Restrict floor usage */
3421- if (floor)
3422- {
3423- /* Scan all objects in the grid */
3424- floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3425- }
3426-
3427- /* Accept p_ptr->inventory_list */
3428- if (i1 <= i2) allow_inven = TRUE;
3429-
3430- /* Accept equipment */
3431- if (e1 <= e2) allow_equip = TRUE;
3432-
3433- /* Accept floor */
3434- if (floor_num) allow_floor = TRUE;
3435-
3436- /* Require at least one legal choice */
3437- if (!allow_inven && !allow_equip && !allow_floor)
3438- {
3439- /* Cancel p_ptr->command_see */
3440- command_see = FALSE;
3441- oops = TRUE;
3442- done = TRUE;
3443-
3444- if (force) {
3445- *cp = INVEN_FORCE;
3446- item = TRUE;
3447- }
3448- }
3449-
3450- /* Analyze choices */
3451- else
3452- {
3453- /* Hack -- Start on equipment if requested */
3454- if (command_see && (command_wrk == (USE_EQUIP))
3455- && allow_equip)
3456- {
3457- command_wrk = (USE_EQUIP);
3458- }
3459-
3460- /* Use p_ptr->inventory_list if allowed */
3461- else if (allow_inven)
3462- {
3463- command_wrk = (USE_INVEN);
3464- }
3465-
3466- /* Use equipment if allowed */
3467- else if (allow_equip)
3468- {
3469- command_wrk = (USE_EQUIP);
3470- }
3471-
3472- /* Use floor if allowed */
3473- else if (allow_floor)
3474- {
3475- command_wrk = (USE_FLOOR);
3476- }
3477- }
3478-
3479- /*
3480- * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
3481- */
3482- if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
3483-
3484- /* Hack -- start out in "display" mode */
3485- if (command_see)
3486- {
3487- screen_save();
3488- }
3489-
3490- /* Repeat until done */
3491- while (!done)
3492- {
3493- COMMAND_CODE get_item_label = 0;
3494-
3495- /* Show choices */
3496- int ni = 0;
3497- int ne = 0;
3498-
3499- /* Scan windows */
3500- for (j = 0; j < 8; j++)
3501- {
3502- /* Unused */
3503- if (!angband_term[j]) continue;
3504-
3505- /* Count windows displaying inven */
3506- if (window_flag[j] & (PW_INVEN)) ni++;
3507-
3508- /* Count windows displaying equip */
3509- if (window_flag[j] & (PW_EQUIP)) ne++;
3510- }
3511-
3512- /* Toggle if needed */
3513- if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
3514- (command_wrk == (USE_INVEN) && !ni && ne))
3515- {
3516- /* Toggle */
3517- toggle_inven_equip();
3518-
3519- /* Track toggles */
3520- toggle = !toggle;
3521- }
3522-
3523- p_ptr->window |= (PW_INVEN | PW_EQUIP);
3524- handle_stuff();
3525-
3526- /* Inventory screen */
3527- if (command_wrk == (USE_INVEN))
3528- {
3529- /* Extract the legal requests */
3530- n1 = I2A(i1);
3531- n2 = I2A(i2);
3532-
3533- /* Redraw if needed */
3534- if (command_see) get_item_label = show_inven(menu_line, mode);
3535- }
3536-
3537- /* Equipment screen */
3538- else if (command_wrk == (USE_EQUIP))
3539- {
3540- /* Extract the legal requests */
3541- n1 = I2A(e1 - INVEN_RARM);
3542- n2 = I2A(e2 - INVEN_RARM);
3543-
3544- /* Redraw if needed */
3545- if (command_see) get_item_label = show_equip(menu_line, mode);
3546- }
3547-
3548- /* Floor screen */
3549- else if (command_wrk == (USE_FLOOR))
3550- {
3551- j = floor_top;
3552- k = MIN(floor_top + 23, floor_num) - 1;
3553-
3554- /* Extract the legal requests */
3555- n1 = I2A(j - floor_top);
3556- n2 = I2A(k - floor_top);
3557-
3558- /* Redraw if needed */
3559- if (command_see) get_item_label = show_floor(menu_line, p_ptr->y, p_ptr->x, &min_width);
3560- }
3561-
3562- /* Viewing p_ptr->inventory_list */
3563- if (command_wrk == (USE_INVEN))
3564- {
3565- /* Begin the prompt */
3566- sprintf(out_val, _("持ち物:", "Inven:"));
3567-
3568- if (!use_menu)
3569- {
3570- /* Build the prompt */
3571- sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3572- index_to_label(i1), index_to_label(i2));
3573-
3574- /* Append */
3575- strcat(out_val, tmp_val);
3576- }
3577-
3578- /* Indicate ability to "view" */
3579- if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3580-
3581- /* Append */
3582- if (allow_equip)
3583- {
3584- if (!use_menu)
3585- strcat(out_val, _(" '/' 装備品,", " / for Equip,"));
3586- else if (allow_floor)
3587- strcat(out_val, _(" '6' 装備品,", " 6 for Equip,"));
3588- else
3589- strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
3590- }
3591-
3592- /* Append */
3593- if (allow_floor)
3594- {
3595- if (!use_menu)
3596- strcat(out_val, _(" '-'床上,", " - for floor,"));
3597- else if (allow_equip)
3598- strcat(out_val, _(" '4' 床上,", " 4 for floor,"));
3599- else
3600- strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
3601- }
3602- }
3603-
3604- /* Viewing equipment */
3605- else if (command_wrk == (USE_EQUIP))
3606- {
3607- /* Begin the prompt */
3608- sprintf(out_val, _("装備品:", "Equip:"));
3609-
3610- if (!use_menu)
3611- {
3612- /* Build the prompt */
3613- sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3614- index_to_label(e1), index_to_label(e2));
3615-
3616- /* Append */
3617- strcat(out_val, tmp_val);
3618- }
3619-
3620- /* Indicate ability to "view" */
3621- if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3622-
3623- /* Append */
3624- if (allow_inven)
3625- {
3626- if (!use_menu)
3627- strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
3628- else if (allow_floor)
3629- strcat(out_val, _(" '4' 持ち物,", " 4 for Inven,"));
3630- else
3631- strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
3632- }
3633-
3634- /* Append */
3635- if (allow_floor)
3636- {
3637- if (!use_menu)
3638- strcat(out_val, _(" '-'床上,", " - for floor,"));
3639- else if (allow_inven)
3640- strcat(out_val, _(" '6' 床上,", " 6 for floor,"));
3641- else
3642- strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
3643- }
3644- }
3645-
3646- /* Viewing floor */
3647- else if (command_wrk == (USE_FLOOR))
3648- {
3649- /* Begin the prompt */
3650- sprintf(out_val, _("床上:", "Floor:"));
3651-
3652- if (!use_menu)
3653- {
3654- /* Build the prompt */
3655- sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
3656-
3657- /* Append */
3658- strcat(out_val, tmp_val);
3659- }
3660-
3661- /* Indicate ability to "view" */
3662- if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3663-
3664- if (use_menu)
3665- {
3666- if (allow_inven && allow_equip)
3667- {
3668- strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
3669- }
3670- else if (allow_inven)
3671- {
3672- strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
3673- }
3674- else if (allow_equip)
3675- {
3676- strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
3677- }
3678- }
3679- /* Append */
3680- else if (allow_inven)
3681- {
3682- strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
3683- }
3684- else if (allow_equip)
3685- {
3686- strcat(out_val, _(" '/'装備品,", " / for Equip,"));
3687- }
3688-
3689- /* Append */
3690- if (command_see && !use_menu)
3691- {
3692- strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
3693- }
3694- }
3695-
3696- /* Append */
3697- if (force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
3698-
3699- /* Finish the prompt */
3700- strcat(out_val, " ESC");
3701-
3702- /* Build the prompt */
3703- sprintf(tmp_val, "(%s) %s", out_val, pmt);
3704-
3705- /* Show the prompt */
3706- prt(tmp_val, 0, 0);
3707-
3708- /* Get a key */
3709- which = inkey();
3710-
3711- if (use_menu)
3712- {
3713- int max_line = 1;
3714- if (command_wrk == USE_INVEN) max_line = max_inven;
3715- else if (command_wrk == USE_EQUIP) max_line = max_equip;
3716- else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
3717- switch (which)
3718- {
3719- case ESCAPE:
3720- case 'z':
3721- case 'Z':
3722- case '0':
3723- {
3724- done = TRUE;
3725- break;
3726- }
3727-
3728- case '8':
3729- case 'k':
3730- case 'K':
3731- {
3732- menu_line += (max_line - 1);
3733- break;
3734- }
3735-
3736- case '2':
3737- case 'j':
3738- case 'J':
3739- {
3740- menu_line++;
3741- break;
3742- }
3743-
3744- case '4':
3745- case 'h':
3746- case 'H':
3747- {
3748- /* Verify legality */
3749- if (command_wrk == (USE_INVEN))
3750- {
3751- if (allow_floor) command_wrk = USE_FLOOR;
3752- else if (allow_equip) command_wrk = USE_EQUIP;
3753- else
3754- {
3755- bell();
3756- break;
3757- }
3758- }
3759- else if (command_wrk == (USE_EQUIP))
3760- {
3761- if (allow_inven) command_wrk = USE_INVEN;
3762- else if (allow_floor) command_wrk = USE_FLOOR;
3763- else
3764- {
3765- bell();
3766- break;
3767- }
3768- }
3769- else if (command_wrk == (USE_FLOOR))
3770- {
3771- if (allow_equip) command_wrk = USE_EQUIP;
3772- else if (allow_inven) command_wrk = USE_INVEN;
3773- else
3774- {
3775- bell();
3776- break;
3777- }
3778- }
3779- else
3780- {
3781- bell();
3782- break;
3783- }
3784-
3785- /* Hack -- Fix screen */
3786- if (command_see)
3787- {
3788- screen_load();
3789- screen_save();
3790- }
3791-
3792- /* Switch inven/equip */
3793- if (command_wrk == USE_INVEN) max_line = max_inven;
3794- else if (command_wrk == USE_EQUIP) max_line = max_equip;
3795- else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
3796- if (menu_line > max_line) menu_line = max_line;
3797-
3798- /* Need to redraw */
3799- break;
3800- }
3801-
3802- case '6':
3803- case 'l':
3804- case 'L':
3805- {
3806- /* Verify legality */
3807- if (command_wrk == (USE_INVEN))
3808- {
3809- if (allow_equip) command_wrk = USE_EQUIP;
3810- else if (allow_floor) command_wrk = USE_FLOOR;
3811- else
3812- {
3813- bell();
3814- break;
3815- }
3816- }
3817- else if (command_wrk == (USE_EQUIP))
3818- {
3819- if (allow_floor) command_wrk = USE_FLOOR;
3820- else if (allow_inven) command_wrk = USE_INVEN;
3821- else
3822- {
3823- bell();
3824- break;
3825- }
3826- }
3827- else if (command_wrk == (USE_FLOOR))
3828- {
3829- if (allow_inven) command_wrk = USE_INVEN;
3830- else if (allow_equip) command_wrk = USE_EQUIP;
3831- else
3832- {
3833- bell();
3834- break;
3835- }
3836- }
3837- else
3838- {
3839- bell();
3840- break;
3841- }
3842-
3843- /* Hack -- Fix screen */
3844- if (command_see)
3845- {
3846- screen_load();
3847- screen_save();
3848- }
3849-
3850- /* Switch inven/equip */
3851- if (command_wrk == USE_INVEN) max_line = max_inven;
3852- else if (command_wrk == USE_EQUIP) max_line = max_equip;
3853- else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
3854- if (menu_line > max_line) menu_line = max_line;
3855-
3856- /* Need to redraw */
3857- break;
3858- }
3859-
3860- case 'x':
3861- case 'X':
3862- case '\r':
3863- case '\n':
3864- {
3865- if (command_wrk == USE_FLOOR)
3866- {
3867- /* Special index */
3868- (*cp) = -get_item_label;
3869- }
3870- else
3871- {
3872- /* Validate the item */
3873- if (!get_item_okay(get_item_label))
3874- {
3875- bell();
3876- break;
3877- }
3878-
3879- /* Allow player to "refuse" certain actions */
3880- if (!get_item_allow(get_item_label))
3881- {
3882- done = TRUE;
3883- break;
3884- }
3885-
3886- /* Accept that choice */
3887- (*cp) = get_item_label;
3888- }
3889-
3890- item = TRUE;
3891- done = TRUE;
3892- break;
3893- }
3894- case 'w':
3895- {
3896- if (force) {
3897- *cp = INVEN_FORCE;
3898- item = TRUE;
3899- done = TRUE;
3900- break;
3901- }
3902- }
3903- }
3904- if (menu_line > max_line) menu_line -= max_line;
3905- }
3906- else
3907- {
3908- /* Parse it */
3909- switch (which)
3910- {
3911- case ESCAPE:
3912- {
3913- done = TRUE;
3914- break;
3915- }
3916-
3917- case '*':
3918- case '?':
3919- case ' ':
3920- {
3921- /* Hide the list */
3922- if (command_see)
3923- {
3924- /* Flip flag */
3925- command_see = FALSE;
3926- screen_load();
3927- }
3928-
3929- /* Show the list */
3930- else
3931- {
3932- screen_save();
3933-
3934- /* Flip flag */
3935- command_see = TRUE;
3936- }
3937- break;
3938- }
3939-
3940- case '\n':
3941- case '\r':
3942- case '+':
3943- {
3944- int i;
3945- OBJECT_IDX o_idx;
3946- grid_type *g_ptr = &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
3947-
3948- if (command_wrk != (USE_FLOOR)) break;
3949-
3950- /* Get the object being moved. */
3951- o_idx = g_ptr->o_idx;
3952-
3953- /* Only rotate a pile of two or more objects. */
3954- if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) break;
3955-
3956- /* Remove the first object from the list. */
3957- excise_object_idx(o_idx);
3958-
3959- /* Find end of the list. */
3960- i = g_ptr->o_idx;
3961- while (current_floor_ptr->o_list[i].next_o_idx)
3962- i = current_floor_ptr->o_list[i].next_o_idx;
3963-
3964- /* Add after the last object. */
3965- current_floor_ptr->o_list[i].next_o_idx = o_idx;
3966-
3967- /* Re-scan floor list */
3968- floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3969-
3970- /* Hack -- Fix screen */
3971- if (command_see)
3972- {
3973- screen_load();
3974- screen_save();
3975- }
3976-
3977- break;
3978- }
3979-
3980- case '/':
3981- {
3982- if (command_wrk == (USE_INVEN))
3983- {
3984- if (!allow_equip)
3985- {
3986- bell();
3987- break;
3988- }
3989- command_wrk = (USE_EQUIP);
3990- }
3991- else if (command_wrk == (USE_EQUIP))
3992- {
3993- if (!allow_inven)
3994- {
3995- bell();
3996- break;
3997- }
3998- command_wrk = (USE_INVEN);
3999- }
4000- else if (command_wrk == (USE_FLOOR))
4001- {
4002- if (allow_inven)
4003- {
4004- command_wrk = (USE_INVEN);
4005- }
4006- else if (allow_equip)
4007- {
4008- command_wrk = (USE_EQUIP);
4009- }
4010- else
4011- {
4012- bell();
4013- break;
4014- }
4015- }
4016-
4017- /* Hack -- Fix screen */
4018- if (command_see)
4019- {
4020- screen_load();
4021- screen_save();
4022- }
4023-
4024- /* Need to redraw */
4025- break;
4026- }
4027-
4028- case '-':
4029- {
4030- if (!allow_floor)
4031- {
4032- bell();
4033- break;
4034- }
4035-
4036- /*
4037- * If we are already examining the floor, and there
4038- * is only one item, we will always select it.
4039- * If we aren't examining the floor and there is only
4040- * one item, we will select it if floor_query_flag
4041- * is FALSE.
4042- */
4043- if (floor_num == 1)
4044- {
4045- if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
4046- {
4047- /* Special index */
4048- k = 0 - floor_list[0];
4049-
4050- /* Allow player to "refuse" certain actions */
4051- if (!get_item_allow(k))
4052- {
4053- done = TRUE;
4054- break;
4055- }
4056-
4057- /* Accept that choice */
4058- (*cp) = k;
4059- item = TRUE;
4060- done = TRUE;
4061-
4062- break;
4063- }
4064- }
4065-
4066- /* Hack -- Fix screen */
4067- if (command_see)
4068- {
4069- screen_load();
4070- screen_save();
4071- }
4072-
4073- command_wrk = (USE_FLOOR);
4074-
4075- break;
4076- }
4077-
4078- case '0':
4079- case '1': case '2': case '3':
4080- case '4': case '5': case '6':
4081- case '7': case '8': case '9':
4082- {
4083- if (command_wrk != USE_FLOOR)
4084- {
4085- /* Look up the tag */
4086- if (!get_tag(&k, which, command_wrk))
4087- {
4088- bell();
4089- break;
4090- }
4091-
4092- /* Hack -- Validate the item */
4093- if ((k < INVEN_RARM) ? !inven : !equip)
4094- {
4095- bell();
4096- break;
4097- }
4098-
4099- /* Validate the item */
4100- if (!get_item_okay(k))
4101- {
4102- bell();
4103- break;
4104- }
4105- }
4106- else
4107- {
4108- /* Look up the alphabetical tag */
4109- if (get_tag_floor(&k, which, floor_list, floor_num))
4110- {
4111- /* Special index */
4112- k = 0 - floor_list[k];
4113- }
4114- else
4115- {
4116- bell();
4117- break;
4118- }
4119- }
4120-
4121- /* Allow player to "refuse" certain actions */
4122- if (!get_item_allow(k))
4123- {
4124- done = TRUE;
4125- break;
4126- }
4127-
4128- /* Accept that choice */
4129- (*cp) = k;
4130- item = TRUE;
4131- done = TRUE;
4132- cur_tag = which;
4133- break;
4134- }
4135-
4136-#if 0
4137- case '\n':
4138- case '\r':
4139- {
4140- /* Choose "default" p_ptr->inventory_list item */
4141- if (command_wrk == (USE_INVEN))
4142- {
4143- k = ((i1 == i2) ? i1 : -1);
4144- }
4145-
4146- /* Choose "default" equipment item */
4147- else if (command_wrk == (USE_EQUIP))
4148- {
4149- k = ((e1 == e2) ? e1 : -1);
4150- }
4151-
4152- /* Choose "default" floor item */
4153- else if (command_wrk == (USE_FLOOR))
4154- {
4155- if (floor_num == 1)
4156- {
4157- /* Special index */
4158- k = 0 - floor_list[0];
4159-
4160- /* Allow player to "refuse" certain actions */
4161- if (!get_item_allow(k))
4162- {
4163- done = TRUE;
4164- break;
4165- }
4166-
4167- /* Accept that choice */
4168- (*cp) = k;
4169- item = TRUE;
4170- done = TRUE;
4171- }
4172- break;
4173- }
4174-
4175- /* Validate the item */
4176- if (!get_item_okay(k))
4177- {
4178- bell();
4179- break;
4180- }
4181-
4182- /* Allow player to "refuse" certain actions */
4183- if (!get_item_allow(k))
4184- {
4185- done = TRUE;
4186- break;
4187- }
4188-
4189- /* Accept that choice */
4190- (*cp) = k;
4191- item = TRUE;
4192- done = TRUE;
4193- break;
4194- }
4195-#endif
4196-
4197- case 'w':
4198- {
4199- if (force) {
4200- *cp = INVEN_FORCE;
4201- item = TRUE;
4202- done = TRUE;
4203- break;
4204- }
4205-
4206- /* Fall through */
4207- }
4208-
4209- default:
4210- {
4211- int ver;
4212-
4213- if (command_wrk != USE_FLOOR)
4214- {
4215- bool not_found = FALSE;
4216-
4217- /* Look up the alphabetical tag */
4218- if (!get_tag(&k, which, command_wrk))
4219- {
4220- not_found = TRUE;
4221- }
4222-
4223- /* Hack -- Validate the item */
4224- else if ((k < INVEN_RARM) ? !inven : !equip)
4225- {
4226- not_found = TRUE;
4227- }
4228-
4229- /* Validate the item */
4230- else if (!get_item_okay(k))
4231- {
4232- not_found = TRUE;
4233- }
4234-
4235- if (!not_found)
4236- {
4237- /* Accept that choice */
4238- (*cp) = k;
4239- item = TRUE;
4240- done = TRUE;
4241- cur_tag = which;
4242- break;
4243- }
4244- }
4245- else
4246- {
4247- /* Look up the alphabetical tag */
4248- if (get_tag_floor(&k, which, floor_list, floor_num))
4249- {
4250- /* Special index */
4251- k = 0 - floor_list[k];
4252-
4253- /* Accept that choice */
4254- (*cp) = k;
4255- item = TRUE;
4256- done = TRUE;
4257- cur_tag = which;
4258- break;
4259- }
4260- }
4261-
4262- /* Extract "query" setting */
4263- ver = isupper(which);
4264- which = (char)tolower(which);
4265-
4266- /* Convert letter to p_ptr->inventory_list index */
4267- if (command_wrk == (USE_INVEN))
4268- {
4269- if (which == '(') k = i1;
4270- else if (which == ')') k = i2;
4271- else k = label_to_inven(which);
4272- }
4273-
4274- /* Convert letter to equipment index */
4275- else if (command_wrk == (USE_EQUIP))
4276- {
4277- if (which == '(') k = e1;
4278- else if (which == ')') k = e2;
4279- else k = label_to_equip(which);
4280- }
4281-
4282- /* Convert letter to floor index */
4283- else if (command_wrk == USE_FLOOR)
4284- {
4285- if (which == '(') k = 0;
4286- else if (which == ')') k = floor_num - 1;
4287- else k = islower(which) ? A2I(which) : -1;
4288- if (k < 0 || k >= floor_num || k >= 23)
4289- {
4290- bell();
4291- break;
4292- }
4293-
4294- /* Special index */
4295- k = 0 - floor_list[k];
4296- }
4297-
4298- /* Validate the item */
4299- if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
4300- {
4301- bell();
4302- break;
4303- }
4304-
4305- /* Verify the item */
4306- if (ver && !verify(_("本当に", "Try"), k))
4307- {
4308- done = TRUE;
4309- break;
4310- }
4311-
4312- /* Allow player to "refuse" certain actions */
4313- if (!get_item_allow(k))
4314- {
4315- done = TRUE;
4316- break;
4317- }
4318-
4319- /* Accept that choice */
4320- (*cp) = k;
4321- item = TRUE;
4322- done = TRUE;
4323- break;
4324- }
4325- }
4326- }
4327- }
4328-
4329- /* Fix the screen if necessary */
4330- if (command_see)
4331- {
4332- screen_load();
4333-
4334- /* Hack -- Cancel "display" */
4335- command_see = FALSE;
4336- }
4337-
4338-
4339- /* Forget the item_tester_tval restriction */
4340- item_tester_tval = 0;
4341-
4342- /* Forget the item_tester_hook restriction */
4343- item_tester_hook = NULL;
4344-
4345-
4346- /* Clean up 'show choices' */
4347- /* Toggle again if needed */
4348- if (toggle) toggle_inven_equip();
4349-
4350- p_ptr->window |= (PW_INVEN | PW_EQUIP);
4351- handle_stuff();
4352-
4353- /* Clear the prompt line */
4354- prt("", 0, 0);
4355-
4356- /* Warning if needed */
4357- if (oops && str) msg_print(str);
4358-
4359- if (item)
4360- {
4361- repeat_push(*cp);
4362- if (command_cmd) prev_tag = cur_tag;
4363- command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4364- }
4365- return (item);
4366-}
4367-
4368-/*!
4369- * @brief 床上のアイテムを拾う選択用サブルーチン
4370- * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
4371- */
4372-static bool py_pickup_floor_aux(void)
4373-{
4374- OBJECT_IDX this_o_idx;
4375- concptr q, s;
4376- OBJECT_IDX item;
4377-
4378- /* Restrict the choices */
4379- item_tester_hook = inven_carry_okay;
4380-
4381- /* Get an object */
4382- q = _("どれを拾いますか?", "Get which item? ");
4383- s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
4384-
4385- if (choose_object(&item, q, s, (USE_FLOOR)))
4386- {
4387- this_o_idx = 0 - item;
4388- }
4389- else
4390- {
4391- return (FALSE);
4392- }
4393-
4394- /* Pick up the object */
4395- py_pickup_aux(this_o_idx);
4396-
4397- return (TRUE);
4398-}
4399-
4400-/*!
4401- * @brief 床上のアイテムを拾うメイン処理
4402- * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
4403- * @return なし
4404- * @details
4405- * This is called by py_pickup() when easy_floor is TRUE.
4406- */
4407-void py_pickup_floor(bool pickup)
4408-{
4409- OBJECT_IDX this_o_idx, next_o_idx = 0;
4410-
4411- GAME_TEXT o_name[MAX_NLEN];
4412- object_type *o_ptr;
4413-
4414- int floor_num = 0;
4415- OBJECT_IDX floor_o_idx = 0;
4416-
4417- int can_pickup = 0;
4418-
4419- /* Scan the pile of objects */
4420- for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
4421- {
4422- /* Access the object */
4423- o_ptr = &current_floor_ptr->o_list[this_o_idx];
4424-
4425- object_desc(o_name, o_ptr, 0);
4426-
4427- /* Access the next object */
4428- next_o_idx = o_ptr->next_o_idx;
4429-
4430- disturb(FALSE, FALSE);
4431-
4432- /* Pick up gold */
4433- if (o_ptr->tval == TV_GOLD)
4434- {
4435-#ifdef JP
4436- msg_format(" $%ld の価値がある%sを見つけた。",
4437- (long)o_ptr->pval, o_name);
4438-#else
4439- msg_format("You have found %ld gold pieces worth of %s.",
4440- (long)o_ptr->pval, o_name);
4441-#endif
4442-
4443- /* Collect the gold */
4444- p_ptr->au += o_ptr->pval;
4445-
4446- /* Redraw gold */
4447- p_ptr->redraw |= (PR_GOLD);
4448-
4449- p_ptr->window |= (PW_PLAYER);
4450-
4451- /* Delete the gold */
4452- delete_object_idx(this_o_idx);
4453-
4454- /* Check the next object */
4455- continue;
4456- }
4457- else if (o_ptr->marked & OM_NOMSG)
4458- {
4459- /* If 0 or 1 non-NOMSG items are in the pile, the NOMSG ones are
4460- * ignored. Otherwise, they are included in the prompt. */
4461- o_ptr->marked &= ~(OM_NOMSG);
4462- continue;
4463- }
4464-
4465- /* Count non-gold objects that can be picked up. */
4466- if (inven_carry_okay(o_ptr))
4467- {
4468- can_pickup++;
4469- }
4470-
4471- /* Count non-gold objects */
4472- floor_num++;
4473-
4474- /* Remember this index */
4475- floor_o_idx = this_o_idx;
4476- }
4477-
4478- /* There are no non-gold objects */
4479- if (!floor_num)
4480- return;
4481-
4482- /* Mention the number of objects */
4483- if (!pickup)
4484- {
4485- /* One object */
4486- if (floor_num == 1)
4487- {
4488- /* Access the object */
4489- o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4490-
4491-#ifdef ALLOW_EASY_SENSE
4492-
4493- /* Option: Make object sensing easy */
4494- if (easy_sense)
4495- {
4496- /* Sense the object */
4497- (void) sense_object(o_ptr);
4498- }
4499-
4500-#endif /* ALLOW_EASY_SENSE */
4501-
4502- object_desc(o_name, o_ptr, 0);
4503-
4504- msg_format(_("%sがある。", "You see %s."), o_name);
4505- }
4506-
4507- /* Multiple objects */
4508- else
4509- {
4510- msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
4511- }
4512-
4513- return;
4514- }
4515-
4516- /* The player has no room for anything on the floor. */
4517- if (!can_pickup)
4518- {
4519- /* One object */
4520- if (floor_num == 1)
4521- {
4522- /* Access the object */
4523- o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4524-
4525-#ifdef ALLOW_EASY_SENSE
4526-
4527- /* Option: Make object sensing easy */
4528- if (easy_sense)
4529- {
4530- /* Sense the object */
4531- (void) sense_object(o_ptr);
4532- }
4533-
4534-#endif /* ALLOW_EASY_SENSE */
4535-
4536- object_desc(o_name, o_ptr, 0);
4537-
4538- msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
4539- }
4540-
4541- /* Multiple objects */
4542- else
4543- {
4544- msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
4545-
4546- }
4547-
4548- return;
4549- }
4550-
4551- /* One object */
4552- if (floor_num == 1)
4553- {
4554- /* Hack -- query every object */
4555- if (carry_query_flag)
4556- {
4557- char out_val[MAX_NLEN+20];
4558-
4559- /* Access the object */
4560- o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4561-
4562-#ifdef ALLOW_EASY_SENSE
4563-
4564- /* Option: Make object sensing easy */
4565- if (easy_sense)
4566- {
4567- /* Sense the object */
4568- (void) sense_object(o_ptr);
4569- }
4570-
4571-#endif /* ALLOW_EASY_SENSE */
4572-
4573- object_desc(o_name, o_ptr, 0);
4574-
4575- /* Build a prompt */
4576- (void) sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
4577-
4578- /* Ask the user to confirm */
4579- if (!get_check(out_val))
4580- {
4581- return;
4582- }
4583- }
4584-
4585- /* Access the object */
4586- o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4587-
4588-#ifdef ALLOW_EASY_SENSE
4589-
4590- /* Option: Make object sensing easy */
4591- if (easy_sense)
4592- {
4593- /* Sense the object */
4594- (void) sense_object(o_ptr);
4595- }
4596-
4597-#endif /* ALLOW_EASY_SENSE */
4598-
4599- /* Pick up the object */
4600- py_pickup_aux(floor_o_idx);
4601- }
4602-
4603- /* Allow the user to choose an object */
4604- else
4605- {
4606- while (can_pickup--)
4607- {
4608- if (!py_pickup_floor_aux()) break;
4609- }
4610- }
4611-}
4612-
4613-
4614-/*!
46151665 * @brief 矢弾を射撃した場合の破損確率を返す /
46161666 * Determines the odds of an object breaking when thrown at a monster
46171667 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
--- a/src/player-inventory.c
+++ b/src/player-inventory.c
@@ -5,6 +5,8 @@
55 #include "object.h"
66 #include "objectkind.h"
77 #include "object-flavor.h"
8+#include "floor.h"
9+#include "player-move.h"
810
911 #include "view-mainwindow.h"
1012
@@ -385,3 +387,2952 @@ bool can_get_item(void)
385387
386388 return FALSE;
387389 }
390+
391+
392+/*!
393+ * @brief 床オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
394+ * Find the "first" p_ptr->inventory_list object with the given "tag".
395+ * @param cp 対応するタグIDを与える参照ポインタ
396+ * @param tag 該当するオブジェクトがあるかを調べたいタグ
397+ * @param floor_list 床上アイテムの配列
398+ * @param floor_num 床上アイテムの配列ID
399+ * @return タグに該当するオブジェクトがあるならTRUEを返す
400+ * @details
401+ * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
402+ * inscription of an object. Alphabetical characters don't work as a\n
403+ * tag in this form.\n
404+ *\n
405+ * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
406+ * and "x" is the "current" command_cmd code.\n
407+ */
408+static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
409+{
410+ COMMAND_CODE i;
411+ concptr s;
412+
413+ /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
414+
415+ /* Check every object in the grid */
416+ for (i = 0; i < floor_num && i < 23; i++)
417+ {
418+ object_type *o_ptr = &current_floor_ptr->o_list[floor_list[i]];
419+
420+ /* Skip empty inscriptions */
421+ if (!o_ptr->inscription) continue;
422+
423+ /* Find a '@' */
424+ s = my_strchr(quark_str(o_ptr->inscription), '@');
425+
426+ /* Process all tags */
427+ while (s)
428+ {
429+ /* Check the special tags */
430+ if ((s[1] == command_cmd) && (s[2] == tag))
431+ {
432+ /* Save the actual floor object ID */
433+ *cp = i;
434+
435+ /* Success */
436+ return (TRUE);
437+ }
438+
439+ /* Find another '@' */
440+ s = my_strchr(s + 1, '@');
441+ }
442+ }
443+
444+
445+ /**** Find a tag in the form of {@#} (allows only numerals) ***/
446+
447+ /* Don't allow {@#} with '#' being alphabet */
448+ if (tag < '0' || '9' < tag)
449+ {
450+ /* No such tag */
451+ return FALSE;
452+ }
453+
454+ /* Check every object in the grid */
455+ for (i = 0; i < floor_num && i < 23; i++)
456+ {
457+ object_type *o_ptr = &current_floor_ptr->o_list[floor_list[i]];
458+
459+ /* Skip empty inscriptions */
460+ if (!o_ptr->inscription) continue;
461+
462+ /* Find a '@' */
463+ s = my_strchr(quark_str(o_ptr->inscription), '@');
464+
465+ /* Process all tags */
466+ while (s)
467+ {
468+ /* Check the normal tags */
469+ if (s[1] == tag)
470+ {
471+ /* Save the floor object ID */
472+ *cp = i;
473+
474+ /* Success */
475+ return (TRUE);
476+ }
477+
478+ /* Find another '@' */
479+ s = my_strchr(s + 1, '@');
480+ }
481+ }
482+
483+ /* No such tag */
484+ return (FALSE);
485+}
486+
487+
488+/*!
489+ * @brief 所持/装備オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
490+ * Find the "first" p_ptr->inventory_list object with the given "tag".
491+ * @param cp 対応するタグIDを与える参照ポインタ
492+ * @param tag 該当するオブジェクトがあるかを調べたいタグ
493+ * @param mode 所持、装備の切り替え
494+ * @return タグに該当するオブジェクトがあるならTRUEを返す
495+ * @details
496+ * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
497+ * inscription of an object. Alphabetical characters don't work as a\n
498+ * tag in this form.\n
499+ *\n
500+ * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
501+ * and "x" is the "current" command_cmd code.\n
502+ */
503+static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode)
504+{
505+ COMMAND_CODE i;
506+ COMMAND_CODE start, end;
507+ concptr s;
508+
509+ /* Extract index from mode */
510+ switch (mode)
511+ {
512+ case USE_EQUIP:
513+ start = INVEN_RARM;
514+ end = INVEN_TOTAL - 1;
515+ break;
516+
517+ case USE_INVEN:
518+ start = 0;
519+ end = INVEN_PACK - 1;
520+ break;
521+
522+ default:
523+ return FALSE;
524+ }
525+
526+ /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
527+
528+ /* Check every p_ptr->inventory_list object */
529+ for (i = start; i <= end; i++)
530+ {
531+ object_type *o_ptr = &p_ptr->inventory_list[i];
532+ if (!o_ptr->k_idx) continue;
533+
534+ /* Skip empty inscriptions */
535+ if (!o_ptr->inscription) continue;
536+
537+ /* Skip non-choice */
538+ if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
539+
540+ /* Find a '@' */
541+ s = my_strchr(quark_str(o_ptr->inscription), '@');
542+
543+ /* Process all tags */
544+ while (s)
545+ {
546+ /* Check the special tags */
547+ if ((s[1] == command_cmd) && (s[2] == tag))
548+ {
549+ /* Save the actual p_ptr->inventory_list ID */
550+ *cp = i;
551+
552+ /* Success */
553+ return (TRUE);
554+ }
555+
556+ /* Find another '@' */
557+ s = my_strchr(s + 1, '@');
558+ }
559+ }
560+
561+
562+ /**** Find a tag in the form of {@#} (allows only numerals) ***/
563+
564+ /* Don't allow {@#} with '#' being alphabet */
565+ if (tag < '0' || '9' < tag)
566+ {
567+ /* No such tag */
568+ return FALSE;
569+ }
570+
571+ /* Check every object */
572+ for (i = start; i <= end; i++)
573+ {
574+ object_type *o_ptr = &p_ptr->inventory_list[i];
575+ if (!o_ptr->k_idx) continue;
576+
577+ /* Skip empty inscriptions */
578+ if (!o_ptr->inscription) continue;
579+
580+ /* Skip non-choice */
581+ if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
582+
583+ /* Find a '@' */
584+ s = my_strchr(quark_str(o_ptr->inscription), '@');
585+
586+ /* Process all tags */
587+ while (s)
588+ {
589+ /* Check the normal tags */
590+ if (s[1] == tag)
591+ {
592+ /* Save the actual p_ptr->inventory_list ID */
593+ *cp = i;
594+
595+ /* Success */
596+ return (TRUE);
597+ }
598+
599+ /* Find another '@' */
600+ s = my_strchr(s + 1, '@');
601+ }
602+ }
603+
604+ /* No such tag */
605+ return (FALSE);
606+}
607+
608+/*!
609+ * @brief タグIDにあわせてタグアルファベットのリストを返す /
610+ * Move around label characters with correspond tags
611+ * @param label ラベルリストを取得する文字列参照ポインタ
612+ * @param mode 所持品リストか装備品リストかの切り替え
613+ * @return なし
614+ */
615+void prepare_label_string(char *label, BIT_FLAGS mode)
616+{
617+ concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
618+ int offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
619+ int i;
620+
621+ /* Prepare normal labels */
622+ strcpy(label, alphabet_chars);
623+
624+ /* Move each label */
625+ for (i = 0; i < 52; i++)
626+ {
627+ COMMAND_CODE index;
628+ SYMBOL_CODE c = alphabet_chars[i];
629+
630+ /* Find a tag with this label */
631+ if (get_tag(&index, c, mode))
632+ {
633+ /* Delete the overwritten label */
634+ if (label[i] == c) label[i] = ' ';
635+
636+ /* Move the label to the place of corresponding tag */
637+ label[index - offset] = c;
638+ }
639+ }
640+}
641+
642+
643+/*!
644+ * @brief タグIDにあわせてタグアルファベットのリストを返す(床上アイテム用) /
645+ * Move around label characters with correspond tags (floor version)
646+ * @param label ラベルリストを取得する文字列参照ポインタ
647+ * @param floor_list 床上アイテムの配列
648+ * @param floor_num 床上アイテムの配列ID
649+ * @return なし
650+ */
651+ /*
652+ */
653+static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
654+{
655+ concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
656+ int i;
657+
658+ /* Prepare normal labels */
659+ strcpy(label, alphabet_chars);
660+
661+ /* Move each label */
662+ for (i = 0; i < 52; i++)
663+ {
664+ COMMAND_CODE index;
665+ SYMBOL_CODE c = alphabet_chars[i];
666+
667+ /* Find a tag with this label */
668+ if (get_tag_floor(&index, c, floor_list, floor_num))
669+ {
670+ /* Delete the overwritten label */
671+ if (label[i] == c) label[i] = ' ';
672+
673+ /* Move the label to the place of corresponding tag */
674+ label[index] = c;
675+ }
676+ }
677+}
678+
679+/*!
680+ * @brief 所持アイテムの表示を行う /
681+ * Display the p_ptr->inventory_list.
682+ * @param target_item アイテムの選択処理を行うか否か。
683+ * @return 選択したアイテムのタグ
684+ * @details
685+ * Hack -- do not display "trailing" empty slots
686+ */
687+COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode)
688+{
689+ COMMAND_CODE i;
690+ int j, k, l, z = 0;
691+ int col, cur_col, len;
692+ object_type *o_ptr;
693+ GAME_TEXT o_name[MAX_NLEN];
694+ char tmp_val[80];
695+ COMMAND_CODE out_index[23];
696+ TERM_COLOR out_color[23];
697+ char out_desc[23][MAX_NLEN];
698+ COMMAND_CODE target_item_label = 0;
699+ TERM_LEN wid, hgt;
700+ char inven_label[52 + 1];
701+
702+ /* Starting column */
703+ col = command_gap;
704+
705+ Term_get_size(&wid, &hgt);
706+
707+ /* Default "max-length" */
708+ len = wid - col - 1;
709+
710+
711+ /* Find the "final" slot */
712+ for (i = 0; i < INVEN_PACK; i++)
713+ {
714+ o_ptr = &p_ptr->inventory_list[i];
715+ if (!o_ptr->k_idx) continue;
716+
717+ /* Track */
718+ z = i + 1;
719+ }
720+
721+ prepare_label_string(inven_label, USE_INVEN);
722+
723+ /* Display the p_ptr->inventory_list */
724+ for (k = 0, i = 0; i < z; i++)
725+ {
726+ o_ptr = &p_ptr->inventory_list[i];
727+
728+ /* Is this item acceptable? */
729+ if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
730+
731+ object_desc(o_name, o_ptr, 0);
732+
733+ /* Save the object index, color, and description */
734+ out_index[k] = i;
735+ out_color[k] = tval_to_attr[o_ptr->tval % 128];
736+
737+ /* Grey out charging items */
738+ if (o_ptr->timeout)
739+ {
740+ out_color[k] = TERM_L_DARK;
741+ }
742+
743+ (void)strcpy(out_desc[k], o_name);
744+
745+ /* Find the predicted "line length" */
746+ l = strlen(out_desc[k]) + 5;
747+
748+ /* Be sure to account for the weight */
749+ if (show_weights) l += 9;
750+
751+ /* Account for icon if displayed */
752+ if (show_item_graph)
753+ {
754+ l += 2;
755+ if (use_bigtile) l++;
756+ }
757+
758+ /* Maintain the maximum length */
759+ if (l > len) len = l;
760+
761+ /* Advance to next "line" */
762+ k++;
763+ }
764+
765+ /* Find the column to start in */
766+ col = (len > wid - 4) ? 0 : (wid - len - 1);
767+
768+ /* Output each entry */
769+ for (j = 0; j < k; j++)
770+ {
771+ i = out_index[j];
772+ o_ptr = &p_ptr->inventory_list[i];
773+
774+ /* Clear the line */
775+ prt("", j + 1, col ? col - 2 : col);
776+
777+ if (use_menu && target_item)
778+ {
779+ if (j == (target_item - 1))
780+ {
781+ strcpy(tmp_val, _("》", "> "));
782+ target_item_label = i;
783+ }
784+ else strcpy(tmp_val, " ");
785+ }
786+ else if (i <= INVEN_PACK)
787+ {
788+ /* Prepare an index --(-- */
789+ sprintf(tmp_val, "%c)", inven_label[i]);
790+ }
791+ else
792+ {
793+ /* Prepare an index --(-- */
794+ sprintf(tmp_val, "%c)", index_to_label(i));
795+ }
796+
797+ /* Clear the line with the (possibly indented) index */
798+ put_str(tmp_val, j + 1, col);
799+
800+ cur_col = col + 3;
801+
802+ /* Display graphics for object, if desired */
803+ if (show_item_graph)
804+ {
805+ TERM_COLOR a = object_attr(o_ptr);
806+ SYMBOL_CODE c = object_char(o_ptr);
807+ Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
808+ if (use_bigtile) cur_col++;
809+
810+ cur_col += 2;
811+ }
812+
813+
814+ /* Display the entry itself */
815+ c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
816+
817+ /* Display the weight if needed */
818+ if (show_weights)
819+ {
820+ int wgt = o_ptr->weight * o_ptr->number;
821+#ifdef JP
822+ (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
823+#else
824+ (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
825+#endif
826+
827+ prt(tmp_val, j + 1, wid - 9);
828+ }
829+ }
830+
831+ /* Make a "shadow" below the list (only if needed) */
832+ if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
833+
834+ /* Save the new column */
835+ command_gap = col;
836+
837+ return target_item_label;
838+}
839+
840+
841+/*!
842+ * @brief 選択したアイテムの確認処理の補助 /
843+ * Verify the choice of an item.
844+ * @param prompt メッセージ表示の一部
845+ * @param item 選択アイテムID
846+ * @return 確認がYesならTRUEを返す。
847+ * @details The item can be negative to mean "item on floor".
848+ */
849+static bool verify(concptr prompt, INVENTORY_IDX item)
850+{
851+ GAME_TEXT o_name[MAX_NLEN];
852+ char out_val[MAX_NLEN + 20];
853+ object_type *o_ptr;
854+
855+
856+ /* Inventory */
857+ if (item >= 0)
858+ {
859+ o_ptr = &p_ptr->inventory_list[item];
860+ }
861+
862+ /* Floor */
863+ else
864+ {
865+ o_ptr = &current_floor_ptr->o_list[0 - item];
866+ }
867+ object_desc(o_name, o_ptr, 0);
868+
869+ /* Prompt */
870+ (void)sprintf(out_val, _("%s%sですか? ", "%s %s? "), prompt, o_name);
871+
872+ /* Query */
873+ return (get_check(out_val));
874+}
875+
876+
877+/*!
878+ * @brief 選択したアイテムの確認処理のメインルーチン /
879+ * @param item 選択アイテムID
880+ * @return 確認がYesならTRUEを返す。
881+ * @details The item can be negative to mean "item on floor".
882+ * Hack -- allow user to "prevent" certain choices
883+ */
884+static bool get_item_allow(INVENTORY_IDX item)
885+{
886+ concptr s;
887+ object_type *o_ptr;
888+ if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
889+
890+ /* Inventory */
891+ if (item >= 0)
892+ {
893+ o_ptr = &p_ptr->inventory_list[item];
894+ }
895+
896+ /* Floor */
897+ else
898+ {
899+ o_ptr = &current_floor_ptr->o_list[0 - item];
900+ }
901+
902+ /* No inscription */
903+ if (!o_ptr->inscription) return (TRUE);
904+
905+ /* Find a '!' */
906+ s = my_strchr(quark_str(o_ptr->inscription), '!');
907+
908+ /* Process preventions */
909+ while (s)
910+ {
911+ /* Check the "restriction" */
912+ if ((s[1] == command_cmd) || (s[1] == '*'))
913+ {
914+ /* Verify the choice */
915+ if (!verify(_("本当に", "Really try"), item)) return (FALSE);
916+ }
917+
918+ /* Find another '!' */
919+ s = my_strchr(s + 1, '!');
920+ }
921+
922+ /* Allow it */
923+ return (TRUE);
924+}
925+
926+
927+/*!
928+ * @brief オブジェクト選択の汎用関数 /
929+ * Let the user select an item, save its "index"
930+ * @param cp 選択したオブジェクトのIDを返す。
931+ * @param pmt 選択目的のメッセージ
932+ * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
933+ * @param mode オプションフラグ
934+ * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
935+ * Return TRUE only if an acceptable item was chosen by the user.\n
936+ * @details
937+ * The selected item must satisfy the "item_tester_hook()" function,\n
938+ * if that hook is set, and the "item_tester_tval", if that value is set.\n
939+ *\n
940+ * All "item_tester" restrictions are cleared before this function returns.\n
941+ *\n
942+ * The user is allowed to choose acceptable items from the equipment,\n
943+ * p_ptr->inventory_list, or floor, respectively, if the proper flag was given,\n
944+ * and there are any acceptable items in that location.\n
945+ *\n
946+ * The equipment or p_ptr->inventory_list are displayed (even if no acceptable\n
947+ * items are in that location) if the proper flag was given.\n
948+ *\n
949+ * If there are no acceptable items available anywhere, and "str" is\n
950+ * not NULL, then it will be used as the text of a warning message\n
951+ * before the function returns.\n
952+ *\n
953+ * Note that the user must press "-" to specify the item on the floor,\n
954+ * and there is no way to "examine" the item on the floor, while the\n
955+ * use of "capital" letters will "examine" an p_ptr->inventory_list/equipment item,\n
956+ * and prompt for its use.\n
957+ *\n
958+ * If a legal item is selected from the p_ptr->inventory_list, we save it in "cp"\n
959+ * directly (0 to 35), and return TRUE.\n
960+ *\n
961+ * If a legal item is selected from the floor, we save it in "cp" as\n
962+ * a negative (-1 to -511), and return TRUE.\n
963+ *\n
964+ * If no item is available, we do nothing to "cp", and we display a\n
965+ * warning message, using "str" if available, and return FALSE.\n
966+ *\n
967+ * If no item is selected, we do nothing to "cp", and return FALSE.\n
968+ *\n
969+ * Global "p_ptr->command_new" is used when viewing the p_ptr->inventory_list or equipment\n
970+ * to allow the user to enter a command while viewing those screens, and\n
971+ * also to induce "auto-enter" of stores, and other such stuff.\n
972+ *\n
973+ * Global "p_ptr->command_see" may be set before calling this function to start\n
974+ * out in "browse" mode. It is cleared before this function returns.\n
975+ *\n
976+ * Global "p_ptr->command_wrk" is used to choose between equip/inven listings.\n
977+ * If it is TRUE then we are viewing p_ptr->inventory_list, else equipment.\n
978+ *\n
979+ * We always erase the prompt when we are done, leaving a blank line,\n
980+ * or a warning message, if appropriate, if no items are available.\n
981+ */
982+bool get_item(OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode)
983+{
984+ OBJECT_IDX this_o_idx, next_o_idx = 0;
985+
986+ char which = ' ';
987+
988+ int j;
989+ OBJECT_IDX k;
990+ OBJECT_IDX i1, i2;
991+ OBJECT_IDX e1, e2;
992+
993+ bool done, item;
994+
995+ bool oops = FALSE;
996+
997+ bool equip = FALSE;
998+ bool inven = FALSE;
999+ bool floor = FALSE;
1000+
1001+ bool allow_floor = FALSE;
1002+
1003+ bool toggle = FALSE;
1004+
1005+ char tmp_val[160];
1006+ char out_val[160];
1007+
1008+ int menu_line = (use_menu ? 1 : 0);
1009+ int max_inven = 0;
1010+ int max_equip = 0;
1011+
1012+ static char prev_tag = '\0';
1013+ char cur_tag = '\0';
1014+
1015+ if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode);
1016+
1017+ /* Extract args */
1018+ if (mode & USE_EQUIP) equip = TRUE;
1019+ if (mode & USE_INVEN) inven = TRUE;
1020+ if (mode & USE_FLOOR) floor = TRUE;
1021+
1022+ /* Get the item index */
1023+ if (repeat_pull(cp))
1024+ {
1025+ /* the_force */
1026+ if (mode & USE_FORCE && (*cp == INVEN_FORCE))
1027+ {
1028+ item_tester_tval = 0;
1029+ item_tester_hook = NULL;
1030+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1031+ return (TRUE);
1032+ }
1033+
1034+ /* Floor item? */
1035+ else if (floor && (*cp < 0))
1036+ {
1037+ object_type *o_ptr;
1038+
1039+ /* Special index */
1040+ k = 0 - (*cp);
1041+ o_ptr = &current_floor_ptr->o_list[k];
1042+
1043+ /* Validate the item */
1044+ if (item_tester_okay(o_ptr) || (mode & USE_FULL))
1045+ {
1046+ /* Forget restrictions */
1047+ item_tester_tval = 0;
1048+ item_tester_hook = NULL;
1049+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1050+
1051+ /* Success */
1052+ return TRUE;
1053+ }
1054+ }
1055+
1056+ else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
1057+ (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
1058+ {
1059+ if (prev_tag && command_cmd)
1060+ {
1061+ /* Look up the tag and validate the item */
1062+ if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
1063+ else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
1064+ else if (!get_item_okay(k)) /* Reject */;
1065+ else
1066+ {
1067+ /* Accept that choice */
1068+ (*cp) = k;
1069+
1070+ /* Forget restrictions */
1071+ item_tester_tval = 0;
1072+ item_tester_hook = NULL;
1073+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1074+
1075+ /* Success */
1076+ return TRUE;
1077+ }
1078+
1079+ prev_tag = '\0'; /* prev_tag is no longer effective */
1080+ }
1081+
1082+ /* Verify the item */
1083+ else if (get_item_okay(*cp))
1084+ {
1085+ /* Forget restrictions */
1086+ item_tester_tval = 0;
1087+ item_tester_hook = NULL;
1088+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1089+
1090+ /* Success */
1091+ return TRUE;
1092+ }
1093+ }
1094+ }
1095+ msg_print(NULL);
1096+
1097+ /* Not done */
1098+ done = FALSE;
1099+
1100+ /* No item selected */
1101+ item = FALSE;
1102+
1103+
1104+ /* Full p_ptr->inventory_list */
1105+ i1 = 0;
1106+ i2 = INVEN_PACK - 1;
1107+
1108+ /* Forbid p_ptr->inventory_list */
1109+ if (!inven) i2 = -1;
1110+ else if (use_menu)
1111+ {
1112+ for (j = 0; j < INVEN_PACK; j++)
1113+ if (item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_inven++;
1114+ }
1115+
1116+ /* Restrict p_ptr->inventory_list indexes */
1117+ while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
1118+ while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
1119+
1120+
1121+ /* Full equipment */
1122+ e1 = INVEN_RARM;
1123+ e2 = INVEN_TOTAL - 1;
1124+
1125+ /* Forbid equipment */
1126+ if (!equip) e2 = -1;
1127+ else if (use_menu)
1128+ {
1129+ for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
1130+ if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_equip++;
1131+ if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
1132+ }
1133+
1134+ /* Restrict equipment indexes */
1135+ while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
1136+ while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
1137+
1138+ if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
1139+ {
1140+ if (p_ptr->migite)
1141+ {
1142+ if (e2 < INVEN_LARM) e2 = INVEN_LARM;
1143+ }
1144+ else if (p_ptr->hidarite) e1 = INVEN_RARM;
1145+ }
1146+
1147+
1148+ /* Restrict floor usage */
1149+ if (floor)
1150+ {
1151+ /* Scan all objects in the grid */
1152+ for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
1153+ {
1154+ object_type *o_ptr;
1155+ o_ptr = &current_floor_ptr->o_list[this_o_idx];
1156+ next_o_idx = o_ptr->next_o_idx;
1157+
1158+ /* Accept the item on the floor if legal */
1159+ if ((item_tester_okay(o_ptr) || (mode & USE_FULL)) && (o_ptr->marked & OM_FOUND)) allow_floor = TRUE;
1160+ }
1161+ }
1162+
1163+ /* Require at least one legal choice */
1164+ if (!allow_floor && (i1 > i2) && (e1 > e2))
1165+ {
1166+ /* Cancel p_ptr->command_see */
1167+ command_see = FALSE;
1168+ oops = TRUE;
1169+ done = TRUE;
1170+
1171+ if (mode & USE_FORCE) {
1172+ *cp = INVEN_FORCE;
1173+ item = TRUE;
1174+ }
1175+ }
1176+
1177+ /* Analyze choices */
1178+ else
1179+ {
1180+ /* Hack -- Start on equipment if requested */
1181+ if (command_see && command_wrk && equip)
1182+ {
1183+ command_wrk = TRUE;
1184+ }
1185+
1186+ /* Use p_ptr->inventory_list if allowed */
1187+ else if (inven)
1188+ {
1189+ command_wrk = FALSE;
1190+ }
1191+
1192+ /* Use equipment if allowed */
1193+ else if (equip)
1194+ {
1195+ command_wrk = TRUE;
1196+ }
1197+
1198+ /* Use p_ptr->inventory_list for floor */
1199+ else
1200+ {
1201+ command_wrk = FALSE;
1202+ }
1203+ }
1204+
1205+
1206+ /*
1207+ * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
1208+ */
1209+ if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
1210+
1211+ /* Hack -- start out in "display" mode */
1212+ if (command_see)
1213+ {
1214+ screen_save();
1215+ }
1216+
1217+
1218+ /* Repeat until done */
1219+ while (!done)
1220+ {
1221+ COMMAND_CODE get_item_label = 0;
1222+
1223+ /* Show choices */
1224+ int ni = 0;
1225+ int ne = 0;
1226+
1227+ /* Scan windows */
1228+ for (j = 0; j < 8; j++)
1229+ {
1230+ /* Unused */
1231+ if (!angband_term[j]) continue;
1232+
1233+ /* Count windows displaying inven */
1234+ if (window_flag[j] & (PW_INVEN)) ni++;
1235+
1236+ /* Count windows displaying equip */
1237+ if (window_flag[j] & (PW_EQUIP)) ne++;
1238+ }
1239+
1240+ /* Toggle if needed */
1241+ if ((command_wrk && ni && !ne) || (!command_wrk && !ni && ne))
1242+ {
1243+ /* Toggle */
1244+ toggle_inven_equip();
1245+
1246+ /* Track toggles */
1247+ toggle = !toggle;
1248+ }
1249+
1250+ p_ptr->window |= (PW_INVEN | PW_EQUIP);
1251+ handle_stuff();
1252+
1253+ /* Inventory screen */
1254+ if (!command_wrk)
1255+ {
1256+ /* Redraw if needed */
1257+ if (command_see) get_item_label = show_inven(menu_line, mode);
1258+ }
1259+
1260+ /* Equipment screen */
1261+ else
1262+ {
1263+ /* Redraw if needed */
1264+ if (command_see) get_item_label = show_equip(menu_line, mode);
1265+ }
1266+
1267+ /* Viewing p_ptr->inventory_list */
1268+ if (!command_wrk)
1269+ {
1270+ /* Begin the prompt */
1271+ sprintf(out_val, _("持ち物:", "Inven:"));
1272+
1273+ /* Some legal items */
1274+ if ((i1 <= i2) && !use_menu)
1275+ {
1276+ /* Build the prompt */
1277+ sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
1278+ index_to_label(i1), index_to_label(i2));
1279+
1280+ /* Append */
1281+ strcat(out_val, tmp_val);
1282+ }
1283+
1284+ /* Indicate ability to "view" */
1285+ if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
1286+
1287+ /* Append */
1288+ if (equip) strcat(out_val, format(_(" %s 装備品,", " %s for Equip,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "/")));
1289+ }
1290+
1291+ /* Viewing equipment */
1292+ else
1293+ {
1294+ /* Begin the prompt */
1295+ sprintf(out_val, _("装備品:", "Equip:"));
1296+
1297+ /* Some legal items */
1298+ if ((e1 <= e2) && !use_menu)
1299+ {
1300+ /* Build the prompt */
1301+ sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
1302+ index_to_label(e1), index_to_label(e2));
1303+
1304+ /* Append */
1305+ strcat(out_val, tmp_val);
1306+ }
1307+
1308+ /* Indicate ability to "view" */
1309+ if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
1310+
1311+ /* Append */
1312+ if (inven) strcat(out_val, format(_(" %s 持ち物,", " %s for Inven,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "'/'")));
1313+ }
1314+
1315+ /* Indicate legality of the "floor" item */
1316+ if (allow_floor) strcat(out_val, _(" '-'床上,", " - for floor,"));
1317+ if (mode & USE_FORCE) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
1318+
1319+ /* Finish the prompt */
1320+ strcat(out_val, " ESC");
1321+
1322+ /* Build the prompt */
1323+ sprintf(tmp_val, "(%s) %s", out_val, pmt);
1324+
1325+ /* Show the prompt */
1326+ prt(tmp_val, 0, 0);
1327+
1328+ /* Get a key */
1329+ which = inkey();
1330+
1331+ if (use_menu)
1332+ {
1333+ int max_line = (command_wrk ? max_equip : max_inven);
1334+ switch (which)
1335+ {
1336+ case ESCAPE:
1337+ case 'z':
1338+ case 'Z':
1339+ case '0':
1340+ {
1341+ done = TRUE;
1342+ break;
1343+ }
1344+
1345+ case '8':
1346+ case 'k':
1347+ case 'K':
1348+ {
1349+ menu_line += (max_line - 1);
1350+ break;
1351+ }
1352+
1353+ case '2':
1354+ case 'j':
1355+ case 'J':
1356+ {
1357+ menu_line++;
1358+ break;
1359+ }
1360+
1361+ case '4':
1362+ case '6':
1363+ case 'h':
1364+ case 'H':
1365+ case 'l':
1366+ case 'L':
1367+ {
1368+ /* Verify legality */
1369+ if (!inven || !equip)
1370+ {
1371+ bell();
1372+ break;
1373+ }
1374+
1375+ /* Hack -- Fix screen */
1376+ if (command_see)
1377+ {
1378+ screen_load();
1379+ screen_save();
1380+ }
1381+
1382+ /* Switch inven/equip */
1383+ command_wrk = !command_wrk;
1384+ max_line = (command_wrk ? max_equip : max_inven);
1385+ if (menu_line > max_line) menu_line = max_line;
1386+
1387+ /* Need to redraw */
1388+ break;
1389+ }
1390+
1391+ case 'x':
1392+ case 'X':
1393+ case '\r':
1394+ case '\n':
1395+ {
1396+ if (command_wrk == USE_FLOOR)
1397+ {
1398+ /* Special index */
1399+ (*cp) = -get_item_label;
1400+ }
1401+ else
1402+ {
1403+ /* Validate the item */
1404+ if (!get_item_okay(get_item_label))
1405+ {
1406+ bell();
1407+ break;
1408+ }
1409+
1410+ /* Allow player to "refuse" certain actions */
1411+ if (!get_item_allow(get_item_label))
1412+ {
1413+ done = TRUE;
1414+ break;
1415+ }
1416+
1417+ /* Accept that choice */
1418+ (*cp) = get_item_label;
1419+ }
1420+
1421+ item = TRUE;
1422+ done = TRUE;
1423+ break;
1424+ }
1425+ case 'w':
1426+ {
1427+ if (mode & USE_FORCE) {
1428+ *cp = INVEN_FORCE;
1429+ item = TRUE;
1430+ done = TRUE;
1431+ break;
1432+ }
1433+ }
1434+ }
1435+ if (menu_line > max_line) menu_line -= max_line;
1436+ }
1437+ else
1438+ {
1439+ /* Parse it */
1440+ switch (which)
1441+ {
1442+ case ESCAPE:
1443+ {
1444+ done = TRUE;
1445+ break;
1446+ }
1447+
1448+ case '*':
1449+ case '?':
1450+ case ' ':
1451+ {
1452+ /* Hide the list */
1453+ if (command_see)
1454+ {
1455+ /* Flip flag */
1456+ command_see = FALSE;
1457+ screen_load();
1458+ }
1459+
1460+ /* Show the list */
1461+ else
1462+ {
1463+ screen_save();
1464+
1465+ /* Flip flag */
1466+ command_see = TRUE;
1467+ }
1468+ break;
1469+ }
1470+
1471+ case '/':
1472+ {
1473+ /* Verify legality */
1474+ if (!inven || !equip)
1475+ {
1476+ bell();
1477+ break;
1478+ }
1479+
1480+ /* Hack -- Fix screen */
1481+ if (command_see)
1482+ {
1483+ screen_load();
1484+ screen_save();
1485+ }
1486+
1487+ /* Switch inven/equip */
1488+ command_wrk = !command_wrk;
1489+
1490+ /* Need to redraw */
1491+ break;
1492+ }
1493+
1494+ case '-':
1495+ {
1496+ /* Use floor item */
1497+ if (allow_floor)
1498+ {
1499+ /* Scan all objects in the grid */
1500+ for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
1501+ {
1502+ object_type *o_ptr;
1503+ o_ptr = &current_floor_ptr->o_list[this_o_idx];
1504+ next_o_idx = o_ptr->next_o_idx;
1505+
1506+ /* Validate the item */
1507+ if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
1508+
1509+ /* Special index */
1510+ k = 0 - this_o_idx;
1511+
1512+ /* Verify the item (if required) */
1513+ if (other_query_flag && !verify(_("本当に", "Try"), k)) continue;
1514+
1515+ /* Allow player to "refuse" certain actions */
1516+ if (!get_item_allow(k)) continue;
1517+
1518+ /* Accept that choice */
1519+ (*cp) = k;
1520+ item = TRUE;
1521+ done = TRUE;
1522+ break;
1523+ }
1524+
1525+ /* Outer break */
1526+ if (done) break;
1527+ }
1528+
1529+ bell();
1530+ break;
1531+ }
1532+
1533+ case '0':
1534+ case '1': case '2': case '3':
1535+ case '4': case '5': case '6':
1536+ case '7': case '8': case '9':
1537+ {
1538+ /* Look up the tag */
1539+ if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
1540+ {
1541+ bell();
1542+ break;
1543+ }
1544+
1545+ /* Hack -- Validate the item */
1546+ if ((k < INVEN_RARM) ? !inven : !equip)
1547+ {
1548+ bell();
1549+ break;
1550+ }
1551+
1552+ /* Validate the item */
1553+ if (!get_item_okay(k))
1554+ {
1555+ bell();
1556+ break;
1557+ }
1558+
1559+ /* Allow player to "refuse" certain actions */
1560+ if (!get_item_allow(k))
1561+ {
1562+ done = TRUE;
1563+ break;
1564+ }
1565+
1566+ /* Accept that choice */
1567+ (*cp) = k;
1568+ item = TRUE;
1569+ done = TRUE;
1570+ cur_tag = which;
1571+ break;
1572+ }
1573+
1574+#if 0
1575+ case '\n':
1576+ case '\r':
1577+ {
1578+ /* Choose "default" p_ptr->inventory_list item */
1579+ if (!command_wrk)
1580+ {
1581+ k = ((i1 == i2) ? i1 : -1);
1582+ }
1583+
1584+ /* Choose "default" equipment item */
1585+ else
1586+ {
1587+ k = ((e1 == e2) ? e1 : -1);
1588+ }
1589+
1590+ /* Validate the item */
1591+ if (!get_item_okay(k))
1592+ {
1593+ bell();
1594+ break;
1595+ }
1596+
1597+ /* Allow player to "refuse" certain actions */
1598+ if (!get_item_allow(k))
1599+ {
1600+ done = TRUE;
1601+ break;
1602+ }
1603+
1604+ /* Accept that choice */
1605+ (*cp) = k;
1606+ item = TRUE;
1607+ done = TRUE;
1608+ break;
1609+ }
1610+#endif
1611+
1612+ case 'w':
1613+ {
1614+ if (mode & USE_FORCE) {
1615+ *cp = INVEN_FORCE;
1616+ item = TRUE;
1617+ done = TRUE;
1618+ break;
1619+ }
1620+
1621+ /* Fall through */
1622+ }
1623+
1624+ default:
1625+ {
1626+ int ver;
1627+ bool not_found = FALSE;
1628+
1629+ /* Look up the alphabetical tag */
1630+ if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
1631+ {
1632+ not_found = TRUE;
1633+ }
1634+
1635+ /* Hack -- Validate the item */
1636+ else if ((k < INVEN_RARM) ? !inven : !equip)
1637+ {
1638+ not_found = TRUE;
1639+ }
1640+
1641+ /* Validate the item */
1642+ else if (!get_item_okay(k))
1643+ {
1644+ not_found = TRUE;
1645+ }
1646+
1647+ if (!not_found)
1648+ {
1649+ /* Accept that choice */
1650+ (*cp) = k;
1651+ item = TRUE;
1652+ done = TRUE;
1653+ cur_tag = which;
1654+ break;
1655+ }
1656+
1657+ /* Extract "query" setting */
1658+ ver = isupper(which);
1659+ which = (char)tolower(which);
1660+
1661+ /* Convert letter to p_ptr->inventory_list index */
1662+ if (!command_wrk)
1663+ {
1664+ if (which == '(') k = i1;
1665+ else if (which == ')') k = i2;
1666+ else k = label_to_inven(which);
1667+ }
1668+
1669+ /* Convert letter to equipment index */
1670+ else
1671+ {
1672+ if (which == '(') k = e1;
1673+ else if (which == ')') k = e2;
1674+ else k = label_to_equip(which);
1675+ }
1676+
1677+ /* Validate the item */
1678+ if (!get_item_okay(k))
1679+ {
1680+ bell();
1681+ break;
1682+ }
1683+
1684+ /* Verify the item */
1685+ if (ver && !verify(_("本当に", "Try"), k))
1686+ {
1687+ done = TRUE;
1688+ break;
1689+ }
1690+
1691+ /* Allow player to "refuse" certain actions */
1692+ if (!get_item_allow(k))
1693+ {
1694+ done = TRUE;
1695+ break;
1696+ }
1697+
1698+ /* Accept that choice */
1699+ (*cp) = k;
1700+ item = TRUE;
1701+ done = TRUE;
1702+ break;
1703+ }
1704+ }
1705+ }
1706+ }
1707+
1708+
1709+ /* Fix the screen if necessary */
1710+ if (command_see)
1711+ {
1712+ screen_load();
1713+
1714+ /* Hack -- Cancel "display" */
1715+ command_see = FALSE;
1716+ }
1717+
1718+
1719+ /* Forget the item_tester_tval restriction */
1720+ item_tester_tval = 0;
1721+
1722+ /* Forget the item_tester_hook restriction */
1723+ item_tester_hook = NULL;
1724+
1725+
1726+ /* Clean up 'show choices' */
1727+ /* Toggle again if needed */
1728+ if (toggle) toggle_inven_equip();
1729+
1730+ p_ptr->window |= (PW_INVEN | PW_EQUIP);
1731+ handle_stuff();
1732+
1733+ /* Clear the prompt line */
1734+ prt("", 0, 0);
1735+
1736+ /* Warning if needed */
1737+ if (oops && str) msg_print(str);
1738+
1739+ if (item)
1740+ {
1741+ repeat_push(*cp);
1742+ if (command_cmd) prev_tag = cur_tag;
1743+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1744+ }
1745+ return (item);
1746+}
1747+
1748+/*
1749+ * Choose an item and get auto-picker entry from it.
1750+ */
1751+object_type *choose_object(OBJECT_IDX *idx, concptr q, concptr s, BIT_FLAGS option)
1752+{
1753+ OBJECT_IDX item;
1754+ if (!get_item(&item, q, s, option)) return NULL;
1755+ if (idx) *idx = item;
1756+
1757+ if (item == INVEN_FORCE) return NULL;
1758+
1759+ /* Get the item (in the pack) */
1760+ else if (item >= 0) return &p_ptr->inventory_list[item];
1761+
1762+ /* Get the item (on the floor) */
1763+ else return &current_floor_ptr->o_list[0 - item];
1764+}
1765+
1766+
1767+/*!
1768+ * @brief 床下に落ちているオブジェクトの数を返す / scan_floor
1769+ * @param items オブジェクトのIDリストを返すための配列参照ポインタ
1770+ * @param y 走査するフロアのY座標
1771+ * @param x 走査するフロアのX座標
1772+ * @param mode オプションフラグ
1773+ * @return 対象のマスに落ちているアイテム数
1774+ * @details
1775+ * Return a list of o_list[] indexes of items at the given current_floor_ptr->grid_array
1776+ * location. Valid flags are:
1777+ *
1778+ * mode & 0x01 -- Item tester
1779+ * mode & 0x02 -- Marked items only
1780+ * mode & 0x04 -- Stop after first
1781+ */
1782+ITEM_NUMBER scan_floor(OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode)
1783+{
1784+ OBJECT_IDX this_o_idx, next_o_idx;
1785+
1786+ ITEM_NUMBER num = 0;
1787+
1788+ /* Sanity */
1789+ if (!in_bounds(y, x)) return 0;
1790+
1791+ /* Scan all objects in the grid */
1792+ for (this_o_idx = current_floor_ptr->grid_array[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
1793+ {
1794+ object_type *o_ptr;
1795+ o_ptr = &current_floor_ptr->o_list[this_o_idx];
1796+ next_o_idx = o_ptr->next_o_idx;
1797+
1798+ /* Item tester */
1799+ if ((mode & 0x01) && !item_tester_okay(o_ptr)) continue;
1800+
1801+ /* Marked */
1802+ if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
1803+
1804+ /* Accept this item */
1805+ /* XXX Hack -- Enforce limit */
1806+ if (num < 23)
1807+ items[num] = this_o_idx;
1808+
1809+ num++;
1810+
1811+ /* Only one */
1812+ if (mode & 0x04) break;
1813+ }
1814+ return num;
1815+}
1816+
1817+
1818+/*!
1819+ * @brief 床下に落ちているアイテムの一覧を返す / Display a list of the items on the floor at the given location.
1820+ * @param target_item カーソルの初期値
1821+ * @param y 走査するフロアのY座標
1822+ * @param x 走査するフロアのX座標
1823+ * @param min_width 表示の長さ
1824+ * @return 選択したアイテムの添え字
1825+ * @details
1826+ */
1827+COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_LEN *min_width)
1828+{
1829+ COMMAND_CODE i, m;
1830+ int j, k, l;
1831+ int col, len;
1832+
1833+ object_type *o_ptr;
1834+
1835+ GAME_TEXT o_name[MAX_NLEN];
1836+ char tmp_val[80];
1837+
1838+ COMMAND_CODE out_index[23];
1839+ TERM_COLOR out_color[23];
1840+ char out_desc[23][MAX_NLEN];
1841+ COMMAND_CODE target_item_label = 0;
1842+
1843+ OBJECT_IDX floor_list[23];
1844+ ITEM_NUMBER floor_num;
1845+ TERM_LEN wid, hgt;
1846+ char floor_label[52 + 1];
1847+
1848+ bool dont_need_to_show_weights = TRUE;
1849+
1850+ Term_get_size(&wid, &hgt);
1851+
1852+ /* Default length */
1853+ len = MAX((*min_width), 20);
1854+
1855+ /* Scan for objects in the grid, using item_tester_okay() */
1856+ floor_num = scan_floor(floor_list, y, x, 0x03);
1857+
1858+ /* Display the floor objects */
1859+ for (k = 0, i = 0; i < floor_num && i < 23; i++)
1860+ {
1861+ o_ptr = &current_floor_ptr->o_list[floor_list[i]];
1862+
1863+ object_desc(o_name, o_ptr, 0);
1864+
1865+ /* Save the index */
1866+ out_index[k] = i;
1867+
1868+ /* Acquire p_ptr->inventory_list color */
1869+ out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
1870+
1871+ /* Save the object description */
1872+ strcpy(out_desc[k], o_name);
1873+
1874+ /* Find the predicted "line length" */
1875+ l = strlen(out_desc[k]) + 5;
1876+
1877+ /* Be sure to account for the weight */
1878+ if (show_weights) l += 9;
1879+
1880+ if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
1881+
1882+ /* Maintain the maximum length */
1883+ if (l > len) len = l;
1884+
1885+ /* Advance to next "line" */
1886+ k++;
1887+ }
1888+
1889+ if (show_weights && dont_need_to_show_weights) len -= 9;
1890+
1891+ /* Save width */
1892+ *min_width = len;
1893+
1894+ /* Find the column to start in */
1895+ col = (len > wid - 4) ? 0 : (wid - len - 1);
1896+
1897+ prepare_label_string_floor(floor_label, floor_list, floor_num);
1898+
1899+ /* Output each entry */
1900+ for (j = 0; j < k; j++)
1901+ {
1902+ m = floor_list[out_index[j]];
1903+ o_ptr = &current_floor_ptr->o_list[m];
1904+
1905+ /* Clear the line */
1906+ prt("", j + 1, col ? col - 2 : col);
1907+
1908+ if (use_menu && target_item)
1909+ {
1910+ if (j == (target_item - 1))
1911+ {
1912+ strcpy(tmp_val, _("》", "> "));
1913+ target_item_label = m;
1914+ }
1915+ else strcpy(tmp_val, " ");
1916+ }
1917+ else
1918+ {
1919+ /* Prepare an index --(-- */
1920+ sprintf(tmp_val, "%c)", floor_label[j]);
1921+ }
1922+
1923+ /* Clear the line with the (possibly indented) index */
1924+ put_str(tmp_val, j + 1, col);
1925+
1926+ /* Display the entry itself */
1927+ c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
1928+
1929+ /* Display the weight if needed */
1930+ if (show_weights && (o_ptr->tval != TV_GOLD))
1931+ {
1932+ int wgt = o_ptr->weight * o_ptr->number;
1933+#ifdef JP
1934+ sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
1935+#else
1936+ sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1937+#endif
1938+
1939+ prt(tmp_val, j + 1, wid - 9);
1940+ }
1941+ }
1942+
1943+ /* Make a "shadow" below the list (only if needed) */
1944+ if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
1945+
1946+ return target_item_label;
1947+}
1948+
1949+/*!
1950+ * @brief オブジェクト選択の汎用関数(床上アイテム用) /
1951+ * Let the user select an item, save its "index"
1952+ * @param cp 選択したオブジェクトのIDを返す。
1953+ * @param pmt 選択目的のメッセージ
1954+ * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
1955+ * @param mode オプションフラグ
1956+ * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
1957+ */
1958+bool get_item_floor(COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode)
1959+{
1960+ char n1 = ' ', n2 = ' ', which = ' ';
1961+
1962+ int j;
1963+ COMMAND_CODE i1, i2;
1964+ COMMAND_CODE e1, e2;
1965+ COMMAND_CODE k;
1966+
1967+ bool done, item;
1968+
1969+ bool oops = FALSE;
1970+
1971+ /* Extract args */
1972+ bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
1973+ bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
1974+ bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
1975+ bool force = (mode & USE_FORCE) ? TRUE : FALSE;
1976+
1977+ bool allow_equip = FALSE;
1978+ bool allow_inven = FALSE;
1979+ bool allow_floor = FALSE;
1980+
1981+ bool toggle = FALSE;
1982+
1983+ char tmp_val[160];
1984+ char out_val[160];
1985+
1986+ ITEM_NUMBER floor_num;
1987+ OBJECT_IDX floor_list[23];
1988+ int floor_top = 0;
1989+ TERM_LEN min_width = 0;
1990+
1991+ int menu_line = (use_menu ? 1 : 0);
1992+ int max_inven = 0;
1993+ int max_equip = 0;
1994+
1995+ static char prev_tag = '\0';
1996+ char cur_tag = '\0';
1997+
1998+ /* Get the item index */
1999+ if (repeat_pull(cp))
2000+ {
2001+ /* the_force */
2002+ if (force && (*cp == INVEN_FORCE))
2003+ {
2004+ item_tester_tval = 0;
2005+ item_tester_hook = NULL;
2006+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2007+ return (TRUE);
2008+ }
2009+
2010+ /* Floor item? */
2011+ else if (floor && (*cp < 0))
2012+ {
2013+ if (prev_tag && command_cmd)
2014+ {
2015+ /* Scan all objects in the grid */
2016+ floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2017+
2018+ /* Look up the tag */
2019+ if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
2020+ {
2021+ /* Accept that choice */
2022+ (*cp) = 0 - floor_list[k];
2023+
2024+ /* Forget restrictions */
2025+ item_tester_tval = 0;
2026+ item_tester_hook = NULL;
2027+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2028+
2029+ /* Success */
2030+ return TRUE;
2031+ }
2032+
2033+ prev_tag = '\0'; /* prev_tag is no longer effective */
2034+ }
2035+
2036+ /* Validate the item */
2037+ else if (item_tester_okay(&current_floor_ptr->o_list[0 - (*cp)]) || (mode & USE_FULL))
2038+ {
2039+ /* Forget restrictions */
2040+ item_tester_tval = 0;
2041+ item_tester_hook = NULL;
2042+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2043+
2044+ /* Success */
2045+ return TRUE;
2046+ }
2047+ }
2048+
2049+ else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
2050+ (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
2051+ {
2052+ if (prev_tag && command_cmd)
2053+ {
2054+ /* Look up the tag and validate the item */
2055+ if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
2056+ else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
2057+ else if (!get_item_okay(k)) /* Reject */;
2058+ else
2059+ {
2060+ /* Accept that choice */
2061+ (*cp) = k;
2062+
2063+ /* Forget restrictions */
2064+ item_tester_tval = 0;
2065+ item_tester_hook = NULL;
2066+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2067+
2068+ /* Success */
2069+ return TRUE;
2070+ }
2071+
2072+ prev_tag = '\0'; /* prev_tag is no longer effective */
2073+ }
2074+
2075+ /* Verify the item */
2076+ else if (get_item_okay(*cp))
2077+ {
2078+ /* Forget restrictions */
2079+ item_tester_tval = 0;
2080+ item_tester_hook = NULL;
2081+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2082+
2083+ /* Success */
2084+ return TRUE;
2085+ }
2086+ }
2087+ }
2088+
2089+ msg_print(NULL);
2090+
2091+
2092+ /* Not done */
2093+ done = FALSE;
2094+
2095+ /* No item selected */
2096+ item = FALSE;
2097+
2098+
2099+ /* Full p_ptr->inventory_list */
2100+ i1 = 0;
2101+ i2 = INVEN_PACK - 1;
2102+
2103+ /* Forbid p_ptr->inventory_list */
2104+ if (!inven) i2 = -1;
2105+ else if (use_menu)
2106+ {
2107+ for (j = 0; j < INVEN_PACK; j++)
2108+ if (item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_inven++;
2109+ }
2110+
2111+ /* Restrict p_ptr->inventory_list indexes */
2112+ while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
2113+ while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
2114+
2115+
2116+ /* Full equipment */
2117+ e1 = INVEN_RARM;
2118+ e2 = INVEN_TOTAL - 1;
2119+
2120+ /* Forbid equipment */
2121+ if (!equip) e2 = -1;
2122+ else if (use_menu)
2123+ {
2124+ for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
2125+ if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_equip++;
2126+ if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
2127+ }
2128+
2129+ /* Restrict equipment indexes */
2130+ while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
2131+ while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
2132+
2133+ if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
2134+ {
2135+ if (p_ptr->migite)
2136+ {
2137+ if (e2 < INVEN_LARM) e2 = INVEN_LARM;
2138+ }
2139+ else if (p_ptr->hidarite) e1 = INVEN_RARM;
2140+ }
2141+
2142+
2143+ /* Count "okay" floor items */
2144+ floor_num = 0;
2145+
2146+ /* Restrict floor usage */
2147+ if (floor)
2148+ {
2149+ /* Scan all objects in the grid */
2150+ floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2151+ }
2152+
2153+ /* Accept p_ptr->inventory_list */
2154+ if (i1 <= i2) allow_inven = TRUE;
2155+
2156+ /* Accept equipment */
2157+ if (e1 <= e2) allow_equip = TRUE;
2158+
2159+ /* Accept floor */
2160+ if (floor_num) allow_floor = TRUE;
2161+
2162+ /* Require at least one legal choice */
2163+ if (!allow_inven && !allow_equip && !allow_floor)
2164+ {
2165+ /* Cancel p_ptr->command_see */
2166+ command_see = FALSE;
2167+ oops = TRUE;
2168+ done = TRUE;
2169+
2170+ if (force) {
2171+ *cp = INVEN_FORCE;
2172+ item = TRUE;
2173+ }
2174+ }
2175+
2176+ /* Analyze choices */
2177+ else
2178+ {
2179+ /* Hack -- Start on equipment if requested */
2180+ if (command_see && (command_wrk == (USE_EQUIP))
2181+ && allow_equip)
2182+ {
2183+ command_wrk = (USE_EQUIP);
2184+ }
2185+
2186+ /* Use p_ptr->inventory_list if allowed */
2187+ else if (allow_inven)
2188+ {
2189+ command_wrk = (USE_INVEN);
2190+ }
2191+
2192+ /* Use equipment if allowed */
2193+ else if (allow_equip)
2194+ {
2195+ command_wrk = (USE_EQUIP);
2196+ }
2197+
2198+ /* Use floor if allowed */
2199+ else if (allow_floor)
2200+ {
2201+ command_wrk = (USE_FLOOR);
2202+ }
2203+ }
2204+
2205+ /*
2206+ * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
2207+ */
2208+ if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
2209+
2210+ /* Hack -- start out in "display" mode */
2211+ if (command_see)
2212+ {
2213+ screen_save();
2214+ }
2215+
2216+ /* Repeat until done */
2217+ while (!done)
2218+ {
2219+ COMMAND_CODE get_item_label = 0;
2220+
2221+ /* Show choices */
2222+ int ni = 0;
2223+ int ne = 0;
2224+
2225+ /* Scan windows */
2226+ for (j = 0; j < 8; j++)
2227+ {
2228+ /* Unused */
2229+ if (!angband_term[j]) continue;
2230+
2231+ /* Count windows displaying inven */
2232+ if (window_flag[j] & (PW_INVEN)) ni++;
2233+
2234+ /* Count windows displaying equip */
2235+ if (window_flag[j] & (PW_EQUIP)) ne++;
2236+ }
2237+
2238+ /* Toggle if needed */
2239+ if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
2240+ (command_wrk == (USE_INVEN) && !ni && ne))
2241+ {
2242+ /* Toggle */
2243+ toggle_inven_equip();
2244+
2245+ /* Track toggles */
2246+ toggle = !toggle;
2247+ }
2248+
2249+ p_ptr->window |= (PW_INVEN | PW_EQUIP);
2250+ handle_stuff();
2251+
2252+ /* Inventory screen */
2253+ if (command_wrk == (USE_INVEN))
2254+ {
2255+ /* Extract the legal requests */
2256+ n1 = I2A(i1);
2257+ n2 = I2A(i2);
2258+
2259+ /* Redraw if needed */
2260+ if (command_see) get_item_label = show_inven(menu_line, mode);
2261+ }
2262+
2263+ /* Equipment screen */
2264+ else if (command_wrk == (USE_EQUIP))
2265+ {
2266+ /* Extract the legal requests */
2267+ n1 = I2A(e1 - INVEN_RARM);
2268+ n2 = I2A(e2 - INVEN_RARM);
2269+
2270+ /* Redraw if needed */
2271+ if (command_see) get_item_label = show_equip(menu_line, mode);
2272+ }
2273+
2274+ /* Floor screen */
2275+ else if (command_wrk == (USE_FLOOR))
2276+ {
2277+ j = floor_top;
2278+ k = MIN(floor_top + 23, floor_num) - 1;
2279+
2280+ /* Extract the legal requests */
2281+ n1 = I2A(j - floor_top);
2282+ n2 = I2A(k - floor_top);
2283+
2284+ /* Redraw if needed */
2285+ if (command_see) get_item_label = show_floor(menu_line, p_ptr->y, p_ptr->x, &min_width);
2286+ }
2287+
2288+ /* Viewing p_ptr->inventory_list */
2289+ if (command_wrk == (USE_INVEN))
2290+ {
2291+ /* Begin the prompt */
2292+ sprintf(out_val, _("持ち物:", "Inven:"));
2293+
2294+ if (!use_menu)
2295+ {
2296+ /* Build the prompt */
2297+ sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2298+ index_to_label(i1), index_to_label(i2));
2299+
2300+ /* Append */
2301+ strcat(out_val, tmp_val);
2302+ }
2303+
2304+ /* Indicate ability to "view" */
2305+ if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2306+
2307+ /* Append */
2308+ if (allow_equip)
2309+ {
2310+ if (!use_menu)
2311+ strcat(out_val, _(" '/' 装備品,", " / for Equip,"));
2312+ else if (allow_floor)
2313+ strcat(out_val, _(" '6' 装備品,", " 6 for Equip,"));
2314+ else
2315+ strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
2316+ }
2317+
2318+ /* Append */
2319+ if (allow_floor)
2320+ {
2321+ if (!use_menu)
2322+ strcat(out_val, _(" '-'床上,", " - for floor,"));
2323+ else if (allow_equip)
2324+ strcat(out_val, _(" '4' 床上,", " 4 for floor,"));
2325+ else
2326+ strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
2327+ }
2328+ }
2329+
2330+ /* Viewing equipment */
2331+ else if (command_wrk == (USE_EQUIP))
2332+ {
2333+ /* Begin the prompt */
2334+ sprintf(out_val, _("装備品:", "Equip:"));
2335+
2336+ if (!use_menu)
2337+ {
2338+ /* Build the prompt */
2339+ sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2340+ index_to_label(e1), index_to_label(e2));
2341+
2342+ /* Append */
2343+ strcat(out_val, tmp_val);
2344+ }
2345+
2346+ /* Indicate ability to "view" */
2347+ if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2348+
2349+ /* Append */
2350+ if (allow_inven)
2351+ {
2352+ if (!use_menu)
2353+ strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
2354+ else if (allow_floor)
2355+ strcat(out_val, _(" '4' 持ち物,", " 4 for Inven,"));
2356+ else
2357+ strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
2358+ }
2359+
2360+ /* Append */
2361+ if (allow_floor)
2362+ {
2363+ if (!use_menu)
2364+ strcat(out_val, _(" '-'床上,", " - for floor,"));
2365+ else if (allow_inven)
2366+ strcat(out_val, _(" '6' 床上,", " 6 for floor,"));
2367+ else
2368+ strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
2369+ }
2370+ }
2371+
2372+ /* Viewing floor */
2373+ else if (command_wrk == (USE_FLOOR))
2374+ {
2375+ /* Begin the prompt */
2376+ sprintf(out_val, _("床上:", "Floor:"));
2377+
2378+ if (!use_menu)
2379+ {
2380+ /* Build the prompt */
2381+ sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
2382+
2383+ /* Append */
2384+ strcat(out_val, tmp_val);
2385+ }
2386+
2387+ /* Indicate ability to "view" */
2388+ if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2389+
2390+ if (use_menu)
2391+ {
2392+ if (allow_inven && allow_equip)
2393+ {
2394+ strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
2395+ }
2396+ else if (allow_inven)
2397+ {
2398+ strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
2399+ }
2400+ else if (allow_equip)
2401+ {
2402+ strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
2403+ }
2404+ }
2405+ /* Append */
2406+ else if (allow_inven)
2407+ {
2408+ strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
2409+ }
2410+ else if (allow_equip)
2411+ {
2412+ strcat(out_val, _(" '/'装備品,", " / for Equip,"));
2413+ }
2414+
2415+ /* Append */
2416+ if (command_see && !use_menu)
2417+ {
2418+ strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
2419+ }
2420+ }
2421+
2422+ /* Append */
2423+ if (force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
2424+
2425+ /* Finish the prompt */
2426+ strcat(out_val, " ESC");
2427+
2428+ /* Build the prompt */
2429+ sprintf(tmp_val, "(%s) %s", out_val, pmt);
2430+
2431+ /* Show the prompt */
2432+ prt(tmp_val, 0, 0);
2433+
2434+ /* Get a key */
2435+ which = inkey();
2436+
2437+ if (use_menu)
2438+ {
2439+ int max_line = 1;
2440+ if (command_wrk == USE_INVEN) max_line = max_inven;
2441+ else if (command_wrk == USE_EQUIP) max_line = max_equip;
2442+ else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
2443+ switch (which)
2444+ {
2445+ case ESCAPE:
2446+ case 'z':
2447+ case 'Z':
2448+ case '0':
2449+ {
2450+ done = TRUE;
2451+ break;
2452+ }
2453+
2454+ case '8':
2455+ case 'k':
2456+ case 'K':
2457+ {
2458+ menu_line += (max_line - 1);
2459+ break;
2460+ }
2461+
2462+ case '2':
2463+ case 'j':
2464+ case 'J':
2465+ {
2466+ menu_line++;
2467+ break;
2468+ }
2469+
2470+ case '4':
2471+ case 'h':
2472+ case 'H':
2473+ {
2474+ /* Verify legality */
2475+ if (command_wrk == (USE_INVEN))
2476+ {
2477+ if (allow_floor) command_wrk = USE_FLOOR;
2478+ else if (allow_equip) command_wrk = USE_EQUIP;
2479+ else
2480+ {
2481+ bell();
2482+ break;
2483+ }
2484+ }
2485+ else if (command_wrk == (USE_EQUIP))
2486+ {
2487+ if (allow_inven) command_wrk = USE_INVEN;
2488+ else if (allow_floor) command_wrk = USE_FLOOR;
2489+ else
2490+ {
2491+ bell();
2492+ break;
2493+ }
2494+ }
2495+ else if (command_wrk == (USE_FLOOR))
2496+ {
2497+ if (allow_equip) command_wrk = USE_EQUIP;
2498+ else if (allow_inven) command_wrk = USE_INVEN;
2499+ else
2500+ {
2501+ bell();
2502+ break;
2503+ }
2504+ }
2505+ else
2506+ {
2507+ bell();
2508+ break;
2509+ }
2510+
2511+ /* Hack -- Fix screen */
2512+ if (command_see)
2513+ {
2514+ screen_load();
2515+ screen_save();
2516+ }
2517+
2518+ /* Switch inven/equip */
2519+ if (command_wrk == USE_INVEN) max_line = max_inven;
2520+ else if (command_wrk == USE_EQUIP) max_line = max_equip;
2521+ else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
2522+ if (menu_line > max_line) menu_line = max_line;
2523+
2524+ /* Need to redraw */
2525+ break;
2526+ }
2527+
2528+ case '6':
2529+ case 'l':
2530+ case 'L':
2531+ {
2532+ /* Verify legality */
2533+ if (command_wrk == (USE_INVEN))
2534+ {
2535+ if (allow_equip) command_wrk = USE_EQUIP;
2536+ else if (allow_floor) command_wrk = USE_FLOOR;
2537+ else
2538+ {
2539+ bell();
2540+ break;
2541+ }
2542+ }
2543+ else if (command_wrk == (USE_EQUIP))
2544+ {
2545+ if (allow_floor) command_wrk = USE_FLOOR;
2546+ else if (allow_inven) command_wrk = USE_INVEN;
2547+ else
2548+ {
2549+ bell();
2550+ break;
2551+ }
2552+ }
2553+ else if (command_wrk == (USE_FLOOR))
2554+ {
2555+ if (allow_inven) command_wrk = USE_INVEN;
2556+ else if (allow_equip) command_wrk = USE_EQUIP;
2557+ else
2558+ {
2559+ bell();
2560+ break;
2561+ }
2562+ }
2563+ else
2564+ {
2565+ bell();
2566+ break;
2567+ }
2568+
2569+ /* Hack -- Fix screen */
2570+ if (command_see)
2571+ {
2572+ screen_load();
2573+ screen_save();
2574+ }
2575+
2576+ /* Switch inven/equip */
2577+ if (command_wrk == USE_INVEN) max_line = max_inven;
2578+ else if (command_wrk == USE_EQUIP) max_line = max_equip;
2579+ else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
2580+ if (menu_line > max_line) menu_line = max_line;
2581+
2582+ /* Need to redraw */
2583+ break;
2584+ }
2585+
2586+ case 'x':
2587+ case 'X':
2588+ case '\r':
2589+ case '\n':
2590+ {
2591+ if (command_wrk == USE_FLOOR)
2592+ {
2593+ /* Special index */
2594+ (*cp) = -get_item_label;
2595+ }
2596+ else
2597+ {
2598+ /* Validate the item */
2599+ if (!get_item_okay(get_item_label))
2600+ {
2601+ bell();
2602+ break;
2603+ }
2604+
2605+ /* Allow player to "refuse" certain actions */
2606+ if (!get_item_allow(get_item_label))
2607+ {
2608+ done = TRUE;
2609+ break;
2610+ }
2611+
2612+ /* Accept that choice */
2613+ (*cp) = get_item_label;
2614+ }
2615+
2616+ item = TRUE;
2617+ done = TRUE;
2618+ break;
2619+ }
2620+ case 'w':
2621+ {
2622+ if (force) {
2623+ *cp = INVEN_FORCE;
2624+ item = TRUE;
2625+ done = TRUE;
2626+ break;
2627+ }
2628+ }
2629+ }
2630+ if (menu_line > max_line) menu_line -= max_line;
2631+ }
2632+ else
2633+ {
2634+ /* Parse it */
2635+ switch (which)
2636+ {
2637+ case ESCAPE:
2638+ {
2639+ done = TRUE;
2640+ break;
2641+ }
2642+
2643+ case '*':
2644+ case '?':
2645+ case ' ':
2646+ {
2647+ /* Hide the list */
2648+ if (command_see)
2649+ {
2650+ /* Flip flag */
2651+ command_see = FALSE;
2652+ screen_load();
2653+ }
2654+
2655+ /* Show the list */
2656+ else
2657+ {
2658+ screen_save();
2659+
2660+ /* Flip flag */
2661+ command_see = TRUE;
2662+ }
2663+ break;
2664+ }
2665+
2666+ case '\n':
2667+ case '\r':
2668+ case '+':
2669+ {
2670+ int i;
2671+ OBJECT_IDX o_idx;
2672+ grid_type *g_ptr = &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
2673+
2674+ if (command_wrk != (USE_FLOOR)) break;
2675+
2676+ /* Get the object being moved. */
2677+ o_idx = g_ptr->o_idx;
2678+
2679+ /* Only rotate a pile of two or more objects. */
2680+ if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) break;
2681+
2682+ /* Remove the first object from the list. */
2683+ excise_object_idx(o_idx);
2684+
2685+ /* Find end of the list. */
2686+ i = g_ptr->o_idx;
2687+ while (current_floor_ptr->o_list[i].next_o_idx)
2688+ i = current_floor_ptr->o_list[i].next_o_idx;
2689+
2690+ /* Add after the last object. */
2691+ current_floor_ptr->o_list[i].next_o_idx = o_idx;
2692+
2693+ /* Re-scan floor list */
2694+ floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2695+
2696+ /* Hack -- Fix screen */
2697+ if (command_see)
2698+ {
2699+ screen_load();
2700+ screen_save();
2701+ }
2702+
2703+ break;
2704+ }
2705+
2706+ case '/':
2707+ {
2708+ if (command_wrk == (USE_INVEN))
2709+ {
2710+ if (!allow_equip)
2711+ {
2712+ bell();
2713+ break;
2714+ }
2715+ command_wrk = (USE_EQUIP);
2716+ }
2717+ else if (command_wrk == (USE_EQUIP))
2718+ {
2719+ if (!allow_inven)
2720+ {
2721+ bell();
2722+ break;
2723+ }
2724+ command_wrk = (USE_INVEN);
2725+ }
2726+ else if (command_wrk == (USE_FLOOR))
2727+ {
2728+ if (allow_inven)
2729+ {
2730+ command_wrk = (USE_INVEN);
2731+ }
2732+ else if (allow_equip)
2733+ {
2734+ command_wrk = (USE_EQUIP);
2735+ }
2736+ else
2737+ {
2738+ bell();
2739+ break;
2740+ }
2741+ }
2742+
2743+ /* Hack -- Fix screen */
2744+ if (command_see)
2745+ {
2746+ screen_load();
2747+ screen_save();
2748+ }
2749+
2750+ /* Need to redraw */
2751+ break;
2752+ }
2753+
2754+ case '-':
2755+ {
2756+ if (!allow_floor)
2757+ {
2758+ bell();
2759+ break;
2760+ }
2761+
2762+ /*
2763+ * If we are already examining the floor, and there
2764+ * is only one item, we will always select it.
2765+ * If we aren't examining the floor and there is only
2766+ * one item, we will select it if floor_query_flag
2767+ * is FALSE.
2768+ */
2769+ if (floor_num == 1)
2770+ {
2771+ if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
2772+ {
2773+ /* Special index */
2774+ k = 0 - floor_list[0];
2775+
2776+ /* Allow player to "refuse" certain actions */
2777+ if (!get_item_allow(k))
2778+ {
2779+ done = TRUE;
2780+ break;
2781+ }
2782+
2783+ /* Accept that choice */
2784+ (*cp) = k;
2785+ item = TRUE;
2786+ done = TRUE;
2787+
2788+ break;
2789+ }
2790+ }
2791+
2792+ /* Hack -- Fix screen */
2793+ if (command_see)
2794+ {
2795+ screen_load();
2796+ screen_save();
2797+ }
2798+
2799+ command_wrk = (USE_FLOOR);
2800+
2801+ break;
2802+ }
2803+
2804+ case '0':
2805+ case '1': case '2': case '3':
2806+ case '4': case '5': case '6':
2807+ case '7': case '8': case '9':
2808+ {
2809+ if (command_wrk != USE_FLOOR)
2810+ {
2811+ /* Look up the tag */
2812+ if (!get_tag(&k, which, command_wrk))
2813+ {
2814+ bell();
2815+ break;
2816+ }
2817+
2818+ /* Hack -- Validate the item */
2819+ if ((k < INVEN_RARM) ? !inven : !equip)
2820+ {
2821+ bell();
2822+ break;
2823+ }
2824+
2825+ /* Validate the item */
2826+ if (!get_item_okay(k))
2827+ {
2828+ bell();
2829+ break;
2830+ }
2831+ }
2832+ else
2833+ {
2834+ /* Look up the alphabetical tag */
2835+ if (get_tag_floor(&k, which, floor_list, floor_num))
2836+ {
2837+ /* Special index */
2838+ k = 0 - floor_list[k];
2839+ }
2840+ else
2841+ {
2842+ bell();
2843+ break;
2844+ }
2845+ }
2846+
2847+ /* Allow player to "refuse" certain actions */
2848+ if (!get_item_allow(k))
2849+ {
2850+ done = TRUE;
2851+ break;
2852+ }
2853+
2854+ /* Accept that choice */
2855+ (*cp) = k;
2856+ item = TRUE;
2857+ done = TRUE;
2858+ cur_tag = which;
2859+ break;
2860+ }
2861+
2862+#if 0
2863+ case '\n':
2864+ case '\r':
2865+ {
2866+ /* Choose "default" p_ptr->inventory_list item */
2867+ if (command_wrk == (USE_INVEN))
2868+ {
2869+ k = ((i1 == i2) ? i1 : -1);
2870+ }
2871+
2872+ /* Choose "default" equipment item */
2873+ else if (command_wrk == (USE_EQUIP))
2874+ {
2875+ k = ((e1 == e2) ? e1 : -1);
2876+ }
2877+
2878+ /* Choose "default" floor item */
2879+ else if (command_wrk == (USE_FLOOR))
2880+ {
2881+ if (floor_num == 1)
2882+ {
2883+ /* Special index */
2884+ k = 0 - floor_list[0];
2885+
2886+ /* Allow player to "refuse" certain actions */
2887+ if (!get_item_allow(k))
2888+ {
2889+ done = TRUE;
2890+ break;
2891+ }
2892+
2893+ /* Accept that choice */
2894+ (*cp) = k;
2895+ item = TRUE;
2896+ done = TRUE;
2897+ }
2898+ break;
2899+ }
2900+
2901+ /* Validate the item */
2902+ if (!get_item_okay(k))
2903+ {
2904+ bell();
2905+ break;
2906+ }
2907+
2908+ /* Allow player to "refuse" certain actions */
2909+ if (!get_item_allow(k))
2910+ {
2911+ done = TRUE;
2912+ break;
2913+ }
2914+
2915+ /* Accept that choice */
2916+ (*cp) = k;
2917+ item = TRUE;
2918+ done = TRUE;
2919+ break;
2920+ }
2921+#endif
2922+
2923+ case 'w':
2924+ {
2925+ if (force) {
2926+ *cp = INVEN_FORCE;
2927+ item = TRUE;
2928+ done = TRUE;
2929+ break;
2930+ }
2931+
2932+ /* Fall through */
2933+ }
2934+
2935+ default:
2936+ {
2937+ int ver;
2938+
2939+ if (command_wrk != USE_FLOOR)
2940+ {
2941+ bool not_found = FALSE;
2942+
2943+ /* Look up the alphabetical tag */
2944+ if (!get_tag(&k, which, command_wrk))
2945+ {
2946+ not_found = TRUE;
2947+ }
2948+
2949+ /* Hack -- Validate the item */
2950+ else if ((k < INVEN_RARM) ? !inven : !equip)
2951+ {
2952+ not_found = TRUE;
2953+ }
2954+
2955+ /* Validate the item */
2956+ else if (!get_item_okay(k))
2957+ {
2958+ not_found = TRUE;
2959+ }
2960+
2961+ if (!not_found)
2962+ {
2963+ /* Accept that choice */
2964+ (*cp) = k;
2965+ item = TRUE;
2966+ done = TRUE;
2967+ cur_tag = which;
2968+ break;
2969+ }
2970+ }
2971+ else
2972+ {
2973+ /* Look up the alphabetical tag */
2974+ if (get_tag_floor(&k, which, floor_list, floor_num))
2975+ {
2976+ /* Special index */
2977+ k = 0 - floor_list[k];
2978+
2979+ /* Accept that choice */
2980+ (*cp) = k;
2981+ item = TRUE;
2982+ done = TRUE;
2983+ cur_tag = which;
2984+ break;
2985+ }
2986+ }
2987+
2988+ /* Extract "query" setting */
2989+ ver = isupper(which);
2990+ which = (char)tolower(which);
2991+
2992+ /* Convert letter to p_ptr->inventory_list index */
2993+ if (command_wrk == (USE_INVEN))
2994+ {
2995+ if (which == '(') k = i1;
2996+ else if (which == ')') k = i2;
2997+ else k = label_to_inven(which);
2998+ }
2999+
3000+ /* Convert letter to equipment index */
3001+ else if (command_wrk == (USE_EQUIP))
3002+ {
3003+ if (which == '(') k = e1;
3004+ else if (which == ')') k = e2;
3005+ else k = label_to_equip(which);
3006+ }
3007+
3008+ /* Convert letter to floor index */
3009+ else if (command_wrk == USE_FLOOR)
3010+ {
3011+ if (which == '(') k = 0;
3012+ else if (which == ')') k = floor_num - 1;
3013+ else k = islower(which) ? A2I(which) : -1;
3014+ if (k < 0 || k >= floor_num || k >= 23)
3015+ {
3016+ bell();
3017+ break;
3018+ }
3019+
3020+ /* Special index */
3021+ k = 0 - floor_list[k];
3022+ }
3023+
3024+ /* Validate the item */
3025+ if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
3026+ {
3027+ bell();
3028+ break;
3029+ }
3030+
3031+ /* Verify the item */
3032+ if (ver && !verify(_("本当に", "Try"), k))
3033+ {
3034+ done = TRUE;
3035+ break;
3036+ }
3037+
3038+ /* Allow player to "refuse" certain actions */
3039+ if (!get_item_allow(k))
3040+ {
3041+ done = TRUE;
3042+ break;
3043+ }
3044+
3045+ /* Accept that choice */
3046+ (*cp) = k;
3047+ item = TRUE;
3048+ done = TRUE;
3049+ break;
3050+ }
3051+ }
3052+ }
3053+ }
3054+
3055+ /* Fix the screen if necessary */
3056+ if (command_see)
3057+ {
3058+ screen_load();
3059+
3060+ /* Hack -- Cancel "display" */
3061+ command_see = FALSE;
3062+ }
3063+
3064+
3065+ /* Forget the item_tester_tval restriction */
3066+ item_tester_tval = 0;
3067+
3068+ /* Forget the item_tester_hook restriction */
3069+ item_tester_hook = NULL;
3070+
3071+
3072+ /* Clean up 'show choices' */
3073+ /* Toggle again if needed */
3074+ if (toggle) toggle_inven_equip();
3075+
3076+ p_ptr->window |= (PW_INVEN | PW_EQUIP);
3077+ handle_stuff();
3078+
3079+ /* Clear the prompt line */
3080+ prt("", 0, 0);
3081+
3082+ /* Warning if needed */
3083+ if (oops && str) msg_print(str);
3084+
3085+ if (item)
3086+ {
3087+ repeat_push(*cp);
3088+ if (command_cmd) prev_tag = cur_tag;
3089+ command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3090+ }
3091+ return (item);
3092+}
3093+
3094+/*!
3095+ * @brief 床上のアイテムを拾う選択用サブルーチン
3096+ * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
3097+ */
3098+static bool py_pickup_floor_aux(void)
3099+{
3100+ OBJECT_IDX this_o_idx;
3101+ concptr q, s;
3102+ OBJECT_IDX item;
3103+
3104+ /* Restrict the choices */
3105+ item_tester_hook = inven_carry_okay;
3106+
3107+ /* Get an object */
3108+ q = _("どれを拾いますか?", "Get which item? ");
3109+ s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
3110+
3111+ if (choose_object(&item, q, s, (USE_FLOOR)))
3112+ {
3113+ this_o_idx = 0 - item;
3114+ }
3115+ else
3116+ {
3117+ return (FALSE);
3118+ }
3119+
3120+ /* Pick up the object */
3121+ py_pickup_aux(this_o_idx);
3122+
3123+ return (TRUE);
3124+}
3125+
3126+/*!
3127+ * @brief 床上のアイテムを拾うメイン処理
3128+ * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
3129+ * @return なし
3130+ * @details
3131+ * This is called by py_pickup() when easy_floor is TRUE.
3132+ */
3133+void py_pickup_floor(bool pickup)
3134+{
3135+ OBJECT_IDX this_o_idx, next_o_idx = 0;
3136+
3137+ GAME_TEXT o_name[MAX_NLEN];
3138+ object_type *o_ptr;
3139+
3140+ int floor_num = 0;
3141+ OBJECT_IDX floor_o_idx = 0;
3142+
3143+ int can_pickup = 0;
3144+
3145+ /* Scan the pile of objects */
3146+ for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3147+ {
3148+ /* Access the object */
3149+ o_ptr = &current_floor_ptr->o_list[this_o_idx];
3150+
3151+ object_desc(o_name, o_ptr, 0);
3152+
3153+ /* Access the next object */
3154+ next_o_idx = o_ptr->next_o_idx;
3155+
3156+ disturb(FALSE, FALSE);
3157+
3158+ /* Pick up gold */
3159+ if (o_ptr->tval == TV_GOLD)
3160+ {
3161+#ifdef JP
3162+ msg_format(" $%ld の価値がある%sを見つけた。",
3163+ (long)o_ptr->pval, o_name);
3164+#else
3165+ msg_format("You have found %ld gold pieces worth of %s.",
3166+ (long)o_ptr->pval, o_name);
3167+#endif
3168+
3169+ /* Collect the gold */
3170+ p_ptr->au += o_ptr->pval;
3171+
3172+ /* Redraw gold */
3173+ p_ptr->redraw |= (PR_GOLD);
3174+
3175+ p_ptr->window |= (PW_PLAYER);
3176+
3177+ /* Delete the gold */
3178+ delete_object_idx(this_o_idx);
3179+
3180+ /* Check the next object */
3181+ continue;
3182+ }
3183+ else if (o_ptr->marked & OM_NOMSG)
3184+ {
3185+ /* If 0 or 1 non-NOMSG items are in the pile, the NOMSG ones are
3186+ * ignored. Otherwise, they are included in the prompt. */
3187+ o_ptr->marked &= ~(OM_NOMSG);
3188+ continue;
3189+ }
3190+
3191+ /* Count non-gold objects that can be picked up. */
3192+ if (inven_carry_okay(o_ptr))
3193+ {
3194+ can_pickup++;
3195+ }
3196+
3197+ /* Count non-gold objects */
3198+ floor_num++;
3199+
3200+ /* Remember this index */
3201+ floor_o_idx = this_o_idx;
3202+ }
3203+
3204+ /* There are no non-gold objects */
3205+ if (!floor_num)
3206+ return;
3207+
3208+ /* Mention the number of objects */
3209+ if (!pickup)
3210+ {
3211+ /* One object */
3212+ if (floor_num == 1)
3213+ {
3214+ /* Access the object */
3215+ o_ptr = &current_floor_ptr->o_list[floor_o_idx];
3216+
3217+#ifdef ALLOW_EASY_SENSE
3218+
3219+ /* Option: Make object sensing easy */
3220+ if (easy_sense)
3221+ {
3222+ /* Sense the object */
3223+ (void)sense_object(o_ptr);
3224+ }
3225+
3226+#endif /* ALLOW_EASY_SENSE */
3227+
3228+ object_desc(o_name, o_ptr, 0);
3229+
3230+ msg_format(_("%sがある。", "You see %s."), o_name);
3231+ }
3232+
3233+ /* Multiple objects */
3234+ else
3235+ {
3236+ msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
3237+ }
3238+
3239+ return;
3240+ }
3241+
3242+ /* The player has no room for anything on the floor. */
3243+ if (!can_pickup)
3244+ {
3245+ /* One object */
3246+ if (floor_num == 1)
3247+ {
3248+ /* Access the object */
3249+ o_ptr = &current_floor_ptr->o_list[floor_o_idx];
3250+
3251+#ifdef ALLOW_EASY_SENSE
3252+
3253+ /* Option: Make object sensing easy */
3254+ if (easy_sense)
3255+ {
3256+ /* Sense the object */
3257+ (void)sense_object(o_ptr);
3258+ }
3259+
3260+#endif /* ALLOW_EASY_SENSE */
3261+
3262+ object_desc(o_name, o_ptr, 0);
3263+
3264+ msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
3265+ }
3266+
3267+ /* Multiple objects */
3268+ else
3269+ {
3270+ msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
3271+
3272+ }
3273+
3274+ return;
3275+ }
3276+
3277+ /* One object */
3278+ if (floor_num == 1)
3279+ {
3280+ /* Hack -- query every object */
3281+ if (carry_query_flag)
3282+ {
3283+ char out_val[MAX_NLEN + 20];
3284+
3285+ /* Access the object */
3286+ o_ptr = &current_floor_ptr->o_list[floor_o_idx];
3287+
3288+#ifdef ALLOW_EASY_SENSE
3289+
3290+ /* Option: Make object sensing easy */
3291+ if (easy_sense)
3292+ {
3293+ /* Sense the object */
3294+ (void)sense_object(o_ptr);
3295+ }
3296+
3297+#endif /* ALLOW_EASY_SENSE */
3298+
3299+ object_desc(o_name, o_ptr, 0);
3300+
3301+ /* Build a prompt */
3302+ (void)sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
3303+
3304+ /* Ask the user to confirm */
3305+ if (!get_check(out_val))
3306+ {
3307+ return;
3308+ }
3309+ }
3310+
3311+ /* Access the object */
3312+ o_ptr = &current_floor_ptr->o_list[floor_o_idx];
3313+
3314+#ifdef ALLOW_EASY_SENSE
3315+
3316+ /* Option: Make object sensing easy */
3317+ if (easy_sense)
3318+ {
3319+ /* Sense the object */
3320+ (void)sense_object(o_ptr);
3321+ }
3322+
3323+#endif /* ALLOW_EASY_SENSE */
3324+
3325+ /* Pick up the object */
3326+ py_pickup_aux(floor_o_idx);
3327+ }
3328+
3329+ /* Allow the user to choose an object */
3330+ else
3331+ {
3332+ while (can_pickup--)
3333+ {
3334+ if (!py_pickup_floor_aux()) break;
3335+ }
3336+ }
3337+}
3338+
Show on old repository browser