class SpeedGauge(Container): default_name = 'SpeedGauge' default_width = 124 default_height = 36 default_state = uiconst.UI_NORMAL def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.controller = attributes.controller self.wantedspeed = None self.speedTimer = None self.speedInited = 0 self.speedCircularPickParent = Container( name='speedCircularPickParent', parent=self, align=uiconst.CENTERBOTTOM, pos=(0, 0, 144, 144), pickRadius=72) self.speedGaugeParent = Container(parent=self.speedCircularPickParent, name='speedGaugeParent', pos=(0, 0, 124, 36), align=uiconst.CENTERBOTTOM, state=uiconst.UI_DISABLED, clipChildren=True) self.speedLabel = EveLabelSmall(name='speedLabel', parent=self.speedGaugeParent, color=Color.BLACK, align=uiconst.CENTER) Sprite(parent=self.speedCircularPickParent, name='speedoUnderlay', pos=(0, 48, 104, 44), align=uiconst.CENTER, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ShipUI/speedoUnderlay.png') self.speedNeedle = Transform(parent=self.speedGaugeParent, name='speedNeedle', pos=(-5, -38, 134, 12), align=uiconst.TOPLEFT, state=uiconst.UI_PICKCHILDREN, rotationCenter=(0.5, 0.5)) Sprite( parent=self.speedNeedle, name='needle', pos=(0, 0, 24, 12), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ShipUI/heatGaugeNeedle.png') Sprite(parent=self.speedNeedle, name='speedGaugeSprite', texturePath='res:/UI/Texture/classes/ShipUI/speedoOverlay.png', pos=(-8, -73, 79, 79), state=uiconst.UI_DISABLED) self.speedTimer = uthread.new(self.UpdateSpeedThread) def OnClick(self, *args): uthread.new(self.controller.SetSpeed, self.GetCurrMouseSpeedPortion()) def LoadTooltipPanel(self, tooltipPanel, *args): tooltipPanel.LoadGeneric3ColumnTemplate() iconObj, labelObj, valueObj = tooltipPanel.AddIconLabelValue( 'ui_22_32_13', GetByLabel('Tooltips/Hud/CurrentSpeed'), '', iconSize=24) setattr(tooltipPanel, '_valueLabelSpeed', valueObj) tooltipPanel.AddSpacer(width=2, height=2) tooltipPanel._setSpeedValue = tooltipPanel.AddLabelMedium( colSpan=tooltipPanel.columns - 1, width=180) self._UpdateSpeedTooltip(tooltipPanel) self._speedTooltipUpdate = AutoTimer(10, self._UpdateSpeedTooltip, tooltipPanel) def _UpdateSpeedTooltip(self, tooltipPanel): if tooltipPanel.destroyed: self._speedTooltipUpdate = None return if not self.controller.IsLoaded(): self._speedTooltipUpdate = None return if self.controller.IsInWarp(): fmtSpeed = FmtDist(self.controller.GetSpeed(), 2) tooltipPanel._valueLabelSpeed.text = '%s/s' % fmtSpeed tooltipPanel._setSpeedValue.text = GetByLabel( 'UI/Inflight/CanNotChangeSpeedWhileWarping') else: fmtSpeed = self.controller.GetSpeedFormatted() tooltipPanel._valueLabelSpeed.text = fmtSpeed portion = self.GetCurrMouseSpeedPortion() speed = self.controller.GetSpeedAtFormatted(portion) tooltipPanel._setSpeedValue.text = GetByLabel( 'UI/Inflight/ClickToSetSpeedTo', speed=speed) def StopShip(self): self.controller.StopShip() @telemetry.ZONE_FUNCTION def UpdateSpeedThread(self): while not self.destroyed: blue.synchro.Sleep(20) try: if not self.controller.IsLoaded(): continue if not (self.controller.GetBall() and self.controller.GetBall().ballpark): continue speedPortion = self.controller.GetSpeedPortion() self.speedNeedle.SetRotation( DegToRad(45.0 + 90.0 * speedPortion)) if self.controller.IsInWarp(): fmtSpeed = GetByLabel('UI/Inflight/WarpSpeedNotification', warpingMessage=GetByLabel( 'UI/Inflight/Scanner/Warping')) else: fmtSpeed = self.controller.GetSpeedFormatted() self.speedLabel.text = fmtSpeed except Exception as e: log.LogException(e) sys.exc_clear() def GetCurrMouseSpeedPortion(self): l, t, w, h = self.speedCircularPickParent.GetAbsolute() centerX = l + w / 2 centerY = t + h / 2 y = float(uicore.uilib.y - centerY) x = float(uicore.uilib.x - centerX) if x and y: angle = math.atan(x / y) deg = angle / math.pi * 180.0 factor = (45.0 + deg) / 90.0 if factor < 0.05: return 0.0 elif factor > 0.95: return 1.0 else: return factor return 0.5
def SetRotation(self, rotation=0): Transform.SetRotation(self, rotation)
class ShipModuleButtonRamps(Container): default_height = 64 default_width = 64 default_align = uiconst.TOPLEFT default_state = uiconst.UI_DISABLED default_opacity = 0.5 def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) leftTexture = 'res:/UI/Texture/classes/ShipUI/slotRampLeft.png' leftRampCont = Container(parent=self, name='leftRampCont', pos=(0, 0, 32, 64), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, clipChildren=True) self.leftRamp = Transform(parent=leftRampCont, name='leftRamp', pos=(0, 0, 64, 64), align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL) rampLeftSprite = Sprite(parent=self.leftRamp, name='rampLeftSprite', pos=(0, 0, 32, 64), state=uiconst.UI_DISABLED, texturePath=leftTexture) self.leftShadowRamp = Transform(parent=leftRampCont, name='leftShadowRamp', pos=(0, 1, 64, 64), align=uiconst.TOPLEFT, state=uiconst.UI_HIDDEN) shadow = Sprite(parent=self.leftShadowRamp, name='rampSprite', pos=(0, 0, 32, 64), state=uiconst.UI_DISABLED, texturePath=leftTexture, color=(0, 0, 0, 1)) rightTexture = 'res:/UI/Texture/classes/ShipUI/slotRampRight.png' rightRampCont = Container(parent=self, name='rightRampCont', pos=(32, 0, 32, 64), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, clipChildren=True) self.rightRamp = Transform(parent=rightRampCont, name='rightRamp', pos=(-32, 0, 64, 64), align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL) rampRightSprite = Sprite(parent=self.rightRamp, name='rampRightSprite', pos=(32, 0, 32, 64), state=uiconst.UI_DISABLED, texturePath=rightTexture) self.rightShadowRamp = Transform(parent=rightRampCont, name='rightShadowRamp', pos=(-32, 1, 64, 64), align=uiconst.TOPLEFT, state=uiconst.UI_HIDDEN) shadow = Sprite(parent=self.rightShadowRamp, name='rampSprite', pos=(32, 0, 32, 64), state=uiconst.UI_DISABLED, texturePath=rightTexture, color=(0, 0, 0, 1)) self.display = False def SetRampValues(self, portionDone): self.SetRampUpValue(portionDone) self.SetRampDownValue(portionDone) def SetRampUpValue(self, portionDone): rampUpVal = min(1.0, max(0.0, portionDone * 2)) newValue = math.pi * (1 - rampUpVal) self.leftRamp.SetRotation(newValue) self.leftShadowRamp.SetRotation(newValue) def SetRampDownValue(self, portionDone): rampDownVal = min(1.0, max(0.0, portionDone * 2 - 1.0)) newValue = math.pi * (1 - rampDownVal) self.rightRamp.SetRotation(newValue) self.rightShadowRamp.SetRotation(newValue) if newValue == 1.0: self.rightRamp.SetRotation(math.pi) self.rightShadowRamp.SetRotation(math.pi) self.leftRamp.SetRotation(math.pi) self.leftShadowRamp.SetRotation(math.pi) def AnimateReload(self, startTime, repairTime): self.SetRampValues(1) percentageDone = 0 while self and not self.destroyed and percentageDone < 1: newNow = blue.os.GetSimTime() percentageDone = (newNow - startTime) / float(repairTime) self.SetRampValues(1 - percentageDone) self.display = True blue.pyos.synchro.Yield()