Skip to content

Commit

Permalink
e
Browse files Browse the repository at this point in the history
  • Loading branch information
pncakespoon1 committed May 16, 2023
1 parent 7520afb commit 39325ff
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ResetTracker/data/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"lbName": "", "version": "2.0.6"}
{"lbName": "", "version": "2.0.7"}
79 changes: 79 additions & 0 deletions ResetTracker/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def graph1(cls, dist, title, smoothness=0.4, removeX=0, kde=True, min2=0, max2=3

return fig
except Exception as e:
print(1)
print(e)
return 1

# makes a pie chart given a list of strings
Expand Down Expand Up @@ -108,6 +110,8 @@ def graph2(cls, items):

return fig
except Exception as e:
print(2)
print(e)
return 1

# makes a table for relevant information of a split
Expand Down Expand Up @@ -151,6 +155,8 @@ def graph3(cls, splitStats):

return fig
except Exception as e:
print(3)
print(e)
return 1

# makes a 2-way table showing the frequency of each combination of iron source and entry method
Expand Down Expand Up @@ -227,6 +233,8 @@ def graph4(cls, enters, settings):
)
return fig
except Exception as e:
print(4)
print(e)
return 1

# table displaying info about a specific split
Expand Down Expand Up @@ -271,6 +279,8 @@ def graph5(cls, splitData):
)
return fig
except Exception as e:
print(5)
print(e)
return 1

# table display split stats of current session
Expand Down Expand Up @@ -320,6 +330,8 @@ def graph6(cls, currentSession):

return fig
except Exception as e:
print(6)
print(e)
return 1

# table displaying general stats of the current session
Expand Down Expand Up @@ -355,6 +367,8 @@ def graph7(cls, currentSession):
)
return fig
except Exception as e:
print(7)
print(e)
return 1

# pie chart from dict of numerical data
Expand Down Expand Up @@ -384,6 +398,8 @@ def graph8(cls, data):

return fig
except Exception as e:
print(8)
print(e)
return 1

# scatterplot displaying nph and average enter, with a canvas based on efficiency score
Expand Down Expand Up @@ -414,6 +430,8 @@ def graph9(cls, sessions):
plt.tight_layout()
return fig
except Exception as e:
print(9)
print(e)
return 1

# table displaying some nether stats for each enter type
Expand Down Expand Up @@ -458,6 +476,8 @@ def graph10(cls, exitSuccess):

return fig
except Exception as e:
print(10)
print(e)
return 1

# table displaying general stats of a session
Expand Down Expand Up @@ -492,6 +512,8 @@ def graph11(cls, generalData):
)
return fig
except Exception as e:
print(11)
print(e)
return 1

# table displaying general stats of a session
Expand Down Expand Up @@ -527,6 +549,8 @@ def graph12(cls, generalData):
)
return fig
except Exception as e:
print(12)
print(e)
return 1

# makes a histogram distribution of rta colour coded based on the current split during reset
Expand Down Expand Up @@ -563,6 +587,8 @@ def graph13(cls, igtDist, latestSplits):

return fig
except Exception as e:
print(13)
print(e)
return 1

@classmethod
Expand Down Expand Up @@ -592,6 +618,59 @@ def graph14(cls, data, split):

return fig
except Exception as e:
print(14)
print(e)
return 1

# table display split stats of selected session
@classmethod
def graph15(cls, session):
try:
# Define headers and values for the table
headers = ['', 'Iron', 'Wood', 'Iron Pickaxe', 'Nether', 'Structure 1', 'Structure 2', 'Nether Exit',
'Stronghold', 'End']
values = [['Count', 'Average', 'Average Split', 'Conversion']
]
for split in headers[1:]:
values.append([
Logistics.formatValue(session['splits stats'][split]['Count']),
Logistics.formatValue(session['splits stats'][split]['Cumulative Average'], isTime=True),
Logistics.formatValue(session['splits stats'][split]['Relative Average'], isTime=True),
Logistics.formatValue(session['splits stats'][split]['Relative Conversion'], isPercent=True)
])

# Create the plot
fig = go.Figure(data=[go.Table(
header=dict(
values=headers,
line_color='#2E2E2E',
fill_color='#2E2E2E',
align='center',
font=dict(color='white', size=12)
),
cells=dict(
values=values,
line_color='#2E2E2E',
fill_color=guiColors['background'],
align='center',
font=dict(color='#2E2E2E', size=11)
))
])

fig.update_layout(
margin=dict(l=20, r=20, t=20, b=20),
height=300,
width=800,
font=dict(size=12),
hovermode='closest',
plot_bgcolor=guiColors['background'],
paper_bgcolor=guiColors['background']
)

return fig
except Exception as e:
print(15)
print(e)
return 1

@classmethod
Expand Down
94 changes: 81 additions & 13 deletions ResetTracker/gui.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import sys

#"""
"""
if not getattr(sys, 'frozen', False): # if not running in a PyInstaller bundle
import importlib
for lib in ["Pillow", "plotly", "pygsheets", "requests", "seaborn", "watchdog", "wget"]:
if importlib.util.find_spec(lib) == None:
print("Run the following command in your terminal: pip install Pillow plotly pygsheets requests seaborn watchdog wget")
print("(If you already have the libraries, remove the # on lines 3 and 11 of gui.py)")
sys.exit()
#"""
"""

import pygsheets
import glob
Expand Down Expand Up @@ -283,10 +283,13 @@ def updateCurrentSession(cls, row):
try:
currentSession['figs'][0] = Graphs.graph6(currentSession)
except Exception as e:
pass
print(16)
print(e)
try:
currentSession['figs'][1] = Graphs.graph7(currentSession)
except Exception as e:
print(17)
print(e)
pass

main1.updateCSGraphs(row)
Expand Down Expand Up @@ -431,7 +434,8 @@ def overworld(cls, data):
elif (data['general stats']['percent played'] > recomendedSeedsPlayed['b']):
text += 'click into less seeds; be more selective with the previews you want to play\n'
except Exception as e:
pass
print(18)
print(e)

# overall reset hardness
try:
Expand All @@ -441,7 +445,8 @@ def overworld(cls, data):
if data['general stats']['rnph'] > thresholds['nph']['high'] and not fast:
text += 'consider resetting your overworlds more agressively; reset harder\n'
except Exception as e:
pass
print(19)
print(e)

# conversions
try:
Expand All @@ -452,14 +457,16 @@ def overworld(cls, data):
elif bt2WoodConversion < thresholds['owConversions']['bt-wood']['low']:
text += 'if you play out islands that do not have trees, stop doing that; consider doing more thorough assessment of ocean quality while looking for the bt\n'
except Exception as e:
pass
print(20)
print(e)

try:
played2btConversion = data['splits stats']['Iron']['Count']/data['general stats']['percent played']/data['general stats']['total resets']
if played2btConversion < thresholds['owConversions']['played-bt']['low']:
text += 'If you are resetting for mapless buried treasure, you might want to work on your mapless; you may be to selective with the spikes you play out for mapless'
except Exception as e:
pass
print(21)
print(e)

return text

Expand All @@ -472,7 +479,8 @@ def nether(cls, data):
if data['splits stats'][split]['Cumulative Average'] - (thresholds['splitFormulas'][split]['m'] * int(settings['playstyle']['target time']) + thresholds['splitFormulas'][split]['b']) > 30:
text += f'your average {split} is a bit on the slow end\n'
except Exception as e:
pass
print(22)
print(e)

return text

Expand Down Expand Up @@ -528,7 +536,8 @@ def push_data():


except Exception as e2:
pass
print(23)
print(e2)

live = True
while live:
Expand Down Expand Up @@ -578,6 +587,8 @@ def on_created(self, evt):
try:
self.data = json.load(record_file)
except Exception as e:
print(24)
print(e)
return
if self.data is None:
return
Expand Down Expand Up @@ -846,7 +857,8 @@ def trackResets(cls):
with open("temp.csv", "x") as f:
pass
except Exception as e:
pass
print(25)
print(e)
while True:
try:
newRecordObserver = Observer()
Expand Down Expand Up @@ -876,7 +888,8 @@ def trackResets(cls):
live = False
time.sleep(3)
except Exception as e:
pass
print(26)
print(e)
finally:
newRecordObserver.stop()
newRecordObserver.join()
Expand Down Expand Up @@ -1044,12 +1057,14 @@ def updateTables(self, run):
try:
bastion = datetime.strptime(time, '%H:%M:%S')
except Exception as e:
pass
print(27)
print(e)
elif split1 == 'Fortress':
try:
fortress = datetime.strptime(time, '%H:%M:%S')
except Exception as e:
pass
print(28)
print(e)
if bastion is not None and fortress is not None:
if self.splitVars[3].get() == 1:
text += (min(bastion, fortress)).strftime('%H:%M:%S') + ' Structure 1 '
Expand Down Expand Up @@ -1097,6 +1112,59 @@ def __init__(self, *args, **kwargs):
self.populate()


class SummaryPage(Page):
explanationText = 'Any stats, data, or figures found on this page are basic, and are more elaborate on other pages'
frame = None
control_panel = None

def displayInfo(self):
global isGraphingGeneral
global lastRun
if not isGraphingGeneral:
lastRun = Stats.appendStats(settings, lastRun)
isGraphingGeneral = True
sessionData = Stats.getSessionData(selectedSession.get(), sessions)

self.frame.clear_widgets()
self.frame.add_plot_frame()
isGraphingGeneral = False


def populate(self):
explanation = Label(self, text=self.explanationText, wraplength=800, foreground=guiColors['header'], font=("Arial", 14))
explanation.grid(row=0, column=0, columnspan=2, padx=50)

self.frame = ScrollableContainer(self)
self.frame.grid(row=1, column=1)

self.control_panel = Frame(self)
self.control_panel.grid(row=1, column=0, sticky='n', pady=10)

self.rta_min = tk.StringVar()
self.rta_max = tk.StringVar()
self.rta_min.set('-1')
self.rta_max.set('-1')
label1 = Label(self.control_panel, text='rta minimum')
label2 = Label(self.control_panel, text='rta maximum')
Tooltip.createToolTip(label1, 'left side cutoff for RTA Distribution')
Tooltip.createToolTip(label2, 'right side cutoff for RTA Distribution')
entry1 = Entry(self.control_panel, textvariable=self.rta_min, width=6, background=guiColors['entry'])
entry2 = Entry(self.control_panel, textvariable=self.rta_max, width=6, background=guiColors['entry'])
label1.grid(row=1, column=0)
label2.grid(row=2, column=0)
entry1.grid(row=1, column=1)
entry2.grid(row=2, column=1)


cmd = partial(self.displayInfo)
graph_Btn = tk.Button(self.control_panel, text='Graph', command=cmd, background=guiColors['button'], foreground=guiColors['white'])
graph_Btn.grid(row=0, column=0, columnspan=2)

def __init__(self, *args, **kwargs):
Page.__init__(self, *args, **kwargs)
SummaryPage.populate(self)


# gui
class GeneralPage(Page):
explanationText = 'General stats, graphs, and tables will appear on this page. The most important statistics will appear on this page'
Expand Down
2 changes: 1 addition & 1 deletion ResetTracker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_previous_item(cls, lst, item):
@classmethod
def isOnWallScreen(cls):
# if we can't check for multi, we assume that it isn't there
if not multiSupported:
if not multiCheckSupported:
return False

if sys.platform.startswith("win32"):
Expand Down

0 comments on commit 39325ff

Please sign in to comment.