def __init__(self, main_interface): self.game_interface = main_interface self.x = 130 self.y = 0 self.width = 20 self.height = 50 self.game_menu_interface_window = newwin(self.height, self.width, self.y, self.x) self.game_menu_interface_panel = new_panel( self.game_menu_interface_window) self.buttons = [] self.buttons_list = [ "MAIN MENU", "TASKS", "FASTER", "SLOWER", "BUILD TOWER", "READY", "PAUSE" ] self._init_buttons() self.topics_pointer = 0 self.locked_buttons = [1, 2, 3, 5] self.to_stay_lock = [] self.last_point = -1 self.enabled = True self.blocked = False wbkgd(self.game_menu_interface_window, CYAN_WHITE) update_panels() doupdate()
def render(self, line=None): # Overwrites existing if self.max_line_len > self.width: raise SizeError("Content is longer than box.") # New window self.win = uni.newwin(self.height, self.width, self.ypos, self.xpos) # Draw outline if self.outline: uni.box(self.win, 0, 0) # Draw label self.draw_label() # Make panel self.panel = uni.new_panel(self.win) # Track the line number currently written self.current_line = 0 # Print content for line in self.lines: # Print line text on line number ix = list(self.lines).index(line) line_no = ix + self.ypad # Print lines according to the text's index in the list uni.mvwaddstr(self.win, line_no, self.xpad, " " * (self.width - 2)) uni.mvwaddstr(self.win, line_no, self.xpad, line) self.current_line += 1 uni.wrefresh(self.win)
def __init__(self, stdscr, body, foreground=None, background=None, attribute=0): self.max_x = stdscr.getmaxyx()[1] - 1 self.max_y = stdscr.getmaxyx()[0] - 1 self.x = self.max_x // 2 self.y = self.max_y // 2 self.body = body del stdscr # CREATE -------------------------------- self.window = curses.newwin(1, 1, self.y, self.x) curses.waddstr(self.window, self.body) self.panel = curses.new_panel(self.window) self.foreground = foreground self.background = background self.color = 0 self.attribute = attribute if foreground is not None and background is not None: self.set_colors(foreground, background) self.show_changes()
def main(): ## Curses normal init sequence stdscr = curses.initscr() curses.noecho() # no echo, but we still see the cursor curses.curs_set(False) #turns off the cursor drawing stdscr.keypad(True) # allows special keys and arrow keys try: curses.start_color() window = curses.newwin(3, 20, 5, 5) window.addstr(1, 1, "Hey there!") window.box() window2 = curses.newwin(3, 20, 4, 4) window2.addstr(1, 1, "Hey there, again!") window2.box() panel = curses.new_panel(window) panel2 = curses.new_panel(window2) #curses.move_panel(panel, 10, 30) curses.update_panels() curses.doupdate() top_p = None while True: key = curses.getch() if key == 27: break top_p = panel if top_p is panel2 else panel2 curses.top_panel(top_p) curses.update_panels() curses.doupdate() except Exception as e: stdscr.addstr(0, 0, str(e)) stdscr.getch() finally: curses.endwin() return 0
def __init__(self): self.win = uc.newwin(10, 30, 0, 0) uc.box(self.win) uc.wmove(self.win, 1, 1) uc.waddstr(self.win, "Tile Info") panel = uc.new_panel(self.win) uc.move_panel(panel, glob.CAM_HEIGHT, 62)
def _register_window(self, name, size): """Register a window Args: size (tuple): The size of the window. name (str): The name of the window. """ self._windows[name] = Window(name, uc.newwin(*size)) self._panels[name] = uc.new_panel(self._windows[name].window) self._ordered_windows.append(self._windows[name])
def main(): ## Curses normal init sequence stdscr = curses.initscr() curses.noecho() # no echo, but we still see the cursor curses.curs_set(False) #turns off the cursor drawing stdscr.keypad(True) # allows special keys and arrow keys try: curses.start_color() curses.init_pair(1, curses.COLOR_YELLOW, curses.COLOR_GREEN) curses.init_pair(2, curses.COLOR_RED, curses.COLOR_GREEN) dude = curses.newwin(1, 1, 10, 30) curses.waddstr(dude, "@", curses.color_pair(2) + curses.A_BOLD) dude_panel = curses.new_panel(dude) grass = curses.newwin(10, 50, 5, 5) grass.bkgd(" ", curses.color_pair(1)) grass_panel = curses.new_panel(grass) curses.top_panel(dude_panel) curses.update_panels() curses.doupdate() while True: key = curses.getch() if key == 27: break curses.update_panels() curses.doupdate() except Exception as e: stdscr.addstr(0, 0, str(e)) stdscr.getch() finally: curses.endwin() return 0
def __init__(self, title, dimensions): height, width, y, x = dimensions self._win = curses.newwin(height, width, y, x) self._win.box() self._panel = curses.new_panel(self._win) self._title = title self._id = uuid1() self._set_title() self.hide()
def __init__(self): #, stdscreen): self.screen = uni.initscr() #stdscreen uni.keypad(self.screen, True) uni.curs_set(0) uni.noecho() uni.cbreak() #menuwin = uni.subwin(self.screen, 23, 79, 0, 0) menuwin = uni.newwin(10, 40, 0, 0) #uni.box(menuwin, 0, 0) #uni.hline(2, 1)#, uni.ACS_HLINE, 77) #uni.mvwhline(menuwin, 2, 1, uni.ACS_HLINE, 40 - 2) uni.new_panel(menuwin) uni.refresh() submenu_items = [('beep', uni.beep), ('flash', uni.flash)] submenu = Menu(submenu_items, self.screen) main_menu_items = [('beep', uni.beep), ('flash', uni.flash), ('submenu', submenu.display)] main_menu = Menu(main_menu_items, self.screen) main_menu.display()
def __init__(self, main_interface): self.game_interface = main_interface self.enabled = True self.x = 0 self.y = 0 self.width = 130 self.height = 5 self.game_stat_window = newwin(self.height, self.width, self.y, self.x) self.game_stat_panel = new_panel(self.game_stat_window) wbkgd(self.game_stat_window, CYAN_RED) update_panels() doupdate()
def init_wins(self): '''Creates win and panel objects. ''' uc.wclear(stdscr) self.max_y, self.max_x = uc.getmaxyx(stdscr) self.win_title = uc.newwin(3, self.max_x, 0, 0) #(h, w, starty, startx) self.win_boardarea = uc.newwin(self.max_y-4, self.max_x, 3, 0) self.win_statusbar = uc.newwin(1, self.max_x, self.max_y-1, 0) x, y = self.player.board.str_size() self.win_board1 = uc.newwin(y, x+2, 0, 0) self.win_board2 = uc.newwin(y, x+2, 0, 0) self.pan_board1 = uc.new_panel(self.win_board1) self.pan_board2 = uc.new_panel(self.win_board2) uc.move_panel(self.pan_board1, 0, 0) uc.move_panel(self.pan_board2, 0, 0) uc.wrefresh(stdscr) self.draw_all()
def __init__(self, main_interface, width, height): self.enabled = True self.game_interface = main_interface self.y = 15 self.x = 50 self.width = width self.height = height self.menu_window = newwin(height, width, self.y, self.x) self.topics = ["NEW GAME", "RESUME GAME", "LOAD GAME", "SAVE GAME", "SETTINGS", "EXIT"] self.topics_pointer = 0 self.locked_topics = [1, 2, 3, 4] self.to_stay_lock = [] self.panel = new_panel(self.menu_window) update_panels() doupdate()
def __init__(self, main_interface): self.game_interface = main_interface self.enabled = True self.blocked = False self.x = 0 self.y = 5 self.point_x = 1 self.point_y = 1 self.width = 130 self.height = 45 self.field_data_pull = None self.game_field_window = newwin(self.height, self.width, self.y, self.x) self.game_field_panel = new_panel(self.game_field_window) self.selector = None wbkgd(self.game_field_window, CYAN_RED) update_panels() doupdate()
def render(self): """Show the menubar.""" #self.make_panels() # Box line uni.box(self.win, 0, 0) # Label self.draw_label() uni.doupdate() self.panel = uni.new_panel(self.win) uni.panel_above(self.panel) # Print submenu names self.update_section_atts() self.make_panels() for submenu in self.submenus: uni.mvwaddstr(self.win, 1, submenu.xpos, submenu.name)
def __init__(self, main_interface, width, height): self.enabled = True self.game_interface = main_interface self.y = 15 self.x = 50 self.width = width self.height = height self.menu_window = newwin(height, width, self.y, self.x) self.topics = [ "NEW GAME", "RESUME GAME", "LOAD GAME", "SAVE GAME", "SETTINGS", "EXIT" ] self.topics_pointer = 0 self.locked_topics = [1, 2, 3, 4] self.to_stay_lock = [] self.panel = new_panel(self.menu_window) update_panels() doupdate()
def __init__(self, items, stdscreen): self.width = 30 self.height = 10 self.startx = int((80 - self.width) / 2) self.starty = int((24 - self.height) / 2) self.window = uni.newwin(self.height, self.width, self.starty, self.startx) #stdscreen.subwin(0,0) #self.window.keypad(1) uni.keypad(self.window, True) self.panel = uni.new_panel(self.window) #.panel.new_panel(self.window) #self.panel.hide() #uni.hide_panel(self.panel) uni.update_panels() #uni.panel.update_panels() self.position = 0 self.items = items self.items.append(('exit', 'exit'))
def __init__(self, main_interface): self.game_interface = main_interface self.x = 130 self.y = 0 self.width = 20 self.height = 50 self.game_menu_interface_window = newwin(self.height, self.width, self.y, self.x) self.game_menu_interface_panel = new_panel(self.game_menu_interface_window) self.buttons = [] self.buttons_list = ["MAIN MENU", "TASKS", "FASTER", "SLOWER", "BUILD TOWER", "READY", "PAUSE"] self._init_buttons() self.topics_pointer = 0 self.locked_buttons = [1, 2, 3, 5] self.to_stay_lock = [] self.last_point = -1 self.enabled = True self.blocked = False wbkgd(self.game_menu_interface_window, CYAN_WHITE) update_panels() doupdate()
def render(self): """Renders but does not show the widget.""" # Draw the box line self.win = uni.newwin(self.height, self.width, self.ypos, self.xpos) if self.outline: uni.box(self.win, 0, 0) # Label self.draw_label() # Box fill # TODO: color fill # Write contents in order for line in self.content: ix = self.content.index(line) + 2 uni.mvwaddstr(self.win, ix, 2, line) # Only create panel attribute on display self.panel = uni.new_panel(self.win)
def init_wins(self): uc.wclear(stdscr) self.max_y, self.max_x = uc.getmaxyx(stdscr) border_x = ceil(self.max_x * 2 / 3) c = int(self.max_x % 2 == 1) self.win_title = uc.newwin(3, self.max_x, 0, 0) #(h, w, starty, startx) self.win_boardarea = uc.newwin(self.max_y - 4, border_x, 3, 0) self.win_shipmenu = uc.newwin(self.max_y - 4, self.max_x - border_x, 3, border_x) self.win_statusbar = uc.newwin(1, self.max_x, self.max_y - 1, 0) x, y = self.player.board.str_size() self.win_board = uc.newwin(y, x + 2, 0, 0) self.pan_board = uc.new_panel(self.win_board) uc.move_panel(self.pan_board, 3 + (self.max_y - 3) // 2 - y // 2, (border_x - 3) // 2 - x // 2) uc.wrefresh(stdscr) self.draw()
my_panels = [0] * 3 stdscr = uni.initscr() uni.start_color() uni.cbreak() uni.noecho() uni.keypad(stdscr, True) uni.init_pair(1, uni.COLOR_RED, uni.COLOR_BLACK) uni.init_pair(2, uni.COLOR_GREEN, uni.COLOR_BLACK) uni.init_pair(3, uni.COLOR_BLUE, uni.COLOR_BLACK) uni.init_pair(4, uni.COLOR_CYAN, uni.COLOR_BLACK) init_wins(my_wins, 3) my_panels[0] = uni.new_panel(my_wins[0]) my_panels[1] = uni.new_panel(my_wins[1]) my_panels[2] = uni.new_panel(my_wins[2]) uni.set_panel_userptr(my_panels[0], my_panels[1]) uni.set_panel_userptr(my_panels[1], my_panels[2]) uni.set_panel_userptr(my_panels[2], my_panels[0]) uni.update_panels() uni.attron(uni.COLOR_PAIR(4)) uni.mvaddstr(0, int(NCOLS / 2) - 2, "Use tab to browse through the windows (Q to Exit)") uni.attroff(uni.COLOR_PAIR(4)) uni.doupdate()
my_panels = [0] * 3 stdscr = uni.initscr() uni.start_color() uni.cbreak() uni.noecho() uni.keypad(stdscr, True) uni.init_pair(1, uni.COLOR_RED, uni.COLOR_BLACK) uni.init_pair(2, uni.COLOR_GREEN, uni.COLOR_BLACK) uni.init_pair(3, uni.COLOR_BLUE, uni.COLOR_BLACK) uni.init_pair(4, uni.COLOR_CYAN, uni.COLOR_BLACK) init_wins(my_wins, 1) #3) my_panels[0] = uni.new_panel(my_wins[0]) #my_panels[1] = uni.new_panel(my_wins[1]) #my_panels[2] = uni.new_panel(my_wins[2]) uni.set_panel_userptr(my_panels[0], my_panels[1]) #uni.set_panel_userptr(my_panels[1], my_panels[2]) #uni.set_panel_userptr(my_panels[2], my_panels[0]) uni.update_panels() # Turn on color text for header #uni.attron(uni.COLOR_PAIR(4)) #uni.mvaddstr(0, int(NCOLS / 2) - 2, "Use tab to browse through the windows (Q to Exit)") # Turn off #uni.attroff(uni.COLOR_PAIR(4)) uni.doupdate()
def __init__(self): self.turn =1 #Create debugging display debug_win = uc.newwin(15, 30, 0, 0) uc.box(debug_win) uc.wmove(debug_win, 1, 1) uc.waddstr(debug_win, "Debug:") uc.wmove(debug_win, 2, 1) debug_pnl = uc.new_panel(debug_win) uc.move_panel(debug_pnl, glob.CAM_HEIGHT, 32) #Generate the world self.world = Map(glob.N_HEX_ROWS, glob.N_HEX_COLS, debug_win) #map_height: 3 + 2*(rows-1) + 2 for border #map_width: 5 + 4*cols + 2 for border map_win = uc.newwin(glob.CAM_HEIGHT, glob.CAM_WIDTH, 0, 0) self.painter = Painter(glob.N_HEX_ROWS, glob.N_HEX_COLS, map_win) self.painter.updateAllTiles(self.world) #Put world window into a panel map_pnl = uc.new_panel(map_win) uc.move_panel(map_pnl, 1, 1) uc.top_panel(debug_pnl) self.status_win = uc.newwin(10, 30, 0, 0) uc.box(self.status_win) uc.wmove(self.status_win, 1, 1) uc.waddstr(self.status_win, "Turn " + str(self.turn)) status_pnl = uc.new_panel(self.status_win) uc.move_panel(status_pnl, glob.CAM_HEIGHT, 2) self.tile_window = TileWindow() self.painter.drawWindow() showChanges() #input loop while True: sys.stdout.flush() ch = uc.getch() uc.waddstr(debug_win, str(ch)) #Exit Key if ch == Key.ESC: break #Movement Keys elif ch == Key.E: self.movePlayer(HexDir.UL) elif ch == Key.R: self.movePlayer(HexDir.UR) elif ch == Key.S: self.movePlayer(HexDir.L) elif ch == Key.G: self.movePlayer(HexDir.R) elif ch == Key.D: self.movePlayer(HexDir.DL) elif ch == Key.F: self.movePlayer(HexDir.DR) #End Turn Key elif ch == Key.SPACE: self.incrementTurn() #Camera Scrolling Keys #TBD: Remaining order checks elif ch == uc.KEY_UP: self.painter.moveCamera(0, -1*glob.CAM_SPEED) elif ch == uc.KEY_DOWN: self.painter.moveCamera(0, glob.CAM_SPEED) elif ch == uc.KEY_LEFT: self.painter.moveCamera(-1*glob.CAM_SPEED, 0) elif ch == uc.KEY_RIGHT: self.painter.moveCamera(glob.CAM_SPEED, 0) #Toggle drawing borders elif ch == Key.B: self.painter.draw_borders = not self.painter.draw_borders self.painter.updateAllTileBorders(self.world) self.painter.drawWindow()
menu = uni.newwin(menu_height, maxx, 0, 0) starty, startx = uni.getbegyx(menu) height, width = uni.getmaxyx(menu) # Box line uni.box(menu, 0, 0) #uni.bkgd(uni.COLOR_PAIR(1)) # Box label #uni.wattron(menu, uni.COLOR_PAIR(0)) #uni.mvwaddstr(menu, 0, 2, "Garin") uni.mvwaddstr(menu, 1, 1, "File") uni.mvwaddstr(menu, 1, len("File") + 2, "Edit") #uni.wattroff(menu, uni.COLOR_PAIR(0)) uni.refresh() #uni.bkgd(uni.COLOR_PAIR(1)) #win_show(my_wins[0], label, 0) panel = uni.new_panel(menu) #uni.set_panel_userptr(panel, panel) uni.update_panels() uni.doupdate() while True: keypress = uni.getch() if keypress == 113: break