OSDN Git Service

[Refactor] #3286 Removed player-redraw-types.h
[hengbandforosx/hengbandosx.git] / src / cmd-visual / cmd-draw.cpp
index 87869f7..62404b3 100644 (file)
@@ -1,29 +1,30 @@
 #include "cmd-visual/cmd-draw.h"
 #include "core/asking-player.h"
-#include "core/player-redraw-types.h"
-#include "core/player-update-types.h"
 #include "core/stuff-handler.h"
 #include "core/window-redrawer.h"
 #include "io/files-util.h"
 #include "io/input-key-acceptor.h"
 #include "main/sound-of-music.h"
+#include "player-base/player-race.h"
 #include "player-info/race-types.h"
 #include "player/process-name.h"
 #include "racial/racial-android.h"
 #include "system/player-type-definition.h"
+#include "system/redrawing-flags-updater.h"
 #include "term/gameterm.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
+#include "term/z-form.h"
 #include "util/int-char-converter.h"
 #include "util/string-processor.h"
 #include "view/display-messages.h"
-#include "view/display-player.h" // 暫定。後で消す.
+#include "view/display-player.h"
 #include "world/world.h"
 
 /*!
  * @brief 画面を再描画するコマンドのメインルーチン
  * Hack -- redraw the screen
- * @param player_ptr ã\83\97ã\83¬ã\83¼ヤーへの参照ポインタ
+ * @param player_ptr ã\83\97ã\83¬ã\82¤ヤーへの参照ポインタ
  * @details
  * <pre>
  * This command performs various low level updates, clears all the "extra"
  * the "TERM_XTRA_REACT" hook before redrawing the windows.
  * </pre>
  */
-void do_cmd_redraw(player_type *player_ptr)
+void do_cmd_redraw(PlayerType *player_ptr)
 {
     term_xtra(TERM_XTRA_REACT, 0);
 
-    player_ptr->update |= (PU_COMBINE | PU_REORDER);
-    player_ptr->update |= (PU_TORCH);
-    player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
-    player_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
-    player_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
-    player_ptr->update |= (PU_MONSTERS);
-
-    player_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
-
-    player_ptr->window_flags |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
-    player_ptr->window_flags |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
-
+    auto &rfu = RedrawingFlagsUpdater::get_instance();
+    const auto flags_srf = {
+        StatusRedrawingFlag::COMBINATION,
+        StatusRedrawingFlag::REORDER,
+        StatusRedrawingFlag::TORCH,
+        StatusRedrawingFlag::BONUS,
+        StatusRedrawingFlag::HP,
+        StatusRedrawingFlag::MP,
+        StatusRedrawingFlag::SPELLS,
+        StatusRedrawingFlag::UN_VIEW,
+        StatusRedrawingFlag::UN_LITE,
+        StatusRedrawingFlag::VIEW,
+        StatusRedrawingFlag::LITE,
+        StatusRedrawingFlag::MONSTER_LITE,
+        StatusRedrawingFlag::MONSTER_STATUSES,
+    };
+    rfu.set_flags(flags_srf);
+    const auto flags_mwrf = {
+        MainWindowRedrawingFlag::WIPE,
+        MainWindowRedrawingFlag::BASIC,
+        MainWindowRedrawingFlag::EXTRA,
+        MainWindowRedrawingFlag::EQUIPPY,
+        MainWindowRedrawingFlag::MAP,
+    };
+    rfu.set_flags(flags_mwrf);
+    player_ptr->window_flags |= (PW_INVENTORY | PW_EQUIPMENT | PW_SPELL | PW_PLAYER);
+    player_ptr->window_flags |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER_LORE | PW_ITEM_KNOWLEDGTE);
     update_playtime();
     handle_stuff(player_ptr);
-    if (player_ptr->prace == player_race_type::ANDROID)
+    if (PlayerRace(player_ptr).equals(PlayerRaceType::ANDROID)) {
         calc_android_exp(player_ptr);
+    }
 
-    term_type *old = Term;
-    for (int j = 0; j < 8; j++) {
-        if (!angband_term[j])
+    term_type *old = game_term;
+    for (auto i = 0U; i < angband_terms.size(); ++i) {
+        if (!angband_terms[i]) {
             continue;
+        }
 
-        term_activate(angband_term[j]);
+        term_activate(angband_terms[i]);
         term_redraw();
         term_fresh();
         term_activate(old);
@@ -71,35 +89,38 @@ void do_cmd_redraw(player_type *player_ptr)
 /*!
  * @brief プレイヤーのステータス表示
  */
-void do_cmd_player_status(player_type *player_ptr)
+void do_cmd_player_status(PlayerType *player_ptr)
 {
     int mode = 0;
     char tmp[160];
     screen_save();
     while (true) {
+        TermCenteredOffsetSetter tcos(MAIN_TERM_MIN_COLS, MAIN_TERM_MIN_ROWS);
+
         update_playtime();
-        display_player(player_ptr, mode);
+        (void)display_player(player_ptr, mode);
 
         if (mode == 5) {
             mode = 0;
-            display_player(player_ptr, mode);
+            (void)display_player(player_ptr, mode);
         }
 
         term_putstr(2, 23, -1, TERM_WHITE,
             _("['c'で名前変更, 'f'でファイルへ書出, 'h'でモード変更, ESCで終了]", "['c' to change name, 'f' to file, 'h' to change mode, or ESC]"));
         char c = inkey();
-        if (c == ESCAPE)
+        if (c == ESCAPE) {
             break;
+        }
 
         if (c == 'c') {
             get_name(player_ptr);
             process_player_name(player_ptr);
         } else if (c == 'f') {
-            sprintf(tmp, "%s.txt", player_ptr->base_name);
+            strnfmt(tmp, sizeof(tmp), "%s.txt", player_ptr->base_name);
             if (get_string(_("ファイル名: ", "File name: "), tmp, 80)) {
                 if (tmp[0] && (tmp[0] != ' ')) {
                     update_playtime();
-                    file_character(player_ptr, tmp, display_player);
+                    file_character(player_ptr, tmp);
                 }
             }
         } else if (c == 'h') {
@@ -112,7 +133,15 @@ void do_cmd_player_status(player_type *player_ptr)
     }
 
     screen_load();
-    player_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
+    auto &rfu = RedrawingFlagsUpdater::get_instance();
+    const auto flags_mwrf = {
+        MainWindowRedrawingFlag::WIPE,
+        MainWindowRedrawingFlag::BASIC,
+        MainWindowRedrawingFlag::EXTRA,
+        MainWindowRedrawingFlag::EQUIPPY,
+        MainWindowRedrawingFlag::MAP,
+    };
+    rfu.set_flags(flags_mwrf);
     handle_stuff(player_ptr);
 }
 
@@ -166,8 +195,9 @@ void do_cmd_messages(int num_now)
         for (j = 0; (j < num_lines) && (i + j < n); j++) {
             concptr msg = message_str(i + j);
             c_prt((i + j < num_now ? TERM_WHITE : TERM_SLATE), msg, num_lines + 1 - j, 0);
-            if (!shower || !shower[0])
+            if (!shower || !shower[0]) {
                 continue;
+            }
 
             concptr str = msg;
             while ((str = angband_strstr(str, shower)) != nullptr) {
@@ -177,24 +207,27 @@ void do_cmd_messages(int num_now)
             }
         }
 
-        for (; j < num_lines; j++)
+        for (; j < num_lines; j++) {
             term_erase(0, num_lines + 1 - j, 255);
+        }
 
         prt(format(_("以前のメッセージ %d-%d 全部で(%d)", "Message Recall (%d-%d of %d)"), i, i + j - 1, n), 0, 0);
         prt(_("[ 'p' で更に古いもの, 'n' で更に新しいもの, '/' で検索, ESC で中断 ]", "[Press 'p' for older, 'n' for newer, ..., or ESCAPE]"), hgt - 1, 0);
         skey = inkey_special(true);
-        if (skey == ESCAPE)
+        if (skey == ESCAPE) {
             break;
+        }
 
         j = i;
         switch (skey) {
         case '=':
             prt(_("強調: ", "Show: "), hgt - 1, 0);
             strcpy(back_str, shower_str);
-            if (askfor(shower_str, 80))
+            if (askfor(shower_str, 80)) {
                 shower = shower_str[0] ? shower_str : nullptr;
-            else
+            } else {
                 strcpy(shower_str, back_str);
+            }
 
             continue;
         case '/':
@@ -231,33 +264,34 @@ void do_cmd_messages(int num_now)
         case SKEY_UP:
         case '\n':
         case '\r':
-            i = MIN(i + 1, n - num_lines);
+            i = std::min(i + 1, n - num_lines);
             break;
         case '+':
-            i = MIN(i + 10, n - num_lines);
+            i = std::min(i + 10, n - num_lines);
             break;
         case 'p':
         case KTRL('P'):
         case ' ':
         case SKEY_PGUP:
-            i = MIN(i + num_lines, n - num_lines);
+            i = std::min(i + num_lines, n - num_lines);
             break;
         case 'n':
         case KTRL('N'):
         case SKEY_PGDOWN:
-            i = MAX(0, i - num_lines);
+            i = std::max(0, i - num_lines);
             break;
         case '-':
-            i = MAX(0, i - 10);
+            i = std::max(0, i - 10);
             break;
         case '2':
         case SKEY_DOWN:
-            i = MAX(0, i - 1);
+            i = std::max(0, i - 1);
             break;
         }
 
-        if (i == j)
+        if (i == j) {
             bell();
+        }
     }
 
     screen_load();