#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/int-char-converter.h"
+#include "util/string-processor.h"
#include "view/display-player.h" // 暫定。後で消す.
/*!
*/
void edit_history(PlayerType *player_ptr)
{
- char old_history[4][60];
+ std::string old_history[4];
for (int i = 0; i < 4; i++) {
- sprintf(old_history[i], "%s", player_ptr->history[i]);
+ old_history[i] = player_ptr->history[i];
}
for (int i = 0; i < 4; i++) {
/* loop */
int j;
- for (j = 0; player_ptr->history[i][j]; j++)
+ for (j = 0; player_ptr->history[i][j]; j++) {
;
+ }
- for (; j < 59; j++)
+ for (; j < 59; j++) {
player_ptr->history[i][j] = ' ';
+ }
player_ptr->history[i][59] = '\0';
}
term_gotoxy(x + 10, y + 12);
int skey = inkey_special(true);
- if (!(skey & SKEY_MASK))
+ if (!(skey & SKEY_MASK)) {
c = (char)skey;
- else
+ } else {
c = 0;
+ }
if (skey == SKEY_UP || c == KTRL('p')) {
y--;
- if (y < 0)
+ if (y < 0) {
y = 3;
+ }
#ifdef JP
- if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1)))
+ if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1))) {
x--;
+ }
#endif
} else if (skey == SKEY_DOWN || c == KTRL('n')) {
y++;
- if (y > 3)
+ if (y > 3) {
y = 0;
+ }
#ifdef JP
- if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1)))
+ if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1))) {
x--;
+ }
#endif
} else if (skey == SKEY_RIGHT || c == KTRL('f')) {
#ifdef JP
- if (iskanji2(player_ptr->history[y], x))
+ if (iskanji2(player_ptr->history[y], x)) {
x++;
+ }
#endif
x++;
if (x > 58) {
x = 0;
- if (y < 3)
+ if (y < 3) {
y++;
+ }
}
} else if (skey == SKEY_LEFT || c == KTRL('b')) {
x--;
if (y) {
y--;
x = 58;
- } else
+ } else {
x = 0;
+ }
}
#ifdef JP
- if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1)))
+ if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1))) {
x--;
+ }
#endif
} else if (c == '\r' || c == '\n') {
term_erase(0, 11, 255);
clear_from(11);
put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
for (int i = 0; i < 4; i++) {
- sprintf(player_ptr->history[i], "%s", old_history[i]);
+ angband_strcpy(player_ptr->history[i], old_history[i].data(), sizeof(player_ptr->history[i]));
put_str(player_ptr->history[i], i + 12, 10);
}
} else if (c == KTRL('A')) {
if (read_histpref(player_ptr)) {
#ifdef JP
- if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1)))
+ if ((x > 0) && (iskanji2(player_ptr->history[y], x - 1))) {
x--;
+ }
#endif
}
} else if (c == '\010') {
if (y) {
y--;
x = 58;
- } else
+ } else {
x = 0;
+ }
}
player_ptr->history[y][x] = ' ';
if (x > 57) {
x = 0;
y++;
- if (y > 3)
+ if (y > 3) {
y = 0;
+ }
}
if (iskanji2(player_ptr->history[y], x + 1)) {
if (x > 58) {
x = 0;
y++;
- if (y > 3)
+ if (y > 3) {
y = 0;
+ }
}
}
}