Exemple #1
0
 def ApplyAttributes(self, attributes):
     uiprimitives.Transform.ApplyAttributes(self, attributes)
     text = attributes.text
     self.func = attributes.func
     self.actionID = attributes.actionID
     self.isEnabled = attributes.isEnabled
     isReversed = attributes.get('isReversed', self.default_isReversed)
     color = COLOR_BRACKET
     colorGradient = util.Color(*color).SetBrightness(0.4).SetAlpha(self.GRADIENT_ALPHA_IDLE).GetRGBA()
     colorEdges = util.Color(*color).SetBrightness(0.5).GetRGBA()
     self.mainTransform = uiprimitives.Transform(name='mainTransform', parent=self, align=uiconst.TOALL, scalingCenter=(0.5, 0.5), scale=((1, -1)[isReversed], 1.0))
     topCont = uiprimitives.Container(name='topCont', parent=self.mainTransform, align=uiconst.TOTOP, height=5, state=uiconst.UI_DISABLED)
     uiprimitives.Sprite(name='topGradientLeft', parent=topCont, texturePath='res:/UI/Texture/Classes/EntityBracket/topGradientLeft.png', align=uiconst.TOLEFT, width=57, color=colorEdges)
     uiprimitives.Sprite(name='topWedge', parent=topCont, texturePath='res:/UI/Texture/Classes/EntityBracket/topWedge.png', align=uiconst.TORIGHT, width=55, color=colorEdges)
     uiprimitives.Sprite(name='topMiddle', parent=topCont, texturePath='res:/UI/Texture/Classes/EntityBracket/topMiddle.png', align=uiconst.TOALL, color=colorEdges)
     self.wedge = uiprimitives.Sprite(name='wedge', parent=topCont, texturePath='res:/UI/Texture/Classes/EntityBracket/wedge.png', align=uiconst.TOPRIGHT, pos=(11,
      self.WEDGE_TOP,
      33,
      4), color=color)
     bottomCont = uiprimitives.Container(name='bottomCont', parent=self.mainTransform, align=uiconst.TOBOTTOM, height=4, state=uiconst.UI_DISABLED)
     uiprimitives.Sprite(name='bottomWedgeLeft', parent=bottomCont, texturePath='res:/UI/Texture/Classes/EntityBracket/bottomWedgeLeft.png', align=uiconst.TOLEFT, width=57, color=colorEdges)
     uiprimitives.Sprite(name='bottom', parent=bottomCont, texturePath='res:/UI/Texture/Classes/EntityBracket/bottom.png', align=uiconst.TOALL, color=colorEdges)
     self.gradient = uiprimitives.Container(name='gradientCont', parent=self.mainTransform, state=uiconst.UI_DISABLED, padTop=-3, padBottom=-3)
     gradientTopCont = uiprimitives.Container(name='gradientTopCont', align=uiconst.TOTOP, parent=self.gradient, height=4)
     uiprimitives.Sprite(name='gradientTopWedge', parent=gradientTopCont, texturePath='res:/UI/Texture/Classes/EntityBracket/gradientTopWedge.png', align=uiconst.TORIGHT, width=55, color=colorGradient)
     uiprimitives.Sprite(name='gradientTop', parent=gradientTopCont, texturePath='res:/UI/Texture/Classes/EntityBracket/gradientTop.png', align=uiconst.TOALL, color=colorGradient)
     gradientBottomCont = uiprimitives.Container(name='gradientBottomCont', align=uiconst.TOBOTTOM, parent=self.gradient, height=3)
     uiprimitives.Sprite(name='gradientBottomWedge', parent=gradientBottomCont, texturePath='res:/UI/Texture/Classes/EntityBracket/gradientBottomWedge.png', align=uiconst.TOLEFT, width=57, color=colorGradient)
     uiprimitives.Sprite(name='gradientBottom', parent=gradientBottomCont, texturePath='res:/UI/Texture/Classes/EntityBracket/gradientBottom.png', align=uiconst.TOALL, color=colorGradient)
     uiprimitives.Sprite(name='gradientTopWedge', parent=self.gradient, texturePath='res:/UI/Texture/Classes/EntityBracket/gradientMiddle.png', align=uiconst.TOALL, color=colorGradient)
     self.label = uicontrols.Label(parent=self, align=uiconst.CENTER, text=text, top=1, fontsize=16, color=color)
     self.width = max(self.label.width + 60, 150)
     if not self.isEnabled:
         self.mainTransform.opacity = self.label.opacity = 0.2
Exemple #2
0
class Colors:
    __guid__ = 'crimewatchConst.Colors'
    Red = util.Color(221, 0, 0)
    Yellow = util.Color(251, 179, 56)
    Green = util.Color(41, 242, 75)
    Turquoise = util.Color(0.0, 0.63, 0.57, 1.0)
    Suspect = Yellow
    Criminal = Red
    Engagement = Turquoise
Exemple #3
0
 def _CreateGradient(self, parent, color):
     colBase = util.Color(*color).GetRGB()
     colBright = util.Color(*color)
     colBright = colBright.SetBrightness(
         min(1.0, 2.0 * colBright.GetBrightness())).GetRGB()
     return uicls.GradientSprite(align=uiconst.TOALL,
                                 parent=parent,
                                 rotation=-pi / 2,
                                 rgbData=[(0, colBright), (0.5, colBase),
                                          (1.0, colBase)],
                                 alphaData=[(0, 1.0)])
Exemple #4
0
    def HighlightCont(self, cont, updateAttrsCont=True):
        self.CleanContHighLight()
        ancestors = self.GetAncestors(cont)
        children = getattr(cont, 'children', [])
        background = getattr(cont, 'background', [])
        numTotal = len(ancestors) + len(children) + 1
        num = 0
        for contList, hlList in ((ancestors, self.ancestorConts),
                                 (children, self.childrenConts),
                                 (background, self.backgroundConts)):
            for c in contList:
                if c == self.highlightCont:
                    continue
                color = self.GetColor(num, numTotal)
                hlCont = HighlightCont(parent=self.highlightCont,
                                       pos=c.GetAbsolute(),
                                       cont=c,
                                       color=color.GetRGBA(),
                                       show=False)
                hlList.append((c, hlCont, color))
                num += 1

        color = util.Color('RED')
        hlCont = HighlightCont(parent=self.highlightCont,
                               pos=cont.GetAbsolute(),
                               cont=cont,
                               color=color.GetRGBA(),
                               show=self.showHighlite)
        self.selectedCont = (cont, hlCont, color)
        if updateAttrsCont:
            self.UpdateAttributeCont(cont)
        desktop = self.GetDesktop(cont)
        self.highlightCont.SetParent(desktop, 0)
        self.UpdateScroll()
 def ApplyAttributes(self, attributes):
     uiprimitives.Container.ApplyAttributes(self, attributes)
     self.headID = attributes.headID
     self.ecuID = attributes.ecuID
     self.value = attributes.get('value', None)
     self.pin = attributes.pin
     self.overlapValue = None
     self.fill = uiprimitives.Fill(
         parent=self,
         align=uiconst.TOTOP,
         height=self.default_height,
         color=util.Color(*util.Color.WHITE).SetAlpha(0.1).GetRGBA(),
         state=uiconst.UI_HIDDEN,
         idx=0)
     self.icon = uicontrols.Icon(parent=self,
                                 icon='ui_77_32_38',
                                 size=self.default_height,
                                 ignoreSize=True,
                                 state=uiconst.UI_DISABLED,
                                 left=-2)
     self.label = SubTextLabel(parent=self,
                               text='',
                               left=self.default_height,
                               top=4)
     self.SetValue(self.value)
 def Animate(self, num):
     blue.synchro.SleepWallclock(num * 800)
     while not self.destroyed:
         duration = 5.0 * self.intensity
         color = util.Color(*hackingUIConst.COLOR_EXPLORED).SetAlpha(
             0.1 + 0.4 * random.random()).GetRGBA()
         self.sprite.SetRGB(*color)
         self.rotation = random.choice((0, pi))
         uicore.animations.Tr2DRotateTo(self,
                                        self.rotation,
                                        self.rotation + random.choice(
                                            (0.05, -0.05)),
                                        duration=duration)
         uicore.animations.Tr2DScaleTo(self, (0.9, 0.9), (1.0, 1.0),
                                       duration=duration)
         uicore.animations.FadeTo(self,
                                  0.0,
                                  1.0,
                                  duration=duration,
                                  curveType=uiconst.ANIM_WAVE)
         x = 0.5 * random.random() - 0.4 * self.intensity + 0.5
         sleepTime = duration * (0.2 + 0.8 * x)
         blue.synchro.SleepWallclock(sleepTime * 1000)
         self.StopAnimations()
         uicore.animations.BlinkOut(self)
         blue.synchro.SleepWallclock(1000)
Exemple #7
0
    def AnimShowTree(self, isAtTop, btnOffsetX, btnOffsetY):
        longLineHeight = 80
        hexHeight = 14
        linePad = 5
        numButtons = len(self.buttonCont.children)
        align = [uiconst.CENTERBOTTOM, uiconst.CENTERTOP][isAtTop]
        itemAlign = [uiconst.TOTOP, uiconst.TOBOTTOM][isAtTop]
        lineTexturePaths = ('res:/UI/Texture/Classes/EntityBracket/line1.png', 'res:/UI/Texture/Classes/EntityBracket/line2.png')
        longLineTexture = ('res:/UI/Texture/Classes/EntityBracket/longLineBottom.png', 'res:/UI/Texture/Classes/EntityBracket/longLineTop.png')[isAtTop]
        height = numButtons * btnOffsetY + longLineHeight + hexHeight / 2
        if not isAtTop:
            height -= btnOffsetY
        treeMainCont = uiprimitives.Container(parent=self.treeCont, align=align, width=2 * btnOffsetX, height=height)
        longLine = uiprimitives.Sprite(parent=treeMainCont, texturePath=longLineTexture, align=itemAlign, color=COLOR_BRACKET, height=longLineHeight, padLeft=linePad, padRight=linePad)
        longLine.opacity = 0.0
        for i, b in enumerate(self.buttonCont.children):
            hexCont = uiprimitives.Container(parent=treeMainCont, align=itemAlign, height=hexHeight)
            hexColor = util.Color(*COLOR_BRACKET).SetAlpha(0.4).GetRGBA()
            hexLeft = (1, -1)[(isAtTop + i) % 2] * btnOffsetX
            uiprimitives.Sprite(parent=hexCont, texturePath='res:/UI/Texture/Classes/EntityBracket/hex.png', color=hexColor, align=uiconst.CENTER, pos=(hexLeft,
             0,
             hexHeight,
             hexHeight), padding=-2)
            if i != numButtons - 1:
                line = uiprimitives.Sprite(parent=treeMainCont, texturePath=lineTexturePaths[i % 2], align=itemAlign, color=COLOR_BRACKET, height=btnOffsetY - hexHeight, padLeft=linePad, padRight=linePad)

        for c in treeMainCont.children:
            c.opacity = 0.0

        for c in treeMainCont.children:
            uicore.animations.FadeIn(c, duration=0.8)
            blue.synchro.SleepWallclock(100)
 def OnMouseEnter(self, *args):
     if self.data.subtype == hackingConst.SUBTYPE_NONE or self.data.isInUse:
         return
     color = util.Color(*self.color).SetBrightness(1.0).GetRGBA()
     uicore.animations.SpColorMorphTo(self.iconSprite,
                                      self.iconSprite.GetRGBA(),
                                      color,
                                      duration=0.3)
     uicore.animations.FadeIn(self.mouseHoverSprite, duration=0.3)
Exemple #9
0
 def OnValueChanged(self, bar, value, *args):
     if not self or self.destroyed:
         return
     HUEMAX = 0.6
     hue = HUEMAX * max(0.0, 1.0 - value)
     color = util.Color().SetHSB(hue, 0.7, 0.8, 1.0).GetRGBA()
     self.bar.color.SetRGB(*color)
     self.bar.top = self.GetTopFromValue(value)
     self.value = value
 def _FlashStateColor(self):
     CYCLETIME = 3.0
     t = 0.0
     while not self.destroyed:
         if self.stateColor:
             t += 1.0 / blue.os.fps % CYCLETIME
             x = math.sin(2 * math.pi * t / CYCLETIME) * 0.2 + 0.3
             color = util.Color(*self.stateColor).SetAlpha(x)
             self.stateColorFill.color.SetRGB(*color.GetRGBA())
         blue.pyos.synchro.Yield()
Exemple #11
0
 def __init__(self, name):
     global MATERIAL_REGISTRY
     
     self.name = name
     
     self.texture_ids = set()
     
     self.k_a = util.Color(0.2, 0.2, 0.2)
     self.k_d = util.Color(0.8, 0.8, 0.8)
     self.k_s = util.Color(0.1, 0.1, 0.1)
     self.k_e = util.Color(0., 0., 0.)
     self.t_f = util.Color(1., 1., 1.)
     self.illum = 0
     self.d = 1.
     self.n_s = 100
     self.sharpness = 60
     self.n_i = 1.
     
     MATERIAL_REGISTRY[name] = self
Exemple #12
0
  def render(self, streams, count = 100):
    accounts = json.loads(self.model.accounts.List())
    accounts = dict((a["id"], a) for a in accounts)
    messages = []
    seen = {}
    time = 0
    orderby = "time"
    order = "desc"
    limit = 50

    if len(streams) == 1:
      # get message data for selected stream
      # stream, account, time, transient, recipient, orderby, order, limit
      msgs = json.loads(self.model.streams.Messages(streams[0]["stream"] or "all", streams[0]["account"] or "all", time, streams[0]["transient"] or "0", streams[0].has_key("recipient") and streams[0]["recipient"] or "0", orderby, order, limit))
     
      for item in msgs:
        message = item
        message["dupes"] = []
        message["txtid"] = util.remove_urls(message["text"]).strip()[:MAX_MESSAGE_LENGTH] or None
        message["color"] = util.Color(accounts.get(message["account"], {"color": "#5A5A5A"})["color"])
        message["time_string"] = util.generate_time_string(message["time"])
        try:
          message["sender"]["image"] = resources.get_avatar_path(message["sender"]["image"])
        except:
          pass
        messages.append(message)

    def dupematch(item, message):
      if item["service"] == message["service"] and item["mid"] == message["mid"]:
        return True

      for item in item["dupes"]:
        if item["service"] == message["service"] and item["mid"] == message["mid"]:
          return True

    # Detect duplicates
    for n, message in enumerate(messages):
      message["is_dupe"] = message["txtid"] in seen
      if message["is_dupe"]:
        item = messages[seen[message["txtid"]]]
        if not dupematch(item, message):
          item["dupes"].append(message)
      else:
        if message["txtid"]:
          seen[message["txtid"]] = n

    messages = [m for m in messages if not m["is_dupe"]]

    WebUi.render(self, self.model.settings["theme"], "template.mako",
        message_store=messages,
        preferences=self.model.settings,
        services=self.model.services,
        accounts=accounts)

    return [m["txtid"] for m in messages]
Exemple #13
0
    def ApplyAttributes(self, attributes):
        uiprimitives.Container.ApplyAttributes(self, attributes)
        color = attributes.Get('color', util.Color.WHITE)
        backgroundColor = attributes.Get('backgroundColor', None)
        self.value = attributes.Get('value', 0.0)
        self.uiEffects = uicls.UIEffects()
        self.busy = False
        self.queuedSetValue = None
        self.gaugeCont = uiprimitives.Container(parent=self, name='gaugeCont', pos=(0,
         0,
         self.width,
         self.height), align=uiconst.TOPLEFT)
        uicontrols.Frame(parent=self.gaugeCont, color=(1.0, 1.0, 1.0, 0.2))
        self.gauge = uiprimitives.Fill(parent=self.gaugeCont, name='gauge', align=uiconst.TOLEFT, width=0, color=color)
        if backgroundColor is None:
            backgroundColor = util.Color(*color).SetAlpha(0.2).GetRGBA()
        uiprimitives.Fill(parent=self.gaugeCont, name='background', color=backgroundColor)
        testString = ''.join(self.HEXDIGITS)
        fontSize = 1
        textHeight = uix.GetTextHeight(testString, fontsize=fontSize)
        while textHeight < self.height:
            fontSize += 1
            textHeight = uix.GetTextHeight(testString, fontsize=fontSize)
        else:
            fontSize -= 1
            textHeight = uix.GetTextHeight(testString, fontsize=fontSize)

        self.textCont = uiprimitives.Container(parent=self, name='textCont', pos=(0,
         0,
         self.width,
         textHeight), align=uiconst.CENTER, clipChildren=True, idx=0)
        self.text = uicontrols.Label(parent=self.textCont, name='hackText', align=uiconst.TOALL, fontsize=fontSize, text='')
        hackText = random.choice(self.HEXDIGITS)
        while uix.GetTextWidth(hackText[1:], fontsize=fontSize) < self.width:
            hackText += random.choice(self.HEXDIGITS)

        self.text.text = hackText
        self.SetValueInstantly(self.value)
        self.hackStrings = ['Hacking Gibson...',
         'Cracking Codes...',
         'Inserting Rootkit...',
         'Defeating ICE...',
         'Circumventing Firewall...',
         'Polymorphing Virii...',
         'Erasing Logs...',
         'Reticulating Splines...',
         'Twisting Mersenne...',
         'Curving Ellipses...',
         'Analyzing Ciphers...',
         'Factoring Primes...']
        self.hackText = uicontrols.EveHeaderMedium(text='', parent=self, align=uiconst.CENTERBOTTOM, height=20, state=uiconst.UI_HIDDEN, top=-24)
        self.active = True
        uthread.new(self._CycleText)
Exemple #14
0
  def render(self, streams, count = 100):
    accounts = json.loads(self.model.accounts.List())
    accounts = dict((a["id"], a) for a in accounts)
    messages = []
    seen = {}

    if len(streams) == 1 and "sql" in streams[0]:
      with sqlite3.connect(SQLITE_DB_FILENAME) as db:
        data = db.execute("%s order by time desc limit %s" % (streams[0]["sql"], count)).fetchall()
        msgs = json.loads("[%s]" % ",".join(i[0] for i in data))
      
      for item in msgs:
        message = item
        message["dupes"] = []
        message["txtid"] = util.remove_urls(message["text"]).strip()[:MAX_MESSAGE_LENGTH] or None
        message["color"] = util.Color(accounts.get(message["account"], {"color": "#5A5A5A"})["color"])
        message["time_string"] = util.generate_time_string(message["time"])
        try:
          message["sender"]["image"] = resources.get_avatar_path(message["sender"]["image"])
        except:
          pass
        messages.append(message)

    def dupematch(item, message):
      if item["service"] == message["service"] and item["mid"] == message["mid"]:
        return True

      for item in item["dupes"]:
        if item["service"] == message["service"] and item["mid"] == message["mid"]:
          return True

    # Detect duplicates
    for n, message in enumerate(messages):
      message["is_dupe"] = message["txtid"] in seen
      if message["is_dupe"]:
        item = messages[seen[message["txtid"]]]
        if not dupematch(item, message):
          item["dupes"].append(message)
      else:
        if message["txtid"]:
          seen[message["txtid"]] = n

    messages = [m for m in messages if not m["is_dupe"]]

    WebUi.render(self, self.model.settings["theme"], "template.mako",
        message_store=messages,
        preferences=self.model.settings,
        services=self.model.services,
        accounts=accounts)

    return [m["txtid"] for m in messages]
 def SetValue(self, value):
     if value == self.value:
         return
     uicore.animations.MorphScalar(self.bar,
                                   'height',
                                   self.bar.height,
                                   value / self.maxValue,
                                   duration=0.6)
     color = util.Color(*self.color).SetBrightness(1.0).GetRGBA()
     uicore.animations.SpColorMorphTo(self.barTexture,
                                      color,
                                      self.barTexture.GetRGBA(),
                                      duration=0.6)
     self.value = value
 def _SetStateInfo(self):
     if self.pin.IsInEditMode():
         self.stateColor = util.Color.WHITE
         self.stateInfoText = localization.GetByLabel(
             'UI/PI/Common/EditsPending')
         flash = True
     elif self.pin.IsActive():
         self.stateColor = util.Color('GREEN').SetAlpha(0.4).GetRGBA()
         self.stateInfoText = localization.GetByLabel(
             'UI/PI/Common/SurveyProgramRunning')
         flash = False
     else:
         self.stateColor = util.Color.WHITE
         self.stateInfoText = localization.GetByLabel('UI/Common/Idle')
         flash = True
     self.FlashStateColor(flash)
Exemple #17
0
    def LoadCase(self, labels = True):
        self.main.Flush()
        self.caseNum = util.Clamp(self.caseNum, 0, len(self.cases) - 1)
        self.UpdateCaption()
        case = self.cases[self.caseNum]
        self.colorFills = []
        for contParams in case:
            self.AddContainer(self.main, contParams, 0, label=labels)

        numConts = len(self.colorFills)
        for i, fill in enumerate(self.colorFills):
            hue = 0.1 * i
            while hue > 1:
                hue = hue - 1

            fill.color.SetRGB(*util.Color('BLUE').SetHSB(hue, 1.0, 0.8).SetAlpha(1.0).GetRGBA())
 def _AnimateIconBG(self):
     color = util.Color(
         *hackingUIConst.COLOR_DATACACHE).SetAlpha(0.5).GetRGBA()
     uicore.animations.SpColorMorphTo(self.iconBG,
                                      self.iconBG.GetRGBA(),
                                      color,
                                      duration=1.0,
                                      callback=self.AnimateIconBG,
                                      sleep=True)
     if self.animateIconThread:
         self.animateIconThread.kill()
     uicore.animations.FadeTo(self.iconBG,
                              0.5,
                              0.85,
                              duration=5.0,
                              curveType=uiconst.ANIM_WAVE,
                              loops=uiconst.ANIM_REPEAT)
Exemple #19
0
 def ApplyAttributes(self, attributes):
     uiprimitives.Container.ApplyAttributes(self, attributes)
     cont = attributes.Get('cont')
     color = attributes.Get('color', util.Color.WHITE)
     show = attributes.Get('show', True)
     l, t, w, h = attributes.Get('pos', (0, 0, 0, 0))
     self.renderState = STATE_NORMAL
     self.oldState = STATE_NORMAL
     uicontrols.Frame(bgParent=self, color=color, width=2)
     self.fill = uiprimitives.Fill(
         bgParent=self, color=util.Color(*color).SetAlpha(0.2).GetRGBA())
     label = cont.name
     self.label = uicontrols.Label(parent=self,
                                   text=label,
                                   align=uiconst.TOPLEFT,
                                   state=uiconst.UI_HIDDEN,
                                   top=-12,
                                   color=color)
     if not show:
         self.ShowHidden()
Exemple #20
0
 def ApplyAttributes(self, attributes):
     _GaugeBase.ApplyAttributes(self, attributes)
     color = attributes.Get('color', util.Color.WHITE)
     backgroundColor = attributes.Get('backgroundColor', None)
     self.value = attributes.Get('value', 0.0)
     self.cyclic = attributes.Get('cyclic', False)
     self.gauge = uicls.Container(parent=self.gaugeCont,
                                  name='gauge',
                                  align=uiconst.TOLEFT_PROP,
                                  clipChildren=True,
                                  width=0.0,
                                  state=uiconst.UI_DISABLED)
     self.gaugeGradient = self._CreateGradient(parent=self.gauge,
                                               color=color)
     self.flashGradient = None
     if backgroundColor is None:
         backgroundColor = util.Color(*color).SetAlpha(0.2).GetRGBA()
     uicls.Fill(bgParent=self.gaugeCont,
                name='background',
                color=backgroundColor)
     self.SetValueInstantly(self.value)
Exemple #21
0
    def ApplyAttributes(self, attributes):
        _GaugeBase.ApplyAttributes(self, attributes)
        colors = attributes.Get('colors', [])
        values = attributes.Get('values', [])
        backgroundColor = attributes.Get('backgroundColor', util.Color.WHITE)
        numGauges = len(colors)
        self.gauges = []
        for gaugeNum in xrange(numGauges):
            layer = uicls.Container(parent=self.gaugeCont, name='layer')
            gauge = uicls.Container(parent=layer,
                                    name='gaugeCont%s' % gaugeNum,
                                    align=uiconst.TOLEFT_PROP)
            self._CreateGradient(gauge, color=colors[gaugeNum])
            self.gauges.append(gauge)

        backgroundColor = util.Color(*backgroundColor).SetAlpha(0.2).GetRGBA()
        uicls.Fill(bgParent=self.gaugeCont,
                   name='background',
                   color=backgroundColor)
        for gaugeNum, value in enumerate(values):
            self.SetValueInstantly(gaugeNum, value)
Exemple #22
0
 def ApplyAttributes(self, attributes):
     _GaugeBase.ApplyAttributes(self, attributes)
     self.color = attributes.Get('color', self.default_color)
     backgroundColor = attributes.Get('backgroundColor',
                                      self.default_backgroundColor)
     self.value = attributes.Get('value', self.default_value)
     self.cyclic = attributes.Get('cyclic', self.default_cyclic)
     gaugeAlign = attributes.Get('gaugeAlign', self.default_gaugeAlign)
     self.gauge = uiprimitives.Container(parent=self.gaugeCont,
                                         name='gauge',
                                         align=gaugeAlign,
                                         clipChildren=True,
                                         width=0.0,
                                         state=uiconst.UI_DISABLED)
     self.gaugeGradient = self._CreateGradient(parent=self.gauge,
                                               color=self.color)
     self.flashGradient = None
     if backgroundColor is None:
         backgroundColor = util.Color(*self.color).SetAlpha(0.2).GetRGBA()
     self.sr.backgroundFill = uiprimitives.Fill(bgParent=self.gaugeCont,
                                                name='background',
                                                color=backgroundColor)
     self.SetValueInstantly(self.value)
Exemple #23
0
 def OnMouseEnter(self, *args):
     if self.tileData.blocked or not self.tileData.IsFlippable():
         return
     sm.GetService('audio').SendUIEvent(
         'minigame_node' + str(len(self.tileData.neighbourTiles)))
     sm.GetService('hackingUI').SetTileHint(self.GetTileHint())
     color = util.Color(*self.bgColor).SetBrightness(1.0).GetRGBA()
     uicore.animations.SpColorMorphTo(self.tileBgSprite,
                                      self.tileBgSprite.GetRGBA(),
                                      color,
                                      duration=0.3)
     if self.HasLargeIcon():
         uicore.animations.SpColorMorphTo(self.iconSprite,
                                          self.iconSprite.GetRGBA(),
                                          util.Color.WHITE,
                                          duration=0.3)
     else:
         uicore.animations.FadeIn(self.mouseHoverSprite, duration=0.3)
     if self.IsAttackable(self.tileData.type):
         uicore.animations.Tr2DScaleTo(self.tileBgTransform, (1.0, 1.0),
                                       (1.05, 1.05),
                                       duration=0.8,
                                       curveType=uiconst.ANIM_WAVE)
Exemple #24
0
 def SetBackgroundColor(self, color):
     adjustedColor = util.Color(*color).SetAlpha(0.2).GetRGBA()
     self.sr.backgroundFill.color = adjustedColor
Exemple #25
0
    BucketData(
        typeSecurityTagCloneSoldierRecruiter,
        *securityLevelsPerTagType[typeSecurityTagCloneSoldierRecruiter]),
    BucketData(
        typeSecurityTagCloneSoldierTransporter,
        *securityLevelsPerTagType[typeSecurityTagCloneSoldierTransporter]),
    BucketData(
        typeSecurityTagCloneSoldierNegotiator,
        *securityLevelsPerTagType[typeSecurityTagCloneSoldierNegotiator]),
    BucketData(
        None,
        securityLevelsPerTagType[typeSecurityTagCloneSoldierNegotiator][1],
        10.0)
]
SEC_BAND_DATA = [
    SecurityBandData(-10, -5, util.Color(79, 0, 0), util.Color(63, 0, 0),
                     'UI/SecurityOffice/SecBandHintPve1',
                     'UI/SecurityOffice/SecBandHintPvp1'),
    SecurityBandData(-5, -4.5, util.Color(121, 0, 0), None,
                     'UI/SecurityOffice/SecBandHintPve1',
                     'UI/SecurityOffice/SecBandHintPvp2'),
    SecurityBandData(-4.5, -4, util.Color(157, 11, 15), None,
                     'UI/SecurityOffice/SecBandHintPve2',
                     'UI/SecurityOffice/SecBandHintPvp2'),
    SecurityBandData(-4, -3.5, util.Color(190, 30, 45), None,
                     'UI/SecurityOffice/SecBandHintPve3',
                     'UI/SecurityOffice/SecBandHintPvp2'),
    SecurityBandData(-3.5, -3, util.Color(238, 64, 54), None,
                     'UI/SecurityOffice/SecBandHintPve4',
                     'UI/SecurityOffice/SecBandHintPvp2'),
    SecurityBandData(-3, -2.5, util.Color(240, 90, 40), None,
Exemple #26
0
  def generate_streams(self):
    items = []
    transients = json.loads(self.streams.List())

    items.append({
      "name": _("Home"),
      "stream": "home",
      "sql": "select data from messages where transient = 0",
      "account": None,
      "transient": False,
      "color": None,
    })

    # This list is defined just to get the strings in the template for translation
    stream_titles = [_("Messages"), _("Replies"), _("Images"), _("Private")]

    for stream in ["messages", "replies", "images", "private"]:
      items.append({
        "name": _(stream.capitalize()),
        "stream": stream,
        "sql": "SELECT data FROM messages WHERE stream = '%s' AND transient = 0" % stream,
        "account": None,
        "transient": False,
        "color": None,
      })

    items.append({
      "name": _("Sent"),
      "stream": "sent",
      "sql": "SELECT data FROM messages WHERE from_me = 1 AND transient = 0",
      "account": None,
      "transient": False,
      "color": None,
    })

    for account in json.loads(self.accounts.List()):
      aId = account["id"]

      if self.services.has_key(account["service"]) and "receive" in self.services[account["service"]]["features"]:

        item = {
            "name": account.get("username", "None"),
            "account": aId,
            "stream": None,
            "sql": "SELECT data FROM messages WHERE account = '%s' AND transient = 0" % aId,
            "transient": False,
            "color": util.Color(account["color"]),
            "service": account["service"],
            "items": [],
        }

        default_streams = self.services[account["service"]]["default_streams"]

        if len(default_streams) > 1:
          for feature in default_streams:
            aname = self.features[feature]["stream"]
            item["items"].append({
              "name": _(aname.capitalize()),
              "account": aId,
              "stream": aname,
              "sql": "SELECT data FROM messages WHERE account = '%s' AND stream = '%s' AND transient = 0" % (aId, aname),
              "transient": False,
              "color": util.Color(account["color"]),
              "service": account["service"],
            })

          item["items"].append({
            "name": _("Sent"),
            "account": aId,
            "stream": "sent",
            "sql": "SELECT data FROM messages WHERE account = '%s' AND from_me = 1 AND transient = 0" % aId,
            "transient": False,
            "color": util.Color(account["color"]),
            "service": account["service"],
          })

        for transient in transients:
          tId = transient["id"]

          if transient["account"] == aId:
            query = "SELECT data FROM messages WHERE transient = '%s'" % tId

            if transient["operation"] == "user_messages" and account["service"] in ["twitter", "identica"]:
              query += (" OR (account = '%s' AND recipient = '%s')" % (aId, transient["parameters"]["id"]))

            if transient["name"] == "Lists": transient["name"] = _("Lists")

            item["items"].append({
              "name": transient["name"],
              "account": aId,
              "stream": self.features[transient["operation"]]["stream"],
              "sql": query,
              "transient": tId,
              "color": util.Color(account["color"]),
              "service": account["service"],
            })

        items.append(item)

    searches = {
        "name": _("Search"),
        "account": None,
        "stream": "search",
        "sql": "SELECT data FROM messages WHERE stream = 'search'",
        "transient": False,
        "color": None,
        "items": [],
    }

    for search in json.loads(self.searches.List()):
      sId = search["id"]
      searches["items"].append({
        "name": search["name"],
        "account": None,
        "sql": "SELECT data FROM messages WHERE transient = '%s'" % sId,
        "stream": "search",
        "transient": sId,
        "color": None,
      })

    items.append(searches)
    return items
Exemple #27
0
import util

log = logging.getLogger('placebo.google_client')

# Full drive access for dev.
SCOPE = 'https://www.googleapis.com/auth/drive'
USER = '******'

CHANNEL_PATTERNS = [
    re.compile('controlgroup.slack.com/messages/([a-z0-9_-]+)'),
    re.compile('#([a-z0-9_-]+)'),
]
FILE_ID_PATTERN = re.compile('/d/([a-zA-Z0-9-_]+)')

# The light-gray background color used for metas on the tracking spreadsheet.
META_BACKGROUND = util.Color(red=0.85, green=0.85, blue=0.85)
# The white background color used for everything else.
PLAIN_BACKGROUND = util.Color(red=1.0, green=1.0, blue=1.0)

# Some presets to use for round colors if QMs don't pick specific ones. (These are pulled from the
# Sheets UI, and shuffled to put relatively high-contrast pairs next to each other.)
ROUND_COLORS = [
    util.Color(red=0.87, green=0.49, blue=0.42),  # light red berry 2
    util.Color(red=0.81, green=0.89, blue=0.95),  # light blue 3
    util.Color(red=0.71, green=0.84, blue=0.66),  # light green 2
    util.Color(red=0.71, green=0.65, blue=0.84),  # light purple 2
    util.Color(red=0.98, green=0.8, blue=0.61),  # light orange 2
    util.Color(red=0.84, green=0.65, blue=0.74),  # light magenta 2
    util.Color(red=0.92, green=0.6, blue=0.6),  # light red 2
    util.Color(red=1.0, green=0.9, blue=0.6),  # light yellow 2
    util.Color(red=0.85, green=0.92, blue=0.83),  # light green 3
Exemple #28
0
 def GetBackgroundColor(self):
     color = settings.char.windows.Get('wndColor', eve.themeColor)
     color = util.Color(*color)
     h, s, b = color.GetHSB()
     return color.SetSaturation(s * 0.5).SetBrightness(b * 0.5).SetAlpha(0.85).GetRGBA()
Exemple #29
0
 def SetAccessability(self, canAccess):
     self.canAccess = canAccess
     if self.icon:
         self.icon.color = self.iconColor if canAccess else util.Color(
             *self.iconColor).SetAlpha(0.5).GetRGBA()
     self.UpdateLabel()
Exemple #30
0
 def GetColor(self, num, maxNum):
     hue = min(1.0, 0.1 + 0.85 * float(num) / maxNum)
     return util.Color().SetHSB(hue, 1.0, 1.0)