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 "view/display-player.h" // 暫定。後で消す.
12 * @brief 生い立ちメッセージを編集する。/Character background edit-mode
13 * @param player_ptr プレイヤーへの参照ポインタ
15 void edit_history(PlayerType *player_ptr)
17 char old_history[4][60];
18 for (int i = 0; i < 4; i++) {
19 sprintf(old_history[i], "%s", player_ptr->history[i]);
22 for (int i = 0; i < 4; i++) {
25 for (j = 0; player_ptr->history[i][j]; j++)
29 player_ptr->history[i][j] = ' ';
30 player_ptr->history[i][59] = '\0';
33 display_player(player_ptr, 1);
34 c_put_str(TERM_L_GREEN, _("(キャラクターの生い立ち - 編集モード)", "(Character Background - Edit Mode)"), 11, 20);
35 put_str(_("[ カーソルキーで移動、Enterで終了、Ctrl-Aでファイル読み込み ]", "[ Cursor key for Move, Enter for End, Ctrl-A for Read pref ]"), 17, 10);
41 for (int i = 0; i < 4; i++) {
42 put_str(player_ptr->history[i], i + 12, 10);
45 if (iskanji2(player_ptr->history[y], x)) {
46 char kanji[3] = { player_ptr->history[y][x], player_ptr->history[y][x + 1], '\0' };
47 c_put_str(TERM_L_BLUE, format("%s", kanji), y + 12, x + 10);
50 c_put_str(TERM_L_BLUE, format("%c", player_ptr->history[y][x]), y + 12, x + 10);
52 term_gotoxy(x + 10, y + 12);
53 int skey = inkey_special(true);
54 if (!(skey & SKEY_MASK))
59 if (skey == SKEY_UP || c == KTRL('p')) {
64 if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1)))
67 } else if (skey == SKEY_DOWN || c == KTRL('n')) {
72 if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1)))
75 } else if (skey == SKEY_RIGHT || c == KTRL('f')) {
77 if (iskanji2(player_ptr->history[y], x))
86 } else if (skey == SKEY_LEFT || c == KTRL('b')) {
97 if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1)))
100 } else if (c == '\r' || c == '\n') {
101 term_erase(0, 11, 255);
102 term_erase(0, 17, 255);
103 put_str(_("(キャラクターの生い立ち - 編集済み)", "(Character Background - Edited)"), 11, 20);
105 } else if (c == ESCAPE) {
107 put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
108 for (int i = 0; i < 4; i++) {
109 sprintf(player_ptr->history[i], "%s", old_history[i]);
110 put_str(player_ptr->history[i], i + 12, 10);
114 } else if (c == KTRL('A')) {
115 if (read_histpref(player_ptr)) {
117 if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1)))
121 } else if (c == '\010') {
131 player_ptr->history[y][x] = ' ';
133 if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1))) {
135 player_ptr->history[y][x] = ' ';
140 else if (iskanji(c) || isprint(c))
142 else if (isprint(c)) /* BUGFIX */
146 if (iskanji2(player_ptr->history[y], x)) {
147 player_ptr->history[y][x + 1] = ' ';
158 if (iskanji2(player_ptr->history[y], x + 1)) {
159 player_ptr->history[y][x + 2] = ' ';
162 player_ptr->history[y][x++] = c;
167 player_ptr->history[y][x++] = c;