def LoopText(self, tubeFlagID): isVelocity = False while self._keepLooping: if isVelocity: self.text = self.GetDistanceText(tubeFlagID) else: self.text = self.GetVelocityText(tubeFlagID) isVelocity = not isVelocity uthread2.Sleep(3)
def _UpdateTiming(self): while self.state != uiconst.UI_HIDDEN: for each in self._scroll.GetNodes(): if each['panel']: step = each['step'] each[ 'panel'].sr.label.text = '{0}<t>{1:.4f}<t>{2:.4f}'.format( step.name or type(step).__name__, step.cpuTime, step.gpuTime) uthread2.Sleep(0.03)
def WaitForSceneReady(self): scene = self.sceneManager.GetRegisteredScene('default') startTime = gametime.GetSimTime() while scene is None and startTime + SEC * 15 < gametime.GetSimTime(): uthread2.Sleep(0.25) if session.solarsystemid is None: raise InvalidClientStateError('Solarsystemid is None in session') scene = self.sceneManager.GetRegisteredScene('default') if scene is None: raise InvalidClientStateError('Failed to find the default space scene')
def _LockTarget(self, shipID): for i in xrange(20): try: self.dogmaLM.AddTargetEx(self.bountyEscrowID, shipID, countBias=1, silent=1) break except UserError as e: logger.debug( 'Failed getting a lock because of %s will try again in 1 second', e.msg) uthread2.Sleep(1) else: logger.error('Failed getting a lock in time ') return False return True
def _UpdatePosition(self): while not self._stopUpdate: if self.video: duration = float((self.video.duration or 1) / 1000000) if duration == 0: duration = 1 mediaTime = min( float((self.video.mediaTime or 0) / 1000000) / duration, 1) downloadedTime = min( float( (self.video.downloadedTime or 0) / 1000000) / duration, 1) if mediaTime == 0: self.positionFill.Hide() else: self.positionFill.Show() self.positionFill.width = mediaTime if downloadedTime == 0: self.downloadedFill.Hide() else: self.downloadedFill.Show() self.downloadedFill.width = downloadedTime self._UpdateSubtitles() uthread2.Sleep(0.1)
def _Update_t(self): while not self.destroyed: self._UpdateHelper() uthread2.Sleep(0.25)
def UpdateGraph(self): while not self.destroyed: if not self.isResizing: self.Build() uthread2.Sleep(0.5)
def RefreshAttributes(self): while not self.destroyed: uthread2.Sleep(self.refreshDelay) for each in self.attributes.GetNodes(): if each.panel: each.panel.UpdateValue()
def Refresh(self): while not self.destroyed: uthread2.Sleep(self.refreshDelay) self.PopulateScroll()
def UpdateMouseTracking(self): self.LogInfo('Mouse tracking update thread started') lastSoundStrength = 0.0 activeBracket = None self.sitesUnderCursor = set() self.audio.SetGlobalRTPC('scanner_mouseover', 0) while self.doMouseTrackingUpdates: try: if not self.IsMouseInSpaceView(): if activeBracket is not None: self.DisableMouseOverSound() activeBracket = None lastSoundStrength = 0.0 continue desktopWidth = uicore.desktop.width desktopHeight = uicore.desktop.height mouseX = uicore.uilib.x mouseY = uicore.uilib.y self.currentOverlapCoordinates = (mouseX, mouseY) closestBracket = None bestProximity = None for data in self.siteController.spaceLocations.IterLocations(): self.sitesUnderCursor.discard(data.siteData) bracket = data.bracket if bracket is None or bracket.destroyed: continue if bracket.state == uiconst.UI_DISABLED: continue centerX = bracket.left + bracket.width / 2 centerY = bracket.top + bracket.height / 2 if centerX < 0: continue if centerX > desktopWidth: continue if centerY < 0: continue if centerY > desktopHeight: continue if mouseX < centerX - MAX_MOUSEOVER_RANGE: continue if mouseX > centerX + MAX_MOUSEOVER_RANGE: continue if mouseY < centerY - MAX_MOUSEOVER_RANGE: continue if mouseY > centerY + MAX_MOUSEOVER_RANGE: continue dx = centerX - mouseX dy = centerY - mouseY if -BRACKET_OVERLAP_DISTANCE <= dx <= BRACKET_OVERLAP_DISTANCE and -BRACKET_OVERLAP_DISTANCE <= dy <= BRACKET_OVERLAP_DISTANCE: self.sitesUnderCursor.add(data.siteData) if data.siteData.hoverSoundEvent is None: continue distanceSquared = dx * dx + dy * dy if distanceSquared >= MAX_MOUSEOVER_RANGE_SQUARED: continue proximity = MAX_RTPC_VALUE - distanceSquared / MAX_MOUSEOVER_RANGE_SQUARED * MAX_RTPC_VALUE if closestBracket is not None: if proximity < bestProximity: closestBracket = bracket bestProximity = proximity else: closestBracket = bracket bestProximity = proximity activeBracket, lastSoundStrength = self.UpdateMouseHoverSound( activeBracket, bestProximity, closestBracket, lastSoundStrength) except (ValueError, OverflowError): pass except Exception: LogException('The sound update loop errored out') finally: uthread2.Sleep(0.025) if activeBracket is not None: self.DisableMouseOverSound() self.LogInfo('Mouse tracking update thread ended')
def Update(self): while not self.destroyed: self.UpdateInfo() uthread2.Sleep(0.5)