Exemplo n.º 1
0
    def run_table(self, laps):
        run_table_fr = tkd.Frame(self.tabcontrol)
        self.tabcontrol.add(run_table_fr, text='Run table')

        cols = [
            "Run", "Run time", "Real time", "Name", "MF", "Players X", "Level",
            "XP Gained", "Uniques kills", "Champions kills", "Minion kills",
            "Total kills", "Session", "Map seed"
        ]
        tree_frame = tkd.Frame(run_table_fr)
        btn_frame2 = tkd.Frame(run_table_fr)
        btn_frame2.pack(side=tk.BOTTOM)

        vscroll_tree = ttk.Scrollbar(tree_frame, orient=tk.VERTICAL)
        hscroll_tree = ttk.Scrollbar(run_table_fr, orient=tk.HORIZONTAL)
        tree = tkd.Treeview(tree_frame,
                            selectmode=tk.BROWSE,
                            yscrollcommand=vscroll_tree.set,
                            xscrollcommand=hscroll_tree.set,
                            show='headings',
                            columns=cols,
                            alternate_colour=True)
        hscroll_tree.config(command=tree.xview)
        vscroll_tree.config(command=tree.yview)
        tkd.Button(btn_frame2,
                   text='Save as .csv',
                   command=lambda: self.save_to_csv(tree)).pack(side=tk.LEFT,
                                                                fill=tk.X)

        vscroll_tree.pack(side=tk.RIGHT, fill=tk.Y)
        tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        hscroll_tree.pack(side=tk.BOTTOM, fill=tk.X)
        tree_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        renamed_cols = [
            c.replace('Uniques', 'Unique').replace('Champions', 'Champion')
            for c in cols
        ]
        tree['columns'] = renamed_cols
        widths = [35, 60, 115, 60, 42, 58, 45, 75, 71, 89, 71, 59, 80, 70]
        for i, col in enumerate(renamed_cols):
            tree.column(col, stretch=tk.NO, minwidth=0, width=widths[i])
            if col in [
                    'Run', 'XP Gained', 'Champion kills', 'Unique kills',
                    'Minion kills', 'Total kills'
            ]:
                sort_by = 'num'
            else:
                sort_by = 'name'
            tree.heading(col, text=col, sort_by=sort_by)

        for n, lap in enumerate(laps, 1):
            tmp_lap = dict(lap)
            tmp_lap['Run time'] = other_utils.build_time_str(
                tmp_lap['Run time'])
            tmp_lap['Run'] = n
            tree.insert('',
                        tk.END,
                        values=[tmp_lap.get(col, '') for col in cols])
Exemplo n.º 2
0
    def map_evaluation(self, laps):
        map_eval_fr = tkd.Frame(self.tabcontrol)
        self.tabcontrol.add(map_eval_fr, text='Map evaluation')

        cols = [
            "Map", "Map seed", "Run count", "Avg run time", "Avg MF",
            "Avg players X", "Avg packs (55% hork)",
            "Avg secs/pack (55% hork)", "Adjeff (55% hork)"
        ]
        tree_frame = tkd.Frame(map_eval_fr)
        btn_frame2 = tkd.Frame(map_eval_fr)
        btn_frame2.pack(side=tk.BOTTOM)

        vscroll_tree = ttk.Scrollbar(tree_frame, orient=tk.VERTICAL)
        hscroll_tree = ttk.Scrollbar(map_eval_fr, orient=tk.HORIZONTAL)
        tree = tkd.Treeview(tree_frame,
                            selectmode=tk.BROWSE,
                            yscrollcommand=vscroll_tree.set,
                            xscrollcommand=hscroll_tree.set,
                            show='headings',
                            columns=cols,
                            alternate_colour=True)
        hscroll_tree.config(command=tree.xview)
        vscroll_tree.config(command=tree.yview)
        tkd.Button(btn_frame2,
                   text='Save as .csv',
                   command=lambda: self.save_to_csv(tree)).pack(side=tk.LEFT,
                                                                fill=tk.X)

        vscroll_tree.pack(side=tk.RIGHT, fill=tk.Y)
        tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        hscroll_tree.pack(side=tk.BOTTOM, fill=tk.X)
        tree_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        tree['columns'] = cols
        widths = [35, 70, 70, 80, 55, 85, 130, 150, 105]
        for i, col in enumerate(cols):
            tree.column(col, stretch=tk.NO, minwidth=0, width=widths[i])
            if col in [
                    "Avg packs (55% hork)", "Avg secs/pack (55% hork)",
                    "Adjeff (55% hork)"
            ]:
                sort_by = 'name'
            else:
                sort_by = 'num'

            tree.heading(col, text=col, sort_by=sort_by)

        grouped = self.group_laps(laps=laps)

        for n, smap in enumerate(grouped, 1):
            tmp_lap = dict(smap)
            tmp_lap['Map'] = n
            tree.insert('',
                        tk.END,
                        values=[tmp_lap.get(col, '') for col in cols])
Exemplo n.º 3
0
    def open_grail_table(self):
        if win32gui.FindWindow(None, 'Item table'):
            return
        window = tk.Toplevel()
        window.title('Item table')
        window.state('zoomed')
        window.resizable(True, True)
        window.iconbitmap(os.path.join(getattr(sys, '_MEIPASS', os.path.abspath('.')), media_path + 'icon.ico'))
        window.protocol("WM_DELETE_WINDOW", lambda: self.close_grail_table(window))

        tree_frame = tkd.Frame(window)
        vscroll = ttk.Scrollbar(tree_frame, orient=tk.VERTICAL)
        hscroll = ttk.Scrollbar(window, orient=tk.HORIZONTAL)
        self.tree = tkd.Treeview(tree_frame, selectmode=tk.BROWSE, yscrollcommand=vscroll.set, xscrollcommand=hscroll.set, show='headings', columns=self.cols)
        hscroll.config(command=self.tree.xview)
        vscroll.config(command=self.tree.yview)

        combofr = tkd.Frame(tree_frame)
        vscroll.pack(side=tk.RIGHT, fill=tk.Y)
        combofr.pack(fill=tk.X)
        self.tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        hscroll.pack(side=tk.BOTTOM, fill=tk.X)
        tree_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        self.tree['columns'] = self.cols
        self.filters = []
        for col in self.cols:
            self.tree.column(col, stretch=tk.YES, minwidth=0, width=80)
            if col in ['TC', 'QLVL', 'Roll rarity', 'Roll chance']:
                sort_by = 'num'
                sort_key = lambda x: float('-inf') if x == '' else float(x.replace('%', ''))
            else:
                sort_by = 'name'
                sort_key = lambda x: x
            self.tree.heading(col, text=col, sort_by=sort_by)

            name = 'combofilter_' + col
            self.filters.append(name)
            setattr(self, name, ttk.Combobox(combofr, values=sorted(set(str(x[col]) for x in self.grail).union({''}), key=sort_key), state="readonly", width=1))
            getattr(self, name).pack(side=tk.LEFT, expand=True, fill=tk.X)
            getattr(self, name).bind('<<ComboboxSelected>>', self.select_from_filters)

        for item in self.grail:
            tag = 'Owned' if item.get('Found', False) else 'Missing'
            self.tree.insert('', tk.END, values=[item.get(col, '') for col in self.cols], tags=(tag,))

        self.tree.tag_configure('Owned', background='#e6ffe6')
        self.tree.tag_configure('Missing', background='peach puff')

        self.grail_table_open = True
Exemplo n.º 4
0
    def drop_table(self, drops):
        drop_table_fr = tkd.Frame(self.tabcontrol)
        self.tabcontrol.add(drop_table_fr, text='Drop table')

        cols = [
            "Run", "Item name", "Extra input", "Real time", "TC", "QLVL",
            "Item Class", "Grailer", "Eth Grailer"
        ]
        tree_frame = tkd.Frame(drop_table_fr)
        btn_frame2 = tkd.Frame(drop_table_fr)
        btn_frame2.pack(side=tk.BOTTOM)

        vscroll_tree = ttk.Scrollbar(tree_frame, orient=tk.VERTICAL)
        hscroll_tree = ttk.Scrollbar(drop_table_fr, orient=tk.HORIZONTAL)
        tree = tkd.Treeview(tree_frame,
                            selectmode=tk.BROWSE,
                            yscrollcommand=vscroll_tree.set,
                            xscrollcommand=hscroll_tree.set,
                            show='headings',
                            columns=cols,
                            alternate_colour=True)
        hscroll_tree.config(command=tree.xview)
        vscroll_tree.config(command=tree.yview)
        tkd.Button(btn_frame2,
                   text='Save as .csv',
                   command=lambda: self.save_to_csv(tree)).pack(side=tk.LEFT,
                                                                fill=tk.X)

        vscroll_tree.pack(side=tk.RIGHT, fill=tk.Y)
        tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        hscroll_tree.pack(side=tk.BOTTOM, fill=tk.X)
        tree_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        tree['columns'] = cols
        widths = [35, 190, 140, 120, 35, 35, 100, 47, 58]
        tree.tag_configure('Grail', background='#e6ffe6')
        for i, col in enumerate(cols):
            tree.column(col, stretch=tk.NO, minwidth=0, width=widths[i])
            if col in ['Run', 'TC', 'QLVL']:
                sort_by = 'num'
            else:
                sort_by = 'name'
            tree.heading(col, text=col, sort_by=sort_by)

        for n, drop_list in drops.items():
            for drop in drop_list:
                tmp_drop = dict(drop)
                tmp_drop['Run'] = n
                if drop.get("item_name", ''):
                    tmp_drop["Item name"] = drop["item_name"]
                    tmp_drop["Extra input"] = drop["extra"]
                else:
                    tmp_drop["Item name"] = tmp_drop["input"]
                    tmp_drop["Extra input"] = ""

                if drop.get('Grailer', False) == 'True' or drop.get(
                        'Eth Grailer', False) == 'True':
                    tree.insert('',
                                tk.END,
                                values=[tmp_drop.get(col, '') for col in cols],
                                tag='Grail')
                else:
                    tree.insert('',
                                tk.END,
                                values=[tmp_drop.get(col, '') for col in cols])
Exemplo n.º 5
0
    def drop_table(self, drops):
        flat_drops = [{
            **drop, 'Run': n,
            'Item name': drop.get('item_name', drop.get('input', '')),
            'Extra input': drop.get('extra', '')
        } for n, drop_list in drops.items() for drop in drop_list]

        def select_drops_from_filters(event=None):
            tree.delete(*tree.get_children())

            # The filtering function breaks if column name has underscore in it - potential issue that could be fixed..
            all_filter = lambda x: all(
                str(x.get(f.split('_')[-1], '')) == getattr(self, f).get() or
                getattr(self, f).get() == '' for f in filters)
            for drop in flat_drops:
                if all_filter(drop):
                    if drop.get('Grailer', False) == 'True':
                        tree.insert('',
                                    tk.END,
                                    values=[drop.get(col, '') for col in cols],
                                    tag='Grail')
                    elif drop.get('Eth Grailer', False) == 'True':
                        tree.insert('',
                                    tk.END,
                                    values=[drop.get(col, '') for col in cols],
                                    tag='EthGrail')
                    else:
                        tree.insert('',
                                    tk.END,
                                    values=[drop.get(col, '') for col in cols])

        drop_table_fr = tkd.Frame(self.tabcontrol)
        self.tabcontrol.add(drop_table_fr, text='Drop table')

        cols = [
            "Run", "Item name", "Extra input", "Real time", "TC", "QLVL",
            "Item Class", "Grailer", "Eth Grailer", "Session", "Rarity"
        ]
        tree_frame = tkd.Frame(drop_table_fr)
        btn_frame2 = tkd.Frame(drop_table_fr)
        btn_frame2.pack(side=tk.BOTTOM)

        vscroll_tree = ttk.Scrollbar(tree_frame, orient=tk.VERTICAL)
        hscroll_tree = ttk.Scrollbar(drop_table_fr, orient=tk.HORIZONTAL)
        tree = tkd.Treeview(tree_frame,
                            selectmode=tk.BROWSE,
                            yscrollcommand=vscroll_tree.set,
                            xscrollcommand=hscroll_tree.set,
                            show='headings',
                            columns=cols,
                            alternate_colour=True)
        hscroll_tree.config(command=tree.xview)
        vscroll_tree.config(command=tree.yview)
        tkd.Button(btn_frame2,
                   text='Save as .csv',
                   command=lambda: self.save_to_csv(tree)).pack(side=tk.LEFT,
                                                                fill=tk.X)
        combofr = tkd.Frame(tree_frame)

        vscroll_tree.pack(side=tk.RIGHT, fill=tk.Y)
        combofr.pack(fill=tk.X)
        tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        hscroll_tree.pack(side=tk.BOTTOM, fill=tk.X)
        tree_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        tree['columns'] = cols
        widths = [35, 200, 140, 120, 35, 38, 100, 47, 65, 80, 80]
        cb_width = [3, 30, 20, 16, 3, 3, 13, 5, 7, 10, 10]
        tree.tag_configure('Grail', background='#e6ffe6')
        tree.tag_configure('EthGrail', background='light goldenrod yellow')

        filters = []
        for i, col in enumerate(cols):
            tree.column(col, stretch=tk.NO, minwidth=0, width=widths[i])
            if col in ['Run', 'TC', 'QLVL']:
                sort_by = 'num'
                sort_key = lambda x: float('-inf') if x == '' else float(
                    x.replace('%', ''))
            else:
                sort_by = 'name'
                sort_key = lambda x: x
            tree.heading(col, text=col, sort_by=sort_by)

            name = 'combofilter_' + col
            filters.append(name)
            setattr(
                self, name,
                tkd.Combobox(combofr,
                             values=sorted(set(
                                 str(x.get(col, ''))
                                 for x in flat_drops).union({''}),
                                           key=sort_key),
                             state="readonly",
                             width=cb_width[i]))
            getattr(self, name).pack(side=tk.LEFT)
            getattr(self, name).bind('<<ComboboxSelected>>',
                                     select_drops_from_filters)

        select_drops_from_filters()