OSDN Git Service

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