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/show-file.h"
7 #include "core/window-redrawer.h"
8 #include "floor/geometry.h"
9 #include "game-option/game-play-options.h"
10 #include "game-option/keymap-directory-getter.h"
11 #include "game-option/option-flags.h"
12 #include "game-option/option-types-table.h"
13 #include "game-option/special-options.h"
14 #include "io/input-key-acceptor.h"
15 #include "io/write-diary.h"
16 #include "main/sound-of-music.h"
17 #include "system/game-option-types.h"
18 #include "system/player-type-definition.h"
19 #include "system/redrawing-flags-updater.h"
20 #include "term/gameterm.h"
21 #include "term/screen-processor.h"
22 #include "term/term-color-types.h"
23 #include "term/z-form.h"
24 #include "util/bit-flags-calculator.h"
25 #include "util/int-char-converter.h"
26 #include "util/string-processor.h"
27 #include "view/display-messages.h"
28 #include "world/world.h"
38 static opts option_fields[OPT_NUM] = {
39 { '1', _(" キー入力 オプション", "Input Options"), 3 },
40 { '2', _(" マップ画面 オプション", "Map Screen Options"), 4 },
41 { '3', _(" テキスト表示 オプション", "Text Display Options"), 5 },
42 { '4', _(" ゲームプレイ オプション", "Game-Play Options"), 6 },
43 { '5', _(" 行動中止関係 オプション", "Disturbance Options"), 7 },
44 { '6', _(" 簡易自動破壊 オプション", "Easy Auto-Destroyer Options"), 8 },
45 { 'r', _(" プレイ記録 オプション", "Play record Options"), 9 },
47 { 'p', _("自動拾いエディタ", "Auto-picker/destroyer editor"), 11 },
48 { 'd', _(" 基本ウェイト量 ", "Base Delay Factor"), 12 },
49 { 'h', _("低ヒットポイント", "Hitpoint Warning"), 13 },
50 { 'm', _(" 低魔力色閾値 ", "Mana Color Threshold"), 14 },
51 { 'a', _(" 自動セーブ オプション", "Autosave Options"), 15 },
52 { 'w', _("ウインドウフラグ", "Window Flags"), 16 },
54 { 'b', _(" 初期 オプション (参照のみ)", "Birth Options (Browse Only)"), 18 },
55 { 'c', _(" 詐欺 オプション", "Cheat Options"), 19 },
59 * @brief セーブ頻度ターンの次の値を返す
60 * @param current 現在のセーブ頻度ターン値
63 static int16_t toggle_frequency(int16_t current)
90 * @brief 自動セーブオプションを変更するコマンドのメインルーチン
93 static void do_cmd_options_autosave(PlayerType *player_ptr, concptr info)
99 prt(format(_("%s ( リターンで次へ, y/n でセット, F で頻度を入力, ESC で決定 ) ", "%s (RET to advance, y/n to set, 'F' for frequency, ESC to accept) "), info), 0, 0);
100 for (i = 0; i < n; i++) {
106 c_prt(a, format("%-48s: %s (%s)", autosave_info[i].o_desc, (*autosave_info[i].o_var ? _("はい ", "yes") : _("いいえ", "no ")), autosave_info[i].o_text), i + 2, 0);
109 prt(format(_("自動セーブの頻度: %d ターン毎", "Timed autosave frequency: every %d turns"), autosave_freq), 5, 0);
110 move_cursor(k + 2, 50);
135 (*autosave_info[k].o_var) = true;
143 (*autosave_info[k].o_var) = false;
150 autosave_freq = toggle_frequency(autosave_freq);
151 prt(format(_("自動セーブの頻度: %d ターン毎", "Timed autosave frequency: every %d turns"), autosave_freq), 5, 0);
156 (void)show_file(player_ptr, true, _("joption.txt#Autosave", "option.txt#Autosave"), nullptr, 0, 0);
170 * @brief 指定のサブウィンドウが指定のウィンドウフラグを持つか調べる
172 * @param y ウィンドウフラグ番号
173 * @return 持つならTRUE、持たないならFALSE
175 static bool has_window_flag(int x, int y)
177 auto flag = i2enum<window_redraw_type>(1UL << y);
178 return any_bits(window_flag[x], flag);
182 * @brief 指定のサブウィンドウに指定のウィンドウフラグをセットする
184 * @param y ウィンドウフラグ番号
188 static void set_window_flag(int x, int y)
190 auto flag = i2enum<window_redraw_type>(1UL << y);
191 if (any_bits(PW_ALL, flag)) {
192 set_bits(window_flag[x], flag);
197 * @brief 指定のウィンドウフラグをサブウィンドウからクリアする
198 * @param y ウィンドウフラグ番号
200 static void clear_window_flag(int x, int y)
204 auto flag = i2enum<window_redraw_type>(1UL << y);
205 for (int i = 0; i < 8; i++) {
206 reset_bits(window_flag[i], flag);
211 * @brief ウィンドウオプションを変更するコマンドのメインルーチン /
212 * Modify the "window" options
214 static void do_cmd_options_win(PlayerType *player_ptr)
221 uint32_t old_flag[8];
223 for (j = 0; j < 8; j++) {
224 old_flag[j] = window_flag[j];
229 prt(_("ウィンドウ・フラグ (<方向>で移動, 't'でON/OFF,'s'でON(他窓OFF), ESC)", "Window Flags (<dir>, <t>oggle, <s>et, ESC) "), 0, 0);
230 for (j = 0; j < 8; j++) {
232 concptr s = angband_term_name[j];
237 term_putstr(35 + j * 5 - strlen(s) / 2, 2 + j % 2, -1, a, s);
240 for (i = 0; i < 16; i++) {
242 concptr str = window_flag_desc[i];
248 str = _("(未使用)", "(Unused option)");
251 term_putstr(0, i + 5, -1, a, str);
252 for (j = 0; j < 8; j++) {
255 if ((i == y) && (j == x)) {
259 if (window_flag[j] & (1UL << i)) {
263 term_putch(35 + j * 5, i + 5, a, c);
267 bool has_flag = false;
268 term_gotoxy(35 + x * 5, y + 5);
277 has_flag = has_window_flag(x, y);
279 if (x > 0 && !has_flag) {
280 set_window_flag(x, y);
289 clear_window_flag(x, y);
290 set_window_flag(x, y);
293 (void)show_file(player_ptr, true, _("joption.txt#Window", "option.txt#Window"), nullptr, 0, 0);
297 d = get_keymap_dir(ch);
298 x = (x + ddx[d] + 8) % 8;
299 y = (y + ddy[d] + 16) % 16;
307 for (auto term_index = 0U; term_index < angband_terms.size(); ++term_index) {
308 term_type *old = game_term;
309 if (!angband_terms[term_index]) {
313 if (window_flag[term_index] == old_flag[term_index]) {
317 term_activate(angband_terms[term_index]);
325 * @brief チートオプションを変更するコマンドのメインルーチン
326 * Interact with some options for cheating
327 * @param info 表示メッセージ
329 static void do_cmd_options_cheat(PlayerType *player_ptr, concptr info)
333 const auto n = cheat_info.size();
335 prt(format(_("%s ( リターンで次へ, y/n でセット, ESC で決定 )", "%s (RET to advance, y/n to set, ESC to accept) "), info), 0, 0);
338 /* 詐欺オプションをうっかりいじってしまう人がいるようなので注意 */
339 prt(" << 注意 >>", 11, 0);
340 prt(" 詐欺オプションを一度でも設定すると、スコア記録が残らなくなります!", 12, 0);
341 prt(" 後に解除してもダメですので、勝利者を目指す方はここのオプションはい", 13, 0);
342 prt(" じらないようにして下さい。", 14, 0);
344 for (auto i = 0U; i < n; i++) {
350 c_prt(enum2i(a), format("%-48s: %s (%s)", cheat_info[i].o_desc, (*cheat_info[i].o_var ? _("はい ", "yes") : _("いいえ", "no ")), cheat_info[i].o_text), i + 2, 0);
353 move_cursor(k + 2, 50);
355 auto dir = get_keymap_dir(ch);
356 if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8)) {
376 if (!w_ptr->noscore) {
377 exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0,
378 _("詐欺オプションをONにして、スコアを残せなくなった。", "gave up sending score to use cheating options."));
381 w_ptr->noscore |= cheat_info[k].o_set * 256 + cheat_info[k].o_bit;
382 *cheat_info[k].o_var = true;
388 *cheat_info[k].o_var = false;
392 (void)show_file(player_ptr, true, std::string(_("joption.txt#", "option.txt#")).append(cheat_info[k].o_text).data(), nullptr, 0, 0);
403 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
405 void extract_option_vars(void)
407 for (int i = 0; option_info[i].o_desc; i++) {
408 int os = option_info[i].o_set;
409 int ob = option_info[i].o_bit;
410 if (option_info[i].o_var) {
411 if (option_flag[os] & (1UL << ob)) {
412 (*option_info[i].o_var) = true;
414 (*option_info[i].o_var) = false;
421 * @brief 標準オプションを変更するコマンドのメインルーチン /
422 * Set or unset various options.
425 * The user must use the "Ctrl-R" command to "adapt" to changes
426 * in any options which control "visual" aspects of the game.
429 void do_cmd_options(PlayerType *player_ptr)
431 TermCenteredOffsetSetter tcos(MAIN_TERM_MIN_COLS, MAIN_TERM_MIN_ROWS);
439 if (!w_ptr->noscore && !allow_debug_opts) {
444 prt(_("[ オプションの設定 ]", "Game options"), 1, 0);
446 for (i = 0; i < n; i++) {
451 term_putstr(5, option_fields[i].row, -1, a, format("(%c) %s", toupper(option_fields[i].key), option_fields[i].name));
454 prt(_("<方向>で移動, Enterで決定, ESCでキャンセル, ?でヘルプ: ", "Move to <dir>, Select to Enter, Cancel to ESC, ? to help: "), 21, 0);
455 skey = inkey_special(true);
456 if (!(skey & SKEY_MASK)) {
466 if (angband_strchr("\n\r ", k)) {
467 k = option_fields[y].key;
471 for (i = 0; i < n; i++) {
472 if (tolower(k) == option_fields[i].key) {
486 if (skey == SKEY_UP) {
489 if (skey == SKEY_DOWN) {
492 y = (y + ddy[d] + n) % n;
504 do_cmd_options_aux(player_ptr, OPT_PAGE_INPUT, _("キー入力オプション", "Input Options"));
508 do_cmd_options_aux(player_ptr, OPT_PAGE_MAPSCREEN, _("マップ画面オプション", "Map Screen Options"));
512 do_cmd_options_aux(player_ptr, OPT_PAGE_TEXT, _("テキスト表示オプション", "Text Display Options"));
516 do_cmd_options_aux(player_ptr, OPT_PAGE_GAMEPLAY, _("ゲームプレイ・オプション", "Game-Play Options"));
520 do_cmd_options_aux(player_ptr, OPT_PAGE_DISTURBANCE, _("行動中止関係のオプション", "Disturbance Options"));
524 do_cmd_options_aux(player_ptr, OPT_PAGE_AUTODESTROY, _("簡易自動破壊オプション", "Easy Auto-Destroyer Options"));
529 do_cmd_options_aux(player_ptr, OPT_PAGE_PLAYRECORD, _("プレイ記録オプション", "Play-record Options"));
534 do_cmd_options_aux(player_ptr, OPT_PAGE_BIRTH,
535 (!w_ptr->wizard || !allow_debug_opts) ? _("初期オプション(参照のみ)", "Birth Options(browse only)")
536 : _("初期オプション((*)はスコアに影響)", "Birth Options ((*)) affect score"));
541 if (!w_ptr->noscore && !allow_debug_opts) {
546 do_cmd_options_cheat(player_ptr, _("詐欺師は決して勝利できない!", "Cheaters never win"));
551 do_cmd_options_autosave(player_ptr, _("自動セーブ", "Autosave"));
556 do_cmd_options_win(player_ptr);
557 player_ptr->window_flags = PW_ALL;
562 do_cmd_edit_autopick(player_ptr);
568 prt(format(_("現在ウェイト量(msec): %d", "Current Delay Factor(msec): %d"), delay_factor), 19, 0);
569 (void)get_value(_("コマンド: ウェイト量(msec)", "Command: Delay Factor(msec)"), 0, 1000, &delay_factor);
576 prt(_("コマンド: 低ヒットポイント警告", "Command: Hitpoint Warning"), 19, 0);
578 prt(format(_("現在の低ヒットポイント警告: %d0%%", "Current hitpoint warning: %d0%%"), hitpoint_warn), 22, 0);
579 prt(_("低ヒットポイント警告 (0-9) ESCで決定: ", "Hitpoint Warning (0-9 or ESC to accept): "), 20, 0);
583 } else if (k == '?') {
584 (void)show_file(player_ptr, true, _("joption.txt#Hitpoint", "option.txt#Hitpoint"), nullptr, 0, 0);
586 } else if (isdigit(k)) {
587 hitpoint_warn = D2I(k);
598 prt(_("コマンド: 低魔力色閾値", "Command: Mana Color Threshold"), 19, 0);
600 prt(format(_("現在の低魔力色閾値: %d0%%", "Current mana color threshold: %d0%%"), mana_warn), 22, 0);
601 prt(_("低魔力閾値 (0-9) ESCで決定: ", "Mana color Threshold (0-9 or ESC to accept): "), 20, 0);
605 } else if (k == '?') {
606 (void)show_file(player_ptr, true, _("joption.txt#Manapoint", "option.txt#Manapoint"), nullptr, 0, 0);
608 } else if (isdigit(k)) {
618 (void)show_file(player_ptr, true, _("joption.txt", "option.txt"), nullptr, 0, 0);
631 RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::EQUIPPY);
635 * @brief 標準オプションを変更するコマンドのサブルーチン /
636 * Interact with some options
637 * @param page オプションページ番号
638 * @param info 表示メッセージ
640 void do_cmd_options_aux(PlayerType *player_ptr, game_option_types page, concptr info)
643 int i, k = 0, n = 0, l;
644 int opt[MAIN_TERM_MIN_ROWS];
645 bool browse_only = (page == OPT_PAGE_BIRTH) && w_ptr->character_generated && (!w_ptr->wizard || !allow_debug_opts);
647 for (i = 0; i < MAIN_TERM_MIN_ROWS; i++) {
651 for (i = 0; option_info[i].o_desc; i++) {
652 if (option_info[i].o_page == page) {
660 constexpr auto command = _("%s (リターン:次, %sESC:終了, ?:ヘルプ) ", "%s (RET:next, %s, ?:help) ");
661 prt(format(command, info, browse_only ? _("", "ESC:exit") : _("y/n:変更, ", "y/n:change, ESC:accept")), 0, 0);
662 if (page == OPT_PAGE_AUTODESTROY) {
663 constexpr auto mes = _("以下のオプションは、簡易自動破壊を使用するときのみ有効", "Following options will protect items from easy auto-destroyer.");
664 c_prt(TERM_YELLOW, mes, 6, _(6, 3));
667 for (i = 0; i < n; i++) {
673 std::string label = format("%-48s: %s (%.19s)", option_info[opt[i]].o_desc, (*option_info[opt[i]].o_var ? _("はい ", "yes") : _("いいえ", "no ")),
674 option_info[opt[i]].o_text);
675 if ((page == OPT_PAGE_AUTODESTROY) && i > 2) {
676 c_prt(a, label, i + 5, 0);
678 c_prt(a, label, i + 2, 0);
682 if ((page == OPT_PAGE_AUTODESTROY) && (k > 2)) {
688 move_cursor(k + 2 + l, 50);
690 dir = get_keymap_dir(ch);
691 if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8)) {
717 (*option_info[opt[k]].o_var) = true;
727 (*option_info[opt[k]].o_var) = false;
734 (*option_info[opt[k]].o_var) = !(*option_info[opt[k]].o_var);
739 (void)show_file(player_ptr, true, std::string(_("joption.txt#", "option.txt#")).append(option_info[opt[k]].o_text).data(), nullptr, 0, 0);