def __init__(self, console_height, console_width): """Create a main screen. :param console_height: the height of the console :param console_width: the width of the console :return: null """ # List should be two smaller in each direction because of surrounding border. self._list_height, self._list_width = console_height-2, console_width-2 # Center the window based on the size of the console. display_start_y, display_start_x = util.center_start(console_height, console_width, self._list_height, self._list_width) # Initialize a Recipe to serve as a shopping list. self._shopping_list = Recipe() # Create window that will act as main visual. self._list_display = curses.newwin(self._list_height, self._list_width, display_start_y, display_start_x) # Add visual detail to window. self._list_display.bkgd(' ', curses.color_pair(1)) util.color_box(self._list_display, 0, 0, self._list_height-1, self._list_width-1, 3) # Initializes help window for use in pause(). help_height, help_width = 12, 50 help_y, help_x = util.center_start(console_height, console_width, help_height, help_width) self.help_window = curses.newwin(help_height, help_width, help_y, help_x)
def __init__(self, console_height, console_width, game_height, game_width, conway): """Initialize ConwayScreen. :param console_height: the height of the console :param console_width: the width of the console :param game_height: the height of the game :param game_width: the width of the game :param conway: a Conway graph :return: null """ self.conway = conway self.game_pad = curses.newpad(game_height, game_width) # Start and stop points for the graph [start, stop). self.start_y, self.start_x = util.center_start(console_height, console_width, game_height, game_width) # Stop points are a function based on the start. self.stop_y, self.stop_x = self.start_y + game_height, self.start_x + game_width # Initializes pause window for use in pause(). pause_height, pause_width = 8, 50 pause_y, pause_x = util.center_start(console_height, console_width, pause_height, pause_width) self.pause_window = curses.newwin(pause_height, pause_width, pause_y, pause_x) # Surround Conway graph with a box util.color_box(self.game_pad, 0, 0, game_height, game_width, 0)
def clear_screen(self): """Clear the contents of the screen. :return: a reference to the main screen """ self._list_display.clear() # Add back border and show display util.color_box(self._list_display, 0, 0, self._list_height-1, self._list_width-1, 3) self._list_display.refresh() return self