OSDN Git Service

Include <string> to avoid compiler error on MacOS/clang when not using precompiled...
[hengbandforosx/hengbandosx.git] / src / view / display-util.cpp
1 #include "view/display-util.h"
2 #include "term/term-color-types.h"
3 #include <string>
4 #include <vector>
5
6 namespace {
7 struct disp_player_line {
8     int col;
9     int row;
10     int len;
11     const char *header;
12 };
13
14 const std::vector<disp_player_line> disp_player_lines = {
15     { 1, 10, 25, _("打撃修正(格闘)", "Barehanded") },
16     { 1, 10, 25, _("打撃修正(両手)", "Two hands") },
17     { 1, 10, 25, _("打撃修正(右手)", "Right hand") },
18     { 1, 10, 25, _("打撃修正(左手)", "Left hand") },
19     { 1, 11, 25, _("打撃修正(左手)", "Left hand") },
20     { 1, 11, 25, _("打撃修正(右手)", "Right hand") },
21     { 1, 11, 25, _("", "Posture") },
22     { 1, 15, 25, _("射撃攻撃修正", "Shooting") },
23     { 1, 16, 25, _("射撃武器倍率", "Multiplier") },
24     { 1, 20, 25, _("加速", "Speed") },
25     { 1, 19, 25, _("AC", "AC") },
26     { 29, 13, 21, _("レベル", "Level") },
27     { 29, 14, 21, _("経験値", "Experience") },
28     { 29, 15, 21, _("最大経験", "Max Exp") },
29     { 29, 16, 21, _("次レベル", "Exp to Adv") },
30     { 29, 17, 21, _("所持金", "Gold") },
31     { 29, 19, 21, _("日付", "Time") },
32     { 29, 10, 21, _("HP", "Hit points") },
33     { 29, 11, 21, _("MP", "SP (Mana)") },
34     { 29, 20, 21, _("プレイ時間", "Play time") },
35     { 53, 10, -1, _("打撃命中  :", "Fighting   : ") },
36     { 53, 11, -1, _("射撃命中  :", "Bows/Throw : ") },
37     { 53, 12, -1, _("魔法防御  :", "SavingThrow: ") },
38     { 53, 13, -1, _("隠密行動  :", "Stealth    : ") },
39     { 53, 15, -1, _("知覚      :", "Perception : ") },
40     { 53, 16, -1, _("探索      :", "Searching  : ") },
41     { 53, 17, -1, _("解除      :", "Disarming  : ") },
42     { 53, 18, -1, _("魔法道具  :", "MagicDevice: ") },
43     { 1, 12, 25, _("打撃回数", "Blows/Round") },
44     { 1, 17, 25, _("射撃回数", "Shots/Round") },
45     { 1, 13, 25, _("平均ダメージ", "AverageDmg/Rnd") },
46     { 53, 20, -1, _("赤外線視力:", "Infravision: ") },
47     { 26, 1, -1, _("名前  : ", "Name  : ") },
48     { 1, 3, -1, _("性別     : ", "Sex      : ") },
49     { 1, 4, -1, _("種族     : ", "Race     : ") },
50     { 1, 5, -1, _("職業     : ", "Class    : ") },
51     { 1, 6, -1, _("魔法     : ", "Magic    : ") },
52     { 1, 7, -1, _("守護魔神 : ", "Patron   : ") },
53     { 29, 3, 21, _("年齢", "Age") },
54     { 29, 4, 21, _("身長", "Height") },
55     { 29, 5, 21, _("体重", "Weight") },
56     { 29, 6, 21, _("社会的地位", "Social Class") },
57     { 29, 7, 21, _("属性", "Align") },
58     { 29, 14, 21, _("強化度", "Construction") },
59     { 29, 16, 21, _("次レベル", "Const to Adv") },
60     { 53, 19, -1, _("掘削      :", "Digging    : ") },
61 };
62 }
63
64 /*!
65  * @brief プレイヤーのステータス1種を出力する
66  * @param entry 項目ID
67  * @param val 値を保管した文字列ポインタ
68  * @param attr 項目表示の色
69  */
70 void display_player_one_line(int entry, std::string_view val, TERM_COLOR attr)
71 {
72     auto head = disp_player_lines[entry].header;
73     auto head_len = strlen(head);
74     auto row = disp_player_lines[entry].row;
75     auto col = disp_player_lines[entry].col;
76     auto len = disp_player_lines[entry].len;
77     term_putstr(col, row, -1, TERM_WHITE, head);
78
79     if (len <= 0) {
80         term_putstr(col + head_len, row, -1, attr, val);
81         return;
82     }
83
84     int val_len = len - head_len;
85     std::string str;
86     if (val_len > static_cast<int>(val.length())) {
87         str.append(val_len - val.length(), ' ');
88     }
89     str.append(val);
90     term_putstr(col + head_len, row, -1, attr, str);
91 }