예제 #1
0
 def __init__(self, screen, args):
     self.log = logging.getLogger(__name__)
     self.log.debug("Initializing screen.")
     self.args = args
     self.interactive = not args.non_interactive
     if self.interactive:
         res, ret = unicurses.KEY_RESIZE, unicurses.KEY_ENTER
         self.ctrlchars = (res, ret, ord('\n'), ord('\x1b'))
         self.msg = None
         self.screen = screen
         self.h, self.w = 22, 78
         self.wrap = textwrap.TextWrapper(width=self.w - 1)
         self.initattrs()
         self.frame = unicurses.newwin(self.h + 2, self.w + 2, 0, 0)
         unicurses.wborder(self.frame)
         self.win = unicurses.newwin(self.h, self.w, 0, 0)
         unicurses.keypad(self.win, 1)
     self.sslnoverify = sys.version_info >= (2, 7, 9) and args.ssl_no_verify
     self.loadst, self.savest = True, True
     self.state = DataTree(self, {})
     self.oldstate = DataTree(self, {})
     self.validate = Validate(self)
     self.format = Format(self)
     self.nexus = Nexus(self)
     self.artifactory = Artifactory(self)
     self.initstate(args.load_file)
     self.log.debug("Screen initialized.")
예제 #2
0
 def __init__(self, screen, args):
     self.log = logging.getLogger(__name__)
     self.log.debug("Initializing screen.")
     self.args = args
     self.interactive = not args.non_interactive
     if self.interactive:
         res, ret = unicurses.KEY_RESIZE, unicurses.KEY_ENTER
         self.ctrlchars = (res, ret, ord('\n'), ord('\x1b'))
         self.msg = None
         self.screen = screen
         self.h, self.w = 22, 78
         self.wrap = textwrap.TextWrapper(width=self.w - 1)
         self.initattrs()
         self.frame = unicurses.newwin(self.h + 2, self.w + 2, 0, 0)
         unicurses.wborder(self.frame)
         self.win = unicurses.newwin(self.h, self.w, 0, 0)
         unicurses.keypad(self.win, 1)
     self.sslnoverify = sys.version_info >= (2, 7, 9) and args.ssl_no_verify
     self.loadst, self.savest = True, True
     self.state = DataTree(self, {})
     self.oldstate = DataTree(self, {})
     self.validate = Validate(self)
     self.format = Format(self)
     self.nexus = Nexus(self)
     self.artifactory = Artifactory(self)
     self.initstate(args.load_file)
     self.log.debug("Screen initialized.")
예제 #3
0
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(2, 25, 3, 5)
    window.addstr(0,0,"Hello, World!")

    # this window will now be displayed. Since we are doing getch
    # on window, that one is brought to front, window 2 isn't.
    # We can tackle this with panels. Or, explicitly call window2.refresh()
    window2 = curses.newwin(2, 25, 3, 50)
    window2.addstr(0,0,"Hello, World again!")
    
    while True:
      key = window.getch()
      if key == 27:
        break

  except Exception as e:
    stdscr.addstr(0,0,str(e))
    stdscr.getch()
  finally:
    
    curses.endwin()
  
  return 0
예제 #4
0
 def __init__(self, screen):
     self.msg = None
     self.screen = screen
     self.modified = False
     self.h, self.w = 22, 78
     self.nexus = Nexus()
     self.artifactory = Artifactory(self)
     self.wrap = textwrap.TextWrapper(width=self.w)
     self.initattrs()
     self.frame = unicurses.newwin(self.h + 2, self.w + 2, 0, 0)
     unicurses.wborder(self.frame)
     self.win = unicurses.newwin(self.h, self.w, 0, 0)
     unicurses.keypad(self.win, 1)
예제 #5
0
 def __init__(self, screen):
     self.msg = None
     self.screen = screen
     self.mainmenu = None
     self.oldstate = None
     self.h, self.w = 22, 78
     self.nexus = Nexus()
     self.artifactory = Artifactory(self)
     self.wrap = textwrap.TextWrapper(width=self.w - 1)
     self.initattrs()
     self.frame = unicurses.newwin(self.h + 2, self.w + 2, 0, 0)
     unicurses.wborder(self.frame)
     self.win = unicurses.newwin(self.h, self.w, 0, 0)
     unicurses.keypad(self.win, 1)
예제 #6
0
 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()
예제 #7
0
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(10, 25, 3, 3)
        window.addstr(1, 1, "Hey there!")

        window.box()

        while True:
            key = window.getch()
            if key == 27:
                break

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
예제 #8
0
    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()
예제 #9
0
    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)
예제 #10
0
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
예제 #11
0
 def __init__(self, screen):
     self.log = logging.getLogger(__name__)
     self.log.debug("Initializing curses screen.")
     self.msg = None
     self.screen = screen
     self.mainmenu = None
     self.oldstate = None
     self.h, self.w = 22, 78
     self.nexus = Nexus()
     self.artifactory = Artifactory(self)
     self.wrap = textwrap.TextWrapper(width=self.w - 1)
     self.initattrs()
     self.frame = unicurses.newwin(self.h + 2, self.w + 2, 0, 0)
     unicurses.wborder(self.frame)
     self.win = unicurses.newwin(self.h, self.w, 0, 0)
     unicurses.keypad(self.win, 1)
     self.log.debug("Curses screen initialized.")
예제 #12
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)
예제 #13
0
def init_wins(wins, n):
    y = 2
    x = 10
    for i in range(0, n):
        wins[i] = uni.newwin(10, 40, y, x)
        label = str.format("Window number {0}", i + 1)
        win_show(wins[i], label, i + 1)
        y += 3
        x += 7
예제 #14
0
    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 init_wins(wins, n):
    # Screen start area
    y = 0  #2
    x = 0  #10
    for i in range(0, n):
        wins[i] = uni.newwin(10, 40, y, x)
        label = "Window number {0}".format(i + 1)
        win_show(wins[i], label, 0)  # i + 1)
        y += 3
        x += 7
예제 #16
0
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
예제 #17
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()
예제 #18
0
 def __init__(self, window, label="", label_color_pair=0):
     super(Menubar, self).__init__(window)
     self.label = label
     self.label_color_pair = label_color_pair
     self.height = 3
     self.width = self._parent.maxx
     #self.sections = OrderedDict()
     self.submenus = []
     self.selection = None
     # Start window at (0, 0); span 3 down and entire width over
     self.win = uni.newwin(self.height, self.width, 0, 0)
예제 #19
0
    def __init__(self,
                 xoff: int,
                 yoff: int,
                 ncols: int,
                 nrows: int,
                 name: str = None):
        global _ALL_WINDOWS

        self.screen = unicurses.newwin(nrows, ncols, yoff, xoff)
        _ALL_WINDOWS.append(self)

        self.name = name
예제 #20
0
 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()
예제 #21
0
 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()
예제 #22
0
	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()
예제 #23
0
 def __init__(self):
     self.stdscr = unicurses.initscr()
     self.client = Client()
     self.client.connect()
     self.receive_data_thread = threading.Thread(
         target=self.display_received_data)
     self.receive_data_thread.daemon = True
     unicurses.start_color()
     unicurses.init_pair(1, unicurses.COLOR_GREEN, unicurses.COLOR_BLACK)
     self.height, self.width = self.stdscr.getmaxyx()
     self.displayWindow = unicurses.newwin(self.height - 6, self.width, 0,
                                           0)
     self.infoWindow = unicurses.newwin(3, self.width, self.height - 6, 0)
     self.inputWindow = unicurses.newwin(3, self.width, self.height - 3, 0)
     self.inputWindow.move(1, 1)
     self.msg = ''
     self.init_display_screen()
     self.init_info_screen()
     try:
         self.receive_data_thread.start()
     except (KeyboardInterrupt, SystemExit):
         sys.exit()
예제 #24
0
def show_search_screen(stdscr):
    curses.curs_set(1)
    stdscr.addstr(1, 2, 'Artist name: (Enter to search)')

    editwin = curses.newwin(1, 40, 3, 3)
    rectangle(stdscr, 2, 2, 4, 44)
    stdscr.refresh()

    box = Textbox(editwin)
    box.edit()

    criteria = box.gather()
    return criteria
예제 #25
0
    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()
예제 #26
0
 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()
예제 #27
0
 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()
예제 #28
0
 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()
예제 #29
0
    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'))
예제 #30
0
 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()
예제 #31
0
 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()
예제 #32
0
    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)
예제 #33
0
    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()
예제 #34
0
    def close(self):
        prompt_start_x = self.max_x // 2 - 19
        prompt_start_y = self.max_y // 3

        if prompt_start_x < 1:
            prompt_start_x = 1
        if prompt_start_y < 1:
            prompt_start_y = 1

        win_prompt = uc.newwin(3, 38, prompt_start_y, prompt_start_x)
        uc.box(win_prompt, 0, 0)
        uc.mvwaddstr(win_prompt, 1, 1, 'Do you want to close the game? (y|n)')
        uc.wbkgd(win_prompt, uc.COLOR_PAIR(1))
        uc.wrefresh(win_prompt)

        answer = uc.wgetch(stdscr)
        if answer == ord('y') or answer == ord('Y'):
            uc.endwin()
            exit()
        else:
            uc.delwin(win_prompt)
NCOLS = 40
#my_wins = [0] * 3

stdscr = uni.initscr()
uni.cbreak()
uni.noecho()
uni.keypad(stdscr, True)
uni.curs_set(0)

uni.start_color()

# Sub window
# Max coords of parent window
maxy, maxx = uni.getmaxyx(stdscr)
menu_height = 3
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()
예제 #36
0
파일: window.py 프로젝트: Chiel92/tfate
 def __init__(self, ui):
     self.win = curses.newwin(0, 0, 0, 0)
     self.ui = ui
     self.doc = ui.doc
     self.enabled = True
예제 #37
0
    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()
예제 #38
0
        if (mouse_y == j + choice) and (mouse_x >= i) and (mouse_x <= i + len(choices[choice])):
            if choice == n_choices - 1:
                return -1
            else:
                return choice + 1
            break

stdscr = uni.initscr()
uni.clear()
uni.noecho()
uni.cbreak()
uni.curs_set(0)
startx = int((80 - WIDTH) / 2)
starty = int((24 - HEIGHT) / 2)

menu_win = uni.newwin(HEIGHT, WIDTH, starty, startx)
uni.keypad(menu_win, True)
uni.mvaddstr(0, 0, "Click on Exit to quit (works best in a virtual console)")
uni.refresh()
print_menu(menu_win, 1)
uni.mouseinterval(0)
uni.mousemask(uni.ALL_MOUSE_EVENTS)


msg = "MOUSE: {0}, {1}, {2}, Choice made is: {3}, Chosen string is: {4}"
while True:
    c = uni.wgetch(menu_win)
    if c == uni.KEY_MOUSE:
        id, x, y, z, bstate = uni.getmouse()
        if bstate & uni.BUTTON1_PRESSED:
            chosen = report_choice(x + 1, y + 1)
예제 #39
0
# -*- coding: utf-8 -*-
"""
Created on Wed Oct  5 16:01:09 2016

@author: Graham Cooke
"""

import unicurses

unicurses.initscr()

unicurses.newwin(10, 10)