Skip to content

Commit

Permalink
Added logistics tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialQualia committed Jul 13, 2017
1 parent a40f8f7 commit cc56c61
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 13 deletions.
54 changes: 47 additions & 7 deletions PyEveLiveDPS/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@

class DPSGraph(tk.Frame):

def __init__(self, dpsOutLabel, dpsInLabel, characterDetector, **kwargs):
def __init__(self, dpsOutLabel, dpsInLabel, logiLabel, characterDetector, **kwargs):
tk.Frame.__init__(self, **kwargs)
self.dpsOutLabel = dpsOutLabel
self.dpsInLabel = dpsInLabel
self.logiLabel = logiLabel

self.degree = 5
self.seconds = 10
Expand All @@ -44,6 +45,7 @@ def __init__(self, dpsOutLabel, dpsInLabel, characterDetector, **kwargs):
self.yValuesOut = np.array([0] * int((self.seconds*1000)/self.interval))
self.yValuesIn = np.array([0] * int((self.seconds*1000)/self.interval))
self.highestAverage = 0
self.showLogi = False

self.characterDetector = characterDetector
self.characterDetector.setGraphInstance(self)
Expand Down Expand Up @@ -85,17 +87,29 @@ def changeSettings(self, seconds, interval, logiSetting, inSettings, outSettings

self.seconds = seconds
self.interval = interval
self.showLogi = logiSetting

self.historicalDamageOut = [0] * int((self.seconds*1000)/self.interval)
self.historicalDamageIn = [0] * int((self.seconds*1000)/self.interval)
self.yValuesOut = np.array([0] * int((self.seconds*1000)/self.interval))
self.yValuesIn = np.array([0] * int((self.seconds*1000)/self.interval))
if (self.showLogi):
self.historicalLogi = [0] * int((self.seconds*1000)/self.interval)
self.yValuesLogi = np.array([0] * int((self.seconds*1000)/self.interval))
self.logiLabel.grid()
else:
self.logiLabel.grid_remove()

if self.showLogi:
self.ySmoothLogi = self.smoothListGaussian(self.yValuesLogi, self.degree)
self.plotLineLogi, = self.subplot.plot(self.ySmoothLogi, 'y')

self.ySmoothIn = self.smoothListGaussian(self.yValuesIn, self.degree)
self.ySmoothOut = self.smoothListGaussian(self.yValuesOut, self.degree)

self.plotLineIn, = self.subplot.plot(self.ySmoothIn, 'r')
self.plotLineOut, = self.subplot.plot(self.ySmoothOut, 'c')

self.subplot.margins(0,0)

self.yInLines = [self.plotLineIn]
Expand All @@ -108,6 +122,21 @@ def changeSettings(self, seconds, interval, logiSetting, inSettings, outSettings

self.ani.event_source.start()

def getSeconds(self):
return self.seconds

def getInterval(self):
return self.interval

def getShowLogi(self):
return self.showLogi

def getInCategories(self):
return self.yInLinesCategories

def getOutCategories(self):
return self.yOutLinesCategories

def catchup(self):
"""This is just to 'clear' the graph"""
self.changeSettings(self.seconds, self.interval)
Expand All @@ -126,7 +155,6 @@ def readjust(self, windowWidth):
else:
self.graphFigure.subplots_adjust(left=(50/self.windowWidth), top=(1-15/self.windowWidth),
bottom=(15/self.windowWidth))
#self.canvas.draw()

def init_animation(self):
"""when blitting we need this, but as of now we do not"""
Expand All @@ -153,30 +181,42 @@ def animate(self, i):
dpsInString = str(decimal.Decimal(damageInAverage).quantize(decimal.Decimal('.01')))
self.dpsInLabel.configure(text="DPS In: " + dpsInString)

if self.showLogi:
self.historicalLogi.pop(0)
self.historicalLogi.insert(len(self.historicalLogi), logistics)
self.yValuesLogi = self.yValuesLogi[1:]
logiAverage = (np.sum(self.historicalLogi)*(1000/self.interval))/len(self.historicalLogi)
self.yValuesLogi = np.append(self.yValuesLogi, logiAverage)
logiString = str(decimal.Decimal(logiAverage).quantize(decimal.Decimal('.01')))
self.logiLabel.configure(text="Logi: " + logiString)

self.highestAverage = 0
for i in range(len(self.yValuesOut)):
if (self.yValuesOut[i] > self.highestAverage):
self.highestAverage = self.yValuesOut[i]
if (self.yValuesIn[i] > self.highestAverage):
self.highestAverage = self.yValuesIn[i]
if self.showLogi:
if (self.yValuesLogi[i] > self.highestAverage):
self.highestAverage = self.yValuesLogi[i]


if self.showLogi:
self.ySmoothLogi = self.smoothListGaussian(self.yValuesLogi, self.degree)
self.plotLineLogi.set_data(range(0, len(self.ySmoothLogi)), self.ySmoothLogi)

self.ySmoothIn = self.smoothListGaussian(self.yValuesIn, self.degree)
self.ySmoothOut = self.smoothListGaussian(self.yValuesOut, self.degree)

self.animateLines()

#self.plotLineOut.set_data(range(0, len(self.ySmoothOut)), self.ySmoothOut)
#self.plotLineIn.set_data(range(0, len(self.ySmoothIn)), self.ySmoothIn)

if (self.highestAverage < 100):
self.graphFigure.axes[0].set_ylim(bottom=0, top=100)
else:
self.graphFigure.axes[0].set_ylim(bottom=0, top=(self.highestAverage+self.highestAverage*0.1))
self.graphFigure.axes[0].get_yaxis().grid(True, linestyle="-", color="grey", alpha=0.2)
self.readjust(self.windowWidth)

return self.plotLineOut, self.plotLineIn

def animateLines(self):
"""
Magic to make many lines with colors work.
Expand Down
5 changes: 5 additions & 0 deletions PyEveLiveDPS/logreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def __init__(self, logPath):
self.damageOutRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*>to<")
self.damageInRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*>from<")
self.armorRepairedRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*> remote armor repaired to <")
self.hullRepairedRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*> remote hull repaired to <")
self.shieldBoostedRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*> remote shield boosted to <")

def readLog(self):
Expand All @@ -158,6 +159,10 @@ def readLog(self):
if armorRepGroup:
for match in armorRepGroup:
logistics += int(match)
hullRepGroup = self.hullRepairedRegex.findall(logData)
if hullRepGroup:
for match in hullRepGroup:
logistics += int(match)
shieldBoostGroup = self.shieldBoostedRegex.findall(logData)
if shieldBoostGroup:
for match in shieldBoostGroup:
Expand Down
23 changes: 17 additions & 6 deletions PyEveLiveDPS/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,24 @@ def __init__(self):
self.dpsFrame = tk.Frame(height="10", borderwidth="0", background="black")
self.dpsFrame.grid(row="6", column="1", columnspan="19", sticky="ew")
self.makeDraggable(self.dpsFrame)
self.dpsFrame.grid_columnconfigure(1, weight="1")

self.dpsOutLabel = tk.Label(self.dpsFrame, text="DPS Out: 0.0", fg="white", background="black")
self.dpsOutLabel.pack(side=tk.LEFT)
self.dpsOutLabel.grid(row="0", column="0")
self.makeDraggable(self.dpsOutLabel)

self.logiLabel = tk.Label(self.dpsFrame, text="Logi: 0.0", fg="white", background="black")
self.logiLabel.grid(row="0", column="1")
self.makeDraggable(self.logiLabel)
self.logiLabel.grid_remove()

self.dpsInLabel = tk.Label(self.dpsFrame, text="DPS In: 0.0", fg="white", background="black")
self.dpsInLabel.pack(side=tk.RIGHT)
self.dpsInLabel.grid(row="0", column="2", sticky="e")
self.makeDraggable(self.dpsInLabel)

#The hero of our app
self.graphFrame = graph.DPSGraph(self.dpsOutLabel, self.dpsInLabel, self.characterDetector,
background="black", borderwidth="0")
self.graphFrame = graph.DPSGraph(self.dpsOutLabel, self.dpsInLabel, self.logiLabel,
self.characterDetector, background="black", borderwidth="0")
self.graphFrame.grid(row="7", column="1", rowspan="13", columnspan="19", sticky="nesw")
self.makeDraggable(self.graphFrame.canvas.get_tk_widget())

Expand Down Expand Up @@ -222,8 +228,13 @@ def openSettings(self):

tk.Frame(self.settingsWindow, height="20", width="10").grid(row="99", column="1", columnspan="5")

okButton = tk.Button(self.settingsWindow, text=" Apply ", command=self.doSettings)
okButton.grid(row="100", column="0", columnspan="5")
buttonFrame = tk.Frame(self.settingsWindow)
buttonFrame.grid(row="100", column="0", columnspan="5")
okButton = tk.Button(buttonFrame, text=" Apply ", command=self.doSettings)
okButton.grid(row="0", column="0")
tk.Frame(buttonFrame, height="1", width="30").grid(row="0", column="1")
cancelButton = tk.Button(buttonFrame, text=" Cancel ", command=self.settingsWindow.destroy)
cancelButton.grid(row="0", column="2")

def expandDPSSettings(self, checkboxValue, dpsFrame, settingsList):
if not checkboxValue.get():
Expand Down

0 comments on commit cc56c61

Please sign in to comment.