2 * @brief 死亡・引退・切腹時の画面表示
6 * core、files、view-mainwindowの参照禁止。コールバックで対応すること
9 #include "process-death.h"
10 #include "core/asking-player.h"
11 #include "core/stuff-handler.h"
12 #include "floor/floor-town.h"
13 #include "floor/floor.h"
14 #include "inventory/player-inventory.h"
15 #include "io/input-key-acceptor.h"
16 #include "object/item-use-flags.h"
17 #include "perception/object-perception.h"
18 #include "object/object-flavor.h"
19 #include "store/store-util.h"
20 #include "store/store.h"
21 #include "term/gameterm.h"
22 #include "term/screen-processor.h"
23 #include "util/int-char-converter.h"
24 #include "util/string-processor.h"
25 #include "view/display-messages.h"
26 #include "world/world.h"
28 #define GRAVE_LINE_WIDTH 31
31 * @brief 墓石の真ん中に文字列を書き込む /
32 * Centers a string within a GRAVE_LINE_WIDTH character string -JWT-
36 static void center_string(char *buf, concptr str)
39 int j = GRAVE_LINE_WIDTH / 2 - i / 2;
40 (void)sprintf(buf, "%*s%s%*s", j, "", str, GRAVE_LINE_WIDTH - i - j, "");
46 * @param dead_ptr プレーヤーへの参照ポインタ
50 static void show_basic_params(player_type *dead_ptr, char *buf)
52 char tomb_message[160];
53 (void)sprintf(tomb_message, _("レベル: %d", "Level: %d"), (int)dead_ptr->lev);
54 center_string(buf, tomb_message);
57 (void)sprintf(tomb_message, _("経験値: %ld", "Exp: %ld"), (long)dead_ptr->exp);
58 center_string(buf, tomb_message);
61 (void)sprintf(tomb_message, _("所持金: %ld", "AU: %ld"), (long)dead_ptr->au);
62 center_string(buf, tomb_message);
69 * @brief プレーヤーを殺したモンスターを表示する (日本語版専用)
70 * @param dead_ptr プレーヤーへの参照ポインタ
72 * @param tomb_message 墓碑に刻む言葉
75 static int show_killing_monster(player_type *dead_ptr, char *buf, char *tomb_message, size_t tomb_message_size)
77 roff_to_buf(dead_ptr->died_from, GRAVE_LINE_WIDTH + 1, tomb_message, tomb_message_size);
79 t = tomb_message + strlen(tomb_message) + 1;
83 strcpy(dummy, t); /* 2nd line */
84 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
86 for (t = dummy + strlen(dummy) - 2; iskanji(*(t - 1)); t--) /* Loop */;
89 else if (angband_strstr(tomb_message, "『") && suffix(dummy, "』"))
92 char *name_head = angband_strstr(tomb_message, "『");
93 sprintf(dummy2, "%s%s", name_head, dummy);
94 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
96 strcpy(dummy, dummy2);
100 else if (angband_strstr(tomb_message, "「") && suffix(dummy, "」"))
103 char *name_head = angband_strstr(tomb_message, "「");
104 sprintf(dummy2, "%s%s", name_head, dummy);
105 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
107 strcpy(dummy, dummy2);
112 center_string(buf, dummy);
113 put_str(buf, 15, 11);
119 * @brief どこで死んだかを表示する (日本語版専用)
120 * @param dead_ptr プレーヤーへの参照ポインタ
122 * @param tomb_message 表示する文字列
123 * @param extra_line 追加の行数
126 static void show_dead_place(player_type *dead_ptr, char *buf, char *tomb_message, int extra_line)
128 if (streq(dead_ptr->died_from, "ripe") || streq(dead_ptr->died_from, "Seppuku"))
131 if (dead_ptr->current_floor_ptr->dun_level == 0)
133 concptr field_name = dead_ptr->town_num ? "街" : "荒野";
134 if (streq(dead_ptr->died_from, "途中終了"))
136 sprintf(tomb_message, "%sで死んだ", field_name);
140 sprintf(tomb_message, "に%sで殺された", field_name);
145 if (streq(dead_ptr->died_from, "途中終了"))
147 sprintf(tomb_message, "地下 %d 階で死んだ", (int)dead_ptr->current_floor_ptr->dun_level);
151 sprintf(tomb_message, "に地下 %d 階で殺された", (int)dead_ptr->current_floor_ptr->dun_level);
155 center_string(buf, tomb_message);
156 put_str(buf, 15 + extra_line, 11);
161 * @brief 墓に刻む言葉を細かく表示 (日本語版専用)
162 * @param dead_ptr プレーヤーへの参照ポインタ
166 static void show_tomb_detail(player_type *dead_ptr, char *buf)
168 char tomb_message[160];
170 if (streq(dead_ptr->died_from, "途中終了"))
172 strcpy(tomb_message, "<自殺>");
174 else if (streq(dead_ptr->died_from, "ripe"))
176 strcpy(tomb_message, "引退後に天寿を全う");
178 else if (streq(dead_ptr->died_from, "Seppuku"))
180 strcpy(tomb_message, "勝利の後、切腹");
184 extra_line = show_killing_monster(dead_ptr, buf, tomb_message, sizeof(tomb_message));
187 center_string(buf, tomb_message);
188 put_str(buf, 14, 11);
190 show_dead_place(dead_ptr, buf, tomb_message, extra_line);
196 * @brief Detailed display of words engraved on the tomb (English version only)
197 * @param dead_ptr reference pointer to the player
198 * @param buf template of the tomb
201 static void show_tomb_detail(player_type *dead_ptr, char *buf)
203 char tomb_message[160];
204 (void)sprintf(tomb_message, "Killed on Level %d", dead_ptr->current_floor_ptr->dun_level);
205 center_string(buf, tomb_message);
206 put_str(buf, 14, 11);
208 roff_to_buf(format("by %s.", dead_ptr->died_from), GRAVE_LINE_WIDTH + 1, tomb_message, sizeof(tomb_message));
209 center_string(buf, tomb_message);
211 put_str(buf, 15, 11);
212 t = tomb_message + strlen(tomb_message) + 1;
216 strcpy(dummy, t); /* 2nd line */
217 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
219 int dummy_len = strlen(dummy);
220 strcpy(dummy + MIN(dummy_len, GRAVE_LINE_WIDTH - 3), "...");
223 center_string(buf, dummy);
224 put_str(buf, 16, 11);
230 * @brief 墓石のアスキーアート表示 /
231 * Display a "tomb-stone"
232 * @param creature_ptr プレーヤーへの参照ポインタ
235 void print_tomb(player_type *dead_ptr)
239 read_dead_file(buf, sizeof(buf));
240 concptr p = (current_world_ptr->total_winner || (dead_ptr->lev > PY_MAX_LEVEL))
241 ? _("偉大なる者", "Magnificant")
242 : player_title[dead_ptr->pclass][(dead_ptr->lev - 1) / 5];
244 center_string(buf, dead_ptr->name);
249 center_string(buf, "the");
253 center_string(buf, p);
256 center_string(buf, cp_ptr->title);
257 put_str(buf, 10, 11);
259 show_basic_params(dead_ptr, buf);
260 show_tomb_detail(dead_ptr, buf);
262 char current_time[80];
263 time_t ct = time((time_t*)0);
264 (void)sprintf(current_time, "%-.24s", ctime(&ct));
265 center_string(buf, current_time);
266 put_str(buf, 17, 11);
267 msg_format(_("さようなら、%s!", "Goodbye, %s!"), dead_ptr->name);
272 * @brief 死亡/引退/切腹時にインベントリ内のアイテムを*鑑定*する
273 * @param creature_ptr プレーヤーへの参照ポインタ
276 static void inventory_aware(player_type *creature_ptr)
279 for (int i = 0; i < INVEN_TOTAL; i++)
281 o_ptr = &creature_ptr->inventory_list[i];
282 if (!o_ptr->k_idx) continue;
284 object_aware(creature_ptr, o_ptr);
291 * @brief 死亡/引退/切腹時に我が家のアイテムを*鑑定*する
292 * @param creature_ptr プレーヤーへの参照ポインタ
295 static void home_aware(player_type *creature_ptr)
298 store_type *store_ptr;
299 for (int i = 1; i < max_towns; i++)
301 store_ptr = &town_info[i].store[STORE_HOME];
302 for (int j = 0; j < store_ptr->stock_num; j++)
304 o_ptr = &store_ptr->stock[j];
305 if (!o_ptr->k_idx) continue;
307 object_aware(creature_ptr, o_ptr);
315 * @brief プレーヤーの持ち物を表示する
316 * @param creature_ptr プレーヤーへの参照ポインタ
317 * @return Escキーでゲームを終了する時TRUE
319 static bool show_dead_player_items(player_type *creature_ptr)
321 if (creature_ptr->equip_cnt)
324 (void)show_equipment(creature_ptr, 0, USE_FULL, 0);
325 prt(_("装備していたアイテム: -続く-", "You are using: -more-"), 0, 0);
326 if (inkey() == ESCAPE) return TRUE;
329 if (creature_ptr->inven_cnt)
332 (void)show_inventory(creature_ptr, 0, USE_FULL, 0);
333 prt(_("持っていたアイテム: -続く-", "You are carrying: -more-"), 0, 0);
335 if (inkey() == ESCAPE) return TRUE;
343 * @brief 我が家にあったアイテムを表示する
344 * @param creature_ptr プレーヤーへの参照ポインタ
347 static void show_dead_home_items(player_type *creature_ptr)
349 for (int l = 1; l < max_towns; l++)
351 store_type *store_ptr;
352 store_ptr = &town_info[l].store[STORE_HOME];
353 if (store_ptr->stock_num == 0) continue;
355 for (int i = 0, k = 0; i < store_ptr->stock_num; k++)
358 for (int j = 0; (j < 12) && (i < store_ptr->stock_num); j++, i++)
360 GAME_TEXT o_name[MAX_NLEN];
363 o_ptr = &store_ptr->stock[i];
364 sprintf(tmp_val, "%c) ", I2A(j));
365 prt(tmp_val, j + 2, 4);
366 object_desc(creature_ptr, o_name, o_ptr, 0);
367 c_put_str(tval_to_attr[o_ptr->tval], o_name, j + 2, 7);
370 prt(format(_("我が家に置いてあったアイテム ( %d ページ): -続く-", "Your home contains (page %d): -more-"), k + 1), 0, 0);
371 if (inkey() == ESCAPE) return;
378 * @brief キャラクタ情報をファイルに書き出す
379 * @param creature_ptr プレーヤーへの参照ポインタ
380 * @param file_character ステータスダンプへのコールバック
383 static void export_player_info(player_type *creature_ptr, update_playtime_pf update_playtime, display_player_pf display_player, map_name_pf map_name)
385 prt(_("キャラクターの記録をファイルに書き出すことができます。", "You may now dump a character record to one or more files."), 21, 0);
386 prt(_("リターンキーでキャラクターを見ます。ESCで中断します。", "Then, hit RETURN to see the character, or ESC to abort."), 22, 0);
390 put_str(_("ファイルネーム: ", "Filename: "), 23, 0);
392 if (!askfor(out_val, 60)) return;
393 if (!out_val[0]) break;
396 (void)file_character(creature_ptr, out_val, update_playtime, display_player, map_name);
403 * @brief 死亡、引退時の簡易ステータス表示
404 * @param creature_ptr プレーヤーへの参照ポインタ
405 * @param handle_stuff 更新処理チェックへのコールバック
406 * @param file_character ステータスダンプへのコールバック
407 * @param update_playtime プレイ時間更新処理へのコールバック
408 * @param display_player ステータス表示へのコールバック
411 void show_death_info(player_type *creature_ptr, update_playtime_pf update_playtime, display_player_pf display_player, map_name_pf map_name)
413 inventory_aware(creature_ptr);
414 home_aware(creature_ptr);
416 creature_ptr->update |= (PU_BONUS);
417 handle_stuff(creature_ptr);
421 export_player_info(creature_ptr, update_playtime, display_player, map_name);
422 (*update_playtime)();
423 (*display_player)(creature_ptr, 0, map_name);
424 prt(_("何かキーを押すとさらに情報が続きます (ESCで中断): ", "Hit any key to see more information (ESC to abort): "), 23, 0);
425 if (inkey() == ESCAPE) return;
426 if (show_dead_player_items(creature_ptr)) return;
428 show_dead_home_items(creature_ptr);