예제 #1
0
파일: ui.py 프로젝트: GudniNatan/GSKI-PA6
 def operation_result(self, result_message, undo_op, continue_op):
     result_menu = Menu("Operation result:\n" + result_message, {
         "Undo": undo_op,
         "Continue": continue_op
     })
     key, operation = result_menu.get_input()
     return operation
예제 #2
0
 def __init__(self, resolution, block_size):
     self.window_size = resolution
     self.block_size = block_size
     self.display = DrawWindow(self.window_size)
     self.menu = Menu((self.window_size), Eventqueue(
         self.block_size), self.display)
     self.game = Game(self.window_size, self.block_size, self.menu)
예제 #3
0
파일: ui.py 프로젝트: GudniNatan/GSKI-PA6
 def choose(self, items: typing.Iterable, message: str = None):
     """Let user pick from list, returns picked item."""
     options = {str(item): item for item in items}
     message = "Choose an item:\n" if message is None else message
     menu = Menu(message, options)
     item_str, item = menu.get_input()
     return item
예제 #4
0
파일: ui.py 프로젝트: vivaelnino9/run
 def run(self):
     while True:
         if self.state == -1:
             self.draw_background()
             self.draw_footer()
             self.window.getch()
             # start main menu
             m = Menu()
             if m.selection < 0:
                 break
             self.state = m.selection
         elif self.state == 0:
             self.window.erase()
             self.draw_footer(main=False)
             self.window.getch()
             # get game difficulty
             m = Menu(main=False)
             if m.selection < 0:
                 # go back to main menu
                 self.state = -1
                 continue
             # start game
             game = Game(self.height, self.width, difficulty=m.selection)
             game.start()
             # If quit game back to main menu
             self.state = -1
         elif self.state == 2:
             # TODO Controls State
             break
         elif self.state == 4:
             # TODO Exit State (Message for exiting)
             break
예제 #5
0
    def __init__(self, game):
        """The class contructor, which creates a new Main Menu.

        Args:
            game: The game which the menu is attached to. This is passed to the
            constructor of the Menu superclass.
        """

        Menu.__init__(self, game)
        self.state = "2"
예제 #6
0
def getCommand(cmd):
    commands = Menu.get_commands()
    #cmd args
    currentCmd = cmd.split(" ")
    try:
        validate_command(currentCmd[0], list(commands.keys()))
    except Exception as ex:
        print(str(ex))
        return
    if len(currentCmd) > 1:
        return Menu.get_commandAt(currentCmd[0]), currentCmd[1]
    return Menu.get_commandAt(currentCmd[0]), None
예제 #7
0
class TitleScreen:
    '''A class for the title screen.

    attr:
        menu: Menu object; the start menu of the game
        title_text: lst; list of tuples (surface, rectangle); title of the game
    '''
    def __init__(self, renderer):
        '''TitleScreen class constructor.

        args:
            renderer: Renderer object
        '''
        self._renderer = renderer

        options = [('battle', 'battle', 'battle'), ('help', 'help', 'help'),
                   ('quit', 'quit', 'quit')]
        x = SCREEN_W // 2
        y = SCREEN_H // 2
        self.menu = Menu(options, 0, SCREEN_W, SCREEN_H, x, y)
        self._title_text = self._create_title_text()

    def render(self):
        '''Renders the title screen.'''
        self.menu.draw(self._renderer)
        for text in self._title_text:
            self._renderer.blit(text[0], text[1])

    def update(self, keys):
        '''Updates the title screen menu.

        args:
            keys: Keys object
        '''
        return self.menu.update(keys)

    def _create_title_text(self):
        '''Creates rendered text surfaces for the title screen.

        return:
            lst; tuples of surfaces and their bounding rectangles
        '''
        top = 'fractured loop:'
        bottom = 'turn-based battle demo'

        top_surf = self._renderer.create_text(top, FONT_SIZE * 2)
        top_rect = top_surf.get_rect(center=(SCREEN_W // 2, SCREEN_H // 4))
        bottom_surf = self._renderer.create_text(bottom, FONT_SIZE)
        bottom_rect = bottom_surf.get_rect(midtop=(SCREEN_W // 2,
                                                   SCREEN_H // 3))

        return [(top_surf, top_rect), (bottom_surf, bottom_rect)]
예제 #8
0
 def run(self):
     """Functia principala care executa programul"""
     while True:
         if Menu.getStackSize() == 0:
             return
         self.__displayMenu()
         op = self.__readOption()
         if Menu.getCurrentMenu().isOption(op):
             self.getNextOption(op)
         else:
             print("Optiunea aleasa trebuie sa fie din multimea " + str(
                 list(Menu.getCurrentMenu().getMenuFunctions().keys())) +
                   "\n")
예제 #9
0
    def __init__(self, game):
        """The class contructor, which creates a new Main Menu.

        Args:
            game: The game which the menu is attached to. This is passed to the
            constructor of the Menu superclass.
        """

        Menu.__init__(self, game)
        self.state = "Solve"
        mid_width, mid_height = self.renderer.display_width / 2, self.renderer.display_height / 2
        self.solvex, self.solvey = mid_width, mid_height + 30
        self.createx, self.createy = mid_width, mid_height + 50
        self.cursor_rect.midtop = (self.solvex + self.offset, self.solvey)
예제 #10
0
    def __init__(self, renderer):
        '''TitleScreen class constructor.

        args:
            renderer: Renderer object
        '''
        self._renderer = renderer

        options = [('battle', 'battle', 'battle'), ('help', 'help', 'help'),
                   ('quit', 'quit', 'quit')]
        x = SCREEN_W // 2
        y = SCREEN_H // 2
        self.menu = Menu(options, 0, SCREEN_W, SCREEN_H, x, y)
        self._title_text = self._create_title_text()
예제 #11
0
파일: console.py 프로젝트: RaulPele/LAB4-6
def callFunction(complexOp, op):
    """
    Apeleaza functia corespunzatoare optiunii op din meniu pentru obiectul de operatii ComplexOperations
    :param complexOp: obiect ComplexOperations
    :param op: string - optiunea aleasa de utilizator
    """
    currentMenu = Menu.get_currentMenu()

    if Menu.user_exits(op):
        Menu.navigate_backwards()

    menuFunctions = currentMenu.get_menuFunctions()

    if op in menuFunctions:
        currentMenu.get_functionAt(menuFunctions, op)(complexOp)
예제 #12
0
def main():
    player = Tracker(color='blue')
    game = Game(flag=False)
    s = Server(handler=game.opponent,
               host=args.host,
               sender=args.sender,
               receiver=args.receiver)
    screen = game.get_screen()
    menu = Menu(screen, s.pubsub)
    menu.main_menu()

    while True:
        player.track(show=False)
        s.send(player.y_loc)
        game.update(player.y_loc, s.pubsub)
예제 #13
0
def main(std_scr):
    last_key_pressed = 0
    files = []
    if len(sys.argv) > 1:
        files.extend(list(set(sys.argv[1:])))
    else:
        # could add a welcome page
        files.extend(["Untitled.txt"])
    context = {
        "Menu": Menu(std_scr),
        "Explorer": Explorer(std_scr),
        "Manager": Manager(std_scr, files)
    }
    navigator = Termineditor(std_scr=std_scr,
                             context=context,
                             current_state=context["Manager"],
                             curses=curses)

    while last_key_pressed != CTRL_X:
        std_scr.clear()
        navigator.display_all_states()
        if not navigator.get_last_came_from() is context["Manager"]:
            last_key_pressed = std_scr.getch()
        else:
            curses.curs_set(False)
            navigator.set_last_came_from(None)
        check_navigation(navigator, last_key_pressed, curses)
        if navigator.get_current_state() is context["Manager"]:
            curses.curs_set(True)
예제 #14
0
 def logged_in_mode(self):
     Menu()
     core.delete_item("Login Window")
     core.add_tab_bar(name="tab_bar", parent="Main Window")
     Tab("Workout", "tab_bar").generate_tab()
     Tab("Records", "tab_bar").generate_tab()
     simple.show_item("Main Menu")
예제 #15
0
 def __operatiiBlocare(self):
     comenzi = {
         '1': self.__tipuriBlocate,
         '2': self.__deblocheazaTip,
         '3': self.__deblocheazaTot,
         '4': self.__blocheazaTip
     }
     while True:
         Menu.showMenuBlocare(self)
         comanda = input('Dati comanda dorita: ')
         if comanda == "0":
             print("La revedere!")
             break
         if not comenzi.__contains__(comanda):
             print("Ati introdus o comanda invalida!\n\n")
         else:
             comenzi[comanda]()
예제 #16
0
 def setUp(self):
     pygame.font.init()
     self.display = pygame.display.set_mode((1024, 640))
     self.gamelogic = GameLogic()
     self.colors = Colors()
     self.startview = StartView(self.display, self.colors)
     self.save = SaveGame(self.gamelogic)
     self.menu = Menu(self.display, self.colors)
     self.shop = Shop(self.display, self.colors, self.gamelogic)
     pygame.init()
예제 #17
0
    def start(self):
        comenzi = {
            '1': self.__afiseazaEmisiuni,
            '2': self.__stergeEmisiune,
            '3': self.__modificaEmisiune,
            '4': self.__genereazaProgramTV,
            '5': self.__operatiiBlocare
        }

        while True:
            Menu.showMenu(self)
            comanda = input('Dati comanda dorita: ')
            if comanda == "0":
                print("La revedere!")
                break
            if not comenzi.__contains__(comanda):
                print("Ati introdus o comanda invalida!\n\n")
            else:
                comenzi[comanda]()
예제 #18
0
    def list_menu_test(self, words):

        words_menu = Menu.menu_from_list(words)
        print(words_menu)
        user_input = input("Number or 'q' to quit: ")

        while user_input != 'q':

            pronunciations = words[int(user_input) - 1].pronunciations

            prons_menu = Menu.menu_from_list(pronunciations)
            print(prons_menu)
            user_input = input("Number or 'q' to quit: ")

            while user_input != 'q':
                self.play_pron(pronunciations[int(user_input) - 1])
                user_input = input("Number or 'q' to quit: ")

            print("\n" + words_menu)
            user_input = input("Number or 'q' to quit: ")
예제 #19
0
    def show_menu(self):
        """Shows the menu screen.
        """

        self.hide_current_view()
        self._current_view = Menu(
            self._root,
            self.handle_username_select,
            self.handle_game_history,
        )
        self._current_view.pack()
예제 #20
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        self.vbox = QVBoxLayout()
        self.setLayout(self.vbox)

        self.preview = QPrintPreviewWidget()
        self.preview.fitToWidth()
        self.vbox.addWidget(self.preview)

        self.menu = Menu('', show_caption=False)
        self.print = self.menu.add_button('Печать')
        self.passport = self.menu.add_button('Передать даннные в электронный паспорт локомотива')
        self.exit = self.menu.add_button('Вернуться в главное меню')
        self.vbox.addWidget(self.menu)
        self.menu.setFixedHeight(140)
        self.menu.vbox.setContentsMargins(0, 0, 0, 0)
        self.passport.clicked.connect(self.connect_passport)
        self.print.clicked.connect(self.preview.print)
        self.on_preview = None
        self.preview.paintRequested.connect(self.on_paint_request)
예제 #21
0
파일: ui.py 프로젝트: GudniNatan/GSKI-PA6
 def search_result_choice(self,
                          results,
                          next,
                          back,
                          order_field=None,
                          message=""):
     """Get user choice from search results."""
     options = [("Back", back)] + [(str(item), item) for item in results]
     menu_msg = ""
     if order_field == "sports":
         menu_msg = "Ordered based on the first alphabetically ordered "
         menu_msg += "sport users are registered for. \nUsers not "
         menu_msg += "registered for any sports are hidden.\n"
     if message:
         menu_msg += message
     else:
         menu_msg += "Search results:"
     menu = Menu(menu_msg, options)
     string, item = menu.get_input()
     if string == "Back":
         return None, item
     return item, next
예제 #22
0
 def select_foreign_key_relationship_inverse(relationship):
     foreign_keys = []
     repository = relationship.repository()
     while Menu.yes_no_question('Add %s' % relationship.name):
         print(Style.create_title('Select %s' % relationship.name))
         paginated_menu = relationship.paginated_menu or Pagination(
             repository)
         item = paginated_menu()
         if item:
             foreign_keys.append(item['id'])
         else:
             print('\nNo relationship added\n')
     return relationship.related_name, foreign_keys
예제 #23
0
    def __init__(self, game):
        """The class contructor, which creates a new Main Menu.

        Args:
            game: The game which the menu is attached to. This is passed to the
            constructor of the Menu superclass.
        """

        Menu.__init__(self, game)
        self.state = "0"
        self.lab_selection = []

        j = 0
        while j < len(self.game.labs):
            self.lab_selection.append(self.game.labs[j:j + 3])
            j += 3

        self.page = 0
        mid_width, mid_height = self.renderer.display_width / 2, self.renderer.display_height / 2
        self.firstx, self.firsty = mid_width, mid_height
        self.secondx, self.secondy = mid_width, mid_height + 30
        self.thirdx, self.thirdy = mid_width, mid_height + 60
        self.cursor_rect.midtop = (self.firstx + self.offset, self.firsty)
예제 #24
0
    def __init__(self, menu_type, options, char=None):
        '''BattleMenu class constructor.

        args:
            menu_type: str; type of the menu (main, skill, magic or item)
            options: lst; options to choose from; used to create the menu buttons
            char: Character object; needed for creating item buttons
        '''
        gutter = SCREEN_W // 64
        w = SCREEN_W // 3 - gutter
        h = SCREEN_H // 4

        self.menu_type = menu_type

        Menu.__init__(self, options, gutter, w, h)

        self._cursor_pos = []
        self._create_bm_buttons(options, char)
        if self._cursor_pos:
            self._cursor = MenuCursor()
            self._cursor_current = self._cursor_pos[0]
        else:
            self._cursor = False
            self._cursor_current = None
예제 #25
0
파일: console.py 프로젝트: RaulPele/LAB4-6
def run():
    """
    Functia principala care ruleaza programul
    """

    complexOp = ComplexOperations()
    create_menus()

    while True:

        if Menu.get_stack_size() == 0:
            return

        display_menu()
        op = read_option(len(complexOp.get_complexList()))
        manage_option(complexOp, op)
예제 #26
0
파일: index.py 프로젝트: qusba/Clicker-peli
def main():
    """Main function of the game. Creates all the classes that GameLoop-class needs to run
    the game, and then starts the game by calling gameloop.start().
    """
    display = pygame.display.set_mode((1024, 640))
    pygame.display.set_caption("Clicker")
    pygame.font.init()
    colors = Colors()
    event_queue = EventQueue()
    startview = StartView(display, colors)
    menu = Menu(display, colors)
    logic = GameLogic()
    shop = Shop(display, colors, logic)
    save = SaveGame(logic)
    game_loop = GameLoop(logic, display, colors, startview, event_queue, menu,
                         shop, save)
    pygame.init()
    game_loop.start()
예제 #27
0
파일: main.py 프로젝트: rduerig/cardquiz
    def init(cls):
        # set font config
        cls.fontconfig = Config.font_vars["large"]

        cls.parser = Parser()
        cls.parser.parse("questions.json")
        pygame.init()
        cls.screen = pygame.display.set_mode(
            (Config.display_width, Config.display_height))

        # display cards
        cls.screen.fill(Config.niceblue)
        cls.font = pygame.font.Font(Config.font_setting[0], cls.fontconfig[0])
        pools = cls.parser.get_pools()

        cls.cardboard = Cardboard(cls.switch_menu)
        cls.menu = Menu(cls.screen, Config.font_setting[0], pools,
                        cls.switch_cardboard)
        pygame.display.flip()

        cls.main()
예제 #28
0
    def getNextOption(self, op):
        """
        Executa urmatoarea actiune in functie de alegerea op a utilizatorului
        navigand prin meniu sau apeland functia corespunzatoare
        :param op: optiunea utilizatorului - string
        """
        if Menu.userExits(op):
            Menu.navigateBackwards()
            return
        currentMenu = Menu.getCurrentMenu()

        if op in currentMenu.getSubMenus().keys():
            Menu.navigateToSubmenu(op)
            return

        function = currentMenu.getFunction(op)
        function()
예제 #29
0
파일: console.py 프로젝트: RaulPele/LAB4-6
def get_next_action(complexOp, op):
    """
    Preia optiunea de la utilizator si apeleaza functia corespunzatoare sau navigheaza in submeniul
    corespunzator
    :param complexOp: obiect ComplexOperations
    """
    currentMenu = Menu.get_currentMenu()

    if Menu.user_exits(op):
        Menu.navigate_backwards()
        return

    currentSubMenus = currentMenu.get_subMenus()

    if currentSubMenus is not None:
        if op in currentSubMenus.keys():
            # navigate to submenu
            Menu.navigate_to_submenu(op)
            return

    callFunction(complexOp, op)
예제 #30
0
        pygame.mixer.music.load(enums.RES + "music/chee-zee-jungle.ogg")
        pygame.mixer.music.play(-1)
        global c
        c = Robot((image.load(enums.RES + "monkey.png")))
        if argv[2] == "buttons":
            buttons = [ImageButton(enums.RES + 'ok_button.png', (300, 200), test),
                       TextButton("Start", (300, 100), (0, 0, 0), callback=test)]

            for btn in buttons:
                btn.draw(enums.SCREEN)
        elif argv[2] == "menu":
            buttons = False
            mn1 = Menu(("Amazing Cool Game!", (250, 200)),
                       ("Start", "Options", "Quit"),
                       ((310, 300),
                        (310, 340),
                        (310, 380)),
                       (start_game, open_options, quit_game),
                       bg_img=enums.RES + "main_menu.png")
            mn1.draw(enums.SCREEN)

    if argv[1] == "scan":
        btn = TextButton("Print Grid",
                         (100, 200),
                         (255, 0, 0),
                         callback=print_grid)
        btn2 = TextButton("Print Grid Length",
                          (200, 200),
                          (255, 0, 0),
                          callback=print_grid_len)
        btn2.draw(enums.SCREEN)
예제 #31
0
파일: console.py 프로젝트: RaulPele/LAB4-6
def isOption(op):
    currentMenu = Menu.get_currentMenu()
    options = list(currentMenu.get_menuItems().keys())
    if op not in options:
        return False
    return True