Example #1
0
File: Main.py Project: mcspen/FIFA
    multiprocessing.freeze_support()

    # Load defaults
    with open(config_filename, 'r') as f:
        configs = json.load(f)
        f.close()
    default_dbs = configs['default_databases']

    # Set defaults
    player_db = PlayerDB()
    player_list = PlayerDB()
    formation_db = FormationDB()
    formation_list = FormationDB()
    team_list = TeamDB()

    player_db.load(default_dbs['player_db'], 'db')
    player_list.load(default_dbs['player_list'], 'list')
    formation_db.load(default_dbs['formation_db'], 'db')
    formation_list.load(default_dbs['formation_list'], 'list')
    team_list.load(default_dbs['team_list'])

    db_dict = {
        'player_db': (default_dbs['player_db'], player_db),
        'player_list': (default_dbs['player_list'], player_list),
        'formation_db': (default_dbs['formation_db'], formation_db),
        'formation_list': (default_dbs['formation_list'], formation_list),
        'team_list': (default_dbs['team_list'], team_list)
    }

    FifaApp.start_app(db_dict)
    # delete_all_temp_images()
Example #2
0
        def select_file_func(file_name):

            # Save new default to config file
            if file_type[:7] == 'default':
                # Load configs
                from Window.AppConfig import config_filename
                configs = {}
                with open(config_filename, 'r') as config_file:
                    configs = json.load(config_file)
                    config_file.close()

                # Assign new file name to config
                configs['default_databases'][file_type[8:]] = file_name

                # Save configs
                with open(config_file, 'w') as config_file:
                    json.dump(configs, config_file)
                    config_file.close()

            # Load db to db_dict
            elif file_type[:7] == 'current':

                if file_type[8:12] == 'play':
                    load_db = PlayerDB()
                elif file_type[8:12] == 'form':
                    load_db = FormationDB()
                elif file_type[8:12] == 'team':
                    load_db = TeamDB()
                else:
                    load_db = PlayerDB()
                    print "File type is invalid."

                if file_type[-2:] == 'db':
                    load_file_type = 'db'
                elif file_type[-4:] == 'list':
                    load_file_type = 'list'
                else:
                    load_file_type = 'Invalid'

                # Load db
                load_db.load(file_name, load_file_type)

                # Assign db to db_dict
                db_dict[file_type[8:]] = (file_name, load_db)

            else:
                print "File type is invalid."

            # Enable back button
            settings['file_changes'] = False
            settings['file_index'] = 0

            if settings['prev_window'] == 'team_creation':
                CreateUltimateTeams.open_create_ultimate_teams_window(
                    win_pick_file.x, win_pick_file.y, db_dict, settings['prev_window_value'],
                    file_name=settings['create_team_name'], roster=settings['roster'],
                    input_formation=settings['input_formation'])
            elif settings['prev_window'] == 'search':
                SearchMenu.open_search_menu(win_pick_file.x, win_pick_file.y, db_dict,
                                            settings['attr_dict'], settings['attr_list'], settings)
            elif settings['prev_window'] == 'pick_player':
                PickPlayer.open_pick_player_window(win_pick_file.x, win_pick_file.y, db_dict,
                                                   settings['input_formation'], settings['win_previous'],
                                                   settings['roster'], settings['pos_symbol'],
                                                   settings['pick_formations_page'], settings['attr_dict'],
                                                   settings['attr_list'], settings)
            else:
                FilesMenu.open_files_menu(win_pick_file.x, win_pick_file.y, db_dict, settings)
            win_pick_file.hide()