mirror of
https://git.zap.org.au/git/trader.git
synced 2024-12-04 14:46:45 -05:00
Allow input keycodes in ask_number_players() to be localised
This commit is contained in:
parent
75503ab103
commit
e87c6ce9b3
24
src/game.c
24
src/game.c
@ -238,6 +238,7 @@ void init_game (void)
|
|||||||
|
|
||||||
static int ask_number_players (void)
|
static int ask_number_players (void)
|
||||||
{
|
{
|
||||||
|
char *keys_contgame;
|
||||||
chtype *chbuf;
|
chtype *chbuf;
|
||||||
int lines, maxwidth;
|
int lines, maxwidth;
|
||||||
int widthbuf[2];
|
int widthbuf[2];
|
||||||
@ -248,6 +249,9 @@ static int ask_number_players (void)
|
|||||||
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0, 2,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0, 2,
|
||||||
WIN_COLS - 7, widthbuf, 2,
|
WIN_COLS - 7, widthbuf, 2,
|
||||||
|
/* TRANSLATORS: The keycode <C> should be modified to
|
||||||
|
match that (or those) specified with msgctxt
|
||||||
|
"input|ContinueGame". */
|
||||||
_("Enter number of players [^{1^}-^{%d^}] "
|
_("Enter number of players [^{1^}-^{%d^}] "
|
||||||
"or ^{<C>^} to continue a game: "), MAX_PLAYERS);
|
"or ^{<C>^} to continue a game: "), MAX_PLAYERS);
|
||||||
assert(lines == 1 || lines == 2);
|
assert(lines == 1 || lines == 2);
|
||||||
@ -260,14 +264,25 @@ static int ask_number_players (void)
|
|||||||
curs_set(CURS_ON);
|
curs_set(CURS_ON);
|
||||||
wrefresh(curwin);
|
wrefresh(curwin);
|
||||||
|
|
||||||
|
/* TRANSLATORS: This string specifies the keycodes used to continue a
|
||||||
|
game; these must NOT contain any numeric digit from 1 to 9. The
|
||||||
|
first character (keyboard input code) is used to print the user's
|
||||||
|
response if one of those keys is pressed. Both upper and
|
||||||
|
lower-case versions should be present. */
|
||||||
|
keys_contgame = xstrdup(pgettext("input|ContinueGame", "Cc"));
|
||||||
|
|
||||||
done = false;
|
done = false;
|
||||||
while (! done) {
|
while (! done) {
|
||||||
key = toupper(gettxchar(curwin));
|
key = gettxchar(curwin);
|
||||||
|
|
||||||
if (key >= '1' && key <= MAX_PLAYERS + '0') {
|
if (key >= '1' && key <= MAX_PLAYERS + '0') {
|
||||||
wechochar(curwin, key | A_BOLD);
|
wechochar(curwin, key | A_BOLD);
|
||||||
ret = key - '0';
|
ret = key - '0';
|
||||||
done = true;
|
done = true;
|
||||||
|
} else if (strchr(keys_contgame, key) != NULL) {
|
||||||
|
wechochar(curwin, ((unsigned char) *keys_contgame) | A_BOLD);
|
||||||
|
ret = 0;
|
||||||
|
done = true;
|
||||||
} else {
|
} else {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case KEY_ESC:
|
case KEY_ESC:
|
||||||
@ -280,12 +295,6 @@ static int ask_number_players (void)
|
|||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
|
||||||
wechochar(curwin, key | A_BOLD);
|
|
||||||
ret = 0;
|
|
||||||
done = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
@ -293,6 +302,7 @@ static int ask_number_players (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
curs_set(CURS_OFF);
|
curs_set(CURS_OFF);
|
||||||
|
free(keys_contgame);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user