예제 #1
0
 def refresh(self):
     if self.enabled and not self.blocked:
         self.draw()
         box(self.game_field_window)
         wrefresh(self.game_field_window)
         update_panels()
         doupdate()
예제 #2
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()
예제 #3
0
 def _activate(self):
     box(self.button_window)
     mvwaddstr(self.button_window, ((self.height + 1) // 2) - 1, (self.width - len(self.name)) // 2 + 1, self.name)
     wbkgd(self.button_window, BLUE_WHITE)
     wrefresh(self.button_window)
     update_panels()
     doupdate()
예제 #4
0
    def draw(self):
        if self.game_interface.game_initialized:
            self.field_data_pull = self.game_interface.game.game_map
            x = 1
            y = 1

            for line in self.field_data_pull:
                for cell in line:
                    if cell == ':':
                        mvwaddstr(self.game_field_window, y, x, cell,
                                  GREEN_YELLOW)
                    elif cell == '~':
                        mvwaddstr(self.game_field_window, y, x, cell,
                                  BLUE_WHITE)
                    elif cell == '#':
                        mvwaddstr(self.game_field_window, y, x, cell,
                                  BLACK_RED)
                    elif cell == 'C':
                        mvwaddstr(self.game_field_window, y, x, cell,
                                  BLUE_WHITE)
                    else:
                        mvwaddstr(self.game_field_window, y, x, cell,
                                  WHITE_BLACK)
                    x += 1
                x = 1
                y += 1
            wrefresh(self.game_field_window)
            if self.selector:
                self.selector.refresh_for_draw()
            update_panels()
            doupdate()
예제 #5
0
 def showLineEdit(self, sel, quiet):
     maxwidth = 4096
     fw, hw = self.scr.w - 2, (self.scr.w - 2) / 2
     unicurses.waddstr(self.scr.win, "Edit " + sel['text'] + ":\n> ")
     unicurses.noutrefresh(self.scr.win)
     (yn, xn) = unicurses.getyx(self.scr.win)
     buf = unicurses.newpad(1, maxwidth + 1)
     unicurses.keypad(buf, 1)
     offs, length, submit = 0, 0, False
     if not quiet and sel['val'] != None and sel['val'] != (None, ):
         length = len(sel['val'])
         unicurses.waddstr(buf, sel['val'])
         offs = max(0, length / hw - 1)
         (yb, xb) = unicurses.getbegyx(self.scr.win)
         (yp, xp) = (yn + yb, xn + xb)
         unicurses.prefresh(buf, 0, offs * hw, yp, xp, yp, xp + fw - 1)
     unicurses.doupdate()
     while True:
         if quiet: ch = self.scr.getch(buf, redact=True)
         else:
             etc = (buf, 0, offs * hw, yn, xn, yn, xn + fw - 1)
             ch = self.scr.getch(buf, etc)
         (y, x) = unicurses.getyx(buf)
         if ch in (ord('\n'), unicurses.KEY_ENTER):
             sel['val'] = unicurses.mvwinstr(buf, 0, 0, length)
             if sel['val'] != None and len(sel['val']) == 0:
                 sel['val'] = None
             submit = True
             break
         elif ch == ord('\x1b'):
             break
         elif ch == unicurses.KEY_HOME and x > 0:
             unicurses.wmove(buf, y, 0)
         elif ch == unicurses.KEY_END and x < length:
             unicurses.wmove(buf, y, length)
         elif ch == unicurses.KEY_LEFT and x > 0:
             unicurses.wmove(buf, y, x - 1)
         elif ch == unicurses.KEY_RIGHT and x < length:
             unicurses.wmove(buf, y, x + 1)
         elif ch in (ord('\b'), ord('\x7f'), unicurses.KEY_BACKSPACE,
                     unicurses.KEY_DC) and x > 0:
             unicurses.wmove(buf, y, x - 1)
             unicurses.wdelch(buf)
             length -= 1
         elif ord(' ') <= ch <= ord('~') and length < maxwidth:
             unicurses.winsstr(buf, chr(ch))
             length += 1
             unicurses.wmove(buf, y, x + 1)
         else:
             continue
         if quiet: continue
         oldoffs, offs = offs, max(0, unicurses.getyx(buf)[1] / hw - 1)
         if oldoffs < offs and maxwidth - offs * hw < fw:
             unicurses.wclrtoeol(self.scr.win)
             unicurses.noutrefresh(self.scr.win)
         (yb, xb) = unicurses.getbegyx(self.scr.win)
         (yp, xp) = (yn + yb, xn + xb)
         unicurses.prefresh(buf, 0, offs * hw, yp, xp, yp, xp + fw - 1)
         unicurses.doupdate()
     return submit
예제 #6
0
def main():

    if not curses.has_colors():
        print("Your terminal emulator needs to have colors.")
        return 0

    ## 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.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
예제 #7
0
 def refresh(self):
     if self.enabled and not self.blocked:
         self.draw()
         box(self.game_field_window)
         wrefresh(self.game_field_window)
         update_panels()
         doupdate()
예제 #8
0
def write(scrid, text, ypos, xpos, color="white"):
    uni.setsyx(ypos, xpos)
    uni.waddstr(scrid, text)
    uni.setsyx(0, 0)
    uni.refresh()
    uni.update_panels()
    uni.doupdate()
예제 #9
0
    def draw(self):
        if self.game_interface.game_initialized:
            self.field_data_pull = self.game_interface.game.game_map
            x = 1
            y = 1

            for line in self.field_data_pull:
                for cell in line:
                    if cell == ':':
                        mvwaddstr(self.game_field_window, y, x, cell, GREEN_YELLOW)
                    elif cell == '~':
                        mvwaddstr(self.game_field_window, y, x, cell, BLUE_WHITE)
                    elif cell == '#':
                        mvwaddstr(self.game_field_window, y, x, cell, BLACK_RED)
                    elif cell == 'C':
                        mvwaddstr(self.game_field_window, y, x, cell, BLUE_WHITE)
                    else:
                        mvwaddstr(self.game_field_window, y, x, cell, WHITE_BLACK)
                    x += 1
                x = 1
                y += 1
            wrefresh(self.game_field_window)
            if self.selector:
                self.selector.refresh_for_draw()
            update_panels()
            doupdate()
예제 #10
0
 def _activate(self):
     box(self.button_window)
     mvwaddstr(self.button_window, ((self.height + 1) // 2) - 1,
               (self.width - len(self.name)) // 2 + 1, self.name)
     wbkgd(self.button_window, BLUE_WHITE)
     wrefresh(self.button_window)
     update_panels()
     doupdate()
예제 #11
0
 def draw(self):
     """Draw window and all child widgets."""
     uni.clrtobot()
     uni.refresh()
     # Requires all child widgets to have a show method
     [w.show() for w in self.widgets]
     uni.update_panels()
     uni.doupdate()
예제 #12
0
 def refresh(self):
     if self.enabled:
         for button in self.buttons:
             button.refresh()
         box(self.game_menu_interface_window)
         wrefresh(self.game_menu_interface_window)
         update_panels()
         doupdate()
예제 #13
0
 def refresh(self):
     if self.enabled:
         for button in self.buttons:
             button.refresh()
         box(self.game_menu_interface_window)
         wrefresh(self.game_menu_interface_window)
         update_panels()
         doupdate()
예제 #14
0
 def showLineEdit(self, sel, quiet):
     maxwidth = 4096
     fw, hw = self.scr.w - 2, (self.scr.w - 2)/2
     unicurses.waddstr(self.scr.win, "Edit " + sel['text'] + ":\n> ")
     unicurses.noutrefresh(self.scr.win)
     (yn, xn) = unicurses.getyx(self.scr.win)
     buf = unicurses.newpad(1, maxwidth + 1)
     unicurses.keypad(buf, 1)
     offs, length, submit = 0, 0, False
     if not quiet and sel['val'] != None:
         length = len(sel['val'])
         unicurses.waddstr(buf, sel['val'])
         offs = max(0, length/hw - 1)
         (yb, xb) = unicurses.getbegyx(self.scr.win)
         (yp, xp) = (yn + yb, xn + xb)
         unicurses.prefresh(buf, 0, offs*hw, yp, xp, yp, xp + fw - 1)
     unicurses.doupdate()
     while True:
         if quiet: ch = self.scr.getch(buf)
         else:
             etc = (buf, 0, offs*hw, yn, xn, yn, xn + fw - 1)
             ch = self.scr.getch(buf, etc)
         (y, x) = unicurses.getyx(buf)
         if ch in (ord('\n'), unicurses.KEY_ENTER):
             sel['val'] = unicurses.mvwinstr(buf, 0, 0, length)
             if sel['val'] != None and len(sel['val']) == 0:
                 sel['val'] = None
             submit = True
             break
         elif ch == ord('\x1b'): break
         elif ch == unicurses.KEY_HOME and x > 0:
             unicurses.wmove(buf, y, 0)
         elif ch == unicurses.KEY_END and x < length:
             unicurses.wmove(buf, y, length)
         elif ch == unicurses.KEY_LEFT and x > 0:
             unicurses.wmove(buf, y, x - 1)
         elif ch == unicurses.KEY_RIGHT and x < length:
             unicurses.wmove(buf, y, x + 1)
         elif ch in (ord('\b'), ord('\x7f'), unicurses.KEY_BACKSPACE,
                     unicurses.KEY_DC) and x > 0:
             unicurses.wmove(buf, y, x - 1)
             unicurses.wdelch(buf)
             length -= 1
         elif ord(' ') <= ch <= ord('~') and length < maxwidth:
             unicurses.winsstr(buf, chr(ch))
             length += 1
             unicurses.wmove(buf, y, x + 1)
         else: continue
         if quiet: continue
         oldoffs, offs = offs, max(0, unicurses.getyx(buf)[1]/hw - 1)
         if oldoffs < offs and maxwidth - offs*hw < fw:
             unicurses.wclrtoeol(self.scr.win)
             unicurses.noutrefresh(self.scr.win)
         (yb, xb) = unicurses.getbegyx(self.scr.win)
         (yp, xp) = (yn + yb, xn + xb)
         unicurses.prefresh(buf, 0, offs*hw, yp, xp, yp, xp + fw - 1)
         unicurses.doupdate()
     return submit
예제 #15
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()
예제 #16
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()
예제 #17
0
 def building(self, key):
     if not self.selector:
         self.selector = GameFieldSelector(self, self.game_field_window)
     self.selector.key_event(key)
     if key == 10:
         if self.selector.building_zone_free:
             self.game_interface.game.add_tower(self.selector.x - 1, self.selector.y - 1)
             self.exit_building()
     elif key == 27:
         self.exit_building()
     wrefresh(self.game_field_window)
     update_panels()
     doupdate()
예제 #18
0
 def building(self, key):
     if not self.selector:
         self.selector = GameFieldSelector(self, self.game_field_window)
     self.selector.key_event(key)
     if key == 10:
         if self.selector.building_zone_free:
             self.game_interface.game.add_tower(self.selector.x - 1,
                                                self.selector.y - 1)
             self.exit_building()
     elif key == 27:
         self.exit_building()
     wrefresh(self.game_field_window)
     update_panels()
     doupdate()
예제 #19
0
 def render(self, etc=None):
     unicurses.redrawwin(self.screen)
     unicurses.noutrefresh(self.screen)
     (hw, ww) = unicurses.getmaxyx(self.screen)
     (yw, xw) = (max(0, (hw - self.h)/2), max(0, (ww - self.w)/2))
     if yw > 0 and xw > 0:
         unicurses.mvwin(self.frame, yw - 1, xw - 1)
         unicurses.noutrefresh(self.frame)
     unicurses.mvwin(self.win, yw, xw)
     unicurses.noutrefresh(self.win)
     if etc != None:
         (buf, a, b, c, d, e, f) = etc
         (yb, xb) = unicurses.getbegyx(self.win)
         unicurses.prefresh(buf, a, b, c + yb, d + xb, e + yb, f + xb)
     unicurses.doupdate()
예제 #20
0
 def refresh(self):
     if self.enabled:
         x = 2
         y = 2
         box(self.game_stat_window, 0, 0)
         mvwaddstr(self.game_stat_window, y, x, " " * 127)
         if self.game_interface.game_initialized:
             for param in self.game_interface.game.player.strings_info:
                 wattron(self.game_stat_window, A_REVERSE)
                 mvwaddstr(self.game_stat_window, y, x, param, RED_WHITE)
                 wattroff(self.game_stat_window, A_REVERSE)
                 x += 5 + len(param)
         wrefresh(self.game_stat_window)
         update_panels()
         doupdate()
예제 #21
0
 def refresh(self):
     if self.enabled:
         x = 2
         y = 2
         box(self.game_stat_window, 0, 0)
         mvwaddstr(self.game_stat_window, y, x, " " * 127)
         if self.game_interface.game_initialized:
             for param in self.game_interface.game.player.strings_info:
                 wattron(self.game_stat_window, A_REVERSE)
                 mvwaddstr(self.game_stat_window, y, x, param, RED_WHITE)
                 wattroff(self.game_stat_window, A_REVERSE)
                 x += 5 + len(param)
         wrefresh(self.game_stat_window)
         update_panels()
         doupdate()
예제 #22
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()
예제 #23
0
 def render(self, etc=None):
     unicurses.redrawwin(self.screen)
     unicurses.noutrefresh(self.screen)
     (hw, ww) = unicurses.getmaxyx(self.screen)
     (yw, xw) = (max(0, (hw - self.h) / 2), max(0, (ww - self.w) / 2))
     if yw > 0 and xw > 0:
         unicurses.mvwin(self.frame, yw - 1, xw - 1)
         unicurses.noutrefresh(self.frame)
     unicurses.mvwin(self.win, yw, xw)
     unicurses.noutrefresh(self.win)
     if etc != None:
         (buf, a, b, c, d, e, f) = etc
         (yb, xb) = unicurses.getbegyx(self.win)
         unicurses.prefresh(buf, a, b, c + yb, d + xb, e + yb, f + xb)
     unicurses.doupdate()
예제 #24
0
    def _get_input(self, wait_tenths):
        # this works around a strange curses bug with window resizing
        # not being reported correctly with repeated calls to this
        # function without a doupdate call in between
        curses.doupdate()

        key = self._getch(wait_tenths)
        resize = False
        raw = []
        keys = []


        while key >= 0:
            raw.append(key)
            if key==KEY_RESIZE:
                resize = True
            elif key==KEY_MOUSE:
                keys += self._encode_mouse_event()
            else:
                keys.append(key)
            key = self._getch_nodelay()

        processed = []

        try:
            while keys:
                run, keys = self.process_keyqueue(keys, True)
                processed += run
        except escape.MoreInputRequired:
            key = self._getch(self.complete_tenths)
            while key >= 0:
                raw.append(key)
                if key==KEY_RESIZE:
                    resize = True
                elif key==KEY_MOUSE:
                    keys += self._encode_mouse_event()
                else:
                    keys.append(key)
                key = self._getch_nodelay()
            while keys:
                run, keys = self.process_keyqueue(keys, False)
                processed += run

        if resize:
            processed.append('window resize')

        return processed, raw
예제 #25
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
예제 #26
0
    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)
예제 #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, 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()
예제 #30
0
 def _refresh(self):
     x = 2
     y = 2
     box(self.menu_window, 0, 0)
     for i in range(0, len(self.topics)):
         if self.topics_pointer == i:
             wattron(self.menu_window, A_REVERSE)
             mvwaddstr(self.menu_window, y, x, self.topics[i])
             wattroff(self.menu_window, A_REVERSE)
         elif i in self.locked_topics:
             wattron(self.menu_window, A_UNDERLINE)
             mvwaddstr(self.menu_window, y, x, self.topics[i])
             wattroff(self.menu_window, A_UNDERLINE)
         else:
             mvwaddstr(self.menu_window, y, x, self.topics[i])
         y += 1
     wrefresh(self.menu_window)
     update_panels()
     doupdate()
예제 #31
0
 def _refresh(self):
     x = 2
     y = 2
     box(self.menu_window, 0, 0)
     for i in range(0, len(self.topics)):
         if self.topics_pointer == i:
             wattron(self.menu_window, A_REVERSE)
             mvwaddstr(self.menu_window, y, x, self.topics[i])
             wattroff(self.menu_window, A_REVERSE)
         elif i in self.locked_topics:
             wattron(self.menu_window, A_UNDERLINE)
             mvwaddstr(self.menu_window, y, x, self.topics[i])
             wattroff(self.menu_window, A_UNDERLINE)
         else:
             mvwaddstr(self.menu_window, y, x, self.topics[i])
         y += 1
     wrefresh(self.menu_window)
     update_panels()
     doupdate()
예제 #32
0
def main():

    if not curses.has_colors():
        print("Your terminal emulator needs to have colors.")
        return 0

    ## 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()

        avatar = Player(stdscr, "@", curses.COLOR_RED, curses.COLOR_BLACK,
                        curses.A_BOLD)

        curses.attron(curses.color_pair(1))
        curses.vline("|", 10)
        curses.hline("-", 10)
        curses.attroff(curses.color_pair(1))

        while True:
            key = curses.getch()

            avatar.move(key)

            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
예제 #33
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
예제 #34
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()
예제 #35
0
    def render(self):
        # Set the panel order based on what action is going on.
        self.set_panel_order()

        # Update the panel size incase the terminal size changed.
        self.update_panel_size()

        # Clear the screen.
        uc.erase()

        # Draw all of the panels.
        self.render_user_panel()
        self.render_track_panel()
        self.render_player_panel()
        self.render_footer()
        self.render_search_panel()
        self.render_select_device_panel()
        self.render_popup_panel()

        # Required.
        uc.update_panels()
        uc.doupdate()
예제 #36
0
    def display(self):
        #self.panel.top()
        uni.top_panel(self.panel)
        uni.show_panel(self.panel)
        #self.panel.show()
        uni.clear()  #self.window.clear()

        while True:
            uni.refresh()  #self.window.refresh()
            uni.doupdate()
            for index, item in enumerate(self.items):
                if index == self.position:
                    mode = uni.A_REVERSE
                else:
                    mode = uni.A_NORMAL

                msg = '%d. %s' % (index, item[0])
                uni.mvaddstr(1 + index, 1, msg, mode)

            key = uni.getch()

            if key in [uni.KEY_ENTER, ord('\n')]:
                if self.position == len(self.items) - 1:
                    break
                else:
                    self.items[self.position][1]()

            elif key == uni.KEY_UP:
                self.navigate(-1)

            elif key == uni.KEY_DOWN:
                self.navigate(1)

        uni.clear()  #self.window.clear()
        uni.hide_panel(self.panel)  #self.panel.hide()
        uni.update_panels()  #panel.update_panels()
        uni.doupdate()
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
예제 #38
0
def main(stdscr):
    curses.cbreak()
    curses.noecho()
    stdscr.keypad(True)
    height, width = stdscr.getmaxyx()

    suffix_text = ' (TAB to search by artist)'
    albums_panel = Menu('Album(s) for the selected artist' + suffix_text,
                        (height, width, 0, 0))

    tracks_panel = Menu('Track(s) for the selected album' + suffix_text,
                        (height, width, 0, 0))

    criteria = show_search_screen(stdscr)
    _data_manager = DataManager()
    artist = _data_manager._search_artist(criteria)
    albums = _data_manager.get_artist_albums(artist['id'])

    clear_screen(stdscr)

    albums_panel.items = albums
    albums_panel.init()
    albums_panel.update()
    albums_panel.show()

    current_panel = albums_panel
    is_running = True

    while is_running:
        curses.doupdate()
        current_panel.update()

        key = stdscr.getch()
        action = current_panel.handle_events(key)

        if action is not None:
            action_result = action()
            if current_panel == albums_panel and action_result is not None:
                _id, uri = action_result
                tracks = _data_manager.get_album_tracklist(_id)
                current_panel.hide()
                current_panel = tracks_panel
                current_panel.items = tracks
                current_panel.init()
                current_panel.show()
            elif current_panel == tracks_panel and action_result is not None:
                _id, uri = action_result
                _data_manager.play(uri)

        if key == TAB:
            current_panel.hide()
            criteria = show_search_screen(stdscr)
            artist = _data_manager._search_artist(criteria)
            albums = _data_manager.get_artist_albums(artist['id'])

            clear_screen(stdscr)
            current_panel = albums_panel
            current_panel.items = albums
            current_panel.init()
            current_panel.show()

        if key == ord('q') or key == ord('Q'):
            is_running = False

        current_panel.update()
예제 #39
0
def showChanges():
    uc.update_panels()
    uc.doupdate()
예제 #40
0
 def show_changes(self):
     curses.update_panels()
     curses.doupdate()