1 #include "cmd-io/cmd-gameoption.h"
2 #include "autopick/autopick.h"
3 #include "cmd-io/cmd-autopick.h"
4 #include "cmd-io/cmd-dump.h"
5 #include "core/asking-player.h"
6 #include "core/player-redraw-types.h"
7 #include "core/show-file.h"
8 #include "core/window-redrawer.h"
9 #include "floor/geometry.h"
10 #include "game-option/game-play-options.h"
11 #include "game-option/keymap-directory-getter.h"
12 #include "game-option/option-flags.h"
13 #include "game-option/option-types-table.h"
14 #include "game-option/special-options.h"
15 #include "io/input-key-acceptor.h"
16 #include "io/write-diary.h"
17 #include "main/sound-of-music.h"
18 #include "system/game-option-types.h"
19 #include "system/player-type-definition.h"
20 #include "term/gameterm.h"
21 #include "term/screen-processor.h"
22 #include "term/term-color-types.h"
23 #include "util/bit-flags-calculator.h"
24 #include "util/int-char-converter.h"
25 #include "util/string-processor.h"
26 #include "view/display-messages.h"
27 #include "world/world.h"
37 static opts option_fields[OPT_NUM] = {
38 { '1', _(" キー入力 オプション", "Input Options"), 3 },
39 { '2', _(" マップ画面 オプション", "Map Screen Options"), 4 },
40 { '3', _(" テキスト表示 オプション", "Text Display Options"), 5 },
41 { '4', _(" ゲームプレイ オプション", "Game-Play Options"), 6 },
42 { '5', _(" 行動中止関係 オプション", "Disturbance Options"), 7 },
43 { '6', _(" 簡易自動破壊 オプション", "Easy Auto-Destroyer Options"), 8 },
44 { 'r', _(" プレイ記録 オプション", "Play record Options"), 9 },
46 { 'p', _("自動拾いエディタ", "Auto-picker/destroyer editor"), 11 },
47 { 'd', _(" 基本ウェイト量 ", "Base Delay Factor"), 12 },
48 { 'h', _("低ヒットポイント", "Hitpoint Warning"), 13 },
49 { 'm', _(" 低魔力色閾値 ", "Mana Color Threshold"), 14 },
50 { 'a', _(" 自動セーブ オプション", "Autosave Options"), 15 },
51 { 'w', _("ウインドウフラグ", "Window Flags"), 16 },
53 { 'b', _(" 初期 オプション (参照のみ)", "Birth Options (Browse Only)"), 18 },
54 { 'c', _(" 詐欺 オプション", "Cheat Options"), 19 },
58 * @brief セーブ頻度ターンの次の値を返す
59 * @param current 現在のセーブ頻度ターン値
62 static int16_t toggle_frequency(int16_t current)
89 * @brief 自動セーブオプションを変更するコマンドのメインルーチン
92 static void do_cmd_options_autosave(PlayerType *player_ptr, concptr info)
100 _("%s ( リターンで次へ, y/n でセット, F で頻度を入力, ESC で決定 ) ", "%s (RET to advance, y/n to set, 'F' for frequency, ESC to accept) "), info);
102 for (i = 0; i < n; i++) {
109 buf, "%-48s: %s (%s)", autosave_info[i].o_desc, (*autosave_info[i].o_var ? _("はい ", "yes") : _("いいえ", "no ")), autosave_info[i].o_text);
110 c_prt(a, buf, i + 2, 0);
113 prt(format(_("自動セーブの頻度: %d ターン毎", "Timed autosave frequency: every %d turns"), autosave_freq), 5, 0);
114 move_cursor(k + 2, 50);
139 (*autosave_info[k].o_var) = true;
147 (*autosave_info[k].o_var) = false;
154 autosave_freq = toggle_frequency(autosave_freq);
155 prt(format(_("自動セーブの頻度: %d ターン毎", "Timed autosave frequency: every %d turns"), autosave_freq), 5, 0);
160 (void)show_file(player_ptr, true, _("joption.txt#Autosave", "option.txt#Autosave"), nullptr, 0, 0);
174 * @brief 指定のサブウィンドウが指定のウィンドウフラグを持つか調べる
176 * @param y ウィンドウフラグ番号
177 * @return 持つならTRUE、持たないならFALSE
179 static bool has_window_flag(int x, int y)
181 auto flag = i2enum<window_redraw_type>(1UL << y);
182 return any_bits(window_flag[x], flag);
186 * @brief 指定のサブウィンドウに指定のウィンドウフラグをセットする
188 * @param y ウィンドウフラグ番号
192 static void set_window_flag(int x, int y)
194 auto flag = i2enum<window_redraw_type>(1UL << y);
195 if (any_bits(PW_ALL, flag)) {
196 set_bits(window_flag[x], flag);
201 * @brief 指定のウィンドウフラグをサブウィンドウからクリアする
202 * @param y ウィンドウフラグ番号
204 static void clear_window_flag(int x, int y)
208 auto flag = i2enum<window_redraw_type>(1UL << y);
209 for (int i = 0; i < 8; i++) {
210 reset_bits(window_flag[i], flag);
215 * @brief ウィンドウオプションを変更するコマンドのメインルーチン /
216 * Modify the "window" options
218 static void do_cmd_options_win(PlayerType *player_ptr)
225 uint32_t old_flag[8];
227 for (j = 0; j < 8; j++) {
228 old_flag[j] = window_flag[j];
233 prt(_("ウィンドウ・フラグ (<方向>で移動, 't'でON/OFF,'s'でON(他窓OFF), ESC)", "Window Flags (<dir>, <t>oggle, <s>et, ESC) "), 0, 0);
234 for (j = 0; j < 8; j++) {
236 concptr s = angband_term_name[j];
241 term_putstr(35 + j * 5 - strlen(s) / 2, 2 + j % 2, -1, a, s);
244 for (i = 0; i < 16; i++) {
246 concptr str = window_flag_desc[i];
252 str = _("(未使用)", "(Unused option)");
255 term_putstr(0, i + 5, -1, a, str);
256 for (j = 0; j < 8; j++) {
259 if ((i == y) && (j == x)) {
263 if (window_flag[j] & (1UL << i)) {
267 term_putch(35 + j * 5, i + 5, a, c);
271 bool has_flag = false;
272 term_gotoxy(35 + x * 5, y + 5);
281 has_flag = has_window_flag(x, y);
283 if (x > 0 && !has_flag) {
284 set_window_flag(x, y);
293 clear_window_flag(x, y);
294 set_window_flag(x, y);
297 (void)show_file(player_ptr, true, _("joption.txt#Window", "option.txt#Window"), nullptr, 0, 0);
301 d = get_keymap_dir(ch);
302 x = (x + ddx[d] + 8) % 8;
303 y = (y + ddy[d] + 16) % 16;
311 for (j = 0; j < 8; j++) {
312 term_type *old = game_term;
313 if (!angband_term[j]) {
317 if (window_flag[j] == old_flag[j]) {
321 term_activate(angband_term[j]);
329 * @brief チートオプションを変更するコマンドのメインルーチン
330 * Interact with some options for cheating
331 * @param info 表示メッセージ
333 static void do_cmd_options_cheat(PlayerType *player_ptr, concptr info)
337 const auto n = cheat_info.size();
340 sprintf(buf, _("%s ( リターンで次へ, y/n でセット, ESC で決定 )", "%s (RET to advance, y/n to set, ESC to accept) "), info);
344 /* 詐欺オプションをうっかりいじってしまう人がいるようなので注意 */
345 prt(" << 注意 >>", 11, 0);
346 prt(" 詐欺オプションを一度でも設定すると、スコア記録が残らなくなります!", 12, 0);
347 prt(" 後に解除してもダメですので、勝利者を目指す方はここのオプションはい", 13, 0);
348 prt(" じらないようにして下さい。", 14, 0);
350 for (auto i = 0U; i < n; i++) {
356 sprintf(buf, "%-48s: %s (%s)", cheat_info[i].o_desc, (*cheat_info[i].o_var ? _("はい ", "yes") : _("いいえ", "no ")), cheat_info[i].o_text);
357 c_prt(enum2i(a), buf, i + 2, 0);
360 move_cursor(k + 2, 50);
362 auto dir = get_keymap_dir(ch);
363 if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8)) {
383 if (!w_ptr->noscore) {
384 exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0,
385 _("詐欺オプションをONにして、スコアを残せなくなった。", "gave up sending score to use cheating options."));
388 w_ptr->noscore |= cheat_info[k].o_set * 256 + cheat_info[k].o_bit;
389 *cheat_info[k].o_var = true;
395 *cheat_info[k].o_var = false;
399 strnfmt(buf, sizeof(buf), _("joption.txt#%s", "option.txt#%s"), cheat_info[k].o_text);
400 (void)show_file(player_ptr, true, buf, nullptr, 0, 0);
411 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
413 void extract_option_vars(void)
415 for (int i = 0; option_info[i].o_desc; i++) {
416 int os = option_info[i].o_set;
417 int ob = option_info[i].o_bit;
418 if (option_info[i].o_var) {
419 if (option_flag[os] & (1UL << ob)) {
420 (*option_info[i].o_var) = true;
422 (*option_info[i].o_var) = false;
429 * @brief 標準オプションを変更するコマンドのメインルーチン /
430 * Set or unset various options.
433 * The user must use the "Ctrl-R" command to "adapt" to changes
434 * in any options which control "visual" aspects of the game.
437 void do_cmd_options(PlayerType *player_ptr)
445 if (!w_ptr->noscore && !allow_debug_opts) {
450 prt(_("[ オプションの設定 ]", "Game options"), 1, 0);
452 for (i = 0; i < n; i++) {
457 term_putstr(5, option_fields[i].row, -1, a, format("(%c) %s", toupper(option_fields[i].key), option_fields[i].name));
460 prt(_("<方向>で移動, Enterで決定, ESCでキャンセル, ?でヘルプ: ", "Move to <dir>, Select to Enter, Cancel to ESC, ? to help: "), 21, 0);
461 skey = inkey_special(true);
462 if (!(skey & SKEY_MASK)) {
472 if (angband_strchr("\n\r ", k)) {
473 k = option_fields[y].key;
477 for (i = 0; i < n; i++) {
478 if (tolower(k) == option_fields[i].key) {
492 if (skey == SKEY_UP) {
495 if (skey == SKEY_DOWN) {
498 y = (y + ddy[d] + n) % n;
510 do_cmd_options_aux(player_ptr, OPT_PAGE_INPUT, _("キー入力オプション", "Input Options"));
514 do_cmd_options_aux(player_ptr, OPT_PAGE_MAPSCREEN, _("マップ画面オプション", "Map Screen Options"));
518 do_cmd_options_aux(player_ptr, OPT_PAGE_TEXT, _("テキスト表示オプション", "Text Display Options"));
522 do_cmd_options_aux(player_ptr, OPT_PAGE_GAMEPLAY, _("ゲームプレイ・オプション", "Game-Play Options"));
526 do_cmd_options_aux(player_ptr, OPT_PAGE_DISTURBANCE, _("行動中止関係のオプション", "Disturbance Options"));
530 do_cmd_options_aux(player_ptr, OPT_PAGE_AUTODESTROY, _("簡易自動破壊オプション", "Easy Auto-Destroyer Options"));
535 do_cmd_options_aux(player_ptr, OPT_PAGE_PLAYRECORD, _("プレイ記録オプション", "Play-record Options"));
540 do_cmd_options_aux(player_ptr, OPT_PAGE_BIRTH,
541 (!w_ptr->wizard || !allow_debug_opts) ? _("初期オプション(参照のみ)", "Birth Options(browse only)")
542 : _("初期オプション((*)はスコアに影響)", "Birth Options ((*)) affect score"));
547 if (!w_ptr->noscore && !allow_debug_opts) {
552 do_cmd_options_cheat(player_ptr, _("詐欺師は決して勝利できない!", "Cheaters never win"));
557 do_cmd_options_autosave(player_ptr, _("自動セーブ", "Autosave"));
562 do_cmd_options_win(player_ptr);
563 player_ptr->window_flags = PW_ALL;
568 do_cmd_edit_autopick(player_ptr);
574 prt(format(_("現在ウェイト量(msec): %d", "Current Delay Factor(msec): %d"), delay_factor), 19, 0);
575 (void)get_value(_("コマンド: ウェイト量(msec)", "Command: Delay Factor(msec)"), 0, 1000, &delay_factor);
582 prt(_("コマンド: 低ヒットポイント警告", "Command: Hitpoint Warning"), 19, 0);
584 prt(format(_("現在の低ヒットポイント警告: %d0%%", "Current hitpoint warning: %d0%%"), hitpoint_warn), 22, 0);
585 prt(_("低ヒットポイント警告 (0-9) ESCで決定: ", "Hitpoint Warning (0-9 or ESC to accept): "), 20, 0);
589 } else if (k == '?') {
590 (void)show_file(player_ptr, true, _("joption.txt#Hitpoint", "option.txt#Hitpoint"), nullptr, 0, 0);
592 } else if (isdigit(k)) {
593 hitpoint_warn = D2I(k);
604 prt(_("コマンド: 低魔力色閾値", "Command: Mana Color Threshold"), 19, 0);
606 prt(format(_("現在の低魔力色閾値: %d0%%", "Current mana color threshold: %d0%%"), mana_warn), 22, 0);
607 prt(_("低魔力閾値 (0-9) ESCで決定: ", "Mana color Threshold (0-9 or ESC to accept): "), 20, 0);
611 } else if (k == '?') {
612 (void)show_file(player_ptr, true, _("joption.txt#Manapoint", "option.txt#Manapoint"), nullptr, 0, 0);
614 } else if (isdigit(k)) {
624 (void)show_file(player_ptr, true, _("joption.txt", "option.txt"), nullptr, 0, 0);
637 player_ptr->redraw |= (PR_EQUIPPY);
641 * @brief 標準オプションを変更するコマンドのサブルーチン /
642 * Interact with some options
643 * @param page オプションページ番号
644 * @param info 表示メッセージ
646 void do_cmd_options_aux(PlayerType *player_ptr, game_option_types page, concptr info)
649 int i, k = 0, n = 0, l;
652 bool browse_only = (page == OPT_PAGE_BIRTH) && w_ptr->character_generated && (!w_ptr->wizard || !allow_debug_opts);
654 for (i = 0; i < 24; i++) {
658 for (i = 0; option_info[i].o_desc; i++) {
659 if (option_info[i].o_page == page) {
667 sprintf(buf, _("%s (リターン:次, %sESC:終了, ?:ヘルプ) ", "%s (RET:next, %s, ?:help) "), info,
668 browse_only ? _("", "ESC:exit") : _("y/n:変更, ", "y/n:change, ESC:accept"));
670 if (page == OPT_PAGE_AUTODESTROY) {
671 c_prt(TERM_YELLOW, _("以下のオプションは、簡易自動破壊を使用するときのみ有効", "Following options will protect items from easy auto-destroyer."), 6,
675 for (i = 0; i < n; i++) {
681 sprintf(buf, "%-48s: %s (%.19s)", option_info[opt[i]].o_desc, (*option_info[opt[i]].o_var ? _("はい ", "yes") : _("いいえ", "no ")),
682 option_info[opt[i]].o_text);
683 if ((page == OPT_PAGE_AUTODESTROY) && i > 2) {
684 c_prt(a, buf, i + 5, 0);
686 c_prt(a, buf, i + 2, 0);
690 if ((page == OPT_PAGE_AUTODESTROY) && (k > 2)) {
696 move_cursor(k + 2 + l, 50);
698 dir = get_keymap_dir(ch);
699 if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8)) {
725 (*option_info[opt[k]].o_var) = true;
735 (*option_info[opt[k]].o_var) = false;
742 (*option_info[opt[k]].o_var) = !(*option_info[opt[k]].o_var);
747 strnfmt(buf, sizeof(buf), _("joption.txt#%s", "option.txt#%s"), option_info[opt[k]].o_text);
748 (void)show_file(player_ptr, true, buf, nullptr, 0, 0);