OSDN Git Service

[Refactor] #40521 Separated inventory-describer.c/h from player-inventory.c/h
authorHourier <hourier@users.sourceforge.jp>
Thu, 2 Jul 2020 13:00:36 +0000 (22:00 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 2 Jul 2020 13:00:36 +0000 (22:00 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd-item/cmd-item.c
src/inventory/inventory-describer.c [new file with mode: 0644]
src/inventory/inventory-describer.h [new file with mode: 0644]
src/inventory/player-inventory.c
src/inventory/player-inventory.h
src/perception/simple-perception.c
src/spell-kind/spells-perception.c
src/view/display-sub-windows.c

index 32b3250..e9614f9 100644 (file)
     <ClCompile Include="..\..\src\info-reader\skill-reader.c" />\r
     <ClCompile Include="..\..\src\info-reader\vault-reader.c" />\r
     <ClCompile Include="..\..\src\inventory\floor-item-getter.c" />\r
+    <ClCompile Include="..\..\src\inventory\inventory-describer.c" />\r
     <ClCompile Include="..\..\src\inventory\inventory-util.c" />\r
     <ClCompile Include="..\..\src\inventory\item-getter.c" />\r
     <ClCompile Include="..\..\src\io\command-repeater.c" />\r
     <ClInclude Include="..\..\src\info-reader\skill-reader.h" />\r
     <ClInclude Include="..\..\src\info-reader\vault-reader.h" />\r
     <ClInclude Include="..\..\src\inventory\floor-item-getter.h" />\r
+    <ClInclude Include="..\..\src\inventory\inventory-describer.h" />\r
     <ClInclude Include="..\..\src\inventory\inventory-util.h" />\r
     <ClInclude Include="..\..\src\inventory\item-getter.h" />\r
     <ClInclude Include="..\..\src\io\command-repeater.h" />\r
index 4a626cd..f938909 100644 (file)
     <ClCompile Include="..\..\src\floor\object-scanner.c">
       <Filter>floor</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\inventory\inventory-describer.c">
+      <Filter>inventory</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\floor\object-scanner.h">
       <Filter>floor</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\inventory\inventory-describer.h">
+      <Filter>inventory</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index abaf3e6..cd8b8dc 100644 (file)
@@ -207,6 +207,7 @@ hengband_SOURCES = \
        inventory/floor-item-getter.c inventory/floor-item-getter.h \
        inventory/inventory-curse.c inventory/inventory-curse.h \
        inventory/inventory-damage.c inventory/inventory-damage.h \
+       inventory/inventory-describer.c inventory/inventory-describer.h \
        inventory/inventory-object.c inventory/inventory-object.h \
        inventory/inventory-util.c inventory/inventory-util.h \
        inventory/item-getter.c inventory/item-getter.h \
index 34ea95c..42e5f91 100644 (file)
@@ -29,6 +29,7 @@
 #include "game-option/birth-options.h"
 #include "game-option/input-options.h"
 #include "game-option/keymap-directory-getter.h"
+#include "inventory/inventory-describer.h"
 #include "inventory/inventory-object.h"
 #include "inventory/player-inventory.h"
 #include "io/cursor.h"
diff --git a/src/inventory/inventory-describer.c b/src/inventory/inventory-describer.c
new file mode 100644 (file)
index 0000000..d33c77a
--- /dev/null
@@ -0,0 +1,149 @@
+#include "inventory/inventory-describer.h"
+#include "game-option/birth-options.h"
+#include "system/object-type-definition.h"
+
+/*!
+ * @brief 所持/装備オブジェクトIDの部位表現を返す /
+ * Return a string mentioning how a given item is carried
+ * @param owner_ptr プレーヤーへの参照ポインタ
+ * @param i 部位表現を求めるプレイヤーの所持/装備オブジェクトID
+ * @return 部位表現の文字列ポインタ
+ */
+concptr mention_use(player_type *owner_ptr, int i)
+{
+    concptr p;
+
+    /* Examine the location */
+    switch (i) {
+#ifdef JP
+    case INVEN_RARM:
+        p = owner_ptr->heavy_wield[0] ? "運搬中" : ((owner_ptr->ryoute && owner_ptr->migite) ? " 両手" : (left_hander ? " 左手" : " 右手"));
+        break;
+#else
+    case INVEN_RARM:
+        p = owner_ptr->heavy_wield[0] ? "Just lifting" : (owner_ptr->migite ? "Wielding" : "On arm");
+        break;
+#endif
+
+#ifdef JP
+    case INVEN_LARM:
+        p = owner_ptr->heavy_wield[1] ? "運搬中" : ((owner_ptr->ryoute && owner_ptr->hidarite) ? " 両手" : (left_hander ? " 右手" : " 左手"));
+        break;
+#else
+    case INVEN_LARM:
+        p = owner_ptr->heavy_wield[1] ? "Just lifting" : (owner_ptr->hidarite ? "Wielding" : "On arm");
+        break;
+#endif
+
+    case INVEN_BOW:
+        p = (adj_str_hold[owner_ptr->stat_ind[A_STR]] < owner_ptr->inventory_list[i].weight / 10) ? _("運搬中", "Just holding") : _("射撃用", "Shooting");
+        break;
+    case INVEN_RIGHT:
+        p = (left_hander ? _("左手指", "On left hand") : _("右手指", "On right hand"));
+        break;
+    case INVEN_LEFT:
+        p = (left_hander ? _("右手指", "On right hand") : _("左手指", "On left hand"));
+        break;
+    case INVEN_NECK:
+        p = _("  首", "Around neck");
+        break;
+    case INVEN_LITE:
+        p = _(" 光源", "Light source");
+        break;
+    case INVEN_BODY:
+        p = _("  体", "On body");
+        break;
+    case INVEN_OUTER:
+        p = _("体の上", "About body");
+        break;
+    case INVEN_HEAD:
+        p = _("  頭", "On head");
+        break;
+    case INVEN_HANDS:
+        p = _("  手", "On hands");
+        break;
+    case INVEN_FEET:
+        p = _("  足", "On feet");
+        break;
+    default:
+        p = _("ザック", "In pack");
+        break;
+    }
+
+    return p;
+}
+
+/*!
+ * @brief 所持/装備オブジェクトIDの現在の扱い方の状態表現を返す /
+ * Return a string describing how a given item is being worn.
+ * @param i 状態表現を求めるプレイヤーの所持/装備オブジェクトID
+ * @return 状態表現内容の文字列ポインタ
+ * @details
+ * Currently, only used for items in the equipment, inventory.
+ */
+concptr describe_use(player_type *owner_ptr, int i)
+{
+    concptr p;
+    switch (i) {
+#ifdef JP
+    case INVEN_RARM:
+        p = owner_ptr->heavy_wield[0]
+            ? "運搬中の"
+            : ((owner_ptr->ryoute && owner_ptr->migite) ? "両手に装備している" : (left_hander ? "左手に装備している" : "右手に装備している"));
+        break;
+#else
+    case INVEN_RARM:
+        p = owner_ptr->heavy_wield[0] ? "just lifting" : (owner_ptr->migite ? "attacking monsters with" : "wearing on your arm");
+        break;
+#endif
+
+#ifdef JP
+    case INVEN_LARM:
+        p = owner_ptr->heavy_wield[1]
+            ? "運搬中の"
+            : ((owner_ptr->ryoute && owner_ptr->hidarite) ? "両手に装備している" : (left_hander ? "右手に装備している" : "左手に装備している"));
+        break;
+#else
+    case INVEN_LARM:
+        p = owner_ptr->heavy_wield[1] ? "just lifting" : (owner_ptr->hidarite ? "attacking monsters with" : "wearing on your arm");
+        break;
+#endif
+
+    case INVEN_BOW:
+        p = (adj_str_hold[owner_ptr->stat_ind[A_STR]] < owner_ptr->inventory_list[i].weight / 10) ? _("持つだけで精一杯の", "just holding")
+                                                                                                  : _("射撃用に装備している", "shooting missiles with");
+        break;
+    case INVEN_RIGHT:
+        p = (left_hander ? _("左手の指にはめている", "wearing on your left hand") : _("右手の指にはめている", "wearing on your right hand"));
+        break;
+    case INVEN_LEFT:
+        p = (left_hander ? _("右手の指にはめている", "wearing on your right hand") : _("左手の指にはめている", "wearing on your left hand"));
+        break;
+    case INVEN_NECK:
+        p = _("首にかけている", "wearing around your neck");
+        break;
+    case INVEN_LITE:
+        p = _("光源にしている", "using to light the way");
+        break;
+    case INVEN_BODY:
+        p = _("体に着ている", "wearing on your body");
+        break;
+    case INVEN_OUTER:
+        p = _("身にまとっている", "wearing on your back");
+        break;
+    case INVEN_HEAD:
+        p = _("頭にかぶっている", "wearing on your head");
+        break;
+    case INVEN_HANDS:
+        p = _("手につけている", "wearing on your hands");
+        break;
+    case INVEN_FEET:
+        p = _("足にはいている", "wearing on your feet");
+        break;
+    default:
+        p = _("ザックに入っている", "carrying in your pack");
+        break;
+    }
+
+    return p;
+}
diff --git a/src/inventory/inventory-describer.h b/src/inventory/inventory-describer.h
new file mode 100644 (file)
index 0000000..9e437a9
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma once
+
+#include "system/angband.h"
+
+concptr mention_use(player_type *owner_ptr, int i);
+concptr describe_use(player_type *owner_ptr, int i);
index 946b0b5..18789f1 100644 (file)
@@ -7,6 +7,7 @@
 #include "game-option/special-options.h"
 #include "game-option/text-display-options.h"
 #include "grid/grid.h"
+#include "inventory/inventory-describer.h"
 #include "inventory/inventory-object.h"
 #include "inventory/inventory-util.h"
 #include "io/input-key-requester.h"
 #include "view/display-messages.h"
 
 /*!
- * @brief 所持/装備オブジェクトIDの部位表現を返す /
- * Return a string mentioning how a given item is carried
- * @param owner_ptr プレーヤーへの参照ポインタ
- * @param i 部位表現を求めるプレイヤーの所持/装備オブジェクトID
- * @return 部位表現の文字列ポインタ
- */
-concptr mention_use(player_type *owner_ptr, int i)
-{
-    concptr p;
-
-    /* Examine the location */
-    switch (i) {
-#ifdef JP
-    case INVEN_RARM:
-        p = owner_ptr->heavy_wield[0] ? "運搬中" : ((owner_ptr->ryoute && owner_ptr->migite) ? " 両手" : (left_hander ? " 左手" : " 右手"));
-        break;
-#else
-    case INVEN_RARM:
-        p = owner_ptr->heavy_wield[0] ? "Just lifting" : (owner_ptr->migite ? "Wielding" : "On arm");
-        break;
-#endif
-
-#ifdef JP
-    case INVEN_LARM:
-        p = owner_ptr->heavy_wield[1] ? "運搬中" : ((owner_ptr->ryoute && owner_ptr->hidarite) ? " 両手" : (left_hander ? " 右手" : " 左手"));
-        break;
-#else
-    case INVEN_LARM:
-        p = owner_ptr->heavy_wield[1] ? "Just lifting" : (owner_ptr->hidarite ? "Wielding" : "On arm");
-        break;
-#endif
-
-    case INVEN_BOW:
-        p = (adj_str_hold[owner_ptr->stat_ind[A_STR]] < owner_ptr->inventory_list[i].weight / 10) ? _("運搬中", "Just holding") : _("射撃用", "Shooting");
-        break;
-    case INVEN_RIGHT:
-        p = (left_hander ? _("左手指", "On left hand") : _("右手指", "On right hand"));
-        break;
-    case INVEN_LEFT:
-        p = (left_hander ? _("右手指", "On right hand") : _("左手指", "On left hand"));
-        break;
-    case INVEN_NECK:
-        p = _("  首", "Around neck");
-        break;
-    case INVEN_LITE:
-        p = _(" 光源", "Light source");
-        break;
-    case INVEN_BODY:
-        p = _("  体", "On body");
-        break;
-    case INVEN_OUTER:
-        p = _("体の上", "About body");
-        break;
-    case INVEN_HEAD:
-        p = _("  頭", "On head");
-        break;
-    case INVEN_HANDS:
-        p = _("  手", "On hands");
-        break;
-    case INVEN_FEET:
-        p = _("  足", "On feet");
-        break;
-    default:
-        p = _("ザック", "In pack");
-        break;
-    }
-
-    return p;
-}
-
-/*!
  * @brief 規定の処理にできるアイテムがプレイヤーの利用可能範囲内にあるかどうかを返す /
  * Determine whether get_item() can get some item or not
  * @return アイテムを拾えるならばTRUEを返す。
@@ -485,78 +415,3 @@ COMMAND_CODE show_equipment(player_type *owner_ptr, int target_item, BIT_FLAGS m
     command_gap = col;
     return target_item_label;
 }
-
-/*!
- * @brief 所持/装備オブジェクトIDの現在の扱い方の状態表現を返す /
- * Return a string describing how a given item is being worn.
- * @param i 状態表現を求めるプレイヤーの所持/装備オブジェクトID
- * @return 状態表現内容の文字列ポインタ
- * @details
- * Currently, only used for items in the equipment, inventory.
- */
-concptr describe_use(player_type *owner_ptr, int i)
-{
-    concptr p;
-    switch (i) {
-#ifdef JP
-    case INVEN_RARM:
-        p = owner_ptr->heavy_wield[0]
-            ? "運搬中の"
-            : ((owner_ptr->ryoute && owner_ptr->migite) ? "両手に装備している" : (left_hander ? "左手に装備している" : "右手に装備している"));
-        break;
-#else
-    case INVEN_RARM:
-        p = owner_ptr->heavy_wield[0] ? "just lifting" : (owner_ptr->migite ? "attacking monsters with" : "wearing on your arm");
-        break;
-#endif
-
-#ifdef JP
-    case INVEN_LARM:
-        p = owner_ptr->heavy_wield[1]
-            ? "運搬中の"
-            : ((owner_ptr->ryoute && owner_ptr->hidarite) ? "両手に装備している" : (left_hander ? "右手に装備している" : "左手に装備している"));
-        break;
-#else
-    case INVEN_LARM:
-        p = owner_ptr->heavy_wield[1] ? "just lifting" : (owner_ptr->hidarite ? "attacking monsters with" : "wearing on your arm");
-        break;
-#endif
-
-    case INVEN_BOW:
-        p = (adj_str_hold[owner_ptr->stat_ind[A_STR]] < owner_ptr->inventory_list[i].weight / 10) ? _("持つだけで精一杯の", "just holding")
-                                                                                                  : _("射撃用に装備している", "shooting missiles with");
-        break;
-    case INVEN_RIGHT:
-        p = (left_hander ? _("左手の指にはめている", "wearing on your left hand") : _("右手の指にはめている", "wearing on your right hand"));
-        break;
-    case INVEN_LEFT:
-        p = (left_hander ? _("右手の指にはめている", "wearing on your right hand") : _("左手の指にはめている", "wearing on your left hand"));
-        break;
-    case INVEN_NECK:
-        p = _("首にかけている", "wearing around your neck");
-        break;
-    case INVEN_LITE:
-        p = _("光源にしている", "using to light the way");
-        break;
-    case INVEN_BODY:
-        p = _("体に着ている", "wearing on your body");
-        break;
-    case INVEN_OUTER:
-        p = _("身にまとっている", "wearing on your back");
-        break;
-    case INVEN_HEAD:
-        p = _("頭にかぶっている", "wearing on your head");
-        break;
-    case INVEN_HANDS:
-        p = _("手につけている", "wearing on your hands");
-        break;
-    case INVEN_FEET:
-        p = _("足にはいている", "wearing on your feet");
-        break;
-    default:
-        p = _("ザックに入っている", "carrying in your pack");
-        break;
-    }
-
-    return p;
-}
index a1fc354..d122f2f 100644 (file)
@@ -4,8 +4,6 @@
 #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);
 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);
index e9dcb7b..33c8e81 100644 (file)
@@ -8,7 +8,7 @@
 #include "autopick/autopick.h"
 #include "game-option/auto-destruction-options.h"
 #include "game-option/disturbance-options.h"
-#include "inventory/player-inventory.h"
+#include "inventory/inventory-describer.h"
 #include "object-enchant/special-object-flags.h"
 #include "object-hook/hook-checker.h"
 #include "object-hook/hook-enchant.h"
index e354779..9cb4d3b 100644 (file)
@@ -4,6 +4,7 @@
 #include "floor/floor-object.h"
 #include "game-option/auto-destruction-options.h"
 #include "game-option/play-record-options.h"
+#include "inventory/inventory-describer.h"
 #include "inventory/player-inventory.h"
 #include "io/write-diary.h"
 #include "object-enchant/special-object-flags.h"
index 6e5521d..928efe4 100644 (file)
@@ -5,6 +5,7 @@
 #include "game-option/text-display-options.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
+#include "inventory/inventory-describer.h"
 #include "inventory/inventory-util.h"
 #include "inventory/player-inventory.h"
 #include "io/input-key-processor.h"