<ClCompile Include="..\..\src\birth\birth-stat.c" />\r
<ClCompile Include="..\..\src\birth\birth-util.c" />\r
<ClCompile Include="..\..\src\birth\game-play-initializer.c" />\r
+ <ClCompile Include="..\..\src\birth\history-editor.c" />\r
<ClCompile Include="..\..\src\birth\history-generator.c" />\r
<ClCompile Include="..\..\src\birth\initial-equipments-table.c" />\r
<ClCompile Include="..\..\src\birth\inventory-initializer.c" />\r
<ClInclude Include="..\..\src\birth\birth-stat.h" />\r
<ClInclude Include="..\..\src\birth\birth-util.h" />\r
<ClInclude Include="..\..\src\birth\game-play-initializer.h" />\r
+ <ClInclude Include="..\..\src\birth\history-editor.h" />\r
<ClInclude Include="..\..\src\birth\history-generator.h" />\r
<ClInclude Include="..\..\src\birth\initial-equipments-table.h" />\r
<ClInclude Include="..\..\src\birth\inventory-initializer.h" />\r
<ClCompile Include="..\..\src\birth\game-play-initializer.c">
<Filter>birth</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\birth\history-editor.c">
+ <Filter>birth</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\cmd\cmd-activate.h">
<ClInclude Include="..\..\src\birth\game-play-initializer.h">
<Filter>birth</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\birth\history-editor.h">
+ <Filter>birth</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\wall.bmp" />
birth/initial-equipments-table.c birth/initial-equipments-table.h \
birth/inventory-initializer.c birth/inventory-initializer.h \
birth/game-play-initializer.c birth/game-play-initializer.h \
+ birth/history-editor.c birth/history-editor.h \
\
main/music-definitions-table.c main/music-definitions-table.h \
main/sound-definitions-table.c main/sound-definitions-table.h \
#include "floor/floor.h"
#include "birth/history.h"
#include "io/write-diary.h"
-#include "locale/japanese.h"
#include "market/store.h"
#include "monster/monster.h"
#include "monster/monster-race.h"
#include "view/display-birth.h" // 暫定。後で消す予定。
#include "birth/inventory-initializer.h"
#include "birth/game-play-initializer.h"
+#include "birth/history-editor.h"
+#include "io/read-pref-file.h"
/*!
* オートローラーの内容を描画する間隔 /
return TRUE;
}
-#define HISTPREF_LIMIT 1024
-static char* histpref_buf = NULL;
-
-/*!
- * @brief 生い立ちメッセージの内容をバッファに加える。 / Hook function for reading the histpref.prf file.
- * @return なし
- */
-void add_history_from_pref_line(concptr t)
-{
- if (!histpref_buf)
- return;
-
- my_strcat(histpref_buf, t, HISTPREF_LIMIT);
-}
-
-/*!
- * @brief 生い立ちメッセージをファイルからロードする。
- * @return なし
- */
-static bool do_cmd_histpref(player_type* creature_ptr, void (*process_autopick_file_command)(char*))
-{
- char buf[80];
- errr err;
- int i, j, n;
- char *s, *t;
- char temp[64 * 4];
- char histbuf[HISTPREF_LIMIT];
-
- if (!get_check(_("生い立ち設定ファイルをロードしますか? ", "Load background history preference file? ")))
- return FALSE;
-
- histbuf[0] = '\0';
- histpref_buf = histbuf;
-
- sprintf(buf, _("histedit-%s.prf", "histpref-%s.prf"), creature_ptr->base_name);
- err = process_histpref_file(creature_ptr, buf, process_autopick_file_command);
-
- if (0 > err) {
- strcpy(buf, _("histedit.prf", "histpref.prf"));
- err = process_histpref_file(creature_ptr, buf, process_autopick_file_command);
- }
-
- if (err) {
- msg_print(_("生い立ち設定ファイルの読み込みに失敗しました。", "Failed to load background history preference."));
- msg_print(NULL);
- histpref_buf = NULL;
- return FALSE;
- } else if (!histpref_buf[0]) {
- msg_print(_("有効な生い立ち設定はこのファイルにありません。", "There does not exist valid background history preference."));
- msg_print(NULL);
- histpref_buf = NULL;
- return FALSE;
- }
-
- for (i = 0; i < 4; i++)
- creature_ptr->history[i][0] = '\0';
-
- /* loop */
- for (s = histpref_buf; *s == ' '; s++)
- ;
-
- n = strlen(s);
- while ((n > 0) && (s[n - 1] == ' '))
- s[--n] = '\0';
-
- roff_to_buf(s, 60, temp, sizeof(temp));
- t = temp;
- for (i = 0; i < 4; i++) {
- if (t[0] == 0)
- break;
- else {
- strcpy(creature_ptr->history[i], t);
- t += strlen(t) + 1;
- }
- }
-
- for (i = 0; i < 4; i++) {
- /* loop */
- for (j = 0; creature_ptr->history[i][j]; j++)
- ;
-
- for (; j < 59; j++)
- creature_ptr->history[i][j] = ' ';
- creature_ptr->history[i][59] = '\0';
- }
-
- histpref_buf = NULL;
- return TRUE;
-}
-
-/*!
- * @brief 生い立ちメッセージを編集する。/Character background edit-mode
- * @return なし
- */
-static void edit_history(player_type* creature_ptr, void (*process_autopick_file_command)(char*))
-{
- char old_history[4][60];
- for (int i = 0; i < 4; i++) {
- sprintf(old_history[i], "%s", creature_ptr->history[i]);
- }
-
- for (int i = 0; i < 4; i++) {
- /* loop */
- int j;
- for (j = 0; creature_ptr->history[i][j]; j++)
- ;
-
- for (; j < 59; j++)
- creature_ptr->history[i][j] = ' ';
- creature_ptr->history[i][59] = '\0';
- }
-
- display_player(creature_ptr, 1, map_name);
- c_put_str(TERM_L_GREEN, _("(キャラクターの生い立ち - 編集モード)", "(Character Background - Edit Mode)"), 11, 20);
- put_str(_("[ カーソルキーで移動、Enterで終了、Ctrl-Aでファイル読み込み ]", "[ Cursor key for Move, Enter for End, Ctrl-A for Read pref ]"), 17, 10);
- TERM_LEN y = 0;
- TERM_LEN x = 0;
- while (TRUE) {
- int skey;
- char c;
-
- for (int i = 0; i < 4; i++) {
- put_str(creature_ptr->history[i], i + 12, 10);
- }
-#ifdef JP
- if (iskanji2(creature_ptr->history[y], x))
- c_put_str(TERM_L_BLUE, format("%c%c", creature_ptr->history[y][x], creature_ptr->history[y][x + 1]), y + 12, x + 10);
- else
-#endif
- c_put_str(TERM_L_BLUE, format("%c", creature_ptr->history[y][x]), y + 12, x + 10);
-
- Term_gotoxy(x + 10, y + 12);
- skey = inkey_special(TRUE);
- if (!(skey & SKEY_MASK))
- c = (char)skey;
- else
- c = 0;
-
- if (skey == SKEY_UP || c == KTRL('p')) {
- y--;
- if (y < 0)
- y = 3;
-#ifdef JP
- if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
- x--;
-#endif
- } else if (skey == SKEY_DOWN || c == KTRL('n')) {
- y++;
- if (y > 3)
- y = 0;
-#ifdef JP
- if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
- x--;
-#endif
- } else if (skey == SKEY_RIGHT || c == KTRL('f')) {
-#ifdef JP
- if (iskanji2(creature_ptr->history[y], x))
- x++;
-#endif
- x++;
- if (x > 58) {
- x = 0;
- if (y < 3)
- y++;
- }
- } else if (skey == SKEY_LEFT || c == KTRL('b')) {
- x--;
- if (x < 0) {
- if (y) {
- y--;
- x = 58;
- } else
- x = 0;
- }
-
-#ifdef JP
- if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
- x--;
-#endif
- } else if (c == '\r' || c == '\n') {
- Term_erase(0, 11, 255);
- Term_erase(0, 17, 255);
- put_str(_("(キャラクターの生い立ち - 編集済み)", "(Character Background - Edited)"), 11, 20);
- break;
- } else if (c == ESCAPE) {
- clear_from(11);
- put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
- for (int i = 0; i < 4; i++) {
- sprintf(creature_ptr->history[i], "%s", old_history[i]);
- put_str(creature_ptr->history[i], i + 12, 10);
- }
-
- break;
- } else if (c == KTRL('A')) {
- if (do_cmd_histpref(creature_ptr, process_autopick_file_command)) {
-#ifdef JP
- if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
- x--;
-#endif
- }
- } else if (c == '\010') {
- x--;
- if (x < 0) {
- if (y) {
- y--;
- x = 58;
- } else
- x = 0;
- }
-
- creature_ptr->history[y][x] = ' ';
-#ifdef JP
- if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1))) {
- x--;
- creature_ptr->history[y][x] = ' ';
- }
-#endif
- }
-#ifdef JP
- else if (iskanji(c) || isprint(c))
-#else
- else if (isprint(c)) /* BUGFIX */
-#endif
- {
-#ifdef JP
- if (iskanji2(creature_ptr->history[y], x)) {
- creature_ptr->history[y][x + 1] = ' ';
- }
-
- if (iskanji(c)) {
- if (x > 57) {
- x = 0;
- y++;
- if (y > 3)
- y = 0;
- }
-
- if (iskanji2(creature_ptr->history[y], x + 1)) {
- creature_ptr->history[y][x + 2] = ' ';
- }
-
- creature_ptr->history[y][x++] = c;
-
- c = inkey();
- }
-#endif
- creature_ptr->history[y][x++] = c;
- if (x > 58) {
- x = 0;
- y++;
- if (y > 3)
- y = 0;
- }
- }
- }
-}
-
/*!
* @brief player_birth()関数のサブセット/Helper function for 'player_birth()'
* @details
extern s32b stat_match[6];
extern s32b auto_round;
-extern void add_history_from_pref_line(concptr t);
extern void player_birth(player_type *creature_ptr, void(*process_autopick_file_command)(char*));
--- /dev/null
+#include "system/angband.h"
+#include "birth/history-editor.h"
+#include "io/files.h"
+#include "view/display-main-window.h" // 暫定。後で消す.
+#include "term/gameterm.h"
+#include "view/display-player.h" // 暫定。後で消す.
+#include "locale/japanese.h"
+#include "io/read-pref-file.h"
+
+/*!
+ * @brief 生い立ちメッセージを編集する。/Character background edit-mode
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param process_autopick_file_command 自動拾いファイルコマンドへの関数ポインタ
+ * @return なし
+ */
+void edit_history(player_type *creature_ptr, void (*process_autopick_file_command)(char *))
+{
+ char old_history[4][60];
+ for (int i = 0; i < 4; i++) {
+ sprintf(old_history[i], "%s", creature_ptr->history[i]);
+ }
+
+ for (int i = 0; i < 4; i++) {
+ /* loop */
+ int j;
+ for (j = 0; creature_ptr->history[i][j]; j++)
+ ;
+
+ for (; j < 59; j++)
+ creature_ptr->history[i][j] = ' ';
+ creature_ptr->history[i][59] = '\0';
+ }
+
+ display_player(creature_ptr, 1, map_name);
+ c_put_str(TERM_L_GREEN, _("(キャラクターの生い立ち - 編集モード)", "(Character Background - Edit Mode)"), 11, 20);
+ put_str(_("[ カーソルキーで移動、Enterで終了、Ctrl-Aでファイル読み込み ]", "[ Cursor key for Move, Enter for End, Ctrl-A for Read pref ]"), 17, 10);
+ TERM_LEN y = 0;
+ TERM_LEN x = 0;
+ while (TRUE) {
+ char c;
+
+ for (int i = 0; i < 4; i++) {
+ put_str(creature_ptr->history[i], i + 12, 10);
+ }
+#ifdef JP
+ if (iskanji2(creature_ptr->history[y], x))
+ c_put_str(TERM_L_BLUE, format("%c%c", creature_ptr->history[y][x], creature_ptr->history[y][x + 1]), y + 12, x + 10);
+ else
+#endif
+ c_put_str(TERM_L_BLUE, format("%c", creature_ptr->history[y][x]), y + 12, x + 10);
+
+ Term_gotoxy(x + 10, y + 12);
+ int skey = inkey_special(TRUE);
+ if (!(skey & SKEY_MASK))
+ c = (char)skey;
+ else
+ c = 0;
+
+ if (skey == SKEY_UP || c == KTRL('p')) {
+ y--;
+ if (y < 0)
+ y = 3;
+#ifdef JP
+ if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
+ x--;
+#endif
+ } else if (skey == SKEY_DOWN || c == KTRL('n')) {
+ y++;
+ if (y > 3)
+ y = 0;
+#ifdef JP
+ if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
+ x--;
+#endif
+ } else if (skey == SKEY_RIGHT || c == KTRL('f')) {
+#ifdef JP
+ if (iskanji2(creature_ptr->history[y], x))
+ x++;
+#endif
+ x++;
+ if (x > 58) {
+ x = 0;
+ if (y < 3)
+ y++;
+ }
+ } else if (skey == SKEY_LEFT || c == KTRL('b')) {
+ x--;
+ if (x < 0) {
+ if (y) {
+ y--;
+ x = 58;
+ } else
+ x = 0;
+ }
+
+#ifdef JP
+ if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
+ x--;
+#endif
+ } else if (c == '\r' || c == '\n') {
+ Term_erase(0, 11, 255);
+ Term_erase(0, 17, 255);
+ put_str(_("(キャラクターの生い立ち - 編集済み)", "(Character Background - Edited)"), 11, 20);
+ break;
+ } else if (c == ESCAPE) {
+ clear_from(11);
+ put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
+ for (int i = 0; i < 4; i++) {
+ sprintf(creature_ptr->history[i], "%s", old_history[i]);
+ put_str(creature_ptr->history[i], i + 12, 10);
+ }
+
+ break;
+ } else if (c == KTRL('A')) {
+ if (read_histpref(creature_ptr, process_autopick_file_command)) {
+#ifdef JP
+ if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1)))
+ x--;
+#endif
+ }
+ } else if (c == '\010') {
+ x--;
+ if (x < 0) {
+ if (y) {
+ y--;
+ x = 58;
+ } else
+ x = 0;
+ }
+
+ creature_ptr->history[y][x] = ' ';
+#ifdef JP
+ if ((x > 0) && (iskanji2(creature_ptr->history[y], x - 1))) {
+ x--;
+ creature_ptr->history[y][x] = ' ';
+ }
+#endif
+ }
+#ifdef JP
+ else if (iskanji(c) || isprint(c))
+#else
+ else if (isprint(c)) /* BUGFIX */
+#endif
+ {
+#ifdef JP
+ if (iskanji2(creature_ptr->history[y], x)) {
+ creature_ptr->history[y][x + 1] = ' ';
+ }
+
+ if (iskanji(c)) {
+ if (x > 57) {
+ x = 0;
+ y++;
+ if (y > 3)
+ y = 0;
+ }
+
+ if (iskanji2(creature_ptr->history[y], x + 1)) {
+ creature_ptr->history[y][x + 2] = ' ';
+ }
+
+ creature_ptr->history[y][x++] = c;
+
+ c = inkey();
+ }
+#endif
+ creature_ptr->history[y][x++] = c;
+ if (x > 58) {
+ x = 0;
+ y++;
+ if (y > 3)
+ y = 0;
+ }
+ }
+ }
+}
--- /dev/null
+#pragma once
+
+void edit_history(player_type *creature_ptr, void (*process_autopick_file_command)(char *));
#define MAX_MACRO_CHARS 65536 // 1つのマクロキー押下で実行可能なコマンド最大数 (エスケープシーケンス含む).
+char *histpref_buf = NULL;
+
/*!
* @brief Rトークンの解釈 / Process "R:<num>:<a>/<c>" -- attr/char for monster races
* @param buf バッファ
return 1;
}
}
+
+/*!
+ * @brief 生い立ちメッセージの内容をバッファに加える。 / Hook function for reading the histpref.prf file.
+ * @return なし
+ */
+void add_history_from_pref_line(concptr t)
+{
+ if (!histpref_buf)
+ return;
+
+ my_strcat(histpref_buf, t, HISTPREF_LIMIT);
+}
#include "system/angband.h"
+#define HISTPREF_LIMIT 1024
+
+extern char *histpref_buf;
+
errr interpret_pref_file(player_type *creature_ptr, char *buf);
+void add_history_from_pref_line(concptr t);
autopick_load_pref(player_ptr, FALSE);
}
+
+/*!
+ * @brief 生い立ちメッセージをファイルからロードする。
+ * @return なし
+ */
+bool read_histpref(player_type *creature_ptr, void (*process_autopick_file_command)(char *))
+{
+ char buf[80];
+ errr err;
+ int i, j, n;
+ char *s, *t;
+ char temp[64 * 4];
+ char histbuf[HISTPREF_LIMIT];
+
+ if (!get_check(_("生い立ち設定ファイルをロードしますか? ", "Load background history preference file? ")))
+ return FALSE;
+
+ histbuf[0] = '\0';
+ histpref_buf = histbuf;
+
+ sprintf(buf, _("histedit-%s.prf", "histpref-%s.prf"), creature_ptr->base_name);
+ err = process_histpref_file(creature_ptr, buf, process_autopick_file_command);
+
+ if (0 > err) {
+ strcpy(buf, _("histedit.prf", "histpref.prf"));
+ err = process_histpref_file(creature_ptr, buf, process_autopick_file_command);
+ }
+
+ if (err) {
+ msg_print(_("生い立ち設定ファイルの読み込みに失敗しました。", "Failed to load background history preference."));
+ msg_print(NULL);
+ histpref_buf = NULL;
+ return FALSE;
+ } else if (!histpref_buf[0]) {
+ msg_print(_("有効な生い立ち設定はこのファイルにありません。", "There does not exist valid background history preference."));
+ msg_print(NULL);
+ histpref_buf = NULL;
+ return FALSE;
+ }
+
+ for (i = 0; i < 4; i++)
+ creature_ptr->history[i][0] = '\0';
+
+ /* loop */
+ for (s = histpref_buf; *s == ' '; s++)
+ ;
+
+ n = strlen(s);
+ while ((n > 0) && (s[n - 1] == ' '))
+ s[--n] = '\0';
+
+ roff_to_buf(s, 60, temp, sizeof(temp));
+ t = temp;
+ for (i = 0; i < 4; i++) {
+ if (t[0] == 0)
+ break;
+ else {
+ strcpy(creature_ptr->history[i], t);
+ t += strlen(t) + 1;
+ }
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* loop */
+ for (j = 0; creature_ptr->history[i][j]; j++)
+ ;
+
+ for (; j < 59; j++)
+ creature_ptr->history[i][j] = ' ';
+ creature_ptr->history[i][59] = '\0';
+ }
+
+ histpref_buf = NULL;
+ return TRUE;
+}
errr process_pref_file(player_type *creature_ptr, concptr name, void(*process_autopick_file_command)(char*));
errr process_autopick_file(player_type *creature_ptr, concptr name, void(*process_autopick_file_command)(char*));
errr process_histpref_file(player_type *creature_ptr, concptr name, void(*process_autopick_file_command)(char*));
+bool read_histpref(player_type *creature_ptr, void (*process_autopick_file_command)(char *));
void auto_dump_printf(FILE *auto_dump_stream, concptr fmt, ...);
bool open_auto_dump(FILE **fpp, concptr buf, concptr mark);