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

corpAllianceContactManagementWindow.py (5516B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\addressBook\corpAllianceContactManagementWindow.py
      2 import localization
      3 from carbonui import ButtonVariant, uiconst
      4 from carbonui.button.group import ButtonGroup
      5 from carbonui.control.button import Button
      6 from carbonui.control.combo import Combo
      7 from carbonui.control.slider import Slider
      8 from carbonui.control.window import Window
      9 from carbonui.primitives.container import Container
     10 from carbonui.primitives.containerAutoSize import ContainerAutoSize
     11 from carbonui.uicore import uicore
     12 from eve.client.script.ui.control import eveIcon, eveLabel
     13 from eve.client.script.ui.shared.standings.levelSelector import StandingLevelSelector
     14 from eve.client.script.ui.util import uix
     15 from eve.common.lib import appConst
     16 
     17 class CorpAllianceContactManagementWnd(Window):
     18     default_fixedHeight = 110
     19     default_fixedWidth = 280
     20     default_captionLabelPath = 'UI/PeopleAndPlaces/ContactManagement'
     21 
     22     def ApplyAttributes(self, attributes):
     23         Window.ApplyAttributes(self, attributes)
     24         entityID = attributes.entityID
     25         level = attributes.level
     26         if level is None:
     27             level = appConst.contactNeutralStanding
     28         isContact = attributes.isContact
     29         contactType = attributes.contactType
     30         self.result = None
     31         self.entityID = entityID
     32         self.level = level
     33         self.isContact = isContact
     34         self.notify = False
     35         self.contactType = contactType
     36         self.ConstructLayout()
     37 
     38     def OnMainContainerSizeChanged(self, *args, **kwds):
     39         _, height = self.GetWindowSizeForContentSize(height=self.mainCont.height)
     40         self.SetFixedHeight(height)
     41 
     42     def ConstructLayout(self):
     43         self.mainCont = ContainerAutoSize(name='mainCont', parent=self.sr.main, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, callback=self.OnMainContainerSizeChanged)
     44         imgCont = Container(name='imgCont', parent=self.mainCont, align=uiconst.TOLEFT, width=64, padRight=uiconst.defaultPadding)
     45         eveIcon.GetOwnerLogo(imgCont, self.entityID, size=64, noServerCall=True)
     46         self.ConstructNameCont()
     47         self.levelText = eveLabel.EveLabelMedium(parent=self.mainCont, align=uiconst.TOTOP, padTop=4)
     48         self.ConstructStandingSlider()
     49         self._UpdateStandingLevelText()
     50         self.levelSelector = StandingLevelSelector(name='levelCont', parent=self.mainCont, align=uiconst.TOTOP, height=20, padTop=4, level=self.level)
     51         self.levelSelector.OnStandingLevelSelected = self.OnStandingLevelSelected
     52         self.ConstructLabelsCombo()
     53         self.ConstructBottomButtons()
     54 
     55     def ConstructBottomButtons(self):
     56         if self.isContact:
     57             btnText = localization.GetByLabel('UI/PeopleAndPlaces/EditContact')
     58         else:
     59             btnText = localization.GetByLabel('UI/PeopleAndPlaces/AddContact')
     60         self.btnGroup = ButtonGroup(parent=self.mainCont, align=uiconst.TOTOP, padding=(-64, 16, 0, 0))
     61         confirm_button = Button(parent=self.btnGroup, label=btnText, func=self.Confirm, args=(), btn_modalresult=1, btn_default=1, variant=ButtonVariant.PRIMARY)
     62         Button(parent=self.btnGroup, label=localization.GetByLabel('UI/Common/Buttons/Cancel'), func=self.Cancel, args=())
     63         uicore.registry.SetFocus(confirm_button)
     64 
     65     def ConstructNameCont(self):
     66         charName = cfg.eveowners.Get(self.entityID).name
     67         label = eveLabel.EveLabelLargeBold(text=charName, parent=self.mainCont, padTop=2, align=uiconst.TOTOP)
     68 
     69     def ConstructLabelsCombo(self):
     70         labels = sm.GetService('addressbook').GetContactLabels(self.contactType).values()
     71         if not self.isContact and len(labels):
     72             options = self._GetLabelComboOptions(labels)
     73             self.labelsCombo = Combo(name='labelscombo', label='', parent=self.mainCont, align=uiconst.TOTOP, options=options, padTop=8)
     74         else:
     75             self.labelsCombo = None
     76 
     77     def _GetLabelComboOptions(self, labels):
     78         labelList = []
     79         for label in labels:
     80             labelList.append((label.name, label.labelID))
     81 
     82         assignLabelText = localization.GetByLabel('UI/PeopleAndPlaces/AssignLabel')
     83         labelList.insert(0, (assignLabelText, None))
     84         return labelList
     85 
     86     def ConstructStandingSlider(self):
     87         self.standingSlider = Slider(name='standing', parent=self.mainCont, minValue=-10.0, maxValue=10.0, value=self.level if self.isContact else 0, on_dragging=self.UpdateSizeSliderLabel, padRight=52, increments=[ x / 10.0 for x in xrange(-100, 101) ])
     88 
     89     def UpdateSizeSliderLabel(self, slider, *args):
     90         self._UpdateStandingLevelText()
     91 
     92     def _UpdateStandingLevelText(self):
     93         standing_value = self.standingSlider.GetValue()
     94         self.levelText.text = localization.GetByLabel('UI/AddressBook/SliderLabel', value=round(standing_value, 1), standingText=uix.GetStanding(round(standing_value, 1)))
     95 
     96     def OnStandingLevelSelected(self, level):
     97         self.standingSlider.SetValue(level)
     98         self._UpdateStandingLevelText()
     99 
    100     def Confirm(self):
    101         relationshipID = round(self.standingSlider.value, 1)
    102         contactLabel = None
    103         if self.labelsCombo:
    104             contactLabel = self.labelsCombo.GetValue()
    105         self.result = (relationshipID, contactLabel)
    106         if getattr(self, 'isModal', None):
    107             self.SetModalResult(1)
    108 
    109     def Cancel(self):
    110         self.result = None
    111         if getattr(self, 'isModal', None):
    112             self.SetModalResult(0)