3 * @brief プレイヤーのインターフェイスに関するコマンドの実装 / Interface commands
7 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
14 * A set of functions to maintain automatic dumps of various kinds.
15 * The dump commands of original Angband simply add new lines to
16 * existing files; these files will become bigger and bigger unless
17 * an user deletes some or all of these files by hand at some
19 * These three functions automatically delete old dumped lines
20 * before adding new ones. Since there are various kinds of automatic
21 * dumps in a single file, we add a header and a footer with a type
22 * name for every automatic dump, and kill old lines only when the
23 * lines have the correct type of header and footer.
24 * We need to be quite paranoid about correctness; the user might
25 * (mistakenly) edit the file by hand, and see all their work come
26 * to nothing on the next auto dump otherwise. The current code only
27 * detects changes by noting inconsistencies between the actual number
28 * of lines and the number written in the footer. Note that this will
29 * not catch single-line edits.
34 #include "cmd/cmd-draw.h"
35 #include "cmd/cmd-dump.h"
36 #include "cmd/cmd-inventory.h"
37 #include "cmd/cmd-visuals.h"
38 #include "cmd/dump-util.h"
40 #include "core.h" // 暫定。後で消す.
41 #include "io/read-pref-file.h"
42 #include "io/interpret-pref-file.h"
44 #include "knowledge/knowledge-autopick.h"
45 #include "knowledge/knowledge-experiences.h"
46 #include "knowledge/knowledge-features.h"
47 #include "knowledge/knowledge-items.h"
48 #include "knowledge/knowledge-monsters.h"
49 #include "knowledge/knowledge-quests.h"
50 #include "knowledge/knowledge-self.h"
51 #include "knowledge/knowledge-uniques.h"
54 #include "view/display-player.h" // 暫定。後で消す.
55 #include "player-personality.h"
58 #include "market/store.h"
60 #include "floor-town.h"
61 #include "cmd/feeling-table.h"
62 #include "market/store-util.h"
68 * @brief prefファイルを選択して処理する /
69 * Ask for a "user pref line" and process it
70 * @brief prf出力内容を消去する /
71 * Remove old lines automatically generated before.
72 * @param orig_file 消去を行うファイル名
74 static void remove_auto_dump(concptr orig_file, concptr auto_dump_mark)
77 bool between_mark = FALSE;
80 long header_location = 0;
81 char header_mark_str[80];
82 char footer_mark_str[80];
84 sprintf(header_mark_str, auto_dump_header, auto_dump_mark);
85 sprintf(footer_mark_str, auto_dump_footer, auto_dump_mark);
86 size_t mark_len = strlen(footer_mark_str);
89 orig_fff = my_fopen(orig_file, "r");
90 if (!orig_fff) return;
93 char tmp_file[FILE_NAME_SIZE];
94 if (!open_temporary_file(&tmp_fff, tmp_file)) return;
98 if (my_fgets(orig_fff, buf, sizeof(buf)))
102 fseek(orig_fff, header_location, SEEK_SET);
103 between_mark = FALSE;
114 if (!strcmp(buf, header_mark_str))
116 header_location = ftell(orig_fff);
123 fprintf(tmp_fff, "%s\n", buf);
129 if (!strncmp(buf, footer_mark_str, mark_len))
132 if (!sscanf(buf + mark_len, " (%d)", &tmp)
135 fseek(orig_fff, header_location, SEEK_SET);
138 between_mark = FALSE;
150 tmp_fff = my_fopen(tmp_file, "r");
151 orig_fff = my_fopen(orig_file, "w");
152 while (!my_fgets(tmp_fff, buf, sizeof(buf)))
153 fprintf(orig_fff, "%s\n", buf);
166 * @brief Return suffix of ordinal number
168 * @return pointer of suffix string.
170 concptr get_ordinal_number_suffix(int num)
172 num = ABS(num) % 100;
176 return (num == 11) ? "th" : "st";
178 return (num == 12) ? "th" : "nd";
180 return (num == 13) ? "th" : "rd";
188 * @brief 画面を再描画するコマンドのメインルーチン
189 * Hack -- redraw the screen
190 * @param creature_ptr プレーヤーへの参照ポインタ
193 * Allow absolute file names?
195 void do_cmd_pref(player_type *creature_ptr)
199 if (!get_string(_("設定変更コマンド: ", "Pref: "), buf, 80)) return;
201 (void)interpret_pref_file(creature_ptr, buf);
206 * Interact with "colors"
208 void do_cmd_colors(player_type *creature_ptr)
213 FILE *auto_dump_stream;
214 FILE_TYPE(FILE_TYPE_TEXT);
219 prt(_("[ カラーの設定 ]", "Interact with Colors"), 2, 0);
220 prt(_("(1) ユーザー設定ファイルのロード", "(1) Load a user pref file"), 4, 5);
221 prt(_("(2) カラーの設定をファイルに書き出す", "(2) Dump colors"), 5, 5);
222 prt(_("(3) カラーの設定を変更する", "(3) Modify colors"), 6, 5);
223 prt(_("コマンド: ", "Command: "), 8, 0);
225 if (i == ESCAPE) break;
229 prt(_("コマンド: ユーザー設定ファイルをロードします", "Command: Load a user pref file"), 8, 0);
230 prt(_("ファイル: ", "File: "), 10, 0);
231 sprintf(tmp, "%s.prf", creature_ptr->base_name);
232 if (!askfor(tmp, 70)) continue;
234 (void)process_pref_file(creature_ptr, tmp);
235 Term_xtra(TERM_XTRA_REACT, 0);
240 static concptr mark = "Colors";
241 prt(_("コマンド: カラーの設定をファイルに書き出します", "Command: Dump colors"), 8, 0);
242 prt(_("ファイル: ", "File: "), 10, 0);
243 sprintf(tmp, "%s.prf", creature_ptr->base_name);
244 if (!askfor(tmp, 70)) continue;
246 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
247 if (!open_auto_dump(&auto_dump_stream, buf, mark)) continue;
249 auto_dump_printf(auto_dump_stream, _("\n# カラーの設定\n\n", "\n# Color redefinitions\n\n"));
250 for (i = 0; i < 256; i++)
252 int kv = angband_color_table[i][0];
253 int rv = angband_color_table[i][1];
254 int gv = angband_color_table[i][2];
255 int bv = angband_color_table[i][3];
257 concptr name = _("未知", "unknown");
258 if (!kv && !rv && !gv && !bv) continue;
260 if (i < 16) name = color_names[i];
262 auto_dump_printf(auto_dump_stream, _("# カラー '%s'\n", "# Color '%s'\n"), name);
263 auto_dump_printf(auto_dump_stream, "V:%d:0x%02X:0x%02X:0x%02X:0x%02X\n\n",
267 close_auto_dump(&auto_dump_stream, mark);
268 msg_print(_("カラーの設定をファイルに書き出しました。", "Dumped color redefinitions."));
273 prt(_("コマンド: カラーの設定を変更します", "Command: Modify colors"), 8, 0);
278 for (byte j = 0; j < 16; j++)
280 Term_putstr(j * 4, 20, -1, a, "###");
281 Term_putstr(j * 4, 22, -1, j, format("%3d", j));
284 name = ((a < 16) ? color_names[a] : _("未定義", "undefined"));
285 Term_putstr(5, 10, -1, TERM_WHITE,
286 format(_("カラー = %d, 名前 = %s", "Color = %d, Name = %s"), a, name));
287 Term_putstr(5, 12, -1, TERM_WHITE,
288 format("K = 0x%02x / R,G,B = 0x%02x,0x%02x,0x%02x",
289 angband_color_table[a][0],
290 angband_color_table[a][1],
291 angband_color_table[a][2],
292 angband_color_table[a][3]));
293 Term_putstr(0, 14, -1, TERM_WHITE,
294 _("コマンド (n/N/k/K/r/R/g/G/b/B): ", "Command (n/N/k/K/r/R/g/G/b/B): "));
296 if (i == ESCAPE) break;
298 if (i == 'n') a = (byte)(a + 1);
299 if (i == 'N') a = (byte)(a - 1);
300 if (i == 'k') angband_color_table[a][0] = (byte)(angband_color_table[a][0] + 1);
301 if (i == 'K') angband_color_table[a][0] = (byte)(angband_color_table[a][0] - 1);
302 if (i == 'r') angband_color_table[a][1] = (byte)(angband_color_table[a][1] + 1);
303 if (i == 'R') angband_color_table[a][1] = (byte)(angband_color_table[a][1] - 1);
304 if (i == 'g') angband_color_table[a][2] = (byte)(angband_color_table[a][2] + 1);
305 if (i == 'G') angband_color_table[a][2] = (byte)(angband_color_table[a][2] - 1);
306 if (i == 'b') angband_color_table[a][3] = (byte)(angband_color_table[a][3] + 1);
307 if (i == 'B') angband_color_table[a][3] = (byte)(angband_color_table[a][3] - 1);
309 Term_xtra(TERM_XTRA_REACT, 0);
326 * Note something in the message recall
328 void do_cmd_note(void)
332 if (!get_string(_("メモ: ", "Note: "), buf, 60)) return;
333 if (!buf[0] || (buf[0] == ' ')) return;
335 msg_format(_("メモ: %s", "Note: %s"), buf);
340 * Mention the current version
342 void do_cmd_version(void)
344 #if FAKE_VER_EXTRA > 0
345 msg_format(_("変愚蛮怒(Hengband) %d.%d.%d.%d", "You are playing Hengband %d.%d.%d.%d."),
346 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH, FAKE_VER_EXTRA);
348 msg_format(_("変愚蛮怒(Hengband) %d.%d.%d", "You are playing Hengband %d.%d.%d."),
349 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
355 * Note that "feeling" is set to zero unless some time has passed.
356 * Note that this is done when the level is GENERATED, not entered.
358 void do_cmd_feeling(player_type *creature_ptr)
360 if (creature_ptr->wild_mode) return;
362 if (creature_ptr->current_floor_ptr->inside_quest && !random_quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level))
364 msg_print(_("典型的なクエストのダンジョンのようだ。", "Looks like a typical quest level."));
368 if (creature_ptr->town_num && !creature_ptr->current_floor_ptr->dun_level)
370 if (!strcmp(town_info[creature_ptr->town_num].name, _("荒野", "wilderness")))
372 msg_print(_("何かありそうな荒野のようだ。", "Looks like a strange wilderness."));
376 msg_print(_("典型的な町のようだ。", "Looks like a typical town."));
380 if (!creature_ptr->current_floor_ptr->dun_level)
382 msg_print(_("典型的な荒野のようだ。", "Looks like a typical wilderness."));
386 if (creature_ptr->muta3 & MUT3_GOOD_LUCK)
387 msg_print(do_cmd_feeling_text_lucky[creature_ptr->feeling]);
388 else if (IS_ECHIZEN(creature_ptr))
389 msg_print(do_cmd_feeling_text_combat[creature_ptr->feeling]);
391 msg_print(do_cmd_feeling_text[creature_ptr->feeling]);
396 * Interact with "knowledge"
398 void do_cmd_knowledge(player_type *creature_ptr)
401 bool need_redraw = FALSE;
402 FILE_TYPE(FILE_TYPE_TEXT);
407 prt(format(_("%d/2 ページ", "page %d/2"), (p + 1)), 2, 65);
408 prt(_("現在の知識を確認する", "Display current knowledge"), 3, 0);
411 prt(_("(1) 既知の伝説のアイテム の一覧", "(1) Display known artifacts"), 6, 5);
412 prt(_("(2) 既知のアイテム の一覧", "(2) Display known objects"), 7, 5);
413 prt(_("(3) 既知の生きているユニーク・モンスター の一覧", "(3) Display remaining uniques"), 8, 5);
414 prt(_("(4) 既知のモンスター の一覧", "(4) Display known monster"), 9, 5);
415 prt(_("(5) 倒した敵の数 の一覧", "(5) Display kill count"), 10, 5);
416 if (!vanilla_town) prt(_("(6) 賞金首 の一覧", "(6) Display wanted monsters"), 11, 5);
417 prt(_("(7) 現在のペット の一覧", "(7) Display current pets"), 12, 5);
418 prt(_("(8) 我が家のアイテム の一覧", "(8) Display home inventory"), 13, 5);
419 prt(_("(9) *鑑定*済み装備の耐性 の一覧", "(9) Display *identified* equip."), 14, 5);
420 prt(_("(0) 地形の表示文字/タイル の一覧", "(0) Display terrain symbols."), 15, 5);
424 prt(_("(a) 自分に関する情報 の一覧", "(a) Display about yourself"), 6, 5);
425 prt(_("(b) 突然変異 の一覧", "(b) Display mutations"), 7, 5);
426 prt(_("(c) 武器の経験値 の一覧", "(c) Display weapon proficiency"), 8, 5);
427 prt(_("(d) 魔法の経験値 の一覧", "(d) Display spell proficiency"), 9, 5);
428 prt(_("(e) 技能の経験値 の一覧", "(e) Display misc. proficiency"), 10, 5);
429 prt(_("(f) プレイヤーの徳 の一覧", "(f) Display virtues"), 11, 5);
430 prt(_("(g) 入ったダンジョン の一覧", "(g) Display dungeons"), 12, 5);
431 prt(_("(h) 実行中のクエスト の一覧", "(h) Display current quests"), 13, 5);
432 prt(_("(i) 現在の自動拾い/破壊設定 の一覧", "(i) Display auto pick/destroy"), 14, 5);
435 prt(_("-続く-", "-more-"), 17, 8);
436 prt(_("ESC) 抜ける", "ESC) Exit menu"), 21, 1);
437 prt(_("SPACE) 次ページ", "SPACE) Next page"), 21, 30);
438 prt(_("コマンド:", "Command: "), 20, 0);
441 if (i == ESCAPE) break;
444 case ' ': /* Page change */
448 case '1': /* Artifacts */
449 do_cmd_knowledge_artifacts(creature_ptr);
451 case '2': /* Objects */
452 do_cmd_knowledge_objects(creature_ptr, &need_redraw, FALSE, -1);
454 case '3': /* Uniques */
455 do_cmd_knowledge_uniques(creature_ptr);
457 case '4': /* Monsters */
458 do_cmd_knowledge_monsters(creature_ptr, &need_redraw, FALSE, -1);
460 case '5': /* Kill count */
461 do_cmd_knowledge_kill_count(creature_ptr);
463 case '6': /* wanted */
464 if (!vanilla_town) do_cmd_knowledge_bounty(creature_ptr);
467 do_cmd_knowledge_pets(creature_ptr);
470 do_cmd_knowledge_home(creature_ptr);
472 case '9': /* Resist list */
473 do_cmd_knowledge_inventory(creature_ptr);
475 case '0': /* Feature list */
477 IDX lighting_level = F_LIT_STANDARD;
478 do_cmd_knowledge_features(&need_redraw, FALSE, -1, &lighting_level);
482 case 'a': /* Max stat */
483 do_cmd_knowledge_stat(creature_ptr);
485 case 'b': /* Mutations */
486 do_cmd_knowledge_mutations(creature_ptr);
488 case 'c': /* weapon-exp */
489 do_cmd_knowledge_weapon_exp(creature_ptr);
491 case 'd': /* spell-exp */
492 do_cmd_knowledge_spell_exp(creature_ptr);
494 case 'e': /* skill-exp */
495 do_cmd_knowledge_skill_exp(creature_ptr);
497 case 'f': /* Virtues */
498 do_cmd_knowledge_virtues(creature_ptr);
500 case 'g': /* Dungeon */
501 do_cmd_knowledge_dungeon(creature_ptr);
503 case 'h': /* Quests */
504 do_cmd_knowledge_quests(creature_ptr);
506 case 'i': /* Autopick */
507 do_cmd_knowledge_autopick(creature_ptr);
509 default: /* Unknown option */
517 if (need_redraw) do_cmd_redraw(creature_ptr);
522 * Check on the status of an active quest
523 * @param creature_ptr プレーヤーへの参照ポインタ
526 void do_cmd_checkquest(player_type *creature_ptr)
528 FILE_TYPE(FILE_TYPE_TEXT);
530 do_cmd_knowledge_quests(creature_ptr);
536 * Display the time and date
537 * @param creature_ptr プレーヤーへの参照ポインタ
540 void do_cmd_time(player_type *creature_ptr)
543 extract_day_hour_min(creature_ptr, &day, &hour, &min);
546 strcpy(desc, _("変な時刻だ。", "It is a strange time."));
549 if (day < MAX_DAYS) sprintf(day_buf, "%d", day);
550 else strcpy(day_buf, "*****");
552 msg_format(_("%s日目, 時刻は%d:%02d %sです。", "This is day %s. The time is %d:%02d %s."),
553 day_buf, (hour % 12 == 0) ? 12 : (hour % 12), min, (hour < 12) ? "AM" : "PM");
556 if (!randint0(10) || creature_ptr->image)
558 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("timefun_j.txt", "timefun.txt"));
562 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("timenorm_j.txt", "timenorm.txt"));
566 fff = my_fopen(buf, "rt");
570 int full = hour * 100 + min;
574 while (!my_fgets(fff, buf, sizeof(buf)))
576 if (!buf[0] || (buf[0] == '#')) continue;
577 if (buf[1] != ':') continue;
581 start = atoi(buf + 2);
592 if ((start > full) || (full > end)) continue;
597 if (!randint0(num)) strcpy(desc, buf + 2);