def Load(self): self.Flush() topCont = ContainerAutoSize(parent=self, align=uiconst.TOTOP, padding=(0, 2, 0, 2)) btnGroup = ToggleButtonGroup(parent=topCont, align=uiconst.CENTER, height=38, width=248, callback=self.LoadActivity) for activityID in industry.ACTIVITIES: isDisabled = activityID not in self.bpData.activities color = industryUIConst.GetActivityColor(activityID) color = color[:3] + (0.5, ) btnGroup.AddButton( activityID, iconPath=industryUIConst.ACTIVITY_ICONS_LARGE[activityID], iconSize=26, colorSelected=color, isDisabled=isDisabled, btnClass=ActivityToggleButtonGroupButton, activityID=activityID) self.activityNameLabel = EveLabelMediumBold(name='label', parent=self, align=uiconst.TOTOP, padding=(6, 0, 0, 0)) self.scroll = Scroll(parent=self, padding=const.defaultPadding) activityID = self.GetSelectedActivityID(activityID) btnGroup.SelectByID(activityID)
def Load(self): self.Flush() toggleButtonCont = Container(name='btnGroupCont', parent=self, align=uiconst.TOTOP, height=45) btnGroup = ToggleButtonGroup(parent=toggleButtonCont, align=uiconst.CENTER, height=toggleButtonCont.height, width=330, padding=(10, 4, 10, 3), callback=self.LoadCertificateSkillsLevel) btns = ((1, 'res:/UI/Texture/icons/79_64_2.png'), (2, 'res:/UI/Texture/icons/79_64_3.png'), (3, 'res:/UI/Texture/icons/79_64_4.png'), (4, 'res:/UI/Texture/icons/79_64_5.png'), (5, 'res:/UI/Texture/icons/79_64_6.png')) for level, iconPath in btns: hint = localization.GetByLabel( 'UI/InfoWindow/CertificateLevelButtonHint', level=level) btnGroup.AddButton(btnID=level, iconPath=iconPath, iconSize=32, hint=hint) self.masteryTimeLabel = EveLabelMediumBold(name='masteryTimeLabel', parent=self, align=uiconst.TOTOP, top=10, left=10) self.scroll = Scroll(name='certSkillScroll', parent=self, padding=const.defaultPadding) cert = sm.GetService('certificates').GetCertificate(self.certificateID) btnGroup.SelectByID(max(1, cert.GetLevel()))
def Load(self): self.Flush() toggleButtonCont = Container(name='btnGroupCont', parent=self, align=uiconst.TOTOP, height=35) btnGroup = ToggleButtonGroup(parent=toggleButtonCont, align=uiconst.CENTER, height=toggleButtonCont.height, width=300, padding=(10, 4, 10, 3), callback=self.LoadRequiredForLevel) for level in xrange(1, 6): hint = localization.GetByLabel( 'UI/InfoWindow/RequiredForLevelButtonHint', skillName=cfg.invtypes.Get(self.typeID).name, level=level) isDisabled = not bool( cfg.GetTypesRequiredBySkill(self.typeID).get(level, None)) btnGroup.AddButton(btnID=level, label=uiutil.IntToRoman(level), hint=hint, isDisabled=isDisabled) self.scroll = Scroll(name='scroll', parent=self, padding=const.defaultPadding) btnGroup.SelectFirst()
def Load(self): self.Flush() toggleButtonCont = Container(name='btnGroupCont', parent=self, align=uiconst.TOTOP, height=45) btnGroup = ToggleButtonGroup(parent=toggleButtonCont, align=uiconst.CENTER, height=toggleButtonCont.height, width=330, padding=(10, 4, 10, 3), callback=self.LoadMasteryLevel) for level, iconPath in BUTTONS: hint = localization.GetByLabel( 'UI/InfoWindow/MasteryLevelButtonHint', level=level) if level == 5: color = Color(*shipTreeConst.COLOR_MASTERED).SetBrightness( 0.2).GetRGBA() else: color = Color( *shipTreeConst.COLOR_BG).SetBrightness(0.35).GetRGBA() btnGroup.AddButton(btnID=level, iconPath=iconPath, iconSize=45, hint=hint, colorSelected=color) self.masteryHeader = Container(name='masteryHeader', parent=self, align=uiconst.TOTOP, height=25) self.settingsMenu = uicls.UtilMenu( menuAlign=uiconst.TOPLEFT, parent=self.masteryHeader, align=uiconst.BOTTOMLEFT, left=4, GetUtilMenu=self.GetSettingsMenu, texturePath='res:/UI/Texture/SettingsCogwheel.png', width=16, height=16, iconSize=18) self.masteryTimeLabel = EveLabelMediumBold(name='masteryTimeLabel', parent=self.masteryHeader, align=uiconst.BOTTOMLEFT, left=24) self.masteryScroll = Scroll(name='masteryScroll', parent=self, padding=const.defaultPadding) level = sm.GetService('certificates').GetCurrCharMasteryLevel( self.typeID) level = max(level, 1) btnGroup.SelectByID(level)
class ActivitySelectionButtons(Container): default_name = 'ActivityTabs' default_height = 32 def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.callback = attributes.callback self.jobData = None self.btnGroup = None self.ReconstructButtons() def ReconstructButtons(self): if self.btnGroup: self.btnGroup.Close() self.btnGroup = ToggleButtonGroup(name='myToggleBtnGroup', parent=self, align=uiconst.TOALL, callback=self.OnActivitySelected, height=0) for activityID in ACTIVITIES: isDisabled = self.jobData is None or activityID not in self.jobData.blueprint.activities color = industryUIConst.GetActivityColor(activityID) color = Color(*color).SetBrightness(0.5).GetRGBA() btn = self.btnGroup.AddButton( activityID, iconPath=industryUIConst.ACTIVITY_ICONS_LARGE[activityID], iconSize=26, colorSelected=color, isDisabled=isDisabled, btnClass=ActivityToggleButtonGroupButton, activityID=activityID) def OnNewJobData(self, jobData): oldJobData = self.jobData self.jobData = jobData if jobData: jobData.on_updated.connect(self.OnJobDataUpdated) blueprint = oldJobData.blueprint if oldJobData else None if jobData and jobData.blueprint.IsSameBlueprint(blueprint): self.UpdateSelectedBtn() return self.ReconstructButtons() self.UpdateState() def OnJobDataUpdated(self, jobData): self.UpdateState() def UpdateState(self): if self.jobData and self.jobData.IsInstalled(): self.btnGroup.Disable() self.btnGroup.opacity = 0.5 else: self.btnGroup.Enable() self.btnGroup.opacity = 1.0 if not self.jobData: return self.UpdateSelectedBtn(self.jobData.activityID) for btn in self.btnGroup.buttons: activityID = btn.btnID if self.jobData.facility and activityID not in self.jobData.facility.activities: btn.ShowErrorFrame() else: btn.HideErrorFrame() def UpdateSelectedBtn(self, activityID=None): if self.btnGroup: self.btnGroup.SetSelectedByID(self.jobData.activityID, animate=False) def OnActivitySelected(self, activityID): self.callback(self.jobData.blueprint, activityID)
def ApplyAttributes(self, attributes): self.viewState = sm.GetService('viewState') if not settings.user.ui.Get('stationservicebtns', 1): minWidth = BIGBUTTONSIZE + (BIGBUTTONSIZE + BUTTONGAP) * 3 + 14 minHeight = 495 else: minWidth = SMALLBUTTONSIZE + (SMALLBUTTONSIZE + BUTTONGAP) * 5 + 10 minHeight = 470 self.default_minSize = (minWidth, minHeight) Window.ApplyAttributes(self, attributes) self.stationSvc = sm.GetService('station') self.guestScroll = None self.sr.serviceAccessCache = {} self.SetWndIcon(None) self.HideHeader() self.scope = 'station' self.MakeUnKillable() self.MakeUnstackable() self.SetTopparentHeight(0) main = self.sr.main main.clipChildren = True self.corpLogoParent = Container(name='corpLogoParent', align=uiconst.TOTOP, height=160, parent=main) self.corpName = CaptionLabel(parent=main, align=uiconst.TOTOP, name='corpName', uppercase=False) self.undockparent = Container(name='undockparent', align=uiconst.TOTOP, height=78, parent=main) self.AddCQButton(parent=self.undockparent) self.AddUndockButton(parent=self.undockparent) EveLabelMedium(text=localization.GetByLabel('UI/Station/StationServices'), align=uiconst.TOTOP, parent=main, bold=True, padding=(6, 6, 6, 0)) self.serviceButtons = FlowContainer(name='serviceButtons', align=uiconst.TOTOP, parent=main, contentSpacing=(BUTTONGAP, BUTTONGAP), padding=(6, 6, 3, 6)) btnGroup = ToggleButtonGroup(name='btnGroup', parent=main, align=uiconst.TOTOP, height=32, padding=(6, 6, 6, 6), idx=-1, callback=self.OnButtonGroupSelection) self.mainButtonGroup = btnGroup self.guestsPanel = Container(name=GUESTSPANEL, parent=main, padding=const.defaultPadding) self.quickFilter = QuickFilterEdit(name='quickFilterEdit', parent=self.guestsPanel) self.quickFilter.ReloadFunction = lambda : self.ShowGuests() self.guestScroll = BasicDynamicScroll(parent=self.guestsPanel, padTop=const.defaultPadding + self.quickFilter.height) guestSettingsMenu = UtilMenu(menuAlign=uiconst.TOPRIGHT, parent=self.guestsPanel, align=uiconst.TOPRIGHT, GetUtilMenu=self.SettingMenu, texturePath='res:/UI/Texture/SettingsCogwheel.png', width=18, height=18, iconSize=18) self.userType = settings.user.ui.Get('guestCondensedUserList', False) self.agentsPanel = Container(name=AGENTSPANEL, parent=main, padding=const.defaultPadding) self.agentFinderBtn = Button(label=localization.GetByLabel('UI/AgentFinder/AgentFinder'), parent=self.agentsPanel, align=uiconst.CENTERTOP, func=uicore.cmd.OpenAgentFinder) self.agentScroll = Scroll(parent=self.agentsPanel, padTop=const.defaultPadding + self.agentFinderBtn.height) self.officesPanel = Container(name=OFFICESPANEL, parent=main, padding=const.defaultPadding) self.officesButtons = FlowContainer(name='officesButtons', align=uiconst.TOTOP, parent=self.officesPanel, contentSpacing=(4, 4), centerContent=True) self.officesScroll = Scroll(parent=self.officesPanel, padTop=const.defaultPadding) agentsButton = btnGroup.AddButton(AGENTSPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Agents'), self.agentsPanel, btnClass=LobbyToggleButtonGroupButton, hint=localization.GetByLabel('Tooltips/StationServices/AgentsTab_descrtiption')) agentsButton.name = 'stationInformationTabAgents' guestsButton = btnGroup.AddButton(GUESTSPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Guests'), self.guestsPanel, btnClass=LobbyToggleButtonGroupButton, hint=localization.GetByLabel('Tooltips/StationServices/GuestsTab_description')) guestsButton.counter = CounterBox(parent=guestsButton, align=uiconst.TOPRIGHT, left=2, top=-5) self.guestsButton = guestsButton btnGroup.AddButton(OFFICESPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Offices'), self.officesPanel, btnClass=LobbyToggleButtonGroupButton, hint=localization.GetByLabel('Tooltips/StationServices/OfficesTab_description')) activePanel = settings.user.ui.Get('stationsLobbyTabs', AGENTSPANEL) if settings.char.windows.Get('dockshipsanditems', 0): self.inventoryPanel = Container(name=INVENTORYPANEL, parent=main) self.sr.shipsContainer = Container(parent=self.inventoryPanel, state=uiconst.UI_HIDDEN, padding=const.defaultPadding) self.sr.itemsContainer = Container(parent=self.inventoryPanel, state=uiconst.UI_HIDDEN, padding=const.defaultPadding) tabs = [[localization.GetByLabel('UI/Station/Ships'), self.sr.shipsContainer, self, 'lobby_ships'], [localization.GetByLabel('UI/Station/Items'), self.sr.itemsContainer, self, 'lobby_items']] self.inventoryTabs = TabGroup(name='inventoryPanel', parent=self.inventoryPanel, idx=0) self.inventoryTabs.Startup(tabs, 'lobbyInventoryPanel', autoselecttab=True, UIIDPrefix='lobbyInventoryPanelTab') self.invButton = btnGroup.AddButton(INVENTORYPANEL, '<center>' + localization.GetByLabel('UI/Station/Lobby/Hangars'), self.inventoryPanel, btnClass=LobbyToggleButtonGroupButton, hint='<b>%s</b><br>%s' % (localization.GetByLabel('Tooltips/StationServices/Hangars'), localization.GetByLabel('Tooltips/StationServices/Hangars_description'))) elif activePanel == INVENTORYPANEL: activePanel = AGENTSPANEL btnGroup.SelectByID(activePanel) myDefaultView = 'hangar' if session.userid % 2 == 1 else 'station' curView = collections.namedtuple('FakeViewInfo', ['name'])(settings.user.ui.Get('defaultDockingView', myDefaultView)) self.OnPrimaryViewChanged(curView, curView) self.LoadOwnerInfo() self.LoadServiceButtons() if self.destroyed: return sm.RegisterNotify(self) self.UpdateGuestTabText()
class LeftPanel(Container): default_clipChildren = True default_padBottom = 4 default_padLeft = 10 __notifyevents__ = [ 'OnFittingsUpdated', 'OnFittingDeleted', 'OnSkillFilteringUpdated', 'OnSlotDblClicked' ] def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.fittingSvc = sm.GetService('fittingSvc') self.configName = attributes.configName self.controller = attributes.controller self.ChangeSignalConnection() self.loaded = False padding = 0 self.ammoShowingForType = None btnCont = FlowContainer(parent=self, align=uiconst.TOBOTTOM, contentAlignment=CONTENT_ALIGN_RIGHT, padTop=4, padRight=0, contentSpacing=uiconst.BUTTONGROUPMARGIN) self.fitBtn = Button(parent=btnCont, label='Fit Ship', func=self.FitShip, align=uiconst.NOALIGN) self.builtShipBtn = Button( parent=btnCont, label=GetByLabel('UI/Fitting/FittingWindow/BuildShip'), func=self.BuildShip, align=uiconst.NOALIGN) self.saveBtn = Button( parent=btnCont, label=GetByLabel('UI/Fitting/FittingWindow/SaveFitAs'), func=self.SaveFitting, align=uiconst.NOALIGN) SetFittingTooltipInfo(targetObject=self.saveBtn, tooltipName='SaveFitting', includeDesc=False) self.AdjustButtons() self.btnGroup = ToggleButtonGroup(name='fittingToggleBtnGroup', parent=self, align=uiconst.TOTOP, callback=self.BrowserSelected, height=40, idx=-1) self.AddExportImportMenu() self.AddSearchFields() self.AddFilterCont() self.hwBrowserBtns = self.AddHardwareSelcetionCont() self.AddFittingFilterButtons() self.hardwareFilterBtns = self.AddHardwareFilterButtons() self.AddChargeFilterButtons() self.browserBtns = {} self.moduleChargeButtons = {} for btnID, labelPath, iconPath, dblClickCallback in ( (BROWSE_FITTINGS, 'UI/Fitting/FittingWindow/ShipAndFittings', 'res:/UI/Texture/classes/Fitting/tabFittings.png', self.LoadFittingSetup), (BROWSE_HARDWARE, 'UI/Fitting/FittingWindow/Hardware', 'res:/UI/Texture/classes/Fitting/tabHardware.png', None)): btn = self.btnGroup.AddButton(btnID, GetByLabel(labelPath), iconPath=iconPath, btnClass=ToggleButtonGhost) self.browserBtns[btnID] = btn if dblClickCallback: btn.OnDblClick = dblClickCallback self.scroll = Scroll(parent=self, align=uiconst.TOALL, padding=(padding, 2, padding, 0)) self.scroll.sr.content.OnDropData = self.OnDropData sm.RegisterNotify(self) def ChangeSignalConnection(self, connect=True): signalAndCallback = [ (self.controller.on_new_itemID, self.OnSimulatedShipLoaded), (self.controller.on_slots_changed, self.OnSlotsChanged), (self.controller.on_simulation_state_changed, self.OnSimulationStateChanged) ] ChangeSignalConnect(signalAndCallback, connect) def AddExportImportMenu(self): m = UtilMenu( menuAlign=uiconst.BOTTOMLEFT, parent=self, align=uiconst.BOTTOMLEFT, label=GetByLabel('UI/Fitting/FittingWindow/ImportAndExport'), labelAlign=uiconst.CENTERRIGHT, GetUtilMenu=self.GetExportImportMenu, texturePath='res:/ui/texture/icons/73_16_50.png', left=-8) def GetExportImportMenu(self, menuParent, *args): if boot.region != 'optic': text = GetByLabel( 'UI/Fitting/FittingWindow/FittingManagement/ImportFromClipboard' ) hint = GetByLabel( 'UI/Fitting/FittingWindow/FittingManagement/ImportFromClipboardHint' ) menuParent.AddIconEntry( icon=ACTION_ICON, text=text, hint=hint, callback=sm.GetService( 'fittingSvc').ImportFittingFromClipboard) menuParent.AddDivider() menuParent.AddIconEntry(icon=ACTION_ICON, text=GetByLabel('UI/Commands/Import'), callback=self.ImportFittings) menuParent.AddIconEntry(icon=ACTION_ICON, text=GetByLabel('UI/Commands/Export'), callback=self.ExportFittings) def ImportFittings(self, *args): ImportFittingsWindow.Open() def ExportFittings(self, *args): isCorp = False ExportFittingsWindow.Open(isCorp=isCorp) def Load(self): if self.loaded: return self.hardwareBtnGroup.SelectByID( settings.user.ui.Get(HW_BTN_ID_CONFIG, BROWSE_MODULES)) self.btnGroup.SelectByID( settings.user.ui.Get(BROWSER_BTN_ID_CONFIG, BROWSE_FITTINGS)) self.loaded = True @telemetry.ZONE_METHOD def AddSearchFields(self): self.searchparent = SearchCont(name='searchparent', parent=self, align=uiconst.TOTOP, height=18, padding=(0, 4, 0, 4), searchFunc=self.Search) def ReloadBrowser(self): btnID = settings.user.ui.Get(BROWSER_BTN_ID_CONFIG, BROWSE_FITTINGS) self.BrowserSelected(btnID) def OnSlotDblClicked(self, flagID, *args): SetSettingForFilterBtns(flagID, self.hardwareFilterBtns) btn = self.browserBtns.get(BROWSE_HARDWARE) if not btn.IsSelected(): btn.OnClick() hwBtn = self.hwBrowserBtns.get(BROWSE_MODULES) hwBtn.OnClick() @telemetry.ZONE_METHOD def BrowserSelected(self, btnID, *args): settings.user.ui.Set(BROWSER_BTN_ID_CONFIG, btnID) if btnID == BROWSE_FITTINGS: self.chargeFilterCont.display = False self.hardwareFilterCont.display = False self.hardwarSelectionCont.display = False self.searchparent.ChangeSearchMode(FITTING_MODE) self.ShowOrHideElements(display=False) self.LoadFittings() elif btnID == BROWSE_HARDWARE: self.hardwarSelectionCont.display = True self.searchparent.ChangeSearchMode(HARDWARE_MODE) self.AddHardwareForChargesButtons() self.ShowOrHideElements(display=True) self.LoadHardware() def ShowOrHideElements(self, display=True): self.hardwareFilterCont.display = display self.fittingFilterCont.display = not display self.fittingFilterCont.display = not display def OnFittingDeleted(self, ownerID, fitID): self.OnFittingsUpdated() def OnFittingsUpdated(self): if settings.user.ui.Get(BROWSER_BTN_ID_CONFIG, BROWSE_FITTINGS) == BROWSE_FITTINGS: self.ReloadBrowser() def OnSkillFilteringUpdated(self): if IsHardwareTabSelected(): self.ReloadBrowser() def LoadFittings(self): scrolllist = self.GetFittingScrolllist() self.searchparent.display = True self.scroll.Load(contentList=scrolllist, scrolltotop=0) @telemetry.ZONE_METHOD def LoadHardware(self): self.scroll.HideLoading() self.chargeFilterCont.display = False self.hardwareFilterCont.display = False if IsHardwareTabSelected() and IsChargeTabSelected(): self.searchparent.display = False self.AddHardwareForChargesButtons() return self.searchparent.display = True self.hardwareFilterCont.display = True self.ChangeResourceBtn() uthread.new(self.LoadHardware_thread) @telemetry.ZONE_METHOD def LoadHardware_thread(self): self.scroll.Load(contentList=[]) self.scroll.ShowLoading() resourceBtn = None if settings.user.ui.Get('fitting_filter_hardware_resources', False): resourceBtn = self.hardwareFilterBtns.get(BTN_TYPE_RESOURCES, None) if resourceBtn: resourceBtn.ShowLoading() scrolllist = self._GetHardwareScrollList() if IsModuleTabSelected() and IsHardwareTabSelected(): self.scroll.Load(contentList=scrolllist, scrolltotop=0, noContentHint=GetByLabel( 'UI/Fitting/FittingWindow/NoModulesFound')) self.scroll.HideLoading() if resourceBtn: resourceBtn.HideLoading() def _GetHardwareScrollList(self): if settings.user.ui.Get('fitting_hardwareSearchField', ''): scrolllist = self.GetSearchResults() else: hardwareBrowserListProvider = HardwareBrowserListProvider( self.fittingSvc.searchFittingHelper, self.OnDropData) scrolllist = hardwareBrowserListProvider.GetGroupListForBrowse( marketGroupID=const.marketCategoryShipEquipment) scrolllist += hardwareBrowserListProvider.GetGroupListForBrowse( marketGroupID=const.marketCategoryShipModifications) scrolllist += hardwareBrowserListProvider.GetGroupListForBrowse( marketGroupID=const.marketCategoryDrones) scrolllist += self.GetStructureGroup() return scrolllist def GetStructureGroup(self): from eve.client.script.ui.control import entries as listentry label = 'Structure' data = { 'GetSubContent': self.GetStructureGroupSubContent, 'label': label, 'id': ('ghostfitting_group', 'structure'), 'showlen': 0, 'sublevel': 0, 'showicon': 'hide', 'state': 'locked', 'BlockOpenWindow': True } return [listentry.Get('Group', data=data)] def GetStructureGroupSubContent(self, nodedate, *args): hardwareBrowserListProvider = HardwareBrowserListProvider( self.fittingSvc.searchFittingHelper, self.OnDropData) scrolllist = hardwareBrowserListProvider.GetGroupListForBrowse( marketGroupID=const.marketCategoryStructureEquipment, sublevel=1) scrolllist += hardwareBrowserListProvider.GetGroupListForBrowse( marketGroupID=const.marketCategoryStructureModifications, sublevel=1) return scrolllist def ExitSimulation(self, *args): sm.GetService('fittingSvc').SetSimulationState(False) shipID = GetActiveShip() sm.GetService('ghostFittingSvc').SendOnSimulatedShipLoadedEvent( shipID, None) def LoadCurrentShip(self, *args): sm.GetService('ghostFittingSvc').LoadCurrentShip() def SaveFitting(self, *args): return self.fittingSvc.SaveFitting() def FitShip(self, *args): fittingSvc = sm.GetService('fittingSvc') if not fittingSvc.IsShipSimulated(): return clientDL = sm.GetService('clientDogmaIM').GetDogmaLocation() fittingDL = sm.GetService('clientDogmaIM').GetFittingDogmaLocation() actualShip = clientDL.GetShip() simulatedShip = fittingDL.GetShip() if actualShip.typeID != simulatedShip.typeID: UserError('CustomNotify', {'notify': "Actual ship and simulated ship don't match"}) fitting = fittingSvc.GetFittingForCurrentInWnd( putModuleAmmoInHangar=False) failedToLoad = fittingSvc.LoadFitting(fitting, getFailedDict=True) or {} failedToLoadCounter = Counter({x[0]: x[1] for x in failedToLoad}) simulated_chargeTypesAndQtyByFlagID = fittingSvc.GetChargesAndQtyByFlag( simulatedShip.GetFittedItems().values()) ammoFailedToLoad = fittingSvc.RemoveAndLoadChargesFromSimulatedShip( clientDL, actualShip.itemID, simulated_chargeTypesAndQtyByFlagID) faildToLoadInfo = failedToLoadCounter + Counter(ammoFailedToLoad) if faildToLoadInfo: self.OpenBuyAllBox(faildToLoadInfo) def OpenBuyAllBox(self, faildToLoadInfoCounters): faildToLoadInfo = dict(faildToLoadInfoCounters) BuyAllMessageBox.Open( missingText=GetByLabel('UI/Fitting/MissingItemsHeader'), faildToLoadInfo=faildToLoadInfo) def BuildShip(self, *args): fitting = sm.GetService('fittingSvc').GetFittingForCurrentInWnd() if not fitting.fitData: eve.Message('uiwarning03') return wnd = OpenOrLoadMultiFitWnd(fitting) wnd.Maximize() def GetFittingScrolllist(self, *args): fittingListProvider = FittingBrowserListProvider(self.OnDropData) return fittingListProvider.GetFittingScrolllist() @telemetry.ZONE_METHOD def Search(self, settingConfig, searchString): settings.user.ui.Set(settingConfig, searchString) self.ReloadBrowser() def LoadFittingSetup(self, *args): if sm.GetService('fittingSvc').HasLegacyClientFittings(): wnd = ImportLegacyFittingsWindow.Open() else: wnd = FittingMgmt.Open() if wnd is not None and not wnd.destroyed: wnd.Maximize() def OnSimulatedShipLoaded(self, *args): self.AdjustButtons() def AdjustButtons(self): self._SetBtnStates() self.fitBtn.display = False self.builtShipBtn.display = False if self.controller.IsSimulated(): if sm.GetService('ghostFittingSvc').IsSimulatingCurrentShipType(): self.fitBtn.display = True else: self.builtShipBtn.display = True def _SetBtnStates(self): shipItem = self.controller.dogmaLocation.GetShip() shipTypeID = shipItem.typeID self.fitBtn.Disable() self.builtShipBtn.Disable() if IsDocked(): self.fitBtn.Enable() if not IsModularShip(shipTypeID): self.builtShipBtn.Enable() @telemetry.ZONE_METHOD def AddHardwareForChargesButtons(self): self.chargeFilterCont.display = True self.hardwareFilterCont.display = False self.chargeFilterCont.Flush() Container(name='scaler', parent=self.chargeFilterCont, pos=(0, 0, 0, 30), align=uiconst.NOALIGN) hardware = self.GetHardware() self.moduleChargeButtons.clear() infoSvc = sm.GetService('info') for moduleTypeID in hardware: chargeTypeIDs = infoSvc.GetUsedWithTypeIDs(moduleTypeID) if not chargeTypeIDs: continue moduleName = evetypes.GetName(moduleTypeID) cont = ModuleChargeButton(parent=self.chargeFilterCont, pos=(0, 0, 30, 30), align=uiconst.NOALIGN, state=uiconst.UI_NORMAL, moduleTypeID=moduleTypeID, onClickFunc=self.OnHardwareIconClicked, usedWithChargesIDs=chargeTypeIDs) cont.hint = moduleName self.moduleChargeButtons[moduleTypeID] = cont btnSelected = self.moduleChargeButtons.get(self.ammoShowingForType, None) if not btnSelected and self.moduleChargeButtons: btnSelected = self.moduleChargeButtons.values()[0] if btnSelected: btnSelected.OnClick() else: self.scroll.Load(contentList=[], noContentHint=GetByLabel( 'UI/Fitting/FittingWindow/NoChargesFound')) def OnHardwareIconClicked(self, moduleTypeID, chargeTypeIDs): self.ammoShowingForType = moduleTypeID for btn in self.moduleChargeButtons.itervalues(): if btn.GetModuleType() == moduleTypeID: btn.SetSelected() else: btn.SetDeselected() self.LoadChargesScrollList(moduleTypeID, chargeTypeIDs) def LoadChargesScrollList(self, moduleTypeID, chargeTypeIDs): provider = ChargeBrowserListProvider(dblClickFunc=self.TryFit, onDropDataFunc=self.OnDropData, reloadFunc=self.ReloadBrowser) scrolllist = provider.GetChargesScrollList(moduleTypeID, chargeTypeIDs) self.scroll.Load(contentList=scrolllist, noContentHint=GetByLabel( 'UI/Fitting/FittingWindow/NoChargesFound')) def TryFit(self, entry, moduleTypeID, ammoTypeID): ghostFittingSvc = sm.GetService('ghostFittingSvc') ghostFittingSvc.TryFitAmmoTypeToAll(moduleTypeID, ammoTypeID) def GetHardware(self): dogmaLocation = self.controller.GetDogmaLocation() shipDogmaItem = dogmaLocation.GetShip() hardwareDict = {} for module in shipDogmaItem.GetFittedItems().itervalues(): typeID = module.typeID if self.IsCharge(typeID): continue flagID = module.flagID flagInHardware = hardwareDict.get(typeID, None) if flagInHardware: flagID = min(flagInHardware, flagID) hardwareDict[typeID] = flagID hardwareList = [(flagID, typeID) for typeID, flagID in hardwareDict.iteritems()] return SortListOfTuples(hardwareList, reverse=True) def IsCharge(self, typeID): return evetypes.GetCategoryID(typeID) == const.categoryCharge def OnSlotsChanged(self): if not IsHardwareTabSelected(): return if not IsChargeTabSelected(): return self.AddHardwareForChargesButtons() def OnSimulationStateChanged(self, inSimulation): if IsModuleTabSelected() and IsHardwareTabSelected( ) and settings.user.ui.Get('fitting_filter_hardware_resources', False): self.LoadHardware() self.ChangeResourceBtn() def OnDropData(self, dragObj, nodes): node = nodes[0] itemKey = node.itemID ghostFittingSvc = sm.GetService('ghostFittingSvc') ghostFittingSvc.UnfitModule(itemKey) ghostFittingSvc.SendFittingSlotsChangedEvent() @telemetry.ZONE_METHOD def AddFilterCont(self): self.filterCont = ContainerAutoSize(name='filterCont', parent=self, align=uiconst.TOTOP, padding=(0, 0, 0, 6)) @telemetry.ZONE_METHOD def AddHardwareSelcetionCont(self): self.hardwarSelectionCont = Container(name='hardwarSelectionCont', parent=self, align=uiconst.TOTOP, height=20, padding=(0, 4, 0, 4)) btnDict = {} self.hardwareBtnGroup = ToggleButtonGroup( name='fittingToggleBtnGroup', parent=self.hardwarSelectionCont, align=uiconst.TOTOP, callback=self.ChangeHardwareGroupSelected, height=20, idx=-1) for btnID, label in ((BROWSE_MODULES, 'UI/Fitting/FittingWindow/Modules'), (BROWSE_CHARGES, 'UI/Fitting/FittingWindow/Charges')): btn = self.hardwareBtnGroup.AddButton(btnID, GetByLabel(label), btnClass=ToggleButtonGhost) btnDict[btnID] = btn return btnDict def ChangeHardwareGroupSelected(self, btnID, *args): settings.user.ui.Set(HW_BTN_ID_CONFIG, btnID) self.LoadHardware() @telemetry.ZONE_METHOD def AddHardwareFilterButtons(self): self.hardwareFilterCont = FlowContainer( parent=self.filterCont, align=uiconst.TOTOP, contentAlignment=CONTENT_ALIGN_LEFT, padTop=4, contentSpacing=uiconst.BUTTONGROUPMARGIN) return AddHardwareButtons(self.hardwareFilterCont, 'fitting_filter_hardware_%s', self.HardwareFilterClicked, self.GetHardwareMenu, hintFunc=self.GetFilterHint) @telemetry.ZONE_METHOD def AddChargeFilterButtons(self): self.chargeFilterCont = FlowContainer( parent=self.filterCont, align=uiconst.TOTOP, contentAlignment=CONTENT_ALIGN_LEFT, padTop=4, contentSpacing=uiconst.BUTTONGROUPMARGIN) @telemetry.ZONE_METHOD def AddFittingFilterButtons(self): self.fittingFilterCont = FlowContainer( name='fittingFilterCont', parent=self.filterCont, align=uiconst.TOTOP, contentAlignment=CONTENT_ALIGN_LEFT, padTop=4, contentSpacing=uiconst.BUTTONGROUPMARGIN) AddFittingFilterButtons(self.fittingFilterCont, 'fitting_filter_ship_%s', self.FittingFilterClicked, hintFunc=self.GetFilterHint) def FittingFilterClicked(self, filterBtn, buttonType): self.FilterButtonClicked(filterBtn) self.LoadFittings() def HardwareFilterClicked(self, filterBtn, buttonType): self.FilterButtonClicked(filterBtn) self.LoadHardware() def GetHardwareMenu(self, filterBtn): m = [] if filterBtn.buttonType == BTN_TYPE_RESOURCES: settingName = 'fitting_filter_resourcesOnOutput' onTotalOutput = settings.user.ui.Get(settingName, True) if onTotalOutput: text = GetByLabel( 'UI/Fitting/FittingWindow/FilterResourcesSettingRemaining') else: text = GetByLabel( 'UI/Fitting/FittingWindow/FilterResourcesSettingTotal') m += [(text, self.ToggleHardwareSetting, (settingName, ))] return m def GetFilterHint(self, filterBtn): if filterBtn.buttonType == BTN_TYPE_RESOURCES: onTotalOutput = settings.user.ui.Get( 'fitting_filter_resourcesOnOutput', True) if onTotalOutput: typeOfFiltering = GetByLabel( 'UI/Fitting/FittingWindow/FilterResourcesTotal') else: typeOfFiltering = GetByLabel( 'UI/Fitting/FittingWindow/FilterResourcesRemaining') hint = GetByLabel(filterBtn.hintLabelPath, typeOfFiltering=typeOfFiltering) if not self.controller.IsSimulated(): hint += '<br><br>%s' % GetByLabel( 'UI/Fitting/FittingWindow/OnlyAvailableInSimulation') return hint elif filterBtn.buttonType == BTN_TYPE_PERSONAL_FITTINGS: personalFittings = self.fittingSvc.GetFittings(session.charid) numFittings = '(%s/%s)' % (len(personalFittings), const.maxCharFittings) return GetByLabel(filterBtn.hintLabelPath, numFittings=numFittings) elif filterBtn.buttonType == BTN_TYPE_CORP_FITTINGS: corpFittings = self.fittingSvc.GetFittings(session.corpid) numFittings = '(%s/%s)' % (len(corpFittings), const.maxCorpFittings) return GetByLabel(filterBtn.hintLabelPath, numFittings=numFittings) else: return GetByLabel(filterBtn.hintLabelPath) def ToggleHardwareSetting(self, settingName): currentValue = settings.user.ui.Get(settingName, True) newValue = not currentValue settings.user.ui.Set(settingName, newValue) self.LoadHardware() def FilterButtonClicked(self, filterBtn): btnSettingConfig = filterBtn.btnSettingConfig filterOn = filterBtn.IsChecked() settings.user.ui.Set(btnSettingConfig, filterOn) def GetSearchResults(self): listProvider = SearchBrowserListProvider( self.fittingSvc.searchFittingHelper, self.OnDropData) scrolllist = listProvider.GetSearchResults() return scrolllist def CreateCurrentShipCont(self): self.shipCont.Flush() Frame(parent=self.shipCont, color=(1, 1, 1, 0.1)) activeShip = GetActiveShip() clientDogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation() shipDogmaItem = clientDogmaLocation.GetShip() shipTypeID = shipDogmaItem.typeID icon = Icon(parent=self.shipCont, pos=(0, 0, 40, 40), ignoreSize=True, state=uiconst.UI_DISABLED) if self.fittingSvc.IsShipSimulated(): self.shipCont.OnClick = self.ExitSimulation icon.LoadIconByTypeID(shipTypeID) else: self.shipCont.OnClick = self.LoadCurrentShip hologramTexture = inventorycommon.typeHelpers.GetHoloIconPath( shipTypeID) icon.LoadTexture(hologramTexture) shipName = cfg.evelocations.Get(activeShip).name text = '%s<br>%s' % (evetypes.GetName(shipTypeID), shipName) self.shipnametext = EveLabelMedium(text=text, parent=self.shipCont, align=uiconst.TOTOP, top=2, padLeft=48) def ChangeResourceBtn(self): btn = self.hardwareFilterBtns.get(BTN_TYPE_RESOURCES, None) if not btn: return if self.controller.IsSimulated(): btn.Enable() else: btn.Disable(opacity=0.3) def Close(self): try: self.ChangeSignalConnection(connect=False) except Exception as e: log.LogError('Failed at closing fitting left panel, e = ', e) finally: Container.Close(self)
class ControlCatalogWindow(Window): default_windowID = 'ControlCatalogWindow' default_topParentHeight = 0 default_caption = 'UI Control Catalog' default_width = 900 default_height = 800 def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.entriesByID = {} self.currClassData = None self.currSampleNum = 1 self.numSamples = 0 uthread.new(self.ConstuctLayout) def ConstuctLayout(self): self.leftCont = DragResizeCont( name='leftCont', parent=self.sr.main, align=uiconst.TOLEFT_PROP, settingsID='ControlCatalogWindowLeftCont') self.infoCont = ContainerAutoSize(name='infoCont', parent=self.sr.main, align=uiconst.TOTOP, padding=6) self.topCont = DragResizeCont( name='topCont', parent=self.sr.main, align=uiconst.TOTOP_PROP, settingsID='ControlCatalogWindowSampleCont', minSize=0.3, maxSize=0.9, defaultSize=0.5, clipChildren=True) tabCont = ContainerAutoSize(name='tabCont', parent=self.topCont.mainCont, align=uiconst.TOBOTTOM) self.mainButtonGroup = ButtonGroup(name='mainButtonGroup', parent=self.sr.main) self.editCont = Container(name='editCont', parent=self.sr.main) GradientSprite(bgParent=self.leftCont, rotation=0, rgbData=[(0, (1.0, 1.0, 1.3))], alphaData=[(0.8, 0.0), (1.0, 0.05)]) self.controlScroll = ScrollContainer(parent=self.leftCont) self.PopulateScroll() self.leftButtonGroup = ButtonGroup(name='leftButtonGroup', parent=self.leftCont, idx=0) self.ConstructLeftButtonGroup() self.classNameLabel = Label(parent=self.infoCont, align=uiconst.TOTOP, fontsize=15, bold=True) self.classDocLabel = EveLabelSmall(parent=self.infoCont, align=uiconst.TOTOP) GradientSprite(align=uiconst.TOTOP, parent=self.infoCont, rotation=-math.pi / 2, height=16, padding=(-4, -10, -4, 0), rgbData=[(0, (1.0, 1.0, 1.3))], alphaData=[(0.0, 0.0), (1.0, 0.03)]) GradientSprite(align=uiconst.TOTOP, parent=tabCont, state=uiconst.UI_DISABLED, rotation=math.pi / 2, height=16, padding=(-4, 0, -4, -10), rgbData=[(0, (1.0, 1.0, 1.3))], alphaData=[(0.0, 0.0), (1.0, 0.03)]) self.sampleNameLabel = EveLabelSmall(parent=tabCont, align=uiconst.TOTOP, padBottom=5) self.tabs = ToggleButtonGroup(parent=Container(parent=tabCont, align=uiconst.TOTOP, height=16), align=uiconst.CENTER, height=16, callback=self.OnTabSelected) sampleParent = Container(name='sampleParent', parent=self.topCont.mainCont, clipChildren=True) self.sampleCont = ContainerAutoSize(name='sampleCont', parent=sampleParent, align=uiconst.CENTER) self.codeEdit = EditPlainText(parent=self.editCont, align=uiconst.TOALL, fontcolor=(1, 1, 1, 1), ignoreTags=True) self.codeEdit.OnKeyDown = self.OnCodeEditKeyDown self.ConstructMainButtonGroup() uthread.new(self._SpyOnSampleCodeReloadThread) def OnSampleFileReload(self, path): self.PopulateScroll() self.SetSelectedControl(self.currClassData) def _SpyOnSampleCodeReloadThread(self): try: from eve.common.modules.sake.platform.win32.win32api import Waitables from eve.common.modules.sake.autocompile import SpyFolder class ControlCatalogSpyFolder(SpyFolder): def __init__(self, callback, *args, **kw): SpyFolder.__init__(self, *args, **kw) self.callback = callback def process_folder(self, path): try: self.callback(path) except Exception as e: log.LogException(e) spy = ControlCatalogSpyFolder( self.OnSampleFileReload, Waitables(), (os.path.abspath(os.path.dirname(__file__)), )) while not self.destroyed: spy.waitables.Wait(0) blue.pyos.synchro.Sleep(50) except ImportError: pass def ConstructLeftButtonGroup(self): for label, func in (('Browse', self.BrowseControls), ): self.leftButtonGroup.AddButton(label, func) def ConstructMainButtonGroup(self): for label, func, hint in (('Reload', self.ReloadSamples, 'Reload all sample code [ctrl+s]'), ('Edit module', self.OpenModuleCodeInEditor, 'Open module containing class in editor'), ('Edit samples', self.OpenSampleCodeInEditor, 'Open sample code in editor')): self.mainButtonGroup.AddButton(label, func, hint=hint) def OpenSampleCodeInEditor(self, *args): self.currClassData.OpenSampleCodeInEditor() def BrowseControls(self, *args): controlData.BrowseControls() def OpenModuleCodeInEditor(self, *args): self.currClassData.OpenModuleCodeInEditor() def PopulateScroll(self): self.controlScroll.Flush() for data in controlData.GetControlData(): TreeViewEntry(parent=self.controlScroll, data=data, eventListener=self) if self.currClassData and self.currClassData.GetID() == data.GetID( ): self.currClassData = data def RegisterID(self, entry, entryID): if entryID in self.entriesByID: raise ValueError('Same entry registered again: %s' % entryID) self.entriesByID[entryID] = entry def UnregisterID(self, entryID): self.entriesByID.pop(entryID) def OnTreeViewClick(self, selected): if selected.data.HasChildren(): selected.ToggleChildren() else: for entry in self.entriesByID.values(): entry.UpdateSelectedState((selected.data.GetID(), )) self.currSampleNum = 1 self.SetSelectedControl(selected.data) def SetSelectedControl(self, data): self.codeEdit.Clear() self.sampleCont.Flush() self.codeEdit.SetText(data.GetCode(), html=False) self.currClassData = data self.UpdateInfoCont() self.ReloadSamples() def UpdateInfoCont(self): cls = self.currClassData.GetBaseClass() if not hasattr(cls, '__module__'): raise RuntimeError( 'Unable to identify sample class. IMPORTANT: Make sure the first line in the example imports the example class itself.' ) self.classNameLabel.text = '<center>' + cls.__module__ + '.' + cls.__name__ doc = cls.__doc__ or '' self.classDocLabel.text = '<center>' + doc.strip() if 'depricated' in doc.lower(): self.classNameLabel.text = '<color=red>' + self.classNameLabel.text self.classDocLabel.text = '<color=red>' + self.classDocLabel.text def GetCodeText(self): return self.codeEdit.GetAllText() def ReloadSamples(self, *args): numSamples = controlData.GetNumSamples(self.GetCodeText()) if numSamples != self.numSamples: self.numSamples = numSamples self.ReconstructTabs() self.tabs.SelectByID(self.currSampleNum) def ReconstructTabs(self): self.tabs.ClearButtons() for i in xrange(1, self.numSamples + 1): self.tabs.AddButton(i, 'Sample %s' % i) self.tabs.width = self.numSamples * 65 def OnTabSelected(self, sampleNum): self.currSampleNum = sampleNum self.ReloadCurrentSample() def ReloadCurrentSample(self): self.sampleCont.Flush() uicore.animations.FadeTo(self.sampleCont, 0.0, 1.0, 0.1) if self.numSamples: exec(self.GetCodeText() + '\n', globals()) exec 'Sample%s(parent=self.sampleCont)' % self.currSampleNum sampleName = None exec 'sampleName = Sample%s.__doc__' % self.currSampleNum if sampleName: self.sampleNameLabel.Show() self.sampleNameLabel.text = '<center>' + sampleName else: self.sampleNameLabel.Hide() self.sampleNameLabel.text = '' def OnCodeEditKeyDown(self, key, flag): if uicore.uilib.Key(uiconst.VK_CONTROL) and key == uiconst.VK_S: self.ReloadSamples() else: return EditPlainText.OnKeyDown(self.codeEdit, key, flag)