OSDN Git Service

[Refactor] #40457 Moved choosable_realm, realm_choices1[] and realm_choices2[] from...
[hengband/hengband.git] / src / cmd-io / cmd-dump.c
1 /*!
2  * @brief プレイヤーのインターフェイスに関するコマンドの実装 / Interface commands
3  * @date 2014/01/02
4  * @author
5  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.  Other copyrights may also apply.
9  * 2020 Hourier Rearranged
10  */
11
12 #include "cmd-io/cmd-dump.h"
13 #include "cmd-io/feeling-table.h"
14 #include "core/asking-player.h"
15 #include "dungeon/quest.h"
16 #include "floor/floor-town.h"
17 #include "floor/floor.h"
18 #include "io-dump/dump-remover.h"
19 #include "io-dump/dump-util.h"
20 #include "io/chuukei.h"
21 #include "io/files-util.h"
22 #include "io/input-key-acceptor.h"
23 #include "io/interpret-pref-file.h"
24 #include "io/read-pref-file.h"
25 #include "locale/english.h"
26 #include "main/sound-of-music.h"
27 #include "mutation/mutation-flag-types.h"
28 #include "mutation/mutation.h"
29 #include "player/player-personalities-types.h"
30 #include "system/angband-version.h"
31 #include "term/gameterm.h"
32 #include "term/screen-processor.h"
33 #include "term/term-color-types.h"
34 #include "util/angband-files.h"
35 #include "util/int-char-converter.h"
36 #include "view/display-messages.h"
37 #include "view/display-player.h" // 暫定。後で消す.
38 #include "world/world.h"
39
40 /*!
41  * @brief 画面を再描画するコマンドのメインルーチン
42  * Hack -- redraw the screen
43  * @param creature_ptr プレーヤーへの参照ポインタ
44  * @return なし
45  * @details
46  * Allow absolute file names?
47  */
48 void do_cmd_pref(player_type *creature_ptr)
49 {
50         char buf[80];
51         strcpy(buf, "");
52         if (!get_string(_("設定変更コマンド: ", "Pref: "), buf, 80)) return;
53
54         (void)interpret_pref_file(creature_ptr, buf);
55 }
56
57
58 /*
59  * Interact with "colors"
60  */
61 void do_cmd_colors(player_type *creature_ptr, void(*process_autopick_file_command)(char*))
62 {
63         int i;
64         char tmp[160];
65         char buf[1024];
66         FILE *auto_dump_stream;
67         screen_save();
68         while (TRUE)
69         {
70                 Term_clear();
71                 prt(_("[ カラーの設定 ]", "Interact with Colors"), 2, 0);
72                 prt(_("(1) ユーザー設定ファイルのロード", "(1) Load a user pref file"), 4, 5);
73                 prt(_("(2) カラーの設定をファイルに書き出す", "(2) Dump colors"), 5, 5);
74                 prt(_("(3) カラーの設定を変更する", "(3) Modify colors"), 6, 5);
75                 prt(_("コマンド: ", "Command: "), 8, 0);
76                 i = inkey();
77                 if (i == ESCAPE) break;
78
79                 if (i == '1')
80                 {
81                         prt(_("コマンド: ユーザー設定ファイルをロードします", "Command: Load a user pref file"), 8, 0);
82                         prt(_("ファイル: ", "File: "), 10, 0);
83                         sprintf(tmp, "%s.prf", creature_ptr->base_name);
84                         if (!askfor(tmp, 70)) continue;
85
86                         (void)process_pref_file(creature_ptr, tmp, process_autopick_file_command);
87                         Term_xtra(TERM_XTRA_REACT, 0);
88                         Term_redraw();
89                 }
90                 else if (i == '2')
91                 {
92                         static concptr mark = "Colors";
93                         prt(_("コマンド: カラーの設定をファイルに書き出します", "Command: Dump colors"), 8, 0);
94                         prt(_("ファイル: ", "File: "), 10, 0);
95                         sprintf(tmp, "%s.prf", creature_ptr->base_name);
96                         if (!askfor(tmp, 70)) continue;
97
98                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
99                         if (!open_auto_dump(&auto_dump_stream, buf, mark)) continue;
100
101                         auto_dump_printf(auto_dump_stream, _("\n# カラーの設定\n\n", "\n# Color redefinitions\n\n"));
102                         for (i = 0; i < 256; i++)
103                         {
104                                 int kv = angband_color_table[i][0];
105                                 int rv = angband_color_table[i][1];
106                                 int gv = angband_color_table[i][2];
107                                 int bv = angband_color_table[i][3];
108
109                                 concptr name = _("未知", "unknown");
110                                 if (!kv && !rv && !gv && !bv) continue;
111
112                                 if (i < 16) name = color_names[i];
113
114                                 auto_dump_printf(auto_dump_stream, _("# カラー '%s'\n", "# Color '%s'\n"), name);
115                                 auto_dump_printf(auto_dump_stream, "V:%d:0x%02X:0x%02X:0x%02X:0x%02X\n\n",
116                                         i, kv, rv, gv, bv);
117                         }
118
119                         close_auto_dump(&auto_dump_stream, mark);
120                         msg_print(_("カラーの設定をファイルに書き出しました。", "Dumped color redefinitions."));
121                 }
122                 else if (i == '3')
123                 {
124                         static byte a = 0;
125                         prt(_("コマンド: カラーの設定を変更します", "Command: Modify colors"), 8, 0);
126                         while (TRUE)
127                         {
128                                 concptr name;
129                                 clear_from(10);
130                                 for (byte j = 0; j < 16; j++)
131                                 {
132                                         Term_putstr(j * 4, 20, -1, a, "###");
133                                         Term_putstr(j * 4, 22, -1, j, format("%3d", j));
134                                 }
135
136                                 name = ((a < 16) ? color_names[a] : _("未定義", "undefined"));
137                                 Term_putstr(5, 10, -1, TERM_WHITE,
138                                         format(_("カラー = %d, 名前 = %s", "Color = %d, Name = %s"), a, name));
139                                 Term_putstr(5, 12, -1, TERM_WHITE,
140                                         format("K = 0x%02x / R,G,B = 0x%02x,0x%02x,0x%02x",
141                                                 angband_color_table[a][0],
142                                                 angband_color_table[a][1],
143                                                 angband_color_table[a][2],
144                                                 angband_color_table[a][3]));
145                                 Term_putstr(0, 14, -1, TERM_WHITE,
146                                         _("コマンド (n/N/k/K/r/R/g/G/b/B): ", "Command (n/N/k/K/r/R/g/G/b/B): "));
147                                 i = inkey();
148                                 if (i == ESCAPE) break;
149
150                                 if (i == 'n') a = (byte)(a + 1);
151                                 if (i == 'N') a = (byte)(a - 1);
152                                 if (i == 'k') angband_color_table[a][0] = (byte)(angband_color_table[a][0] + 1);
153                                 if (i == 'K') angband_color_table[a][0] = (byte)(angband_color_table[a][0] - 1);
154                                 if (i == 'r') angband_color_table[a][1] = (byte)(angband_color_table[a][1] + 1);
155                                 if (i == 'R') angband_color_table[a][1] = (byte)(angband_color_table[a][1] - 1);
156                                 if (i == 'g') angband_color_table[a][2] = (byte)(angband_color_table[a][2] + 1);
157                                 if (i == 'G') angband_color_table[a][2] = (byte)(angband_color_table[a][2] - 1);
158                                 if (i == 'b') angband_color_table[a][3] = (byte)(angband_color_table[a][3] + 1);
159                                 if (i == 'B') angband_color_table[a][3] = (byte)(angband_color_table[a][3] - 1);
160
161                                 Term_xtra(TERM_XTRA_REACT, 0);
162                                 Term_redraw();
163                         }
164                 }
165                 else
166                 {
167                         bell();
168                 }
169
170                 msg_erase();
171         }
172
173         screen_load();
174 }
175
176
177 /*
178  * Note something in the message recall
179  */
180 void do_cmd_note(void)
181 {
182         char buf[80];
183         strcpy(buf, "");
184         if (!get_string(_("メモ: ", "Note: "), buf, 60)) return;
185         if (!buf[0] || (buf[0] == ' ')) return;
186
187         msg_format(_("メモ: %s", "Note: %s"), buf);
188 }
189
190
191 /*
192  * Mention the current version
193  */
194 void do_cmd_version(void)
195 {
196 #if FAKE_VER_EXTRA > 0
197         msg_format(_("変愚蛮怒(Hengband) %d.%d.%d.%d", "You are playing Hengband %d.%d.%d.%d."),
198                 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH, FAKE_VER_EXTRA);
199 #else
200         msg_format(_("変愚蛮怒(Hengband) %d.%d.%d", "You are playing Hengband %d.%d.%d."),
201                 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
202 #endif
203 }
204
205
206 /*
207  * Note that "feeling" is set to zero unless some time has passed.
208  * Note that this is done when the level is GENERATED, not entered.
209  */
210 void do_cmd_feeling(player_type *creature_ptr)
211 {
212         if (creature_ptr->wild_mode) return;
213
214         if (creature_ptr->current_floor_ptr->inside_quest && !random_quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level))
215         {
216                 msg_print(_("典型的なクエストのダンジョンのようだ。", "Looks like a typical quest level."));
217                 return;
218         }
219
220         if (creature_ptr->town_num && !creature_ptr->current_floor_ptr->dun_level)
221         {
222                 if (!strcmp(town_info[creature_ptr->town_num].name, _("荒野", "wilderness")))
223                 {
224                         msg_print(_("何かありそうな荒野のようだ。", "Looks like a strange wilderness."));
225                         return;
226                 }
227
228                 msg_print(_("典型的な町のようだ。", "Looks like a typical town."));
229                 return;
230         }
231
232         if (!creature_ptr->current_floor_ptr->dun_level)
233         {
234                 msg_print(_("典型的な荒野のようだ。", "Looks like a typical wilderness."));
235                 return;
236         }
237
238         if (creature_ptr->muta3 & MUT3_GOOD_LUCK)
239                 msg_print(do_cmd_feeling_text_lucky[creature_ptr->feeling]);
240         else if (is_echizen(creature_ptr))
241                 msg_print(do_cmd_feeling_text_combat[creature_ptr->feeling]);
242         else
243                 msg_print(do_cmd_feeling_text[creature_ptr->feeling]);
244 }
245
246
247 /*
248  * Display the time and date
249  * @param creature_ptr プレーヤーへの参照ポインタ
250  * @return なし
251  */
252 void do_cmd_time(player_type *creature_ptr)
253 {
254         int day, hour, min;
255         extract_day_hour_min(creature_ptr, &day, &hour, &min);
256
257         char desc[1024];
258         strcpy(desc, _("変な時刻だ。", "It is a strange time."));
259
260         char day_buf[10];
261         if (day < MAX_DAYS) sprintf(day_buf, "%d", day);
262         else strcpy(day_buf, "*****");
263
264         msg_format(_("%s日目, 時刻は%d:%02d %sです。", "This is day %s. The time is %d:%02d %s."),
265                 day_buf, (hour % 12 == 0) ? 12 : (hour % 12), min, (hour < 12) ? "AM" : "PM");
266
267         char buf[1024];
268         if (!randint0(10) || creature_ptr->image)
269         {
270                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("timefun_j.txt", "timefun.txt"));
271         }
272         else
273         {
274                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("timenorm_j.txt", "timenorm.txt"));
275         }
276
277         FILE *fff;
278         fff = angband_fopen(buf, "rt");
279
280         if (!fff) return;
281
282         int full = hour * 100 + min;
283         int start = 9999;
284         int end = -9999;
285         int num = 0;
286         while (!angband_fgets(fff, buf, sizeof(buf)))
287         {
288                 if (!buf[0] || (buf[0] == '#')) continue;
289                 if (buf[1] != ':') continue;
290
291                 if (buf[0] == 'S')
292                 {
293                         start = atoi(buf + 2);
294                         end = start + 59;
295                         continue;
296                 }
297
298                 if (buf[0] == 'E')
299                 {
300                         end = atoi(buf + 2);
301                         continue;
302                 }
303
304                 if ((start > full) || (full > end)) continue;
305
306                 if (buf[0] == 'D')
307                 {
308                         num++;
309                         if (!randint0(num)) strcpy(desc, buf + 2);
310
311                         continue;
312                 }
313         }
314
315         msg_print(desc);
316         angband_fclose(fff);
317 }