def UpdateStatusUI(self, tubeStatus):
     stateText = LABEL_BY_STATE[tubeStatus.statusID]
     self.tubeStatusLabel.text = GetByLabel(stateText)
     if self.ShouldShowStationUI():
         stateColor = Color(*COLOR_OPEN)
     else:
         stateColor = Color(*COLOR_BY_STATE[tubeStatus.statusID])
     self.leftTube.SetRGBA(*stateColor.GetRGBA())
     self.rightTube.SetRGBA(*stateColor.GetRGBA())
     stateColor.a = 0.8
     self.tubeStatusLabel.SetTextColor(stateColor.GetRGBA())
 def _GetHilightGlowColor(self):
     if self._colorHiliteGlow:
         return self._colorHiliteGlow
     color = Color(*self._GetHilightColor()).SetBrightness(1.0)
     if color.GetSaturation() > 0.2:
         color.SetSaturation(0.2)
     self._colorHiliteGlow = color.GetRGBA()
     return self._colorHiliteGlow
class ColorPicker(ContainerAutoSize):
    default_name = 'ColorPicker'
    default_alignMode = uiconst.TOTOP

    def ApplyAttributes(self, attributes):
        ContainerAutoSize.ApplyAttributes(self, attributes)
        label = attributes.label
        maxValue = attributes.Get('maxValue', 1.0)
        self.colorCallback = attributes.colorCallback
        self.color = Color(*attributes.color)
        self.initialized = False
        Label(parent=self, align=uiconst.TOTOP, text=label, fontsize=20, left=14)
        Button(parent=self, left=4, top=4, align=uiconst.TOPRIGHT, label='Copy to Clipboard', func=self.CopyToClipboard)
        self.r = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=self.color.r, maxValue=maxValue, label='R', callback=self.OnRChange)
        self.g = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=self.color.g, maxValue=maxValue, label='G', callback=self.OnGChange, padTop=PADTOP)
        self.b = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=self.color.b, maxValue=maxValue, label='B', callback=self.OnBChange, padTop=PADTOP)
        h, s, b = self.color.GetHSB()
        self.h = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=h, maxValue=1.0, label='H', callback=self.OnHChange, padTop=PADTOP + 14)
        self.s = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=s, maxValue=1.0, label='S', callback=self.OnSChange, padTop=PADTOP)
        self.br = ValueSelector(parent=self, align=uiconst.TOTOP, height=18, value=b, maxValue=maxValue, label='B', callback=self.OnBrChange, padTop=PADTOP)
        self.initialized = True

    def UpdateColor(self, color):
        self.color.SetRGB(*color)
        self.UpdateSliders()

    def UpdateSliders(self):
        self.r.SetValue(self.color.r)
        self.g.SetValue(self.color.g)
        self.b.SetValue(self.color.b)
        h, s, br = self.color.GetHSB()
        self.h.SetValue(h)
        self.s.SetValue(s)
        self.br.SetValue(br)

    def UpdateValues(self):
        if not self.initialized:
            return
        self.UpdateSliders()
        self.colorCallback(self.color.GetRGBA())

    def OnRChange(self, slider):
        self.color.SetRGB(slider.GetValue(), self.color.g, self.color.b)
        self.UpdateValues()

    def OnGChange(self, slider):
        self.color.SetRGB(self.color.r, slider.GetValue(), self.color.b)
        self.UpdateValues()

    def OnBChange(self, slider):
        self.color.SetRGB(self.color.r, self.color.g, slider.GetValue())
        self.UpdateValues()

    def OnHChange(self, slider):
        self.color.SetHue(slider.GetValue())
        self.UpdateValues()

    def OnSChange(self, slider):
        self.color.SetSaturation(slider.GetValue())
        self.UpdateValues()

    def OnBrChange(self, slider):
        self.color.SetBrightness(slider.GetValue())
        self.UpdateValues()

    def CopyToClipboard(self, *args):
        data = '(%s, %s, %s)' % self.color.GetRGBRounded()
        blue.win32.SetClipboardData(data)
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     self.controller = SquadronMgmtController()
     self.shipFighterState = GetShipFighterState()
     self.tubeFlagID = attributes.tubeFlagID
     self.leftTube = Sprite(
         parent=self,
         texturePath=
         'res:/UI/Texture/classes/CarrierBay/tubeSideElement.png',
         align=uiconst.TOLEFT_NOPUSH,
         width=15)
     self.rightTube = Sprite(
         parent=self,
         texturePath=
         'res:/UI/Texture/classes/CarrierBay/tubeSideElementRIGHT.png',
         align=uiconst.TORIGHT_NOPUSH,
         width=15)
     inSpaceCont = Container(parent=self, height=86, align=uiconst.TOTOP)
     inSpaceCont.OnDropData = self.OnDropToSpace
     inSpaceCont.GetMenu = self.GetMenu
     self.squadronNumber = SquadronNumber(parent=inSpaceCont, top=1, left=1)
     self.squadronNumber.SetText(self.tubeFlagID)
     self.inStationCont = Container(parent=inSpaceCont, align=uiconst.TOALL)
     cantLaunchIcon = Sprite(
         parent=self.inStationCont,
         width=44,
         height=44,
         align=uiconst.CENTER,
         texturePath='res:/UI/Texture/classes/CarrierBay/unableToLaunch.png'
     )
     self.stateCont = Container(parent=self,
                                height=24,
                                align=uiconst.TOTOP,
                                state=uiconst.UI_NORMAL)
     self.stateContBG = Fill(bgParent=self.stateCont, color=(0, 0, 0, 0))
     deckCont = Container(parent=self,
                          height=86,
                          align=uiconst.TOTOP,
                          state=uiconst.UI_NORMAL)
     deckCont.OnDropData = self.OnDropToTube
     deckCont.GetMenu = self.GetMenu
     self.tubeStatusLabel = EveHeaderSmall(parent=self.stateCont,
                                           align=uiconst.CENTER,
                                           text='')
     self.loadingGauge = Gauge(parent=self.stateCont,
                               align=uiconst.CENTERBOTTOM,
                               backgroundColor=(0, 0, 0, 1),
                               color=(0.2, 0.2, 0.2, 0.5),
                               padLeft=1,
                               padRight=1,
                               top=1,
                               width=75,
                               value=0.0)
     self.loadingGauge.display = False
     spaceColor = Color(*COLOR_INSPACE)
     spaceColor.a = 1.0
     self.launchIcon = ButtonIcon(
         parent=inSpaceCont,
         align=uiconst.CENTER,
         width=86,
         height=86,
         iconSize=44,
         texturePath='res:/UI/Texture/classes/CarrierBay/tubeLaunch_Up.png',
         downTexture=
         'res:/UI/Texture/classes/CarrierBay/tubeLaunch_Down.png',
         hoverTexture=
         'res:/UI/Texture/classes/CarrierBay/tubeLaunch_Over.png',
         iconColor=spaceColor.GetRGBA(),
         showGlow=False)
     self.launchIcon.OnClick = self.LaunchFightersFromTube
     self.launchIcon.OnDropData = self.OnDropToSpace
     returnColor = Color(*COLOR_RETURNING)
     returnColor.a = 1.0
     self.scoopIcon = ButtonIcon(
         parent=deckCont,
         align=uiconst.CENTER,
         width=86,
         height=86,
         iconSize=44,
         texturePath='res:/UI/Texture/classes/CarrierBay/tubeRecall_Up.png',
         downTexture=
         'res:/UI/Texture/classes/CarrierBay/tubeRecall_Down.png',
         hoverTexture=
         'res:/UI/Texture/classes/CarrierBay/tubeRecall_Over.png',
         iconColor=returnColor.GetRGBA(),
         showGlow=False)
     self.scoopIcon.OnClick = self.RecallFighterToTube
     self.scoopIcon.OnDropData = self.OnDropToTube
     self.landingStrip = LandingStrip(parent=deckCont)
     self.landingStrip.display = False
     self.emptyTubeIcon = ButtonIcon(
         parent=deckCont,
         align=uiconst.CENTER,
         width=44,
         height=44,
         iconSize=44,
         texturePath='res:/UI/Texture/classes/CarrierBay/tubeOpen_Up.png',
         downTexture='res:/UI/Texture/classes/CarrierBay/tubeOpen_Down.png',
         hoverTexture='res:/UI/Texture/classes/CarrierBay/tubeOpen_Over.png',
         showGlow=False)
     self.emptyTubeIcon.OnDropData = self.OnDropToTube
     self.squadronInSpace = FightersHealthGauge(name='squadronInSpace',
                                                parent=inSpaceCont,
                                                align=uiconst.CENTER,
                                                width=86,
                                                height=86,
                                                state=TUBE_STATE_INSPACE,
                                                tubeFlagID=self.tubeFlagID)
     self.squadronInSpace.display = False
     self.squadronInSpace.GetMenu = self.GetMenu
     self.squadronInTube = FightersHealthGauge(name='squadronInTube',
                                               parent=deckCont,
                                               align=uiconst.CENTER,
                                               width=86,
                                               height=86,
                                               state=TUBE_STATE_READY,
                                               tubeFlagID=self.tubeFlagID)
     self.squadronInTube.OnDropData = self.OnDropToTube
     self.squadronInTube.display = False
     self.squadronInTube.GetMenu = self.GetMenu
     self.launchingStrip = LaunchingStrip(parent=inSpaceCont)
     self.launchingStrip.display = False
     self.UpdateLaunchTubeContentUI()
     self.UpdateLaunchTubeStateUI()
     self.UpdateInSpaceUI()
     self.shipFighterState.signalOnFighterTubeStateUpdate.connect(
         self.OnFighterTubeStateUpdate)
     self.shipFighterState.signalOnFighterTubeContentUpdate.connect(
         self.OnFighterTubeContentUpdate)
     self.shipFighterState.signalOnFighterInSpaceUpdate.connect(
         self.OnFighterInSpaceUpdate)