Skip to content

Commit

Permalink
GameEngine.h:
Browse files Browse the repository at this point in the history
* Now added a GameEngineParam param enable_terminal_window_resize which is default true.
* Using said param in above point.
  • Loading branch information
razterizer committed Oct 10, 2024
1 parent 710f805 commit 8de12e2
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions GameEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct GameEngineParams
bool quit_confirm_unsaved_changes = false;
bool enable_hiscores = true;
bool enable_pause = true;
bool enable_terminal_window_resize = true; // If true it will resize the terminal window if too small for the game screen.

Color screen_bg_color_default = Color::Default;
Color screen_bg_color_title = Color::Default;
Expand Down Expand Up @@ -222,11 +223,14 @@ class GameEngine
hide_cursor();

std::tie(term_win_rows, term_win_cols) = get_terminal_window_size();
int new_rows = term_win_rows;
int new_cols = term_win_cols;
math::maximize(new_rows, NR + 1);
math::maximize(new_cols, NC);
resize_terminal_window(new_rows, new_cols);
if (m_params.enable_terminal_window_resize)
{
int new_rows = term_win_rows;
int new_cols = term_win_cols;
math::maximize(new_rows, NR + 1);
math::maximize(new_cols, NC);
resize_terminal_window(new_rows, new_cols);
}

//nodelay(stdscr, TRUE);

Expand Down Expand Up @@ -262,8 +266,9 @@ class GameEngine
{
restore_cursor();
show_cursor();
if (term_win_rows > 0 && term_win_cols > 0)
resize_terminal_window(term_win_rows, term_win_cols);
if (m_params.enable_terminal_window_resize)
if (term_win_rows > 0 && term_win_cols > 0)
resize_terminal_window(term_win_rows, term_win_cols);
on_quit();
}

Expand Down

0 comments on commit 8de12e2

Please sign in to comment.