NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

factionCircle.py (10274B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\factionalWarfare\enlistmentFlow\factionCircle.py
      2 import math
      3 from carbonui.uianimations import animations
      4 from carbonui import const as uiconst, TextAlign
      5 from carbonui.text.styles import TextBody
      6 from carbonui.primitives.container import Container
      7 from carbonui.primitives.sprite import Sprite
      8 from carbonui.primitives.transform import Transform
      9 from carbonui.primitives.vectorlinetrace import DashedCircle
     10 from carbonui.util.dpi import ScaleDpi
     11 from eve.client.script.ui import eveColor
     12 from eve.client.script.ui.shared.careerPortal.circleView.circleView import CircleView
     13 from eve.client.script.ui.shared.factionalWarfare.enlistmentFlow.backBtn import BackBtnFaction
     14 from eve.client.script.ui.shared.factionalWarfare.enlistmentFlow.enlistmentConst import NODE_SIZE
     15 from eve.client.script.ui.shared.factionalWarfare.enlistmentFlow.enlistmentUtil import GetFactionIcon, GetFactionColor
     16 from eve.client.script.ui.shared.factionalWarfare.enlistmentFlow.warzoneGaugeCont import WarzoneGaugeCont
     17 from eve.common.script.util.facwarCommon import IsCombatEnemyFaction
     18 WARZONE_GAUGE_SIZE = 61
     19 
     20 class EnlistmentCircleView(CircleView):
     21 
     22     def ApplyAttributes(self, attributes):
     23         self.extraCircle = None
     24         self.enlistmentController = attributes.enlistmentController
     25         super(EnlistmentCircleView, self).ApplyAttributes(attributes)
     26         self.ConstructBackBtn()
     27 
     28     def ConstructBackBtn(self):
     29         nodeSize = self.GetNodeSize()
     30         self.backBtn = BackBtnFaction(parent=self, align=uiconst.CENTERRIGHT, pos=(0,
     31          0,
     32          nodeSize,
     33          nodeSize), idx=0, enlistmentController=self.enlistmentController)
     34 
     35     def LoadNodes(self, factionIDs):
     36         self.Reset()
     37         for factionID in factionIDs:
     38             node = FactionCircleNode(factionID=factionID, enlistmentController=self.enlistmentController)
     39             self.AddNode(node)
     40 
     41         self.UpdateCircle()
     42 
     43     def UpdateFaction(self, animate = True):
     44         self.UpdateViewColor()
     45         for node in self.nodes:
     46             node.factionPickerIcon.UpdateFrame()
     47 
     48         selectedFactionID = self.enlistmentController.selectedFactionID
     49         if selectedFactionID:
     50             if animate:
     51                 animations.FadeOut(self.nodeParent, callback=self.nodeParent.Hide, duration=0.3)
     52             else:
     53                 self.nodeParent.display = False
     54             self.backBtn.display = True
     55         else:
     56             self.nodeParent.opacity = 1.0
     57             self.nodeParent.display = True
     58             self.backBtn.display = False
     59 
     60     def ConstructOuterCircle(self, radius):
     61         pass
     62 
     63     def GetNodeSize(self):
     64         return ScaleDpi(NODE_SIZE)
     65 
     66     def _GetViewColor(self):
     67         factionID = self.enlistmentController.selectedFactionID or self.enlistmentController.hoveredFactionID
     68         if factionID:
     69             viewColor = GetFactionColor(factionID) or eveColor.WHITE
     70         else:
     71             viewColor = eveColor.WHITE
     72         return eveColor.Color(viewColor)
     73 
     74     def UpdateViewColor(self):
     75         viewColor = self._GetViewColor()
     76         self.fill.color = viewColor.SetOpacity(self.fill.opacity).GetRGBA()
     77 
     78     def MovingFinished(self):
     79         self.UpdateViewColor()
     80 
     81 
     82 class EnlistmentCenterCont(Container):
     83     default_state = uiconst.UI_NORMAL
     84     default_align = uiconst.CENTER
     85     default_width = 200
     86     default_height = 200
     87     default_pickRadius = 200
     88     centerText = ''
     89 
     90     def ApplyAttributes(self, attributes):
     91         super(EnlistmentCenterCont, self).ApplyAttributes(attributes)
     92         self.enlistmentController = attributes.enlistmentController
     93         gaugeRadius = WARZONE_GAUGE_SIZE + 8
     94         self.warzoneGaugeCont = WarzoneGaugeCont(parent=self, pos=(0,
     95          0,
     96          2 * gaugeRadius,
     97          2 * gaugeRadius), gaugeRadius=gaugeRadius, idx=0, showScore=False)
     98         self.centerIcon = Sprite(parent=self, align=uiconst.CENTER, texturePath='res:/ui/Texture/classes/frontlines/factionalwarfare_icon.png', pos=(0, 0, 64, 64))
     99         self.centerLabel = TextBody(parent=self, width=200, align=uiconst.CENTER, textAlign=TextAlign.CENTER)
    100         self.centerLabel.Hide()
    101 
    102     def OnMouseEnter(self, *args):
    103         if self.enlistmentController.isMovingCircle:
    104             return
    105         self.centerIcon.Hide()
    106         self.centerLabel.Show()
    107 
    108     def OnMouseExit(self, *args):
    109         self.centerIcon.Show()
    110         self.centerLabel.Hide()
    111 
    112     def ShowFaction(self, factionID):
    113         self.warzoneGaugeCont.ShowFaction(factionID)
    114 
    115     def LoadCenterText(self, text):
    116         self.centerLabel.text = text
    117 
    118     def LoadCenterIcon(self, texturePath):
    119         self.centerIcon.texturePath = texturePath
    120 
    121 
    122 class BaseCircleNode(Transform):
    123     isDragObject = True
    124     default_align = uiconst.CENTER
    125 
    126     def ApplyAttributes(self, attributes):
    127         super(BaseCircleNode, self).ApplyAttributes(attributes)
    128         self.anchorPointX = self.width * 0.5
    129         self.anchorPointY = self.height * 0.5
    130         self.PrepareUI()
    131         self.ConnectSignals()
    132 
    133     def PrepareUI(self):
    134         raise NotImplementedError
    135 
    136     def ConnectSignals(self):
    137         for signal, func in self.GetSignals():
    138             signal.connect(func)
    139 
    140     def DisconnectSignals(self):
    141         for signal, func in self.GetSignals():
    142             signal.disconnect(func)
    143 
    144     def Close(self):
    145         self.DisconnectSignals()
    146         super(BaseCircleNode, self).Close()
    147 
    148     def GetSignals(self):
    149         return []
    150 
    151     def ResizeComponents(self, contSize, left, top, angle, animate = False):
    152         pass
    153 
    154     def UpdateAnchorPointsAndSize(self, contSize):
    155         raise NotImplementedError
    156 
    157 
    158 class FactionCircleNode(BaseCircleNode):
    159     default_state = uiconst.UI_NORMAL
    160 
    161     def ApplyAttributes(self, attributes):
    162         self.factionID = attributes.factionID
    163         self.enlistmentController = attributes.enlistmentController
    164         self.angle = 0
    165         super(FactionCircleNode, self).ApplyAttributes(attributes)
    166 
    167     def PrepareUI(self):
    168         self.iconCont = Container(name='iconCont', parent=self, align=uiconst.TOALL)
    169         self.ConstructFrame()
    170         self.ConstructIcon()
    171 
    172     def ConstructIcon(self):
    173         self.bgSprite = Sprite(name='bgSprite', parent=self.iconCont, align=uiconst.CENTER, texturePath='res:/UI/Texture/Classes/Enlistment/circle/darkCircle.png', state=uiconst.UI_DISABLED, opacity=1.0)
    174         self.factionPickerIcon = FactionPickerIcon(parent=self.iconCont, enlistmentController=self.enlistmentController, idx=0, factionID=self.factionID, align=uiconst.TOALL)
    175 
    176     def ConstructFrame(self):
    177         self.frame = Sprite(name='frameSprite', parent=self.iconCont, align=uiconst.TOALL, texturePath='', state=uiconst.UI_DISABLED, opacity=0.0)
    178 
    179     def ResizeComponents(self, nodeSize, left, top, angle, animate = False):
    180         self.top = top
    181         self.left = left
    182         self.width = nodeSize
    183         self.height = nodeSize
    184         self.angle = angle
    185         self.UpdateIconSize(nodeSize)
    186 
    187     def UpdateIconSize(self, nodeSize):
    188         self.factionPickerIcon.UpdateIconSize(nodeSize)
    189         self.bgSprite.SetSize(2 * nodeSize, 2 * nodeSize)
    190 
    191     def OnMouseEnter(self, *args):
    192         if self.enlistmentController.isMovingCircle:
    193             return
    194         self.enlistmentController.on_mouse_enter(self.factionID)
    195         self.factionPickerIcon.TryShowFrame()
    196 
    197     def OnMouseExit(self, *args):
    198         if self.enlistmentController.isMovingCircle:
    199             return
    200         self.enlistmentController.on_mouse_exit(self.factionID)
    201         self.factionPickerIcon.TryHideFrame()
    202 
    203     def OnClick(self, *args):
    204         self.enlistmentController.on_node_clicked(self.factionID)
    205         self.factionPickerIcon.UpdateFrame()
    206 
    207     def ChangeFrameDisplay(self, show = True):
    208         if show:
    209             self.frame.Show()
    210         else:
    211             self.frame.Hide()
    212 
    213 
    214 class FactionPickerIcon(Transform):
    215     default_align = uiconst.CENTER
    216 
    217     def ApplyAttributes(self, attributes):
    218         self.enlistmentController = attributes.enlistmentController
    219         super(FactionPickerIcon, self).ApplyAttributes(attributes)
    220         self.factionID = attributes.factionID
    221         texturePath = GetFactionIcon(self.factionID)
    222         textureColor = GetFactionColor(self.factionID) or eveColor.WHITE
    223         self.factionIcon = Sprite(name='factionIcon', parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, pos=(0, 0, 0, 0), texturePath=texturePath, outputMode=uiconst.OUTPUT_COLOR_AND_GLOW, glowBrightness=0)
    224         self.mouseOverFrame = Sprite(name='mouseOverFrame', parent=self, align=uiconst.TOALL, texturePath='res:/UI/Texture/Classes/Enlistment/hoverCircle.png', state=uiconst.UI_DISABLED, opacity=1.0, color=textureColor, padding=-4)
    225         self.mouseOverFrame.Hide()
    226         self.enemeyFrame = Sprite(name='enemeyFrame', parent=self, align=uiconst.TOALL, texturePath='res:/UI/Texture/Classes/Enlistment/hoverCircle.png', state=uiconst.UI_DISABLED, opacity=0.5, color=textureColor)
    227         self.enemeyFrame.Hide()
    228 
    229     def UpdateIconSize(self, nodeSize):
    230         iconSize = nodeSize / 1.2
    231         self.factionIcon.SetSize(iconSize, iconSize)
    232 
    233     def TryShowFrame(self):
    234         self.mouseOverFrame.Show()
    235         self.mouseOverFrame.opacity = 1.0
    236 
    237     def TryHideFrame(self):
    238         if self.factionID not in (self.enlistmentController.hoveredFactionID, self.enlistmentController.selectedFactionID):
    239             self.mouseOverFrame.Hide()
    240 
    241     def UpdateFrame(self):
    242         isFactionIsHighlighted = bool(self.enlistmentController.hoveredFactionID or self.enlistmentController.selectedFactionID)
    243         self.opacity = 1.0
    244         if self.factionID in (self.enlistmentController.hoveredFactionID, self.enlistmentController.selectedFactionID):
    245             self.mouseOverFrame.Show()
    246             self.mouseOverFrame.opacity = 1.0
    247         elif IsCombatEnemyFaction(self.factionID, self.enlistmentController.hoveredFactionID) or IsCombatEnemyFaction(self.factionID, self.enlistmentController.hoveredFactionID):
    248             self.mouseOverFrame.Show()
    249             self.mouseOverFrame.opacity = 0.5
    250         else:
    251             self.mouseOverFrame.Hide()
    252             if isFactionIsHighlighted:
    253                 self.opacity = 0.3