OSDN Git Service

[fix] MPの無い職業に設定される定数を定義
[hengband/hengband.git] / src / window / main-window-left-frame.c
1 #include "window/main-window-left-frame.h"
2 #include "game-option/special-options.h"
3 #include "game-option/text-display-options.h"
4 #include "market/arena-info-table.h"
5 #include "monster-race/monster-race.h"
6 #include "monster/monster-status.h"
7 #include "player/mimic-info-table.h"
8 #include "player/player-class.h"
9 #include "player/player-status-table.h"
10 #include "system/floor-type-definition.h"
11 #include "term/screen-processor.h"
12 #include "term/term-color-types.h"
13 #include "util/string-processor.h"
14 #include "window/main-window-row-column.h"
15 #include "window/main-window-stat-poster.h"
16 #include "window/main-window-util.h"
17 #include "world/world.h"
18
19 /*!
20  * @brief プレイヤーの称号を表示する / Prints "title", including "wizard" or "winner" as needed.
21  * @return なし
22  */
23 void print_title(player_type *creature_ptr)
24 {
25     GAME_TEXT str[14];
26     concptr p = "";
27     if (current_world_ptr->wizard) {
28         p = _("[ウィザード]", "[=-WIZARD-=]");
29     } else if (current_world_ptr->total_winner || (creature_ptr->lev > PY_MAX_LEVEL)) {
30         if (creature_ptr->arena_number > MAX_ARENA_MONS + 2) {
31             p = _("*真・勝利者*", "*TRUEWINNER*");
32         } else {
33             p = _("***勝利者***", "***WINNER***");
34         }
35     } else {
36         angband_strcpy(str, player_title[creature_ptr->pclass][(creature_ptr->lev - 1) / 5], sizeof(str));
37         p = str;
38     }
39
40     print_field(p, ROW_TITLE, COL_TITLE);
41 }
42
43 /*!
44  * @brief プレイヤーのレベルを表示する / Prints level
45  * @return なし
46  */
47 void print_level(player_type *creature_ptr)
48 {
49     char tmp[32];
50     sprintf(tmp, "%5d", creature_ptr->lev);
51     if (creature_ptr->lev >= creature_ptr->max_plv) {
52         put_str(_("レベル ", "LEVEL "), ROW_LEVEL, 0);
53         c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 7);
54     } else {
55         put_str(_("xレベル", "Level "), ROW_LEVEL, 0);
56         c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 7);
57     }
58 }
59
60 /*!
61  * @brief プレイヤーの経験値を表示する / Display the experience
62  * @return なし
63  */
64 void print_exp(player_type *creature_ptr)
65 {
66     char out_val[32];
67
68     if ((!exp_need) || (creature_ptr->prace == RACE_ANDROID)) {
69         (void)sprintf(out_val, "%8ld", (long)creature_ptr->exp);
70     } else {
71         if (creature_ptr->lev >= PY_MAX_LEVEL) {
72             (void)sprintf(out_val, "********");
73         } else {
74             (void)sprintf(out_val, "%8ld", (long)(player_exp[creature_ptr->lev - 1] * creature_ptr->expfact / 100L) - creature_ptr->exp);
75         }
76     }
77
78     if (creature_ptr->exp >= creature_ptr->max_exp) {
79         if (creature_ptr->prace == RACE_ANDROID)
80             put_str(_("強化 ", "Cst "), ROW_EXP, 0);
81         else
82             put_str(_("経験 ", "EXP "), ROW_EXP, 0);
83         c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 4);
84     } else {
85         put_str(_("x経験", "Exp "), ROW_EXP, 0);
86         c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 4);
87     }
88 }
89
90 /*!
91  * @brief プレイヤーのACを表示する / Prints current AC
92  * @return なし
93  */
94 void print_ac(player_type *creature_ptr)
95 {
96     char tmp[32];
97
98 #ifdef JP
99     /* AC の表示方式を変更している */
100     put_str(" AC(     )", ROW_AC, COL_AC);
101     sprintf(tmp, "%5d", creature_ptr->dis_ac + creature_ptr->dis_to_a);
102     c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 6);
103 #else
104     put_str("Cur AC ", ROW_AC, COL_AC);
105     sprintf(tmp, "%5d", creature_ptr->dis_ac + creature_ptr->dis_to_a);
106     c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 7);
107 #endif
108 }
109
110 /*!
111  * @brief プレイヤーのHPを表示する / Prints Cur/Max hit points
112  * @return なし
113  */
114 void print_hp(player_type *creature_ptr)
115 {
116     char tmp[32];
117     put_str("HP", ROW_CURHP, COL_CURHP);
118     sprintf(tmp, "%4ld", (long int)creature_ptr->chp);
119     TERM_COLOR color;
120     if (creature_ptr->chp >= creature_ptr->mhp) {
121         color = TERM_L_GREEN;
122     } else if (creature_ptr->chp > (creature_ptr->mhp * hitpoint_warn) / 10) {
123         color = TERM_YELLOW;
124     } else {
125         color = TERM_RED;
126     }
127
128     c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 3);
129     put_str("/", ROW_CURHP, COL_CURHP + 7);
130     sprintf(tmp, "%4ld", (long int)creature_ptr->mhp);
131     color = TERM_L_GREEN;
132     c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 8);
133 }
134
135 /*!
136  * @brief プレイヤーのMPを表示する / Prints players max/cur spell points
137  * @return なし
138  */
139 void print_sp(player_type *creature_ptr)
140 {
141     char tmp[32];
142     byte color;
143     if (!mp_ptr->spell_book && mp_ptr->spell_first == SPELL_FIRST_NO_SPELL)
144         return;
145
146     put_str(_("MP", "SP"), ROW_CURSP, COL_CURSP);
147     sprintf(tmp, "%4ld", (long int)creature_ptr->csp);
148     if (creature_ptr->csp >= creature_ptr->msp) {
149         color = TERM_L_GREEN;
150     } else if (creature_ptr->csp > (creature_ptr->msp * mana_warn) / 10) {
151         color = TERM_YELLOW;
152     } else {
153         color = TERM_RED;
154     }
155
156     c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 3);
157     put_str("/", ROW_CURSP, COL_CURSP + 7);
158     sprintf(tmp, "%4ld", (long int)creature_ptr->msp);
159     color = TERM_L_GREEN;
160     c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 8);
161 }
162
163 /*!
164  * @brief プレイヤーの所持金を表示する / Prints current gold
165  * @param creature_ptr プレーヤーへの参照ポインタ
166  * @return なし
167  */
168 void print_gold(player_type *creature_ptr)
169 {
170     char tmp[32];
171     put_str(_("$ ", "AU "), ROW_GOLD, COL_GOLD);
172     sprintf(tmp, "%9ld", (long)creature_ptr->au);
173     c_put_str(TERM_L_GREEN, tmp, ROW_GOLD, COL_GOLD + 3);
174 }
175
176 /*!
177  * @brief 現在のフロアの深さを表示する / Prints depth in stat area
178  * @param creature_ptr プレーヤーへの参照ポインタ
179  * @return なし
180  */
181 void print_depth(player_type *creature_ptr)
182 {
183     char depths[32];
184     TERM_COLOR attr = TERM_WHITE;
185
186     TERM_LEN wid, hgt;
187     term_get_size(&wid, &hgt);
188     TERM_LEN col_depth = wid + COL_DEPTH;
189     TERM_LEN row_depth = hgt + ROW_DEPTH;
190
191     floor_type *floor_ptr = creature_ptr->current_floor_ptr;
192     if (!floor_ptr->dun_level) {
193         strcpy(depths, _("地上", "Surf."));
194         c_prt(attr, format("%7s", depths), row_depth, col_depth);
195         return;
196     }
197
198     if (floor_ptr->inside_quest && !creature_ptr->dungeon_idx) {
199         strcpy(depths, _("地上", "Quest"));
200         c_prt(attr, format("%7s", depths), row_depth, col_depth);
201         return;
202     }
203
204     if (depth_in_feet)
205         (void)sprintf(depths, _("%d ft", "%d ft"), (int)floor_ptr->dun_level * 50);
206     else
207         (void)sprintf(depths, _("%d 階", "Lev %d"), (int)floor_ptr->dun_level);
208
209     switch (creature_ptr->feeling) {
210     case 0:
211         attr = TERM_SLATE;
212         break; /* Unknown */
213     case 1:
214         attr = TERM_L_BLUE;
215         break; /* Special */
216     case 2:
217         attr = TERM_VIOLET;
218         break; /* Horrible visions */
219     case 3:
220         attr = TERM_RED;
221         break; /* Very dangerous */
222     case 4:
223         attr = TERM_L_RED;
224         break; /* Very bad feeling */
225     case 5:
226         attr = TERM_ORANGE;
227         break; /* Bad feeling */
228     case 6:
229         attr = TERM_YELLOW;
230         break; /* Nervous */
231     case 7:
232         attr = TERM_L_UMBER;
233         break; /* Luck is turning */
234     case 8:
235         attr = TERM_L_WHITE;
236         break; /* Don't like */
237     case 9:
238         attr = TERM_WHITE;
239         break; /* Reasonably safe */
240     case 10:
241         attr = TERM_WHITE;
242         break; /* Boring place */
243     }
244
245     c_prt(attr, format("%7s", depths), row_depth, col_depth);
246 }
247
248 /*!
249  * @brief プレイヤーのステータスを一括表示する(左側部分) / Display basic info (mostly left of map)
250  * @param creature_ptr プレーヤーへの参照ポインタ
251  * @return なし
252  */
253 void print_frame_basic(player_type *creature_ptr)
254 {
255     if (creature_ptr->mimic_form) {
256         print_field(mimic_info[creature_ptr->mimic_form].title, ROW_RACE, COL_RACE);
257     } else {
258         char str[14];
259         angband_strcpy(str, rp_ptr->title, sizeof(str));
260         print_field(str, ROW_RACE, COL_RACE);
261     }
262
263     print_title(creature_ptr);
264     print_level(creature_ptr);
265     print_exp(creature_ptr);
266     for (int i = 0; i < A_MAX; i++)
267         print_stat(creature_ptr, i);
268
269     print_ac(creature_ptr);
270     print_hp(creature_ptr);
271     print_sp(creature_ptr);
272     print_gold(creature_ptr);
273     print_depth(creature_ptr);
274     health_redraw(creature_ptr, FALSE);
275     health_redraw(creature_ptr, TRUE);
276 }
277
278 /*!
279  * @brief モンスターの体力ゲージを表示する
280  * @param riding TRUEならば騎乗中のモンスターの体力、FALSEならターゲットモンスターの体力を表示する。表示位置は固定。
281  * @return なし
282  * @details
283  * <pre>
284  * Redraw the "monster health bar"      -DRS-
285  * Rather extensive modifications by    -BEN-
286  *
287  * The "monster health bar" provides visual feedback on the "health"
288  * of the monster currently being "tracked".  There are several ways
289  * to "track" a monster, including targetting it, attacking it, and
290  * affecting it (and nobody else) with a ranged attack.
291  *
292  * Display the monster health bar (affectionately known as the
293  * "health-o-meter").  Clear health bar if nothing is being tracked.
294  * Auto-track current target monster when bored.  Note that the
295  * health-bar stops tracking any monster that "disappears".
296  * </pre>
297  */
298 void health_redraw(player_type *creature_ptr, bool riding)
299 {
300     s16b health_who;
301     int row, col;
302
303     if (riding) {
304         health_who = creature_ptr->riding;
305         row = ROW_RIDING_INFO;
306         col = COL_RIDING_INFO;
307     } else {
308         health_who = creature_ptr->health_who;
309         row = ROW_INFO;
310         col = COL_INFO;
311     }
312
313     monster_type *m_ptr;
314     m_ptr = &creature_ptr->current_floor_ptr->m_list[health_who];
315
316     if (current_world_ptr->wizard && creature_ptr->phase_out) {
317         row = ROW_INFO - 2;
318         col = COL_INFO + 2;
319
320         term_putstr(col - 2, row, 12, TERM_WHITE, "      /     ");
321         term_putstr(col - 2, row + 1, 12, TERM_WHITE, "      /     ");
322         term_putstr(col - 2, row + 2, 12, TERM_WHITE, "      /     ");
323         term_putstr(col - 2, row + 3, 12, TERM_WHITE, "      /     ");
324
325         if (creature_ptr->current_floor_ptr->m_list[1].r_idx) {
326             term_putstr(col - 2, row, 2, r_info[creature_ptr->current_floor_ptr->m_list[1].r_idx].x_attr,
327                 format("%c", r_info[creature_ptr->current_floor_ptr->m_list[1].r_idx].x_char));
328             term_putstr(col - 1, row, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[1].hp));
329             term_putstr(col + 5, row, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[1].max_maxhp));
330         }
331
332         if (creature_ptr->current_floor_ptr->m_list[2].r_idx) {
333             term_putstr(col - 2, row + 1, 2, r_info[creature_ptr->current_floor_ptr->m_list[2].r_idx].x_attr,
334                 format("%c", r_info[creature_ptr->current_floor_ptr->m_list[2].r_idx].x_char));
335             term_putstr(col - 1, row + 1, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[2].hp));
336             term_putstr(col + 5, row + 1, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[2].max_maxhp));
337         }
338
339         if (creature_ptr->current_floor_ptr->m_list[3].r_idx) {
340             term_putstr(col - 2, row + 2, 2, r_info[creature_ptr->current_floor_ptr->m_list[3].r_idx].x_attr,
341                 format("%c", r_info[creature_ptr->current_floor_ptr->m_list[3].r_idx].x_char));
342             term_putstr(col - 1, row + 2, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[3].hp));
343             term_putstr(col + 5, row + 2, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[3].max_maxhp));
344         }
345
346         if (creature_ptr->current_floor_ptr->m_list[4].r_idx) {
347             term_putstr(col - 2, row + 3, 2, r_info[creature_ptr->current_floor_ptr->m_list[4].r_idx].x_attr,
348                 format("%c", r_info[creature_ptr->current_floor_ptr->m_list[4].r_idx].x_char));
349             term_putstr(col - 1, row + 3, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[4].hp));
350             term_putstr(col + 5, row + 3, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[4].max_maxhp));
351         }
352
353         return;
354     }
355
356     if (!health_who) {
357         term_erase(col, row, 12);
358         return;
359     }
360
361     if (!m_ptr->ml) {
362         term_putstr(col, row, 12, TERM_WHITE, "[----------]");
363         return;
364     }
365
366     if (creature_ptr->image) {
367         term_putstr(col, row, 12, TERM_WHITE, "[----------]");
368         return;
369     }
370
371     if (m_ptr->hp < 0) {
372         term_putstr(col, row, 12, TERM_WHITE, "[----------]");
373         return;
374     }
375
376     int pct = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
377     int pct2 = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->max_maxhp : 0;
378     int len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
379     TERM_COLOR attr = TERM_RED;
380     if (monster_invulner_remaining(m_ptr))
381         attr = TERM_WHITE;
382     else if (monster_csleep_remaining(m_ptr))
383         attr = TERM_BLUE;
384     else if (monster_fear_remaining(m_ptr))
385         attr = TERM_VIOLET;
386     else if (pct >= 100)
387         attr = TERM_L_GREEN;
388     else if (pct >= 60)
389         attr = TERM_YELLOW;
390     else if (pct >= 25)
391         attr = TERM_ORANGE;
392     else if (pct >= 10)
393         attr = TERM_L_RED;
394
395     term_putstr(col, row, 12, TERM_WHITE, "[----------]");
396     term_putstr(col + 1, row, len, attr, "**********");
397 }