1 #include "birth/history-editor.h"
2 #include "io/input-key-acceptor.h"
3 #include "io/read-pref-file.h"
4 #include "term/screen-processor.h"
5 #include "term/term-color-types.h"
6 #include "util/int-char-converter.h"
7 #include "view/display-player.h" // 暫定。後で消す.
9 #include "locale/japanese.h"
13 * @brief 生い立ちメッセージを編集する。/Character background edit-mode
14 * @param creature_ptr プレーヤーへの参照ポインタ
15 * @param process_autopick_file_command 自動拾いファイルコマンドへの関数ポインタ
18 void edit_history(player_type *creature_ptr, void (*process_autopick_file_command)(char *))
20 char old_history[4][60];
21 for (int i = 0; i < 4; i++) {
22 sprintf(old_history[i], "%s", creature_ptr->history[i]);
25 for (int i = 0; i < 4; i++) {
28 for (j = 0; creature_ptr->history[i][j]; j++)
32 creature_ptr->history[i][j] = ' ';
33 creature_ptr->history[i][59] = '\0';
36 display_player(creature_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(creature_ptr->history[i], i + 12, 10);
48 if (iskanji2(creature_ptr->history[y], x))
49 c_put_str(TERM_L_BLUE, format("%c%c", creature_ptr->history[y][x], creature_ptr->history[y][x + 1]), y + 12, x + 10);
52 c_put_str(TERM_L_BLUE, format("%c", creature_ptr->history[y][x]), y + 12, x + 10);
54 term_gotoxy(x + 10, y + 12);
55 int skey = inkey_special(TRUE);
56 if (!(skey & SKEY_MASK))
61 if (skey == SKEY_UP || c == KTRL('p')) {
66 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
69 } else if (skey == SKEY_DOWN || c == KTRL('n')) {
74 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
77 } else if (skey == SKEY_RIGHT || c == KTRL('f')) {
79 if (iskanji2(creature_ptr->history[y], x))
88 } else if (skey == SKEY_LEFT || c == KTRL('b')) {
99 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
102 } else if (c == '\r' || c == '\n') {
103 term_erase(0, 11, 255);
104 term_erase(0, 17, 255);
105 put_str(_("(キャラクターの生い立ち - 編集済み)", "(Character Background - Edited)"), 11, 20);
107 } else if (c == ESCAPE) {
109 put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
110 for (int i = 0; i < 4; i++) {
111 sprintf(creature_ptr->history[i], "%s", old_history[i]);
112 put_str(creature_ptr->history[i], i + 12, 10);
116 } else if (c == KTRL('A')) {
117 if (read_histpref(creature_ptr, process_autopick_file_command)) {
119 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
123 } else if (c == '\010') {
133 creature_ptr->history[y][x] = ' ';
135 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1))) {
137 creature_ptr->history[y][x] = ' ';
142 else if (iskanji(c) || isprint(c))
144 else if (isprint(c)) /* BUGFIX */
148 if (iskanji2(creature_ptr->history[y], x)) {
149 creature_ptr->history[y][x + 1] = ' ';
160 if (iskanji2(creature_ptr->history[y], x + 1)) {
161 creature_ptr->history[y][x + 2] = ' ';
164 creature_ptr->history[y][x++] = c;
169 creature_ptr->history[y][x++] = c;