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"), 0, 0);
170 * @brief 指定のサブウィンドウが指定のウィンドウフラグを持つか調べる
172 * @param y ウィンドウフラグ番号
173 * @return 持つならTRUE、持たないかメインウィンドウならFALSE
175 static bool has_window_flag(int x, int y)
181 auto flag = i2enum<SubWindowRedrawingFlag>(y);
182 return g_window_flags[x].has(flag);
186 * @brief 指定のサブウィンドウに指定のウィンドウフラグをセットする
188 * @param y ウィンドウフラグ番号
192 static void set_window_flag(int x, int y)
198 auto flag = i2enum<SubWindowRedrawingFlag>(y);
199 g_window_flags[x].set(flag);
203 * @brief 指定のウィンドウフラグをサブウィンドウからクリアする
204 * @param y ウィンドウフラグ番号
206 static void clear_window_flag(int x, int y)
208 g_window_flags[x].clear();
213 auto flag = i2enum<SubWindowRedrawingFlag>(y);
214 for (auto &window_flag : g_window_flags) {
215 window_flag.reset(flag);
220 * @brief ウィンドウオプションを変更するコマンドのメインルーチン /
221 * Modify the "window" options
223 static void do_cmd_options_win(PlayerType *player_ptr)
230 const auto old_flags = g_window_flags;
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 auto 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 (g_window_flags[j].has(i2enum<SubWindowRedrawingFlag>(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);
282 g_window_flags[x].clear();
283 if (x > 0 && !has_flag) {
284 set_window_flag(x, y);
292 g_window_flags[x].clear();
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"), 0, 0);
301 d = get_keymap_dir(ch);
302 x = (x + ddx[d] + 8) % 8;
303 y = (y + ddy[d] + 16) % 16;
311 for (auto term_index = 0U; term_index < angband_terms.size(); ++term_index) {
312 term_type *old = game_term;
313 if (!angband_terms[term_index]) {
317 if (g_window_flags[term_index] == old_flags[term_index]) {
321 term_activate(angband_terms[term_index]);
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();
339 prt(format(_("%s ( リターンで次へ, y/n でセット, ESC で決定 )", "%s (RET to advance, y/n to set, ESC to accept) "), info), 0, 0);
342 /* 詐欺オプションをうっかりいじってしまう人がいるようなので注意 */
343 prt(" << 注意 >>", 11, 0);
344 prt(" 詐欺オプションを一度でも設定すると、スコア記録が残らなくなります!", 12, 0);
345 prt(" 後に解除してもダメですので、勝利者を目指す方はここのオプションはい", 13, 0);
346 prt(" じらないようにして下さい。", 14, 0);
348 for (auto i = 0U; i < n; i++) {
354 const auto yesno = *cheat_info[i].o_var ? _("はい ", "yes") : _("いいえ", "no ");
355 c_prt(enum2i(a), format("%-48s: %s (%s)", cheat_info[i].o_desc, yesno, cheat_info[i].o_text), i + 2, 0);
358 move_cursor(k + 2, 50);
360 auto dir = get_keymap_dir(ch);
361 if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8)) {
381 if (!w_ptr->noscore) {
382 exe_write_diary(player_ptr, DiaryKind::DESCRIPTION, 0,
383 _("詐欺オプションをONにして、スコアを残せなくなった。", "gave up sending score to use cheating options."));
386 w_ptr->noscore |= cheat_info[k].o_set * 256 + cheat_info[k].o_bit;
387 *cheat_info[k].o_var = true;
393 *cheat_info[k].o_var = false;
397 (void)show_file(player_ptr, true, std::string(_("joption.txt#", "option.txt#")).append(cheat_info[k].o_text), 0, 0);
408 * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
410 void extract_option_vars(void)
412 for (int i = 0; option_info[i].o_desc; i++) {
413 int os = option_info[i].o_set;
414 int ob = option_info[i].o_bit;
415 if (option_info[i].o_var) {
416 if (g_option_flags[os] & (1UL << ob)) {
417 (*option_info[i].o_var) = true;
419 (*option_info[i].o_var) = false;
426 * @brief 標準オプションを変更するコマンドのメインルーチン /
427 * Set or unset various options.
430 * The user must use the "Ctrl-R" command to "adapt" to changes
431 * in any options which control "visual" aspects of the game.
434 void do_cmd_options(PlayerType *player_ptr)
436 TermCenteredOffsetSetter tcos(MAIN_TERM_MIN_COLS, MAIN_TERM_MIN_ROWS);
444 if (!w_ptr->noscore && !allow_debug_opts) {
449 prt(_("[ オプションの設定 ]", "Game options"), 1, 0);
451 for (i = 0; i < n; i++) {
456 term_putstr(5, option_fields[i].row, -1, a, format("(%c) %s", toupper(option_fields[i].key), option_fields[i].name));
459 prt(_("<方向>で移動, Enterで決定, ESCでキャンセル, ?でヘルプ: ", "Move to <dir>, Select to Enter, Cancel to ESC, ? to help: "), 21, 0);
460 skey = inkey_special(true);
461 if (!(skey & SKEY_MASK)) {
471 if (angband_strchr("\n\r ", k)) {
472 k = option_fields[y].key;
476 for (i = 0; i < n; i++) {
477 if (tolower(k) == option_fields[i].key) {
491 if (skey == SKEY_UP) {
494 if (skey == SKEY_DOWN) {
497 y = (y + ddy[d] + n) % n;
509 do_cmd_options_aux(player_ptr, OPT_PAGE_INPUT, _("キー入力オプション", "Input Options"));
513 do_cmd_options_aux(player_ptr, OPT_PAGE_MAPSCREEN, _("マップ画面オプション", "Map Screen Options"));
517 do_cmd_options_aux(player_ptr, OPT_PAGE_TEXT, _("テキスト表示オプション", "Text Display Options"));
521 do_cmd_options_aux(player_ptr, OPT_PAGE_GAMEPLAY, _("ゲームプレイ・オプション", "Game-Play Options"));
525 do_cmd_options_aux(player_ptr, OPT_PAGE_DISTURBANCE, _("行動中止関係のオプション", "Disturbance Options"));
529 do_cmd_options_aux(player_ptr, OPT_PAGE_AUTODESTROY, _("簡易自動破壊オプション", "Easy Auto-Destroyer Options"));
534 do_cmd_options_aux(player_ptr, OPT_PAGE_PLAYRECORD, _("プレイ記録オプション", "Play-record Options"));
539 do_cmd_options_aux(player_ptr, OPT_PAGE_BIRTH,
540 (!w_ptr->wizard || !allow_debug_opts) ? _("初期オプション(参照のみ)", "Birth Options(browse only)")
541 : _("初期オプション((*)はスコアに影響)", "Birth Options ((*)) affect score"));
546 if (!w_ptr->noscore && !allow_debug_opts) {
551 do_cmd_options_cheat(player_ptr, _("詐欺師は決して勝利できない!", "Cheaters never win"));
556 do_cmd_options_autosave(player_ptr, _("自動セーブ", "Autosave"));
561 do_cmd_options_win(player_ptr);
562 RedrawingFlagsUpdater::get_instance().fill_up_sub_flags();
567 do_cmd_edit_autopick(player_ptr);
573 prt(format(_("現在ウェイト量(msec): %d", "Current Delay Factor(msec): %d"), delay_factor), 19, 0);
574 constexpr auto prompt = _("コマンド: ウェイト量(msec)", "Command: Delay Factor(msec)");
575 const auto new_delay_factor = input_integer(prompt, 0, 1000, delay_factor);
576 if (new_delay_factor) {
577 delay_factor = *new_delay_factor;
586 prt(_("コマンド: 低ヒットポイント警告", "Command: Hitpoint Warning"), 19, 0);
588 prt(format(_("現在の低ヒットポイント警告: %d0%%", "Current hitpoint warning: %d0%%"), hitpoint_warn), 22, 0);
589 prt(_("低ヒットポイント警告 (0-9) ESCで決定: ", "Hitpoint Warning (0-9 or ESC to accept): "), 20, 0);
593 } else if (k == '?') {
594 (void)show_file(player_ptr, true, _("joption.txt#Hitpoint", "option.txt#Hitpoint"), 0, 0);
596 } else if (isdigit(k)) {
597 hitpoint_warn = D2I(k);
608 prt(_("コマンド: 低魔力色閾値", "Command: Mana Color Threshold"), 19, 0);
610 prt(format(_("現在の低魔力色閾値: %d0%%", "Current mana color threshold: %d0%%"), mana_warn), 22, 0);
611 prt(_("低魔力閾値 (0-9) ESCで決定: ", "Mana color Threshold (0-9 or ESC to accept): "), 20, 0);
615 } else if (k == '?') {
616 (void)show_file(player_ptr, true, _("joption.txt#Manapoint", "option.txt#Manapoint"), 0, 0);
618 } else if (isdigit(k)) {
628 (void)show_file(player_ptr, true, _("joption.txt", "option.txt"), 0, 0);
641 RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::EQUIPPY);
645 * @brief 標準オプションを変更するコマンドのサブルーチン /
646 * Interact with some options
647 * @param page オプションページ番号
648 * @param info 表示メッセージ
650 void do_cmd_options_aux(PlayerType *player_ptr, game_option_types page, concptr info)
653 int i, k = 0, n = 0, l;
654 int opt[MAIN_TERM_MIN_ROWS]{};
655 bool browse_only = (page == OPT_PAGE_BIRTH) && w_ptr->character_generated && (!w_ptr->wizard || !allow_debug_opts);
657 for (i = 0; i < MAIN_TERM_MIN_ROWS; i++) {
661 for (i = 0; option_info[i].o_desc; i++) {
662 if (option_info[i].o_page == page) {
670 constexpr auto command = _("%s (リターン:次, %sESC:終了, ?:ヘルプ) ", "%s (RET:next, %s, ?:help) ");
671 prt(format(command, info, browse_only ? _("", "ESC:exit") : _("y/n:変更, ", "y/n:change, ESC:accept")), 0, 0);
672 if (page == OPT_PAGE_AUTODESTROY) {
673 constexpr auto mes = _("以下のオプションは、簡易自動破壊を使用するときのみ有効", "Following options will protect items from easy auto-destroyer.");
674 c_prt(TERM_YELLOW, mes, 6, _(6, 3));
677 for (i = 0; i < n; i++) {
683 const auto reply = *option_info[opt[i]].o_var ? _("はい ", "yes") : _("いいえ", "no ");
684 const auto label = format("%-48s: %s (%.19s)", option_info[opt[i]].o_desc, reply, option_info[opt[i]].o_text);
685 if ((page == OPT_PAGE_AUTODESTROY) && i > 2) {
686 c_prt(a, label, i + 5, 0);
688 c_prt(a, label, i + 2, 0);
692 if ((page == OPT_PAGE_AUTODESTROY) && (k > 2)) {
698 move_cursor(k + 2 + l, 50);
700 dir = get_keymap_dir(ch);
701 if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8)) {
727 (*option_info[opt[k]].o_var) = true;
737 (*option_info[opt[k]].o_var) = false;
744 (*option_info[opt[k]].o_var) = !(*option_info[opt[k]].o_var);
749 (void)show_file(player_ptr, true, std::string(_("joption.txt#", "option.txt#")).append(option_info[opt[k]].o_text), 0, 0);