Exemple #1
0
def call_a_menu(menu,default_option,info,display,font,mainClock):
    menu.option=default_option
    title_image=pygame.image.load("data/title.png")
    while 1:
        mainClock.tick(30)
        Inputs.readkeys()#read all the actual keys
        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            pygame.quit()
            sys.exit()
        # Move the menu cursor if you press up or down    
        if Inputs.player_just_U[1]:
            menu.move_cursor(-1)
        if Inputs.player_just_D[1]:
            menu.move_cursor(1)
        # If you press A, check which option you're on!
        if Inputs.player_just_A[1]:
            option, text = menu.get_option()
            return option, text
        # If you press B, cancel 
        if Inputs.player_just_B[1]:
            return -1, ""
        
        # Get the surface from the NES game library
        screen = display.get_surface()
        screen.blit(title_image,(0,0))
        
        # Draw the menu boxes
        ren = font.render(info)
        screen.blit(ren, (8, 112))
        menu.draw(screen, (16, 128), background=(0, 0, 0), border=(255, 255, 255))
        # Update and draw the display
        display.update()
Exemple #2
0
def call_a_menu(menu, default_option, info, display, font, mainClock):
    menu.option = default_option
    title_image = pygame.image.load("data/title.png")
    while 1:
        mainClock.tick(30)
        Inputs.readkeys()  #read all the actual keys
        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            pygame.quit()
            sys.exit()
        # Move the menu cursor if you press up or down
        if Inputs.player_just_U[1]:
            menu.move_cursor(-1)
        if Inputs.player_just_D[1]:
            menu.move_cursor(1)
        # If you press A, check which option you're on!
        if Inputs.player_just_A[1]:
            option, text = menu.get_option()
            return option, text
        # If you press B, cancel
        if Inputs.player_just_B[1]:
            return -1, ""

        # Get the surface from the NES game library
        screen = display.get_surface()
        screen.blit(title_image, (0, 0))

        # Draw the menu boxes
        ren = font.render(info)
        screen.blit(ren, (8, 112))
        menu.draw(screen, (16, 128),
                  background=(0, 0, 0),
                  border=(255, 255, 255))
        # Update and draw the display
        display.update()
Exemple #3
0
def draw_team_info_text(screen,font,x):
    y=160
    x_scale=1
    y_gap=10
    color=(200,200,0)
    ren = font.render("speed")
    screen.blit(ren,(x+font.center_shift("speed"),y-4))
    y+=y_gap
    ren = font.render("resistance")
    screen.blit(ren,(x+font.center_shift("resistance"),y-4))
    y+=y_gap
    ren = font.render("control")
    screen.blit(ren,(x+font.center_shift("control"),y-4))
    y+=y_gap
    ren = font.render("kick")
    screen.blit(ren,(x+font.center_shift("kick"),y-4))
    y+=y_gap
    ren = font.render("punch")
    screen.blit(ren,(x+font.center_shift("punch"),y-4))
    y+=y_gap
    ren = font.render("precision")
    screen.blit(ren,(x+font.center_shift("precision"),y-4))
    y+=y_gap
    ren = font.render("listening")
    screen.blit(ren,(x+font.center_shift("listening"),y-4))
    y+=y_gap
Exemple #4
0
def draw_team_info_text(screen, font, x):
    y = 160
    x_scale = 1
    y_gap = 10
    color = (200, 200, 0)
    ren = font.render("speed")
    screen.blit(ren, (x + font.center_shift("speed"), y - 4))
    y += y_gap
    ren = font.render("resistance")
    screen.blit(ren, (x + font.center_shift("resistance"), y - 4))
    y += y_gap
    ren = font.render("control")
    screen.blit(ren, (x + font.center_shift("control"), y - 4))
    y += y_gap
    ren = font.render("kick")
    screen.blit(ren, (x + font.center_shift("kick"), y - 4))
    y += y_gap
    ren = font.render("punch")
    screen.blit(ren, (x + font.center_shift("punch"), y - 4))
    y += y_gap
    ren = font.render("precision")
    screen.blit(ren, (x + font.center_shift("precision"), y - 4))
    y += y_gap
    ren = font.render("listening")
    screen.blit(ren, (x + font.center_shift("listening"), y - 4))
    y += y_gap
Exemple #5
0
 def display(self,display,font,mainClock):
     title_image=pygame.image.load("data/title.png")
     dlg=0
     selected_option=self.default_num
     if (len(self.choices_values_value)>0):#if settings, read in "configuration"
         selected_option=0
         for val in self.choices_values_value :
             if (val==configuration[self.variable]):
                 break
             selected_option+=1
         if (selected_option==len(self.choices_values_value)):
             selected_option=self.default_num
         dlg = dialog.Menu(font, self.choices_values_text)
     else:#look for submenus
         dlg = dialog.Menu(font, self.choices_submenus_text)
     
     dlg.option=selected_option
     if (len(self.dialogtext)>0):
         dialogbox = dialog.DialogBox((240, 51), (0, 0, 0),(255, 255, 255), font)
         dialogbox.set_dialog([self.dialogtext])
     while 1:
         mainClock.tick(30)
         Inputs.readkeys()#read all the actual keys
         if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
             pygame.quit()
             sys.exit()
         # Move the menu cursor if you press up or down    
         if Inputs.player_just_U[1]:
             dlg.move_cursor(-1)
         if Inputs.player_just_D[1]:
             dlg.move_cursor(1)
         # If you press A, check which option you're on!
         if Inputs.player_just_A[1]:
             if (len(self.choices_values_value)>0):#if settings
                 configuration[self.variable]=self.choices_values_value[dlg.get_option()[0]]
                 if (self.choices_values_goto[dlg.get_option()[0]]!=0):
                     self.choices_values_goto[dlg.get_option()[0]].display(display,font,mainClock)
                 else:
                     if (self.exits):
                         configuration["exit_menu"]="yes"
                     return
                 
             else:#if submenus
                 #print(dlg.get_option())
                 self.choices_submenus[dlg.get_option()[0]].display(display,font,mainClock)
         ## If you press B, cancel 
         if Inputs.player_just_B[1]:
             if (self.id!="menu_welcome"):
                 Inputs.player_just_B[1]=False
                 return
             else:
                 print("Nothing to do...")
         
         #if returns from a sub-menu asking to exit :
         if (configuration["exit_menu"]=="yes"):
             return
         
         # Get the surface from the NES game library
         screen = display.get_surface()
         screen.blit(title_image,(0,0))
         
         # Draw the menu boxes
         ren = font.render(self.text)
         screen.blit(ren, (8, 112))
         dlg.draw(screen, (16, 128), background=(0, 0, 0), border=(255, 255, 255))
         if (len(self.dialogtext)>0):
             dialogbox.draw(screen, (8, 180))
         # Update and draw the display
         display.update()
Exemple #6
0
def select_teams(display,font,mainClock,west_team_index_init,east_team_index_init):
    path="data/teams/"
    dirList=os.listdir(path)
    allteams=[]
    for fname in dirList:
        if fnmatch.fnmatch(fname, '*.xml'):
            allteams.append(Team("data/teams/"+fname))
    
    title_image=pygame.image.load("data/title.png")
    up_image=pygame.image.load("data/arrow_up.png")
    down_image=pygame.image.load("data/arrow_down.png")

    cursor_on_east_wing=False
    cursor_color_angle=0
    west_team_index=west_team_index_init
    east_team_index=east_team_index_init
    while 1:
        mainClock.tick(30)
        cursor_color_angle+=0.1
        Inputs.readkeys()#read all the actual keys
        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            pygame.quit()
            sys.exit()
        # Move the menu cursor if you press up or down    
        if Inputs.player_just_U[1]:
            if (cursor_on_east_wing):
                east_team_index-=1
                if (east_team_index<0):
                    east_team_index=len(allteams)-1
                if (east_team_index==west_team_index):
                    east_team_index-=1
                    if (east_team_index<0):
                        east_team_index=len(allteams)-1
            else:
                west_team_index-=1
                if (west_team_index<0):
                    west_team_index=len(allteams)-1
                if (east_team_index==west_team_index):
                    west_team_index-=1
                    if (west_team_index<0):
                        west_team_index=len(allteams)-1
        if Inputs.player_just_D[1]:
            if (cursor_on_east_wing):
                east_team_index+=1
                if (east_team_index>=len(allteams)):
                    east_team_index=0
                if (east_team_index==west_team_index):
                    east_team_index+=1
                    if (east_team_index>=len(allteams)):
                        east_team_index=0
            else:
                west_team_index+=1
                if (west_team_index>=len(allteams)):
                    west_team_index=0
                if (east_team_index==west_team_index):
                    west_team_index+=1
                    if (west_team_index>=len(allteams)):
                        west_team_index=0
        if Inputs.player_just_R[1] or Inputs.player_just_L[1]:
                cursor_on_east_wing=not cursor_on_east_wing
        # If you press A, check which option you're on!
        if Inputs.player_just_A[1]:
            return (allteams[west_team_index].xml_filename,west_team_index,allteams[east_team_index].xml_filename,east_team_index)
        # If you press B, cancel 
        if (Inputs.player_just_B[1]):# or  Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            return ("?",west_team_index,"?",east_team_index)
        
        
        # Get the surface from the NES game library
        screen = display.get_surface()
        screen.blit(title_image,(0,0))
        
        #draw current teams
        if (cursor_on_east_wing):
            pygame.draw.rect(screen, (150+cos(cursor_color_angle)*50,150+cos(cursor_color_angle+2.1)*50 ,150+cos(cursor_color_angle+1.2)*50 ), (185, 95, 25,25),1)
            screen.blit(up_image,(185, 78))
            screen.blit(down_image,(185, 121))
        else:
            pygame.draw.rect(screen, (150+cos(cursor_color_angle)*50,150+cos(cursor_color_angle+2.1)*50 ,150+cos(cursor_color_angle+1.2)*50), (37, 95, 25,25),1)
            screen.blit(up_image,(37, 78))
            screen.blit(down_image,(37, 121))

        draw_team_info_text(screen,font,128)
        #screen.blit(allteams[west_team_index].image,(42,120))
        transf_west_img=pygame.transform.scale(allteams[west_team_index].image,(int(16+4*cos(cursor_color_angle)),int(16+4*cos(1.3*cursor_color_angle+0.5))))
        transf_west_img=pygame.transform.scale(allteams[west_team_index].image,(int(16+4*cos(cursor_color_angle)),int(16+4*cos(1.3*cursor_color_angle+0.5))))
        transf_east_img=pygame.transform.scale(allteams[east_team_index].image,(int(16+4*cos(cursor_color_angle+1)),int(16+4*cos(1.3*cursor_color_angle+1.5))))

        screen.blit(transf_west_img,(42+8-(16+4*cos(cursor_color_angle))/2,100+8-(16+4*cos(1.3*cursor_color_angle+0.5))/2))
        screen.blit(transf_east_img,(190+8-(16+4*cos(cursor_color_angle+1))/2,100+8-(16+4*cos(1.3*cursor_color_angle+1.5))/2))

        allteams[west_team_index].draw_info(screen,78,-1)
        allteams[east_team_index].draw_info(screen,178,1)
        
        ren = font.render(allteams[west_team_index].name)
        screen.blit(ren, (55+font.center_shift(allteams[west_team_index].name), 142))
        ren = font.render(allteams[east_team_index].name)
        screen.blit(ren, (200+font.center_shift(allteams[east_team_index].name), 142))
        ren = font.render("vs.")
        screen.blit(ren, (120, 125))


#        x=100
#        y=100
#        draw_team_info_text(screen,font,10)
#        for team in allteams:
#            screen.blit(team.image,(x,y))
#            team.draw_info(screen,x)
#            x+=50
        # Draw the menu boxes
        #ren = font.render(info)
        #screen.blit(ren, (8, 112))
        # Update and draw the display
        display.update()
Exemple #7
0
def select_teams(display, font, mainClock, west_team_index_init,
                 east_team_index_init):
    path = "data/teams/"
    dirList = os.listdir(path)
    allteams = []
    for fname in dirList:
        if fnmatch.fnmatch(fname, '*.xml'):
            allteams.append(Team("data/teams/" + fname))

    title_image = pygame.image.load("data/title.png")
    up_image = pygame.image.load("data/arrow_up.png")
    down_image = pygame.image.load("data/arrow_down.png")

    cursor_on_east_wing = False
    cursor_color_angle = 0
    west_team_index = west_team_index_init
    east_team_index = east_team_index_init
    while 1:
        mainClock.tick(30)
        cursor_color_angle += 0.1
        Inputs.readkeys()  #read all the actual keys
        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            pygame.quit()
            sys.exit()
        # Move the menu cursor if you press up or down
        if Inputs.player_just_U[1]:
            if (cursor_on_east_wing):
                east_team_index -= 1
                if (east_team_index < 0):
                    east_team_index = len(allteams) - 1
                if (east_team_index == west_team_index):
                    east_team_index -= 1
                    if (east_team_index < 0):
                        east_team_index = len(allteams) - 1
            else:
                west_team_index -= 1
                if (west_team_index < 0):
                    west_team_index = len(allteams) - 1
                if (east_team_index == west_team_index):
                    west_team_index -= 1
                    if (west_team_index < 0):
                        west_team_index = len(allteams) - 1
        if Inputs.player_just_D[1]:
            if (cursor_on_east_wing):
                east_team_index += 1
                if (east_team_index >= len(allteams)):
                    east_team_index = 0
                if (east_team_index == west_team_index):
                    east_team_index += 1
                    if (east_team_index >= len(allteams)):
                        east_team_index = 0
            else:
                west_team_index += 1
                if (west_team_index >= len(allteams)):
                    west_team_index = 0
                if (east_team_index == west_team_index):
                    west_team_index += 1
                    if (west_team_index >= len(allteams)):
                        west_team_index = 0
        if Inputs.player_just_R[1] or Inputs.player_just_L[1]:
            cursor_on_east_wing = not cursor_on_east_wing
        # If you press A, check which option you're on!
        if Inputs.player_just_A[1]:
            return (allteams[west_team_index].xml_filename, west_team_index,
                    allteams[east_team_index].xml_filename, east_team_index)
        # If you press B, cancel
        if (Inputs.player_just_B[1]
            ):  # or  Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            return ("?", west_team_index, "?", east_team_index)

        # Get the surface from the NES game library
        screen = display.get_surface()
        screen.blit(title_image, (0, 0))

        #draw current teams
        if (cursor_on_east_wing):
            pygame.draw.rect(screen,
                             (150 + cos(cursor_color_angle) * 50,
                              150 + cos(cursor_color_angle + 2.1) * 50,
                              150 + cos(cursor_color_angle + 1.2) * 50),
                             (185, 95, 25, 25), 1)
            screen.blit(up_image, (185, 78))
            screen.blit(down_image, (185, 121))
        else:
            pygame.draw.rect(screen,
                             (150 + cos(cursor_color_angle) * 50,
                              150 + cos(cursor_color_angle + 2.1) * 50,
                              150 + cos(cursor_color_angle + 1.2) * 50),
                             (37, 95, 25, 25), 1)
            screen.blit(up_image, (37, 78))
            screen.blit(down_image, (37, 121))

        draw_team_info_text(screen, font, 128)
        #screen.blit(allteams[west_team_index].image,(42,120))
        transf_west_img = pygame.transform.scale(
            allteams[west_team_index].image,
            (int(16 + 4 * cos(cursor_color_angle)),
             int(16 + 4 * cos(1.3 * cursor_color_angle + 0.5))))
        transf_west_img = pygame.transform.scale(
            allteams[west_team_index].image,
            (int(16 + 4 * cos(cursor_color_angle)),
             int(16 + 4 * cos(1.3 * cursor_color_angle + 0.5))))
        transf_east_img = pygame.transform.scale(
            allteams[east_team_index].image,
            (int(16 + 4 * cos(cursor_color_angle + 1)),
             int(16 + 4 * cos(1.3 * cursor_color_angle + 1.5))))

        screen.blit(transf_west_img,
                    (42 + 8 - (16 + 4 * cos(cursor_color_angle)) / 2, 100 + 8 -
                     (16 + 4 * cos(1.3 * cursor_color_angle + 0.5)) / 2))
        screen.blit(transf_east_img,
                    (190 + 8 -
                     (16 + 4 * cos(cursor_color_angle + 1)) / 2, 100 + 8 -
                     (16 + 4 * cos(1.3 * cursor_color_angle + 1.5)) / 2))

        allteams[west_team_index].draw_info(screen, 78, -1)
        allteams[east_team_index].draw_info(screen, 178, 1)

        ren = font.render(allteams[west_team_index].name)
        screen.blit(
            ren, (55 + font.center_shift(allteams[west_team_index].name), 142))
        ren = font.render(allteams[east_team_index].name)
        screen.blit(
            ren,
            (200 + font.center_shift(allteams[east_team_index].name), 142))
        ren = font.render("vs.")
        screen.blit(ren, (120, 125))

        #        x=100
        #        y=100
        #        draw_team_info_text(screen,font,10)
        #        for team in allteams:
        #            screen.blit(team.image,(x,y))
        #            team.draw_info(screen,x)
        #            x+=50
        # Draw the menu boxes
        #ren = font.render(info)
        #screen.blit(ren, (8, 112))
        # Update and draw the display
        display.update()