2 * @brief 死亡・引退・切腹時の画面表示
6 * core、files、view-mainwindowの参照禁止。コールバックで対応すること
9 #include "process-death.h"
11 #include "floor-town.h"
12 #include "player-inventory.h"
13 #include "object-flavor.h"
17 #define GRAVE_LINE_WIDTH 31
20 * @brief 墓石の真ん中に文字列を書き込む /
21 * Centers a string within a GRAVE_LINE_WIDTH character string -JWT-
25 static void center_string(char *buf, concptr str)
28 int j = GRAVE_LINE_WIDTH / 2 - i / 2;
29 (void)sprintf(buf, "%*s%s%*s", j, "", str, GRAVE_LINE_WIDTH - i - j, "");
34 * @brief プレーヤーを殺したモンスターを表示する
35 * @param dead_ptr プレーヤーへの参照ポインタ
36 * @param buf 墓テンプレへのバッファ
39 static int show_killing_monster(player_type *dead_ptr, char *buf, char *tmp)
41 roff_to_buf(dead_ptr->died_from, GRAVE_LINE_WIDTH + 1, tmp, sizeof(tmp));
43 t = tmp + strlen(tmp) + 1;
47 strcpy(dummy, t); /* 2nd line */
48 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
50 for (t = dummy + strlen(dummy) - 2; iskanji(*(t - 1)); t--) /* Loop */;
53 else if (my_strstr(tmp, "『") && suffix(dummy, "』"))
56 char *name_head = my_strstr(tmp, "『");
57 sprintf(dummy2, "%s%s", name_head, dummy);
58 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
60 strcpy(dummy, dummy2);
64 else if (my_strstr(tmp, "「") && suffix(dummy, "」"))
67 char *name_head = my_strstr(tmp, "「");
68 sprintf(dummy2, "%s%s", name_head, dummy);
69 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
71 strcpy(dummy, dummy2);
76 center_string(buf, dummy);
83 * @brief 墓石のアスキーアート表示 /
84 * Display a "tomb-stone"
85 * @param creature_ptr プレーヤーへの参照ポインタ
88 void print_tomb(player_type *dead_ptr, void(*read_dead_file)(char*, size_t))
92 (*read_dead_file)(buf, sizeof(buf));
93 concptr p = (current_world_ptr->total_winner || (dead_ptr->lev > PY_MAX_LEVEL))
94 ? _("偉大なる者", "Magnificant")
95 : player_title[dead_ptr->pclass][(dead_ptr->lev - 1) / 5];
97 center_string(buf, dead_ptr->name);
102 center_string(buf, "the");
106 center_string(buf, p);
109 center_string(buf, cp_ptr->title);
110 put_str(buf, 10, 11);
113 (void)sprintf(tmp, _("レベル: %d", "Level: %d"), (int)dead_ptr->lev);
114 center_string(buf, tmp);
115 put_str(buf, 11, 11);
117 (void)sprintf(tmp, _("経験値: %ld", "Exp: %ld"), (long)dead_ptr->exp);
118 center_string(buf, tmp);
119 put_str(buf, 12, 11);
121 (void)sprintf(tmp, _("所持金: %ld", "AU: %ld"), (long)dead_ptr->au);
122 center_string(buf, tmp);
123 put_str(buf, 13, 11);
126 /* 墓に刻む言葉をオリジナルより細かく表示 */
128 if (streq(dead_ptr->died_from, "途中終了"))
132 else if (streq(dead_ptr->died_from, "ripe"))
134 strcpy(tmp, "引退後に天寿を全う");
136 else if (streq(dead_ptr->died_from, "Seppuku"))
138 strcpy(tmp, "勝利の後、切腹");
142 extra_line = show_killing_monster(dead_ptr, buf, tmp);
145 center_string(buf, tmp);
146 put_str(buf, 14, 11);
148 if (!streq(dead_ptr->died_from, "ripe") && !streq(dead_ptr->died_from, "Seppuku"))
150 if (dead_ptr->current_floor_ptr->dun_level == 0)
152 concptr field_name = dead_ptr->town_num ? "街" : "荒野";
153 if (streq(dead_ptr->died_from, "途中終了"))
155 sprintf(tmp, "%sで死んだ", field_name);
159 sprintf(tmp, "に%sで殺された", field_name);
164 if (streq(dead_ptr->died_from, "途中終了"))
166 sprintf(tmp, "地下 %d 階で死んだ", (int)dead_ptr->current_floor_ptr->dun_level);
170 sprintf(tmp, "に地下 %d 階で殺された", (int)dead_ptr->current_floor_ptr->dun_level);
174 center_string(buf, tmp);
175 put_str(buf, 15 + extra_line, 11);
178 (void)sprintf(tmp, "Killed on Level %d", dead_ptr->current_floor_ptr->dun_level);
179 center_string(buf, tmp);
180 put_str(buf, 14, 11);
182 roff_to_buf(format("by %s.", dead_ptr->died_from), GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
183 center_string(buf, tmp);
185 put_str(buf, 15, 11);
186 t = tmp + strlen(tmp) + 1;
190 strcpy(dummy, t); /* 2nd line */
191 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
193 int dummy_len = strlen(dummy);
194 strcpy(dummy + MIN(dummy_len, GRAVE_LINE_WIDTH - 3), "...");
196 center_string(buf, dummy);
197 put_str(buf, 16, 11);
200 time_t ct = time((time_t*)0);
201 (void)sprintf(tmp, "%-.24s", ctime(&ct));
202 center_string(buf, tmp);
203 put_str(buf, 17, 11);
204 msg_format(_("さようなら、%s!", "Goodbye, %s!"), dead_ptr->name);
209 * todo handle_stuff、display_playerの引数は暫定。どのように設計し直すか少し考える
210 * @brief 死亡、引退時の簡易ステータス表示
211 * @param creature_ptr プレーヤーへの参照ポインタ
212 * @param handle_stuff 更新処理チェックへのコールバック
213 * @param file_character ステータスダンプへのコールバック
214 * @param update_playtime プレイ時間更新処理へのコールバック
215 * @param display_player ステータス表示へのコールバック
218 void show_info(player_type *creature_ptr, void(*handle_stuff)(player_type*), errr(*file_character)(player_type*, concptr), void(*update_playtime)(void), void(*display_player)(player_type*, int))
221 for (int i = 0; i < INVEN_TOTAL; i++)
223 o_ptr = &creature_ptr->inventory_list[i];
224 if (!o_ptr->k_idx) continue;
226 object_aware(creature_ptr, o_ptr);
231 for (int i = 1; i < max_towns; i++)
233 st_ptr = &town_info[i].store[STORE_HOME];
234 for (int j = 0; j < st_ptr->stock_num; j++)
236 o_ptr = &st_ptr->stock[j];
237 if (!o_ptr->k_idx) continue;
239 object_aware(creature_ptr, o_ptr);
244 creature_ptr->update |= (PU_BONUS);
245 handle_stuff(creature_ptr);
248 prt(_("キャラクターの記録をファイルに書き出すことができます。", "You may now dump a character record to one or more files."), 21, 0);
249 prt(_("リターンキーでキャラクターを見ます。ESCで中断します。", "Then, hit RETURN to see the character, or ESC to abort."), 22, 0);
253 put_str(_("ファイルネーム: ", "Filename: "), 23, 0);
255 if (!askfor(out_val, 60)) return;
256 if (!out_val[0]) break;
258 (void)file_character(creature_ptr, out_val);
263 display_player(creature_ptr, 0);
264 prt(_("何かキーを押すとさらに情報が続きます (ESCで中断): ", "Hit any key to see more information (ESC to abort): "), 23, 0);
265 if (inkey() == ESCAPE) return;
267 if (creature_ptr->equip_cnt)
270 (void)show_equipment(creature_ptr, 0, USE_FULL, 0);
271 prt(_("装備していたアイテム: -続く-", "You are using: -more-"), 0, 0);
272 if (inkey() == ESCAPE) return;
275 if (creature_ptr->inven_cnt)
278 (void)show_inventory(creature_ptr, 0, USE_FULL, 0);
279 prt(_("持っていたアイテム: -続く-", "You are carrying: -more-"), 0, 0);
281 if (inkey() == ESCAPE) return;
284 for (int l = 1; l < max_towns; l++)
286 st_ptr = &town_info[l].store[STORE_HOME];
287 if (st_ptr->stock_num == 0) continue;
288 for (int i = 0, k = 0; i < st_ptr->stock_num; k++)
291 for (int j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
293 GAME_TEXT o_name[MAX_NLEN];
295 o_ptr = &st_ptr->stock[i];
296 sprintf(tmp_val, "%c) ", I2A(j));
297 prt(tmp_val, j + 2, 4);
298 object_desc(creature_ptr, o_name, o_ptr, 0);
299 c_put_str(tval_to_attr[o_ptr->tval], o_name, j + 2, 7);
302 prt(format(_("我が家に置いてあったアイテム ( %d ページ): -続く-", "Your home contains (page %d): -more-"), k + 1), 0, 0);
303 if (inkey() == ESCAPE) return;