mirror of
https://git.zap.org.au/git/trader.git
synced 2024-12-04 14:46:45 -05:00
Move some functions from center() to pr_center()
This commit is contained in:
parent
b27af38537
commit
15f06bdc79
45
src/intf.c
45
src/intf.c
@ -371,6 +371,11 @@ void end_screen (void)
|
|||||||
|
|
||||||
void init_title (void)
|
void init_title (void)
|
||||||
{
|
{
|
||||||
|
chtype *chbuf;
|
||||||
|
int width;
|
||||||
|
int lines;
|
||||||
|
|
||||||
|
|
||||||
bkgd(attr_root_window);
|
bkgd(attr_root_window);
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
@ -379,8 +384,20 @@ void init_title (void)
|
|||||||
addch(attr_game_title | ' ');
|
addch(attr_game_title | ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
center(stdscr, 0, attr_game_title, "Star Traders");
|
chbuf = malloc(BUFSIZE * sizeof(chtype));
|
||||||
|
if (chbuf == NULL) {
|
||||||
|
err_exit_nomem();
|
||||||
|
}
|
||||||
|
|
||||||
|
lines = prepstr(chbuf, BUFSIZE, attr_game_title, 0, 0, 1, COLS,
|
||||||
|
&width, 1, "%s", _("Star Traders"));
|
||||||
|
if (lines < 0) {
|
||||||
|
errno_exit("init_title");
|
||||||
|
}
|
||||||
|
|
||||||
|
pr_center(stdscr, 0, 0, chbuf, lines, &width);
|
||||||
attrset(attr_root_window);
|
attrset(attr_root_window);
|
||||||
|
free(chbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -588,7 +605,7 @@ int txdlgbox (int maxlines, int ncols, int begin_y, int begin_x,
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (lines < 0) {
|
if (lines < 0) {
|
||||||
errno_exit("txdlgbox: `%s'", format);
|
errno_exit(_("txdlgbox: `%s'"), format);
|
||||||
}
|
}
|
||||||
|
|
||||||
newtxwin(usetitle ? lines + 6 : lines + 5, ncols, begin_y, begin_x,
|
newtxwin(usetitle ? lines + 6 : lines + 5, ncols, begin_y, begin_x,
|
||||||
@ -608,7 +625,7 @@ int txdlgbox (int maxlines, int ncols, int begin_y, int begin_x,
|
|||||||
norm_attr, 1, ncols - 4, &titlewidth, 1,
|
norm_attr, 1, ncols - 4, &titlewidth, 1,
|
||||||
"%s", boxtitle);
|
"%s", boxtitle);
|
||||||
if (titlelines < 0) {
|
if (titlelines < 0) {
|
||||||
errno_exit("txdlgbox: `%s'", boxtitle);
|
errno_exit(_("txdlgbox: `%s'"), boxtitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_center(curwin, 1, 0, titlebuf, titlelines, &titlewidth);
|
pr_center(curwin, 1, 0, titlebuf, titlelines, &titlewidth);
|
||||||
@ -1243,7 +1260,7 @@ int pr_left (WINDOW *win, int y, int x, const chtype *restrict chbuf,
|
|||||||
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
// pr_center: Print strings in chbuf centered in window
|
// pr_center: Print strings in chbuf centred in window
|
||||||
|
|
||||||
int pr_center (WINDOW *win, int y, int offset, const chtype *restrict chbuf,
|
int pr_center (WINDOW *win, int y, int offset, const chtype *restrict chbuf,
|
||||||
int lines, const int *restrict widthbuf)
|
int lines, const int *restrict widthbuf)
|
||||||
@ -2461,15 +2478,31 @@ bool answer_yesno (WINDOW *win, chtype attr_keys)
|
|||||||
|
|
||||||
void wait_for_key (WINDOW *win, int y, chtype attr)
|
void wait_for_key (WINDOW *win, int y, chtype attr)
|
||||||
{
|
{
|
||||||
|
chtype *chbuf;
|
||||||
|
int width;
|
||||||
|
int lines;
|
||||||
|
|
||||||
int key;
|
int key;
|
||||||
bool done;
|
bool done;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
keypad(win, true);
|
keypad(win, true);
|
||||||
meta(win, true);
|
meta(win, true);
|
||||||
wtimeout(win, -1);
|
wtimeout(win, -1);
|
||||||
|
|
||||||
center(win, y, attr, "[ Press <SPACE> to continue ] ");
|
chbuf = malloc(BUFSIZE * sizeof(chtype));
|
||||||
|
if (chbuf == NULL) {
|
||||||
|
err_exit_nomem();
|
||||||
|
}
|
||||||
|
|
||||||
|
lines = prepstr(chbuf, BUFSIZE, attr, 0, 0, 1, getmaxx(win) - 4,
|
||||||
|
&width, 1, _("[ Press <SPACE> to continue ] "));
|
||||||
|
if (lines < 0) {
|
||||||
|
errno_exit("wait_for_key");
|
||||||
|
}
|
||||||
|
|
||||||
|
pr_center(win, y, 0, chbuf, lines, &width);
|
||||||
wrefresh(win);
|
wrefresh(win);
|
||||||
|
|
||||||
done = false;
|
done = false;
|
||||||
@ -2490,6 +2523,8 @@ void wait_for_key (WINDOW *win, int y, chtype attr)
|
|||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(chbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,8 +272,8 @@ extern int txrefresh (void);
|
|||||||
Returns: int - OK is always returned
|
Returns: int - OK is always returned
|
||||||
|
|
||||||
This function creates a dialog box window using newtxwin(), displays
|
This function creates a dialog box window using newtxwin(), displays
|
||||||
boxtitle centered on the first line (if boxtitle is not NULL), displays
|
boxtitle centred on the first line (if boxtitle is not NULL), displays
|
||||||
format (and associated parameters) centered using prepstr(), then waits
|
format (and associated parameters) centred using prepstr(), then waits
|
||||||
for the user to press any key before closing the dialog box window.
|
for the user to press any key before closing the dialog box window.
|
||||||
Note that txrefresh() is NOT called once the window is closed.
|
Note that txrefresh() is NOT called once the window is closed.
|
||||||
*/
|
*/
|
||||||
@ -398,7 +398,7 @@ extern int pr_left (WINDOW *win, int y, int x, const chtype *restrict chbuf,
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: pr_center - Print strings in chbuf centered in window
|
Function: pr_center - Print strings in chbuf centred in window
|
||||||
Parameters: win - Window to use (should be curwin)
|
Parameters: win - Window to use (should be curwin)
|
||||||
y - Line on which to print first string
|
y - Line on which to print first string
|
||||||
offset - Column offset to add to position for each line
|
offset - Column offset to add to position for each line
|
||||||
@ -408,7 +408,7 @@ extern int pr_left (WINDOW *win, int y, int x, const chtype *restrict chbuf,
|
|||||||
Returns: int - ERR if more lines in chbuf[] than lines, else OK
|
Returns: int - ERR if more lines in chbuf[] than lines, else OK
|
||||||
|
|
||||||
This function takes the strings in the chtype array chbuf and prints
|
This function takes the strings in the chtype array chbuf and prints
|
||||||
them centered in the window win, offset by the parameter offset. Note
|
them centred in the window win, offset by the parameter offset. Note
|
||||||
that wrefresh() is NOT called. ERR is returned if there are more lines
|
that wrefresh() is NOT called. ERR is returned if there are more lines
|
||||||
in chbuf[] than are passed in the parameter lines.
|
in chbuf[] than are passed in the parameter lines.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user