#include "autopick/autopick.h"
#include "cmd-io/cmd-autopick.h"
#include "cmd-io/cmd-dump.h"
-#include "core/player-redraw-types.h"
+#include "core/asking-player.h"
#include "core/show-file.h"
#include "core/window-redrawer.h"
#include "floor/geometry.h"
#include "main/sound-of-music.h"
#include "system/game-option-types.h"
#include "system/player-type-definition.h"
+#include "system/redrawing-flags-updater.h"
#include "term/gameterm.h"
#include "term/screen-processor.h"
#include "term/term-color-types.h"
+#include "term/z-form.h"
#include "util/bit-flags-calculator.h"
#include "util/int-char-converter.h"
#include "util/string-processor.h"
#define OPT_NUM 15
-typedef struct {
+struct opts {
char key;
concptr name;
int row;
-} opts;
+};
static opts option_fields[OPT_NUM] = {
{ '1', _(" キー入力 オプション", "Input Options"), 3 },
* @brief 自動セーブオプションを変更するコマンドのメインルーチン
* @param info 表示メッセージ
*/
-static void do_cmd_options_autosave(player_type *player_ptr, concptr info)
+static void do_cmd_options_autosave(PlayerType *player_ptr, concptr info)
{
char ch;
int i, k = 0, n = 2;
- char buf[80];
term_clear();
while (true) {
- sprintf(buf,
- _("%s ( リターンで次へ, y/n でセット, F で頻度を入力, ESC で決定 ) ", "%s (RET to advance, y/n to set, 'F' for frequency, ESC to accept) "), info);
- prt(buf, 0, 0);
+ prt(format(_("%s ( リターンで次へ, y/n でセット, F で頻度を入力, ESC で決定 ) ", "%s (RET to advance, y/n to set, 'F' for frequency, ESC to accept) "), info), 0, 0);
for (i = 0; i < n; i++) {
byte a = TERM_WHITE;
- if (i == k)
+ if (i == k) {
a = TERM_L_BLUE;
+ }
- sprintf(
- buf, "%-48s: %s (%s)", autosave_info[i].o_desc, (*autosave_info[i].o_var ? _("はい ", "yes") : _("いいえ", "no ")), autosave_info[i].o_text);
- c_prt(a, buf, i + 2, 0);
+ c_prt(a, format("%-48s: %s (%s)", autosave_info[i].o_desc, (*autosave_info[i].o_var ? _("はい ", "yes") : _("いいえ", "no ")), autosave_info[i].o_text), i + 2, 0);
}
prt(format(_("自動セーブの頻度: %d ターン毎", "Timed autosave frequency: every %d turns"), autosave_freq), 5, 0);
static void set_window_flag(int x, int y)
{
auto flag = i2enum<window_redraw_type>(1UL << y);
- if (any_bits(PW_ALL, flag))
+ if (any_bits(PW_ALL, flag)) {
set_bits(window_flag[x], flag);
+ }
}
/*!
* @brief ウィンドウオプションを変更するコマンドのメインルーチン /
* Modify the "window" options
*/
-static void do_cmd_options_win(player_type *player_ptr)
+static void do_cmd_options_win(PlayerType *player_ptr)
{
int i, j, d;
TERM_LEN y = 0;
for (j = 0; j < 8; j++) {
byte a = TERM_WHITE;
concptr s = angband_term_name[j];
- if (j == x)
+ if (j == x) {
a = TERM_L_BLUE;
+ }
term_putstr(35 + j * 5 - strlen(s) / 2, 2 + j % 2, -1, a, s);
}
for (i = 0; i < 16; i++) {
byte a = TERM_WHITE;
concptr str = window_flag_desc[i];
- if (i == y)
+ if (i == y) {
a = TERM_L_BLUE;
+ }
- if (!str)
+ if (!str) {
str = _("(未使用)", "(Unused option)");
+ }
term_putstr(0, i + 5, -1, a, str);
for (j = 0; j < 8; j++) {
char c = '.';
a = TERM_WHITE;
- if ((i == y) && (j == x))
+ if ((i == y) && (j == x)) {
a = TERM_L_BLUE;
+ }
- if (window_flag[j] & (1UL << i))
+ if (window_flag[j] & (1UL << i)) {
c = 'X';
+ }
term_putch(35 + j * 5, i + 5, a, c);
}
case 'T':
has_flag = has_window_flag(x, y);
window_flag[x] = 0;
- if (x > 0 && !has_flag)
+ if (x > 0 && !has_flag) {
set_window_flag(x, y);
+ }
break;
case 's':
case 'S':
- if (x == 0)
+ if (x == 0) {
break;
+ }
window_flag[x] = 0;
clear_window_flag(x, y);
set_window_flag(x, y);
d = get_keymap_dir(ch);
x = (x + ddx[d] + 8) % 8;
y = (y + ddy[d] + 16) % 16;
- if (!d)
+ if (!d) {
bell();
+ }
break;
}
}
- for (j = 0; j < 8; j++) {
- term_type *old = Term;
- if (!angband_term[j])
+ for (auto term_index = 0U; term_index < angband_terms.size(); ++term_index) {
+ term_type *old = game_term;
+ if (!angband_terms[term_index]) {
continue;
+ }
- if (window_flag[j] == old_flag[j])
+ if (window_flag[term_index] == old_flag[term_index]) {
continue;
+ }
- term_activate(angband_term[j]);
+ term_activate(angband_terms[term_index]);
term_clear();
term_fresh();
term_activate(old);
* Interact with some options for cheating
* @param info 表示メッセージ
*/
-static void do_cmd_options_cheat(player_type *player_ptr, concptr info)
+static void do_cmd_options_cheat(PlayerType *player_ptr, concptr info)
{
- char ch;
- int i, k = 0, n = MAX_CHEAT_OPTIONS;
- char buf[80];
term_clear();
+ auto k = 0U;
+ const auto n = cheat_info.size();
while (true) {
- DIRECTION dir;
- sprintf(buf, _("%s ( リターンで次へ, y/n でセット, ESC で決定 )", "%s (RET to advance, y/n to set, ESC to accept) "), info);
- prt(buf, 0, 0);
+ prt(format(_("%s ( リターンで次へ, y/n でセット, ESC で決定 )", "%s (RET to advance, y/n to set, ESC to accept) "), info), 0, 0);
#ifdef JP
/* 詐欺オプションをうっかりいじってしまう人がいるようなので注意 */
prt(" 後に解除してもダメですので、勝利者を目指す方はここのオプションはい", 13, 0);
prt(" じらないようにして下さい。", 14, 0);
#endif
- for (i = 0; i < n; i++) {
- byte a = TERM_WHITE;
- if (i == k)
+ for (auto i = 0U; i < n; i++) {
+ auto a = TERM_WHITE;
+ if (i == k) {
a = TERM_L_BLUE;
+ }
- sprintf(buf, "%-48s: %s (%s)", cheat_info[i].o_desc, (*cheat_info[i].o_var ? _("はい ", "yes") : _("いいえ", "no ")), cheat_info[i].o_text);
- c_prt(a, buf, i + 2, 0);
+ c_prt(enum2i(a), format("%-48s: %s (%s)", cheat_info[i].o_desc, (*cheat_info[i].o_var ? _("はい ", "yes") : _("いいえ", "no ")), cheat_info[i].o_text), i + 2, 0);
}
move_cursor(k + 2, 50);
- ch = inkey();
- dir = get_keymap_dir(ch);
- if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8))
+ auto ch = inkey();
+ auto dir = get_keymap_dir(ch);
+ if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8)) {
ch = I2D(dir);
+ }
switch (ch) {
- case ESCAPE: {
+ case ESCAPE:
return;
- }
case '-':
- case '8': {
+ case '8':
k = (n + k - 1) % n;
break;
- }
case ' ':
case '\n':
case '\r':
- case '2': {
+ case '2':
k = (k + 1) % n;
break;
- }
case 'y':
case 'Y':
- case '6': {
- if (!w_ptr->noscore)
+ case '6':
+ if (!w_ptr->noscore) {
exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0,
_("詐欺オプションをONにして、スコアを残せなくなった。", "gave up sending score to use cheating options."));
+ }
- w_ptr->noscore |= (cheat_info[k].o_set * 256 + cheat_info[k].o_bit);
- (*cheat_info[k].o_var) = true;
+ w_ptr->noscore |= cheat_info[k].o_set * 256 + cheat_info[k].o_bit;
+ *cheat_info[k].o_var = true;
k = (k + 1) % n;
break;
- }
case 'n':
case 'N':
- case '4': {
- (*cheat_info[k].o_var) = false;
+ case '4':
+ *cheat_info[k].o_var = false;
k = (k + 1) % n;
break;
- }
- case '?': {
- strnfmt(buf, sizeof(buf), _("joption.txt#%s", "option.txt#%s"), cheat_info[k].o_text);
- (void)show_file(player_ptr, true, buf, nullptr, 0, 0);
+ case '?':
+ (void)show_file(player_ptr, true, std::string(_("joption.txt#", "option.txt#")).append(cheat_info[k].o_text).data(), nullptr, 0, 0);
term_clear();
break;
- }
- default: {
+ default:
bell();
break;
}
- }
}
}
* in any options which control "visual" aspects of the game.
* </pre>
*/
-void do_cmd_options(player_type *player_ptr)
+void do_cmd_options(PlayerType *player_ptr)
{
+ TermCenteredOffsetSetter tcos(MAIN_TERM_MIN_COLS, MAIN_TERM_MIN_ROWS);
+
char k;
int d, skey;
TERM_LEN i, y = 0;
screen_save();
while (true) {
int n = OPT_NUM;
- if (!w_ptr->noscore && !allow_debug_opts)
+ if (!w_ptr->noscore && !allow_debug_opts) {
n--;
+ }
term_clear();
prt(_("[ オプションの設定 ]", "Game options"), 1, 0);
while (true) {
for (i = 0; i < n; i++) {
byte a = TERM_WHITE;
- if (i == y)
+ if (i == y) {
a = TERM_L_BLUE;
+ }
term_putstr(5, option_fields[i].row, -1, a, format("(%c) %s", toupper(option_fields[i].key), option_fields[i].name));
}
prt(_("<方向>で移動, Enterで決定, ESCでキャンセル, ?でヘルプ: ", "Move to <dir>, Select to Enter, Cancel to ESC, ? to help: "), 21, 0);
skey = inkey_special(true);
- if (!(skey & SKEY_MASK))
+ if (!(skey & SKEY_MASK)) {
k = (char)skey;
- else
+ } else {
k = 0;
+ }
- if (k == ESCAPE)
+ if (k == ESCAPE) {
break;
+ }
if (angband_strchr("\n\r ", k)) {
k = option_fields[y].key;
}
for (i = 0; i < n; i++) {
- if (tolower(k) == option_fields[i].key)
+ if (tolower(k) == option_fields[i].key) {
break;
+ }
}
- if (i < n)
+ if (i < n) {
break;
+ }
- if (k == '?')
+ if (k == '?') {
break;
+ }
d = 0;
- if (skey == SKEY_UP)
+ if (skey == SKEY_UP) {
d = 8;
- if (skey == SKEY_DOWN)
+ }
+ if (skey == SKEY_DOWN) {
d = 2;
+ }
y = (y + ddy[d] + n) % n;
- if (!d)
+ if (!d) {
bell();
+ }
}
- if (k == ESCAPE)
+ if (k == ESCAPE) {
break;
+ }
switch (k) {
case '1': {
case 'b': {
do_cmd_options_aux(player_ptr, OPT_PAGE_BIRTH,
(!w_ptr->wizard || !allow_debug_opts) ? _("初期オプション(参照のみ)", "Birth Options(browse only)")
- : _("初期オプション((*)はスコアに影響)", "Birth Options ((*)) affect score"));
+ : _("初期オプション((*)はスコアに影響)", "Birth Options ((*)) affect score"));
break;
}
- case 'C': {
+ case 'C':
+ case 'c': {
if (!w_ptr->noscore && !allow_debug_opts) {
bell();
break;
case 'D':
case 'd': {
clear_from(18);
- prt(_("コマンド: 基本ウェイト量", "Command: Base Delay Factor"), 19, 0);
- while (true) {
- int msec = delay_factor * delay_factor * delay_factor;
- prt(format(_("現在のウェイト: %d (%dミリ秒)", "Current base delay factor: %d (%d msec)"), delay_factor, msec), 22, 0);
- prt(_("ウェイト (0-9) ESCで決定: ", "Delay Factor (0-9 or ESC to accept): "), 20, 0);
- k = inkey();
- if (k == ESCAPE)
- break;
- else if (k == '?') {
- (void)show_file(player_ptr, true, _("joption.txt#BaseDelay", "option.txt#BaseDelay"), nullptr, 0, 0);
- term_clear();
- } else if (isdigit(k))
- delay_factor = D2I(k);
- else
- bell();
- }
-
+ prt(format(_("現在ウェイト量(msec): %d", "Current Delay Factor(msec): %d"), delay_factor), 19, 0);
+ (void)get_value(_("コマンド: ウェイト量(msec)", "Command: Delay Factor(msec)"), 0, 1000, &delay_factor);
+ clear_from(18);
break;
}
case 'H':
prt(format(_("現在の低ヒットポイント警告: %d0%%", "Current hitpoint warning: %d0%%"), hitpoint_warn), 22, 0);
prt(_("低ヒットポイント警告 (0-9) ESCで決定: ", "Hitpoint Warning (0-9 or ESC to accept): "), 20, 0);
k = inkey();
- if (k == ESCAPE)
+ if (k == ESCAPE) {
break;
- else if (k == '?') {
+ } else if (k == '?') {
(void)show_file(player_ptr, true, _("joption.txt#Hitpoint", "option.txt#Hitpoint"), nullptr, 0, 0);
term_clear();
- } else if (isdigit(k))
+ } else if (isdigit(k)) {
hitpoint_warn = D2I(k);
- else
+ } else {
bell();
+ }
}
break;
prt(format(_("現在の低魔力色閾値: %d0%%", "Current mana color threshold: %d0%%"), mana_warn), 22, 0);
prt(_("低魔力閾値 (0-9) ESCで決定: ", "Mana color Threshold (0-9 or ESC to accept): "), 20, 0);
k = inkey();
- if (k == ESCAPE)
+ if (k == ESCAPE) {
break;
- else if (k == '?') {
+ } else if (k == '?') {
(void)show_file(player_ptr, true, _("joption.txt#Manapoint", "option.txt#Manapoint"), nullptr, 0, 0);
term_clear();
- } else if (isdigit(k))
+ } else if (isdigit(k)) {
mana_warn = D2I(k);
- else
+ } else {
bell();
+ }
}
break;
}
screen_load();
- player_ptr->redraw |= (PR_EQUIPPY);
+ RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::EQUIPPY);
}
/*!
* @param page オプションページ番号
* @param info 表示メッセージ
*/
-void do_cmd_options_aux(player_type *player_ptr, game_option_types page, concptr info)
+void do_cmd_options_aux(PlayerType *player_ptr, game_option_types page, concptr info)
{
char ch;
int i, k = 0, n = 0, l;
- int opt[24];
- char buf[80];
+ int opt[MAIN_TERM_MIN_ROWS];
bool browse_only = (page == OPT_PAGE_BIRTH) && w_ptr->character_generated && (!w_ptr->wizard || !allow_debug_opts);
- for (i = 0; i < 24; i++)
+ for (i = 0; i < MAIN_TERM_MIN_ROWS; i++) {
opt[i] = 0;
+ }
for (i = 0; option_info[i].o_desc; i++) {
- if (option_info[i].o_page == page)
+ if (option_info[i].o_page == page) {
opt[n++] = i;
+ }
}
term_clear();
while (true) {
DIRECTION dir;
- sprintf(buf, _("%s (リターン:次, %sESC:終了, ?:ヘルプ) ", "%s (RET:next, %s, ?:help) "), info,
- browse_only ? _("", "ESC:exit") : _("y/n:変更, ", "y/n:change, ESC:accept"));
- prt(buf, 0, 0);
- if (page == OPT_PAGE_AUTODESTROY)
- c_prt(TERM_YELLOW, _("以下のオプションは、簡易自動破壊を使用するときのみ有効", "Following options will protect items from easy auto-destroyer."), 6,
- _(6, 3));
+ constexpr auto command = _("%s (リターン:次, %sESC:終了, ?:ヘルプ) ", "%s (RET:next, %s, ?:help) ");
+ prt(format(command, info, browse_only ? _("", "ESC:exit") : _("y/n:変更, ", "y/n:change, ESC:accept")), 0, 0);
+ if (page == OPT_PAGE_AUTODESTROY) {
+ constexpr auto mes = _("以下のオプションは、簡易自動破壊を使用するときのみ有効", "Following options will protect items from easy auto-destroyer.");
+ c_prt(TERM_YELLOW, mes, 6, _(6, 3));
+ }
for (i = 0; i < n; i++) {
byte a = TERM_WHITE;
- if (i == k)
+ if (i == k) {
a = TERM_L_BLUE;
+ }
- sprintf(buf, "%-48s: %s (%.19s)", option_info[opt[i]].o_desc, (*option_info[opt[i]].o_var ? _("はい ", "yes") : _("いいえ", "no ")),
+ std::string label = format("%-48s: %s (%.19s)", option_info[opt[i]].o_desc, (*option_info[opt[i]].o_var ? _("はい ", "yes") : _("いいえ", "no ")),
option_info[opt[i]].o_text);
- if ((page == OPT_PAGE_AUTODESTROY) && i > 2)
- c_prt(a, buf, i + 5, 0);
- else
- c_prt(a, buf, i + 2, 0);
+ if ((page == OPT_PAGE_AUTODESTROY) && i > 2) {
+ c_prt(a, label, i + 5, 0);
+ } else {
+ c_prt(a, label, i + 2, 0);
+ }
}
- if ((page == OPT_PAGE_AUTODESTROY) && (k > 2))
+ if ((page == OPT_PAGE_AUTODESTROY) && (k > 2)) {
l = 3;
- else
+ } else {
l = 0;
+ }
move_cursor(k + 2 + l, 50);
ch = inkey();
dir = get_keymap_dir(ch);
- if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8))
+ if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8)) {
ch = I2D(dir);
+ }
switch (ch) {
case ESCAPE: {
case 'y':
case 'Y':
case '6': {
- if (browse_only)
+ if (browse_only) {
break;
+ }
(*option_info[opt[k]].o_var) = true;
k = (k + 1) % n;
break;
case 'n':
case 'N':
case '4': {
- if (browse_only)
+ if (browse_only) {
break;
+ }
(*option_info[opt[k]].o_var) = false;
k = (k + 1) % n;
break;
}
case 't':
case 'T': {
- if (!browse_only)
+ if (!browse_only) {
(*option_info[opt[k]].o_var) = !(*option_info[opt[k]].o_var);
+ }
break;
}
case '?': {
- strnfmt(buf, sizeof(buf), _("joption.txt#%s", "option.txt#%s"), option_info[opt[k]].o_text);
- (void)show_file(player_ptr, true, buf, nullptr, 0, 0);
+ (void)show_file(player_ptr, true, std::string(_("joption.txt#", "option.txt#")).append(option_info[opt[k]].o_text).data(), nullptr, 0, 0);
term_clear();
break;
}