menuFunctions.py (27010B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\services\menuSvcExtras\menuFunctions.py 2 import sys 3 import types 4 import evetypes 5 import blue 6 import destiny 7 import localization 8 import log 9 import structures 10 from carbonui import uiconst 11 from carbonui.primitives.container import Container 12 from carbonui.primitives.frame import Frame 13 from cosmetics.client.shipSkinApplicationSvc import get_ship_skin_application_svc 14 from crates.crateutil import is_fixed_crate 15 from eve.client.script.ui.control import eveLabel 16 from player_messaging.client.ui_message import message_player, prompt_player_fsd_dialog 17 from eve.client.script.ui.crate.fixedcratewindow import FixedCrateWindow 18 from eve.client.script.ui.crate.window import CrateWindow 19 from eve.client.script.ui.services.encodedItemsWindow import EncodedItemsWindow 20 from eve.client.script.ui.shared.shipNameDialog import prompt_rename_ship 21 from eve.client.script.ui.shared.skillRequirementDialog import prompt_missing_skill_requirements 22 from eve.client.script.ui.skilltrading.skillInjectorWindow import SkillInjectorWindow 23 from eve.client.script.ui.util import searchOld 24 from eve.client.script.ui.util import uix, utilWindows 25 from eve.common.lib import appConst as const 26 from eve.common.script.sys import eveCfg, idCheckers 27 from eveexceptions import UserError 28 from eveprefs import prefs 29 from inventorycommon.typeHelpers import GetAveragePrice 30 from menu import MenuLabel 31 from neocom2 import btnIDs 32 from plex.common.const import InvoiceType 33 from structures.deployment import GetStructureNamePrefix 34 from utillib import KeyVal 35 import logging 36 logger = logging.getLogger(__name__) 37 38 def AddHint(hint, where): 39 hintobj = Container(parent=where, name='hint', align=uiconst.TOPLEFT, width=200, height=16, idx=0, state=uiconst.UI_DISABLED) 40 hintobj.hinttext = eveLabel.EveHeaderSmall(text=hint, parent=hintobj, top=4, state=uiconst.UI_DISABLED) 41 border = Frame(parent=hintobj, frameConst=uiconst.FRAME_BORDER1_CORNER5, state=uiconst.UI_DISABLED, color=(1.0, 1.0, 1.0, 0.25)) 42 frame = Frame(parent=hintobj, color=(0.0, 0.0, 0.0, 0.75), frameConst=uiconst.FRAME_FILLED_CORNER4, state=uiconst.UI_DISABLED) 43 if hintobj.hinttext.textwidth > 200: 44 hintobj.hinttext.width = 200 45 hintobj.hinttext.text = '<center>' + hint + '</center>' 46 hintobj.width = max(56, hintobj.hinttext.textwidth + 16) 47 hintobj.height = max(16, hintobj.hinttext.textheight + hintobj.hinttext.top * 2) 48 hintobj.left = (where.width - hintobj.width) / 2 49 hintobj.top = -hintobj.height - 4 50 hintobj.hinttext.left = (hintobj.width - hintobj.hinttext.textwidth) / 2 51 52 53 def AwardDecoration(charIDs): 54 if not charIDs: 55 return 56 if not type(charIDs) == list: 57 charIDs = [charIDs] 58 info, graphics = sm.GetService('medals').GetAllCorpMedals(session.corpid) 59 options = [ (medal.title, medal.medalID) for medal in info ] 60 if len(options) <= 0: 61 raise UserError('MedalCreateToAward') 62 cfg.eveowners.Prime(charIDs) 63 hintLen = 5 64 hint = ', '.join([ cfg.eveowners.Get(charID).name for charID in charIDs[:hintLen] ]) 65 if len(charIDs) > hintLen: 66 hint += ', ...' 67 ret = uix.ListWnd(options, 'generic', localization.GetByLabel('UI/Corporations/Common/AwardCorpMemberDecoration'), isModal=1, ordered=1, scrollHeaders=[localization.GetByLabel('UI/Inventory/InvItemNameShort')], hint=hint) 68 if ret: 69 medalID = ret[1] 70 sm.StartService('medals').GiveMedalToCharacters(medalID, charIDs) 71 72 73 def GetOwnerLabel(ownerID): 74 name = '' 75 if ownerID is not None: 76 try: 77 name = ' (' + cfg.eveowners.Get(ownerID).name + ') ' 78 except: 79 sys.exc_clear() 80 81 return str(ownerID) + name 82 83 84 def CopyItemIDAndMaybeQuantityToClipboard(invItem): 85 txt = str(invItem.itemID) 86 if invItem.stacksize > 1: 87 txt = MenuLabel('UI/Menusvc/ItemAndQuantityForClipboard', {'itemID': str(invItem.itemID), 88 'quantity': invItem.stacksize}) 89 blue.pyos.SetClipboardData(txt) 90 91 92 def AddToQuickBar(typeID, parent = 0): 93 sm.GetService('marketutils').AddTypeToQuickBar(typeID, parent) 94 95 96 def RemoveFromQuickBar(node): 97 current = settings.user.ui.Get('quickbar', {}) 98 parent = node.parent 99 typeID = node.typeID 100 toDelete = None 101 for dataID, data in current.items(): 102 if parent == data.parent and type(data.label) == types.IntType: 103 if data.label == typeID: 104 toDelete = dataID 105 break 106 107 if toDelete: 108 del current[toDelete] 109 settings.user.ui.Set('quickbar', current) 110 sm.ScatterEvent('OnMarketQuickbarChange') 111 112 113 def TryLookAt(itemID, radius = None): 114 slimItem = uix.GetBallparkRecord(itemID) 115 isSiteBall = sm.GetService('sensorSuite').IsSiteBall(itemID) 116 if not slimItem and not isSiteBall: 117 return 118 camera = sm.GetService('sceneManager').GetActivePrimaryCamera() 119 camera.LookAt(itemID, objRadius=radius) 120 121 122 def ToggleLookAt(itemID, radius = None): 123 bp = sm.GetService('michelle').GetBallpark() 124 if bp: 125 ball = bp.GetBall(session.shipid) 126 if ball and ball.mode == destiny.DSTBALL_WARP: 127 return 128 TryLookAt(itemID, radius) 129 130 131 def AbandonLoot(wreckID): 132 twit = sm.GetService('michelle') 133 localPark = twit.GetBallpark() 134 allowedGroup = None 135 if wreckID in localPark.slimItems: 136 allowedGroup = localPark.slimItems[wreckID].groupID 137 if prompt_player_fsd_dialog('ConfirmAbandonLoot', {'type': (const.UE_GROUPID, allowedGroup)}, uiconst.YESNO, suppress=uiconst.ID_YES) != uiconst.ID_YES: 138 return 139 remotePark = sm.GetService('michelle').GetRemotePark() 140 if remotePark is not None: 141 remotePark.CmdAbandonLoot([wreckID]) 142 143 144 def AbandonAllLoot(wreckID): 145 twit = sm.GetService('michelle') 146 localPark = twit.GetBallpark() 147 remotePark = twit.GetRemotePark() 148 if remotePark is None: 149 return 150 wrecks = [] 151 allowedGroup = None 152 if wreckID in localPark.slimItems: 153 allowedGroup = localPark.slimItems[wreckID].groupID 154 if prompt_player_fsd_dialog('ConfirmAbandonLootAll', {'type': (const.UE_GROUPID, allowedGroup)}, uiconst.YESNO, suppress=uiconst.ID_YES) != uiconst.ID_YES: 155 return 156 bp = sm.GetService('michelle').GetBallpark() 157 for itemID, slimItem in localPark.slimItems.iteritems(): 158 if slimItem.groupID == allowedGroup: 159 if bp.HaveLootRight(itemID) and not bp.IsAbandoned(itemID): 160 wrecks.append(itemID) 161 162 if remotePark is not None: 163 remotePark.CmdAbandonLoot(wrecks) 164 165 166 def Eject(suppressConfirmation = False): 167 if suppressConfirmation or prompt_player_fsd_dialog('ConfirmEject', {}, uiconst.YESNO) == uiconst.ID_YES: 168 ship = sm.StartService('gameui').GetShipAccess() 169 if ship: 170 if session.stationid: 171 prompt_player_fsd_dialog('NoEjectingToSpaceInStation') 172 else: 173 log.LogNotice('Ejecting from ship', session.shipid) 174 sm.ScatterEvent('OnBeforeActiveShipChanged', None, eveCfg.GetActiveShip()) 175 sm.StartService('sessionMgr').PerformSessionChange('eject', ship.Eject) 176 177 178 def Board(itemID): 179 ship = sm.StartService('gameui').GetShipAccess() 180 if ship: 181 typeID = None 182 if not session.stationid: 183 ballparkRecord = uix.GetBallparkRecord(itemID) 184 if ballparkRecord: 185 typeID = ballparkRecord.typeID 186 else: 187 item = sm.GetService('godma').GetItem(itemID) 188 if item: 189 typeID = item.typeID 190 if typeID: 191 dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation() 192 if len(dogmaLocation.GetMissingSkills(typeID)) > 0: 193 prompt_missing_skill_requirements(typeID) 194 return 195 log.LogNotice('Boarding ship', itemID) 196 sm.ScatterEvent('OnBeforeActiveShipChanged', itemID, eveCfg.GetActiveShip()) 197 sm.StartService('sessionMgr').PerformSessionChange('board', ship.Board, itemID, session.shipid or session.stationid) 198 199 200 def BoardSMAShip(structureID, shipID): 201 ship = sm.StartService('gameui').GetShipAccess() 202 if ship: 203 log.LogNotice('Boarding SMA ship', structureID, shipID) 204 sm.ScatterEvent('OnBeforeActiveShipChanged', shipID, eveCfg.GetActiveShip()) 205 sm.StartService('sessionMgr').PerformSessionChange('board', ship.BoardStoredShip, structureID, shipID) 206 207 208 def SafeLogoff(): 209 shipAccess = sm.GetService('gameui').GetShipAccess() 210 failedConditions = shipAccess.SafeLogoff() 211 if failedConditions: 212 prompt_player_fsd_dialog('CustomNotify', {'notify': '<br>'.join([localization.GetByLabel('UI/Inflight/SafeLogoff/ConditionsFailedHeader')] + [ localization.GetByLabel(error) for error in failedConditions ])}) 213 214 215 def AskNewContainerPassword(invCacheSvc, id_, desc, which = 1, setnew = '', setold = ''): 216 container = invCacheSvc.GetInventoryFromId(id_) 217 wndFormat = [] 218 if container.HasExistingPasswordSet(which): 219 wndFormat.append({'type': 'edit', 220 'setvalue': setold or '', 221 'label': localization.GetByLabel('UI/Menusvc/OldPassword'), 222 'key': 'oldpassword', 223 'maxlength': 16, 224 'setfocus': 1, 225 'passwordChar': '*'}) 226 wndFormat.append({'type': 'edit', 227 'setvalue': setnew or '', 228 'label': localization.GetByLabel('UI/Menusvc/NewPassword'), 229 'key': 'newpassword', 230 'maxlength': 16, 231 'passwordChar': '*'}) 232 wndFormat.append({'type': 'edit', 233 'setvalue': '', 234 'label': localization.GetByLabel('UI/Menusvc/ConfirmPassword'), 235 'key': 'conpassword', 236 'maxlength': 16, 237 'passwordChar': '*'}) 238 retval = uix.HybridWnd(wndFormat, desc, windowID='askNewContainerPassword', icon=uiconst.QUESTION, minW=420, minH=75) 239 if retval: 240 old = retval['oldpassword'] or None if 'oldpassword' in retval else None 241 new = retval['newpassword'] or None 242 con = retval['conpassword'] or None 243 if new is None or len(new) < 3: 244 prompt_player_fsd_dialog('MinThreeLetters') 245 return AskNewContainerPassword(invCacheSvc, id_, desc, which, new, old) 246 if new != con: 247 prompt_player_fsd_dialog('NewPasswordMismatch') 248 return AskNewContainerPassword(invCacheSvc, id_, desc, which, new, old) 249 container.SetPassword(which, old, new) 250 251 252 def ConfigureALSC(itemID, invCacheSvc): 253 container = invCacheSvc.GetInventoryFromId(itemID) 254 config = container.ALSCConfigGet() 255 defaultLock = bool(config & const.ALSCLockAddedItems) 256 containerOwnerID = container.GetItem().ownerID 257 if idCheckers.IsCorporation(containerOwnerID): 258 if charsession.corprole & const.corpRoleEquipmentConfig == 0: 259 raise UserError('PermissionDeniedNeedEquipRole', {'corp': (const.UE_OWNERID, containerOwnerID)}) 260 else: 261 userDefaultLock = settings.user.ui.Get('defaultContainerLock_%s' % itemID, None) 262 if userDefaultLock: 263 defaultLock = True if userDefaultLock == const.flagLocked else False 264 configSettings = [(const.ALSCPasswordNeededToOpen, localization.GetByLabel('UI/Menusvc/ContainerPasswordForOpening')), 265 (const.ALSCPasswordNeededToLock, localization.GetByLabel('UI/Menusvc/ContainerPasswordForLocking')), 266 (const.ALSCPasswordNeededToUnlock, localization.GetByLabel('UI/Menusvc/ContainerPasswordForUnlocking')), 267 (const.ALSCPasswordNeededToViewAuditLog, localization.GetByLabel('UI/Menusvc/ContainerPasswordForViewingLog'))] 268 formFormat = [] 269 formFormat.append({'type': 'header', 270 'text': localization.GetByLabel('UI/Menusvc/ContainerDefaultLocked')}) 271 formFormat.append({'type': 'checkbox', 272 'setvalue': defaultLock, 273 'key': const.ALSCLockAddedItems, 274 'label': '', 275 'text': localization.GetByLabel('UI/Menusvc/ALSCLocked')}) 276 formFormat.append({'type': 'btline'}) 277 formFormat.append({'type': 'push'}) 278 formFormat.append({'type': 'header', 279 'text': localization.GetByLabel('UI/Menusvc/ContainerPasswordRequiredFor')}) 280 for value, settingName in configSettings: 281 formFormat.append({'type': 'checkbox', 282 'setvalue': value & config == value, 283 'key': value, 284 'label': '', 285 'text': settingName}) 286 287 formFormat.append({'type': 'btline'}) 288 formFormat.append({'type': 'push'}) 289 retval = uix.HybridWnd(formFormat, caption=localization.GetByLabel('UI/Menusvc/ContainerConfigurationHeader'), windowID='configureContainer', modal=1, buttons=uiconst.OKCANCEL, unresizeAble=1, minW=300) 290 if retval is None: 291 return 292 settings.user.ui.Delete('defaultContainerLock_%s' % itemID) 293 newconfig = 0 294 for k, v in retval.iteritems(): 295 newconfig |= k * v 296 297 if config != newconfig: 298 container.ALSCConfigSet(newconfig) 299 300 301 def RetrievePasswordALSC(itemID, invCacheSvc): 302 container = invCacheSvc.GetInventoryFromId(itemID) 303 formFormat = [] 304 formFormat.append({'type': 'header', 305 'text': localization.GetByLabel('UI/Menusvc/RetrieveWhichPassword')}) 306 formFormat.append({'type': 'push'}) 307 formFormat.append({'type': 'btline'}) 308 configSettings = [[const.SCCPasswordTypeGeneral, localization.GetByLabel('UI/Menusvc/GeneralPassword')], [const.SCCPasswordTypeConfig, localization.GetByLabel('UI/Menusvc/RetrievePasswordConfiguration')]] 309 for value, settingName in configSettings: 310 formFormat.append({'type': 'checkbox', 311 'setvalue': value & const.SCCPasswordTypeGeneral == value, 312 'key': value, 313 'label': '', 314 'text': settingName, 315 'group': 'which_password'}) 316 317 formFormat.append({'type': 'btline'}) 318 retval = uix.HybridWnd(formFormat, caption=localization.GetByLabel('UI/Commands/RetrievePassword'), windowID='retrieveContainerPassword', modal=1, buttons=uiconst.OKCANCEL) 319 if retval is None: 320 return 321 container.RetrievePassword(retval['which_password']) 322 323 324 def SetName(invOrSlimItem, invCacheSvc): 325 itemID = invOrSlimItem.itemID 326 invCacheSvc.TryLockItem(itemID, 'lockItemRenaming', {'itemType': invOrSlimItem.typeID}, 1) 327 try: 328 cfg.evelocations.Prime([itemID]) 329 categoryID = evetypes.GetCategoryID(invOrSlimItem.typeID) 330 if categoryID == const.categoryStructure: 331 return _SetStructureName(itemID) 332 try: 333 setval = cfg.evelocations.Get(itemID).name 334 except Exception: 335 setval = '' 336 sys.exc_clear() 337 338 maxLength = 100 339 if categoryID == const.categoryStarbase: 340 maxLength = 32 341 if categoryID == const.categoryShip: 342 nameRet = prompt_rename_ship(ship_type_id=invOrSlimItem.typeID, name=setval) 343 else: 344 nameRet = utilWindows.NamePopup(localization.GetByLabel('UI/Menusvc/SetName'), localization.GetByLabel('UI/Menusvc/TypeInNewName'), setvalue=setval, maxLength=maxLength) 345 if nameRet: 346 invCacheSvc.GetInventoryMgr().SetLabel(itemID, nameRet.replace('\n', ' ')) 347 sm.ScatterEvent('OnItemNameChange', itemID) 348 finally: 349 invCacheSvc.UnlockItem(itemID) 350 351 352 def _SetStructureName(structureID): 353 structureInfo = sm.GetService('structureDirectory').GetStructureInfo(structureID) 354 if structureInfo is None: 355 log.LogError('Trying to set a name on a non-existent structure', structureID) 356 return 357 if not idCheckers.IsSolarSystem(structureInfo.solarSystemID) or not structureInfo.inSpace: 358 log.LogError("Can't rename a structure that's not in space. What is", structureID, 'doing inside', structureInfo.solarSystemID, 'anyways?') 359 return 360 extraConfig = KeyVal() 361 if evetypes.IsUpwellStargate(structureInfo.typeID): 362 destinationSolarsystemID = sm.GetService('structureDirectory').GetJbStructureDestination(structureID) 363 if not destinationSolarsystemID: 364 raise UserError('JumpGateHasNoDestination') 365 extraConfig.destinationSolarsystemID = destinationSolarsystemID 366 namePrefix = GetStructureNamePrefix(structureInfo.typeID, structureInfo.solarSystemID, extraConfig) 367 currentName = cfg.evelocations.Get(structureID).locationName 368 if not currentName.startswith(namePrefix): 369 currentName = namePrefix + currentName 370 371 def _CheckLen(name, *args): 372 if len(name) - len(namePrefix) < structures.MIN_STRUCTURE_NAME_LEN: 373 raise UserError('CharNameTooShort') 374 375 newName = utilWindows.NamePopup(localization.GetByLabel('UI/Menusvc/SetName'), localization.GetByLabel('UI/Menusvc/TypeInNewName'), setvalue=currentName, maxLength=32 + len(namePrefix), fixedPrefix=namePrefix, validator=_CheckLen) 376 if newName: 377 sm.RemoteSvc('structureDeployment').RenameStructure(structureID, newName) 378 sm.GetService('structureDirectory').OnCorporationStructuresUpdated() 379 380 381 def RedeemCurrency(item, qty): 382 sm.GetService('invCache').GetInventoryMgr().DepositPlexToVault(session.stationid or session.structureid, item.itemID, qty, InvoiceType.InventoryToVault) 383 384 385 def ActivateCharacterReSculpt(itemID): 386 dialogParams = {'charName': cfg.eveowners.Get(session.charid).name} 387 if prompt_player_fsd_dialog('ActivateCharacterReSculpt', dialogParams, uiconst.YESNO) == uiconst.ID_YES: 388 sm.RemoteSvc('userSvc').ActivateCharacterReSculpt(itemID) 389 390 391 def _activate_ship_skin_license(itemID, typeID): 392 license = sm.GetService('cosmeticsSvc').GetStaticLicenseByID(typeID) 393 duration = None 394 if license.is_single_use: 395 key = 'ActivateSkinLicenseSingleUse' 396 elif license.is_permanent: 397 key = 'ActivateSkinLicensePermanent' 398 else: 399 key = 'ActivateSkinLicenseLimited' 400 duration = license.duration 401 parameters = _GetParametersForMsg(license, session.charid, duration) 402 if prompt_player_fsd_dialog(key, parameters, uiconst.YESNO, suppress=uiconst.ID_YES) == uiconst.ID_YES: 403 sm.GetService('cosmeticsSvc').ActivateShipSkinLicense([itemID]) 404 return True 405 else: 406 return False 407 408 409 def ActivateShipSkinLicense(itemAndTypeIDs): 410 if len(itemAndTypeIDs) > 1: 411 key = 'ActivateMultipleShipSkinLicense' 412 parameters = {'ownerID': session.charid, 413 'numSkins': len(itemAndTypeIDs)} 414 if prompt_player_fsd_dialog(key, parameters, uiconst.YESNO, suppress=uiconst.ID_YES) != uiconst.ID_YES: 415 return 416 itemIDs = [ x[0] for x in itemAndTypeIDs ] 417 sm.GetService('cosmeticsSvc').ActivateShipSkinLicense(itemIDs) 418 return 419 itemID, typeID = itemAndTypeIDs[0] 420 _activate_ship_skin_license(itemID, typeID) 421 422 423 def ActivateShipSkinLicenseAndApply(itemID, typeID): 424 if not _activate_ship_skin_license(itemID, typeID): 425 return 426 if not session.shipid: 427 return 428 licenceType = sm.GetService('cosmeticsSvc').GetSkinByLicenseType(typeID) 429 if not licenceType: 430 logger.error('licenceType not found for typeID=%r', typeID) 431 return 432 shipItem = sm.GetService('invCache').GetInventoryFromId(session.shipid).GetItem() 433 if not shipItem: 434 logger.error('shipItem not found for session.shipid=%r', session.shipid) 435 return 436 get_ship_skin_application_svc().apply_first_party_skin(shipItem.itemID, shipItem.typeID, licenceType) 437 438 439 def ConsumeSkinDesignComponent(items): 440 if len(items) == 0: 441 return 442 quantity = 0 443 for item in items: 444 _, _, stacksize = item 445 quantity += stacksize 446 447 if quantity > 1: 448 key = 'ConsumeMultipleSkinDesignComponents' 449 parameters = {'ownerID': session.charid, 450 'quantity': quantity} 451 if prompt_player_fsd_dialog(key, parameters, uiconst.YESNO, suppress=uiconst.ID_YES) != uiconst.ID_YES: 452 return 453 else: 454 key = 'ConsumeSkinDesignComponent' 455 _, typeID, _ = items[0] 456 parameters = {'ownerID': session.charid, 457 'typeID': typeID} 458 if prompt_player_fsd_dialog(key, parameters, uiconst.YESNO, suppress=uiconst.ID_YES) != uiconst.ID_YES: 459 return 460 from cosmetics.client.shipSkinComponentSvc import get_ship_skin_component_svc 461 error_msg = get_ship_skin_component_svc().consume_component_items(items) 462 if error_msg: 463 message_player(error_msg) 464 else: 465 sm.GetService('neocom').Blink(btnIDs.SHIP_SKINR, localization.GetByLabel('UI/Personalization/ShipSkins/SKINR/Studio/NewDesignElementAddedToCollection')) 466 467 468 def DecryptItem(itemID, typeID): 469 url = sm.RemoteSvc('encodedItems').DecodeItem(itemID) 470 if url is not None: 471 EncodedItemsWindow.Open(windowInstanceID=typeID, url=url, caption=evetypes.GetName(typeID), typeID=typeID) 472 473 474 def _GetParametersForMsg(license, ownerID, duration): 475 parameters = {'type': license.typeID, 476 'ownerID': ownerID, 477 'materialName': license.material.name, 478 'hullNames': ', '.join((evetypes.GetName(ship) for ship in license.skin.types)), 479 'days': duration} 480 return parameters 481 482 483 def ActivateSkillExtractor(item): 484 sm.GetService('skills').ActivateSkillExtractor(item) 485 486 487 def ActivateSkillInjector(item, quantity): 488 SkillInjectorWindow.OpenOrReload(injectorItem=item, quantity=quantity) 489 490 491 def SplitSkillInjector(itemID, quantity): 492 sm.GetService('skills').SplitSkillInjector(itemID, quantity) 493 494 495 def CombineSkillInjector(itemID, quantity): 496 sm.GetService('skills').CombineSkillInjector(itemID, quantity) 497 498 499 def OpenCrate(typeID, itemID, stacksize): 500 if is_fixed_crate(typeID): 501 FixedCrateWindow.Open(crate_stack_list=[(typeID, itemID, stacksize)]) 502 else: 503 CrateWindow.Open(typeID=typeID, itemID=itemID, stacksize=stacksize) 504 505 506 def CraftDynamicItem(item): 507 sm.GetService('dynamicItemSvc').OpenCraftWindow(item) 508 509 510 def ActivateAbyssalKey(item): 511 sm.GetService('abyss').open_key_activation_window(item) 512 513 514 def ActivateWarpVector(item): 515 sm.RemoteSvc('warpVectorMgr').UseVector(item.itemID) 516 517 518 def ActivateVoidSpaceKey(item): 519 sm.GetService('voidSpaceSvc').open_void_space_activation_window(item) 520 521 522 def ActivateRandomJumpKey(item): 523 sm.GetService('randomJumpSvc').open_random_jump_key_activation_window(item) 524 525 526 def ActivatePVPfilamentKey(item): 527 sm.GetService('pvpFilamentSvc').OpenPVPfilamentWindow(item) 528 529 530 def AbortSelfDestructShip(pickid): 531 if prompt_player_fsd_dialog('ConfirmAbortSelfDestruct', {}, uiconst.YESNO) == uiconst.ID_YES: 532 ship = sm.StartService('gameui').GetShipAccess() 533 if ship and not session.stationid: 534 log.LogNotice('Aborting self Destruct for', session.shipid) 535 sm.StartService('sessionMgr').PerformSessionChange('abortselfdestruct', ship.AbortSelfDestruct, pickid) 536 537 538 def SelfDestructShip(pickid): 539 slimItem = uix.GetBallparkRecord(pickid) 540 groupID = None 541 if slimItem: 542 groupID = slimItem.groupID 543 msg = 'ConfirmSelfDestruct' 544 msgArgs = {} 545 if groupID == const.groupCapsule: 546 msg = 'ConfirmSelfDestructCapsule' 547 implantCost = uix.GetImplantsCostForCharacter() 548 if implantCost: 549 implantsText = localization.GetByLabel('UI/Inflight/ImplantsLostOnSelfDestruct', iskValue=implantCost) 550 else: 551 implantsText = '' 552 msgArgs = {'implantsText': implantsText} 553 if prompt_player_fsd_dialog(msg, msgArgs, uiconst.YESNO) == uiconst.ID_YES: 554 ship = sm.StartService('gameui').GetShipAccess() 555 if ship and not session.stationid: 556 log.LogNotice('Self Destruct for', session.shipid) 557 sm.StartService('sessionMgr').PerformSessionChange('selfdestruct', ship.SelfDestruct, pickid) 558 559 560 def DeclareWar(): 561 from eve.client.script.ui.shared.neocom.corporation.war.warDeclare import WarDeclareWnd 562 wnd = WarDeclareWnd.GetIfOpen() 563 if wnd and not wnd.destroyed: 564 wnd.Maximize() 565 else: 566 WarDeclareWnd() 567 568 569 def DeclareWarAgainst(againstID): 570 from eve.client.script.ui.shared.neocom.corporation.war.warDeclare import WarDeclareWnd 571 wnd = WarDeclareWnd.GetIfOpen() 572 if wnd and not wnd.destroyed and wnd.warDeclareController.GetDefenderID() == againstID: 573 wnd.Maximize() 574 else: 575 WarDeclareWnd(defenderOwnerID=againstID) 576 577 578 def TransferOwnership(itemID): 579 members = sm.GetService('alliance').GetMembers() 580 twit = sm.GetService('michelle') 581 remotePark = twit.GetRemotePark() 582 localPark = twit.GetBallpark() 583 if itemID not in localPark.slimItems: 584 return 585 oldOwnerID = localPark.slimItems[itemID].ownerID 586 owners = {member.corporationID for member in members.itervalues()} 587 if len(owners): 588 cfg.eveowners.Prime(owners) 589 tmplist = [] 590 for member in members.itervalues(): 591 if oldOwnerID != member.corporationID: 592 tmplist.append((cfg.eveowners.Get(member.corporationID).ownerName, member.corporationID)) 593 594 ret = uix.ListWnd(tmplist, 'generic', localization.GetByLabel('UI/Corporations/Common/SelectCorporation'), None, 1, noContentHint=localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Members/NoMembersFound')) 595 if ret is not None and len(ret): 596 newOwnerID = ret[1] 597 if remotePark is not None: 598 remotePark.CmdTransferCorpAssetOwnership(itemID, oldOwnerID, newOwnerID) 599 600 601 def AbortSelfDestructStructure(itemID): 602 if prompt_player_fsd_dialog('ConfirmAbortSelfDestruct', {}, uiconst.YESNO) == uiconst.ID_YES: 603 michelle = sm.GetService('michelle') 604 localPark = michelle.GetBallpark() 605 if itemID not in localPark.slimItems: 606 return 607 remotePark = michelle.GetRemotePark() 608 if remotePark is not None: 609 remotePark.CmdAbortSelfDestructStructure(itemID) 610 611 612 def SelfDestructStructure(itemID): 613 timeDelayInMinutes = prefs.GetValue('secondsUntilStructureSelfDestruct', 1200) / 60 614 corpName = cfg.eveowners.Get(session.corpid).ownerName 615 if prompt_player_fsd_dialog('ConfirmSelfDestructStructure', {'durationInMin': timeDelayInMinutes, 616 'corpName': corpName}, uiconst.YESNO) == uiconst.ID_YES: 617 michelle = sm.GetService('michelle') 618 localPark = michelle.GetBallpark() 619 if itemID not in localPark.slimItems: 620 return 621 remotePark = michelle.GetRemotePark() 622 if remotePark is not None: 623 remotePark.CmdSelfDestructStructure(itemID) 624 625 626 def TransferCorporationOwnership(itemID): 627 michelle = sm.GetService('michelle') 628 remotePark = michelle.GetRemotePark() 629 localPark = michelle.GetBallpark() 630 if itemID not in localPark.slimItems or remotePark is None: 631 return 632 oldOwnerID = localPark.slimItems[itemID].ownerID 633 name = utilWindows.NamePopup(localization.GetByLabel('UI/Corporations/Common/TransferOwnership'), localization.GetByLabel('UI/Corporations/Common/TransferOwnershipLabel')) 634 if name is None: 635 return 636 owner = searchOld.SearchOwners(searchStr=name, groupIDs=[const.groupCorporation], hideNPC=True, notifyOneMatch=True, searchWndName='AddToBlockSearch') 637 if owner is None or owner == oldOwnerID: 638 return 639 remotePark.CmdTransferCorpAssetOwnership(itemID, oldOwnerID, owner)