Skip to content

Commit

Permalink
Merge pull request #9 from ArtificialQualia/dev
Browse files Browse the repository at this point in the history
Added logi IN line and custom logi colors, improved settings window
  • Loading branch information
ArtificialQualia committed Jul 14, 2017
2 parents e441723 + 598d780 commit 8918efb
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 63 deletions.
106 changes: 73 additions & 33 deletions PyEveLiveDPS/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@

class DPSGraph(tk.Frame):

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

self.degree = 5
self.seconds = 10
Expand All @@ -46,7 +47,10 @@ def __init__(self, dpsOutLabel, dpsInLabel, logiLabel, characterDetector, **kwar
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.showLogiIn = False
self.showLogiOut = False
self.logiInColor = "#FFFF00"
self.logiOutColor = "#FFFF00"

self.characterDetector = characterDetector
self.characterDetector.setGraphInstance(self)
Expand Down Expand Up @@ -81,29 +85,40 @@ def __init__(self, dpsOutLabel, dpsInLabel, logiLabel, characterDetector, **kwar

self.canvas.show()

def changeSettings(self, seconds, interval, logiSetting, inSettings, outSettings):
def changeSettings(self, seconds, interval, logiOutSetting, logiOutColor, logiInSetting, logiInColor, inSettings, outSettings):
"""This function is called when a user changes settings AFTER the settings are verified in window.py"""
self.ani.event_source.stop()
self.subplot.clear()

self.seconds = seconds
self.interval = interval
self.showLogi = logiSetting
self.showLogiOut = logiOutSetting
self.showLogiIn = logiInSetting
self.logiInColor = logiInColor
self.logiOutColor = logiOutColor

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()
if self.showLogiOut:
self.historicalLogiOut = [0] * int((self.seconds*1000)/self.interval)
self.yValuesLogiOut = np.array([0] * int((self.seconds*1000)/self.interval))
self.logiLabelOut.grid()
self.ySmoothLogiOut = self.smoothListGaussian(self.yValuesLogiOut, self.degree)
self.plotLineLogiOut, = self.subplot.plot(self.ySmoothLogiOut, self.logiOutColor)
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.logiLabelOut.grid_remove()

if self.showLogiIn:
self.historicalLogiIn = [0] * int((self.seconds*1000)/self.interval)
self.yValuesLogiIn = np.array([0] * int((self.seconds*1000)/self.interval))
self.logiLabelIn.grid()
self.ySmoothLogiIn = self.smoothListGaussian(self.yValuesLogiIn, self.degree)
self.plotLineLogiIn, = self.subplot.plot(self.ySmoothLogiIn, self.logiInColor)
else:
self.logiLabelIn.grid_remove()


self.ySmoothIn = self.smoothListGaussian(self.yValuesIn, self.degree)
self.ySmoothOut = self.smoothListGaussian(self.yValuesOut, self.degree)
Expand All @@ -129,8 +144,17 @@ def getSeconds(self):
def getInterval(self):
return self.interval

def getShowLogi(self):
return self.showLogi
def getLogiOutColor(self):
return self.logiOutColor

def getLogiInColor(self):
return self.logiInColor

def getShowLogiOut(self):
return self.showLogiOut

def getShowLogiIn(self):
return self.showLogiIn

def getInCategories(self):
return copy.deepcopy(self.yInLinesCategories)
Expand All @@ -148,21 +172,21 @@ def readjust(self, windowWidth):
Annoyingly, we have to use a %, not a number of pixels"""
self.windowWidth = windowWidth
if (self.highestAverage < 900):
self.graphFigure.subplots_adjust(left=(30/self.windowWidth), top=(1-15/self.windowWidth),
self.graphFigure.subplots_adjust(left=(33/self.windowWidth), top=(1-15/self.windowWidth),
bottom=(15/self.windowWidth))
elif (self.highestAverage < 9000):
self.graphFigure.subplots_adjust(left=(40/self.windowWidth), top=(1-15/self.windowWidth),
self.graphFigure.subplots_adjust(left=(44/self.windowWidth), top=(1-15/self.windowWidth),
bottom=(15/self.windowWidth))
else:
self.graphFigure.subplots_adjust(left=(50/self.windowWidth), top=(1-15/self.windowWidth),
self.graphFigure.subplots_adjust(left=(55/self.windowWidth), top=(1-15/self.windowWidth),
bottom=(15/self.windowWidth))

def init_animation(self):
"""when blitting we need this, but as of now we do not"""
return

def animate(self, i):
damageOut,damageIn,logistics = self.characterDetector.readLog()
damageOut,damageIn,logiOut,logiIn = self.characterDetector.readLog()

self.historicalDamageOut.pop(0)
self.historicalDamageOut.insert(len(self.historicalDamageOut), damageOut)
Expand All @@ -182,29 +206,45 @@ 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)
if self.showLogiOut:
self.historicalLogiOut.pop(0)
self.historicalLogiOut.insert(len(self.historicalLogiOut), logiOut)
self.yValuesLogiOut = self.yValuesLogiOut[1:]
logiAverage = (np.sum(self.historicalLogiOut)*(1000/self.interval))/len(self.historicalLogiOut)
self.yValuesLogiOut = np.append(self.yValuesLogiOut, logiAverage)
logiString = str(decimal.Decimal(logiAverage).quantize(decimal.Decimal('.01')))
self.logiLabelOut.configure(text="| Logi Out: " + logiString)

if self.showLogiIn:
self.historicalLogiIn.pop(0)
self.historicalLogiIn.insert(len(self.historicalLogiIn), logiIn)
self.yValuesLogiIn = self.yValuesLogiIn[1:]
logiAverage = (np.sum(self.historicalLogiIn)*(1000/self.interval))/len(self.historicalLogiIn)
self.yValuesLogiIn = np.append(self.yValuesLogiIn, logiAverage)
logiString = str(decimal.Decimal(logiAverage).quantize(decimal.Decimal('.01')))
self.logiLabel.configure(text="Logi: " + logiString)
self.logiLabelIn.configure(text="Logi In: " + 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.showLogiOut:
if (self.yValuesLogiOut[i] > self.highestAverage):
self.highestAverage = self.yValuesLogiOut[i]
if self.showLogiIn:
if (self.yValuesLogiIn[i] > self.highestAverage):
self.highestAverage = self.yValuesLogiIn[i]


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

if self.showLogiIn:
self.ySmoothLogiIn = self.smoothListGaussian(self.yValuesLogiIn, self.degree)
self.plotLineLogiIn.set_data(range(0, len(self.ySmoothLogiIn)), self.ySmoothLogiIn)

self.ySmoothIn = self.smoothListGaussian(self.yValuesIn, self.degree)
self.ySmoothOut = self.smoothListGaussian(self.yValuesOut, self.degree)
Expand Down
39 changes: 28 additions & 11 deletions PyEveLiveDPS/logreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ 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 <")
self.armorRepairedOutRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*> remote armor repaired to <")
self.hullRepairedOutRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*> remote hull repaired to <")
self.shieldBoostedOutRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*> remote shield boosted to <")
self.armorRepairedInRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*> remote armor repaired by <")
self.hullRepairedInRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*> remote hull repaired by <")
self.shieldBoostedInRegex = re.compile("\(combat\) <.*?><b>([0-9]+).*> remote shield boosted by <")

def readLog(self):
logData = self.log.read()
Expand All @@ -154,21 +157,35 @@ def readLog(self):
for match in damageInGroup:
damageIn += int(match)

logistics = 0
armorRepGroup = self.armorRepairedRegex.findall(logData)
logisticsOut = 0
armorRepGroup = self.armorRepairedOutRegex.findall(logData)
if armorRepGroup:
for match in armorRepGroup:
logistics += int(match)
hullRepGroup = self.hullRepairedRegex.findall(logData)
logisticsOut += int(match)
hullRepGroup = self.hullRepairedOutRegex.findall(logData)
if hullRepGroup:
for match in hullRepGroup:
logistics += int(match)
shieldBoostGroup = self.shieldBoostedRegex.findall(logData)
logisticsOut += int(match)
shieldBoostGroup = self.shieldBoostedOutRegex.findall(logData)
if shieldBoostGroup:
for match in shieldBoostGroup:
logistics += int(match)
logisticsOut += int(match)

return damageOut, damageIn, logistics
logisticsIn = 0
armorRepGroup = self.armorRepairedInRegex.findall(logData)
if armorRepGroup:
for match in armorRepGroup:
logisticsIn += int(match)
hullRepGroup = self.hullRepairedInRegex.findall(logData)
if hullRepGroup:
for match in hullRepGroup:
logisticsIn += int(match)
shieldBoostGroup = self.shieldBoostedInRegex.findall(logData)
if shieldBoostGroup:
for match in shieldBoostGroup:
logisticsIn += int(match)

return damageOut, damageIn, logisticsOut, logisticsIn

def catchup(self):
self.log.read()
Expand Down
8 changes: 5 additions & 3 deletions PyEveLiveDPS/peld.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
here rather than in the BorderlessWindow class (and improve error handling)
but almost everything has a dependency on some window component, so we just
allow that to control it for now.
TODO: most of the huge functions should really be split up into many smaller
functions, and more things should be done through get and set methods
rather than class variables.
Probably a whole separate class for the settings window as well.
"""

import window
Expand All @@ -15,9 +20,6 @@ class App():
def __init__(self):
graphWindow = window.BorderlessWindow()
graphWindow.mainloop()

def destroy(self):
graphWindow.destroy()

try:
App()
Expand Down
Loading

0 comments on commit 8918efb

Please sign in to comment.