structureSettingsWnd.py (6133B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\structure\structureSettings\structureSettingsWnd.py 2 from carbonui.primitives.container import Container 3 from carbonui.control.button import Button 4 from eve.client.script.ui.control.eveLabel import EveLabelLarge 5 from eve.client.script.ui.control.themeColored import LineThemeColored 6 from eve.client.script.ui.structure import ChangeSignalConnect 7 from eve.client.script.ui.structure.structureBrowser.browserUIConst import ALL_PROFILES 8 from eve.client.script.ui.structure.structureSettings.serviceListCont import ServiceListCont 9 from eve.client.script.ui.structure.structureSettings.settingsCategoryCont import SettingsCategoryCont 10 from localization import GetByLabel 11 import log 12 import structures 13 import carbonui.const as uiconst 14 from player_messaging.client.ui_message import prompt_player_fsd_dialog 15 NO_GROUP = 0 16 17 class StructureProfileSettingCont(Container): 18 TAB_ID = 'PROFILE_SETTINGS' 19 20 def ApplyAttributes(self, attributes): 21 Container.ApplyAttributes(self, attributes) 22 self.structureBrowserController = attributes.structureBrowserController 23 self.allStructuresProfileController = attributes.allStructuresProfileController 24 self.ChangeSignalConnection(connect=True) 25 self.structureProfileController = None 26 self.SetStructureProfileController() 27 28 def ChangeSignalConnection(self, connect = True): 29 signalAndCallback = [(self.structureBrowserController.on_profile_selected, self.OnProfileSelected)] 30 ChangeSignalConnect(signalAndCallback, connect) 31 32 def SetStructureProfileController(self): 33 profileID = self.structureBrowserController.GetSelectedProfileID() 34 if profileID != ALL_PROFILES: 35 slimController = self.allStructuresProfileController.GetSlimProfileController(profileID) 36 if slimController is None: 37 return 38 self.ChangeSignalConnectionForProfileController(connect=False) 39 self.structureProfileController = slimController.GetFullProfileController() 40 self.ChangeSignalConnectionForProfileController(connect=True) 41 42 def ChangeSignalConnectionForProfileController(self, connect = True): 43 if self.structureProfileController: 44 signalAndCallback = [(self.structureProfileController.on_profile_value_changed, self.OnProfileChanged)] 45 ChangeSignalConnect(signalAndCallback, connect) 46 47 def OnTabSelect(self): 48 profileID = self.structureBrowserController.GetSelectedProfileID() 49 if self.structureProfileController is None: 50 self.SetStructureProfileController() 51 self.structureBrowserController.SetTabSelected(self.TAB_ID) 52 self.ConstructUI() 53 54 def ConstructUI(self, flush = True): 55 self.Flush() 56 profileID = self.structureBrowserController.GetSelectedProfileID() 57 if profileID == ALL_PROFILES: 58 return 59 btnCont = Container(parent=self, idx=0, height=32, align=uiconst.TOBOTTOM) 60 LineThemeColored(parent=btnCont, colorType=uiconst.COLORTYPE_UIHILIGHT, align=uiconst.TOTOP) 61 self.saveBtn = Button(parent=btnCont, label=GetByLabel('UI/Common/Buttons/Save'), func=self.SaveProfile, align=uiconst.CENTERRIGHT) 62 self.mainCont = Container(name='mainCont', parent=self, padding=(0, 4, 4, 4)) 63 self.categoryListCont = ServiceListCont(name='groupListCont', parent=self.mainCont, structureBrowserController=self.structureBrowserController) 64 profileName = self.structureProfileController.GetProfileName() 65 EveLabelLarge(text=profileName, parent=self.mainCont, state=uiconst.UI_DISABLED, align=uiconst.TOTOP, top=4, padBottom=5) 66 self.categoryCont = SettingsCategoryCont(name='categoryCont', parent=self.mainCont, padding=(0, 2, 0, 2), structureBrowserController=self.structureBrowserController, structureProfileController=self.structureProfileController) 67 68 def SaveProfile(self, *args): 69 settingsToSave = [] 70 scBySettingID = self.structureProfileController.GetAllGroups() 71 groupIDsInSettings = set() 72 for settingID, scSet in scBySettingID.iteritems(): 73 for eachSg in scSet: 74 if eachSg.GetSettingType() == structures.SETTINGS_TYPE_BOOL: 75 groupID = NO_GROUP 76 else: 77 groupID = eachSg.GetGroupID() 78 groupIDsInSettings.add(groupID) 79 settingsToSave.append((settingID, eachSg.GetValue(), groupID)) 80 81 accessGroupsController = sm.GetService('structureControllers').GetAccessGroupController() 82 accessGroupsController.PopulatePublicGroupInfo(groupIDsInSettings, forceFetchInfoForPublicGroup=True) 83 warning = False 84 toSave = [] 85 for settingID, value, groupID in settingsToSave: 86 if accessGroupsController.GetGroupInfoFromID(groupID, fetchToServer=False) is None: 87 warning = True 88 continue 89 toSave.append((settingID, value, groupID)) 90 91 if warning: 92 prompt_player_fsd_dialog('CustomNotify', {'notify': GetByLabel('UI/StructureSettingWnd/AccessListNotValid')}) 93 oldHadChangedValue = self.structureBrowserController.HasProfileChanged() 94 try: 95 self.structureBrowserController.SetProfileChangedValue(False) 96 self.structureProfileController.SaveProfile(toSave) 97 except Exception: 98 self.structureBrowserController.SetProfileChangedValue(oldHadChangedValue) 99 raise 100 101 def OnProfileSelected(self, profileID): 102 self.SetStructureProfileController() 103 self.ConstructUI() 104 105 def OnProfileChanged(self): 106 self.saveBtn.Blink() 107 self.structureBrowserController.SetProfileChangedValue(True) 108 109 def Close(self): 110 try: 111 self.ChangeSignalConnection(connect=False) 112 self.ChangeSignalConnectionForProfileController(connect=False) 113 except Exception as e: 114 log.LogError('Failed at closing structure setting wnd, e = ', e) 115 finally: 116 Container.Close(self)