OSDN Git Service

Merge branch 'develop' into macos-develop
[hengbandforosx/hengbandosx.git] / src / cmd-io / cmd-gameoption.cpp
index 9100fff..16ecb9b 100644 (file)
@@ -1,4 +1,4 @@
-#include "cmd-io/cmd-gameoption.h"
+#include "cmd-io/cmd-gameoption.h"
 #include "autopick/autopick.h"
 #include "cmd-io/cmd-autopick.h"
 #include "cmd-io/cmd-dump.h"
@@ -153,7 +153,7 @@ static void do_cmd_options_autosave(PlayerType *player_ptr, concptr info)
         }
 
         case '?': {
-            (void)show_file(player_ptr, true, _("joption.txt#Autosave", "option.txt#Autosave"), nullptr, 0, 0);
+            (void)show_file(player_ptr, true, _("joption.txt#Autosave", "option.txt#Autosave"), 0, 0);
             term_clear();
             break;
         }
@@ -170,12 +170,16 @@ static void do_cmd_options_autosave(PlayerType *player_ptr, concptr info)
  * @brief 指定のサブウィンドウが指定のウィンドウフラグを持つか調べる
  * @param x ウィンドウ番号
  * @param y ウィンドウフラグ番号
- * @return 持つならTRUE、持たないならFALSE
+ * @return æ\8c\81ã\81¤ã\81ªã\82\89TRUEã\80\81æ\8c\81ã\81\9fã\81ªã\81\84ã\81\8bã\83¡ã\82¤ã\83³ã\82¦ã\82£ã\83³ã\83\89ã\82¦ã\81ªã\82\89FALSE
  */
 static bool has_window_flag(int x, int y)
 {
-    auto flag = i2enum<window_redraw_type>(1UL << y);
-    return any_bits(window_flag[x], flag);
+    if (x == 0) {
+        return false;
+    }
+
+    auto flag = i2enum<SubWindowRedrawingFlag>(y);
+    return g_window_flags[x].has(flag);
 }
 
 /*!
@@ -187,10 +191,12 @@ static bool has_window_flag(int x, int y)
  */
 static void set_window_flag(int x, int y)
 {
-    auto flag = i2enum<window_redraw_type>(1UL << y);
-    if (any_bits(PW_ALL, flag)) {
-        set_bits(window_flag[x], flag);
+    if (x == 0) {
+        return;
     }
+
+    auto flag = i2enum<SubWindowRedrawingFlag>(y);
+    g_window_flags[x].set(flag);
 }
 
 /*!
@@ -199,11 +205,14 @@ static void set_window_flag(int x, int y)
  */
 static void clear_window_flag(int x, int y)
 {
-    window_flag[x] = 0;
+    g_window_flags[x].clear();
+    if (x == 0) {
+        return;
+    }
 
-    auto flag = i2enum<window_redraw_type>(1UL << y);
-    for (int i = 0; i < 8; i++) {
-        reset_bits(window_flag[i], flag);
+    auto flag = i2enum<SubWindowRedrawingFlag>(y);
+    for (auto &window_flag : g_window_flags) {
+        window_flag.reset(flag);
     }
 }
 
@@ -218,18 +227,13 @@ static void do_cmd_options_win(PlayerType *player_ptr)
     TERM_LEN x = 0;
     char ch;
     bool go = true;
-    uint32_t old_flag[8];
-
-    for (j = 0; j < 8; j++) {
-        old_flag[j] = window_flag[j];
-    }
-
+    const auto old_flags = g_window_flags;
     term_clear();
     while (go) {
         prt(_("ウィンドウ・フラグ (<方向>で移動, 't'でON/OFF,'s'でON(他窓OFF), ESC)", "Window Flags (<dir>, <t>oggle, <s>et, ESC) "), 0, 0);
         for (j = 0; j < 8; j++) {
             byte a = TERM_WHITE;
-            concptr s = angband_term_name[j];
+            auto s = angband_term_name[j];
             if (j == x) {
                 a = TERM_L_BLUE;
             }
@@ -256,7 +260,7 @@ static void do_cmd_options_win(PlayerType *player_ptr)
                     a = TERM_L_BLUE;
                 }
 
-                if (window_flag[j] & (1UL << i)) {
+                if (g_window_flags[j].has(i2enum<SubWindowRedrawingFlag>(i))) {
                     c = 'X';
                 }
 
@@ -275,7 +279,7 @@ static void do_cmd_options_win(PlayerType *player_ptr)
         case 't':
         case 'T':
             has_flag = has_window_flag(x, y);
-            window_flag[x] = 0;
+            g_window_flags[x].clear();
             if (x > 0 && !has_flag) {
                 set_window_flag(x, y);
             }
@@ -285,12 +289,12 @@ static void do_cmd_options_win(PlayerType *player_ptr)
             if (x == 0) {
                 break;
             }
-            window_flag[x] = 0;
+            g_window_flags[x].clear();
             clear_window_flag(x, y);
             set_window_flag(x, y);
             break;
         case '?':
-            (void)show_file(player_ptr, true, _("joption.txt#Window", "option.txt#Window"), nullptr, 0, 0);
+            (void)show_file(player_ptr, true, _("joption.txt#Window", "option.txt#Window"), 0, 0);
             term_clear();
             break;
         default:
@@ -310,7 +314,7 @@ static void do_cmd_options_win(PlayerType *player_ptr)
             continue;
         }
 
-        if (window_flag[term_index] == old_flag[term_index]) {
+        if (g_window_flags[term_index] == old_flags[term_index]) {
             continue;
         }
 
@@ -347,7 +351,8 @@ static void do_cmd_options_cheat(PlayerType *player_ptr, concptr info)
                 a = TERM_L_BLUE;
             }
 
-            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);
+            const auto yesno = *cheat_info[i].o_var ? _("はい  ", "yes") : _("いいえ", "no ");
+            c_prt(enum2i(a), format("%-48s: %s (%s)", cheat_info[i].o_desc, yesno, cheat_info[i].o_text), i + 2, 0);
         }
 
         move_cursor(k + 2, 50);
@@ -374,7 +379,7 @@ static void do_cmd_options_cheat(PlayerType *player_ptr, concptr info)
         case 'Y':
         case '6':
             if (!w_ptr->noscore) {
-                exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0,
+                exe_write_diary(player_ptr, DiaryKind::DESCRIPTION, 0,
                     _("詐欺オプションをONにして、スコアを残せなくなった。", "gave up sending score to use cheating options."));
             }
 
@@ -389,7 +394,7 @@ static void do_cmd_options_cheat(PlayerType *player_ptr, concptr info)
             k = (k + 1) % n;
             break;
         case '?':
-            (void)show_file(player_ptr, true, std::string(_("joption.txt#", "option.txt#")).append(cheat_info[k].o_text).data(), nullptr, 0, 0);
+            (void)show_file(player_ptr, true, std::string(_("joption.txt#", "option.txt#")).append(cheat_info[k].o_text), 0, 0);
             term_clear();
             break;
         default:
@@ -408,7 +413,7 @@ void extract_option_vars(void)
         int os = option_info[i].o_set;
         int ob = option_info[i].o_bit;
         if (option_info[i].o_var) {
-            if (option_flag[os] & (1UL << ob)) {
+            if (g_option_flags[os] & (1UL << ob)) {
                 (*option_info[i].o_var) = true;
             } else {
                 (*option_info[i].o_var) = false;
@@ -554,7 +559,7 @@ void do_cmd_options(PlayerType *player_ptr)
         case 'W':
         case 'w': {
             do_cmd_options_win(player_ptr);
-            player_ptr->window_flags = PW_ALL;
+            RedrawingFlagsUpdater::get_instance().fill_up_sub_flags();
             break;
         }
         case 'P':
@@ -566,7 +571,12 @@ void do_cmd_options(PlayerType *player_ptr)
         case 'd': {
             clear_from(18);
             prt(format(_("現在ウェイト量(msec): %d", "Current Delay Factor(msec): %d"), delay_factor), 19, 0);
-            (void)get_value(_("コマンド: ウェイト量(msec)", "Command: Delay Factor(msec)"), 0, 1000, &delay_factor);
+            constexpr auto prompt = _("コマンド: ウェイト量(msec)", "Command: Delay Factor(msec)");
+            const auto new_delay_factor = input_integer(prompt, 0, 1000, delay_factor);
+            if (new_delay_factor) {
+                delay_factor = *new_delay_factor;
+            }
+
             clear_from(18);
             break;
         }
@@ -581,7 +591,7 @@ void do_cmd_options(PlayerType *player_ptr)
                 if (k == ESCAPE) {
                     break;
                 } else if (k == '?') {
-                    (void)show_file(player_ptr, true, _("joption.txt#Hitpoint", "option.txt#Hitpoint"), nullptr, 0, 0);
+                    (void)show_file(player_ptr, true, _("joption.txt#Hitpoint", "option.txt#Hitpoint"), 0, 0);
                     term_clear();
                 } else if (isdigit(k)) {
                     hitpoint_warn = D2I(k);
@@ -603,7 +613,7 @@ void do_cmd_options(PlayerType *player_ptr)
                 if (k == ESCAPE) {
                     break;
                 } else if (k == '?') {
-                    (void)show_file(player_ptr, true, _("joption.txt#Manapoint", "option.txt#Manapoint"), nullptr, 0, 0);
+                    (void)show_file(player_ptr, true, _("joption.txt#Manapoint", "option.txt#Manapoint"), 0, 0);
                     term_clear();
                 } else if (isdigit(k)) {
                     mana_warn = D2I(k);
@@ -615,7 +625,7 @@ void do_cmd_options(PlayerType *player_ptr)
             break;
         }
         case '?':
-            (void)show_file(player_ptr, true, _("joption.txt", "option.txt"), nullptr, 0, 0);
+            (void)show_file(player_ptr, true, _("joption.txt", "option.txt"), 0, 0);
             term_clear();
             break;
         default: {
@@ -641,7 +651,7 @@ void do_cmd_options_aux(PlayerType *player_ptr, game_option_types page, concptr
 {
     char ch;
     int i, k = 0, n = 0, l;
-    int opt[MAIN_TERM_MIN_ROWS];
+    int opt[MAIN_TERM_MIN_ROWS]{};
     bool browse_only = (page == OPT_PAGE_BIRTH) && w_ptr->character_generated && (!w_ptr->wizard || !allow_debug_opts);
 
     for (i = 0; i < MAIN_TERM_MIN_ROWS; i++) {
@@ -670,8 +680,8 @@ void do_cmd_options_aux(PlayerType *player_ptr, game_option_types page, concptr
                 a = TERM_L_BLUE;
             }
 
-            std::string label = format("%-48s: %s (%.19s)", option_info[opt[i]].o_desc, (*option_info[opt[i]].o_var ? _("はい  ", "yes") : _("いいえ", "no ")),
-                option_info[opt[i]].o_text);
+            const auto reply = *option_info[opt[i]].o_var ? _("はい  ", "yes") : _("いいえ", "no ");
+            const auto label = format("%-48s: %s (%.19s)", option_info[opt[i]].o_desc, reply, option_info[opt[i]].o_text);
             if ((page == OPT_PAGE_AUTODESTROY) && i > 2) {
                 c_prt(a, label, i + 5, 0);
             } else {
@@ -736,7 +746,7 @@ void do_cmd_options_aux(PlayerType *player_ptr, game_option_types page, concptr
             break;
         }
         case '?': {
-            (void)show_file(player_ptr, true, std::string(_("joption.txt#", "option.txt#")).append(option_info[opt[k]].o_text).data(), nullptr, 0, 0);
+            (void)show_file(player_ptr, true, std::string(_("joption.txt#", "option.txt#")).append(option_info[opt[k]].o_text), 0, 0);
             term_clear();
             break;
         }