OSDN Git Service

Merge remote-tracking branch 'remotes/hengbandosx/english-mind-edits' into feature...
[hengband/hengband.git] / src / cmd-visual / cmd-draw.c
1 #include "cmd-visual/cmd-draw.h"
2 #include "core/asking-player.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "core/stuff-handler.h"
6 #include "core/window-redrawer.h"
7 #include "io/files-util.h"
8 #include "io/input-key-acceptor.h"
9 #include "main/sound-of-music.h"
10 #include "player/player-race-types.h"
11 #include "player/process-name.h"
12 #include "racial/racial-android.h"
13 #include "term/gameterm.h"
14 #include "term/screen-processor.h"
15 #include "term/term-color-types.h"
16 #include "util/int-char-converter.h"
17 #include "util/string-processor.h"
18 #include "view/display-messages.h"
19 #include "view/display-player.h" // 暫定。後で消す.
20 #include "world/world.h"
21
22 /*!
23  * @brief 画面を再描画するコマンドのメインルーチン
24  * Hack -- redraw the screen
25  * @param creature_ptr プレーヤーへの参照ポインタ
26  * @return なし
27  * @details
28  * <pre>
29  * This command performs various low level updates, clears all the "extra"
30  * windows, does a total redraw of the main window, and requests all of the
31  * interesting updates and redraws that I can think of.
32  *
33  * This command is also used to "instantiate" the results of the user
34  * selecting various things, such as graphics mode, so it must call
35  * the "TERM_XTRA_REACT" hook before redrawing the windows.
36  * </pre>
37  */
38 void do_cmd_redraw(player_type *creature_ptr)
39 {
40         term_xtra(TERM_XTRA_REACT, 0);
41
42         creature_ptr->update |= (PU_COMBINE | PU_REORDER);
43         creature_ptr->update |= (PU_TORCH);
44         creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
45         creature_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
46         creature_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
47         creature_ptr->update |= (PU_MONSTERS);
48
49         creature_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
50
51         creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
52         creature_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
53
54         update_playtime();
55         handle_stuff(creature_ptr);
56         if (creature_ptr->prace == RACE_ANDROID) calc_android_exp(creature_ptr);
57
58         term_type *old = Term;
59         for (int j = 0; j < 8; j++)
60         {
61                 if (!angband_term[j]) continue;
62
63                 term_activate(angband_term[j]);
64                 term_redraw();
65                 term_fresh();
66                 term_activate(old);
67         }
68 }
69
70
71 /*!
72  * @brief プレイヤーのステータス表示
73  * @return なし
74  */
75 void do_cmd_player_status(player_type *creature_ptr)
76 {
77         int mode = 0;
78         char tmp[160];
79         screen_save();
80         while (TRUE)
81         {
82                 update_playtime();
83                 display_player(creature_ptr, mode);
84
85                 if (mode == 4)
86                 {
87                         mode = 0;
88                         display_player(creature_ptr, mode);
89                 }
90
91                 term_putstr(2, 23, -1, TERM_WHITE,
92                         _("['c'で名前変更, 'f'でファイルへ書出, 'h'でモード変更, ESCで終了]", "['c' to change name, 'f' to file, 'h' to change mode, or ESC]"));
93                 char c = inkey();
94                 if (c == ESCAPE) break;
95
96                 if (c == 'c')
97                 {
98                         get_name(creature_ptr);
99                         process_player_name(creature_ptr, FALSE);
100                 }
101                 else if (c == 'f')
102                 {
103                         sprintf(tmp, "%s.txt", creature_ptr->base_name);
104                         if (get_string(_("ファイル名: ", "File name: "), tmp, 80))
105                         {
106                                 if (tmp[0] && (tmp[0] != ' '))
107                                 {
108                                         file_character(creature_ptr, tmp, update_playtime, display_player);
109                                 }
110                         }
111                 }
112                 else if (c == 'h')
113                 {
114                         mode++;
115                 }
116                 else
117                 {
118                         bell();
119                 }
120
121                 msg_erase();
122         }
123
124         screen_load();
125         creature_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
126         handle_stuff(creature_ptr);
127 }
128
129
130 /*!
131  * @brief 最近表示されたメッセージを再表示するコマンドのメインルーチン
132  * Recall the most recent message
133  * @return なし
134  */
135 void do_cmd_message_one(void)
136 {
137         prt(format("> %s", message_str(0)), 0, 0);
138 }
139
140
141 /*!
142  * @brief メッセージのログを表示するコマンドのメインルーチン
143  * Recall the most recent message
144  * @return なし
145  * @details
146  * <pre>
147  * Show previous messages to the user   -BEN-
148  *
149  * The screen format uses line 0 and 23 for headers and prompts,
150  * skips line 1 and 22, and uses line 2 thru 21 for old messages.
151  *
152  * This command shows you which commands you are viewing, and allows
153  * you to "search" for strings in the recall.
154  *
155  * Note that messages may be longer than 80 characters, but they are
156  * displayed using "infinite" length, with a special sub-command to
157  * "slide" the virtual display to the left or right.
158  *
159  * Attempt to only hilite the matching portions of the string.
160  * </pre>
161  */
162 void do_cmd_messages(int num_now)
163 {
164         char shower_str[81];
165         char finder_str[81];
166         char back_str[81];
167         concptr shower = NULL;
168         int wid, hgt;
169         term_get_size(&wid, &hgt);
170         int num_lines = hgt - 4;
171         strcpy(finder_str, "");
172         strcpy(shower_str, "");
173         int n = message_num();
174         int i = 0;
175         screen_save();
176         term_clear();
177         while (TRUE)
178         {
179                 int j;
180                 int skey;
181                 for (j = 0; (j < num_lines) && (i + j < n); j++)
182                 {
183                         concptr msg = message_str(i + j);
184                         c_prt((i + j < num_now ? TERM_WHITE : TERM_SLATE), msg, num_lines + 1 - j, 0);
185                         if (!shower || !shower[0]) continue;
186
187                         concptr str = msg;
188                         while ((str = angband_strstr(str, shower)) != NULL)
189                         {
190                                 int len = strlen(shower);
191                                 term_putstr(str - msg, num_lines + 1 - j, len, TERM_YELLOW, shower);
192                                 str += len;
193                         }
194                 }
195
196                 for (; j < num_lines; j++)
197                         term_erase(0, num_lines + 1 - j, 255);
198
199                 prt(format(_("以前のメッセージ %d-%d 全部で(%d)", "Message Recall (%d-%d of %d)"),
200                         i, i + j - 1, n), 0, 0);
201                 prt(_("[ 'p' で更に古いもの, 'n' で更に新しいもの, '/' で検索, ESC で中断 ]",
202                         "[Press 'p' for older, 'n' for newer, ..., or ESCAPE]"), hgt - 1, 0);
203                 skey = inkey_special(TRUE);
204                 if (skey == ESCAPE) break;
205
206                 j = i;
207                 switch (skey)
208                 {
209                 case '=':
210                         prt(_("強調: ", "Show: "), hgt - 1, 0);
211                         strcpy(back_str, shower_str);
212                         if (askfor(shower_str, 80))
213                                 shower = shower_str[0] ? shower_str : NULL;
214                         else
215                                 strcpy(shower_str, back_str);
216
217                         continue;
218                 case '/':
219                 case KTRL('s'):
220                 {
221                         prt(_("検索: ", "Find: "), hgt - 1, 0);
222                         strcpy(back_str, finder_str);
223                         if (!askfor(finder_str, 80))
224                         {
225                                 strcpy(finder_str, back_str);
226                                 continue;
227                         }
228                         else if (!finder_str[0])
229                         {
230                                 shower = NULL;
231                                 continue;
232                         }
233
234                         shower = finder_str;
235                         for (int z = i + 1; z < n; z++)
236                         {
237                                 concptr msg = message_str(z);
238                                 if (angband_strstr(msg, finder_str))
239                                 {
240                                         i = z;
241                                         break;
242                                 }
243                         }
244                 }
245
246                 break;
247
248                 case SKEY_TOP:
249                         i = n - num_lines;
250                         break;
251                 case SKEY_BOTTOM:
252                         i = 0;
253                         break;
254                 case '8':
255                 case SKEY_UP:
256                 case '\n':
257                 case '\r':
258                         i = MIN(i + 1, n - num_lines);
259                         break;
260                 case '+':
261                         i = MIN(i + 10, n - num_lines);
262                         break;
263                 case 'p':
264                 case KTRL('P'):
265                 case ' ':
266                 case SKEY_PGUP:
267                         i = MIN(i + num_lines, n - num_lines);
268                         break;
269                 case 'n':
270                 case KTRL('N'):
271                 case SKEY_PGDOWN:
272                         i = MAX(0, i - num_lines);
273                         break;
274                 case '-':
275                         i = MAX(0, i - 10);
276                         break;
277                 case '2':
278                 case SKEY_DOWN:
279                         i = MAX(0, i - 1);
280                         break;
281                 }
282
283                 if (i == j) bell();
284         }
285
286         screen_load();
287 }