OSDN Git Service

[Refactor] #39962 files.c からdisplay-util.c/h を分離 / Separated display-util.c/h from...
authorHourier <hourier@users.sourceforge.jp>
Sun, 23 Feb 2020 15:24:26 +0000 (00:24 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 23 Feb 2020 15:24:46 +0000 (00:24 +0900)
Hengband_vcs2017/Hengband/Hengband.vcxproj
Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
src/files.c
src/view/display-util.c [new file with mode: 0644]
src/view/display-util.h [new file with mode: 0644]
src/view/status-first-page.c
src/view/status-first-page.h

index 2ca7f04..9de95fb 100644 (file)
     <ClCompile Include="..\..\src\spells1.c" />\r
     <ClCompile Include="..\..\src\spells2.c" />\r
     <ClCompile Include="..\..\src\spells3.c" />\r
+    <ClCompile Include="..\..\src\view\display-util.c" />\r
     <ClCompile Include="..\..\src\view\status-first-page.c" />\r
     <ClCompile Include="..\..\src\store.c" />\r
     <ClCompile Include="..\..\src\floor-streams.c" />\r
     <ClInclude Include="..\..\src\object-flavor.h" />\r
     <ClInclude Include="..\..\src\player-inventory.h" />\r
     <ClInclude Include="..\..\src\signal-handlers.h" />\r
+    <ClInclude Include="..\..\src\view\display-util.h" />\r
     <ClInclude Include="..\..\src\view\status-first-page.h" />\r
     <ClInclude Include="japanese.h" />\r
   </ItemGroup>\r
index 76a84fb..721d565 100644 (file)
     <ClCompile Include="..\..\src\view\status-first-page.c">
       <Filter>view</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\view\display-util.c">
+      <Filter>view</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\view\status-first-page.h">
       <Filter>view</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\view\display-util.h">
+      <Filter>view</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 2ae404a..49368c9 100644 (file)
@@ -13,7 +13,9 @@
  */
 
 #include "angband.h"
+#include "term.h"
 #include "signal-handlers.h"
+#include "view/display-util.h"
 #include "view/status-first-page.h"
 #include "util.h"
 #include "files.h"
@@ -1108,144 +1110,6 @@ errr process_pref_file(player_type *creature_ptr, concptr name)
        return err2;
 }
 
-static struct
-{
-       int col;
-       int row;
-       int len;
-       char header[20];
-} disp_player_line[]
-#ifdef JP
-= {
-       { 1, 10, 25, "打撃修正(格闘)"},
-       { 1, 10, 25, "打撃修正(両手)"},
-       { 1, 10, 25, "打撃修正(右手)"},
-       { 1, 10, 25, "打撃修正(左手)"},
-       { 1, 11, 25, "打撃修正(左手)"},
-       { 1, 11, 25, "打撃修正(右手)"},
-       { 1, 11, 25, ""},
-       { 1, 15, 25, "射撃攻撃修正"},
-       { 1, 16, 25, "射撃武器倍率"},
-       { 1, 20, 25, "加速"},
-       { 1, 19, 25, "AC"},
-       {29, 13, 21, "レベル"},
-       {29, 14, 21, "経験値"},
-       {29, 15, 21, "最大経験"},
-       {29, 16, 21, "次レベル"},
-       {29, 17, 21, "所持金"},
-       {29, 19, 21, "日付"},
-       {29, 10, 21, "HP"},
-       {29, 11, 21, "MP"},
-       {29, 20, 21, "プレイ時間"},
-       {53, 10, -1, "打撃命中  :"},
-       {53, 11, -1, "射撃命中  :"},
-       {53, 12, -1, "魔法防御  :"},
-       {53, 13, -1, "隠密行動  :"},
-       {53, 15, -1, "知覚      :"},
-       {53, 16, -1, "探索      :"},
-       {53, 17, -1, "解除      :"},
-       {53, 18, -1, "魔法道具  :"},
-       { 1, 12, 25, "打撃回数"},
-       { 1, 17, 25, "射撃回数"},
-       { 1, 13, 25, "平均ダメージ"},
-       {53, 20, -1, "赤外線視力:"},
-       {26,  1, -1, "名前  : "},
-       { 1,  3, -1, "性別     : "},
-       { 1,  4, -1, "種族     : "},
-       { 1,  5, -1, "職業     : "},
-       { 1,  6, -1, "魔法     : "},
-       { 1,  7, -1, "守護魔神 : "},
-       {29,  3, 21, "年齢"},
-       {29,  4, 21, "身長"},
-       {29,  5, 21, "体重"},
-       {29,  6, 21, "社会的地位"},
-       {29,  7, 21, "属性"},
-       {29, 14, 21, "強化度"},
-       {29, 16, 21, "次レベル"},
-       {53, 19, -1, "掘削      :" },
-};
-#else
-= {
-       { 1, 10, 25, "Bare hand"},
-       { 1, 10, 25, "Two hands"},
-       { 1, 10, 25, "Right hand"},
-       { 1, 10, 25, "Left hand"},
-       { 1, 11, 25, "Left hand"},
-       { 1, 11, 25, "Right hand"},
-       { 1, 11, 25, "Posture"},
-       { 1, 15, 25, "Shooting"},
-       { 1, 16, 25, "Multiplier"},
-       { 1, 20, 25, "Speed"},
-       { 1, 19, 25, "AC"},
-       {29, 13, 21, "Level"},
-       {29, 14, 21, "Experience"},
-       {29, 15, 21, "Max Exp"},
-       {29, 16, 21, "Exp to Adv"},
-       {29, 17, 21, "Gold"},
-       {29, 19, 21, "Time"},
-       {29, 10, 21, "Hit point"},
-       {29, 11, 21, "SP (Mana)"},
-       {29, 20, 21, "Play time"},
-       {53, 10, -1, "Fighting   : "},
-       {53, 11, -1, "Bows/Throw : "},
-       {53, 12, -1, "SavingThrow: "},
-       {53, 13, -1, "Stealth    : "},
-       {53, 15, -1, "Perception : "},
-       {53, 16, -1, "Searching  : "},
-       {53, 17, -1, "Disarming  : "},
-       {53, 18, -1, "MagicDevice: "},
-       { 1, 12, 25, "Blows/Round"},
-       { 1, 17, 25, "Shots/Round"},
-       { 1, 13, 25, "AverageDmg/Rnd"},
-       {53, 20, -1, "Infravision: "},
-       {26,  1, -1, "Name  : "},
-       { 1,  3, -1, "Sex      : "},
-       { 1,  4, -1, "Race     : "},
-       { 1,  5, -1, "Class    : "},
-       { 1,  6, -1, "Magic    : "},
-       { 1,  7, -1, "Patron   : "},
-       {29,  3, 21, "Age"},
-       {29,  4, 21, "Height"},
-       {29,  5, 21, "Weight"},
-       {29,  6, 21, "Social Class"},
-       {29,  7, 21, "Align"},
-       {29, 14, 21, "Construction"},
-       {29, 16, 21, "Const to Adv"},
-       {53, 19, -1, "Digging    : " },
-};
-#endif
-
-
-/*!
- * @brief プレイヤーのステータス1種を出力する
- * @param entry 項目ID
- * @param val 値を保管した文字列ポインタ
- * @param attr 項目表示の色
- * @return なし
- */
-static void display_player_one_line(int entry, concptr val, TERM_COLOR attr)
-{
-       concptr head = disp_player_line[entry].header;
-       int head_len = strlen(head);
-       int row = disp_player_line[entry].row;
-       int col = disp_player_line[entry].col;
-       int len = disp_player_line[entry].len;
-       Term_putstr(col, row, -1, TERM_WHITE, head);
-
-       if (!val) return;
-
-       if (len <= 0)
-       {
-               Term_putstr(col + head_len, row, -1, attr, val);
-               return;
-       }
-
-       int val_len = len - head_len;
-       char buf[40];
-       sprintf(buf, "%*.*s", val_len, val_len, val);
-       Term_putstr(col + head_len, row, -1, attr, buf);
-}
-
 
 /*!
  * @brief プレイヤーの打撃能力修正を表示する
@@ -3082,7 +2946,7 @@ void display_player(player_type *creature_ptr, int mode)
        if (mode == 0)
        {
                display_player_middle(creature_ptr);
-               display_player_various(creature_ptr, display_player_one_line);
+               display_player_various(creature_ptr);
                return;
        }
 
diff --git a/src/view/display-util.c b/src/view/display-util.c
new file mode 100644 (file)
index 0000000..97d8243
--- /dev/null
@@ -0,0 +1,140 @@
+#include "display-util.h"
+#include "term.h"
+
+static struct
+{
+       int col;
+       int row;
+       int len;
+       char header[20];
+} disp_player_line[]
+#ifdef JP
+= {
+       { 1, 10, 25, "\91Å\8c\82\8fC\90³(\8ai\93¬)"},
+       { 1, 10, 25, "\91Å\8c\82\8fC\90³(\97¼\8eè)"},
+       { 1, 10, 25, "\91Å\8c\82\8fC\90³(\89E\8eè)"},
+       { 1, 10, 25, "\91Å\8c\82\8fC\90³(\8d\8eè)"},
+       { 1, 11, 25, "\91Å\8c\82\8fC\90³(\8d\8eè)"},
+       { 1, 11, 25, "\91Å\8c\82\8fC\90³(\89E\8eè)"},
+       { 1, 11, 25, ""},
+       { 1, 15, 25, "\8eË\8c\82\8dU\8c\82\8fC\90³"},
+       { 1, 16, 25, "\8eË\8c\82\95\90\8aí\94{\97¦"},
+       { 1, 20, 25, "\89Á\91¬"},
+       { 1, 19, 25, "\82`\82b"},
+       {29, 13, 21, "\83\8c\83x\83\8b"},
+       {29, 14, 21, "\8co\8c±\92l"},
+       {29, 15, 21, "\8dÅ\91å\8co\8c±"},
+       {29, 16, 21, "\8e\9f\83\8c\83x\83\8b"},
+       {29, 17, 21, "\8f\8a\8e\9d\8bà"},
+       {29, 19, 21, "\93ú\95t"},
+       {29, 10, 21, "\82g\82o"},
+       {29, 11, 21, "\82l\82o"},
+       {29, 20, 21, "\83v\83\8c\83C\8e\9e\8aÔ"},
+       {53, 10, -1, "\91Å\8c\82\96½\92\86  :"},
+       {53, 11, -1, "\8eË\8c\82\96½\92\86  :"},
+       {53, 12, -1, "\96\82\96@\96h\8cä  :"},
+       {53, 13, -1, "\89B\96§\8ds\93®  :"},
+       {53, 15, -1, "\92m\8ao      :"},
+       {53, 16, -1, "\92T\8dõ      :"},
+       {53, 17, -1, "\89ð\8f\9c      :"},
+       {53, 18, -1, "\96\82\96@\93¹\8bï  :"},
+       { 1, 12, 25, "\91Å\8c\82\89ñ\90\94"},
+       { 1, 17, 25, "\8eË\8c\82\89ñ\90\94"},
+       { 1, 13, 25, "\95½\8bÏ\83_\83\81\81[\83W"},
+       {53, 20, -1, "\90Ô\8aO\90ü\8e\8b\97Í:"},
+       {26,  1, -1, "\96¼\91O  : "},
+       { 1,  3, -1, "\90«\95Ê     : "},
+       { 1,  4, -1, "\8eí\91°     : "},
+       { 1,  5, -1, "\90E\8bÆ     : "},
+       { 1,  6, -1, "\96\82\96@     : "},
+       { 1,  7, -1, "\8eç\8cì\96\82\90_ : "},
+       {29,  3, 21, "\94N\97î"},
+       {29,  4, 21, "\90g\92·"},
+       {29,  5, 21, "\91Ì\8fd"},
+       {29,  6, 21, "\8eÐ\89ï\93I\92n\88Ê"},
+       {29,  7, 21, "\91®\90«"},
+       {29, 14, 21, "\8b­\89»\93x"},
+       {29, 16, 21, "\8e\9f\83\8c\83x\83\8b"},
+       {53, 19, -1, "\8c@\8dí      :" },
+};
+#else
+= {
+       { 1, 10, 25, "Bare hand"},
+       { 1, 10, 25, "Two hands"},
+       { 1, 10, 25, "Right hand"},
+       { 1, 10, 25, "Left hand"},
+       { 1, 11, 25, "Left hand"},
+       { 1, 11, 25, "Right hand"},
+       { 1, 11, 25, "Posture"},
+       { 1, 15, 25, "Shooting"},
+       { 1, 16, 25, "Multiplier"},
+       { 1, 20, 25, "Speed"},
+       { 1, 19, 25, "AC"},
+       {29, 13, 21, "Level"},
+       {29, 14, 21, "Experience"},
+       {29, 15, 21, "Max Exp"},
+       {29, 16, 21, "Exp to Adv"},
+       {29, 17, 21, "Gold"},
+       {29, 19, 21, "Time"},
+       {29, 10, 21, "Hit point"},
+       {29, 11, 21, "SP (Mana)"},
+       {29, 20, 21, "Play time"},
+       {53, 10, -1, "Fighting   : "},
+       {53, 11, -1, "Bows/Throw : "},
+       {53, 12, -1, "SavingThrow: "},
+       {53, 13, -1, "Stealth    : "},
+       {53, 15, -1, "Perception : "},
+       {53, 16, -1, "Searching  : "},
+       {53, 17, -1, "Disarming  : "},
+       {53, 18, -1, "MagicDevice: "},
+       { 1, 12, 25, "Blows/Round"},
+       { 1, 17, 25, "Shots/Round"},
+       { 1, 13, 25, "AverageDmg/Rnd"},
+       {53, 20, -1, "Infravision: "},
+       {26,  1, -1, "Name  : "},
+       { 1,  3, -1, "Sex      : "},
+       { 1,  4, -1, "Race     : "},
+       { 1,  5, -1, "Class    : "},
+       { 1,  6, -1, "Magic    : "},
+       { 1,  7, -1, "Patron   : "},
+       {29,  3, 21, "Age"},
+       {29,  4, 21, "Height"},
+       {29,  5, 21, "Weight"},
+       {29,  6, 21, "Social Class"},
+       {29,  7, 21, "Align"},
+       {29, 14, 21, "Construction"},
+       {29, 16, 21, "Const to Adv"},
+       {53, 19, -1, "Digging    : " },
+};
+#endif
+
+
+/*!
+ * @brief \83v\83\8c\83C\83\84\81[\82Ì\83X\83e\81[\83^\83X1\8eí\82ð\8fo\97Í\82·\82é
+ * @param entry \8d\80\96ÚID
+ * @param val \92l\82ð\95Û\8aÇ\82µ\82½\95\8e\9a\97ñ\83|\83C\83\93\83^
+ * @param attr \8d\80\96Ú\95\\8e¦\82Ì\90F
+ * @return \82È\82µ
+ */
+void display_player_one_line(int entry, concptr val, TERM_COLOR attr)
+{
+       concptr head = disp_player_line[entry].header;
+       int head_len = strlen(head);
+       int row = disp_player_line[entry].row;
+       int col = disp_player_line[entry].col;
+       int len = disp_player_line[entry].len;
+       Term_putstr(col, row, -1, TERM_WHITE, head);
+
+       if (!val) return;
+
+       if (len <= 0)
+       {
+               Term_putstr(col + head_len, row, -1, attr, val);
+               return;
+       }
+
+       int val_len = len - head_len;
+       char buf[40];
+       sprintf(buf, "%*.*s", val_len, val_len, val);
+       Term_putstr(col + head_len, row, -1, attr, buf);
+}
diff --git a/src/view/display-util.h b/src/view/display-util.h
new file mode 100644 (file)
index 0000000..20fb29e
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "angband.h"
+
+void display_player_one_line(int entry, concptr val, TERM_COLOR attr);
index 0796cac..10af521 100644 (file)
@@ -6,7 +6,9 @@
  */
 
 #include "angband.h"
+#include "term.h"
 #include "status-first-page.h"
+#include "display-util.h"
 #include "artifact.h"
 #include "combat/melee.h"
 #include "combat/shoot.h"
@@ -290,7 +292,7 @@ static void calc_two_hands(player_type *creature_ptr, int *damage, int *to_h)
  * @param display_player_one_line 1\8ds\95\\8e¦\97p\82Ì\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94
  * @return \82È\82µ
  */
-static void display_first_page(player_type *creature_ptr, int xthb, int *damage, int shots, int shot_frac, void(*display_player_one_line)(int, concptr, TERM_COLOR))
+static void display_first_page(player_type *creature_ptr, int xthb, int *damage, int shots, int shot_frac)
 {
        int xthn = creature_ptr->skill_thn + (creature_ptr->to_h_m * BTH_PLUS_ADJ);
 
@@ -312,49 +314,49 @@ static void display_first_page(player_type *creature_ptr, int xthb, int *damage,
        int xdig = creature_ptr->skill_dig;
 
        concptr desc = likert(xthn, 12);
-       (*display_player_one_line)(ENTRY_SKILL_FIGHT, desc, likert_color);
+       display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
 
        desc = likert(xthb, 12);
-       (*display_player_one_line)(ENTRY_SKILL_SHOOT, desc, likert_color);
+       display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
 
        desc = likert(xsav, 7);
-       (*display_player_one_line)(ENTRY_SKILL_SAVING, desc, likert_color);
+       display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
 
        desc = likert((xstl > 0) ? xstl : -1, 1);
-       (*display_player_one_line)(ENTRY_SKILL_STEALTH, desc, likert_color);
+       display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
 
        desc = likert(xfos, 6);
-       (*display_player_one_line)(ENTRY_SKILL_PERCEP, desc, likert_color);
+       display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
 
        desc = likert(xsrh, 6);
-       (*display_player_one_line)(ENTRY_SKILL_SEARCH, desc, likert_color);
+       display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
 
        desc = likert(xdis, 8);
-       (*display_player_one_line)(ENTRY_SKILL_DISARM, desc, likert_color);
+       display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
 
        desc = likert(xdev, 6);
-       (*display_player_one_line)(ENTRY_SKILL_DEVICE, desc, likert_color);
+       display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
 
        desc = likert(xdev, 6);
-       (*display_player_one_line)(ENTRY_SKILL_DEVICE, desc, likert_color);
+       display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
 
        desc = likert(xdig, 4);
-       (*display_player_one_line)(ENTRY_SKILL_DIG, desc, likert_color);
+       display_player_one_line(ENTRY_SKILL_DIG, desc, likert_color);
 
        if (!muta_att)
-               (*display_player_one_line)(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
+               display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
        else
-               (*display_player_one_line)(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
+               display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
 
-       (*display_player_one_line)(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
+       display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
 
        if ((damage[0] + damage[1]) == 0)
                desc = "nil!";
        else
                desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
 
-       (*display_player_one_line)(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
-       (*display_player_one_line)(ENTRY_INFRA, format("%d feet", creature_ptr->see_infra * 10), TERM_WHITE);
+       display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
+       display_player_one_line(ENTRY_INFRA, format("%d feet", creature_ptr->see_infra * 10), TERM_WHITE);
 }
 
 
@@ -367,7 +369,7 @@ static void display_first_page(player_type *creature_ptr, int xthb, int *damage,
  * @details
  * This code is "imitated" elsewhere to "dump" a character sheet.
  */
-void display_player_various(player_type *creature_ptr, void(*display_player_one_line)(int, concptr, TERM_COLOR))
+void display_player_various(player_type *creature_ptr)
 {
        object_type *o_ptr;
        o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
@@ -380,5 +382,5 @@ void display_player_various(player_type *creature_ptr, void(*display_player_one_
        int damage[2];
        int to_h[2];
        calc_two_hands(creature_ptr, damage, to_h);
-       display_first_page(creature_ptr, xthb, damage, shots, shot_frac, display_player_one_line);
+       display_first_page(creature_ptr, xthb, damage, shots, shot_frac);
 }
index 5cb7cb3..c6ec432 100644 (file)
@@ -1,7 +1,5 @@
 #pragma once
 
-#include "term.h"
-
 #define ENTRY_BARE_HAND 0
 #define ENTRY_TWO_HANDS 1
 #define ENTRY_RIGHT_HAND1 2
@@ -52,4 +50,4 @@
 #define ENTRY_EXP_ANDR 43
 #define ENTRY_EXP_TO_ADV_ANDR 44
 
-void display_player_various(player_type *creature_ptr, void(*display_player_one_line)(int, concptr, TERM_COLOR));
+void display_player_various(player_type *creature_ptr);