|
315 | 315 | # History |
316 | 316 | # -------------------------------- |
317 | 317 |
|
| 318 | +def historySelect(event): |
| 319 | + elements = history.get_children() |
| 320 | + |
| 321 | + for e in elements: |
| 322 | + tags = history.item(e, "tags") |
| 323 | + |
| 324 | + if "selected" in tags: |
| 325 | + tag = core.getScoreTag(history.item(e, "values")[0]) |
| 326 | + history.item(e, tags=(tag)) |
| 327 | + break |
| 328 | + |
| 329 | + currElementFocus = history.focus() |
| 330 | + history.item(currElementFocus, tags=("selected")) |
| 331 | + |
| 332 | +def _fixed_map(style, style_name, option): |
| 333 | + return [elm for elm in style.map(style_name, query_opt=option) if elm[:2] != ('!disabled', '!selected')] |
| 334 | + |
318 | 335 | historyListContainer = tk.Frame(historyTab) |
319 | 336 | historyListContainer.pack(fill="both", expand=True) |
320 | 337 |
|
321 | 338 | historyStyle = ttk.Style() |
| 339 | +historyStyle.map("history.Treeview", foreground=_fixed_map(historyStyle, "history.Treeview", "foreground"), background=_fixed_map(historyStyle, "history.Treeview", "background")) |
322 | 340 | historyStyle.configure("history.Treeview", highlightthickness=0, bd=0, font=('TkDefaultFont', 10)) |
323 | 341 | historyStyle.configure("history.Treeview.Heading", font=('TkDefaultFont', 10,'bold')) |
324 | 342 | historyStyle.layout("history.Treeview", [('history.Treeview.treearea', {'sticky': 'nswe'})]) |
|
334 | 352 | history.column(2, anchor="e") |
335 | 353 | history.column(3, anchor="e") |
336 | 354 |
|
| 355 | +history.tag_configure("win", background=vars.WIN_BG_COLOR, foreground=vars.WIN_FG_COLOR) |
| 356 | +history.tag_configure("loss", background=vars.LOSS_BG_COLOR, foreground=vars.LOSS_FG_COLOR) |
| 357 | +history.tag_configure("selected", background=vars.SELECTED_BG_COLOR, foreground=vars.SELECTED_FG_COLOR) |
| 358 | + |
337 | 359 | # Create history Scrollbar |
338 | 360 | historyScrollbar = Scrollbar(historyListContainer, orient=VERTICAL, command=history.yview) |
339 | 361 | historyScrollbar.pack(side=tk.LEFT, fill="y") |
340 | 362 |
|
341 | 363 | history.configure(yscrollcommand=historyScrollbar.set) |
| 364 | +history.bind("<<TreeviewSelect>>", historySelect) |
342 | 365 |
|
343 | 366 | historyBtnContainer = tk.Frame(historyTab) |
344 | 367 | historyBtnContainer.pack(fill="x") |
@@ -672,7 +695,10 @@ def updateGoals(config, plot, collectedXP): |
672 | 695 |
|
673 | 696 | totalInGoal = collectedInGoal + config["goals"][i]["remaining"] |
674 | 697 |
|
675 | | - goalContainers[i].setValues(round(collectedInGoal / totalInGoal * 100), collectedInGoal, config["goals"][i]["remaining"], totalInGoal) |
| 698 | + goalProgress = round(collectedInGoal / totalInGoal * 100) |
| 699 | + if goalProgress > 100: goalProgress = 100 |
| 700 | + |
| 701 | + goalContainers[i].setValues(goalProgress, collectedInGoal, config["goals"][i]["remaining"] if config["goals"][i]["remaining"] > 0 else 0, totalInGoal) |
676 | 702 | goalContainers[i].removeBtn.configure(command=lambda j=i: gcRemoveCallback(j)) |
677 | 703 | goalContainers[i].editBtn.configure(command=lambda j=i: gcEditCallback(j)) |
678 | 704 |
|
@@ -723,7 +749,8 @@ def updateGraph(config, epilogue, plot): |
723 | 749 | yAxisYou.append(int(h["amount"]) + prevValue) |
724 | 750 | index += 1 |
725 | 751 |
|
726 | | - if prevDate != date.today(): yAxisYou.append(yAxisYou[len(yAxisYou) - 1]) |
| 752 | + deltaDate = date.today() - prevDate |
| 753 | + for i in range(0, deltaDate.days): yAxisYou.append(yAxisYou[len(yAxisYou) - 1]) |
727 | 754 |
|
728 | 755 | yAxisDailyIdeal = [] |
729 | 756 |
|
@@ -752,18 +779,31 @@ def updateGraph(config, epilogue, plot): |
752 | 779 | plot.grid(axis="x", color="lightgray", which="both", linestyle=":") |
753 | 780 |
|
754 | 781 | # -------------------------------- |
755 | | - # Draw lines for significant unlocks |
| 782 | + # Draw lines for battlepass unlocks |
756 | 783 | # -------------------------------- |
757 | 784 |
|
758 | 785 | for i in range(0, vars.NUM_BPLEVELS + 1, 1): |
759 | | - plot.axhline(core.cumulativeSum(i, vars.LEVEL2_OFFSET, vars.NUM_XP_PER_LEVEL), color="gray", alpha=0.05, linestyle="-") |
| 786 | + alpha = 0.5 |
| 787 | + neededXP = core.cumulativeSum(i, vars.LEVEL2_OFFSET, vars.NUM_XP_PER_LEVEL) |
| 788 | + |
| 789 | + if totalXPCollected >= neededXP: alpha = 0.05 |
| 790 | + plot.axhline(neededXP, color="lightgray", alpha=alpha, linestyle="-") |
760 | 791 |
|
761 | 792 | for i in range(0, vars.NUM_BPLEVELS + 1, 5): |
762 | | - plot.axhline(core.cumulativeSum(i, vars.LEVEL2_OFFSET, vars.NUM_XP_PER_LEVEL), color="green", alpha=0.15, linestyle="-") |
| 793 | + alpha = 0.5 |
| 794 | + neededXP = core.cumulativeSum(i, vars.LEVEL2_OFFSET, vars.NUM_XP_PER_LEVEL) |
| 795 | + |
| 796 | + if totalXPCollected >= neededXP: alpha = 0.05 |
| 797 | + plot.axhline(neededXP, color="limegreen", alpha=alpha, linestyle="-") |
763 | 798 |
|
764 | 799 | if epilogue: |
765 | 800 | for i in range(1, vars.NUM_EPLOGUE_LEVELS + 1, 1): |
766 | | - plot.axhline(core.cumulativeSum(vars.NUM_BPLEVELS, vars.LEVEL2_OFFSET, vars.NUM_XP_PER_LEVEL) + i * vars.NUM_EPLOGUE_XP_PER_LEVEL, color="green", alpha=0.15, linestyle="-") |
| 801 | + alpha = 0.5 |
| 802 | + neededXP = core.cumulativeSum(vars.NUM_BPLEVELS, vars.LEVEL2_OFFSET, vars.NUM_XP_PER_LEVEL) + i * vars.NUM_EPLOGUE_XP_PER_LEVEL |
| 803 | + |
| 804 | + if totalXPCollected >= neededXP: alpha = 0.05 |
| 805 | + |
| 806 | + plot.axhline(neededXP, color="orange", alpha=alpha, linestyle="-") |
767 | 807 |
|
768 | 808 | updateGoals(config, plot, totalXPCollected) |
769 | 809 |
|
@@ -839,7 +879,10 @@ def updateValues(): |
839 | 879 |
|
840 | 880 | history.delete(*history.get_children()) |
841 | 881 | for i in range(len(config["history"]) - 1, -1, -1): |
842 | | - history.insert("", "end", values=(config["history"][i]["description"], str(config["history"][i]["amount"]) + " XP", datetime.fromtimestamp(config["history"][i]["time"]).strftime("%d.%m.%Y %H:%M"))) |
| 882 | + desc = config["history"][i]["description"] |
| 883 | + tag = core.getScoreTag(desc) |
| 884 | + |
| 885 | + history.insert("", "end", values=(desc, str(config["history"][i]["amount"]) + " XP", datetime.fromtimestamp(config["history"][i]["time"]).strftime("%d.%m.%Y %H:%M")), tags=(tag)) |
843 | 886 |
|
844 | 887 | # ================================ |
845 | 888 | # Buttons |
|
0 commit comments