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

characterOverviewElements.py (7080B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\charsheet\characterOverviewPanel\characterOverviewElements.py
      2 import eveformat.client
      3 import homestation.client
      4 import threadutils
      5 from carbon.client.script.environment.AudioUtil import PlaySound
      6 from carbonui import const as uiconst, TextColor
      7 from carbonui.primitives.container import Container
      8 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      9 from carbonui.uicore import uicore
     10 from carbonui.control.buttonIcon import ButtonIcon
     11 from eve.client.script.ui.control.eveLabel import EveLabelMedium, EveLabelLarge
     12 from eve.client.script.ui.control.glowSprite import GlowSprite
     13 from eve.client.script.ui.shared.info.infoConst import TAB_WARHISTORY
     14 from eve.client.script.ui.shared.neocom.corporation.war.atWarTooltip import LoadAtWarTooltipPanelFindWars
     15 from eve.common.lib import appConst
     16 from eve.common.lib import appConst as const
     17 from localization import GetByLabel
     18 from menu import MenuList
     19 from eve.client.script.ui.const.eveIconConst import RACE_ICONS
     20 CHAR_INFO_ELEMENT_HEIGHT = 25
     21 CHAR_INFO_TOOLTIP_ICON_PATH = 'res:/UI/Texture/Icons/generic/more_info_16.png'
     22 CHAR_INFO_TOOLTIP_WIDTH = 16
     23 
     24 class EmpireIcon(GlowSprite):
     25     default_state = uiconst.UI_NORMAL
     26     default_iconOpacity = 1.0
     27 
     28     def ApplyAttributes(self, attributes):
     29         if 'texturePath' not in attributes and 'empireID' in attributes:
     30             attributes['texturePath'] = RACE_ICONS[attributes['empireID']]
     31         super(EmpireIcon, self).ApplyAttributes(attributes)
     32 
     33     def OnMouseHover(self, *args):
     34         super(EmpireIcon, self).OnMouseHover(*args)
     35         PlaySound(uiconst.SOUND_BUTTON_HOVER)
     36 
     37     def OnClick(self, *args):
     38         super(EmpireIcon, self).OnClick(*args)
     39         PlaySound(uiconst.SOUND_BUTTON_CLICK)
     40         factionID = const.factionByRace[session.raceID]
     41         sm.GetService('info').ShowInfo(const.typeFaction, itemID=factionID)
     42 
     43 
     44 class CharacterInfoElement(Container):
     45 
     46     def ApplyAttributes(self, attributes):
     47         Container.ApplyAttributes(self, attributes)
     48         leftCont = ContainerAutoSize(parent=self, name='leftCont', align=uiconst.TOLEFT, height=CHAR_INFO_ELEMENT_HEIGHT, padRight=10, padTop=1)
     49         centerCont = ContainerAutoSize(parent=self, name='rightCont', align=uiconst.TOLEFT, height=CHAR_INFO_ELEMENT_HEIGHT, padRight=10)
     50         rightCont = ContainerAutoSize(parent=self, name='rightCont', align=uiconst.TOLEFT, height=CHAR_INFO_ELEMENT_HEIGHT)
     51         self.titleLabel = EveLabelLarge(parent=leftCont, name='titleLabel', align=uiconst.CENTERLEFT, text=attributes.titleText, opacity=1, color=TextColor.SECONDARY)
     52         self.valueLabel = EveLabelLarge(parent=centerCont, name='valueLabel', align=uiconst.CENTERLEFT, text=attributes.valueText, opacity=1)
     53         if attributes.tooltip is not None:
     54             self.tooltipIcon = ButtonIcon(parent=rightCont, name='tooltipButton', texturePath=CHAR_INFO_TOOLTIP_ICON_PATH, align=uiconst.CENTERLEFT, width=CHAR_INFO_TOOLTIP_WIDTH, height=CHAR_INFO_TOOLTIP_WIDTH, state=uiconst.UI_NORMAL, hint=attributes.tooltip)
     55 
     56 
     57 class CharacterInfoSecurityStatus(CharacterInfoElement):
     58     default_state = uiconst.UI_NORMAL
     59 
     60     def ApplyAttributes(self, attributes):
     61         CharacterInfoElement.ApplyAttributes(self, attributes)
     62 
     63     def OnClick(self, *args):
     64         PlaySound(uiconst.SOUND_BUTTON_CLICK)
     65         from eve.client.script.ui.shared.neocom.characterSheetWindow import CharacterSheetWindow
     66         CharacterSheetWindow.OpenSecurityStatus()
     67 
     68 
     69 class CharacterInfoHomeStation(CharacterInfoElement):
     70     default_state = uiconst.UI_NORMAL
     71 
     72     def ApplyAttributes(self, attributes):
     73         CharacterInfoElement.ApplyAttributes(self, attributes)
     74         homestation.Service.instance().on_home_station_changed.connect(self._UpdateHomeStationText)
     75         self._UpdateHomeStationText()
     76 
     77     @property
     78     def home_station(self):
     79         return homestation.Service.instance().get_home_station()
     80 
     81     @threadutils.threaded
     82     def _UpdateHomeStationText(self):
     83         text = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/UnknownSystem')
     84         if self.home_station and self.home_station.solar_system_id:
     85             text = eveformat.solar_system_with_security(self.home_station.solar_system_id)
     86         self.valueLabel.SetText(text)
     87         self.tooltipIcon.hint = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/CloneLocationHint', locationId=self.home_station.id)
     88 
     89     def GetMenu(self):
     90         if self.home_station:
     91             return sm.GetService('menu').GetMenuFromItemIDTypeID(self.home_station.id, self.home_station.type_id)
     92         return MenuList()
     93 
     94     def OnClick(self, *args):
     95         from eve.client.script.ui.shared.neocom.characterSheetWindow import CharacterSheetWindow
     96         PlaySound(uiconst.SOUND_BUTTON_CLICK)
     97         CharacterSheetWindow.OpenHomeStation()
     98 
     99 
    100 class IconButtonCont(Container):
    101     default_state = uiconst.UI_NORMAL
    102     default_align = uiconst.TOLEFT
    103     default_width = 45
    104 
    105     def ApplyAttributes(self, attributes):
    106         Container.ApplyAttributes(self, attributes)
    107         self.func = attributes.func
    108 
    109     def OnMouseEnter(self, *args):
    110         PlaySound(uiconst.SOUND_BUTTON_HOVER)
    111         uicore.animations.FadeTo(self, self.opacity, 1.5, duration=0.15)
    112 
    113     def OnMouseExit(self, *args):
    114         uicore.animations.FadeTo(self, self.opacity, 1.0, duration=0.3)
    115 
    116     def OnClick(self, *args):
    117         PlaySound(uiconst.SOUND_BUTTON_CLICK)
    118         self.func()
    119 
    120 
    121 class AtWarIconAndLabel(ContainerAutoSize):
    122     default_state = uiconst.UI_NORMAL
    123     texturePath = 'res:/UI/Texture/classes/war/atWar_64.png'
    124     iconSize = 52
    125 
    126     def ApplyAttributes(self, attributes):
    127         ContainerAutoSize.ApplyAttributes(self, attributes)
    128         iconCont = Container(parent=self, align=uiconst.TOTOP, height=self.iconSize)
    129         self.icon = GlowSprite(parent=iconCont, state=uiconst.UI_DISABLED, align=uiconst.CENTER, texturePath=self.texturePath, width=52, height=52)
    130         labelCont = ContainerAutoSize(parent=self, align=uiconst.TOTOP)
    131         self.label = EveLabelMedium(parent=labelCont, align=uiconst.CENTER, text=self.GetText())
    132 
    133     def OnMouseEnter(self, *args):
    134         PlaySound(uiconst.SOUND_BUTTON_HOVER)
    135         self.icon.OnMouseEnter()
    136         uicore.animations.FadeTo(self, self.opacity, 1.3, duration=0.15)
    137 
    138     def OnMouseExit(self, *args):
    139         self.icon.OnMouseExit()
    140         uicore.animations.FadeTo(self, self.opacity, 1.0, duration=0.3)
    141 
    142     def OnClick(self, *args):
    143         PlaySound(uiconst.SOUND_BUTTON_CLICK)
    144         typeID = appConst.typeAlliance if session.allianceid else appConst.typeCorporation
    145         itemID = session.allianceid or session.corpid
    146         sm.GetService('info').ShowInfo(typeID, itemID, selectTabType=TAB_WARHISTORY)
    147 
    148     def GetText(self):
    149         return '<color=0xff99251f>%s</color>' % GetByLabel('UI/Corporations/Wars/AtWar')
    150 
    151     def GetHint(self):
    152         return ''
    153 
    154     def LoadTooltipPanel(self, tooltipPanel, *args):
    155         LoadAtWarTooltipPanelFindWars(tooltipPanel)