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

shipNameDialog.py (4443B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\shipNameDialog.py
      2 import carbonui.text.styles
      3 import localization
      4 import carbonui
      5 import carbonui.const as uiconst
      6 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText
      7 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      8 from carbonui.control.button import Button
      9 from carbonui.button.group import ButtonGroup, ButtonSizeMode
     10 from carbonui.control.checkbox import Checkbox
     11 from carbonui.control.window import Window
     12 from carbon.client.script.environment.AudioUtil import PlaySound
     13 from eve.client.script.ui.control.infoIcon import QuestionMarkGlyphIcon
     14 from eve.client.script.ui.control.themeColored import FrameThemeColored, SpriteThemeColored
     15 from clientsettings.setting import SuppressSettingBool
     16 
     17 def prompt_rename_ship(ship_type_id, name = '', show_suppress = False):
     18     wnd = ShipNameDialog.Open(ship_type_id=ship_type_id, current_name=name, show_suppress=show_suppress)
     19     if wnd.ShowModal() == 1:
     20         return wnd.result
     21     else:
     22         return None
     23 
     24 
     25 class ShipNameDialog(Window):
     26     default_name = 'ShipNameDialog'
     27     default_windowID = 'ship_name_dialog'
     28     default_captionLabelPath = 'UI/Ship/NameChange/WindowTitle'
     29     default_width = 360
     30     default_height = 160
     31     default_minSize = (default_width, default_height)
     32     default_isStackable = False
     33     result = None
     34 
     35     def ApplyAttributes(self, attributes):
     36         Window.ApplyAttributes(self, attributes)
     37         self.show_window_controls = False
     38         self.MakeUnResizeable()
     39         current_name = attributes.get('current_name', '')
     40         show_suppress = attributes.get('show_suppress', False)
     41         self._hint_text = localization.GetByLabel('UI/Inflight/OwnerAndShip', session.languageID, charID=session.charid, shipTypeID=attributes.get('ship_type_id'))
     42         self._main_container = main = ContainerAutoSize(parent=self.content, align=carbonui.Align.TOTOP, callback=self._on_content_size_changed)
     43         self._input_field = SingleLineEditText(parent=main, align=carbonui.Align.TOTOP, label=localization.GetByLabel('UI/Ship/NameChange/InputFieldLabel'), setvalue=current_name, hintText=self._hint_text, maxLength=32, autoselect=True, showLetterCounter=True, OnReturn=self._confirm, padTop=16)
     44         MoreInfoContainer(parent=main, align=carbonui.Align.TOTOP, padTop=8, text=localization.GetByLabel('UI/Ship/NameChange/InfoLabel'), hint=localization.GetByLabel('UI/Ship/NameChange/InfoTooltip'))
     45         if show_suppress:
     46             suppress_setting = SuppressSettingBool('suppress.ShipNameChangeOnAssemble', False)
     47             Checkbox(parent=main, align=carbonui.Align.TOTOP, text=localization.GetByLabel('/Carbon/UI/Common/DoNotAskAgain'), setting=suppress_setting, padTop=8)
     48         button_group = ButtonGroup(parent=main, align=uiconst.TOTOP, button_size_mode=ButtonSizeMode.STRETCH, padTop=8)
     49         Button(parent=button_group, label=localization.GetByLabel('UI/Common/Confirm'), func=self._confirm, variant=carbonui.ButtonVariant.PRIMARY)
     50         Button(parent=button_group, label=localization.GetByLabel('UI/Common/Later'), func=self._cancel)
     51 
     52     def _confirm(self, *args, **kwargs):
     53         self.result = (self._input_field.GetValue() or self._hint_text).replace('\n', ' ').strip()
     54         PlaySound('ship_goals_name_ship_play')
     55         self.SetModalResult(1)
     56 
     57     def _cancel(self, *args, **kwargs):
     58         self.result = None
     59         self.SetModalResult(0)
     60 
     61     def _on_content_size_changed(self):
     62         _, self.height = self.GetWindowSizeForContentSize(height=self._main_container.height)
     63 
     64 
     65 class MoreInfoContainer(ContainerAutoSize):
     66     default_alignMode = carbonui.Align.CENTERLEFT
     67 
     68     def __init__(self, text, hint, *args, **kwargs):
     69         super(MoreInfoContainer, self).__init__(*args, **kwargs)
     70         QuestionMarkGlyphIcon(parent=self, align=carbonui.Align.CENTERLEFT, hint=hint, left=8)
     71         carbonui.text.styles.TextDetail(parent=self, align=carbonui.Align.CENTERLEFT, padding=(32, 8, 8, 8), text=text)
     72         SpriteThemeColored(name='cornerSprite', parent=self, align=carbonui.Align.TOPLEFT, texturePath='res:/UI/Texture/Shared/DarkStyle/cornerTriSmall.png', pos=(0, 0, 8, 8))
     73         FrameThemeColored(bgParent=self, texturePath='res:/UI/Texture/classes/Agency/fleetup/solidFrame_12corner.png', cornerSize=12, colorType=carbonui.uiconst.COLORTYPE_ACCENT, opacity=0.3)