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

closeWindowStackPrompt.py (3440B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\closeWindowStackPrompt.py
      2 import localization
      3 from carbonui import AxisAlignment, uiconst
      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.container import Container
      8 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      9 from carbonui.primitives.flowcontainer import FlowContainer
     10 from eve.client.script.ui.control.eveLabel import EveLabelMedium
     11 MESSAGE_KEY = 'CloseWindowStackPrompt'
     12 
     13 def ask():
     14     if is_suppressed():
     15         return Response.close_all
     16     window = CloseWindowStackPrompt.Open()
     17     response = window.ShowModal()
     18     if response in (uiconst.ID_CLOSE, uiconst.ID_CANCEL):
     19         response = Response.cancel
     20     if window.suppress_checkbox.checked and response == Response.close_all:
     21         set_suppressed()
     22     return response
     23 
     24 
     25 class Response(object):
     26     cancel = 'cancel'
     27     close_all = 'close_all'
     28     close_current = 'close_current'
     29 
     30 
     31 class CloseWindowStackPrompt(Window):
     32     default_fixedWidth = 400
     33     default_isMinimizable = False
     34     default_isStackable = False
     35     default_isCollapseable = False
     36     default_isLockable = False
     37     default_isOverlayable = False
     38     default_isLightBackgroundConfigurable = False
     39     default_iconNum = 'res:/ui/Texture/WindowIcons/question.png'
     40 
     41     def __init__(self, **kwargs):
     42         self.main_cont = None
     43         self.suppress_checkbox = None
     44         super(CloseWindowStackPrompt, self).__init__(**kwargs)
     45         self.caption = localization.GetByLabel('UI/CloseWindowStackPrompt/WindowCaption')
     46         self.layout()
     47 
     48     def layout(self):
     49         self.main_cont = ContainerAutoSize(parent=self.GetMainArea(), align=uiconst.TOTOP, callback=self._update_height)
     50         self.main_cont.DisableAutoSize()
     51         EveLabelMedium(parent=self.main_cont, align=uiconst.TOTOP, text=localization.GetByLabel('UI/CloseWindowStackPrompt/BodyText'))
     52         self.suppress_checkbox = Checkbox(parent=ContainerAutoSize(parent=self.main_cont, align=uiconst.TOTOP, top=16), align=uiconst.TOPLEFT, text=localization.GetByLabel('UI/CloseWindowStackPrompt/SuppressLabel'), checked=False)
     53         button_cont = FlowContainer(parent=self.main_cont, align=uiconst.TOTOP, top=8, contentAlignment=AxisAlignment.END, contentSpacing=(8, 8))
     54         Button(parent=button_cont, align=uiconst.NOALIGN, label=localization.GetByLabel('UI/CloseWindowStackPrompt/CloseAllLabel'), func=self.SetModalResult, args=(Response.close_all,))
     55         Button(parent=button_cont, align=uiconst.NOALIGN, label=localization.GetByLabel('UI/CloseWindowStackPrompt/CloseCurrentLabel'), func=self.SetModalResult, args=(Response.close_current,))
     56         Button(parent=button_cont, align=uiconst.NOALIGN, label=localization.GetByLabel('UI/Common/Cancel'), func=self.SetModalResult, args=(Response.cancel,))
     57         self.main_cont.EnableAutoSize()
     58 
     59     def Prepare_Background_(self):
     60         super(CloseWindowStackPrompt, self).Prepare_Background_()
     61 
     62     def _update_height(self):
     63         _, height = self.GetWindowSizeForContentSize(height=self.main_cont.height)
     64         self.SetFixedHeight(height)
     65 
     66 
     67 def is_suppressed():
     68     return settings.user.suppress.Get('suppress.{}'.format(MESSAGE_KEY), False)
     69 
     70 
     71 def set_suppressed():
     72     settings.user.suppress.Set('suppress.{}'.format(MESSAGE_KEY), True)