OSDN Git Service

Changed English wording for header of the monster list selected by matching a substring.
[hengbandforosx/hengbandosx.git] / src / cmd-io / cmd-lore.cpp
1 #include "cmd-io/cmd-lore.h"
2 #include "core/asking-player.h"
3 #include "core/stuff-handler.h"
4 #include "game-option/cheat-options.h"
5 #include "game-option/game-play-options.h"
6 #include "io/input-key-acceptor.h"
7 #include "monster-race/monster-race.h"
8 #include "monster-race/race-flags1.h"
9 #include "monster-race/race-flags7.h"
10 #include "term/gameterm.h"
11 #include "term/screen-processor.h"
12 #include "term/term-color-types.h"
13 #include "util/int-char-converter.h"
14 #include "util/sort.h"
15 #include "util/string-processor.h"
16 #include "view/display-lore.h"
17
18 /*!
19  * @brief モンスターの思い出を見るコマンドのメインルーチン
20  * Identify a character, allow recall of monsters
21  * @param player_ptr プレーヤーへの参照ポインタ
22  * @return なし
23  * @details
24  * <pre>
25  * Several "special" responses recall "multiple" monsters:
26  *   ^A (all monsters)
27  *   ^U (all unique monsters)
28  *   ^N (all non-unique monsters)
29  *
30  * The responses may be sorted in several ways, see below.
31  *
32  * Note that the player ghosts are ignored.
33  * </pre>
34  */
35 void do_cmd_query_symbol(player_type *creature_ptr)
36 {
37     MONRACE_IDX i;
38     int n;
39     MONRACE_IDX r_idx;
40     char sym, query;
41     char buf[256];
42
43     bool all = FALSE;
44     bool uniq = FALSE;
45     bool norm = FALSE;
46     bool ride = FALSE;
47     char temp[MAX_MONSTER_NAME] = "";
48
49     bool recall = FALSE;
50
51     u16b why = 0;
52     MONRACE_IDX *who;
53
54     if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
55                      "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "),
56             &sym, FALSE))
57         return;
58
59     for (i = 0; ident_info[i]; ++i) {
60         if (sym == ident_info[i][0])
61             break;
62     }
63
64     if (sym == KTRL('A')) {
65         all = TRUE;
66         strcpy(buf, _("全モンスターのリスト", "Full monster list."));
67     } else if (sym == KTRL('U')) {
68         all = uniq = TRUE;
69         strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
70     } else if (sym == KTRL('N')) {
71         all = norm = TRUE;
72         strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
73     } else if (sym == KTRL('R')) {
74         all = ride = TRUE;
75         strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
76     } else if (sym == KTRL('M')) {
77         all = TRUE;
78         if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"), temp, 70)) {
79             temp[0] = 0;
80             return;
81         }
82         sprintf(buf, _("名前:%sにマッチ", "Monsters' names with \"%s\""), temp);
83     } else if (ident_info[i]) {
84         sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
85     } else {
86         sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
87     }
88
89     prt(buf, 0, 0);
90     C_MAKE(who, max_r_idx, MONRACE_IDX);
91     for (n = 0, i = 1; i < max_r_idx; i++) {
92         monster_race *r_ptr = &r_info[i];
93         if (!cheat_know && !r_ptr->r_sights)
94             continue;
95
96         if (norm && (r_ptr->flags1 & (RF1_UNIQUE)))
97             continue;
98
99         if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE)))
100             continue;
101
102         if (ride && !(r_ptr->flags7 & (RF7_RIDING)))
103             continue;
104
105         if (temp[0]) {
106             TERM_LEN xx;
107             char temp2[MAX_MONSTER_NAME];
108
109             for (xx = 0; temp[xx] && xx < MAX_MONSTER_NAME; xx++) {
110 #ifdef JP
111                 if (iskanji(temp[xx])) {
112                     xx++;
113                     continue;
114                 }
115 #endif
116                 if (isupper(temp[xx]))
117                     temp[xx] = (char)tolower(temp[xx]);
118             }
119
120 #ifdef JP
121             strcpy(temp2, r_name + r_ptr->E_name);
122 #else
123             strcpy(temp2, r_name + r_ptr->name);
124 #endif
125             for (xx = 0; temp2[xx] && xx < MAX_MONSTER_NAME; xx++)
126                 if (isupper(temp2[xx]))
127                     temp2[xx] = (char)tolower(temp2[xx]);
128
129 #ifdef JP
130             if (angband_strstr(temp2, temp) || angband_strstr(r_name + r_ptr->name, temp))
131 #else
132             if (angband_strstr(temp2, temp))
133 #endif
134                 who[n++] = i;
135         }
136
137         else if (all || (r_ptr->d_char == sym))
138             who[n++] = i;
139     }
140
141     if (!n) {
142         C_KILL(who, max_r_idx, MONRACE_IDX);
143         return;
144     }
145
146     put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
147     query = inkey();
148     prt(buf, 0, 0);
149     why = 2;
150     ang_sort(creature_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
151     if (query == 'k') {
152         why = 4;
153         query = 'y';
154     }
155
156     if (query != 'y') {
157         C_KILL(who, max_r_idx, MONRACE_IDX);
158         return;
159     }
160
161     if (why == 4) {
162         ang_sort(creature_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
163     }
164
165     i = n - 1;
166     while (TRUE) {
167         r_idx = who[i];
168         monster_race_track(creature_ptr, r_idx);
169         handle_stuff(creature_ptr);
170         while (TRUE) {
171             if (recall) {
172                 screen_save();
173                 screen_roff(creature_ptr, who[i], MONSTER_LORE_NORMAL);
174             }
175
176             roff_top(r_idx);
177             term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
178             query = inkey();
179             if (recall) {
180                 screen_load();
181             }
182
183             if (query != 'r')
184                 break;
185             recall = !recall;
186         }
187
188         if (query == ESCAPE)
189             break;
190
191         if (query == '-') {
192             if (++i == n) {
193                 i = 0;
194                 if (!expand_list)
195                     break;
196             }
197         } else {
198             if (i-- == 0) {
199                 i = n - 1;
200                 if (!expand_list)
201                     break;
202             }
203         }
204     }
205
206     C_KILL(who, max_r_idx, MONRACE_IDX);
207     prt(buf, 0, 0);
208 }