shipconfig.py (8704B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\shipconfig.py 2 import evetypes 3 import localization 4 import carbonui.const as uiconst 5 from carbonui.control.window import Window 6 from carbonui.primitives.container import Container 7 from eve.client.script.ui.control import eveIcon, eveLabel, eveScroll 8 from carbonui.button.group import ButtonGroup 9 from eve.client.script.ui.control.entries.util import GetFromClass 10 from eve.client.script.ui.shared.userentry import User 11 from eve.client.script.ui.util import uix 12 from carbonui.control.tabGroup import TabGroup 13 from eve.common.lib import appConst as const 14 from eve.common.script.net import eveMoniker 15 from eve.common.script.sys import eveCfg, idCheckers 16 from eve.common.script.sys.eveCfg import InStructure 17 from eveservices.menu import GetMenuService 18 from player_messaging.client.ui_message import prompt_player_fsd_dialog 19 20 class ShipConfig(Window): 21 default_windowID = 'shipconfig' 22 default_captionLabelPath = 'UI/Ship/ShipConfig/ShipConfig' 23 default_minSize = (300, 230) 24 default_height = 400 25 default_width = 300 26 __notifyevents__ = ['ProcessSessionChange', 'OnShipCloneJumpUpdate'] 27 shipmodules = [('CloneFacility', 'canReceiveCloneJumps')] 28 29 def ApplyAttributes(self, attributes): 30 Window.ApplyAttributes(self, attributes) 31 self.shipid = eveCfg.GetActiveShip() 32 self.shipItem = self.GetShipItem() 33 self.topParent = Container(name='topParent', parent=self.GetMainArea(), align=uiconst.TOTOP, height=72, clipChildren=True) 34 self.sr.top = Container(name='top', align=uiconst.TOTOP, parent=self.topParent, pos=(const.defaultPadding, 35 const.defaultPadding, 36 const.defaultPadding, 37 64)) 38 icon = eveIcon.Icon(parent=self.sr.top, align=uiconst.TOLEFT, left=const.defaultPadding, size=64, state=uiconst.UI_NORMAL, typeID=self.shipItem.typeID) 39 icon.GetMenu = self.ShipMenu 40 Container(name='push', align=uiconst.TOLEFT, pos=(5, 0, 5, 0), parent=self.sr.top) 41 eveLabel.EveHeaderMedium(name='label', text=cfg.evelocations.Get(self.shipItem.itemID).name, parent=self.sr.top, align=uiconst.TOTOP, bold=True, state=uiconst.UI_NORMAL) 42 eveLabel.EveLabelMedium(name='label', text=evetypes.GetName(self.shipItem.typeID), parent=self.sr.top, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) 43 self.ship = eveMoniker.GetShipAccess() 44 self.conf = self.ship.GetShipConfiguration(self.shipid) 45 modules = self.GetShipModules() 46 for module in modules: 47 self.sr.Set('%sPanel' % module.lower(), Container(name=module, align=uiconst.TOALL, state=uiconst.UI_HIDDEN, parent=self.sr.main, pos=(0, 0, 0, 0))) 48 49 tabs = [ [name, 50 self.sr.Get('%sPanel' % module.lower(), None), 51 self, 52 module] for module, name in modules.iteritems() if self.sr.Get('%sPanel' % module.lower()) ] 53 if tabs: 54 self.sr.maintabs = TabGroup(name='tabparent', align=uiconst.TOTOP, height=18, parent=self.sr.main, idx=self.topParent.GetOrder() + 1, tabs=tabs, groupID='pospanel') 55 else: 56 eveLabel.CaptionLabel(text=localization.GetByLabel('UI/Ship/ShipConfig/ShipConfig'), parent=self.sr.main, size=18, uppercase=0, left=const.defaultPadding, width=const.defaultPadding, top=const.defaultPadding) 57 58 def _OnClose(self, *args): 59 self.shipid = None 60 self.shipItem = None 61 self.capacity = None 62 self.tower = None 63 64 def Load(self, key): 65 eval('self.Show%s()' % key) 66 67 def ShowCloneFacility(self): 68 if not getattr(self, 'cloneinited', 0): 69 self.InitCloneFacilityPanel() 70 godmaSM = sm.GetService('godma').GetStateManager() 71 self.panelsetup = 1 72 cloneRS = sm.GetService('clonejump').GetShipClones() 73 scrolllist = [] 74 for each in cloneRS: 75 charinfo = cfg.eveowners.Get(each['ownerID']) 76 scrolllist.append(GetFromClass(User, {'charID': each['ownerID'], 77 'info': charinfo, 78 'cloneID': each['jumpCloneID']})) 79 80 self.sr.clonescroll.Load(contentList=scrolllist, headers=[localization.GetByLabel('UI/Common/Name')]) 81 self.sr.clonescroll.ShowHint([localization.GetByLabel('UI/Ship/ShipConfig/NoClonesInstalledAtShip'), None][bool(scrolllist)]) 82 numClones = int(len(cloneRS)) 83 totalClones = int(getattr(godmaSM.GetItem(self.shipItem.itemID), 'maxJumpClones', 0)) 84 self.sr.cloneInfo.text = localization.GetByLabel('UI/Ship/ShipConfig/NumJumpClones', numClones=numClones, totalClones=totalClones) 85 self.panelsetup = 0 86 87 def InitCloneFacilityPanel(self): 88 panel = self.sr.clonefacilityPanel 89 btns = [(localization.GetByLabel('UI/Ship/ShipConfig/Invite'), 90 self.InviteClone, 91 (), 92 84), (localization.GetByLabel('UI/Ship/ShipConfig/Destroy'), 93 self.DestroyClone, 94 (), 95 84)] 96 self.cloneFacilityButtons = ButtonGroup(btns=btns, parent=panel) 97 if not session.solarsystemid or InStructure(): 98 self.cloneFacilityButtons.buttons[0].Disable() 99 numClones = int(0) 100 totalClones = int(getattr(sm.GetService('godma').GetItem(self.shipItem.itemID), 'maxJumpClones', 0)) 101 text = localization.GetByLabel('UI/Ship/ShipConfig/NumJumpClones', numClones=numClones, totalClones=totalClones) 102 self.sr.cloneInfo = eveLabel.EveLabelSmall(text=text, parent=panel, align=uiconst.TOTOP, padding=(const.defaultPadding, 103 const.defaultPadding, 104 const.defaultPadding, 105 0), state=uiconst.UI_NORMAL) 106 self.sr.clonescroll = eveScroll.Scroll(name='clonescroll', parent=panel, padding=const.defaultPadding) 107 self.cloneinited = 1 108 109 def InviteClone(self, *args): 110 if not sm.GetService('clonejump').HasCloneReceivingBay(): 111 prompt_player_fsd_dialog('InviteClone1') 112 return 113 godmaSM = sm.GetService('godma').GetStateManager() 114 opDist = getattr(godmaSM.GetType(self.shipItem.typeID), 'maxOperationalDistance', 0) 115 bp = sm.GetService('michelle').GetBallpark() 116 if not bp: 117 return 118 charIDs = self._GetPotentialInvitees(bp, opDist) 119 if not charIDs: 120 prompt_player_fsd_dialog('InviteClone2') 121 return 122 lst = [] 123 for charID in charIDs: 124 char = cfg.eveowners.Get(charID) 125 lst.append((char.name, charID, char.typeID)) 126 127 chosen = uix.ListWnd(lst, 'character', localization.GetByLabel('UI/Ship/ShipConfig/SelectAPilot'), None, 1, minChoices=1, isModal=1) 128 if chosen: 129 sm.GetService('clonejump').OfferShipCloneInstallation(chosen[1]) 130 131 def _GetPotentialInvitees(self, bp, opDist): 132 charIDs = set() 133 for slimItem in bp.slimItems.itervalues(): 134 if not slimItem.charID or slimItem.charID == session.charid or idCheckers.IsNPC(slimItem.charID): 135 continue 136 if slimItem.categoryID == const.categoryStructure: 137 continue 138 if slimItem.surfaceDist <= opDist: 139 charIDs.add(slimItem.charID) 140 141 return charIDs 142 143 def DestroyClone(self, *args): 144 for each in self.sr.clonescroll.GetSelected(): 145 sm.GetService('clonejump').DestroyInstalledClone(each.cloneID) 146 147 def GetShipItem(self): 148 if session.stationid or InStructure(): 149 return sm.GetService('clientDogmaIM').GetDogmaLocation().GetShip() 150 if session.solarsystemid: 151 bp = sm.GetService('michelle').GetBallpark() 152 if bp and self.shipid in bp.slimItems: 153 return bp.slimItems[self.shipid] 154 155 def GetShipModules(self): 156 typeID = self.shipItem.typeID 157 godmaSM = sm.GetService('godma').GetStateManager() 158 hasModules = {} 159 for module in self.shipmodules: 160 if getattr(godmaSM.GetType(typeID), module[1], 0): 161 nameString = '' 162 if module[0] == 'CloneFacility': 163 nameString = localization.GetByLabel('UI/Ship/ShipConfig/CloneFacility') 164 hasModules[module[0]] = nameString 165 166 return hasModules 167 168 def ShipMenu(self): 169 return GetMenuService().GetMenuFromItemIDTypeID(self.shipItem.itemID, self.shipItem.typeID) 170 171 def ProcessSessionChange(self, isRemote, session, change): 172 if session.shipid and 'shipid' in change: 173 self.CloseByUser() 174 elif 'solarsystemid' in change: 175 self.CloseByUser() 176 177 def OnShipCloneJumpUpdate(self): 178 if self.sr.maintabs.GetSelectedArgs() == 'CloneFacility': 179 self.ShowCloneFacility()