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

levelSelector.py (5194B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\standings\levelSelector.py
      2 import appConst
      3 import localization
      4 from carbon.client.script.environment.AudioUtil import PlaySound
      5 from carbonui import uiconst
      6 from carbonui.primitives.container import Container
      7 from carbonui.primitives.frame import Frame
      8 from carbonui.uicore import uicore
      9 from eve.client.script.parklife import states
     10 from eve.client.script.ui.shared.stateFlag import AddAndSetFlagIcon
     11 
     12 class StandingLevelSelector(Container):
     13 
     14     def ApplyAttributes(self, attributes):
     15         Container.ApplyAttributes(self, attributes)
     16         self.level = attributes.get('level', None)
     17         self.iconPadding = attributes.get('iconPadding', 6)
     18         self.vertical = attributes.get('vertical', False)
     19         if attributes.get('callback', None):
     20             self.OnStandingLevelSelected = attributes.get('callback', None)
     21         self.ConstructLayout()
     22 
     23     def ConstructLayout(self):
     24         self.standingList = {appConst.contactHighStanding: localization.GetByLabel('UI/PeopleAndPlaces/ExcellentStanding'),
     25          appConst.contactGoodStanding: localization.GetByLabel('UI/PeopleAndPlaces/GoodStanding'),
     26          appConst.contactNeutralStanding: localization.GetByLabel('UI/PeopleAndPlaces/NeutralStanding'),
     27          appConst.contactBadStanding: localization.GetByLabel('UI/PeopleAndPlaces/BadStanding'),
     28          appConst.contactHorribleStanding: localization.GetByLabel('UI/PeopleAndPlaces/TerribleStanding')}
     29         levelList = self.standingList.keys()
     30         levelList.sort()
     31         shift = 20 + self.iconPadding
     32         for i, relationshipLevel in enumerate(levelList):
     33             leftPos = i * shift * float(not self.vertical)
     34             rightPos = i * shift * float(self.vertical)
     35             contName = 'level%d' % i
     36             level = StandingsContainer(name=contName, parent=self, align=uiconst.TOPLEFT, pos=(leftPos,
     37              rightPos,
     38              20,
     39              20), level=relationshipLevel, text=self.standingList.get(relationshipLevel), windowName='contactmanagement')
     40             setattr(self.sr, contName, level)
     41             level.OnClick = (self.LevelOnClick, relationshipLevel, level)
     42             if self.level == relationshipLevel:
     43                 level.sr.selected.state = uiconst.UI_DISABLED
     44                 uicore.registry.SetFocus(level)
     45 
     46     def LevelOnClick(self, level, container, *args):
     47         PlaySound(uiconst.SOUND_BUTTON_CLICK)
     48         for i in xrange(0, 5):
     49             cont = self.sr.Get('level%d' % i)
     50             cont.sr.selected.state = uiconst.UI_HIDDEN
     51 
     52         container.sr.selected.state = uiconst.UI_DISABLED
     53         self.level = level
     54         if hasattr(self, 'OnStandingLevelSelected'):
     55             self.OnStandingLevelSelected(level)
     56 
     57     def GetValue(self):
     58         return self.level
     59 
     60 
     61 class StandingsContainer(Container):
     62 
     63     def ApplyAttributes(self, attributes):
     64         Container.ApplyAttributes(self, attributes)
     65         text = attributes.get('text', '')
     66         self.text = text
     67         level = attributes.get('level', None)
     68         self.level = level
     69         windowName = attributes.get('windowName', '')
     70         self.windowName = windowName
     71         self.Prepare_(text, level)
     72         self.cursor = uiconst.UICURSOR_SELECT
     73 
     74     def Prepare_(self, text = '', contactLevel = None, *args):
     75         self.isTabStop = 1
     76         self.state = uiconst.UI_NORMAL
     77         flag = None
     78         if contactLevel == appConst.contactHighStanding:
     79             flag = states.flagStandingHigh
     80         elif contactLevel == appConst.contactGoodStanding:
     81             flag = states.flagStandingGood
     82         elif contactLevel == appConst.contactNeutralStanding:
     83             flag = states.flagStandingNeutral
     84         elif contactLevel == appConst.contactBadStanding:
     85             flag = states.flagStandingBad
     86         elif contactLevel == appConst.contactHorribleStanding:
     87             flag = states.flagStandingHorrible
     88         if flag:
     89             flagContainer = AddAndSetFlagIcon(self, flag=flag, state=uiconst.UI_DISABLED, showHint=False)
     90             flagContainer.ChangeFlagPos(0, 0, 20, 20)
     91             Frame(parent=flagContainer, color=(1.0, 1.0, 1.0, 0.2))
     92             self.sr.selected = Frame(parent=flagContainer, color=(1.0, 1.0, 1.0, 0.75), state=uiconst.UI_DISABLED, idx=0)
     93             self.sr.selected.display = False
     94             self.sr.hilite = Frame(parent=flagContainer, color=(1.0, 1.0, 1.0, 0.75), state=uiconst.UI_DISABLED, idx=0)
     95             self.sr.hilite.display = False
     96             self.hint = text
     97 
     98     def OnMouseEnter(self, *args):
     99         PlaySound(uiconst.SOUND_BUTTON_HOVER)
    100         if self.sr.hilite:
    101             self.sr.hilite.display = True
    102 
    103     def OnMouseExit(self, *args):
    104         if self.sr.hilite:
    105             self.sr.hilite.display = False
    106 
    107     def OnSetFocus(self, *args):
    108         if self.sr.hilite:
    109             self.sr.hilite.display = True
    110 
    111     def OnKillFocus(self, *args):
    112         if self.sr.hilite:
    113             self.sr.hilite.display = False
    114 
    115     def OnChar(self, char, *args):
    116         if char in (uiconst.VK_SPACE, uiconst.VK_RETURN):
    117             self.parent.LevelOnClick(self.level, self)