def ApplyAttributes(self, attributes):
     VectorLineTrace.ApplyAttributes(self, attributes)
     ColorThemeMixin.ApplyAttributes(self, attributes)
     self.lineType = LINE_SOLID
     self.fromID = attributes.fromID
     self.toID = attributes.toID
     self.glowLine = VectorLineTrace(
         parent=self.parent,
         lineWidth=20,
         spriteEffect=trinity.TR2_SFX_COPY,
         texturePath='res:/UI/Texture/classes/Achievements/lineGlow.png',
         name='glowLine',
         blendMode=trinity.TR2_SBM_ADDX2,
         opacity=0.3)
     sm.RegisterNotify(self)
Esempio n. 2
0
    def ConstructLine(self, colorStart, colorEnd):
        numPoints = self.radius
        line = VectorLineTrace(name='bg', parent=self, lineWidth=self.lineWidth, width=1, height=1, end=0.0)
        w = self.lineWidth / 2.0
        stepSize = 2 * pi / numPoints
        for i in xrange(numPoints + 1):
            if i == 0:
                t = self.startAngle - 0.1 * stepSize
                point = (w + self.radius * (1.0 + cos(t)), w + self.radius * (1.0 + sin(t)))
                line.AddPoint(point, color=(1, 1, 1, 0))
            t = self.startAngle + float(i) * stepSize
            point = (w + self.radius * (1.0 + cos(t)), w + self.radius * (1.0 + sin(t)))
            color = geo2.Vec4Lerp(colorStart, colorEnd, i / float(numPoints))
            line.AddPoint(point, color)

        return line
    def ConstructSegments(self):
        ret = []
        stepSize = 2 * pi / self.numSegments
        numPoints = max(3, int(30 / self.numSegments))
        w = self.lineWidth / 2.0
        radius = self.radius - self.lineWidth / 2.0
        for i in xrange(self.numSegments):
            line = VectorLineTrace(name='line', parent=self.segmentTransform, lineWidth=self.lineWidth, width=100, height=100)
            for j in xrange(numPoints + 1):
                t = float(i) / self.numSegments * 2 * pi + float(j) / numPoints * stepSize
                t += pi / 2
                point = (w + radius * (1.0 + cos(t)), w + radius * (1.0 + sin(t)))
                if self.numSegments > 1 and (j == 0 or j == numPoints):
                    line.AddPoint(point, color=(1, 1, 1, 0))
                else:
                    line.AddPoint(point)

            ret.append(line)

        return ret
Esempio n. 4
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))
Esempio n. 5
0
    def ConstructLine(self, colorStart, colorEnd):
        numPoints = max(30, self.radius)
        line = VectorLineTrace(parent=self,
                               lineWidth=self.lineWidth,
                               width=1,
                               height=1,
                               end=0.0)
        w = self.lineWidth / 2.0
        stepSize = 2 * pi / numPoints
        for i in xrange(numPoints + 1):
            if i == 0:
                t = self.startAngle - 0.1 * stepSize
                point = self.GetLinePoint(t, w)
                line.AddPoint(point, color=(1, 1, 1, 0))
            t = self.startAngle + float(i) * stepSize
            point = self.GetLinePoint(t, w)
            color = geo2.Vec4Lerp(colorStart, colorEnd, i / float(numPoints))
            line.AddPoint(point, color)

        return line
Esempio n. 6
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))
Esempio n. 7
0
    def DoUpdateLayout(self, dockPlacement):
        pointerWidth = self.dockPointerLength * 2
        if dockPlacement == DockPlacement.TopCenter:
            pointList = ((0, 0),
             ((self.width - pointerWidth) * 0.5, 0),
             (self.width * 0.5, -self.dockPointerLength),
             ((self.width + pointerWidth) * 0.5, 0),
             (self.width, 0),
             (self.width, self.height),
             (0, self.height))
        elif dockPlacement == DockPlacement.BottomCenter:
            pointList = ((0, 0),
             (self.width, 0),
             (self.width, self.height),
             ((self.width + pointerWidth) * 0.5, self.height),
             (self.width * 0.5, self.height + pointerWidth),
             ((self.width - pointerWidth) * 0.5, self.height),
             (0, self.height))
        elif dockPlacement == DockPlacement.LeftCenter:
            pointList = ((0, 0),
             (self.width, 0),
             (self.width, self.height),
             (0, self.height),
             (0, (self.height + pointerWidth) * 0.5),
             (-self.dockPointerLength, self.height * 0.5),
             (0, (self.height - pointerWidth) * 0.5))
        elif dockPlacement == DockPlacement.RightCenter:
            pointList = ((0, 0),
             (self.width, 0),
             (self.width, (self.height - pointerWidth) * 0.5),
             (self.width + self.dockPointerLength, self.height * 0.5),
             (self.width, (self.height + pointerWidth) * 0.5),
             (self.width, self.height),
             (0, self.height))
        else:
            raise NotImplementedError('This case of dock placement has not been implemented yet')
        if self.lineTrace is not None:
            self.lineTrace.Close()
        self.lineTrace = VectorLineTrace(parent=self, lineWidth=1.0, spriteEffect=trinity.TR2_SFX_FILL)
        self.lineTrace.isLoop = True
        for point in pointList:
            x, y = point
            x, y = uicore.ScaleDpi(x), uicore.ScaleDpi(y)
            self.lineTrace.AddPoint((x, y), self.hintFrameColor)

        pointerSideWidth = int(self.dockPointerLength * 2 / sqrt(2))
        pointerSideWidthHalf = pointerSideWidth / 2
        if dockPlacement == DockPlacement.TopCenter:
            clipperAlign = uiconst.CENTERTOP
            transformAlign = uiconst.CENTERBOTTOM
            horizontal = False
        elif dockPlacement == DockPlacement.BottomCenter:
            clipperAlign = uiconst.CENTERBOTTOM
            transformAlign = uiconst.CENTERTOP
            horizontal = False
        elif dockPlacement == DockPlacement.LeftCenter:
            clipperAlign = uiconst.CENTERLEFT
            transformAlign = uiconst.CENTERRIGHT
            horizontal = True
        elif dockPlacement == DockPlacement.RightCenter:
            clipperAlign = uiconst.CENTERRIGHT
            transformAlign = uiconst.CENTERLEFT
            horizontal = True
        else:
            raise NotImplementedError('This case of dock placement has not been implemented yet')
        clipperCont = Container(name='clipper', parent=self, width=self.dockPointerLength if horizontal else pointerWidth, height=pointerWidth if horizontal else self.dockPointerLength, clipChildren=True, align=clipperAlign, top=0 if horizontal else -self.dockPointerLength, left=-self.dockPointerLength if horizontal else 0)
        transform = Transform(name='transform', parent=clipperCont, align=transformAlign, rotation=pi / 4, width=pointerSideWidth, height=pointerSideWidth, top=0 if horizontal else -pointerSideWidthHalf, left=-pointerSideWidthHalf if horizontal else 0)
        Fill(bgParent=transform, color=self.hintBgColor)