mirror of
https://git.zap.org.au/git/trader.git
synced 2024-12-04 14:46:45 -05:00
Move to the new left/center/right functions; add maxlines parameter
This commit is contained in:
parent
22677c0d89
commit
82647cf691
175
src/game.c
175
src/game.c
@ -368,7 +368,7 @@ void ask_player_names (void)
|
||||
// Ask for the player's name
|
||||
|
||||
newtxwin(5, WIN_COLS - 4, 9, WCENTER, true, attr_normal_window);
|
||||
left(curwin, 2, 2, attr_normal, 0, 0, "Please enter your name: ");
|
||||
left(curwin, 2, 2, attr_normal, 0, 0, 1, "Please enter your name: ");
|
||||
|
||||
int x = getcurx(curwin);
|
||||
int w = getmaxx(curwin) - x - 2;
|
||||
@ -404,12 +404,12 @@ void ask_player_names (void)
|
||||
|
||||
newtxwin(number_players + 5, WIN_COLS - 4, 9, WCENTER,
|
||||
true, attr_normal_window);
|
||||
center(curwin, 1, 0, attr_title, 0, 0, " Enter Player Names ");
|
||||
center(curwin, 1, 0, attr_title, 0, 0, 1, " Enter Player Names ");
|
||||
|
||||
for (i = 0; i < number_players; i++) {
|
||||
player[i].name = NULL;
|
||||
entered[i] = false;
|
||||
left(curwin, i + 3, 2, attr_normal, 0, 0, "Player %d:", i + 1);
|
||||
left(curwin, i + 3, 2, attr_normal, 0, 0, 1, "Player %d:", i + 1);
|
||||
}
|
||||
|
||||
int x = getcurx(curwin) + 1;
|
||||
@ -508,8 +508,9 @@ void ask_player_names (void)
|
||||
|
||||
void end_game (void)
|
||||
{
|
||||
int i;
|
||||
char *buf;
|
||||
chtype *chbuf;
|
||||
int lines;
|
||||
int widthbuf[5];
|
||||
|
||||
|
||||
if (abort_game) {
|
||||
@ -517,14 +518,14 @@ void end_game (void)
|
||||
return;
|
||||
}
|
||||
|
||||
buf = xmalloc(BUFSIZE);
|
||||
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||
|
||||
txdlgbox(MAX_DLG_LINES, 50, 9, WCENTER, attr_error_window,
|
||||
attr_error_title, attr_error_highlight, 0, 0,
|
||||
attr_error_waitforkey, " Game Over ",
|
||||
"The game is over after %d turns.", turn_number - 1);
|
||||
|
||||
for (i = 0; i < number_players; i++) {
|
||||
for (int i = 0; i < number_players; i++) {
|
||||
show_status(i);
|
||||
}
|
||||
|
||||
@ -535,43 +536,45 @@ void end_game (void)
|
||||
total_value(0));
|
||||
} else {
|
||||
// Sort players on the basis of total value
|
||||
for (i = 0; i < number_players; i++) {
|
||||
for (int i = 0; i < number_players; i++) {
|
||||
player[i].sort_value = total_value(i);
|
||||
}
|
||||
qsort(player, number_players, sizeof(player_info_t), cmp_player);
|
||||
|
||||
newtxwin(number_players + 10, WIN_COLS - 4, 3, WCENTER,
|
||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight, attr_blink,
|
||||
5, WIN_COLS - 8, widthbuf, 5, (player[0].sort_value == 0) ?
|
||||
"The winner is ^{%s^}\n"
|
||||
"who is ^[*** BANKRUPT ***^]" :
|
||||
"The winner is ^{%s^}\n"
|
||||
"with a value of ^{%N^}.", player[0].name,
|
||||
player[0].sort_value);
|
||||
|
||||
newtxwin(number_players + lines + 8, WIN_COLS - 4, 3, WCENTER,
|
||||
true, attr_normal_window);
|
||||
center(curwin, 1, 0, attr_title, 0, 0, 1, " Game Winner ");
|
||||
centerch(curwin, 3, 0, chbuf, lines, widthbuf);
|
||||
|
||||
old_center(curwin, 1, attr_title, " Game Winner ");
|
||||
old_center2(curwin, 3, attr_normal, attr_highlight, "The winner is ",
|
||||
"%s", player[0].name);
|
||||
if (player[0].sort_value == 0.0) {
|
||||
old_center2(curwin, 4, attr_normal, attr_blink, "who is ",
|
||||
"*** BANKRUPT ***");
|
||||
} else {
|
||||
l_strfmon(buf, BUFSIZE, "%1n", player[0].sort_value);
|
||||
old_center2(curwin, 4, attr_normal, attr_highlight,
|
||||
"with a value of ", "%s", buf);
|
||||
}
|
||||
mvwhline(curwin, lines + 4, 2, ' ' | attr_subtitle,
|
||||
getmaxx(curwin) - 4);
|
||||
left(curwin, lines + 4, ORDINAL_COLS + 4, attr_subtitle, 0, 0, 1,
|
||||
"Player");
|
||||
right(curwin, lines + 4, getmaxx(curwin) - 4, attr_subtitle, 0, 0, 1,
|
||||
"Total Value (%s)", lconvinfo.currency_symbol);
|
||||
|
||||
int w = getmaxx(curwin) - 33;
|
||||
wattrset(curwin, attr_subtitle);
|
||||
snprintf(buf, BUFSIZE, "Total Value (%s)", lconvinfo.currency_symbol);
|
||||
mvwprintw(curwin, 6, 2, "%5s %-*.*s %18s ", "", w, w, "Player", buf);
|
||||
wattrset(curwin, attr_normal);
|
||||
|
||||
for (i = 0; i < number_players; i++) {
|
||||
l_strfmon(buf, BUFSIZE, "%!18n", player[i].sort_value);
|
||||
mvwprintw(curwin, i + 7, 2, "%5s %-*.*s %18s ",
|
||||
gettext(ordinal[i + 1]), w, w, player[i].name, buf);
|
||||
for (int i = 0; i < number_players; i++) {
|
||||
right(curwin, i + lines + 5, ORDINAL_COLS + 2, attr_normal, 0, 0,
|
||||
1, gettext(ordinal[i + 1]));
|
||||
left(curwin, i + lines + 5, ORDINAL_COLS + 4, attr_normal, 0, 0,
|
||||
1, "%s", player[i].name);
|
||||
right(curwin, i + lines + 5, getmaxx(curwin) - 2, attr_normal, 0,
|
||||
0, 1, " %!N ", player[i].sort_value);
|
||||
}
|
||||
|
||||
wait_for_key(curwin, getmaxy(curwin) - 2, attr_waitforkey);
|
||||
deltxwin();
|
||||
}
|
||||
|
||||
free(buf);
|
||||
free(chbuf);
|
||||
}
|
||||
|
||||
|
||||
@ -592,13 +595,12 @@ void show_map (bool closewin)
|
||||
mvwhline(curwin, 1, 2, ' ' | attr_mapwin_title, getmaxx(curwin) - 4);
|
||||
|
||||
// Display current player and turn number
|
||||
left(curwin, 1, 2, attr_mapwin_title, attr_mapwin_highlight, 0,
|
||||
left(curwin, 1, 2, attr_mapwin_title, attr_mapwin_highlight, 0, 1,
|
||||
" Player: ^{%s^} ", player[current_player].name);
|
||||
right(curwin, 1, getmaxx(curwin) - 2, attr_mapwin_title,
|
||||
attr_mapwin_highlight, attr_mapwin_blink, (turn_number != max_turn) ?
|
||||
" Turn: ^{%d^} " : " ^[*** Last Turn ***^] ", turn_number);
|
||||
|
||||
wattrset(curwin, attr_map_window);
|
||||
attr_mapwin_highlight, attr_mapwin_blink, 1,
|
||||
(turn_number != max_turn) ? " Turn: ^{%d^} " :
|
||||
" ^[*** Last Turn ***^] ", turn_number);
|
||||
|
||||
// Display the actual map
|
||||
for (y = 0; y < MAX_Y; y++) {
|
||||
@ -657,17 +659,15 @@ void show_status (int num)
|
||||
|
||||
newtxwin(MAX_COMPANIES + 15, WIN_COLS, 1, WCENTER, true,
|
||||
attr_normal_window);
|
||||
center(curwin, 1, 0, attr_title, 0, 0, " Stock Portfolio ");
|
||||
center(curwin, 2, 0, attr_normal, attr_highlight, 0, "Player: ^{%s^}",
|
||||
center(curwin, 1, 0, attr_title, 0, 0, 1, " Stock Portfolio ");
|
||||
center(curwin, 2, 0, attr_normal, attr_highlight, 0, 1, "Player: ^{%s^}",
|
||||
player[num].name);
|
||||
|
||||
val = total_value(num);
|
||||
if (val == 0.0) {
|
||||
center(curwin, 11, 0, attr_normal, attr_highlight, attr_blink,
|
||||
center(curwin, 11, 0, attr_normal, attr_highlight, attr_blink, 1,
|
||||
"^[* * * B A N K R U P T * * *^]");
|
||||
} else {
|
||||
char *buf = xmalloc(BUFSIZE);
|
||||
|
||||
// Check to see if any companies are on the map
|
||||
bool none = true;
|
||||
for (i = 0; i < MAX_COMPANIES; i++) {
|
||||
@ -678,52 +678,83 @@ void show_status (int num)
|
||||
}
|
||||
|
||||
if (none) {
|
||||
center(curwin, 8, 0, attr_normal, attr_highlight, 0,
|
||||
center(curwin, 8, 0, attr_normal, attr_highlight, 0, 1,
|
||||
"No companies on the map");
|
||||
} else {
|
||||
// Handle the locale's currency symbol
|
||||
snprintf(buf, BUFSIZE, "share (%s)", lconvinfo.currency_symbol);
|
||||
mvwhline(curwin, 4, 2, ' ' | attr_subtitle, getmaxx(curwin) - 4);
|
||||
mvwhline(curwin, 5, 2, ' ' | attr_subtitle, getmaxx(curwin) - 4);
|
||||
|
||||
wattrset(curwin, attr_subtitle);
|
||||
mvwprintw(curwin, 4, 2, " %-22s %12s %10s %10s %10s ",
|
||||
"", "Price per", "", "Holdings", "Company");
|
||||
mvwprintw(curwin, 5, 2, " %-22s %12s %10s %10s %10s ",
|
||||
"Company", buf, "Return (%)", "(shares)", "owner (%)");
|
||||
wattrset(curwin, attr_normal);
|
||||
left(curwin, 4, 4, attr_subtitle, 0, 0, 2, "\nCompany");
|
||||
right(curwin, 4, getmaxx(curwin) - 4, attr_subtitle, 0, 0, 2,
|
||||
"Ownership\n(%%)");
|
||||
right(curwin, 4, getmaxx(curwin) - 6 - OWNERSHIP_COLS,
|
||||
attr_subtitle, 0, 0, 2, "Holdings\n(shares)");
|
||||
right(curwin, 4, getmaxx(curwin) - 8 - OWNERSHIP_COLS
|
||||
- STOCK_OWNED_COLS, attr_subtitle, 0, 0, 2,
|
||||
"\nReturn (%%)");
|
||||
right(curwin, 4, getmaxx(curwin) - 10 - OWNERSHIP_COLS
|
||||
- STOCK_OWNED_COLS - SHARE_RETURN_COLS, attr_subtitle, 0, 0,
|
||||
2, "Price per\nshare (%s)", lconvinfo.currency_symbol);
|
||||
|
||||
for (line = 6, i = 0; i < MAX_COMPANIES; i++) {
|
||||
if (company[i].on_map) {
|
||||
l_strfmon(buf, BUFSIZE, "%!12n", company[i].share_price);
|
||||
mvwprintw(curwin, line, 2,
|
||||
" %-22s %10s %10.2f %'10ld %10.2f ",
|
||||
company[i].name, buf,
|
||||
company[i].share_return * 100.0,
|
||||
player[num].stock_owned[i],
|
||||
(company[i].stock_issued == 0) ? 0.0 :
|
||||
((double) player[num].stock_owned[i] * 100.0)
|
||||
/ company[i].stock_issued);
|
||||
left(curwin, line, 4, attr_normal, 0, 0, 1, "%s",
|
||||
company[i].name);
|
||||
|
||||
right(curwin, line, getmaxx(curwin) - 2, attr_normal, 0, 0,
|
||||
1, "%.2f ", (company[i].stock_issued == 0) ? 0.0 :
|
||||
((double) player[num].stock_owned[i] * 100.0)
|
||||
/ company[i].stock_issued);
|
||||
right(curwin, line, getmaxx(curwin) - 4 - OWNERSHIP_COLS,
|
||||
attr_normal, 0, 0, 1, "%'ld ",
|
||||
player[num].stock_owned[i]);
|
||||
right(curwin, line, getmaxx(curwin) - 6 - OWNERSHIP_COLS
|
||||
- STOCK_OWNED_COLS, attr_normal, 0, 0, 1, "%.2f ",
|
||||
company[i].share_return * 100.0);
|
||||
right(curwin, line, getmaxx(curwin) - 8 - OWNERSHIP_COLS
|
||||
- STOCK_OWNED_COLS - SHARE_RETURN_COLS, attr_normal,
|
||||
0, 0, 1, " %!N ", company[i].share_price);
|
||||
|
||||
line++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
line = 15;
|
||||
l_strfmon(buf, BUFSIZE, "%18n", player[num].cash);
|
||||
old_center2(curwin, line++, attr_normal, attr_highlight, "Current cash: ",
|
||||
" %s ", buf);
|
||||
line = MAX_COMPANIES + 7;
|
||||
|
||||
chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||
int width, x;
|
||||
|
||||
mkchstr(chbuf, BUFSIZE, attr_highlight, 0, 0, 1, getmaxx(curwin) / 2,
|
||||
&width, 1, "Total value: ");
|
||||
x = (getmaxx(curwin) + width - (TOTAL_VALUE_COLS + 2)) / 2;
|
||||
|
||||
right(curwin, line, x, attr_normal, attr_highlight, 0, 1,
|
||||
"Current cash: ");
|
||||
right(curwin, line, x + TOTAL_VALUE_COLS + 2, attr_normal,
|
||||
attr_highlight, 0, 1, " ^{%N^} ", player[num].cash);
|
||||
line++;
|
||||
|
||||
if (player[num].debt != 0.0) {
|
||||
l_strfmon(buf, BUFSIZE, "%18n", player[num].debt);
|
||||
old_center2(curwin, line++, attr_normal, attr_highlight,
|
||||
"Current debt: ", " %s ", buf);
|
||||
old_center2(curwin, line++, attr_normal, attr_highlight,
|
||||
"Interest rate: ", " %17.2f%% ", interest_rate * 100.0);
|
||||
right(curwin, line, x, attr_normal, attr_highlight, 0, 1,
|
||||
"Current debt: ");
|
||||
right(curwin, line, x + TOTAL_VALUE_COLS + 2, attr_normal,
|
||||
attr_highlight, 0, 1, " ^{%N^} ", player[num].debt);
|
||||
line++;
|
||||
|
||||
right(curwin, line, x, attr_normal, attr_highlight, 0, 1,
|
||||
"Interest rate: ");
|
||||
right(curwin, line, x + TOTAL_VALUE_COLS + 2, attr_normal,
|
||||
attr_highlight, 0, 1, " ^{%.2f%%^} ", interest_rate * 100.0);
|
||||
line++;
|
||||
}
|
||||
|
||||
l_strfmon(buf, BUFSIZE, "%18n", val);
|
||||
old_center2(curwin, line + 1, attr_highlight, attr_title,
|
||||
"Total value: ", " %s ", buf);
|
||||
rightch(curwin, line + 1, x, chbuf, 1, &width);
|
||||
whline(curwin, ' ' | attr_title, TOTAL_VALUE_COLS + 2);
|
||||
right(curwin, line + 1, x + TOTAL_VALUE_COLS + 2, attr_title, 0, 0, 1,
|
||||
" %N ", val);
|
||||
|
||||
free(buf);
|
||||
free(chbuf);
|
||||
}
|
||||
|
||||
wait_for_key(curwin, getmaxy(curwin) - 2, attr_waitforkey);
|
||||
|
@ -178,8 +178,8 @@ void show_help (void)
|
||||
wbkgd(curwin, attr_normal_window);
|
||||
box(curwin, 0, 0);
|
||||
|
||||
center(curwin, 1, 0, attr_title, 0, 0, " How to Play ");
|
||||
center(curwin, 2, 0, attr_normal, attr_highlight, 0,
|
||||
center(curwin, 1, 0, attr_title, 0, 0, 1, " How to Play ");
|
||||
center(curwin, 2, 0, attr_normal, attr_highlight, 0, 1,
|
||||
"Page %d of %d", curpage + 1, numpages);
|
||||
wmove(curwin, 4, 2);
|
||||
|
||||
@ -325,7 +325,7 @@ void show_help (void)
|
||||
s++;
|
||||
}
|
||||
|
||||
center(curwin, getmaxy(curwin) - 2, 0, attr_waitforkey, 0, 0,
|
||||
center(curwin, getmaxy(curwin) - 2, 0, attr_waitforkey, 0, 0, 1,
|
||||
(curpage == 0) ? "[ Press <SPACE> to continue ] " :
|
||||
"[ Press <SPACE> to continue or <BACKSPACE> "
|
||||
"for the previous page ] ");
|
||||
|
63
src/intf.c
63
src/intf.c
@ -409,7 +409,7 @@ void init_title (void)
|
||||
clear();
|
||||
|
||||
mvwhline(stdscr, 0, 0, ' ' | attr_game_title, COLS);
|
||||
center(stdscr, 0, 0, attr_game_title, 0, 0, _("Star Traders"));
|
||||
center(stdscr, 0, 0, attr_game_title, 0, 0, 1, _("Star Traders"));
|
||||
}
|
||||
|
||||
|
||||
@ -609,7 +609,7 @@ int txdlgbox (int maxlines, int ncols, int begin_y, int begin_x,
|
||||
true, bkgd_attr);
|
||||
|
||||
if (usetitle) {
|
||||
center(curwin, 1, 0, title_attr, 0, 0, boxtitle);
|
||||
center(curwin, 1, 0, title_attr, 0, 0, 1, boxtitle);
|
||||
}
|
||||
|
||||
centerch(curwin, usetitle ? 3 : 2, 0, chbuf, lines, widthbuf);
|
||||
@ -1345,25 +1345,30 @@ int rightch (WINDOW *win, int y, int x, const chtype *restrict chstr,
|
||||
// left: Print strings left-aligned
|
||||
|
||||
int left (WINDOW *win, int y, int x, chtype attr_norm, chtype attr_alt1,
|
||||
chtype attr_alt2, const char *restrict format, ...)
|
||||
chtype attr_alt2, int maxlines, const char *restrict format, ...)
|
||||
{
|
||||
va_list args;
|
||||
chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||
int widthbuf[MAX_DLG_LINES];
|
||||
chtype *chbuf;
|
||||
int *widthbuf;
|
||||
int lines;
|
||||
int ret;
|
||||
|
||||
|
||||
assert(maxlines > 0);
|
||||
|
||||
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||
widthbuf = xmalloc(maxlines * sizeof(int));
|
||||
|
||||
va_start(args, format);
|
||||
lines = vmkchstr(chbuf, BUFSIZE, attr_norm, attr_alt1, attr_alt2,
|
||||
MAX_DLG_LINES, getmaxx(win) - x - 2, widthbuf,
|
||||
MAX_DLG_LINES, format, args);
|
||||
lines = vmkchstr(chbuf, BUFSIZE, attr_norm, attr_alt1, attr_alt2, maxlines,
|
||||
getmaxx(win) - x - 2, widthbuf, maxlines, format, args);
|
||||
ret = leftch(win, y, x, chbuf, lines, widthbuf);
|
||||
assert(ret == OK);
|
||||
va_end(args);
|
||||
|
||||
free(widthbuf);
|
||||
free(chbuf);
|
||||
return ret;
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
@ -1371,25 +1376,30 @@ int left (WINDOW *win, int y, int x, chtype attr_norm, chtype attr_alt1,
|
||||
// center: Print strings centred in window
|
||||
|
||||
int center (WINDOW *win, int y, int offset, chtype attr_norm, chtype attr_alt1,
|
||||
chtype attr_alt2, const char *restrict format, ...)
|
||||
chtype attr_alt2, int maxlines, const char *restrict format, ...)
|
||||
{
|
||||
va_list args;
|
||||
chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||
int widthbuf[MAX_DLG_LINES];
|
||||
chtype *chbuf;
|
||||
int *widthbuf;
|
||||
int lines;
|
||||
int ret;
|
||||
|
||||
|
||||
assert(maxlines > 0);
|
||||
|
||||
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||
widthbuf = xmalloc(maxlines * sizeof(int));
|
||||
|
||||
va_start(args, format);
|
||||
lines = vmkchstr(chbuf, BUFSIZE, attr_norm, attr_alt1, attr_alt2,
|
||||
MAX_DLG_LINES, getmaxx(win) - 4, widthbuf,
|
||||
MAX_DLG_LINES, format, args);
|
||||
lines = vmkchstr(chbuf, BUFSIZE, attr_norm, attr_alt1, attr_alt2, maxlines,
|
||||
getmaxx(win) - 4, widthbuf, maxlines, format, args);
|
||||
ret = centerch(win, y, offset, chbuf, lines, widthbuf);
|
||||
assert(ret == OK);
|
||||
va_end(args);
|
||||
|
||||
free(widthbuf);
|
||||
free(chbuf);
|
||||
return ret;
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
@ -1397,25 +1407,30 @@ int center (WINDOW *win, int y, int offset, chtype attr_norm, chtype attr_alt1,
|
||||
// right: Print strings right-aligned
|
||||
|
||||
int right (WINDOW *win, int y, int x, chtype attr_norm, chtype attr_alt1,
|
||||
chtype attr_alt2, const char *restrict format, ...)
|
||||
chtype attr_alt2, int maxlines, const char *restrict format, ...)
|
||||
{
|
||||
va_list args;
|
||||
chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||
int widthbuf[MAX_DLG_LINES];
|
||||
chtype *chbuf;
|
||||
int *widthbuf;
|
||||
int lines;
|
||||
int ret;
|
||||
|
||||
|
||||
assert(maxlines > 0);
|
||||
|
||||
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||
widthbuf = xmalloc(maxlines * sizeof(int));
|
||||
|
||||
va_start(args, format);
|
||||
lines = vmkchstr(chbuf, BUFSIZE, attr_norm, attr_alt1, attr_alt2,
|
||||
MAX_DLG_LINES, x - 2, widthbuf, MAX_DLG_LINES,
|
||||
format, args);
|
||||
lines = vmkchstr(chbuf, BUFSIZE, attr_norm, attr_alt1, attr_alt2, maxlines,
|
||||
x - 2, widthbuf, maxlines, format, args);
|
||||
ret = rightch(win, y, x, chbuf, lines, widthbuf);
|
||||
assert(ret == OK);
|
||||
va_end(args);
|
||||
|
||||
free(widthbuf);
|
||||
free(chbuf);
|
||||
return ret;
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
@ -2554,7 +2569,7 @@ void wait_for_key (WINDOW *win, int y, chtype attr)
|
||||
meta(win, true);
|
||||
wtimeout(win, -1);
|
||||
|
||||
center(curwin, y, 0, attr, 0, 0, _("[ Press <SPACE> to continue ] "));
|
||||
center(curwin, y, 0, attr, 0, 0, 1, _("[ Press <SPACE> to continue ] "));
|
||||
wrefresh(win);
|
||||
|
||||
done = false;
|
||||
|
33
src/intf.h
33
src/intf.h
@ -50,13 +50,19 @@
|
||||
#define MIN_LINES 24 // Minimum number of lines in terminal
|
||||
#define MIN_COLS 80 // Minimum number of columns in terminal
|
||||
|
||||
#define WIN_LINES MIN_LINES // Number of lines used in main window
|
||||
#define WIN_COLS MIN_COLS // Number of columns used in main window
|
||||
#define WIN_LINES MIN_LINES // Number of lines used in main window
|
||||
#define WIN_COLS MIN_COLS // Number of columns used in main window
|
||||
|
||||
#define WCENTER -1 // Centre the new window
|
||||
#define WCENTER -1 // Centre the new window
|
||||
|
||||
#define MAX_DLG_LINES 10 // Default maximum lines of text in dialog box
|
||||
#define YESNO_COLS 4 // Space to allow for "Yes" or "No" response
|
||||
#define MAX_DLG_LINES 10 // Default maximum lines of text in dialog box
|
||||
#define YESNO_COLS 4 // Space to allow for "Yes" or "No" response
|
||||
#define ORDINAL_COLS 5 // Space for ordinals (1st, 2nd, etc)
|
||||
#define TOTAL_VALUE_COLS 18 // Space for total value (monetary)
|
||||
#define SHARE_PRICE_COLS 12 // Space for "Price per share"
|
||||
#define SHARE_RETURN_COLS 10 // Space for "Return per share"
|
||||
#define STOCK_OWNED_COLS 10 // Space for "Holdings (shares)"
|
||||
#define OWNERSHIP_COLS 10 // Space for "Company ownership (%)"
|
||||
|
||||
|
||||
// Check if resizing events are supported
|
||||
@ -470,9 +476,10 @@ extern int rightch (WINDOW *win, int y, int x, const chtype *restrict chstr,
|
||||
attr_norm - Normal character rendition to use
|
||||
attr_alt1 - First alternate character rendition to use
|
||||
attr_alt2 - Second alternate character rendition to use
|
||||
maxlines - Maximum number of screen lines to use
|
||||
format - Format string as described for mkchstr()
|
||||
... - Arguments for the format string
|
||||
Returns: int - Always returns OK
|
||||
Returns: int - Number of lines actually used
|
||||
|
||||
This shortcut function prepares a chtype string using mkchstr(), then
|
||||
prints the string using leftch(). At most MAX_DLG_LINES are printed,
|
||||
@ -480,7 +487,8 @@ extern int rightch (WINDOW *win, int y, int x, const chtype *restrict chstr,
|
||||
for the right-hand border).
|
||||
*/
|
||||
extern int left (WINDOW *win, int y, int x, chtype attr_norm, chtype attr_alt1,
|
||||
chtype attr_alt2, const char *restrict format, ...);
|
||||
chtype attr_alt2, int maxlines, const char *restrict format,
|
||||
...);
|
||||
|
||||
|
||||
/*
|
||||
@ -491,16 +499,17 @@ extern int left (WINDOW *win, int y, int x, chtype attr_norm, chtype attr_alt1,
|
||||
attr_norm - Normal character rendition to use
|
||||
attr_alt1 - First alternate character rendition to use
|
||||
attr_alt2 - Second alternate character rendition to use
|
||||
maxlines - Maximum number of screen lines to use
|
||||
format - Format string as described for mkchstr()
|
||||
... - Arguments for the format string
|
||||
Returns: int - Always returns OK
|
||||
Returns: int - Number of lines actually used
|
||||
|
||||
This shortcut function prepares a chtype string using mkchstr(), then
|
||||
prints the string using centerch(). At most MAX_DLG_LINES are printed,
|
||||
with the maximum width being that of the window win - 4 (for borders).
|
||||
*/
|
||||
extern int center (WINDOW *win, int y, int offset, chtype attr_norm,
|
||||
chtype attr_alt1, chtype attr_alt2,
|
||||
chtype attr_alt1, chtype attr_alt2, int maxlines,
|
||||
const char *restrict format, ...);
|
||||
|
||||
|
||||
@ -512,9 +521,10 @@ extern int center (WINDOW *win, int y, int offset, chtype attr_norm,
|
||||
attr_norm - Normal character rendition to use
|
||||
attr_alt1 - First alternate character rendition to use
|
||||
attr_alt2 - Second alternate character rendition to use
|
||||
maxlines - Maximum number of screen lines to use
|
||||
format - Format string as described for mkchstr()
|
||||
... - Arguments for the format string
|
||||
Returns: int - Always returns OK
|
||||
Returns: int - Number of lines actually used
|
||||
|
||||
This shortcut function prepares a chtype string using mkchstr(), then
|
||||
prints the string using rightch(). At most MAX_DLG_LINES are printed,
|
||||
@ -522,7 +532,8 @@ extern int center (WINDOW *win, int y, int offset, chtype attr_norm,
|
||||
left-hand border).
|
||||
*/
|
||||
extern int right (WINDOW *win, int y, int x, chtype attr_norm, chtype attr_alt1,
|
||||
chtype attr_alt2, const char *restrict format, ...);
|
||||
chtype attr_alt2, int maxlines, const char *restrict format,
|
||||
...);
|
||||
|
||||
|
||||
/*
|
||||
|
20
src/move.c
20
src/move.c
@ -231,17 +231,17 @@ selection_t get_move (void)
|
||||
werase(curwin);
|
||||
box(curwin, 0, 0);
|
||||
|
||||
left(curwin, 2, 2, attr_normal, attr_keycode, 0,
|
||||
left(curwin, 2, 2, attr_normal, attr_keycode, 0, 1,
|
||||
"^{<1>^} Display stock portfolio");
|
||||
left(curwin, 3, 2, attr_normal, attr_keycode, 0,
|
||||
left(curwin, 3, 2, attr_normal, attr_keycode, 0, 1,
|
||||
"^{<2>^} Declare bankruptcy");
|
||||
left(curwin, 2, getmaxx(curwin) / 2, attr_normal, attr_keycode, 0,
|
||||
left(curwin, 2, getmaxx(curwin) / 2, attr_normal, attr_keycode, 0, 1,
|
||||
"^{<3>^} Save and end the game");
|
||||
left(curwin, 3, getmaxx(curwin) / 2, attr_normal, attr_keycode, 0,
|
||||
left(curwin, 3, getmaxx(curwin) / 2, attr_normal, attr_keycode, 0, 1,
|
||||
"^{<CTRL><C>^} Quit the game");
|
||||
|
||||
right(curwin, 1, getmaxx(curwin) / 2, attr_normal, attr_keycode,
|
||||
attr_choice, "Select move "
|
||||
attr_choice, 1, "Select move "
|
||||
"[^[%c^]-^[%c^]/^{1^}-^{3^}/^{<CTRL><C>^}]: ",
|
||||
MOVE_TO_KEY(0), MOVE_TO_KEY(NUMBER_MOVES - 1));
|
||||
|
||||
@ -257,7 +257,7 @@ selection_t get_move (void)
|
||||
|
||||
curs_set(CURS_OFF);
|
||||
left(curwin, 1, getmaxx(curwin) / 2, attr_normal, attr_choice,
|
||||
0, "Move ^{%c^}", key);
|
||||
0, 1, "Move ^{%c^}", key);
|
||||
} else {
|
||||
switch (key) {
|
||||
case '1':
|
||||
@ -271,7 +271,7 @@ selection_t get_move (void)
|
||||
|
||||
curs_set(CURS_OFF);
|
||||
left(curwin, 1, getmaxx(curwin) / 2, attr_normal,
|
||||
attr_normal | A_BOLD, 0,
|
||||
attr_normal | A_BOLD, 0, 1,
|
||||
"^{<2>^} (Declare bankruptcy)");
|
||||
break;
|
||||
|
||||
@ -280,7 +280,7 @@ selection_t get_move (void)
|
||||
|
||||
curs_set(CURS_OFF);
|
||||
left(curwin, 1, getmaxx(curwin) / 2, attr_normal,
|
||||
attr_normal | A_BOLD, 0,
|
||||
attr_normal | A_BOLD, 0, 1,
|
||||
"^{<3>^} (Save and end the game)");
|
||||
break;
|
||||
|
||||
@ -294,7 +294,7 @@ selection_t get_move (void)
|
||||
|
||||
curs_set(CURS_OFF);
|
||||
left(curwin, 1, getmaxx(curwin) / 2, attr_normal,
|
||||
attr_normal | A_BOLD, 0,
|
||||
attr_normal | A_BOLD, 0, 1,
|
||||
"^{<CTRL><C>^} (Quit the game)");
|
||||
break;
|
||||
|
||||
@ -309,7 +309,7 @@ selection_t get_move (void)
|
||||
mvwhline(curwin, 3, 2, ' ' | attr_normal, getmaxx(curwin) - 4);
|
||||
|
||||
// Ask the player to confirm their choice
|
||||
right(curwin, 2, getmaxx(curwin) / 2, attr_normal, attr_keycode, 0,
|
||||
right(curwin, 2, getmaxx(curwin) / 2, attr_normal, attr_keycode, 0, 1,
|
||||
"Are you sure? [^{Y^}/^{N^}] ");
|
||||
wrefresh(curwin);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user