Beispiel #1
0
 def DrawOutline(self, margin = 0):
     if self.outline:
         outline = self.outline
     else:
         outline = VectorLineTrace(parent=self, lineWidth=1, idx=0)
         outline.isLoop = True
         self.outline = outline
     outline.Flush()
     self.cornerPoints = []
     colors = [(1, 0, 0, 1),
      (1, 1, 1, 1),
      (0, 1, 0, 1),
      (1, 1, 1, 1),
      (0, 0, 1, 1),
      (1, 1, 1, 1)]
     for i in xrange(6):
         if self.isFlatTop:
             outlineRad = self.displayWidth * 0.5 - margin
             angle = 2.0 * math.pi / 6.0 * i
         else:
             outlineRad = self.displayHeight * 0.5 - margin
             angle = 2.0 * math.pi / 6.0 * (i + 0.5)
         x_i = ReverseScaleDpi(self.displayWidth * 0.5 + outlineRad * math.cos(angle))
         y_i = ReverseScaleDpi(self.displayHeight * 0.5 + outlineRad * math.sin(angle))
         outline.AddPoint((x_i, y_i), colors[i])
         self.cornerPoints.append((x_i, y_i))
Beispiel #2
0
 def UpdateExtraContainer(self):
     if not self.extraContainer or not self.markerContainer:
         return
     offsetX, offsetY = self.GetExtraContainerDisplayOffset()
     self.extraContainer.renderObject.displayX = self.markerContainer.renderObject.displayX + offsetX
     self.extraContainer.renderObject.displayY = self.markerContainer.renderObject.displayY + offsetY
     self.extraContainer.left = ReverseScaleDpi(self.extraContainer.renderObject.displayX)
     self.extraContainer.top = ReverseScaleDpi(self.extraContainer.renderObject.displayY)
Beispiel #3
0
 def Load(self):
     MarkerLabelBase.Load(self)
     self.textSprite.displayX = ScaleDpi(6)
     self.textSprite.displayY = ScaleDpi(2)
     self.markerContainer.pos = (
         0, 0, ReverseScaleDpi(self.textSprite.textWidth + 12),
         ReverseScaleDpi(self.textSprite.textHeight + 4))
     self.projectBracket.offsetY = -ScaleDpi(self.markerContainer.height +
                                             8)
     Frame(bgParent=self.markerContainer, color=self.fontColor)
     Fill(bgParent=self.markerContainer, color=(0, 0, 0, 0.5))
Beispiel #4
0
 def _InsertChild(self, idx, obj):
     self.mainCont.children.insert(idx, obj)
     contentWidth = ReverseScaleDpi(self.displayWidth)
     minContentHeight = ReverseScaleDpi(self.clipCont.displayHeight)
     self.mainCont.width = contentWidth
     obj.top = self.contentHeight
     obj.width = contentWidth
     obj.displayY = ScaleDpiF(self.contentHeight)
     obj.displayWidth = ScaleDpiF(contentWidth)
     self.contentHeight += obj.height
     self.mainCont.height = max(minContentHeight, self.contentHeight)
     self._UpdateScrollbars()
     self.LoadEntryIfVisible(obj)
 def RegisterPosition(self, position = None):
     pW = ReverseScaleDpi(self.parent.displayWidth)
     pH = ReverseScaleDpi(self.parent.displayHeight)
     if position:
         left, top = position
     else:
         left = self.left
         top = self.top
     cX = left + self.width / 2
     cY = top + self.height / 2
     proportionX = cX / float(pW)
     proportionY = cY / float(pH)
     settings.char.ui.Set('opportunities_tree_position8', (proportionX, proportionY))
Beispiel #6
0
 def is_mouse_out_of_bounds(self, mouse_position, img_position):
     if mouse_position[0] < img_position[0]:
         return True
     elif mouse_position[0] > img_position[0] + ReverseScaleDpi(
             self.image_sprite.displayWidth):
         return True
     elif mouse_position[1] < img_position[1]:
         return True
     elif mouse_position[1] > img_position[1] + ReverseScaleDpi(
             self.image_sprite.displayHeight):
         return True
     else:
         return False
    def _UpdateHelper(self):
        if not self.enabled:
            return
        status = blue.threadMonitor.GetStatus()
        downloads = 0
        loads = 0
        for threadId, threadStatus in status:
            if threadStatus == 3:
                downloads += 1
            elif threadStatus > 0:
                loads += 1

        if self.downloadingBar.display:
            barWidth = ReverseScaleDpi(self.displayWidth) / 3 - 2
            barHeight = ReverseScaleDpi(self.displayHeight)
            self.downloadingBar.height = min(downloads, barHeight)
            self.downloadingBar.width = barWidth
            self.loadingBar.height = min(loads, barHeight)
            self.loadingBar.width = barWidth
            self.loadingBar.left = barWidth + 1
            inQueue = blue.resMan.pendingLoads + blue.resMan.pendingPrepares
            self.queueBar.height = min(inQueue, barHeight)
            self.queueBar.width = barWidth
            self.queueBar.left = barWidth * 2 + 2
            if self.tooltip:
                tooltip = self.tooltip()
                if tooltip and not tooltip.destroyed:
                    tooltip.readout.text = 'downloads: %s<br>loads: %s<br>inQueue: %s' % (
                        downloads, loads, inQueue)
        if downloads > 0:
            if not self.active:
                self.active = True
                uicore.animations.FadeTo(self.wheel,
                                         startVal=self.wheel.opacity,
                                         endVal=1.0,
                                         duration=0.3)
            if not self.wheel.HasAnimation('rotation'):
                uicore.animations.MorphScalar(self.wheel,
                                              'rotation',
                                              self.wheel.rotation,
                                              -2 * math.pi +
                                              self.wheel.rotation,
                                              duration=1.0,
                                              curveType=uiconst.ANIM_LINEAR,
                                              loops=uiconst.ANIM_REPEAT)
        elif self.active:
            self.active = False
            uicore.animations.FadeTo(self.wheel,
                                     startVal=self.wheel.opacity,
                                     endVal=0.0,
                                     duration=0.3)
 def UpdateProgress(self):
     if self.groupData.IsCompleted():
         self.rewardAmount.hint = GetByLabel(
             'UI/Achievements/OpportunityRewardGiven')
         self.rewardAmount.bold = True
         self.rewardAmount.color = self.rewardAmountThemeColor
     else:
         self.rewardAmount.color = (1.0, 1.0, 1.0, 0.5)
         self.rewardAmount.hint = GetByLabel(
             'UI/Achievements/OpportunityRewardNotGiven')
         self.rewardAmount.bold = False
     progressProportion = self.groupData.GetProgressProportion()
     maxWidth = ReverseScaleDpi(self.displayWidth) - POINTER_PADRIGHT
     uicore.animations.MorphScalar(self.progress,
                                   'padRight',
                                   startVal=self.progress.padRight,
                                   endVal=POINTER_PADRIGHT + maxWidth *
                                   (1 - progressProportion),
                                   curveType=uiconst.ANIM_SMOOTH,
                                   duration=0.33)
     uicore.animations.MorphScalar(self.progress,
                                   'opacity',
                                   startVal=self.progress.opacity,
                                   endVal=min(progressProportion, 0.25),
                                   curveType=uiconst.ANIM_SMOOTH,
                                   duration=0.33)
Beispiel #9
0
 def LoadEntryIfVisible(self, entry):
     topOffset = self.mainCont.top
     visibleHeight = ReverseScaleDpi(self.clipCont.displayHeight)
     if topOffset + entry.top + entry.height >= 0 and topOffset + entry.top <= visibleHeight:
         entry.UpdateAlignmentAsRoot()
         entry.LoadContent()
         entry.display = True
     else:
         entry.display = False
Beispiel #10
0
    def TraverseHexMap(self, viewportRect=None, scaling=None):
        if not self.parent:
            return
        if scaling is None:
            scaling = self.globalScaling
        self.globalScaling = scaling
        if self.objectByID:
            if viewportRect is None:
                viewportRect = (self.left, self.top,
                                ReverseScaleDpi(self.parent.displayWidth),
                                ReverseScaleDpi(self.parent.displayHeight))
            else:
                vX, vY, vW, vH = viewportRect
                viewportRect = (vX + self.left, vY + self.top, vW, vH)
            for objectID, hexCell in self.objectByID.iteritems():
                hexCell.TraverseHexCell(viewportRect,
                                        self.globalScaling * self.localScaling)

            self.UpdateJumpLines()
Beispiel #11
0
 def DrawOutline(self):
     if self.outline:
         outline = self.outline
     else:
         outline = VectorLineTrace(parent=self, lineWidth=2)
         outline.isLoop = True
         self.outline = outline
     outline.Flush()
     for i in xrange(6):
         if self.isFlatTop:
             outlineRad = self.displayWidth * 0.5
             angle = 2.0 * math.pi / 6.0 * i
         else:
             outlineRad = self.displayHeight * 0.5
             angle = 2.0 * math.pi / 6.0 * (i + 0.5)
         x_i = ReverseScaleDpi(self.displayWidth * 0.5 +
                               outlineRad * math.cos(angle))
         y_i = ReverseScaleDpi(self.displayHeight * 0.5 +
                               outlineRad * math.sin(angle))
         outline.AddPoint((x_i, y_i), (1, 0, 0, 0.8))
Beispiel #12
0
 def Load(self):
     self.isLoaded = True
     if self.measurer is None:
         measurer = trinity.Tr2FontMeasurer()
         measurer.limit = 0
         measurer.font = self.fontPath
         measurer.fontSize = ScaleDpi(self.fontSize)
         measurer.letterSpace = ScaleDpi(self.letterSpace)
         measurer.AddText(StripTags(self.GetLabelText()))
         measurer.CommitText(0, measurer.ascender)
         self.measurer = measurer
     textSprite = trinity.Tr2Sprite2dTextObject()
     textSprite.fontMeasurer = self.measurer
     textSprite.color = self.fontColor
     textSprite.blendMode = trinity.TR2_SBM_ADD
     self.markerContainer.renderObject.children.append(textSprite)
     self.textSprite = textSprite
     height = self.measurer.ascender - self.measurer.descender
     width = self.measurer.cursorX
     self.textSprite.textWidth = width
     self.textSprite.textHeight = height
     self.markerContainer.pos = (0, 0, ReverseScaleDpi(width),
                                 ReverseScaleDpi(height))
 def ClampPosition(self, smooth = True):
     mL, mT, mR, mB = self.treeMargin
     pW = ReverseScaleDpi(self.parent.displayWidth)
     pH = ReverseScaleDpi(self.parent.displayHeight)
     if self.width < pW:
         left = (pW - self.width) / 2
     else:
         left = max(pW - self.width, mL + -self.width / 2, self.left)
         left = min(0, -mR + pW - self.width / 2, left)
     if self.height < pH:
         top = (pH - self.height) / 2
     else:
         top = max(pH - self.height, mT + -self.height / 2, self.top)
         top = min(0, -mB + pH - self.height / 2, top)
     if smooth:
         if self.left != left:
             uicore.animations.MorphScalar(self, 'left', startVal=self.left, endVal=left, duration=0.3)
         if self.top != top:
             uicore.animations.MorphScalar(self, 'top', startVal=self.top, endVal=top, duration=0.3)
     else:
         self.left = left
         self.top = top
     self.RegisterPosition(position=(left, top))
 def UpdateProgress(self):
     progressProportion = self.groupData.GetProgressProportion()
     maxWidth = ReverseScaleDpi(self.displayWidth) - POINTER_PADRIGHT
     uicore.animations.MorphScalar(self.progress,
                                   'padRight',
                                   startVal=self.progress.padRight,
                                   endVal=POINTER_PADRIGHT + maxWidth *
                                   (1 - progressProportion),
                                   curveType=uiconst.ANIM_SMOOTH,
                                   duration=0.33)
     uicore.animations.MorphScalar(self.progress,
                                   'opacity',
                                   startVal=self.progress.opacity,
                                   endVal=min(progressProportion, 0.25),
                                   curveType=uiconst.ANIM_SMOOTH,
                                   duration=0.33)
Beispiel #15
0
    def UpdateAlignment(self, *args, **kwds):
        if not self.isButtonSizeUpToDate:
            numButtons = len(self.buttons)
            for i, button in enumerate(self.buttons):
                isLast = i == numButtons - 1
                button.align = uiconst.TOALL if isLast else uiconst.TOLEFT_PROP
                button.width = 0 if isLast else 1.0 / numButtons

            self.isButtonSizeUpToDate = True
        if self.autoHeight:
            minHeight = self.setHeight
            for button in self.buttons:
                if hasattr(button, 'GetAutoHeight'):
                    minHeight = max(minHeight, button.GetAutoHeight())

            self.height = ReverseScaleDpi(minHeight)
        return Container.UpdateAlignment(self, *args, **kwds)
Beispiel #16
0
 def _OnVerticalScrollBar(self, posFraction):
     posFraction = max(0.0, min(posFraction, 1.0))
     self.mainCont.top = -posFraction * (
         self.mainCont.height -
         ReverseScaleDpi(self.clipCont.displayHeight))