コード例 #1
0
def handle_events():
    global exit_button
    global exit_indicator
    global menu
    global host_match_button
    global loaded
    
    if not loaded:
        load()
    
    menu.handle_events()
    
    if pygame.MOUSEBUTTONDOWN in wotsuievents.event_types:
        if exit_button.contains(wotsuievents.mouse_pos):
            exit_indicator = True
            exit_button.color = button.Button._SlctdColor
            exit_button.symbol.color = button.Button._SlctdColor
    elif pygame.MOUSEBUTTONUP in wotsuievents.event_types:
        if exit_indicator == True:
            exit_indicator = False
            exit_button.color = button.Button._InactiveColor
            exit_button.symbol.color = button.Button._InactiveColor
            
            if exit_button.contains(wotsuievents.mouse_pos):
                unload()
                gamestate.mode = gamestate.Modes.MAINMENU
        
    if gamestate.mode == gamestate.Modes.ONLINEVERSUSMOVESETSELECTLOADER:
        if host_match_button.contains(wotsuievents.mouse_pos):
            gamestate.hosting = True
            onlineversusmovesetselectloader.load(versusserver.get_lan_ip_address())
        
    elif loaded:
        exit_button.draw(gamestate.screen)
        menu.draw(gamestate.screen)
コード例 #2
0
def handle_events():
    global exit_button
    global exit_indicator
    global connect_button
    global loaded
    global server_address_input
    global server_list
    global server_finder

    if not loaded:
        load()
    else:
        while server_finder.Receive():
            pass

        server_address_input.handle_events()
        server_list.handle_events()
        exit_button.draw(gamestate.screen)
        connect_button.draw(gamestate.screen)
        server_address_input.draw(gamestate.screen)
        server_list.draw(gamestate.screen)

        if server_list.selected_row != None:
            server_address_input.set_text(server_list.selected_row.get_address())

        if re.match(VALID_IPV4_ADDRESS_REGEX, server_address_input.get_input()) and connect_button.active == False:
            connect_button.activate()
        elif not re.match(VALID_IPV4_ADDRESS_REGEX, server_address_input.get_input()) and connect_button.active:
            connect_button.inactivate()

        if pygame.MOUSEBUTTONDOWN in wotsuievents.event_types:
            if exit_button.contains(wotsuievents.mouse_pos):
                exit_indicator = True
                exit_button.color = button.Button._SlctdColor
                exit_button.symbol.color = button.Button._SlctdColor

            if connect_button.contains(wotsuievents.mouse_pos) and connect_button.active:
                connect_button.handle_selected()

        elif pygame.MOUSEBUTTONUP in wotsuievents.event_types:
            if exit_indicator == True:
                exit_indicator = False
                exit_button.color = button.Button._InactiveColor
                exit_button.symbol.color = button.Button._InactiveColor

                if exit_button.contains(wotsuievents.mouse_pos):
                    unload()
                    gamestate.mode = gamestate.Modes.ONLINEMENUPAGE

            elif connect_button.contains(wotsuievents.mouse_pos) and connect_button.selected:
                connect_button.handle_selected()

                unload()
                gamestate.mode = gamestate.Modes.ONLINEVERSUSMOVESETSELECTLOADER
                onlineversusmovesetselectloader.load(versusserver.get_lan_ip_address())