mirror of
https://git.zap.org.au/git/trader.git
synced 2025-01-03 14:57:41 -05:00
Move background setting and box drawing into newtxwin()
Setting the background and drawing a box is almost always the first thing done after window creation.
This commit is contained in:
parent
ee259b8a83
commit
c6007be5aa
62
src/exch.c
62
src/exch.c
@ -65,7 +65,7 @@ void exchange_stock (void)
|
||||
return;
|
||||
}
|
||||
|
||||
newtxwin(17, 80, LINE_OFFSET + 1, COL_CENTER(80));
|
||||
newtxwin(17, 80, LINE_OFFSET + 1, COL_CENTER(80), false, 0);
|
||||
|
||||
while (selection != SEL_EXIT) {
|
||||
selection = SEL_NONE;
|
||||
@ -125,9 +125,8 @@ void exchange_stock (void)
|
||||
wrefresh(curwin);
|
||||
|
||||
// Show menu of choices for the player
|
||||
newtxwin(6, 80, LINE_OFFSET + 18, COL_CENTER(80));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(6, 80, LINE_OFFSET + 18, COL_CENTER(80), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
wmove(curwin, 3, 2);
|
||||
attrpr(curwin, ATTR_KEYCODE_STR, "<1>");
|
||||
@ -253,9 +252,7 @@ void visit_bank (void)
|
||||
}
|
||||
|
||||
// Show the informational part of the Bank
|
||||
newtxwin(10, 76, LINE_OFFSET + 5, COL_CENTER(76));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(10, 76, LINE_OFFSET + 5, COL_CENTER(76), true, ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_WINDOW_TITLE, " Interstellar Trading Bank ");
|
||||
|
||||
@ -277,9 +274,7 @@ void visit_bank (void)
|
||||
wrefresh(curwin);
|
||||
|
||||
// Show menu of choices for the player
|
||||
newtxwin(7, 76, LINE_OFFSET + 15, COL_CENTER(76));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(7, 76, LINE_OFFSET + 15, COL_CENTER(76), true, ATTR_NORMAL_WINDOW);
|
||||
|
||||
center2(curwin, 3, ATTR_KEYCODE_STR, ATTR_NORMAL_WINDOW,
|
||||
"<1>", " Borrow money ");
|
||||
@ -328,9 +323,8 @@ void visit_bank (void)
|
||||
case '1':
|
||||
// Borrow money from the Bank
|
||||
if (credit_limit == 0.0) {
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Insufficient Credit Limit ");
|
||||
center(curwin, 3, ATTR_ERROR_STR,
|
||||
@ -380,7 +374,9 @@ void visit_bank (void)
|
||||
case '2':
|
||||
// Repay a debt
|
||||
if (player[current_player].debt == 0.0) {
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50));
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
|
||||
@ -390,9 +386,8 @@ void visit_bank (void)
|
||||
wait_for_key(curwin, 5, ATTR_WAITERROR_STR);
|
||||
deltxwin();
|
||||
} else if (player[current_player].cash == 0.0) {
|
||||
newtxwin(7, 60, LINE_OFFSET + 8, COL_CENTER(60));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(7, 60, LINE_OFFSET + 8, COL_CENTER(60), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " No Cash ");
|
||||
center(curwin, 3, ATTR_ERROR_STR, "You have no cash with which to repay the debt!");
|
||||
@ -491,9 +486,7 @@ void trade_shares (int num, bool *bid_used)
|
||||
company[num].stock_issued);
|
||||
|
||||
// Show the informational part of the trade window
|
||||
newtxwin(9, 76, LINE_OFFSET + 5, COL_CENTER(76));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(9, 76, LINE_OFFSET + 5, COL_CENTER(76), true, ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_WINDOW_TITLE, " Stock Transaction in %s ",
|
||||
company[num].name);
|
||||
@ -528,9 +521,7 @@ void trade_shares (int num, bool *bid_used)
|
||||
wrefresh(curwin);
|
||||
|
||||
// Show menu of choices for the player
|
||||
newtxwin(7, 76, LINE_OFFSET + 14, COL_CENTER(76));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(7, 76, LINE_OFFSET + 14, COL_CENTER(76), true, ATTR_NORMAL_WINDOW);
|
||||
|
||||
wmove(curwin, 3, 2);
|
||||
attrpr(curwin, ATTR_KEYCODE_STR, "<1>");
|
||||
@ -591,9 +582,8 @@ void trade_shares (int num, bool *bid_used)
|
||||
maxshares = player[current_player].cash / company[num].share_price;
|
||||
|
||||
if (company[num].max_stock - company[num].stock_issued == 0) {
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " No Shares Available ");
|
||||
center(curwin, 3, ATTR_ERROR_STR,
|
||||
@ -603,9 +593,8 @@ void trade_shares (int num, bool *bid_used)
|
||||
deltxwin();
|
||||
|
||||
} else if (maxshares <= 0) {
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Insufficient Cash ");
|
||||
center(curwin, 3, ATTR_ERROR_STR,
|
||||
@ -644,9 +633,8 @@ void trade_shares (int num, bool *bid_used)
|
||||
// Sell stock back to company
|
||||
maxshares = player[current_player].stock_owned[num];
|
||||
if (maxshares == 0) {
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " No Shares ");
|
||||
center(curwin, 3, ATTR_ERROR_STR,
|
||||
@ -689,9 +677,8 @@ void trade_shares (int num, bool *bid_used)
|
||||
*bid_used = true;
|
||||
|
||||
if (maxshares == 0) {
|
||||
newtxwin(8, 50, LINE_OFFSET + 8, COL_CENTER(50));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(8, 50, LINE_OFFSET + 8, COL_CENTER(50), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " No Shares Issued ");
|
||||
center(curwin, 3, ATTR_ERROR_STR, "%s", company[num].name);
|
||||
@ -700,9 +687,8 @@ void trade_shares (int num, bool *bid_used)
|
||||
wait_for_key(curwin, 6, ATTR_WAITERROR_STR);
|
||||
deltxwin();
|
||||
} else {
|
||||
newtxwin(8, 50, LINE_OFFSET + 8, COL_CENTER(50));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(8, 50, LINE_OFFSET + 8, COL_CENTER(50), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_WINDOW_TITLE, " Shares Issued ");
|
||||
center(curwin, 3, ATTR_HIGHLIGHT_STR, "%s", company[num].name);
|
||||
|
20
src/fileio.c
20
src/fileio.c
@ -171,9 +171,8 @@ bool load_game (int num)
|
||||
|
||||
if (errno == ENOENT) {
|
||||
// File not found
|
||||
newtxwin(7, 40, LINE_OFFSET + 9, COL_CENTER(40));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(7, 40, LINE_OFFSET + 9, COL_CENTER(40), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Game Not Found ");
|
||||
center(curwin, 3, ATTR_ERROR_STR,
|
||||
@ -185,9 +184,8 @@ bool load_game (int num)
|
||||
// Some other file error
|
||||
saved_errno = errno;
|
||||
|
||||
newtxwin(9, 70, LINE_OFFSET + 9, COL_CENTER(70));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(9, 70, LINE_OFFSET + 9, COL_CENTER(70), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Game Not Loaded ");
|
||||
center(curwin, 3, ATTR_ERROR_STR,
|
||||
@ -343,9 +341,8 @@ bool save_game (int num)
|
||||
} else {
|
||||
// Data directory could not be created
|
||||
|
||||
newtxwin(9, 70, LINE_OFFSET + 7, COL_CENTER(70));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(9, 70, LINE_OFFSET + 7, COL_CENTER(70), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Game Not Saved ");
|
||||
center(curwin, 3, ATTR_ERROR_STR,
|
||||
@ -370,9 +367,8 @@ bool save_game (int num)
|
||||
// File could not be opened for writing
|
||||
saved_errno = errno;
|
||||
|
||||
newtxwin(9, 70, LINE_OFFSET + 7, COL_CENTER(70));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(9, 70, LINE_OFFSET + 7, COL_CENTER(70), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Game Not Saved ");
|
||||
center(curwin, 3, ATTR_ERROR_STR,
|
||||
|
75
src/game.c
75
src/game.c
@ -69,9 +69,7 @@ void init_game (void)
|
||||
|
||||
// Try to load an old game, if possible
|
||||
if (game_num != 0) {
|
||||
newtxwin(5, 30, LINE_OFFSET + 6, COL_CENTER(30));
|
||||
wbkgd(curwin, ATTR_STATUS_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(5, 30, LINE_OFFSET + 6, COL_CENTER(30), true, ATTR_STATUS_WINDOW);
|
||||
center(curwin, 2, ATTR_STATUS_WINDOW, "Loading game %d... ", game_num);
|
||||
wrefresh(curwin);
|
||||
|
||||
@ -87,9 +85,8 @@ void init_game (void)
|
||||
while (number_players == 0) {
|
||||
|
||||
// Ask for the number of players
|
||||
newtxwin(5, 62, LINE_OFFSET + 3, COL_CENTER(62));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(5, 62, LINE_OFFSET + 3, COL_CENTER(62), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
mvwaddstr(curwin, 2, 2, "Enter number of players ");
|
||||
waddstr(curwin, "[");
|
||||
@ -136,9 +133,8 @@ void init_game (void)
|
||||
} else {
|
||||
|
||||
// Ask which game to load
|
||||
newtxwin(5, 54, LINE_OFFSET + 6, COL_CENTER(54));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(5, 54, LINE_OFFSET + 6, COL_CENTER(54), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
mvwaddstr(curwin, 2, 2, "Enter game number ");
|
||||
waddstr(curwin, "[");
|
||||
@ -186,9 +182,8 @@ void init_game (void)
|
||||
wechochar(curwin, key | A_BOLD);
|
||||
|
||||
// Try to load the game, if possible
|
||||
newtxwin(5, 30, LINE_OFFSET + 9, COL_CENTER(30));
|
||||
wbkgd(curwin, ATTR_STATUS_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(5, 30, LINE_OFFSET + 9, COL_CENTER(30), true,
|
||||
ATTR_STATUS_WINDOW);
|
||||
center(curwin, 2, ATTR_STATUS_WINDOW,
|
||||
"Loading game %d... ", game_num);
|
||||
wrefresh(curwin);
|
||||
@ -209,9 +204,8 @@ void init_game (void)
|
||||
if (number_players == 1) {
|
||||
// Ask for the player name
|
||||
|
||||
newtxwin(5, 76, LINE_OFFSET + 9, COL_CENTER(76));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(5, 76, LINE_OFFSET + 9, COL_CENTER(76), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
mvwaddstr(curwin, 2, 2, "Please enter your name: ");
|
||||
|
||||
@ -226,9 +220,8 @@ void init_game (void)
|
||||
}
|
||||
} while (! done);
|
||||
|
||||
newtxwin(5, 44, LINE_OFFSET + 6, COL_CENTER(44));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(5, 44, LINE_OFFSET + 6, COL_CENTER(44), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
mvwaddstr(curwin, 2, 2, "Do you need any instructions? ");
|
||||
waddstr(curwin, "[");
|
||||
@ -248,9 +241,8 @@ void init_game (void)
|
||||
} else {
|
||||
|
||||
// Ask for all of the player names
|
||||
newtxwin(number_players + 5, 76, LINE_OFFSET + 9, COL_CENTER(76));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(number_players + 5, 76, LINE_OFFSET + 9,
|
||||
COL_CENTER(76), true, ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_WINDOW_TITLE, " Enter Player Names ");
|
||||
|
||||
@ -329,9 +321,8 @@ void init_game (void)
|
||||
}
|
||||
}
|
||||
|
||||
newtxwin(5, 50, LINE_OFFSET + 6, COL_CENTER(50));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(5, 50, LINE_OFFSET + 6, COL_CENTER(50), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
mvwaddstr(curwin, 2, 2, "Does any player need instructions? ");
|
||||
waddstr(curwin, "[");
|
||||
@ -392,9 +383,8 @@ void init_game (void)
|
||||
first_player = randi(number_players);
|
||||
current_player = first_player;
|
||||
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(7, 50, LINE_OFFSET + 8, COL_CENTER(50), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 2, ATTR_NORMAL_WINDOW,
|
||||
"The first player to go is");
|
||||
@ -439,9 +429,7 @@ void end_game (void)
|
||||
err_exit_nomem();
|
||||
}
|
||||
|
||||
newtxwin(7, 40, LINE_OFFSET + 9, COL_CENTER(40));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(7, 40, LINE_OFFSET + 9, COL_CENTER(40), true, ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Game Over ");
|
||||
center(curwin, 3, ATTR_ERROR_STR, "The game is over after %d turns",
|
||||
@ -457,9 +445,8 @@ void end_game (void)
|
||||
if (number_players == 1) {
|
||||
l_strfmon(buf, BUFSIZE, "%1n", total_value(0));
|
||||
|
||||
newtxwin(9, 60, LINE_OFFSET + 8, COL_CENTER(60));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(9, 60, LINE_OFFSET + 8, COL_CENTER(60), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_WINDOW_TITLE, " Total Value ");
|
||||
center2(curwin, 4, ATTR_NORMAL_WINDOW, ATTR_HIGHLIGHT_STR,
|
||||
@ -474,9 +461,8 @@ void end_game (void)
|
||||
}
|
||||
qsort(player, number_players, sizeof(player_info_t), cmp_player);
|
||||
|
||||
newtxwin(number_players + 10, 76, LINE_OFFSET + 3, COL_CENTER(76));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(number_players + 10, 76, LINE_OFFSET + 3, COL_CENTER(76),
|
||||
true, ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_WINDOW_TITLE, " Game Winner ");
|
||||
center2(curwin, 3, ATTR_NORMAL_WINDOW, ATTR_HIGHLIGHT_STR,
|
||||
@ -529,11 +515,11 @@ void show_map (bool closewin)
|
||||
int n, x, y;
|
||||
|
||||
|
||||
newtxwin(MAX_Y + 4, WIN_COLS, LINE_OFFSET + 1, COL_CENTER(WIN_COLS));
|
||||
wbkgd(curwin, ATTR_MAP_WINDOW);
|
||||
newtxwin(MAX_Y + 4, WIN_COLS, LINE_OFFSET + 1, COL_CENTER(WIN_COLS),
|
||||
true, ATTR_MAP_WINDOW);
|
||||
|
||||
// Draw various borders
|
||||
box(curwin, 0, 0);
|
||||
|
||||
mvwaddch(curwin, 2, 0, ACS_LTEE);
|
||||
whline(curwin, ACS_HLINE, getmaxx(curwin) - 2);
|
||||
mvwaddch(curwin, 2, getmaxx(curwin) - 1, ACS_RTEE);
|
||||
@ -612,10 +598,8 @@ void show_map (bool closewin)
|
||||
|
||||
wrefresh(curwin);
|
||||
|
||||
newtxwin(WIN_LINES - MAX_Y - 5, WIN_COLS,
|
||||
LINE_OFFSET + MAX_Y + 5, COL_CENTER(WIN_COLS));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(WIN_LINES - MAX_Y - 5, WIN_COLS, LINE_OFFSET + MAX_Y + 5,
|
||||
COL_CENTER(WIN_COLS), true, ATTR_NORMAL_WINDOW);
|
||||
|
||||
wait_for_key(curwin, 2, ATTR_WAITNORMAL_STR);
|
||||
|
||||
@ -644,9 +628,8 @@ void show_status (int num)
|
||||
|
||||
assert(num >= 0 && num < number_players);
|
||||
|
||||
newtxwin(MAX_COMPANIES + 15, 80, LINE_OFFSET + 1, COL_CENTER(80));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(MAX_COMPANIES + 15, 80, LINE_OFFSET + 1, COL_CENTER(80), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_WINDOW_TITLE, " Stock Portfolio ");
|
||||
center2(curwin, 2, ATTR_NORMAL_WINDOW, ATTR_HIGHLIGHT_STR, "Player: ",
|
||||
|
@ -170,7 +170,8 @@ void show_help (void)
|
||||
if (numpages == 0)
|
||||
return;
|
||||
|
||||
newtxwin(WIN_LINES - 1, WIN_COLS, LINE_OFFSET + 1, COL_CENTER(WIN_COLS));
|
||||
newtxwin(WIN_LINES - 1, WIN_COLS, LINE_OFFSET + 1, COL_CENTER(WIN_COLS),
|
||||
false, 0);
|
||||
|
||||
while (! done) {
|
||||
// Display a page of instructions
|
||||
|
22
src/intf.c
22
src/intf.c
@ -149,12 +149,14 @@ void end_screen (void)
|
||||
************************************************************************/
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
Function: newtxwin - Create a new window, inserted into window stack
|
||||
Arguments: nlines - Number of lines in new window
|
||||
ncols - Number of columns in new window
|
||||
begin_y - Starting line number (global coordinates)
|
||||
begin_x - Starting column number (global coordinates)
|
||||
Returns: WINDOW * - Pointer to new window structure
|
||||
Function: newtxwin - Create a new window, inserted into window stack
|
||||
Arguments: nlines - Number of lines in new window
|
||||
ncols - Number of columns in new window
|
||||
begin_y - Starting line number (global coordinates)
|
||||
begin_x - Starting column number (global coordinates)
|
||||
draw_bkgd_box - True to draw background and box frame
|
||||
bkgd_attr - Background attribute
|
||||
Returns: WINDOW * - Pointer to new window structure
|
||||
|
||||
This function creates a window (using the Curses newwin() function) and
|
||||
places it top-most in the stack of windows managed by this module. A
|
||||
@ -163,7 +165,8 @@ void end_screen (void)
|
||||
called on the new window.
|
||||
*/
|
||||
|
||||
WINDOW *newtxwin (int nlines, int ncols, int begin_y, int begin_x)
|
||||
WINDOW *newtxwin (int nlines, int ncols, int begin_y, int begin_x,
|
||||
bool draw_bkgd_box, chtype bkgd_attr)
|
||||
{
|
||||
WINDOW *win;
|
||||
txwin_t *nw;
|
||||
@ -195,6 +198,11 @@ WINDOW *newtxwin (int nlines, int ncols, int begin_y, int begin_x)
|
||||
firstwin = nw;
|
||||
}
|
||||
|
||||
if (draw_bkgd_box) {
|
||||
wbkgd(win, bkgd_attr);
|
||||
box(win, 0, 0);
|
||||
}
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,8 @@ extern void end_screen (void);
|
||||
|
||||
// Simplified panel-like window functions
|
||||
|
||||
extern WINDOW *newtxwin (int nlines, int ncols, int begin_y, int begin_x);
|
||||
extern WINDOW *newtxwin (int nlines, int ncols, int begin_y, int begin_x,
|
||||
bool draw_bkgd_box, chtype bkgd_attr);
|
||||
extern int deltxwin (void);
|
||||
extern int delalltxwin (void);
|
||||
extern int txrefresh (void);
|
||||
|
49
src/move.c
49
src/move.c
@ -165,7 +165,7 @@ selection_t get_move (void)
|
||||
wrefresh(curwin);
|
||||
|
||||
// Show menu of choices for the player
|
||||
newtxwin(5, 80, LINE_OFFSET + 19, COL_CENTER(80));
|
||||
newtxwin(5, 80, LINE_OFFSET + 19, COL_CENTER(80), false, 0);
|
||||
while (selection == SEL_NONE) {
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
werase(curwin);
|
||||
@ -291,9 +291,8 @@ selection_t get_move (void)
|
||||
|
||||
if (game_loaded) {
|
||||
// Save the game to the same game number
|
||||
newtxwin(5, 30, LINE_OFFSET + 7, COL_CENTER(30));
|
||||
wbkgd(curwin, ATTR_STATUS_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(5, 30, LINE_OFFSET + 7, COL_CENTER(30), true,
|
||||
ATTR_STATUS_WINDOW);
|
||||
center(curwin, 2, ATTR_STATUS_WINDOW,
|
||||
"Saving game %d... ", game_num);
|
||||
wrefresh(curwin);
|
||||
@ -309,9 +308,8 @@ selection_t get_move (void)
|
||||
bool done;
|
||||
|
||||
// Ask which game to save
|
||||
newtxwin(6, 54, LINE_OFFSET + 8, COL_CENTER(54));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(6, 54, LINE_OFFSET + 8, COL_CENTER(54), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_WINDOW_TITLE, " Save Game ");
|
||||
mvwaddstr(curwin, 3, 2, "Enter game number ");
|
||||
@ -360,9 +358,8 @@ selection_t get_move (void)
|
||||
wechochar(curwin, key | A_BOLD);
|
||||
|
||||
// Try to save the game, if possible
|
||||
newtxwin(5, 30, LINE_OFFSET + 7, COL_CENTER(30));
|
||||
wbkgd(curwin, ATTR_STATUS_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(5, 30, LINE_OFFSET + 7, COL_CENTER(30), true,
|
||||
ATTR_STATUS_WINDOW);
|
||||
center(curwin, 2, ATTR_STATUS_WINDOW,
|
||||
"Saving game %d... ", game_num);
|
||||
wrefresh(curwin);
|
||||
@ -601,12 +598,12 @@ void bankrupt_player (bool forced)
|
||||
int longname = (strlen(player[current_player].name) > 20);
|
||||
|
||||
if (forced) {
|
||||
newtxwin((longname ? 9 : 8), 54, LINE_OFFSET + 7, COL_CENTER(54));
|
||||
newtxwin((longname ? 9 : 8), 54, LINE_OFFSET + 7, COL_CENTER(54),
|
||||
true, ATTR_ERROR_WINDOW);
|
||||
} else {
|
||||
newtxwin((longname ? 8 : 7), 50, LINE_OFFSET + 7, COL_CENTER(50));
|
||||
newtxwin((longname ? 8 : 7), 50, LINE_OFFSET + 7, COL_CENTER(50),
|
||||
true, ATTR_ERROR_WINDOW);
|
||||
}
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Bankruptcy Court ");
|
||||
|
||||
@ -699,9 +696,8 @@ void try_start_new_company (int x, int y)
|
||||
} else {
|
||||
// Create the new company
|
||||
|
||||
newtxwin(8, 50, LINE_OFFSET + 7, COL_CENTER(50));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(8, 50, LINE_OFFSET + 7, COL_CENTER(50), true,
|
||||
ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_WINDOW_TITLE, " New Company ");
|
||||
center(curwin, 3, ATTR_NORMAL_WINDOW, "A new company has been formed!");
|
||||
@ -773,9 +769,7 @@ void merge_companies (map_val_t a, map_val_t b)
|
||||
// Display information about the merger
|
||||
|
||||
newtxwin(number_players + 14, 76, LINE_OFFSET + (9 - number_players),
|
||||
COL_CENTER(76));
|
||||
wbkgd(curwin, ATTR_NORMAL_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
COL_CENTER(76), true, ATTR_NORMAL_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_WINDOW_TITLE, " Company Merger ");
|
||||
center3(curwin, 3, ATTR_HIGHLIGHT_STR, ATTR_HIGHLIGHT_STR, ATTR_NORMAL_WINDOW,
|
||||
@ -941,9 +935,8 @@ void adjust_values (void)
|
||||
|
||||
if (company[which].on_map) {
|
||||
if (randf() < ALL_ASSETS_TAKEN) {
|
||||
newtxwin(10, 60, LINE_OFFSET + 6, COL_CENTER(60));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(10, 60, LINE_OFFSET + 6, COL_CENTER(60), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Bankruptcy Court ");
|
||||
center(curwin, 3, ATTR_ERROR_STR, "%s has been declared",
|
||||
@ -973,9 +966,8 @@ void adjust_values (void)
|
||||
}
|
||||
}
|
||||
|
||||
newtxwin(14, 60, LINE_OFFSET + 4, COL_CENTER(60));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(14, 60, LINE_OFFSET + 4, COL_CENTER(60), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Bankruptcy Court ");
|
||||
center(curwin, 3, ATTR_ERROR_STR, "%s has been declared",
|
||||
@ -1086,9 +1078,8 @@ void adjust_values (void)
|
||||
impounded = MIN(player[current_player].cash,
|
||||
player[current_player].debt);
|
||||
|
||||
newtxwin(8, 60, LINE_OFFSET + 7, COL_CENTER(60));
|
||||
wbkgd(curwin, ATTR_ERROR_WINDOW);
|
||||
box(curwin, 0, 0);
|
||||
newtxwin(8, 60, LINE_OFFSET + 7, COL_CENTER(60), true,
|
||||
ATTR_ERROR_WINDOW);
|
||||
|
||||
center(curwin, 1, ATTR_ERROR_TITLE, " Interstellar Trading Bank ");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user