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"
14 #include "market/store-util.h"
18 #define GRAVE_LINE_WIDTH 31
21 * @brief 墓石の真ん中に文字列を書き込む /
22 * Centers a string within a GRAVE_LINE_WIDTH character string -JWT-
26 static void center_string(char *buf, concptr str)
29 int j = GRAVE_LINE_WIDTH / 2 - i / 2;
30 (void)sprintf(buf, "%*s%s%*s", j, "", str, GRAVE_LINE_WIDTH - i - j, "");
36 * @param dead_ptr プレーヤーへの参照ポインタ
40 static void show_basic_params(player_type *dead_ptr, char *buf)
42 char tomb_message[160];
43 (void)sprintf(tomb_message, _("レベル: %d", "Level: %d"), (int)dead_ptr->lev);
44 center_string(buf, tomb_message);
47 (void)sprintf(tomb_message, _("経験値: %ld", "Exp: %ld"), (long)dead_ptr->exp);
48 center_string(buf, tomb_message);
51 (void)sprintf(tomb_message, _("所持金: %ld", "AU: %ld"), (long)dead_ptr->au);
52 center_string(buf, tomb_message);
59 * @brief プレーヤーを殺したモンスターを表示する (日本語版専用)
60 * @param dead_ptr プレーヤーへの参照ポインタ
62 * @param tomb_message 墓碑に刻む言葉
65 static int show_killing_monster(player_type *dead_ptr, char *buf, char *tomb_message, size_t tomb_message_size)
67 roff_to_buf(dead_ptr->died_from, GRAVE_LINE_WIDTH + 1, tomb_message, tomb_message_size);
69 t = tomb_message + strlen(tomb_message) + 1;
73 strcpy(dummy, t); /* 2nd line */
74 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
76 for (t = dummy + strlen(dummy) - 2; iskanji(*(t - 1)); t--) /* Loop */;
79 else if (my_strstr(tomb_message, "『") && suffix(dummy, "』"))
82 char *name_head = my_strstr(tomb_message, "『");
83 sprintf(dummy2, "%s%s", name_head, dummy);
84 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
86 strcpy(dummy, dummy2);
90 else if (my_strstr(tomb_message, "「") && suffix(dummy, "」"))
93 char *name_head = my_strstr(tomb_message, "「");
94 sprintf(dummy2, "%s%s", name_head, dummy);
95 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
97 strcpy(dummy, dummy2);
102 center_string(buf, dummy);
103 put_str(buf, 15, 11);
109 * @brief どこで死んだかを表示する (日本語版専用)
110 * @param dead_ptr プレーヤーへの参照ポインタ
112 * @param tomb_message 表示する文字列
113 * @param extra_line 追加の行数
116 static void show_dead_place(player_type *dead_ptr, char *buf, char *tomb_message, int extra_line)
118 if (streq(dead_ptr->died_from, "ripe") || streq(dead_ptr->died_from, "Seppuku"))
121 if (dead_ptr->current_floor_ptr->dun_level == 0)
123 concptr field_name = dead_ptr->town_num ? "街" : "荒野";
124 if (streq(dead_ptr->died_from, "途中終了"))
126 sprintf(tomb_message, "%sで死んだ", field_name);
130 sprintf(tomb_message, "に%sで殺された", field_name);
135 if (streq(dead_ptr->died_from, "途中終了"))
137 sprintf(tomb_message, "地下 %d 階で死んだ", (int)dead_ptr->current_floor_ptr->dun_level);
141 sprintf(tomb_message, "に地下 %d 階で殺された", (int)dead_ptr->current_floor_ptr->dun_level);
145 center_string(buf, tomb_message);
146 put_str(buf, 15 + extra_line, 11);
151 * @brief 墓に刻む言葉を細かく表示 (日本語版専用)
152 * @param dead_ptr プレーヤーへの参照ポインタ
156 static void show_tomb_detail(player_type *dead_ptr, char *buf)
158 char tomb_message[160];
160 if (streq(dead_ptr->died_from, "途中終了"))
162 strcpy(tomb_message, "<自殺>");
164 else if (streq(dead_ptr->died_from, "ripe"))
166 strcpy(tomb_message, "引退後に天寿を全う");
168 else if (streq(dead_ptr->died_from, "Seppuku"))
170 strcpy(tomb_message, "勝利の後、切腹");
174 extra_line = show_killing_monster(dead_ptr, buf, tomb_message, sizeof(tomb_message));
177 center_string(buf, tomb_message);
178 put_str(buf, 14, 11);
180 show_dead_place(dead_ptr, buf, tomb_message, extra_line);
186 * @brief Detailed display of words engraved on the tomb (English version only)
187 * @param dead_ptr reference pointer to the player
188 * @param buf template of the tomb
191 static void show_tomb_detail(player_type *dead_ptr, char *buf)
193 char tomb_message[160];
194 (void)sprintf(tomb_message, "Killed on Level %d", dead_ptr->current_floor_ptr->dun_level);
195 center_string(buf, tomb_message);
196 put_str(buf, 14, 11);
198 roff_to_buf(format("by %s.", dead_ptr->died_from), GRAVE_LINE_WIDTH + 1, tomb_message, sizeof(tomb_message));
199 center_string(buf, tomb_message);
201 put_str(buf, 15, 11);
202 t = tomb_message + strlen(tomb_message) + 1;
206 strcpy(dummy, t); /* 2nd line */
207 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
209 int dummy_len = strlen(dummy);
210 strcpy(dummy + MIN(dummy_len, GRAVE_LINE_WIDTH - 3), "...");
213 center_string(buf, dummy);
214 put_str(buf, 16, 11);
220 * @brief 墓石のアスキーアート表示 /
221 * Display a "tomb-stone"
222 * @param creature_ptr プレーヤーへの参照ポインタ
225 void print_tomb(player_type *dead_ptr)
229 read_dead_file(buf, sizeof(buf));
230 concptr p = (current_world_ptr->total_winner || (dead_ptr->lev > PY_MAX_LEVEL))
231 ? _("偉大なる者", "Magnificant")
232 : player_title[dead_ptr->pclass][(dead_ptr->lev - 1) / 5];
234 center_string(buf, dead_ptr->name);
239 center_string(buf, "the");
243 center_string(buf, p);
246 center_string(buf, cp_ptr->title);
247 put_str(buf, 10, 11);
249 show_basic_params(dead_ptr, buf);
250 show_tomb_detail(dead_ptr, buf);
252 char current_time[80];
253 time_t ct = time((time_t*)0);
254 (void)sprintf(current_time, "%-.24s", ctime(&ct));
255 center_string(buf, current_time);
256 put_str(buf, 17, 11);
257 msg_format(_("さようなら、%s!", "Goodbye, %s!"), dead_ptr->name);
262 * @brief 死亡/引退/切腹時にインベントリ内のアイテムを*鑑定*する
263 * @param creature_ptr プレーヤーへの参照ポインタ
266 static void inventory_aware(player_type *creature_ptr)
269 for (int i = 0; i < INVEN_TOTAL; i++)
271 o_ptr = &creature_ptr->inventory_list[i];
272 if (!o_ptr->k_idx) continue;
274 object_aware(creature_ptr, o_ptr);
281 * @brief 死亡/引退/切腹時に我が家のアイテムを*鑑定*する
282 * @param creature_ptr プレーヤーへの参照ポインタ
285 static void home_aware(player_type *creature_ptr)
288 store_type *store_ptr;
289 for (int i = 1; i < max_towns; i++)
291 store_ptr = &town_info[i].store[STORE_HOME];
292 for (int j = 0; j < store_ptr->stock_num; j++)
294 o_ptr = &store_ptr->stock[j];
295 if (!o_ptr->k_idx) continue;
297 object_aware(creature_ptr, o_ptr);
305 * @brief プレーヤーの持ち物を表示する
306 * @param creature_ptr プレーヤーへの参照ポインタ
307 * @return Escキーでゲームを終了する時TRUE
309 static bool show_dead_player_items(player_type *creature_ptr)
311 if (creature_ptr->equip_cnt)
314 (void)show_equipment(creature_ptr, 0, USE_FULL, 0);
315 prt(_("装備していたアイテム: -続く-", "You are using: -more-"), 0, 0);
316 if (inkey() == ESCAPE) return TRUE;
319 if (creature_ptr->inven_cnt)
322 (void)show_inventory(creature_ptr, 0, USE_FULL, 0);
323 prt(_("持っていたアイテム: -続く-", "You are carrying: -more-"), 0, 0);
325 if (inkey() == ESCAPE) return TRUE;
333 * @brief 我が家にあったアイテムを表示する
334 * @param creature_ptr プレーヤーへの参照ポインタ
337 static void show_dead_home_items(player_type *creature_ptr)
339 for (int l = 1; l < max_towns; l++)
341 store_type *store_ptr;
342 store_ptr = &town_info[l].store[STORE_HOME];
343 if (store_ptr->stock_num == 0) continue;
345 for (int i = 0, k = 0; i < store_ptr->stock_num; k++)
348 for (int j = 0; (j < 12) && (i < store_ptr->stock_num); j++, i++)
350 GAME_TEXT o_name[MAX_NLEN];
353 o_ptr = &store_ptr->stock[i];
354 sprintf(tmp_val, "%c) ", I2A(j));
355 prt(tmp_val, j + 2, 4);
356 object_desc(creature_ptr, o_name, o_ptr, 0);
357 c_put_str(tval_to_attr[o_ptr->tval], o_name, j + 2, 7);
360 prt(format(_("我が家に置いてあったアイテム ( %d ページ): -続く-", "Your home contains (page %d): -more-"), k + 1), 0, 0);
361 if (inkey() == ESCAPE) return;
368 * @brief キャラクタ情報をファイルに書き出す
369 * @param creature_ptr プレーヤーへの参照ポインタ
370 * @param file_character ステータスダンプへのコールバック
373 static void export_player_info(player_type *creature_ptr, update_playtime_pf update_playtime, display_player_pf display_player, map_name_pf map_name)
375 prt(_("キャラクターの記録をファイルに書き出すことができます。", "You may now dump a character record to one or more files."), 21, 0);
376 prt(_("リターンキーでキャラクターを見ます。ESCで中断します。", "Then, hit RETURN to see the character, or ESC to abort."), 22, 0);
380 put_str(_("ファイルネーム: ", "Filename: "), 23, 0);
382 if (!askfor(out_val, 60)) return;
383 if (!out_val[0]) break;
386 (void)file_character(creature_ptr, out_val, update_playtime, display_player, map_name);
393 * @brief 死亡、引退時の簡易ステータス表示
394 * @param creature_ptr プレーヤーへの参照ポインタ
395 * @param handle_stuff 更新処理チェックへのコールバック
396 * @param file_character ステータスダンプへのコールバック
397 * @param update_playtime プレイ時間更新処理へのコールバック
398 * @param display_player ステータス表示へのコールバック
401 void show_info(player_type *creature_ptr, void(*handle_stuff)(player_type*), update_playtime_pf update_playtime, display_player_pf display_player, map_name_pf map_name)
403 inventory_aware(creature_ptr);
404 home_aware(creature_ptr);
406 creature_ptr->update |= (PU_BONUS);
407 (*handle_stuff)(creature_ptr);
411 export_player_info(creature_ptr, update_playtime, display_player, map_name);
412 (*update_playtime)();
413 (*display_player)(creature_ptr, 0, map_name);
414 prt(_("何かキーを押すとさらに情報が続きます (ESCで中断): ", "Hit any key to see more information (ESC to abort): "), 23, 0);
415 if (inkey() == ESCAPE) return;
416 if (show_dead_player_items(creature_ptr)) return;
418 show_dead_home_items(creature_ptr);