コード例 #1
0
ファイル: CreateList.py プロジェクト: mcspen/FIFA
    def display_formations(results_list, attributes, index_range):
        # Remove old messages off page
        for result_message in create_list_settings['results']:
            view.remove(result_message)
        del create_list_settings['results'][:]

        # Add navigation buttons to page
        previous_range = (index_range[0]-num_results, index_range[0])
        previous_btn.action = (previous_btn_func, results_list, attributes, previous_range)

        next_range = (index_range[1], index_range[1]+num_results)
        next_btn.action = (next_btn_func, results_list, attributes, next_range)

        total_num_results_label.text = str(len(results_list.db)) + " Formations"
        pages_label.text = "Page %d of %d" % (int(index_range[1]/num_results),
                                              math.ceil(len(results_list.db)/float(num_results)))

        if index_range[0] > 0:
            previous_btn.enabled = 1
        else:
            previous_btn.enabled = 0
        if index_range[1] <= len(results_list.db) - 1:
            next_btn.enabled = 1
        else:
            next_btn.enabled = 0

        create_list_settings['results'].append(previous_btn)
        create_list_settings['results'].append(next_btn)
        create_list_settings['results'].append(total_num_results_label)
        create_list_settings['results'].append(pages_label)

        # Print out labels
        labels = [''] + formation_info_labels()[:-2]
        stat_index = 0
        add_btn_width = 30
        add_btn_space = add_btn_width + 10
        spacing_list = [add_btn_space, 100, 100, 55, 55, 55, 55]
        left_border = (win_create_list.width - sum(spacing_list)) / 2
        msg_x = left_border
        msg_y = previous_btn.bottom + 5

        for info_label in labels:
            player_label = Label(text=info_label, font=std_tf_font_bold, width=win_width-(2*left_border),
                                 height=std_tf_height, x=msg_x, y=msg_y, color=title_color)
            create_list_settings['results'].append(player_label)
            msg_x += spacing_list[stat_index]
            stat_index += 1

        msg_y += std_tf_height + 5

        # Print out formations
        for idx, formation in enumerate(results_list.db[index_range[0]:index_range[1]]):
            msg_x = left_border
            formation_stats = formation_info(formation)[:-2]
            stat_index = 0

            add_btn = Button("Add", width=add_btn_width, height=15, x=msg_x, y=msg_y,
                             action=(add_formation_btn_func, formation))
            create_list_settings['results'].append(add_btn)
            msg_x += spacing_list[stat_index]
            stat_index += 1

            for formation_stat in formation_stats:
                formation_label = Label(text=formation_stat, font=small_button_font, width=win_width-(2*left_border),
                                        height=std_tf_height, x=msg_x, y=msg_y, color=title_color)

                create_list_settings['results'].append(formation_label)
                msg_x += spacing_list[stat_index]
                stat_index += 1

            msg_y += std_tf_height

        for results_msg in create_list_settings['results']:
            view.add(results_msg)
コード例 #2
0
ファイル: EditMenu.py プロジェクト: mcspen/FIFA
    def display_formations(display_db, attributes, index_range):
        # Remove old messages off page
        for message in settings['messages']['results']:
            view.remove(message)
        del settings['messages']['results'][:]

        # Add navigation buttons to page
        if settings['edit_type'] == 'add':
            add_to_list_btn.title = 'Add All Formations'
            add_to_list_btn.action = (add_to_list_btn_func, display_db.db, 'add all')
        elif settings['edit_type'] == 'edit':
            add_to_list_btn.title = 'Remove All Formations'
            add_to_list_btn.action = (add_to_list_btn_func, display_db.db, 'remove all')
        else:
            print "Invalid edit type."

        previous_range = (index_range[0]-num_results, index_range[0])
        previous_btn.action = (previous_btn_func, display_db, attributes, previous_range)

        next_range = (index_range[1], index_range[1]+num_results)
        next_btn.action = (next_btn_func, display_db, attributes, next_range)

        total_num_results_label.text = str(len(display_db.db)) + " Formations"
        pages_label.text = "Page %d of %d" % (int(index_range[1]/num_results),
                                              math.ceil(len(display_db.db)/float(num_results)))

        if index_range[0] > 0:
            previous_btn.enabled = 1
        else:
            previous_btn.enabled = 0
        if index_range[1] <= len(display_db.db) - 1:
            next_btn.enabled = 1
        else:
            next_btn.enabled = 0

        settings['messages']['results'].append(add_to_list_btn)
        settings['messages']['results'].append(previous_btn)
        settings['messages']['results'].append(next_btn)
        settings['messages']['results'].append(total_num_results_label)
        settings['messages']['results'].append(pages_label)

        # Print out labels
        labels = formation_info_labels()
        stat_index = 1
        spacing_list = [25, 100, 100, 55, 55, 55, 55, 140, 160]
        left_border = (win_edit.width - sum(spacing_list))/2
        msg_x = left_border + spacing_list[0]
        msg_y = add_to_list_btn.bottom + 5

        for info_label in labels:
            formation_label = Label(text=info_label, font=std_tf_font_bold, width=spacing_list[stat_index]-5,
                                    height=std_tf_height, x=msg_x, y=msg_y, color=title_color)
            settings['messages']['results'].append(formation_label)
            msg_x += spacing_list[stat_index]

            if stat_index < len(spacing_list)-1:
                stat_index += 1

        msg_y += std_tf_height + 5

        # Print out formations
        for idx, formation in enumerate(display_db.db[index_range[0]:index_range[1]]):
            msg_x = left_border
            formation_stats = formation_info(formation)
            stat_index = 0

            if formation in list_formations.db:
                add_btn_text = '-'
            else:
                add_btn_text = '+'

            add_btn = Button(title=add_btn_text, width=spacing_list[stat_index]-5, height=15, x=msg_x, y=msg_y)
            add_btn.action = (add_btn_func, formation, add_btn)
            settings['messages']['results'].append(add_btn)
            msg_x += spacing_list[stat_index]
            stat_index += 1

            bio_btn = Button(title=formation['name'], width=spacing_list[stat_index]-5, height=15, x=msg_x, y=msg_y,
                             action=(formation_bio_btn_func, formation))
            settings['messages']['results'].append(bio_btn)
            msg_x += spacing_list[stat_index]
            stat_index += 1

            for formation_stat in formation_stats[1:]:
                formation_label = Label(text=formation_stat, font=small_button_font, width=spacing_list[stat_index]-5,
                                        height=std_tf_height, x=msg_x, y=msg_y, color=title_color)
                settings['messages']['results'].append(formation_label)

                msg_x += spacing_list[stat_index]
                if stat_index < len(spacing_list) - 1:
                    stat_index += 1

            msg_y += std_tf_height

        for results_msg in settings['messages']['results']:
            view.add(results_msg)
コード例 #3
0
ファイル: SearchMenu.py プロジェクト: mcspen/FIFA
    def display_formations(results_list, attributes, index_range):
        # Remove old messages off page
        for message in settings["messages"]["results"]:
            view.remove(message)
        del settings["messages"]["results"][:]

        # Add navigation buttons to page
        if settings["f_db_rg"] == "formation_db":
            add_to_list_btn.title = "Add All Formations"
            add_to_list_btn.action = (add_to_list_btn_func, results_list.db, "add all")
        elif settings["f_db_rg"] == "formation_list":
            add_to_list_btn.title = "Remove All Formations"
            add_to_list_btn.action = (add_to_list_btn_func, results_list.db, "remove all")
        else:
            print "Invalid edit type."

        previous_range = (index_range[0] - num_results, index_range[0])
        previous_btn.action = (previous_btn_func, results_list, attributes, previous_range)

        next_range = (index_range[1], index_range[1] + num_results)
        next_btn.action = (next_btn_func, results_list, attributes, next_range)

        total_num_results_label.text = str(len(results_list.db)) + " Formations"
        pages_label.text = "Page %d of %d" % (
            int(index_range[1] / num_results),
            math.ceil(len(results_list.db) / float(num_results)),
        )

        if index_range[0] > 0:
            previous_btn.enabled = 1
        else:
            previous_btn.enabled = 0
        if index_range[1] <= len(results_list.db) - 1:
            next_btn.enabled = 1
        else:
            next_btn.enabled = 0

        settings["messages"]["results"].append(add_to_list_btn)
        settings["messages"]["results"].append(previous_btn)
        settings["messages"]["results"].append(next_btn)
        settings["messages"]["results"].append(total_num_results_label)
        settings["messages"]["results"].append(pages_label)

        # Print out labels
        labels = formation_info_labels()
        stat_index = 0
        # Spacing values for each of the stats
        spacing_list = [100, 100, 55, 55, 55, 55, 140, 160]
        # Calculate the left border of the stats based on the number and width of the stats
        left_border = (win_search.width - sum(spacing_list)) / 2
        msg_x = left_border
        msg_y = add_to_list_btn.bottom + 5

        for info_label in labels:
            formation_label = Label(
                text=info_label,
                font=std_tf_font_bold,
                width=spacing_list[stat_index] - 5,
                height=std_tf_height,
                x=msg_x,
                y=msg_y,
                color=title_color,
            )
            settings["messages"]["results"].append(formation_label)
            msg_x += spacing_list[stat_index]

            if stat_index < len(spacing_list) - 1:
                stat_index += 1

        msg_y += std_tf_height + 5

        # Print out formations
        for formation in results_list.db[index_range[0] : index_range[1]]:
            msg_x = left_border
            formation_stats = formation_info(formation)
            stat_index = 0

            bio_btn = Button(
                title=formation_stats[0],
                width=spacing_list[stat_index] - 5,
                height=15,
                x=msg_x,
                y=msg_y,
                action=(formation_bio_btn_func, formation),
            )
            settings["messages"]["results"].append(bio_btn)
            msg_x += spacing_list[stat_index]
            stat_index += 1

            for formation_stat in formation_stats[1:]:
                formation_label = Label(
                    text=formation_stat,
                    font=small_button_font,
                    width=spacing_list[stat_index] - 5,
                    height=std_tf_height,
                    x=msg_x,
                    y=msg_y,
                    color=title_color,
                )

                settings["messages"]["results"].append(formation_label)
                msg_x += spacing_list[stat_index]
                if stat_index < len(spacing_list) - 1:
                    stat_index += 1

            msg_y += std_tf_height

        for results_msg in settings["messages"]["results"]:
            view.add(results_msg)