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

infoPanelShipTree.py (10213B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\infoPanels\infoPanelShipTree.py
      2 import carbonui.const as uiconst
      3 import eve.client.script.ui.shared.shipTree.shipTreeConst as shipTreeConst
      4 import localization
      5 from carbonui.primitives.container import Container
      6 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      7 from carbonui.primitives.flowcontainer import FlowContainer
      8 from carbonui.primitives.frame import Frame
      9 from carbonui.primitives.sprite import Sprite
     10 from carbonui.primitives.stretchspritehorizontal import StretchSpriteHorizontal
     11 from carbonui.uicore import uicore
     12 from characterdata.factions import get_faction_name
     13 from carbonui.control.buttonIcon import ButtonIcon
     14 from carbonui.control.button import Button
     15 from eve.client.script.ui import eveColor
     16 from eve.client.script.ui.control.eveIcon import LogoIcon
     17 from eve.client.script.ui.control.eveLabel import Label, EveCaptionSmall
     18 from eve.client.script.ui.shared.infoPanels.InfoPanelBase import InfoPanelBase
     19 from eve.client.script.ui.shared.infoPanels.const import infoPanelConst
     20 from eve.client.script.ui.shared.shipTree.shipTreeConst import ICON_BY_FACTIONID
     21 from eve.client.script.ui.shared.traits import TraitAttributeIcon
     22 from eveservices.menu import GetMenuService
     23 from inventorycommon.const import typeFaction
     24 
     25 class InfoPanelShipTree(InfoPanelBase):
     26     default_name = 'InfoPanelShipTree'
     27     panelTypeID = infoPanelConst.PANEL_SHIP_TREE
     28     label = 'UI/ShipTree/ShipTree'
     29     default_iconTexturePath = 'res:/UI/Texture/Classes/InfoPanels/ShipTree.png'
     30     hasSettings = False
     31     isCollapsable = False
     32     __notifyevents__ = ('OnBeforeShipTreeFactionSelected', 'OnShipTreeSkillTrained')
     33 
     34     def ApplyAttributes(self, attributes):
     35         InfoPanelBase.ApplyAttributes(self, attributes)
     36         self.header = self.headerCls(parent=self.headerCont, align=uiconst.CENTERLEFT, text=localization.GetByLabel(self.label))
     37         BTNSIZE = 24
     38         Button(parent=self.headerCont, align=uiconst.CENTERRIGHT, pos=(0,
     39          0,
     40          BTNSIZE,
     41          BTNSIZE), texturePath='res:/UI/Texture/Icons/73_16_45.png', iconSize=16, func=self.ExitShipTreeMode, hint=localization.GetByLabel('UI/ShipTree/ExitShipTree'))
     42         self.mainIconCont = ContainerAutoSize(name='mainIconCont', parent=self.mainCont, align=uiconst.TOTOP, padTop=2)
     43         numInRow = 5
     44         size = 53
     45         self.factionButtons = []
     46         selectedFactionID = sm.GetService('shipTreeUI').GetSelectedFaction()
     47         for i, factionID in enumerate(shipTreeConst.FACTIONS):
     48             left = i % numInRow * (size + 1)
     49             top = i / numInRow * (size + 2)
     50             isActive = factionID == selectedFactionID
     51             btn = ShipTreeButtonIcon(parent=self.mainIconCont, texturePath=ICON_BY_FACTIONID.get(factionID), align=uiconst.TOPLEFT, pos=(left,
     52              top,
     53              size,
     54              size), iconSize=46, func=sm.GetService('shipTreeUI').SelectFaction, args=(factionID, True), hint=get_faction_name(factionID), factionID=factionID, isActive=isActive)
     55             self.factionButtons.append(btn)
     56 
     57         factionID = sm.GetService('shipTreeUI').GetSelectedFaction()
     58         self.factionInfoCont = InfoBubbleRace(parent=self.mainCont, align=uiconst.TOTOP, width=0, padTop=10, factionID=factionID)
     59 
     60     def OnBeforeShipTreeFactionSelected(self, factionID):
     61         for btn in self.mainIconCont.children:
     62             btn.SetActive(factionID == btn.factionID)
     63 
     64         self.factionInfoCont.UpdateFaction(factionID)
     65 
     66     def OnShipTreeSkillTrained(self):
     67         for btn in self.factionButtons:
     68             btn.CheckBlink()
     69 
     70     def ExitShipTreeMode(self, *args):
     71         uicore.cmd.GetCommandAndExecute('CmdToggleShipTree')
     72 
     73 
     74 class InfoBubbleRace(Container):
     75     default_name = 'InfoBubbleRace'
     76     default_alignMode = uiconst.TOTOP
     77     __notifyevents__ = ('OnShipTreeFactionButtonEnter', 'OnShipTreeFactionButtonExit', 'OnShipTreeFactionSelected')
     78 
     79     def ApplyAttributes(self, attributes):
     80         super(InfoBubbleRace, self).ApplyAttributes(attributes)
     81         sm.RegisterNotify(self)
     82         self.factionID = attributes.factionID
     83         self.mainCont = Container(name='mainCont', parent=self)
     84         self.content = ContainerAutoSize(name='content', parent=self.mainCont, align=uiconst.TOTOP, callback=self.OnMainContResize)
     85         self.bgFrame = Container(name='bgFrame', parent=self, state=uiconst.UI_DISABLED)
     86         self.frameTop = StretchSpriteHorizontal(name='frameTop', parent=self.bgFrame, align=uiconst.TOTOP, texturePath='res:/UI/Texture/classes/ShipTree/InfoBubble/frameUpper.png', height=36)
     87         self.frameBottom = StretchSpriteHorizontal(name='frameBottom', parent=self.bgFrame, align=uiconst.TOBOTTOM, texturePath='res:/UI/Texture/classes/ShipTree/InfoBubble/frameLower.png', height=36)
     88         self.bgFill = Container(name='bgFill', parent=self, state=uiconst.UI_DISABLED)
     89         StretchSpriteHorizontal(parent=self.bgFill, align=uiconst.TOTOP, texturePath='res:/UI/Texture/classes/ShipTree/InfoBubble/backTopExtender.png', height=1)
     90         StretchSpriteHorizontal(parent=self.bgFill, align=uiconst.TOBOTTOM, texturePath='res:/UI/Texture/classes/ShipTree/InfoBubble/backBottom.png', height=6)
     91         Sprite(parent=self.bgFill, align=uiconst.TOALL, texturePath='res:/UI/Texture/classes/ShipTree/InfoBubble/backMiddle.png')
     92         topCont = ContainerAutoSize(name='topContainer', parent=self.content, align=uiconst.TOTOP, padding=(10, 10, 10, 0), height=50)
     93         topRightCont = ContainerAutoSize(name='topContentContainer', parent=topCont, align=uiconst.TOPLEFT, left=64, width=180)
     94         self.icon = Sprite(name='icon', parent=topCont, pos=(0, 0, 64, 64), align=uiconst.TOPLEFT)
     95         self.caption = EveCaptionSmall(parent=topRightCont, align=uiconst.TOTOP)
     96         self.flowContainerCont = ContainerAutoSize(parent=topRightCont, align=uiconst.TOTOP, alignMode=uiconst.TOPLEFT)
     97         self.attributeCont = FlowContainer(name='attributeCont', parent=self.flowContainerCont, align=uiconst.TOPLEFT, contentSpacing=(1, 1), padTop=5, width=160)
     98         self.descriptionLabel = Label(name='descriptionLabel', parent=self.content, align=uiconst.TOTOP, padding=(10, 6, 10, 10))
     99         self.ShowFaction(self.factionID)
    100 
    101     def OnMainContResize(self):
    102         self.height = self.content.height
    103 
    104     def UpdateFaction(self, factionID):
    105         self.factionID = factionID
    106         self.ShowFaction(factionID)
    107 
    108     def ShowFaction(self, factionID, animate = True):
    109         self.icon.texturePath = ICON_BY_FACTIONID.get(factionID)
    110         self.caption.text = get_faction_name(factionID)
    111         factionData = cfg.infoBubbleFactions[factionID]
    112         self.attributeCont.Flush()
    113         for _, attributeID in factionData['elements'].iteritems():
    114             TraitAttributeIcon(name='InfoBubbleAttributeIcon', parent=self.attributeCont, align=uiconst.NOALIGN, attributeID=attributeID, opacity=1.0, width=30)
    115 
    116         self.descriptionLabel.text = localization.GetByMessageID(factionData['descriptionID'])
    117 
    118     def OnShipTreeFactionButtonEnter(self, factionID):
    119         self.ShowFaction(factionID, animate=False)
    120 
    121     def OnShipTreeFactionButtonExit(self, factionID):
    122         self.ShowFaction(self.factionID, animate=False)
    123 
    124 
    125 class ShipTreeButtonIcon(ButtonIcon):
    126     default_name = 'ShipTreeButtonIcon'
    127     default_iconColor = eveColor.WHITE
    128 
    129     def ApplyAttributes(self, attributes):
    130         super(ShipTreeButtonIcon, self).ApplyAttributes(attributes)
    131         self.factionID = attributes.factionID
    132         self.CheckBlink()
    133         self.SetActive(self.isActive)
    134 
    135     def _GetIconColor(self):
    136         return eveColor.WHITE
    137 
    138     def CheckBlink(self):
    139         if sm.GetService('shipTree').IsGroupsRecentlyUnlocked(self.factionID):
    140             self.Blink(duration=1.2, loops=uiconst.ANIM_REPEAT)
    141         else:
    142             self.StopBlink()
    143 
    144     def ConstructBackground(self):
    145         self.mouseEnterBG = Frame(name='mouseEnterBG', bgParent=self.bgContainer, texturePath='res:/UI/Texture/classes/ShipTree/InfoPanel/hover.png', opacity=0.0)
    146         self.mouseDownBG = Sprite(name='mouseDownBG', bgParent=self.bgContainer, texturePath='res:/UI/Texture/classes/ButtonIcon/mouseDown.png', opacity=0.0)
    147         self.selectedBG = Frame(name='selectedBG', bgParent=self.bgContainer, texturePath='res:/UI/Texture/classes/ShipTree/InfoPanel/selected.png', opacity=0.0)
    148 
    149     def OnMouseEnter(self, *args):
    150         super(ShipTreeButtonIcon, self).OnMouseEnter(*args)
    151         sm.ScatterEvent('OnShipTreeFactionButtonEnter', self.factionID)
    152 
    153     def OnMouseExit(self, *args):
    154         super(ShipTreeButtonIcon, self).OnMouseExit(*args)
    155         sm.ScatterEvent('OnShipTreeFactionButtonExit', self.factionID)
    156 
    157     def SetActive(self, isActive, animate = True):
    158         self.isActive = isActive
    159         self.UpdateIconState()
    160         if animate:
    161             if isActive:
    162                 uicore.animations.FadeTo(self.selectedBG, self.selectedBG.opacity, 1.0, duration=0.15)
    163             else:
    164                 uicore.animations.FadeTo(self.selectedBG, self.selectedBG.opacity, 0.0, duration=0.15)
    165         elif self.selectedBG:
    166             self.selectedBG.StopAnimations()
    167             self.selectedBG.opacity = 1.0 if isActive else 0.0
    168 
    169     def OnMouseDown(self, *args):
    170         if not self.enabled:
    171             return
    172         self.SetActive(self.isActive)
    173         if self.isHoverBGUsed:
    174             uicore.animations.FadeIn(self.mouseDownBG, duration=0.1)
    175         else:
    176             uicore.animations.FadeTo(self.icon, self.icon.opacity, self.GLOWAMOUNT_MOUSECLICK, duration=0.1)
    177 
    178     def OnMouseUp(self, *args):
    179         if self.isHoverBGUsed:
    180             uicore.animations.FadeOut(self.mouseDownBG, duration=0.1)
    181         else:
    182             uicore.animations.FadeTo(self.icon, self.icon.opacity, self.OPACITY_IDLE, duration=0.1)
    183         if not self.enabled:
    184             return
    185         if uicore.uilib.mouseOver == self:
    186             if not self.isHoverBGUsed:
    187                 uicore.animations.FadeTo(self.icon, self.icon.opacity, self.GLOWAMOUNT_MOUSEHOVER, duration=0.1)
    188 
    189     def GetMenu(self):
    190         return GetMenuService().GetMenuFromItemIDTypeID(self.factionID, typeFaction)