示例#1
0
 def updateBestExit(self, splitnum):
     if not timeh.greater(self.state.comparisons[3].totalDiffs[splitnum],0)\
         or\
         (timeh.isBlank(self.state.comparisons[3].totals[splitnum])\
         and not timeh.isBlank(self.state.currentRun.totals[splitnum])):
         self.info.configure(text="Yes", fg=self.config["colours"]["yes"])
     else:
         self.info.configure(text="No", fg=self.config["colours"]["no"])
示例#2
0
    def setPreviousColour(self):
        split = self.state.splitnum - 1
        if timeh.isBlank(self.state.comparisons[3].totals[split])\
            or timeh.isBlank(self.state.currentRun.totals[split])\
            or timeh.isBlank(self.state.currentComparison.totals[split]):
            return self.config["colours"]["skipped"]

        if timeh.greater(self.state.comparisons[3].totals[split],
                         self.state.currentRun.totals[split]):
            return self.config["colours"]["gold"]
        else:
            return self.setColour(self.state.currentRun.segments[split],
                                  self.state.currentRun.totals[split], split)
示例#3
0
    def frameUpdate(self):
        if self.state.runEnded:
            return
        if self.state.splitnum and self.shouldHide():
            self.hide()
            return
        if not timeh.greater(self.state.comparisons[0].segments[self.state.splitnum],self.state.segmentTime)\
            and not timeh.isBlank(self.state.comparisons[0].segments[self.state.splitnum])\
            and not (self.state.splitnum and timeh.isBlank(self.state.currentRun.segments[self.state.splitnum-1])):

            if self.state.splitnum and self.shouldHide():
                self.hide()
                return

            self.header.configure(text="Current Segment:")
            self.setTimes(self.state.segmentTime,previous=False)
示例#4
0
 def findDiffColour(self,splitIndex):
     # Either the split in this run is blank, or we're comparing
     # to something that's blank
     if \
         timeh.isBlank(self.state.currentRun.totals[splitIndex]) \
         or timeh.isBlank(self.state.currentComparison.totals[splitIndex]):
         return self.config["diff"]["colours"]["skipped"]
     # This split is the best ever. Mark it with the gold colour
     elif not timeh.isBlank(self.state.comparisons[0].segmentDiffs[splitIndex]) \
         and timeh.greater(0,self.state.comparisons[0].segmentDiffs[splitIndex]):
         return self.config["diff"]["colours"]["gold"]
     else:
         return self.getCurrentDiffColour(\
             self.state.currentComparison.segmentDiffs[splitIndex],\
             self.state.currentComparison.totalDiffs[splitIndex]\
         )
示例#5
0
 def getAverages(self):
     averages = []
     for i in range(len(self.splitnames)):
         average = []
         for j in range(int((len(self.completeCsv[0]) - 1) / 2)):
             time = timeh.stringToTime(self.completeCsv[i + 1][2 * j + 1])
             if not timeh.isBlank(time):
                 average.append(
                     timeh.stringToTime(self.completeCsv[i + 1][2 * j + 1]))
         if not timeh.isBlank(self.currentRun.segments[i]):
             average.append(self.currentRun.segments[i])
         averageTime = timeh.sumTimeList(average)
         if timeh.isBlank(averageTime):
             averages.append(timeh.blank())
         else:
             averages.append(averageTime / len(average))
     return SumList.SumList(averages)
示例#6
0
    def setCurrentColour(self):
        split = self.state.splitnum
        if timeh.isBlank(self.state.currentComparison.segments[split]):
            return self.config["colours"]["skipped"]

        else:
            return self.setColour(self.state.segmentTime, self.state.totalTime,
                                  split)
示例#7
0
    def frameUpdate(self):
        if self.state.runEnded:
            return
        if self.state.splitnum and self.shouldHide():
            self.hide()
            return
        if (not timeh.greater(self.state.comparisons[0].segments[self.state.splitnum],self.state.segmentTime)\
            and not timeh.isBlank(self.state.comparisons[0].segments[self.state.splitnum]))\
            or (not timeh.greater(self.state.comparisons[3].totals[self.state.splitnum],self.state.totalTime)\
            and not timeh.isBlank(self.state.comparisons[3].totals[self.state.splitnum]))\
            and not (self.state.splitnum and timeh.isBlank(self.state.currentRun.totals[self.state.splitnum-1])):

            if self.shouldHide():
                self.hide()
                return

            self.setTimes(self.state.totalTime, previous=False)
示例#8
0
    def setCurrentColour(self):
        split = self.state.splitnum
        if timeh.isBlank(self.state.currentComparison.segments[split]):
            return self.config["colours"]["skipped"]

        elif timeh.greater(self.state.currentComparison.segments[split],self.state.segmentTime):
            return self.config["colours"]["gaining"]
        else:
            return self.config["colours"]["losing"]
示例#9
0
def getRows(completeCsv):
    rows = []
    for i in range(len(completeCsv)):
        timeList = []
        for j in range(len(completeCsv[i])):
            time = timeh.stringToTime(completeCsv[i][j])
            if not timeh.isBlank(time):
                timeList.append(time)
        rows.append(timeList)
    return rows
示例#10
0
文件: 20to21.py 项目: ribecks98/Timer
def findBestExit(splitnum, complete):
    minVal = 100000000
    for i in range(int((len(complete[0]) - 1) / 2)):
        val = timeh.stringToTime(complete[splitnum + 1][2 * i + 2])
        if (timeh.isBlank(val)):
            continue
        if val < minVal:
            minVal = val
    if minVal == 100000000:
        return 'BLANK'
    return minVal
示例#11
0
    def completeSegment(self, time):
        totalTime = time - self.starttime
        splitTime = time - self.splitstarttime
        self.currentRun.addSegment(splitTime, totalTime)
        self.bptList.update(totalTime)

        for i in range(self.numComparisons):
            self.comparisons[i].updateDiffs(splitTime, totalTime)
        if timeh.isBlank(
                self.currentBests.bests[self.splitnum]) or not timeh.greater(
                    self.currentRun.segments[-1],
                    self.currentBests.bests[self.splitnum]):
            self.currentBests.update(splitTime, self.splitnum)
        if timeh.isBlank(
                self.bestExits.totals[self.splitnum]) or not timeh.greater(
                    totalTime, self.bestExits.totals[self.splitnum]):
            self.bestExits.update(totalTime, self.splitnum)
        self.splitnum = self.splitnum + 1
        self.splitstarttime = time
        if self.splitnum >= len(self.splitnames):
            self.runEnded = True
            self.localSave()
示例#12
0
 def setMainDiffs(self):
     for i in range(self.numRows-1):
         split = self.splits.currentSplits[i]
         if self.splits.typeChecker.isEmpty(split):
             self.rows[i].setDiff(text="")
         elif self.splits.typeChecker.isGroup(split):
             if (split.end < self.state.splitnum):
                 if split.start > 0:
                     groupChange = timeh.difference(\
                         timeh.difference(\
                             self.state.currentRun.totals[split.end],\
                             self.state.currentRun.totals[split.start]\
                         ),\
                         timeh.difference(\
                             self.state.currentComparison.totals[split.end],\
                             self.state.currentComparison.totals[split.start]\
                         )\
                     )
                     if timeh.isBlank(groupChange):
                         diffColour = self.config["diff"]["colours"]["skipped"]
                     else:
                         diffColour=self.getCurrentDiffColour(\
                             groupChange,\
                             self.state.currentComparison.totalDiffs[split.end]\
                         )
                 else:
                     diffColour=self.getCurrentDiffColour(\
                         timeh.blank(),\
                         self.state.currentComparison.totalDiffs[split.end]\
                     )
                 self.rows[i].setDiff(\
                     text=self.formatDiff(self.state.currentComparison.totalDiffs[split.end]),\
                     fg=diffColour\
                 )
             else:
                 self.rows[i].setDiff(text="")
         else:
             if (split.index < self.state.splitnum):
                 self.rows[i].setDiff(\
                     text=self.formatDiff(self.state.currentComparison.totalDiffs[split.index]),\
                     fg=self.findDiffColour(split.index)\
                 )
             else:
                 self.rows[i].setDiff(text="")
示例#13
0
    def timerColour(self):
        splitnum = self.state.splitnum
        comparisonTime = self.state.currentComparison.totals[splitnum]
        comparisonSegment = self.state.currentComparison.segments[splitnum]
        goldSegment = self.state.comparisons[0].segments[splitnum]

        # last split skipped
        if self.state.splitnum \
            and timeh.isBlank(self.state.currentRun.totals[-1]):
            # total blank or ahead of total
            if timeh.greater(comparisonTime, self.state.totalTime):
                return self.config["mainTimer"]["colours"]["main"]
            # behind total
            else:
                return self.config["mainTimer"]["colours"]["behindLosing"]
        # total blank
        if timeh.isBlank(comparisonTime):
            # gold blank or ahead of gold
            if timeh.greater(goldSegment, self.state.segmentTime):
                return self.config["mainTimer"]["colours"]["main"]
            # behind gold
            else:
                return self.config["mainTimer"]["colours"]["behindLosing"]
        # ahead of total
        elif timeh.greater(comparisonTime, self.state.totalTime):
            # segment blank
            if timeh.isBlank(comparisonSegment):
                # gold blank or ahead of gold
                if timeh.greater(goldSegment, self.state.segmentTime):
                    return self.config["mainTimer"]["colours"]["main"]
                # behind gold
                else:
                    return self.config["mainTimer"]["colours"]["aheadLosing"]
            # ahead of segment
            elif timeh.greater(comparisonSegment, self.state.segmentTime):
                # gold blank or ahead of gold
                if timeh.greater(goldSegment, self.state.segmentTime):
                    return self.config["mainTimer"]["colours"]["main"]
                # behind gold
                else:
                    return self.config["mainTimer"]["colours"][
                        "notGoldAheadGaining"]
            # behind segment
            else:
                return self.config["mainTimer"]["colours"]["aheadLosing"]
        # behind total
        else:
            # segment blank
            if timeh.isBlank(comparisonSegment):
                # gold blank or behind gold
                if timeh.greater(self.state.segmentTime, goldSegment):
                    return self.config["mainTimer"]["colours"]["behindLosing"]
                # ahead of gold
                else:
                    return self.config["mainTimer"]["colours"]["behindGaining"]
            # ahead of segment
            elif timeh.greater(comparisonSegment, self.state.segmentTime):
                # gold blank or ahead of gold
                if timeh.greater(goldSegment, self.state.segmentTime):
                    return self.config["mainTimer"]["colours"]["behindGaining"]
                # behind gold
                else:
                    return self.config["mainTimer"]["colours"][
                        "notGoldBehindGaining"]
            # behind segment
            else:
                return self.config["mainTimer"]["colours"]["behindLosing"]
示例#14
0
 def lastNonBlank(self):
     for i in range(len(self.totals)-1,-1,-1):
         if not timeh.isBlank(self.totals[i]):
             return i
     return -1
示例#15
0
 def updateDiffs(self,splittime,totaltime):
     if (not(len(self.segmentDiffs)) or not timeh.isBlank(self.totalDiffs[-1])):
         self.segmentDiffs.append(timeh.difference(splittime,self.segments[len(self.segmentDiffs)]))
     else:
         self.segmentDiffs.append(timeh.blank())
     self.totalDiffs.append(timeh.difference(totaltime,self.totals[len(self.totalDiffs)]))
示例#16
0
 def addSegment(self, segment, total):
     if (not (len(self.segments)) or not timeh.isBlank(self.totals[-1])):
         self.segments.append(segment)
     else:
         self.segments.append(timeh.blank())
     self.totals.append(total)