OSDN Git Service

[Refactor] #40521 Moved display_equipment() from player-inventory.c/h to display...
authorHourier <hourier@users.sourceforge.jp>
Thu, 2 Jul 2020 12:16:48 +0000 (21:16 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 2 Jul 2020 12:16:48 +0000 (21:16 +0900)
src/inventory/player-inventory.c
src/inventory/player-inventory.h
src/view/display-sub-windows.c

index 309d0da..5a740ac 100644 (file)
@@ -28,7 +28,7 @@
  * @param i 部位表現を求めるプレイヤーの所持/装備オブジェクトID
  * @return 部位表現の文字列ポインタ
  */
-static concptr mention_use(player_type *owner_ptr, int i)
+concptr mention_use(player_type *owner_ptr, int i)
 {
     concptr p;
 
@@ -93,65 +93,6 @@ static concptr mention_use(player_type *owner_ptr, int i)
 }
 
 /*!
- * @brief 装備アイテム一覧を表示する /
- * Choice window "shadow" of the "show_equip()" function
- * @return なし
- */
-void display_equipment(player_type *owner_ptr, tval_type tval)
-{
-    if (!owner_ptr || !owner_ptr->inventory_list)
-        return;
-
-    TERM_LEN wid, hgt;
-    Term_get_size(&wid, &hgt);
-
-    TERM_COLOR attr = TERM_WHITE;
-    char tmp_val[80];
-    GAME_TEXT o_name[MAX_NLEN];
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
-        object_type *o_ptr;
-        o_ptr = &owner_ptr->inventory_list[i];
-        tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
-        if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(owner_ptr, o_ptr, tval)) {
-            tmp_val[0] = index_to_label(i);
-            tmp_val[1] = ')';
-        }
-
-        Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
-        if ((((i == INVEN_RARM) && owner_ptr->hidarite) || ((i == INVEN_LARM) && owner_ptr->migite)) && owner_ptr->ryoute) {
-            strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
-            attr = TERM_WHITE;
-        } else {
-            object_desc(owner_ptr, o_name, o_ptr, 0);
-            attr = tval_to_attr[o_ptr->tval % 128];
-        }
-
-        int n = strlen(o_name);
-        if (o_ptr->timeout) {
-            attr = TERM_L_DARK;
-        }
-        Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
-
-        Term_erase(3 + n, i - INVEN_RARM, 255);
-
-        if (show_weights) {
-            int wgt = o_ptr->weight * o_ptr->number;
-            sprintf(tmp_val, _("%3d.%1d kg", "%3d.%1d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
-            prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
-        }
-
-        if (show_labels) {
-            Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
-            prt(mention_use(owner_ptr, i), i - INVEN_RARM, wid - 15);
-        }
-    }
-
-    for (int i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++) {
-        Term_erase(0, i, 255);
-    }
-}
-
-/*!
  * @brief 規定の処理にできるアイテムがプレイヤーの利用可能範囲内にあるかどうかを返す /
  * Determine whether get_item() can get some item or not
  * @return アイテムを拾えるならばTRUEを返す。
index b1f8286..122e498 100644 (file)
@@ -4,10 +4,9 @@
 #include "system/angband.h"
 #include "system/object-type-definition.h"
 
+concptr mention_use(player_type *owner_ptr, int i);
 concptr describe_use(player_type *owner_ptr, int i);
-
 void display_inventory(player_type *creature_ptr, tval_type tval);
-void display_equipment(player_type *creature_ptr, tval_type tval);
 COMMAND_CODE show_inventory(player_type *owner_ptr, int target_item, BIT_FLAGS mode, tval_type tval);
 COMMAND_CODE show_equipment(player_type *owner_ptr, int target_item, BIT_FLAGS mode, tval_type tval);
 bool can_get_item(player_type *owner_ptr, tval_type tval);
index 536483a..6e5521d 100644 (file)
@@ -2,8 +2,10 @@
 #include "floor/floor.h"
 #include "game-option/option-flags.h"
 #include "game-option/special-options.h"
+#include "game-option/text-display-options.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
+#include "inventory/inventory-util.h"
 #include "inventory/player-inventory.h"
 #include "io/input-key-processor.h"
 #include "io/targeting.h"
 #include "monster-race/race-flags1.h"
 #include "monster/monster-flag-types.h"
 #include "monster/monster-info.h"
+#include "object/item-tester-hooker.h"
+#include "object/object-flavor.h"
+#include "object/object-info.h"
 #include "spell/spells3.h"
 #include "system/monster-type-definition.h"
 #include "term/gameterm.h"
+#include "term/screen-processor.h"
 #include "term/term-color-types.h"
+#include "view/display-lore.h"
 #include "view/display-map.h"
 #include "view/display-messages.h"
-#include "view/display-lore.h"
 #include "view/display-player.h"
 #include "view/main-window-util.h"
 #include "view/object-describer.h"
@@ -180,6 +186,62 @@ void fix_monster_list(player_type *player_ptr)
 }
 
 /*!
+ * @brief 装備アイテム一覧を表示する /
+ * Choice window "shadow" of the "show_equip()" function
+ * @return なし
+ */
+static void display_equipment(player_type *owner_ptr, tval_type tval)
+{
+    if (!owner_ptr || !owner_ptr->inventory_list)
+        return;
+
+    TERM_LEN wid, hgt;
+    Term_get_size(&wid, &hgt);
+
+    TERM_COLOR attr = TERM_WHITE;
+    char tmp_val[80];
+    GAME_TEXT o_name[MAX_NLEN];
+    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        object_type *o_ptr;
+        o_ptr = &owner_ptr->inventory_list[i];
+        tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
+        if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(owner_ptr, o_ptr, tval)) {
+            tmp_val[0] = index_to_label(i);
+            tmp_val[1] = ')';
+        }
+
+        Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
+        if ((((i == INVEN_RARM) && owner_ptr->hidarite) || ((i == INVEN_LARM) && owner_ptr->migite)) && owner_ptr->ryoute) {
+            strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
+            attr = TERM_WHITE;
+        } else {
+            object_desc(owner_ptr, o_name, o_ptr, 0);
+            attr = tval_to_attr[o_ptr->tval % 128];
+        }
+
+        int n = strlen(o_name);
+        if (o_ptr->timeout)
+            attr = TERM_L_DARK;
+
+        Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
+        Term_erase(3 + n, i - INVEN_RARM, 255);
+        if (show_weights) {
+            int wgt = o_ptr->weight * o_ptr->number;
+            sprintf(tmp_val, _("%3d.%1d kg", "%3d.%1d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
+            prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
+        }
+
+        if (show_labels) {
+            Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
+            prt(mention_use(owner_ptr, i), i - INVEN_RARM, wid - 15);
+        }
+    }
+
+    for (int i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
+        Term_erase(0, i, 255);
+}
+
+/*!
  * @brief 現在の装備品をサブウィンドウに表示する /
  * Hack -- display equipment in sub-windows
  * @param player_ptr プレーヤーへの参照ポインタ