Пример #1
0
def open_menu(window_width, window_height):
    pymenu_font = pygameMenu.font.FONT_OPEN_SANS
    menu = pygameMenu.Menu(screen,
                           bgfun=do_nothing,
                           window_width=width,
                           window_height=height,
                           menu_width=int(window_width),
                           menu_height=int(window_height),
                           font=pymenu_font,
                           font_size=23,
                           font_size_title=27,
                           font_color=SILVER,
                           color_selected=DARK_RED,
                           menu_alpha=100,
                           menu_color_title=DARK_RED,
                           menu_color=GOLD,
                           onclose=pygameMenu.events.CLOSE,
                           title='Main Menu',
                           widget_alignment=pygameMenu.locals.ALIGN_CENTER,
                           option_margin=19,
                           title_offsetx=4,
                           title_offsety=4)
    menu.add_selector('Options :', [('None', 0), ('Lagrange Interpolation', 1),
                                    ('Bezier Curves', 2),
                                    ('Cubic Hermite Interpolation', 3),
                                    ('Cubic Spline Interpolation', 4)],
                      onchange=set_curve)
    menu.add_button('Select', select_option)
    menu.add_button('Quit', pygameMenu.events.EXIT)
    return menu
Пример #2
0
    def __init__(self, window, config, fps):
        self.window = window
        self.config = config
        self._main_menu = None

        width = self.window.get_rect().width
        height = self.window.get_rect().height

        self._main_menu = pgm.Menu(
            self.window.surface,
            width,
            height,
            fonts.get_filename("Amatic-Bold"),
            'Settings',
            draw_region_y=55,
            font_color=(38, 139, 210),
            color_selected=(42, 161, 152),
            menu_color=(253, 246, 227),
            menu_color_title=(238, 232, 213),
            enabled=False,
            onclose=self._on_close,
            dopause=False,
        )

        for name in ('GENERAL', 'WINDOW', 'PICTURE', 'PRINTER'):
            submenu = self._build_submenu(name, width, height)
            self._main_menu.add_option(submenu.get_title(), submenu)
        self._main_menu.add_option('Exit Pibooth', pgmevt.EXIT)

        self._main_menu.set_fps(fps)
Пример #3
0
def main(test=False):
    global set_fullscreen
    global set_language
    global set_music
    global main_menu
    pygame.display.set_caption(CAPTION)
    clock = pygame.time.Clock()
    set_language, set_fullscreen, set_music = load_stored_settings()
    main_menu = pygameMenu.Menu(
        surface,  # main menu
        bgfun=main_background,
        color_selected=COLOR_YELLOW,
        font=font_type,
        font_color=COLOR_BLACK,
        font_size=14,
        font_size_title=35,
        menu_alpha=100,
        menu_color=COLOR_GRAY,
        menu_height=1,
        menu_width=int(WINDOW_SIZE[0]),
        onclose=pygameMenu.events.EXIT,
        option_shadow=False,
        title=TITLE + ":",
        menu_color_title=COLOR_ORANGE,
        window_height=1,
        window_width=WINDOW_SIZE[0])
    main_menu.set_sound(sound, recursive=True)  # set menu sounds
    while True:
        clock.tick(FPS)
        main_menu.mainloop(disable_loop=test)
        pygame.display.flip()
        if test == True:
            break
Пример #4
0
    def on_start(self, win):
        self.win = win
        if self.menu:
            self.menu.enable()
        else:
            self.menu = pygameMenu.Menu(win,
                                        self.width,
                                        self.height,
                                        back_box=False,
                                        menu_width=800,
                                        menu_height=640,
                                        draw_select=True,
                                        option_margin=50,
                                        bgfun=self.draw_background,
                                        font=self.font,
                                        title="Main Menu",
                                        dopause=True)
            self.menu.set_fps(60, True)

            self.menu.add_option("Start Game", self.on_start_game)
            self.menu.add_selector("Algorithm", [("Backtracking", 0),
                                                 ("Exact Cover", 1)],
                                   selector_id="selector_solver",
                                   default=0,
                                   onchange=self.on_change_solver)
            self.menu.add_selector("Difficulty",
                                   [("Easy", Difficulty.EASY),
                                    ("Normal", Difficulty.NORMAL),
                                    ("Hard", Difficulty.HARD),
                                    ("Very Hard", Difficulty.VERY_HARD)],
                                   selector_id="selector_level",
                                   default=0,
                                   onchange=self.on_change_level)
            self.menu.add_option("Exit", pygameMenu.events.EXIT)
Пример #5
0
    def __init__(self, game):
        self.game = game
        self.walls = Group()
        self.bullets = Group()
        self.zombies = Group()
        self.adventurers = Group()

        self.finish = False

        self.adventures_menu = pygameMenu.Menu(game.screen,
                                               WIDTH,
                                               HEIGHT,
                                               'assets/fonts/blocks.ttf',
                                               "Adventures",
                                               dopause=False)
        self._close_menu()

        self._create_list_adventures()

        self.map = TiledMap('assets/maps/home.tmx')
        self.map_image = self.map.make_map()
        self.map_rect = self.map_image.get_rect()

        for tile_object in self.map.tiled_map.objects:
            if tile_object.name == 'wall':
                self._create_obstacle(tile_object, self.walls)
            elif tile_object.name == 'adventurer':
                self.adventurer = self._create_adventurer(game, tile_object)
            elif tile_object.name == 'ranking':
                self._create_ranker(tile_object)
            elif tile_object.name == 'player':
                self._create_player(tile_object)
Пример #6
0
def pause_menu():
    pause_menu = pygameMenu.Menu(surface,
                                 bgfun=no,
                                 back_box=False,
                                 color_selected=DARKRED,
                                 font=pygameMenu.font.FONT_BEBAS,
                                 font_color=COLOR_BLACK,
                                 font_size=30,
                                 menu_alpha=100,
                                 menu_color_title=MENU_BACKGROUND_COLOR,
                                 menu_color=COLOR_WHITE,
                                 menu_height=int(WINDOW_SIZE[1] * 0.5),
                                 menu_width=int(WINDOW_SIZE[0] * 0.5),
                                 onclose=pygameMenu.events.DISABLE_CLOSE,
                                 option_shadow=False,
                                 title='Paused',
                                 window_height=WINDOW_SIZE[1],
                                 window_width=WINDOW_SIZE[0])
    pause_menu.add_button(
        'Resume',  # When pressing return -> play(mode[0], font)
        unpause,
        pause_menu)
    pause_menu.add_button('Quit', run_menu)

    global paused
    while paused:
        # Tick
        clock.tick(FPS)

        # Main menu
        pause_menu.mainloop()

        # Flip surface
        pygame.display.flip()
Пример #7
0
    def init_move_menu(self, screen, directions):
        H_SIZE = 600
        W_SIZE = 600
        screen_width, screen_height = screen.get_size()
        formatted_directions = []
        for direction in directions:
            formatted_directions.append((direction, direction))

        self.move_menu = pygameMenu.Menu(
            screen,
            dopause=False,
            enabled=False,
            font=pygameMenu.fonts.FONT_NEVIS,
            menu_alpha=85,
            menu_color=(0, 0, 0),  # Background color
            menu_color_title=(0, 0, 255),
            menu_height=int(H_SIZE / 2),
            menu_width=W_SIZE,
            onclose=pygameMenu.locals.PYGAME_MENU_CLOSE,
            # If this menu closes (press ESC) back to main
            title='Move',
            title_offsety=10,  # Adds 5px to title vertical position
            window_height=screen_height,
            window_width=screen_width)

        self.move_menu.add_selector('Move to?',
                                    formatted_directions,
                                    onchange=self.update_move_direction,
                                    onreturn=self.update_move_direction,
                                    default=1)
        self.move_menu.add_option('Done', self.movement_chosen)
        self.move_menu.add_option('Cancel',
                                  pygameMenu.locals.PYGAME_MENU_CLOSE)
        self.menu_list.append(self.move_menu)
Пример #8
0
def gameover():
    gameover = True
    while gameover:
        gameover_menu = pygameMenu.Menu(screen,
                                        bgfun=main_background,
                                        color_selected=white,
                                        font=pygameMenu.fonts.FONT_XEN_GALAXIE,
                                        font_color=black,
                                        font_size=40,
                                        menu_alpha=100,
                                        menu_color=MENU_BACKGROUND_COLOR,
                                        menu_height=int(WINDOW_SIZE[1]),
                                        menu_width=int(WINDOW_SIZE[0]),
                                        onclose=PYGAME_MENU_DISABLE_CLOSE,
                                        option_shadow=False,
                                        title='GAMEOVER',
                                        window_height=WINDOW_SIZE[1],
                                        window_width=WINDOW_SIZE[0])
        gameover_menu.add_option('Quitter', PYGAME_MENU_EXIT)
        events = pygame.event.get()
        for event in events:
            if event.type == QUIT:
                paused = False
                exit()
        gameover_menu.mainloop(events)
        pygame.display.flip()
        pygame.display.update()
        clock.tick(5)
Пример #9
0
    def __init__(self, window, config, fps, version):
        self.window = window
        self.config = config
        self._main_menu = None

        width = self.window.get_rect().width
        height = self.window.get_rect().height

        self._main_menu = pgm.Menu(self.window.surface,
                                   width,
                                   height,
                                   fonts.get_filename("Amatic-Bold"),
                                   "Pibooth v{} - Settings".format(version),
                                   draw_region_y=55,
                                   font_color=(255, 255, 255),
                                   font_title = fonts.get_filename("Amatic-Bold"),
                                   color_selected=(38, 139, 210),
                                   menu_color=(0, 0, 51),
                                   menu_color_title=(90, 90, 140),
                                   enabled=False,
                                   onclose=self._on_close,
                                   dopause=False,
                                   )

        for name in ('GENERAL', 'WINDOW', 'PICTURE', 'PRINTER', 'SERVER'):
            submenu = self._build_submenu(name, width, height)
            self._main_menu.add_option(submenu.get_title(), submenu)

        exitmenu = self._build_exitmenu('Exit', width, height)
        self._main_menu.add_option(exitmenu.get_title(), exitmenu)

        self._main_menu.set_fps(fps)
Пример #10
0
def create_menu(title, bgfun, alpha):
    return pygameMenu.Menu(game_screen, bgfun=bgfun, color_selected=COLOR_SELECTED, font=pygameMenu.fonts.FONT_BEBAS,
                           font_color=COLOR_BLACK, font_size=60, menu_alpha=alpha, menu_color=MENU_BACKGROUND_COLOR,
                           menu_color_title=COLOR_SELECTED, menu_height=int(SCREEN_RESOLUTION[1] * 0.6),
                           menu_width=int(SCREEN_RESOLUTION[0] * 0.6), onclose=PYGAME_MENU_DISABLE_CLOSE,
                           option_shadow=False, title=title, window_height=SCREEN_RESOLUTION[1],
                           window_width=SCREEN_RESOLUTION[0], draw_select=False)
Пример #11
0
    def __init__(self, surface, clock, start_game_function):
        self._surface = surface
        self._clock = clock

        path = harmonize_path(
            os.path.join(os.path.dirname(__file__),
                         "../resources/sprites/cropped_floor.png"))
        self._background_image = pygame.image.load(path).convert()

        self.main_menu = pygameMenu.Menu(
            self._surface,
            bgfun=self.bg_func,
            color_selected=Menu.WHITE,  # ausgewähltes Menüelement
            font="resources/fonts/VCR_OSD_MONO_1.001.ttf",
            # pygameMenu.font.FONT_BEBAS,
            font_color=Menu.WHITE,
            font_size=50,
            menu_alpha=100,
            menu_color=Menu.BG_COLOR,
            menu_color_title=Menu.BG_TITLE_COLOR,
            menu_height=int(WINDOW_SIZE[1] * 0.8),
            menu_width=int(WINDOW_SIZE[0] * 0.9),
            onclose=pygameMenu.events.DISABLE_CLOSE,
            option_shadow=False,
            title='GREEDY ROYALS',
            window_height=WINDOW_SIZE[1],
            window_width=WINDOW_SIZE[0])

        self.highscore_menu = pygameMenu.TextMenu(
            self._surface,
            bgfun=self.bg_func,
            font="resources/fonts/VCR_OSD_MONO_1.001.ttf",
            font_color=Menu.WHITE,
            font_size=50,
            menu_alpha=100,
            menu_color=Menu.BG_COLOR,
            menu_color_title=Menu.BG_TITLE_COLOR,
            menu_width=int(WINDOW_SIZE[0] * 0.8),
            menu_height=int(WINDOW_SIZE[1] * 0.8),
            title="Highscore",
            option_shadow=False,
            window_height=WINDOW_SIZE[1],
            window_width=WINDOW_SIZE[0],
            # TextMenu specific parameters
            draw_text_region_x=TEXT_DRAW_X,
            text_align=pygameMenu.locals.ALIGN_CENTER,
            text_color=Menu.BG_TITLE_COLOR,
            text_fontsize=20,
            text_margin=TEXT_MARGIN,
        )

        # create DB if necessary and fill highscore list
        Highscore.create_db()
        self.fill_highscore_list()

        self.main_menu.add_option('Play', start_game_function)
        # main_menu.add_option('About', about_menu)
        self.main_menu.add_option('Highscore', self.highscore_menu)
        self.main_menu.add_option('Quit', pygameMenu.events.EXIT)
Пример #12
0
def menu_func():
    return pygameMenu.Menu(screen,
                           window_width=glob.WINDOW_SIZE[0] - 600,
                           window_height=glob.WINDOW_SIZE[1] - 100,
                           font=pygameMenu.font.FONT_FRANCHISE,
                           title='STAR WARS MENU',
                           bgfun=main_background,
                           menu_width=glob.MENU_SIZE[0],
                           menu_height=glob.MENU_SIZE[1])
Пример #13
0
    def initMenu(self):
        """"create generic menu for in game    """

        gameDisplay = pygame.display.set_mode((800, 600))

        stillOn = True

        clock = pygame.time.Clock()

        def close_fun():
            print(main_menu.is_disabled())
            main_menu.disable()
            print(main_menu.is_disabled())

        def mainmenu_background():
            """Background color of the main menu, on this function user can plot
                images, play sounds, etc."""
            gameDisplay.fill((40, 0, 40))

        main_menu = pygameMenu.Menu(gameDisplay,
                                    bgfun=mainmenu_background,
                                    color_selected=COLOR_WHITE,
                                    font=pygameMenu.fonts.FONT_BEBAS,
                                    font_color=COLOR_BLACK,
                                    font_size=30,
                                    menu_alpha=100,
                                    menu_color=(40, 0, 40),
                                    menu_height=600,
                                    menu_width=800,
                                    onclose=mainmenu_background,
                                    option_shadow=False,
                                    title='RPmG',
                                    window_height=600,
                                    window_width=800)
        print('inside the game init menu')

        main_menu.add_option('Save the Game', self.saveGame)
        main_menu.add_option('Close: Pressasdfg esc', PYGAME_MENU_CLOSE)

        looping = True
        while looping:

            # Tick
            clock.tick(60)

            # Application events
            events = pygame.event.get()
            for event in events:
                if event.type == QUIT:
                    exit()

            # Main menu
            main_menu.mainloop(events)
            looping = False

            # Flip surface
            pygame.display.flip()
Пример #14
0
def main_menu():
    """ Function for Main Menu """

    # initialize
    pygame.init()

    # set for title my game
    pygame.display.set_caption("Advanture of Gimo")
    # hide mouse cursor
    pygame.mouse.set_visible(False)

    # set clock
    clock = pygame.time.Clock()

    # stop the background music
    pygame.mixer.stop()

    # Core Menu
    main_menu = pygameMenu.Menu(configscreen.screen,
                                bgfun=main_background,
                                color_selected=constants.WHITE,
                                font=pygameMenu.fonts.FONT_8BIT,
                                font_size=30,
                                font_size_title=30,
                                menu_alpha=100,
                                menu_color=constants.DARK_BROWN_DIRT,
                                menu_height=int(constants.SCREEN_HEIGHT * 0.6),
                                menu_width=int(constants.SCREEN_WIDTH * 0.6),
                                onclose=PYGAME_MENU_DISABLE_CLOSE,
                                option_shadow=False,
                                title='Main Menu',
                                window_height=constants.SCREEN_HEIGHT,
                                window_width=constants.SCREEN_WIDTH)

    main_menu.add_option('Play', play_menu)
    main_menu.add_option('How To Play', platform_scroller_tutorial.gameplay)
    main_menu.add_option('Option', option_menu)
    main_menu.add_option('About', about_menu)
    main_menu.add_option('Exit', confirm_exit)

    while True:

        # Tick
        clock.tick(60)

        # Application events
        events = pygame.event.get()
        for event in events:
            if event.type == QUIT:
                exit()

        # Main menu
        main_menu.mainloop(events)

        # Flip surface
        pygame.display.flip()
Пример #15
0
def multi_menu():
    multiplayer_menu = pygameMenu.Menu(window,
                                       settings.WINDOW_WIDTH,
                                       settings.WINDOW_HEIGHT,
                                       pygameMenu.fonts.FONT_8BIT,
                                       "Multiplayer",
                                       bgfun=main_background,
                                       menu_alpha=20)
    multiplayer_menu.add_option("Connect", start_multi)
    multiplayer_menu.add_option("Back to main menu", PYGAME_MENU_BACK)
    return multiplayer_menu
Пример #16
0
def server_menu():
    serv_menu = pygameMenu.Menu(window,
                                settings.WINDOW_WIDTH,
                                settings.WINDOW_HEIGHT,
                                pygameMenu.fonts.FONT_8BIT,
                                "Server menu",
                                bgfun=main_background,
                                menu_alpha=20)
    serv_menu.add_option("Host server", start_server)
    serv_menu.add_option("Back to main menu", PYGAME_MENU_BACK)
    return serv_menu
Пример #17
0
def select_level_katakana_display2():
    """ Function for Select level in katakana mode"""
    clock = pygame.time.Clock()

    select_level_katakana_page2 = pygameMenu.Menu(
        configscreen.screen,
        bgfun=main_background,
        color_selected=constants.WHITE,
        font=pygameMenu.fonts.FONT_8BIT,
        font_size=25,
        font_size_title=30,
        menu_alpha=100,
        menu_color=constants.DARK_BROWN_DIRT,
        menu_height=int(constants.SCREEN_HEIGHT * 0.6),
        menu_width=int(constants.SCREEN_WIDTH * 0.6),
        onclose=PYGAME_MENU_DISABLE_CLOSE,
        option_shadow=False,
        title='Select Levels',
        window_height=constants.SCREEN_HEIGHT,
        window_width=constants.SCREEN_WIDTH)

    # LEVEL PAGE 2
    select_level_katakana_page2.add_option('Level 05',
                                           play_katakana_level_5.gameplay)
    select_level_katakana_page2.add_option('Level 06',
                                           play_katakana_level_6.gameplay)
    select_level_katakana_page2.add_option('Level 07',
                                           play_katakana_level_7.gameplay)
    select_level_katakana_page2.add_option('Level 08',
                                           play_katakana_level_8.gameplay)
    select_level_katakana_page2.add_option('Level 09',
                                           play_katakana_level_9.gameplay)
    select_level_katakana_page2.add_option('Next',
                                           select_level_katakana_display3)
    select_level_katakana_page2.add_option('Back',
                                           select_level_katakana_display1)

    while True:

        # Tick
        clock.tick(60)

        # Application events
        events = pygame.event.get()
        for event in events:
            if event.type == QUIT:
                exit()

        # Main menu
        select_level_katakana_page2.mainloop(events)

        # Flip surface
        pygame.display.flip()
Пример #18
0
def select_level_hiragana_display1():
    """ Function for Select level in hiragana mode"""
    clock = pygame.time.Clock()

    # Display Menu
    select_level_hiragana_page1 = pygameMenu.Menu(
        configscreen.screen,
        bgfun=main_background,
        color_selected=constants.WHITE,
        font=pygameMenu.fonts.FONT_8BIT,
        font_size=25,
        font_size_title=30,
        menu_alpha=100,
        menu_color=constants.DARK_BROWN_DIRT,
        menu_height=int(constants.SCREEN_HEIGHT * 0.6),
        menu_width=int(constants.SCREEN_WIDTH * 0.6),
        onclose=PYGAME_MENU_DISABLE_CLOSE,
        option_shadow=False,
        title='Select Levels',
        window_height=constants.SCREEN_HEIGHT,
        window_width=constants.SCREEN_WIDTH)
    # LEVEL PAGE 1
    select_level_hiragana_page1.add_option('Play All Levels',
                                           platform_scroller_hiragana.gameplay)
    select_level_hiragana_page1.add_option('Level 01 ',
                                           play_hiragana_level_1.gameplay)
    select_level_hiragana_page1.add_option('Level 02',
                                           play_hiragana_level_2.gameplay)
    select_level_hiragana_page1.add_option('Level 03',
                                           play_hiragana_level_3.gameplay)
    select_level_hiragana_page1.add_option('Level 04',
                                           play_hiragana_level_4.gameplay)
    select_level_hiragana_page1.add_option('Next',
                                           select_level_hiragana_display2)
    select_level_hiragana_page1.add_option('Back', play_menu)

    while True:

        # Tick
        clock.tick(60)

        # Application events
        events = pygame.event.get()
        for event in events:
            if event.type == QUIT:
                exit()

        # Main menu
        select_level_hiragana_page1.mainloop(events)

        # Flip surface
        pygame.display.flip()
Пример #19
0
    def _build_submenu(self, section, width, height):
        """Build sub-menu"""
        menu = pgm.Menu(
            self.window.surface,
            width,
            height,
            fonts.get_filename("Amatic-Bold"),
            section.capitalize(),
            font_size=30,
            font_color=(255, 255, 255),
            font_title=fonts.get_filename("Amatic-Bold"),
            color_selected=(38, 139, 100),
            menu_color=(0, 0, 51),
            menu_color_title=(60, 90, 140),
            dopause=False,
        )

        for name, option in DEFAULT[section].items():
            if option[2]:
                if isinstance(option[3], str):
                    menu.add_text_input(
                        option[2],
                        cursor_color=(255, 255, 255),
                        onchange=self._on_text_changed,
                        default=self.config.get(section, name).strip('"'),
                        # Additional parameters:
                        section=section,
                        option=name)
                elif isinstance(option[3], (list, tuple)) and len(option[3]) == 3\
                        and all(isinstance(i, int) for i in option[3]):
                    menu.add_color_input(option[2],
                                         "rgb",
                                         cursor_color=(255, 255, 255),
                                         default=self.config.gettyped(
                                             section, name),
                                         input_separator=',',
                                         onchange=self._on_color_changed,
                                         previsualization_width=3,
                                         section=section,
                                         option=name)
                else:
                    values = [(v, ) for v in option[3]]
                    menu.add_selector(
                        option[2],
                        values,
                        onchange=self._on_selector_changed,
                        default=_find(values, self.config.get(section, name)),
                        # Additional parameters:
                        section=section,
                        option=name)

        return menu
Пример #20
0
def update_menu():
    update_m = pygameMenu.Menu(
        surface,  # main menu menu
        bgfun=settings_background,
        color_selected=COLOR_YELLOW,
        font=font_type_bold,
        font_color=COLOR_WHITE,
        font_size=16,
        font_size_title=28,
        menu_alpha=100,
        menu_color=COLOR_BLACK,
        menu_height=40,
        menu_width=int(WINDOW_SIZE[0]),
        onclose=pygameMenu.events.EXIT,
        option_shadow=False,
        title="",
        menu_color_title=COLOR_ORANGE,
        widget_alignment=pygameMenu.locals.ALIGN_LEFT,
        window_height=40,
        window_width=WINDOW_SIZE[0])
    topA = "data/images/topA.png"
    topB = "data/images/topB.png"
    top_menu_A = pygame.image.load(topA)  # load game top front A
    top_menu_B = pygame.image.load(topB)  # load game top front B (exit)
    surface.blit(
        top_menu_A,
        (WINDOW_SIZE[0] - 1025, WINDOW_SIZE[1] - 770))  # load top main image
    surface.blit(
        top_menu_B,
        (WINDOW_SIZE[0] - 25, WINDOW_SIZE[1] - 769))  # load top exit image
    update_rect = pygame.draw.rect(
        surface, COLOR_BLACK,
        (WINDOW_SIZE[0] / 9 + 95, WINDOW_SIZE[1] / 2 - 100, 600,
         400))  # update back box
    if set_language == "0":  # English
        f = open(updates_EN_path, "r")
    else:  # Spanish
        f = open(updates_ES_path, "r")
    updates = f.readlines()
    f.close()
    l = 0
    for line in updates:
        l = l + 35  # used to create spaces between lines
        line = line.replace("\n", "")
        display_text_animation(update_rect, line, l)
        for event in pygame.event.get():
            if event.type == 5:  # "5" = click DOWN event
                main()  # whatever click goes to main menu
    l = 150
    r = 9
    create_counter(10)  # create visual ETA counter for return to main menu
Пример #21
0
def login(surface, WINDOW_SIZE, set_language, current_machine):
    global login_menu
    global login_surface
    global WINDOW
    global LANGUAGE
    global NETWORK_MACHINE_NUMBER
    NETWORK_MACHINE_NUMBER = current_machine
    WINDOW = WINDOW_SIZE
    LANGUAGE = set_language
    login_surface = surface
    pygame.draw.rect(surface, COLOR_BLACK,
                     (WINDOW_SIZE[1] / 10 - 75, WINDOW_SIZE[1] / 2 - 165,
                      WINDOW_SIZE[0], 150))  # used to hide login returned msg
    TRANS_SERVICE, TRANS_USERNAME, TRANS_PASSWORD, TRANS_ACCESS, GUEST_ACCESS_GRANTED, DENIED_ACCESS = load_level0_translations(
        set_language)
    USERNAME = extract_username()
    if not NETWORK_MACHINE_NUMBER:
        NETWORK_MACHINE_NUMBER = random.randrange(
            1111, 9999
        )  # generate random proxy number (between proxy reserved directions)
    login_menu = pygameMenu.Menu(
        surface,  # level 0: "login" menu
        bgfun=data.menu.level0_login_background,
        color_selected=COLOR_YELLOW,
        font=font_type,
        font_color=COLOR_WHITE,
        font_size=18,
        font_size_title=35,
        menu_alpha=100,
        menu_color=COLOR_BLACK,
        menu_height=220,
        menu_width=int(WINDOW_SIZE[0]),
        onclose=data.menu.main,  # back to main menu
        option_shadow=False,
        title="[" + str(NETWORK_DOMAIN) + "]>[MAC:" +
        str(NETWORK_MACHINE_NUMBER) + "]>",
        menu_color_title=COLOR_GREEN,
        widget_alignment=pygameMenu.locals.ALIGN_LEFT,
        window_height=220,
        window_width=int(WINDOW_SIZE[0]))
    login_menu.add_selector('* ' + str(TRANS_SERVICE), [('SSH', 'SSH'),
                                                        ('WEB', 'WEB')],
                            selector_id='service',
                            onchange=update_menu_service,
                            default=1)
    if login_menu.get_widget("user_name"):
        login_menu.get_widget("user_name").clear()
    if login_menu.get_widget("user_password"):
        login_menu.get_widget("user_password").clear()
    while True:
        login_menu.mainloop()
Пример #22
0
 def _create_menu(self, title):
     return pygameMenu.Menu(
         self.window,
         self.window_width,
         self.window_height,
         flatpakmanager_steamos.config.font,
         self.title,
         dopause=False,
         menu_width=self.window_width,
         menu_height=self.window_height,
         menu_color=flatpakmanager_steamos.color.background,
         menu_color_title=flatpakmanager_steamos.color.title,
         color_selected=flatpakmanager_steamos.color.selected,
         menu_alpha=100)
Пример #23
0
    def init_suspect_menu(self, screen, initiator, responder, cards):
        screen_width, screen_height = screen.get_size()
        text_menu = pygameMenu.TextMenu(
            screen,
            dopause=False,
            font=pygameMenu.fonts.FONT_FRANCHISE,
            menu_color=(30, 50, 107),  # Background color
            menu_color_title=(120, 45, 30),
            menu_width=600,
            menu_height=300,
            onclose=pygameMenu.locals.
            PYGAME_MENU_CLOSE,  # Pressing ESC button does nothing
            title='Suspection',
            window_height=screen_height,
            window_width=screen_width)
        text_menu.add_line(responder.upper())
        line_1 = "The player " + initiator.upper(
        ) + " has accused " + self.who_accusation.upper() + " of the"
        line_2 = "murder in the " + self.where_accusation.upper(
        ) + " with the " + self.what_accusation.upper()
        text_menu.add_line(line_1)
        text_menu.add_line(line_2)
        text_menu.add_option('Back', pygameMenu.locals.PYGAME_MENU_BACK)

        self.suspect_menu = pygameMenu.Menu(
            screen,
            dopause=False,
            enabled=False,
            font=pygameMenu.fonts.FONT_NEVIS,
            menu_alpha=85,
            menu_color=(0, 0, 0),  # Background color
            menu_color_title=(255, 0, 0),
            menu_height=400,
            menu_width=1200,
            onclose=pygameMenu.locals.PYGAME_MENU_CLOSE,
            # If this menu closes (press ESC) back to main
            title=responder.upper() + ': Suspection',
            title_offsety=5,  # Adds 5px to title vertical position
            window_height=screen_height,
            window_width=screen_width)
        self.suspect_menu.add_option('View Suspection', text_menu)
        self.suspect_menu.add_selector('Give card?',
                                       cards,
                                       onchange=self.update_card_given,
                                       onreturn=self.update_card_given,
                                       default=1)
        self.suspect_menu.add_option('Give', self.give_card)
        self.suspect_menu.add_option('Pass', self.pass_turn)
        self.menu_list.append(self.suspect_menu)
Пример #24
0
def create_menus():
    m = multi_menu()
    s = server_menu()
    main_menu = pygameMenu.Menu(window,
                                settings.WINDOW_WIDTH,
                                settings.WINDOW_HEIGHT,
                                pygameMenu.fonts.FONT_8BIT,
                                "Fortnite",
                                bgfun=main_background,
                                menu_alpha=20)
    main_menu.add_option("Singleplayer", start_single, levelGenerator)
    main_menu.add_option("Multiplayer", m)
    main_menu.add_option("Host server", s)
    main_menu.add_option("Exit", PYGAME_MENU_EXIT)
    return main_menu
Пример #25
0
    def render(self, win):
        # Main menu, pauses execution of the application
        self.menu = pygameMenu.Menu(self.screen,
                                    window_width=SCREEN_WIDTH,
                                    window_height=SCREEN_HEIGHT,
                                    font=pygameMenu.fonts.FONT_NEVIS,
                                    title='You ' + ("WIN" if win else "LOSE"),
                                    title_offsety=5,
                                    menu_alpha=90,
                                    enabled=True,
                                    bgfun=bg,
                                    onclose=PYGAME_MENU_CLOSE)

        self.menu.add_option('Start new game', self.context.restart)
        self.menu.add_option('Exit', PYGAME_MENU_EXIT)  # Add exit function

        self.menu.mainloop([self.events])
Пример #26
0
def show_menu():
    menu_text = "Your score: {0}".format(scoring.get_score())
    if scoring.get_score() > scoring.get_high_score():
        scoring.update_high_score()

    menu = pygameMenu.Menu(
        screen,
        WIDTH,
        HEIGHT,
        pygameMenu.fonts.FONT_NEVIS,
        "Crash! Score: {0}".format(scoring.get_score()),
        bgfun=mainmenu_background,
    )

    menu.add_option("Try Again", play_the_game)
    menu.add_option("Exit", PYGAME_MENU_EXIT)
    menu.mainloop(pygame.event.get())
Пример #27
0
def run_main_menu(app: App):
    menu = pygameMenu.Menu(
        app.screen,
        *app.conf.pixel_size.as_ints(),
        font=pygameMenu.fonts.FONT_8BIT,
        title='Bomber Monkey',
        dopause=False
    )
    menu.add_option('New game', app.new_game)
    menu.add_option('Exit', PYGAME_MENU_EXIT)

    while app.app_state == AppState.MAIN_MENU:
        events = pg.event.get()
        for event in events:
            if event.type == QUIT:
                exit()
        menu.mainloop(events)
        pg.display.flip()
Пример #28
0
    def generic_menu(title=''):
        """
        Generate a generic test menu.

        :param title: Menu title
        :type title: basestring
        :return: Menu
        :rtype: pygameMenu.Menu
        """
        return pygameMenu.Menu(surface,
                               dopause=False,
                               enabled=False,
                               font=pygameMenu.font.FONT_NEVIS,
                               fps=FPS,
                               menu_alpha=90,
                               title=title,
                               window_height=H_SIZE,
                               window_width=W_SIZE)
Пример #29
0
    def generic_menu(title='',
                     columns=1,
                     rows=None,
                     width=600,
                     height=400,
                     position_x=50,
                     position_y=50,
                     *args,
                     **kwargs):
        """
        Generate a generic test menu.

        :param title: Menu title
        :type title: basestring
        :param columns: Number of columns
        :type columns: int
        :param rows: Number of rows
        :type rows: int, NoneType
        :param width: Menu width (px)
        :type width: int
        :param height: Menu height (px)
        :type height: int
        :param position_x: X position of the menu
        :type position_x: int, float
        :param position_y: Y position of the menu
        :type position_y: int, float
        :param args: Additional args
        :param kwargs: Additional key parameters
        :type kwargs: dict
        :return: Menu
        :rtype: pygameMenu.Menu
        """
        return pygameMenu.Menu(columns=columns,
                               enabled=False,
                               font=pygameMenu.font.FONT_NEVIS,
                               menu_height=height,
                               menu_opacity=90,
                               menu_position_x=position_x,
                               menu_position_y=position_y,
                               menu_width=width,
                               rows=rows,
                               title=title,
                               *args,
                               **kwargs)
Пример #30
0
def show_game_over_tutorial():
    clock = pygame.time.Clock()
    # stop the background music
    pygame.mixer.stop()
    # play game over music
    configsounds.game_over_sfx.play()
    configsounds.game_over_sfx.set_volume(0.5)

    game_over_screen = pygameMenu.Menu(
        configscreen.screen,
        dopause=False,
        font=pygameMenu.fonts.FONT_8BIT,
        font_size_title=30,
        font_title=pygameMenu.fonts.FONT_8BIT,
        menu_color_title=constants.BLUE,
        onclose=PYGAME_MENU_DISABLE_CLOSE,
        title='Game Over',
        menu_height=int(constants.SCREEN_HEIGHT * 0.6),
        menu_width=int(
            constants.SCREEN_WIDTH * 0.6),
        window_height=constants.SCREEN_HEIGHT,
        window_width=constants.SCREEN_WIDTH
    )
    game_over_screen.add_option('Retry', platform_scroller_tutorial.gameplay)
    game_over_screen.add_option('Main Menu', mainmenu.main_menu)
    game_over_screen.add_option('Exit Game', PYGAME_MENU_EXIT)

    while True:

        # Tick
        clock.tick(60)

        # Application events
        events = pygame.event.get()
        for event in events:
            if event.type == QUIT:
                exit()

        # Main menu
        game_over_screen.mainloop(events)

        # Flip surface
        pygame.display.flip()