structureProfileEntry.py (6230B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\structure\structureBrowser\entries\structureProfileEntry.py 2 import itertoolsext 3 from carbon.common.script.sys.serviceConst import ROLEMASK_ELEVATEDPLAYER 4 from menu import MenuLabel 5 from eve.client.script.ui.control.eveLabel import EveLabelMedium 6 from eve.client.script.ui.structure import ChangeSignalConnect 7 from eve.client.script.ui.structure.structureBrowser.nameAndDescriptionWnd import EditProfileNameAndDescriptionWnd 8 from eve.client.script.ui.structure.structureSettings.profileEntry import ProfileEntryBase 9 import carbonui.const as uiconst 10 import blue 11 import log 12 import eve.client.script.ui.structure.structureBrowser.browserUIConst as browserUIConst 13 from carbonui.uicore import uicore 14 from player_messaging.client.ui_message import prompt_player_fsd_dialog 15 16 class StructureProfileEntry(ProfileEntryBase): 17 default_align = uiconst.TOTOP 18 default_state = uiconst.UI_NORMAL 19 ENTRYHEIGHT = 36 20 21 def ApplyAttributes(self, attributes): 22 ProfileEntryBase.ApplyAttributes(self, attributes) 23 self.sr.node = self.node = attributes.node 24 self.profileController = self.node.profileController 25 self.allStructuresProfileController = self.node.allStructuresProfileController 26 self.structureBrowserController = self.node.structureBrowserController 27 self.ChangeSignalConnection(connect=True) 28 isSelected = self.node.isSelected 29 self.node.isSelected = None 30 if isSelected: 31 self.Select() 32 profileName = self.profileController.GetProfileName() 33 self.profileNameLabel = EveLabelMedium(name='profileName', parent=self, left=10, align=uiconst.CENTERLEFT, text=profileName) 34 self.hint = self.profileController.GetProfileDescription() 35 if self.profileController.IsDefault(): 36 self.profileNameLabel.underline = True 37 38 def ChangeSignalConnection(self, connect = True): 39 signalAndCallback = [(self.structureBrowserController.on_profile_selected, self.OnProfileSelected), (self.allStructuresProfileController.on_profile_assigned, self.OnProfileAssigned)] 40 ChangeSignalConnect(signalAndCallback, connect) 41 42 def Load(self, node): 43 pass 44 45 def OnClick(self, *args): 46 if not self.structureBrowserController.HasProfileChanged(): 47 self.Select() 48 profileID = self.profileController.GetProfileID() 49 self.structureBrowserController.SelectProfile(profileID) 50 51 def OnDropData(self, dragSource, dragData): 52 firstNode = dragData[0] 53 isMyCorpStructureEntry = getattr(firstNode, 'isMyCorpStructureEntry', False) 54 if not isMyCorpStructureEntry: 55 return 56 profileID = self.profileController.GetProfileID() 57 if profileID == browserUIConst.ALL_PROFILES: 58 return 59 structureIDs = [] 60 for eachNode in dragData: 61 structureIDs.append(eachNode.itemID) 62 63 self.allStructuresProfileController.UpdateProfileIDForStructures(profileID, structureIDs) 64 65 def IsThisProfile(self, profileID): 66 return profileID == self.profileController.GetProfileID() 67 68 def OnProfileSelected(self, profileID): 69 if self.destroyed: 70 return 71 if self.IsThisProfile(profileID): 72 self.Select() 73 else: 74 self.Deselect() 75 76 def OnProfileAssigned(self, profileID): 77 if not self.IsThisProfile(profileID): 78 return 79 self.CheckConstructBlinkBG() 80 uicore.animations.FadeTo(self.blinkBG, 0.0, 0.25, duration=0.25, curveType=uiconst.ANIM_WAVE, loops=2) 81 82 def GetMenu(self, *args): 83 m = [(MenuLabel('UI/StructureBrowser/EditNameAndDescription'), self.EditNameAndDescription, ()), (MenuLabel('UI/StructureBrowser/DuplicateProfile'), self.DuplicateProfile, ()), (MenuLabel('UI/StructureBrowser/DeleteProfile'), self.DeleteProfile, ())] 84 if session.corprole & const.corpRoleStationManager and not self.profileController.IsDefault(): 85 m.append((MenuLabel('UI/StructureBrowser/SetDefaultProfile'), self.SetDefaultProfile, ())) 86 if session.role & ROLEMASK_ELEVATEDPLAYER: 87 profileID = self.profileController.GetProfileID() 88 m.append(('GM: profileID: ' + str(profileID), blue.pyos.SetClipboardData, (str(profileID),))) 89 return m 90 91 def DuplicateProfile(self, *args): 92 profileID = self.profileController.GetProfileID() 93 self.allStructuresProfileController.DuplicateProfile(profileID) 94 95 def DeleteProfile(self, *args): 96 profileID = self.profileController.GetProfileID() 97 structureControllers = self.structureBrowserController.GetMyStructures() 98 usingProfile = itertoolsext.count(structureControllers, lambda x: x.GetProfileID() == profileID) 99 if usingProfile: 100 raise UserError('CannotDeleteStructureProfileInUse', {'numStructures': usingProfile}) 101 reply = prompt_player_fsd_dialog('DeleteStructureProfile', buttons=uiconst.YESNO) 102 if reply != uiconst.ID_YES: 103 return 104 self.allStructuresProfileController.DeleteProfile(profileID) 105 self.structureBrowserController.ProfileDeleted(profileID) 106 107 def EditNameAndDescription(self): 108 EditProfileNameAndDescriptionWnd(controller=self.profileController) 109 110 def SetDefaultProfile(self): 111 self.profileController.SetDefaultProfile() 112 self.structureBrowserController.on_default_profile_set() 113 114 def Close(self): 115 try: 116 self.ChangeSignalConnection(connect=False) 117 except Exception as e: 118 log.LogError('Failed at closing profile entry, e = ', e) 119 finally: 120 self.profileController = None 121 self.allStructuresProfileController = None 122 self.structureBrowserController = None 123 ProfileEntryBase.Close(self) 124 125 126 class StructureAllProfilesEntry(StructureProfileEntry): 127 128 def ApplyAttributes(self, attributes): 129 StructureProfileEntry.ApplyAttributes(self, attributes) 130 self.profileNameLabel.bold = True 131 if self.rightBtn: 132 self.rightBtn.Close() 133 self.rightBtn = None 134 135 def GetMenu(self): 136 return []