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

logOffWnd.py (5259B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\logOffWnd.py
      2 import carbonui.const as uiconst
      3 from carbonui import ButtonVariant
      4 from carbonui.control.button import Button
      5 from carbonui.control.checkbox import Checkbox
      6 from carbonui.control.window import Window
      7 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      8 from carbonui.uicore import uicore
      9 from carbonui.button.group import ButtonGroup, ButtonSizeMode
     10 from eve.client.script.ui.control.eveLabel import EveLabelMediumBold
     11 from eve.client.script.ui.shared.loginRewards.reminderCont import ReminderCont
     12 from localization import GetByLabel
     13 import log
     14 
     15 class LogOffWnd(Window):
     16     __guid__ = 'LogOffWnd'
     17     default_windowID = 'message'
     18     default_height = 188
     19     default_alwaysLoadDefaults = True
     20     default_scope = uiconst.SCOPE_ALL
     21     default_isMinimizable = False
     22     default_isCollapseable = False
     23     default_isLockable = False
     24     default_isOverlayable = False
     25     default_isStackable = False
     26     default_isLightBackgroundConfigurable = False
     27     default_fixedWidth = 380
     28     default_width = default_fixedWidth
     29     default_minSize = [default_fixedWidth, default_height]
     30     default_iconNum = 'res:/UI/Texture/WindowIcons/quitGame.png'
     31 
     32     def ApplyAttributes(self, attributes):
     33         super(LogOffWnd, self).ApplyAttributes(attributes)
     34         self.suppress = 0
     35         self.name = 'modal'
     36         self.edit = None
     37         self.yesBtn = None
     38         self.msgKey = attributes.get('msgKey', None)
     39         self.MakeUnResizeable()
     40         self.mainCont = ContainerAutoSize(parent=self.GetMainArea(), align=uiconst.TOTOP, callback=self.OnRewardSectionUpdated)
     41         self.rewardSection = ContainerAutoSize(name='rewardSection', parent=self.mainCont, align=uiconst.TOTOP)
     42         self.msgLabel = EveLabelMediumBold(parent=self.mainCont, align=uiconst.TOTOP, top=16)
     43         self.bottomCont = ContainerAutoSize(name='bottomCont', parent=self.mainCont, align=uiconst.TOTOP, top=16)
     44         self.buttonCont = ContainerAutoSize(name='buttonCont', parent=self.bottomCont, align=uiconst.TOTOP)
     45         self.suppressCont = ContainerAutoSize(name='suppressContainer', parent=self.bottomCont, align=uiconst.TOTOP, padding=(0, 0, 0, 8), idx=0)
     46 
     47     def Prepare_Background_(self):
     48         super(LogOffWnd, self).Prepare_Background_()
     49 
     50     def _show_message(self, text, title, buttons, icon, suppText, height = None, default = None, modal = True, okLabel = None, cancelLabel = None, isClosable = True, **kwargs):
     51         if title is None:
     52             title = GetByLabel('UI/Common/Information')
     53         self.SetCaption(title)
     54         self.msgLabel.text = '<center>%s</center>' % text
     55         self.DefineButtons(buttons, default=default, okLabel=okLabel, cancelLabel=cancelLabel)
     56         if suppText:
     57             self.ShowSupp(suppText)
     58         self.suppressCont.display = bool(suppText)
     59         if modal:
     60             if self.yesBtn:
     61                 uicore.registry.SetFocus(self.yesBtn)
     62             else:
     63                 uicore.registry.SetFocus(self)
     64         if session.charid:
     65             self.rewardSection.display = True
     66             self.LoadClaimCont()
     67         else:
     68             self.rewardSection.display = False
     69 
     70     def DefineButtons(self, *args, **kwargs):
     71         btnGroup = ButtonGroup(parent=self.buttonCont, align=uiconst.TOTOP, button_size_mode=ButtonSizeMode.STRETCH)
     72         self.yesBtn = Button(parent=btnGroup, label=GetByLabel('UI/Common/Buttons/Yes'), func=self.ClickYes, variant=ButtonVariant.PRIMARY)
     73         Button(parent=btnGroup, label=GetByLabel('UI/Common/Buttons/No'), func=self.ClickNo)
     74 
     75     def ShowSupp(self, text):
     76         self.sr.suppCheckbox = Checkbox(text=text, parent=self.suppressCont, configName='suppress', retval=0, checked=0, groupname=None, callback=self.ChangeSupp, align=uiconst.CENTERLEFT)
     77         self.suppressCont.height = max(20, self.sr.suppCheckbox.height)
     78 
     79     def ChangeSupp(self, sender):
     80         self.suppress = sender.checked
     81 
     82     def OnSuppLabelClicked(self, *args):
     83         self.sr.suppCheckbox.ToggleState()
     84 
     85     def CloseByUser(self, *etc):
     86         if self.isModal:
     87             self.SetModalResult(uiconst.ID_CLOSE)
     88         else:
     89             super(LogOffWnd, self).CloseByUser(*etc)
     90 
     91     def ClickYes(self, *args, **kwargs):
     92         if self.isModal:
     93             self.SetModalResult(uiconst.ID_YES)
     94 
     95     def ClickNo(self, *args, **kwargs):
     96         if self.isModal:
     97             self.SetModalResult(uiconst.ID_NO)
     98 
     99     def LoadClaimCont(self):
    100         try:
    101             self.rewardSection.Flush()
    102             self.rewardSection.display = True
    103             padLeft, _, padRight, _ = self.GetContentToWindowEdgePadding()
    104             ReminderCont(parent=self.rewardSection, parentWidth=self.width - padLeft - padRight, align=uiconst.TOTOP)
    105         except Exception:
    106             log.LogException()
    107             self.rewardSection.display = False
    108 
    109     def OnRewardSectionUpdated(self):
    110         heightBefore = self.height
    111         _, newHeight = self.GetWindowSizeForContentSize(height=self.mainCont.height)
    112         self.SetMinSize(size=(self.GetMinWidth(), newHeight), refresh=True)
    113         heightChange = self.height - heightBefore
    114         self.top = max(0, self.top - heightChange / 2)