def _Rotate(self, uitransform, time, fromRot, toRot, timeFunc): time *= 1000 i = 0 start, ndt = timeFunc(), 0.0 while ndt != 1.0 and not uitransform.destroyed: ndt = max(ndt, min(blue.os.TimeDiffInMs(start, timeFunc()) / time, 1.0)) deg = mathUtil.Lerp(fromRot, toRot, ndt) rad = mathUtil.DegToRad(deg) uitransform.SetRotation(rad) blue.pyos.synchro.Yield()
class CPUGauge(FittingGauge): gaugeRange = 45 default_name = 'cpuGauge' default_colorStart = (0.203125, 0.3828125, 0.37890625, 0.8) default_colorEnd = (0.203125, 0.3828125, 0.37890625, 0.8) default_colorMarker = (1.0, 1.0, 1.0, 0.0) default_startAngle = mathUtil.DegToRad(135) default_clockwise = False default_bgPortion = gaugeRange / 360.0 hintPath = 'UI/Fitting/FittingWindow/CpuState'
def AddSlot(self, parent, flagID): left, top, cos, sin = self.GetPositionNumbers(self.angle) radCosSin = (self.rad, cos, sin, self.center, self.center) ret = self.slotClass(name='%s' % flagID, parent=parent, pos=(left, top, self.width, self.height), rotation=-mathUtil.DegToRad(self.angle), opacity=0.0, radCosSin=radCosSin, controller=self.controller.GetSlotController(flagID)) self.angle += self.stepSize return ret
def MakeArc(self, radius=32.0, outerRadius=66.0, segments=12, fromDeg=0.0, toDeg=90.0, innerColor=default_color, outerColor=default_color, feather=3.0): self.Flush() ro = self.GetRenderObject() segmentStep = (toDeg - fromDeg) / float(segments) TRANSPCOLOR = (0, 0, 0, 0) for i in xrange(segments + 1): a = mathUtil.DegToRad(fromDeg + i * segmentStep) x = math.cos(a) y = math.sin(a) innerVertex = trinity.Tr2Sprite2dVertex() innerVertex.position = (x * radius, y * radius) innerVertex.color = innerColor ro.vertices.append(innerVertex) outerVertex = trinity.Tr2Sprite2dVertex() outerVertex.position = (x * outerRadius, y * outerRadius) outerVertex.color = outerColor ro.vertices.append(outerVertex) for i in xrange(segments * 2): triangle = trinity.Tr2Sprite2dTriangle() triangle.index0 = i triangle.index1 = i + 1 triangle.index2 = i + 2 ro.triangles.append(triangle) if feather: shift = len(ro.vertices) for i in xrange(segments + 1): a = mathUtil.DegToRad(fromDeg + i * segmentStep) x = math.cos(a) y = math.sin(a) innerFeatherVertex = trinity.Tr2Sprite2dVertex() innerFeatherVertex.position = (x * (radius - feather), y * (radius - feather)) innerFeatherVertex.color = TRANSPCOLOR ro.vertices.append(innerFeatherVertex) outerFeatherVertex = trinity.Tr2Sprite2dVertex() outerFeatherVertex.position = (x * (outerRadius + feather), y * (outerRadius + feather)) outerFeatherVertex.color = TRANSPCOLOR ro.vertices.append(outerFeatherVertex) for i in xrange(segments * 2): triangle = trinity.Tr2Sprite2dTriangle() triangle.index0 = i triangle.index1 = shift + i triangle.index2 = shift + i + 2 ro.triangles.append(triangle) triangle = trinity.Tr2Sprite2dTriangle() triangle.index0 = shift + i + 2 triangle.index1 = i + 2 triangle.index2 = i ro.triangles.append(triangle)
def UpdateFitting(self): if self.destroyed: return if not self.controller.SlotExists() and not self.controller.GetModule( ): if self.controller.IsSubsystemSlot( ) and self.controller.parentController.HasStance(): self.HideSlot() else: self.DisableSlot() self.HideChargeIndicator() self.RemoveUtilButtons() return self.EnableSlot() self.SetDragState() if self.controller.GetCharge(): chargeQty = self.controller.GetChargeQuantity() if self.controller.GetModule() is None: portion = 1.0 else: cap = self.controller.GetChargeCapacity() if cap.capacity == 0: portion = 1.0 else: portion = cap.used / cap.capacity step = max(0, min(4, int(portion * 5.0))) self.ConstructChargeIndicator() self.chargeIndicator.rectTop = 10 * step self.chargeIndicator.state = uiconst.UI_NORMAL self.chargeIndicator.hint = '%s %d%%' % (evetypes.GetName( self.controller.GetCharge().typeID), portion * 100) elif not self.controller.GetModule(): self.HideUtilButtons(1) self.HideChargeIndicator() elif self.controller.IsChargeable(): self.ConstructChargeIndicator() self.chargeIndicator.rectTop = 0 self.chargeIndicator.state = uiconst.UI_NORMAL self.chargeIndicator.hint = localization.GetByLabel( 'UI/Fitting/NoCharge') else: self.HideChargeIndicator() if self.controller.GetModule(): self.tooltipPanelClassInfo = TooltipModuleWrapper() modulehint = evetypes.GetName(self.controller.GetModuleTypeID()) if self.controller.GetCharge(): modulehint += '<br>%s' % localization.GetByLabel( 'UI/Fitting/ChargeQuantity', charge=self.controller.GetCharge().typeID, chargeQuantity=chargeQty) if not self.controller.SlotExists(): modulehint = localization.GetByLabel( 'UI/Fitting/SlotDoesNotExist') self.hint = modulehint else: self.tooltipPanelClassInfo = None self.hint = self._emptyHint tooltipName = self._emptyTooltip if tooltipName: SetFittingTooltipInfo(targetObject=self, tooltipName=tooltipName, includeDesc=False) self.PrepareUtilButtons() iconSize = int(48 * GetScaleFactor()) self.flagIcon.SetSize(iconSize, iconSize) if self.controller.GetCharge() or self.controller.GetModule(): self.flagIcon.LoadIconByTypeID( (self.controller.GetCharge() or self.controller.GetModule()).typeID, ignoreSize=True) self.flagIcon.rotation = -self.GetRotation() else: rev = 0 slotIcon = { const.flagSubSystemSlot0: 'res:/UI/Texture/Icons/81_64_9.png', const.flagSubSystemSlot1: 'res:/UI/Texture/Icons/81_64_10.png', const.flagSubSystemSlot2: 'res:/UI/Texture/Icons/81_64_11.png', const.flagSubSystemSlot3: 'res:/UI/Texture/Icons/81_64_12.png', const.flagSubSystemSlot4: 'res:/UI/Texture/Icons/81_64_13.png' }.get(self.controller.GetFlagID(), None) if slotIcon is None: slotIcon = { const.effectLoPower: 'res:/UI/Texture/Icons/81_64_5.png', const.effectMedPower: 'res:/UI/Texture/Icons/81_64_6.png', const.effectHiPower: 'res:/UI/Texture/Icons/81_64_7.png', const.effectRigSlot: 'res:/UI/Texture/Icons/81_64_8.png' }.get(self.controller.GetPowerType(), None) else: rev = 1 if slotIcon is not None: self.flagIcon.LoadIcon(slotIcon, ignoreSize=True) if rev: self.flagIcon.rotation = mathUtil.DegToRad(180.0) else: self.flagIcon.rotation = 0.0 self.SetGroup() self.UpdateOnlineDisplay() self.Hilite(0)
def ApplyAttributes(self, attributes): uiprimitives.Transform.ApplyAttributes(self, attributes) self.degree = attributes.get('degree', 0) self.func = None self.funcArgs = None self.itemID = attributes.itemID self.isDisabled = False self.degreeWidth = attributes.degreeWidth self.labelPath = '' self.labelText = '' self.isEmpty = attributes.get('isEmpty', False) self.commandName = None self.isHilighted = False self.fullWidth = attributes.sizeInfo.buttonWidth self.fullHeight = attributes.sizeInfo.buttonHeight iconPar = uiprimitives.Transform(parent=self, name='iconPar', pos=(0, 3, 32, 32), state=uiconst.UI_DISABLED, align=uiconst.CENTER) iconPar.rotation = mathUtil.DegToRad(self.degree) self.icon = GlowSprite(parent=iconPar, name='icon', pos=(0, 0, 32, 32), state=uiconst.UI_DISABLED, align=uiconst.CENTER) selectionSlice = SpriteUnderlay(parent=self, name='selectionSlice', state=uiconst.UI_DISABLED, texturePath=self.selelectedBasePath % self.degreeWidth, align=uiconst.TOALL, opacity=0.9) selectionSlice.display = False self.selectionSlice = selectionSlice if self.isEmpty: sliceTexturePath = self.emptySliceBasePath % self.degreeWidth else: sliceTexturePath = self.sliceBasePath % self.degreeWidth self.hilite = SpriteUnderlay(parent=self, name='hilite', state=uiconst.UI_DISABLED, texturePath=self.selelectedBasePath % self.degreeWidth, align=uiconst.TOALL, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.0) self.availableSlice = SpriteUnderlay(parent=self, name='availableSlice', state=uiconst.UI_DISABLED, texturePath=sliceTexturePath, align=uiconst.TOALL, opacity=attributes.get( 'buttonBackgroundOpacity', 0.8)) self.unavailableSlice = SpriteUnderlay( parent=self, name='unavailableSlice', state=uiconst.UI_DISABLED, texturePath=sliceTexturePath, align=uiconst.TOALL, colorType=uiconst.COLORTYPE_UIBASE, opacity=0.85) self.unavailableSlice.display = False self.sliceInUse = self.availableSlice
def SetFitting(self, invItem, shell=None, putOnline=0): if self.destroyed: return lg.Info('fitting', 'SetFitting', self.flag, invItem and cfg.invtypes.Get(invItem.typeID).Group().name) if invItem is None: self.DisableDrag() else: self.EnableDrag() self.shell = shell or self.shell if invItem and self.IsCharge(invItem.typeID): self.charge = invItem chargeQty = self.shell.GetQuantity(invItem.itemID) if self.module is None: portion = 1.0 else: cap = self.shell.GetCapacity(self.module.locationID, const.attributeCapacity, self.flag) if cap.capacity == 0: portion = 1.0 else: portion = cap.used / cap.capacity step = max(0, min(4, int(portion * 5.0))) self.sr.chargeIndicator.rectTop = 10 * step self.sr.chargeIndicator.state = uiconst.UI_NORMAL self.sr.chargeIndicator.hint = '%s %d%%' % (cfg.invtypes.Get( self.charge.typeID).name, portion * 100) elif invItem is None: self.id = None self.isChargeable = 0 self.typeID = None self.module = None self.charge = None self.fitted = 0 self.isChargeable = 0 self.HideUtilButtons(1) self.sr.chargeIndicator.state = uiconst.UI_HIDDEN else: self.id = invItem.itemID self.typeID = invItem.typeID self.module = invItem self.fitted = 1 self.charge = None if invItem.groupID in cfg.__chargecompatiblegroups__: self.isChargeable = 1 self.sr.chargeIndicator.rectTop = 0 self.sr.chargeIndicator.state = uiconst.UI_NORMAL self.sr.chargeIndicator.hint = localization.GetByLabel( 'UI/Fitting/NoCharge') else: self.isChargeable = 0 self.sr.chargeIndicator.state = uiconst.UI_HIDDEN if self.typeID: self.tooltipPanelClassInfo = TooltipModuleWrapper() modulehint = cfg.invtypes.Get(self.typeID).name if self.charge: modulehint += '<br>%s' % localization.GetByLabel( 'UI/Fitting/ChargeQuantity', charge=self.charge.typeID, chargeQuantity=chargeQty) shipID = self.GetShipID() if not self.shell.SlotExists(shipID, self.module.flagID): modulehint = localization.GetByLabel( 'UI/Fitting/SlotDoesNotExist') self.hint = modulehint else: self.tooltipPanelClassInfo = None self.hint = self._emptyHint tooltipName = self._emptyTooltip if tooltipName: SetFittingTooltipInfo(targetObject=self, tooltipName=tooltipName, includeDesc=False) self.opacity = 1.0 self.state = uiconst.UI_NORMAL self.PrepareUtilButtons() if putOnline: uthread.new(self.DelayedOnlineAttempt, eve.session.shipid, invItem.itemID) icon = self.sr.flagIcon icon.SetAlign(uiconst.CENTER) iconSize = int(48 * self.scaleFactor) icon.SetSize(iconSize, iconSize) icon.SetPosition(0, 0) if self.charge or self.module: icon.LoadIconByTypeID((self.charge or self.module).typeID, ignoreSize=True) icon.parent.SetRotation(-self.GetRotation()) else: rev = 0 slotIcon = { const.flagSubSystemSlot0: 'ui_81_64_9', const.flagSubSystemSlot1: 'ui_81_64_10', const.flagSubSystemSlot2: 'ui_81_64_11', const.flagSubSystemSlot3: 'ui_81_64_12', const.flagSubSystemSlot4: 'ui_81_64_13' }.get(self.flag, None) if slotIcon is None: slotIcon = { const.effectLoPower: 'ui_81_64_5', const.effectMedPower: 'ui_81_64_6', const.effectHiPower: 'ui_81_64_7', const.effectRigSlot: 'ui_81_64_8' }.get(self.powerType, None) else: rev = 1 if slotIcon is not None: icon.LoadIcon(slotIcon, ignoreSize=True) if rev: icon.parent.SetRotation(mathUtil.DegToRad(180.0)) else: icon.parent.SetRotation(0.0) icon.state = uiconst.UI_PICKCHILDREN self.SetGroup() self.UpdateOnlineDisplay() self.Hilite(0)