1 #include "birth/history-editor.h"
2 #include "io/input-key-acceptor.h"
3 #include "io/read-pref-file.h"
4 #include "locale/japanese.h"
5 #include "system/player-type-definition.h"
6 #include "term/screen-processor.h"
7 #include "term/term-color-types.h"
8 #include "util/int-char-converter.h"
9 #include "util/string-processor.h"
10 #include "view/display-player.h" // 暫定。後で消す.
13 * @brief 生い立ちメッセージを編集する。/Character background edit-mode
14 * @param player_ptr プレイヤーへの参照ポインタ
16 void edit_history(PlayerType *player_ptr)
18 std::string old_history[4];
19 for (int i = 0; i < 4; i++) {
20 old_history[i] = player_ptr->history[i];
23 for (int i = 0; i < 4; i++) {
26 for (j = 0; player_ptr->history[i][j]; j++) {
31 player_ptr->history[i][j] = ' ';
33 player_ptr->history[i][59] = '\0';
36 (void)display_player(player_ptr, 1);
37 c_put_str(TERM_L_GREEN, _("(キャラクターの生い立ち - 編集モード)", "(Character Background - Edit Mode)"), 11, 20);
38 put_str(_("[ カーソルキーで移動、Enterで終了、Ctrl-Aでファイル読み込み ]", "[ Cursor key for Move, Enter for End, Ctrl-A for Read pref ]"), 17, 10);
44 for (int i = 0; i < 4; i++) {
45 put_str(player_ptr->history[i], i + 12, 10);
48 if (iskanji2(player_ptr->history[y], x)) {
49 char kanji[3] = { player_ptr->history[y][x], player_ptr->history[y][x + 1], '\0' };
50 c_put_str(TERM_L_BLUE, format("%s", kanji), y + 12, x + 10);
53 c_put_str(TERM_L_BLUE, format("%c", player_ptr->history[y][x]), y + 12, x + 10);
55 term_gotoxy(x + 10, y + 12);
56 int skey = inkey_special(true);
57 if (!(skey & SKEY_MASK)) {
63 if (skey == SKEY_UP || c == KTRL('p')) {
69 if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1))) {
73 } else if (skey == SKEY_DOWN || c == KTRL('n')) {
79 if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1))) {
83 } else if (skey == SKEY_RIGHT || c == KTRL('f')) {
85 if (iskanji2(player_ptr->history[y], x)) {
96 } else if (skey == SKEY_LEFT || c == KTRL('b')) {
108 if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1))) {
112 } else if (c == '\r' || c == '\n') {
115 put_str(_("(キャラクターの生い立ち - 編集済み)", "(Character Background - Edited)"), 11, 20);
117 } else if (c == ESCAPE) {
119 put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
120 for (int i = 0; i < 4; i++) {
121 angband_strcpy(player_ptr->history[i], old_history[i], sizeof(player_ptr->history[i]));
122 put_str(player_ptr->history[i], i + 12, 10);
126 } else if (c == KTRL('A')) {
127 if (read_histpref(player_ptr)) {
129 if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1))) {
134 } else if (c == '\010') {
145 player_ptr->history[y][x] = ' ';
147 if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1))) {
149 player_ptr->history[y][x] = ' ';
154 else if (iskanji(c) || isprint(c))
156 else if (isprint(c)) /* BUGFIX */
160 if (iskanji2(player_ptr->history[y], x)) {
161 player_ptr->history[y][x + 1] = ' ';
173 if (iskanji2(player_ptr->history[y], x + 1)) {
174 player_ptr->history[y][x + 2] = ' ';
177 player_ptr->history[y][x++] = c;
182 player_ptr->history[y][x++] = c;