1 #include "birth/history-editor.h"
2 #include "io/input-key-acceptor.h"
3 #include "io/read-pref-file.h"
4 #include "system/player-type-definition.h"
5 #include "term/screen-processor.h"
6 #include "term/term-color-types.h"
7 #include "util/int-char-converter.h"
8 #include "view/display-player.h" // 暫定。後で消す.
10 #include "locale/japanese.h"
14 * @brief 生い立ちメッセージを編集する。/Character background edit-mode
15 * @param creature_ptr プレーヤーへの参照ポインタ
18 void edit_history(player_type *creature_ptr)
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 char kanji[3] = { creature_ptr->history[y][x], creature_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", creature_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))
62 if (skey == SKEY_UP || c == KTRL('p')) {
67 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
70 } else if (skey == SKEY_DOWN || c == KTRL('n')) {
75 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
78 } else if (skey == SKEY_RIGHT || c == KTRL('f')) {
80 if (iskanji2(creature_ptr->history[y], x))
89 } else if (skey == SKEY_LEFT || c == KTRL('b')) {
100 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
103 } else if (c == '\r' || c == '\n') {
104 term_erase(0, 11, 255);
105 term_erase(0, 17, 255);
106 put_str(_("(キャラクターの生い立ち - 編集済み)", "(Character Background - Edited)"), 11, 20);
108 } else if (c == ESCAPE) {
110 put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
111 for (int i = 0; i < 4; i++) {
112 sprintf(creature_ptr->history[i], "%s", old_history[i]);
113 put_str(creature_ptr->history[i], i + 12, 10);
117 } else if (c == KTRL('A')) {
118 if (read_histpref(creature_ptr)) {
120 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
124 } else if (c == '\010') {
134 creature_ptr->history[y][x] = ' ';
136 if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1))) {
138 creature_ptr->history[y][x] = ' ';
143 else if (iskanji(c) || isprint(c))
145 else if (isprint(c)) /* BUGFIX */
149 if (iskanji2(creature_ptr->history[y], x)) {
150 creature_ptr->history[y][x + 1] = ' ';
161 if (iskanji2(creature_ptr->history[y], x + 1)) {
162 creature_ptr->history[y][x + 2] = ' ';
165 creature_ptr->history[y][x++] = c;
170 creature_ptr->history[y][x++] = c;