OSDN Git Service

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