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 プレーヤーへの参照ポインタ
17 void edit_history(player_type *creature_ptr)
19 char old_history[4][60];
20 for (int i = 0; i < 4; i++) {
21 sprintf(old_history[i], "%s", creature_ptr->history[i]);
24 for (int i = 0; i < 4; i++) {
27 for (j = 0; creature_ptr->history[i][j]; j++)
31 creature_ptr->history[i][j] = ' ';
32 creature_ptr->history[i][59] = '\0';
35 display_player(creature_ptr, 1);
36 c_put_str(TERM_L_GREEN, _("(キャラクターの生い立ち - 編集モード)", "(Character Background - Edit Mode)"), 11, 20);
37 put_str(_("[ カーソルキーで移動、Enterで終了、Ctrl-Aでファイル読み込み ]", "[ Cursor key for Move, Enter for End, Ctrl-A for Read pref ]"), 17, 10);
43 for (int i = 0; i < 4; i++) {
44 put_str(creature_ptr->history[i], i + 12, 10);
47 if (iskanji2(creature_ptr->history[y], x))
48 c_put_str(TERM_L_BLUE, format("%c%c", creature_ptr->history[y][x], creature_ptr->history[y][x + 1]), y + 12, x + 10);
51 c_put_str(TERM_L_BLUE, format("%c", creature_ptr->history[y][x]), y + 12, x + 10);
53 term_gotoxy(x + 10, y + 12);
54 int skey = inkey_special(TRUE);
55 if (!(skey & SKEY_MASK))
60 if (skey == SKEY_UP || c == KTRL('p')) {
65 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
68 } else if (skey == SKEY_DOWN || c == KTRL('n')) {
73 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
76 } else if (skey == SKEY_RIGHT || c == KTRL('f')) {
78 if (iskanji2(creature_ptr->history[y], x))
87 } else if (skey == SKEY_LEFT || c == KTRL('b')) {
98 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
101 } else if (c == '\r' || c == '\n') {
102 term_erase(0, 11, 255);
103 term_erase(0, 17, 255);
104 put_str(_("(キャラクターの生い立ち - 編集済み)", "(Character Background - Edited)"), 11, 20);
106 } else if (c == ESCAPE) {
108 put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
109 for (int i = 0; i < 4; i++) {
110 sprintf(creature_ptr->history[i], "%s", old_history[i]);
111 put_str(creature_ptr->history[i], i + 12, 10);
115 } else if (c == KTRL('A')) {
116 if (read_histpref(creature_ptr)) {
118 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
122 } else if (c == '\010') {
132 creature_ptr->history[y][x] = ' ';
134 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1))) {
136 creature_ptr->history[y][x] = ' ';
141 else if (iskanji(c) || isprint(c))
143 else if (isprint(c)) /* BUGFIX */
147 if (iskanji2(creature_ptr->history[y], x)) {
148 creature_ptr->history[y][x + 1] = ' ';
159 if (iskanji2(creature_ptr->history[y], x + 1)) {
160 creature_ptr->history[y][x + 2] = ' ';
163 creature_ptr->history[y][x++] = c;
168 creature_ptr->history[y][x++] = c;