serviceListCont.py (4140B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\structure\structureSettings\serviceListCont.py 2 from carbonui.primitives.container import Container 3 from carbonui.primitives.flowcontainer import FlowContainer 4 from eve.client.script.ui.control.toggleButtonGroupButton import LegacyToggleButtonGroupButton 5 import carbonui.const as uiconst 6 from eve.client.script.ui.structure import ChangeSignalConnect 7 from localization import GetByLabel 8 import structures 9 10 class ServiceListCont(Container): 11 default_align = uiconst.TORIGHT 12 default_padBottom = 8 13 default_padTop = 0 14 default_width = 48 15 default_clipChildren = True 16 17 def ApplyAttributes(self, attributes): 18 Container.ApplyAttributes(self, attributes) 19 self.SetController(attributes.structureBrowserController) 20 21 def SetController(self, controller): 22 self.structureBrowserController = controller 23 self.ChangeSignalConnection(connect=True) 24 self.LoadList() 25 26 def ChangeSignalConnection(self, connect = True): 27 signalAndCallback = [(self.structureBrowserController.on_category_selected, self.OnCategorySelected)] 28 ChangeSignalConnect(signalAndCallback, connect) 29 30 def LoadList(self): 31 self.Flush() 32 self.AddHullButtons() 33 Container(parent=self, name='push', pos=(0, 0, 20, 20), align=uiconst.NOALIGN) 34 self.AddSerivceModuleButtons() 35 36 def AddHullButtons(self): 37 for categoryID in structures.CATEGORIES_HULL: 38 self.AddButton(categoryID, color=None) 39 40 def AddSerivceModuleButtons(self): 41 usedCat = self.GetModuleCategories() 42 usedCat.sort(key=lambda x: (self.GetCategoryNamePath(x) if x else None)) 43 for categoryID in usedCat: 44 self.AddButton(categoryID, color=(0.4, 0.4, 0.4, 0.1)) 45 46 def GetCategoryNamePath(self, categoryID): 47 categoryNamePath = structures.CATEGORY_LABELS.get(categoryID, None) 48 return categoryNamePath 49 50 def AddButton(self, categoryID, color): 51 categoryNamePath = self.GetCategoryNamePath(categoryID) 52 if categoryNamePath is None: 53 return 54 iconPath = structures.CATEGORY_TEXTURES.get(categoryID, None) 55 btn = ServiceToggleButton(name='Button_%s' % categoryID, parent=self, controller=self.structureBrowserController, btnID=categoryID, iconPath=iconPath, hint=GetByLabel(categoryNamePath), colorSelected=color, categoryID=categoryID) 56 if categoryID == self.structureBrowserController.GetSelectedCategory(): 57 btn.SetSelected(animate=False) 58 return btn 59 60 def LoadCategory(self, categoryID, *args): 61 self.structureBrowserController.SelectCategory(categoryID) 62 63 def OnCategorySelected(self, *args): 64 pass 65 66 def SortScrollList(self, scrollList): 67 return sorted(scrollList, key=lambda x: x.sort_sortValue) 68 69 def GetModuleCategories(self): 70 return structures.CATEGORIES_MODULES 71 72 def Close(self): 73 self.ChangeSignalConnection(connect=False) 74 FlowContainer.Close(self) 75 76 77 class ServiceToggleButton(LegacyToggleButtonGroupButton): 78 default_height = 38 79 default_width = 48 80 default_iconSize = 26 81 default_align = uiconst.TOTOP 82 default_showBg = False 83 84 def ApplyAttributes(self, attributes): 85 LegacyToggleButtonGroupButton.ApplyAttributes(self, attributes) 86 self.controller = self.controller 87 self.ChangeSignalConnection(connect=True) 88 self.categoryID = attributes.categoryID 89 90 def ChangeSignalConnection(self, connect = True): 91 signalAndCallback = [(self.controller.on_category_selected, self.OnCategorySelected)] 92 ChangeSignalConnect(signalAndCallback, connect) 93 94 def OnClick(self, *args): 95 if not self.isDisabled: 96 self.controller.SelectCategory(self.categoryID) 97 98 def OnCategorySelected(self, categoryID): 99 if categoryID == self.categoryID: 100 self.SetSelected() 101 else: 102 self.SetDeselected() 103 104 def Close(self): 105 self.ChangeSignalConnection(connect=False) 106 LegacyToggleButtonGroupButton.Close(self)