class ShipGroupIconAndSkillBar(ContainerAutoSize): default_name = 'ShipGroupIconAndSkillBar' default_state = uiconst.UI_NORMAL default_align = uiconst.TOPLEFT __notifyevents__ = ('OnSkillQueueRefreshed', 'OnSkillStarted') default_bgColor = COLOR_BG def ApplyAttributes(self, attributes): ContainerAutoSize.ApplyAttributes(self, attributes) sm.RegisterNotify(self) self.node = attributes.node self.shipGroupIcon = ShipGroupIcon(parent=self, node=self.node) self.skillBarCont = ContainerAutoSize(parent=self, align=uiconst.TOPLEFT, width=42, top=43, state=uiconst.UI_DISABLED) for typeID, _ in self.node.GetBonusSkillsSorted(): SkillLevels(parent=self.skillBarCont, typeID=typeID, align=uiconst.TOTOP, padTop=1, padBottom=1, frameColor=COLOR_FRAME, barColor=shipTreeConst.COLOR_HILIGHT) def OnMouseEnter(self, *args): sm.GetService('shipTreeUI').ShowInfoBubble(self, node=self.node) self.shipGroupIcon.OnMouseEnter() def OnMouseExit(self, *args): self.shipGroupIcon.OnMouseExit() def GetMenu(self): m = [] if session.role & ROLE_PROGRAMMER: text = 'shipGroupID: %s' % self.node.shipGroupID m.append((text, blue.pyos.SetClipboardData, (str(self.node.shipGroupID), ))) return m def UpdateState(self, i, animate=True): self.shipGroupIcon.UpdateState(i, animate) self.UpdateBars(i, animate) def OnSkillQueueRefreshed(self): self.UpdateBars() def OnSkillStarted(self, *args): self.UpdateBars() def UpdateBars(self, i=0, animate=True): if self.node.IsLocked(): self.skillBarCont.Hide() else: self.skillBarCont.Show() for bar in self.skillBarCont.children: bar.Update()
class PreviewWnd(Window): __guid__ = 'form.PreviewWnd' default_windowID = 'previewWnd' default_topParentHeight = 0 default_minSize = (420, 320) default_caption = localization.GetByLabel('UI/Preview/PreviewCaption') PANEL_WIDTH = 280 def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) itemID = attributes.itemID self.typeID = attributes.typeID subsystems = attributes.subsystems animate = attributes.animate width = self.PANEL_WIDTH if self.IsPanelExpanded() else 0 self.sidePanel = Container(parent=self.sr.main, align=uiconst.TOLEFT, width=width, clipChildren=True) self.skinController = SkinPanelController(typeID=None) SkinPanel(parent=self.sidePanel, align=uiconst.TOLEFT, width=self.PANEL_WIDTH - 10, left=10, controller=self.skinController, settingsPrefix='Preview_SkinPanel', logContext='PreviewWindow') mainCont = Container(parent=self.sr.main, align=uiconst.TOALL, padding=(2, 0, 2, 2)) opacity = 1.0 if self.IsPanelEnabled() else 0.0 self.sidePanelButton = SidePanelButton(parent=mainCont, align=uiconst.CENTERLEFT, opacity=opacity, onClick=self.ToggleSidePanel, expanded=self.IsPanelExpanded()) self.loadingWheel = LoadingWheel(parent=mainCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED) self.previewContFill = FillThemeColored(parent=mainCont, align=uiconst.TOALL) overlayCont = Container(name='overlayCont', parent=mainCont, padding=2, clipChildren=1) self.title = EveCaptionMedium(text='', parent=overlayCont, align=uiconst.TOTOP, padding=(17, 4, 17, 0), state=uiconst.UI_NORMAL) self.title.GetMenu = self.GetShipMenu self.title.expandOnLeft = 1 self.subtitle = EveHeaderSmall(text='', parent=overlayCont, align=uiconst.TOTOP, padding=(19, 0, 17, 0), state=uiconst.UI_DISABLED) descLayer = Container(parent=mainCont) self.descCont = ContainerAutoSize(parent=descLayer, align=uiconst.TOBOTTOM, bgColor=(0.0, 0.0, 0.0, 0.3), padding=6, state=uiconst.UI_HIDDEN) self.desc = Label(parent=self.descCont, padding=6, fontsize=12, align=uiconst.TOBOTTOM) self.previewContainer = PreviewContainer( parent=mainCont, OnStartLoading=self.OnStartLoading, OnStopLoading=self.OnStopLoading) self.previewContainer.navigation.OnDropData = self.OnDropData self.PreviewType(self.typeID, subsystems, itemID, animate) def IsPanelExpanded(self): return self.IsPanelEnabled() and settings.user.ui.Get( 'previewPanel', 1) def IsPanelEnabled(self): return evetypes.GetCategoryID( self.typeID) == invconst.categoryShip or evetypes.GetGroupID( self.typeID) == invconst.groupShipSkins def ToggleSidePanel(self): isExpanded = not self.IsPanelExpanded() settings.user.ui.Set('previewPanel', isExpanded) self.UpdateSidePanel(isExpanded) def UpdateSidePanel(self, expanded=None): if expanded is None: expanded = settings.user.ui.Get('previewPanel', 1) width = self.PANEL_WIDTH if expanded else 0 uicore.animations.MorphScalar(self.sidePanel, 'width', startVal=self.sidePanel.width, endVal=width, duration=0.3) def OnStartLoading(self, previewCont): uicore.animations.FadeIn(self.loadingWheel, duration=0.4) uicore.animations.FadeIn(self.previewContFill, duration=0.2, sleep=True) self.ClearText() def OnStopLoading(self, previewCont, success): uicore.animations.FadeOut(self.loadingWheel, duration=0.2) if success: uicore.animations.FadeOut(self.previewContFill, duration=0.4) self.UpdateText() def UpdateText(self): context = self.previewContainer.context if not hasattr(context, 'typeID'): return groupID = evetypes.GetGroupID(context.typeID) categoryID = evetypes.GetCategoryID(context.typeID) title = evetypes.GetName(context.typeID) if hasattr(context, 'itemID'): bp = sm.GetService('michelle').GetBallpark() if bp: slim = bp.GetInvItem(context.itemID) if slim: title = slim.name self.title.text = title subtitle = '' if categoryID != invconst.categoryApparel: scene = self.previewContainer.sceneContainer.scene model = first_or_default(getattr(scene, 'objects', []), None) if model: radius = round(model.GetBoundingSphereRadius() * 2, 0) if groupID in invconst.turretModuleGroups or groupID in invconst.turretAmmoGroups: subtitle = localization.GetByLabel( 'UI/Preview/ShipSubLabelNoRace', groupName=evetypes.GetGroupName(context.typeID), length=FmtDist(radius)) else: raceID = evetypes.GetRaceID(context.typeID) race = cfg.races.Get( raceID) if raceID in cfg.races else None if race is None: subtitle = localization.GetByLabel( 'UI/Preview/ShipSubLabelNoRace', groupName=evetypes.GetGroupName(context.typeID), length=FmtDist(radius)) else: raceName = localization.GetByMessageID(race.raceNameID) subtitle = localization.GetByLabel( 'UI/Preview/ShipSubLabel', raceName=raceName, groupName=evetypes.GetGroupName(context.typeID), length=FmtDist(radius)) self.subtitle.text = subtitle if categoryID == invconst.categoryApparel: self.descCont.Show() description = evetypes.GetDescription(context.typeID) or '' description = re.sub('<b>|</b>|\\r', '', description) description = re.sub('\\n', '<br>', description) self.desc.text = description def GetShipMenu(self, *args): return sm.GetService('menu').GetMenuFormItemIDTypeID( None, self.typeID, ignoreMarketDetails=False, filterFunc=[localization.GetByLabel('UI/Preview/Preview')]) def OnDropData(self, dragObj, nodes): super(PreviewWnd, self).OnDropData(dragObj, nodes) node = first(nodes) typeID = None if hasattr(node, 'item') and hasattr(node.item, 'typeID'): typeID = node.item.typeID elif hasattr(node, 'typeID'): typeID = node.typeID itemID = None if hasattr(node, 'item') and hasattr(node.item, 'itemID'): itemID = node.item.itemID elif hasattr(node, 'itemID'): itemID = node.itemID if typeID: self.PreviewType(typeID, itemID=itemID) def PreviewType(self, typeID, subsystems=None, itemID=None, animate=True): uthread.new(self._PreviewType, typeID, subsystems, itemID, animate) def _PreviewType(self, typeID, subsystems, itemID, animate): self.typeID = typeID self.BringToFront() if evetypes.GetCategoryID(typeID) == invconst.categoryApparel: self.SetMinSize([320, 470]) self.SetMaxSize([800, 950]) else: self.SetMinSize([660, 320]) self.SetMaxSize([None, None]) if not self.IsPanelEnabled(): uicore.animations.FadeOut(self.sidePanelButton, duration=0.3) self.UpdateSidePanel(expanded=False) newScene = self.previewContainer.PreviewType( typeID, subsystems=subsystems, itemID=itemID, controller=getattr(self, 'skinController', None)) if self.IsPanelEnabled(): uicore.animations.FadeIn(self.sidePanelButton, duration=0.3) self.UpdateSidePanel() if IsModularShip(typeID): kv = KeyVal(typeID=typeID) wnd = AssembleShip.GetIfOpen('PreviewSubSystems') if wnd: wnd.UpdateShip(kv, self.previewContainer.context.subsystems) else: AssembleShip.Open( windowID='PreviewSubSystems', ship=kv, groupIDs=None, isPreview=True, setselected=self.previewContainer.context.subsystems) else: self.CloseSubSystemWnd() if newScene and animate: self.previewContainer.AnimEntry() def ClearText(self): self.title.text = '' self.subtitle.text = '' self.desc.SetText('') self.descCont.Hide() def BringToFront(self): self.Maximize() wnd = AssembleShip.GetIfOpen(windowID='PreviewSubSystems') if wnd and wnd.parent.children.index(wnd) > 1: wnd.Maximize() def _OnResize(self, *args, **kw): self.previewContainer.UpdateViewPort() def CloseSubSystemWnd(self): AssembleShip.CloseIfOpen(windowID='PreviewSubSystems') def Close(self, setClosed=False, *args, **kwds): Window.Close(self, setClosed, *args, **kwds) self.CloseSubSystemWnd()
class PreviewWnd(Window): __guid__ = 'form.PreviewWnd' default_windowID = 'previewWnd' default_topParentHeight = 0 default_minSize = (420, 320) default_caption = localization.GetByLabel('UI/Preview/PreviewCaption') def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) itemID = attributes.itemID self.typeID = attributes.typeID subsystems = attributes.subsystems animate = attributes.animate self.loadingWheel = LoadingWheel(parent=self.sr.main, align=uiconst.CENTER, state=uiconst.UI_DISABLED) self.previewContFill = FillThemeColored(parent=self.sr.main, align=uiconst.TOALL) overlayCont = Container(name='overlayCont', parent=self.sr.main, padding=2, clipChildren=1) self.title = EveCaptionMedium(text='', parent=overlayCont, align=uiconst.TOTOP, padding=(17, 4, 17, 0), state=uiconst.UI_NORMAL) self.title.GetMenu = self.GetShipMenu self.title.expandOnLeft = 1 self.subtitle = EveHeaderSmall(text='', parent=overlayCont, align=uiconst.TOTOP, padding=(19, 0, 17, 0), state=uiconst.UI_DISABLED) descLayer = Container(parent=self.sr.main) self.descCont = ContainerAutoSize(parent=descLayer, align=uiconst.TOBOTTOM, bgColor=(0.0, 0.0, 0.0, 0.3), padding=6, state=uiconst.UI_HIDDEN) self.desc = Label(parent=self.descCont, padding=6, fontsize=12, align=uiconst.TOBOTTOM) self.previewContainer = PreviewContainer( parent=self.sr.main, OnStartLoading=self.OnStartLoading, OnStopLoading=self.OnStopLoading, padding=2) self.previewContainer.navigation.OnDropData = self.OnDropData self.PreviewType(self.typeID, subsystems, itemID, animate) def OnStartLoading(self, previewCont): uicore.animations.FadeIn(self.loadingWheel, duration=0.4) uicore.animations.FadeIn(self.previewContFill, duration=0.2, sleep=True) self.ClearText() def OnStopLoading(self, previewCont): if previewCont.loadingFailed: uicore.animations.FadeOut(self.loadingWheel, duration=0.2) else: uicore.animations.FadeOut(self.loadingWheel, duration=0.2) uicore.animations.FadeOut(self.previewContFill, duration=0.4) self.UpdateText() def UpdateText(self): context = self.previewContainer.context if not hasattr(context, 'typeID'): return typeInfo = cfg.invtypes.Get(context.typeID) title = typeInfo.name if hasattr(context, 'itemID'): bp = sm.GetService('michelle').GetBallpark() if bp: slim = bp.GetInvItem(context.itemID) if slim: title = slim.name self.title.text = title if typeInfo.categoryID == invconst.categoryApparel: subtitle = '' else: scene = self.previewContainer.sceneContainer.scene model = first_or_default(getattr(scene, 'objects', []), None) if model: radius = round(model.GetBoundingSphereRadius() * 2, 0) if typeInfo.groupID in invconst.turretModuleGroups or typeInfo.groupID in invconst.turretAmmoGroups: subtitle = localization.GetByLabel( 'UI/Preview/ShipSubLabelNoRace', groupName=typeInfo.Group().groupName, length=FmtDist(radius)) else: raceID = typeInfo.raceID race = cfg.races.Get( raceID) if raceID in cfg.races else None if race is None: subtitle = localization.GetByLabel( 'UI/Preview/ShipSubLabelNoRace', groupName=typeInfo.Group().groupName, length=FmtDist(radius)) else: raceName = localization.GetByMessageID(race.raceNameID) subtitle = localization.GetByLabel( 'UI/Preview/ShipSubLabel', raceName=raceName, groupName=typeInfo.Group().groupName, length=FmtDist(radius)) self.subtitle.text = subtitle if typeInfo.categoryID == invconst.categoryApparel: self.descCont.Show() description = typeInfo.description or '' description = re.sub('<b>|</b>|\\r', '', description) description = re.sub('\\n', '<br>', description) self.desc.text = description def GetShipMenu(self, *args): return sm.GetService('menu').GetMenuFormItemIDTypeID( None, self.typeID, ignoreMarketDetails=False, filterFunc=[localization.GetByLabel('UI/Preview/Preview')]) def OnDropData(self, dragObj, nodes): super(PreviewWnd, self).OnDropData(dragObj, nodes) node = first(nodes) typeID = None if hasattr(node, 'item') and hasattr(node.item, 'typeID'): typeID = node.item.typeID elif hasattr(node, 'typeID'): typeID = node.typeID itemID = None if hasattr(node, 'item') and hasattr(node.item, 'itemID'): itemID = node.item.itemID elif hasattr(node, 'itemID'): itemID = node.itemID if typeID: self.PreviewType(typeID, itemID=itemID) def PreviewType(self, typeID, subsystems=None, itemID=None, animate=True): uthread.new(self._PreviewType, typeID, subsystems, itemID, animate) def _PreviewType(self, typeID, subsystems, itemID, animate): self.typeID = typeID self.BringToFront() typeInfo = cfg.invtypes.Get(typeID) if typeInfo.categoryID == invconst.categoryApparel: self.SetMinSize([320, 470]) self.SetMaxSize([800, 950]) else: self.SetMinSize([420, 320]) self.SetMaxSize([None, None]) newScene = self.previewContainer.PreviewType(typeID, subsystems=subsystems, itemID=itemID) if IsModularShip(typeID): kv = KeyVal(typeID=typeID) wnd = AssembleShip.GetIfOpen('PreviewSubSystems') if wnd: wnd.UpdateShip(kv, self.previewContainer.context.subsystems) else: AssembleShip.Open( windowID='PreviewSubSystems', ship=kv, groupIDs=None, isPreview=True, setselected=self.previewContainer.context.subsystems) else: self.CloseSubSystemWnd() if newScene and animate: self.previewContainer.AnimEntry(-1.8, 0.2, -0.7, -0.3) def ClearText(self): self.title.text = '' self.subtitle.text = '' self.desc.SetText('') self.descCont.Hide() def BringToFront(self): self.Maximize() wnd = AssembleShip.GetIfOpen(windowID='PreviewSubSystems') if wnd and wnd.parent.children.index(wnd) > 1: wnd.Maximize() def _OnResize(self, *args, **kw): self.previewContainer.UpdateViewPort() def CloseSubSystemWnd(self): AssembleShip.CloseIfOpen(windowID='PreviewSubSystems') def Close(self, setClosed=False, *args, **kwds): Window.Close(self, setClosed, *args, **kwds) self.CloseSubSystemWnd()
class UITree(Window): default_windowID = 'uitree' default_caption = 'UI Roots' default_width = 300 default_height = 400 default_minSize = (default_width, default_height) default_left = '__center__' default_top = '__center__' filterString = None def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) mainArea = self.GetMainArea() mainArea.padding = 6 self._selectedObject = None self.SetTopparentHeight(0) self._infoContainer = Container(parent=mainArea, align=uiconst.TOTOP, height=72) self.searchInput = SinglelineEdit(parent=self._infoContainer, align=uiconst.BOTTOMRIGHT, left=4, top=8, width=100, OnChange=self.OnSearchInputChange, hinttext='Search') self.searchInput.SetHistoryVisibility(False) self.searchInput.ShowClearButton() m = UtilMenu(menuAlign=uiconst.TOPRIGHT, parent=self._infoContainer, align=uiconst.TOPRIGHT, GetUtilMenu=self.SettingMenu) self._infoLabel = Label(parent=self._infoContainer, state=uiconst.UI_DISABLED, color=(1.0, 1.0, 1.0, 0.75), left=2) self.searchResultParent = ContainerAutoSize(parent=mainArea, align=uiconst.TOTOP_NOPUSH, padding=(26, -6, 4, 0), bgColor=(0.5, 0.5, 0.5, 1)) self.attributeScroll = Scroll(parent=mainArea, align=uiconst.TOBOTTOM, name='attributeScroll') self.attributeScroll.height = min( self.height / 2, max(72, settings.user.ui.Get('uitree_attributeScroll_height', 200))) settings.user.ui.Set('uitree_attributeScroll_height', self.attributeScroll.height) self.divider = Divider(align=uiconst.TOBOTTOM, parent=mainArea, height=11, state=uiconst.UI_NORMAL) self.divider.OnChange_ = self.OnDividerMove self.divider.OnChangeStart_ = self.OnDividerMoveStart Fill(parent=self.divider, align=uiconst.CENTER, pos=(0, 0, 20, 1)) self.scroll = Scroll(parent=mainArea, name='treeScroll') self._hiliteFrame = Fill(parent=uicore.desktop, align=uiconst.ABSOLUTE, color=(0, 1, 0, 0.3), idx=0, state=uiconst.UI_DISABLED) self._selectedFrame = Frame(parent=uicore.desktop, align=uiconst.ABSOLUTE, color=(0, 1, 0, 0.3), idx=0, state=uiconst.UI_DISABLED) self.ReloadUIRoots() uthread.new(self.UpdateInfo) self._keyDownCookie = uicore.uilib.RegisterForTriuiEvents( [uiconst.UI_KEYDOWN], self.OnGlobalKeyDown) def OnSearchInputChange(self, *args): self.searchThread = base.AutoTimer(250, self.SearchTree) def SearchTree(self): self.searchThread = None self.filterString = self.searchInput.GetValue() if not self.filterString: self.searchResultParent.Hide() self.searchResultParent.Flush() return self.searchResultParent.Flush() res = [] searchFor = self.filterString.lower() def Crawl(obj, path): if obj is self: return if searchFor in obj.name.lower(): if path: res.append((obj, path + '/ <b>' + obj.name + '</b>')) else: res.append((obj, '<b>' + obj.name + '</b>')) if hasattr(obj, 'children'): for each in obj.children: if path: Crawl(each, path + '/' + obj.name) else: Crawl(each, obj.name) for root in uicore.uilib.rootObjects: Crawl(root, '') if res: for obj, path in res[:20]: label = Label(parent=self.searchResultParent, align=uiconst.TOTOP, text=path, state=uiconst.UI_NORMAL, padding=(10, 2, 10, 2)) label._searchObj = obj label.hint = path label.OnClick = (self.OnSearchResultClick, obj) if len(res) > 20: Label(parent=self.searchResultParent, align=uiconst.TOTOP, text='and even more... (%s found)' % len(res), padding=(10, 2, 10, 2)) else: Label(parent=self.searchResultParent, align=uiconst.TOTOP, text='No Match!', padding=(10, 3, 10, 3)) self.searchResultParent.Show() def OnSearchResultClick(self, obj): self.searchResultParent.Hide() self.ShowUIObject(obj) def _OnSizeChange_NoBlock(self, *args, **kwds): Window._OnSizeChange_NoBlock(self, *args, **kwds) self.attributeScroll.height = min( self.height / 2, max(72, settings.user.ui.Get('uitree_attributeScroll_height', 200))) settings.user.ui.Set('uitree_attributeScroll_height', self.attributeScroll.height) def OnDividerMove(self, divider, dx, dy): self.attributeScroll.height = min( self.height / 2, max(72, self._initAttributeScrollHeight - dy)) settings.user.ui.Set('uitree_attributeScroll_height', self.attributeScroll.height) def OnDividerMoveStart(self, *args): self._initAttributeScrollHeight = self.attributeScroll.height def SettingMenu(self, menuParent, *args): checked = settings.user.ui.Get('uitreeShowPickHilite', True) menuParent.AddCheckBox(text='Show pick hilite', checked=checked, callback=(self.ToggleCheckboxSetting, 'ShowPickHilite')) checked = settings.user.ui.Get('uitreeIgnoreFullScreenPick', False) menuParent.AddCheckBox(text='Ignore fullscreen hilite', checked=checked, callback=(self.ToggleCheckboxSetting, 'IgnoreFullScreenPick')) menuParent.AddIconEntry(icon=None, text='Move To Desktop', callback=self.MoveToDesktop) menuParent.AddIconEntry(icon=None, text='Reload Textures', callback=self.ReloadTextures) def ReloadTextures(self): import blue for resPath in blue.motherLode.GetNonCachedKeys( ) + blue.motherLode.GetCachedKeys(): if resPath.lower().startswith('res:/ui'): res = blue.motherLode.Lookup(resPath) if res: if hasattr(res, 'Reload'): res.Reload() def MoveToDesktop(self): self.SetParent(uicore.desktop, idx=0) def ToggleCheckboxSetting(self, settingName, *args): checked = settings.user.ui.Get('uitree' + settingName, True) settings.user.ui.Set('uitree' + settingName, not checked) def Close(self, *args, **kwds): frame = getattr(self, '_hiliteFrame', None) if frame: frame.Close() if getattr(self, '_selectedFrame', None): self._selectedFrame.Close() Window.Close(self, *args, **kwds) def OnGlobalKeyDown(self, *args, **kwds): if self.destroyed: return False ctrl = uicore.uilib.Key(uiconst.VK_CONTROL) alt = uicore.uilib.Key(uiconst.VK_MENU) if ctrl and not (IsUnder(uicore.uilib.mouseOver, self) or uicore.uilib.mouseOver is self): self.ShowUIObject(uicore.uilib.mouseOver) return True def UpdateInfo(self): while not self.destroyed: mo = uicore.uilib.mouseOver if mo: infoText = 'MouseOver: %s' % mo.name else: infoText = 'MouseOver: None' active = uicore.registry.GetActive() if active: infoText += '<br>Active: %s' % active.name else: infoText += '<br>Active: None' focus = uicore.registry.GetFocus() if focus: infoText += '<br>Focus: %s' % (focus.name or focus.__guid__) else: infoText += '<br>Focus: None' capture = uicore.uilib.GetMouseCapture() if capture: infoText += '<br>Capture: %s' % (capture.name or capture.__guid__) else: infoText += '<br>Capture: None' infoText += '<br>MouseX/Y: %s, %s' % (uicore.uilib.x, uicore.uilib.y) showHilite = settings.user.ui.Get('uitreeShowPickHilite', True) ignoreFullScreenPick = settings.user.ui.Get( 'uitreeIgnoreFullScreenPick', False) hiliteUIObject = None if showHilite: if IsUnder(mo, self): if IsUnder(mo, self.scroll): uiObjectGetAbs = GetAttrs(mo, 'sr', 'node', 'uiObject', 'GetAbsolute') if uiObjectGetAbs: hiliteUIObject = GetAttrs(mo, 'sr', 'node', 'uiObject') elif mo is not uicore.desktop and mo is not self and not IsUnder( mo, self) and self.state == uiconst.UI_NORMAL: hiliteUIObject = mo if hiliteUIObject and ignoreFullScreenPick and isinstance( hiliteUIObject, (LayerCore, UIRoot)): hiliteUIObject = None self.ShowHilitedObjectInUI(hiliteUIObject) selectedObject = None if self._selectedObject: selectedObject = self._selectedObject() if getattr(selectedObject, 'destroyed', False): selectedObject = None for node in self.scroll.sr.nodes: if node.panel: node.panel.UpdateSelected(selectedObject) node.panel.UpdatePickHilite(hiliteUIObject) if getattr(node.uiObject, 'destroyed', False): node.panel.CheckDestroyed() self.ShowSelectedObjectInUI(selectedObject) self._infoLabel.text = infoText self._infoContainer.height = self._infoLabel.textheight + 5 blue.pyos.synchro.SleepWallclock(100) def ShowSelectedObjectInUI(self, uiObject): if uiObject and hasattr(uiObject, 'GetAbsolute'): self._selectedFrame.pos = uiObject.GetAbsolute() self._selectedFrame.display = True else: self._selectedFrame.display = False def ShowHilitedObjectInUI(self, uiObject): if self.destroyed: return if uiObject: self._hiliteFrame.pos = uiObject.GetAbsolute() self._hiliteFrame.display = True else: self._hiliteFrame.display = False def ReloadUIRoots(self, *args): startRoot = uicore.uilib.rootObjects scrollNodes = [] for root in startRoot: self._CrawlUIObject(root, scrollNodes, 0) self.scroll.LoadContent(contentList=scrollNodes) def _AddUIObject(self, uiObject, scrollList, lvl, isExpanded=False, objectLabel=None, isExpandable=False): if len(scrollList) > 1 and lvl: for i in xrange(1, len(scrollList) - 1): last = scrollList[-i] if last.level < lvl: break if lvl not in last.connectLevels: last.connectLevels.append(lvl) node = ScrollEntryNode(decoClass=UITreeEntry, uiObject=uiObject, level=lvl, isExpanded=isExpanded, objectLabel=objectLabel, isExpandable=isExpandable, connectLevels=[lvl]) scrollList.append(node) def IsExpanded(self, uiObject): desktopObjectID = id(uicore.desktop) allPrefs = settings.user.ui.Get('UITreeExpandedObjects', {}) if desktopObjectID not in allPrefs: return False uiObjectID = id(uiObject) if getattr(uiObject, 'parent', None): uiObjectID = (id(uiObject.parent), uiObjectID) return uiObjectID in allPrefs[desktopObjectID] def ExpandUIObject(self, uiObject): uiObjectID = id(uiObject) if getattr(uiObject, 'parent', None): uiObjectID = (id(uiObject.parent), uiObjectID) desktopObjectID = id(uicore.desktop) allPrefs = settings.user.ui.Get('UITreeExpandedObjects', {}) if desktopObjectID not in allPrefs: allPrefs[desktopObjectID] = [] if uiObjectID not in allPrefs[desktopObjectID]: allPrefs[desktopObjectID].append(uiObjectID) settings.user.ui.Set('UITreeExpandedObjects', allPrefs) def ToggleExpandedObject(self, uiObject): uiObjectID = id(uiObject) if getattr(uiObject, 'parent', None): uiObjectID = (id(uiObject.parent), uiObjectID) desktopObjectID = id(uicore.desktop) allPrefs = settings.user.ui.Get('UITreeExpandedObjects', {}) if desktopObjectID not in allPrefs: allPrefs[desktopObjectID] = [] if uiObjectID in allPrefs[desktopObjectID]: allPrefs[desktopObjectID].remove(uiObjectID) else: allPrefs[desktopObjectID].append(uiObjectID) settings.user.ui.Set('UITreeExpandedObjects', allPrefs) self.ReloadUIRoots() def _CrawlUIObject(self, uiObject, scrollNodes, lvl, objectLabel=None): """Defines what to show in the tree""" isExpandable = UITree._IsExpandable(uiObject) if isExpandable: isExpanded = self.IsExpanded(uiObject) else: isExpanded = False self._AddUIObject(uiObject, scrollNodes, lvl, isExpanded, objectLabel=objectLabel, isExpandable=isExpandable) if isExpanded: if isinstance(uiObject, Base): allPy = dir(uiObject) for propertyName in allPy: if propertyName.startswith( '_') or propertyName in IGNORE_PROPERTIES: continue try: prop = getattr(uiObject, propertyName, None) except: print 'Failed on property', propertyName continue try: if getattr(prop, 'TypeInfo', None): self._CrawlUIObject(prop, scrollNodes, lvl + 1, objectLabel=propertyName) except (KeyError, RuntimeError): pass for dictName in PYOBJECT_SUBDICTS: dct = getattr(uiObject, dictName, {}) if dct: for k, v in dct.iteritems(): self._CrawlUIObject(v, scrollNodes, lvl + 1, objectLabel='%s: %s' % (dictName.lstrip('_'), k)) for listName in PYOBJECT_SUBLISTS: lst = getattr(uiObject, listName, []) if lst: for objChild in lst: if listName == 'background': self._CrawlUIObject(objChild, scrollNodes, lvl + 1, objectLabel=listName) else: self._CrawlUIObject(objChild, scrollNodes, lvl + 1) else: allC = dir(uiObject) for propertyName in allC: if propertyName.startswith('_'): continue prop = getattr(uiObject, propertyName, None) if callable(prop): continue if getattr(prop, '__bluetype__', None) == 'blue.List': isExpanded = self.IsExpanded(prop) self._AddUIObject(prop, scrollNodes, lvl + 1, isExpanded, isExpandable=True, objectLabel='%s (%s)' % (propertyName, len(prop))) if isExpanded: for each in prop: self._CrawlUIObject(each, scrollNodes, lvl + 2) continue elif getattr(prop, '__bluetype__', None) == 'blue.Dict': isExpanded = self.IsExpanded(prop) self._AddUIObject(prop, scrollNodes, lvl + 1, isExpanded, isExpandable=True, objectLabel=propertyName) if isExpanded: for k, v in prop.items(): self._CrawlUIObject(v, scrollNodes, lvl + 2, objectLabel=k) continue elif hasattr(prop, 'TypeInfo'): self._CrawlUIObject(prop, scrollNodes, lvl + 1, objectLabel=propertyName) @classmethod def _IsExpandable(cls, uiObject): if isinstance(uiObject, Base): return True allC = dir(uiObject) for propertyName in allC: if propertyName.startswith('_'): continue prop = getattr(uiObject, propertyName, None) if getattr(prop, '__bluetype__', None) in ('blue.List', 'blue.Dict'): return True if hasattr(prop, 'TypeInfo'): return True return False def ShowUIObject(self, uiObject): traceUp = [uiObject] parent = uiObject.parent while parent: traceUp.insert(0, parent) parent = parent.parent for each in traceUp: self.ExpandUIObject(each) self.ShowPropertiesForObject(uiObject) for node in self.scroll.sr.nodes: if node.uiObject is uiObject: self.scroll.ShowNodeIdx(node.idx) break def ShowPropertiesForObject(self, uiObject): if uiObject is None: return try: len(uiObject) self.attributeScroll.LoadContent(contentList=[]) return except: pass self._selectedObject = weakref.ref(uiObject) level = 0 newNodes = [] if isinstance(uiObject, Base): combined = [] if hasattr(uiObject, 'color'): combined.append( ('color', ('color.r', 'color.g', 'color.b', 'color.a'))) for propertyName, subs in combined: propertyNode = ScrollEntryNode(decoClass=UITreePropertyEntry, uiObject=uiObject, level=level, propertyName=propertyName, combineProperties=subs) newNodes.append(propertyNode) basics = [ 'name', 'pos', 'opacity', 'padding', 'displayRect', 'display', 'pickState', 'align', 'clipChildren', 'pickRadius', 'absoluteCoordinates', 'cacheContents', 'text', 'blendMode', 'spriteEffect', 'effectAmount', 'effectAmount2', 'glowColor', 'glowFactor', 'glowExpand', 'useSizeFromTexture', 'rotation', 'rotationCenter', 'scale', 'scalingCenter', 'scalingRotation', '', '__guid__', '__class__' ] for propertyName in basics: prop = getattr(uiObject, propertyName, '_!_') if prop == '_!_': continue propertyNode = ScrollEntryNode(decoClass=UITreePropertyEntry, uiObject=uiObject, level=level, propertyName=propertyName) newNodes.append(propertyNode) else: for attr in dir(uiObject): if attr[0] == attr[0].upper(): continue if attr[0] == '_': continue if attr in ('children', 'background'): continue propertyNode = ScrollEntryNode(decoClass=UITreePropertyEntry, uiObject=uiObject, level=level, propertyName=attr) newNodes.append((attr, propertyNode)) newNodes = SortListOfTuples(newNodes) self.ReloadUIRoots() self.attributeScroll.LoadContent(contentList=newNodes)
class OutcomeContainer(Container): default_width = 327 default_height = 202 def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.jobData = None foregroundCont = Container( bgTexturePath= 'res:/UI/Texture/Classes/Industry/Output/outputContBg.png', parent=self, align=uiconst.CENTER, width=self.width, height=self.height, state=uiconst.UI_DISABLED) self.bgPattern = Frame( bgParent=foregroundCont, texturePath='res:/UI/Texture/Classes/Industry/Output/bgPattern.png', cornerSize=12) self.captionCont = ContainerAutoSize(name='captionCont', parent=self, align=uiconst.TOPLEFT, pos=(14, 10, 300, 0)) self.outcomeCaption = EveHeaderMedium( name='outcomeCaption', parent=self.captionCont, align=uiconst.TOTOP, bold=True, text=GetByLabel('UI/Industry/Outcome')) self.outcomeLabel = EveHeaderSmall(name='outcomeLabel', parent=self.captionCont, align=uiconst.TOTOP, bold=True) self.probabilityLabel = EveHeaderSmall(name='probabilityLabel', parent=self.captionCont, align=uiconst.TOTOP, bold=False, state=uiconst.UI_HIDDEN) self.probabilityLabel.LoadTooltipPanel = self.LoadProbabilityTooltipPanel self.probabilityLabel.GetTooltipDelay = self.GetProbabilityTooltipDelay self.copyInfoCont = Container(name='copyInfoCont', parent=self, align=uiconst.CENTERBOTTOM, pos=(0, 8, 300, 32), state=uiconst.UI_HIDDEN) self.containerME = ContainerME(parent=self.copyInfoCont, align=uiconst.TOPLEFT, width=71, height=30) self.runsPerCopyCont = ContainerAutoSize(name='runsPerCopyCont', parent=self.copyInfoCont, align=uiconst.CENTERTOP) self.containerTE = ContainerTE(parent=self.copyInfoCont, align=uiconst.TOPRIGHT, width=71, height=30) IndustryCaptionLabel(parent=self.runsPerCopyCont, text=localization.GetByLabel('UI/Industry/Runs'), align=uiconst.CENTERTOP) self.bpRunsLabel = EveLabelMediumBold(parent=self.runsPerCopyCont, align=uiconst.CENTERTOP, top=12) self.errorFrame = ErrorFrame(bgParent=self, padding=1) self.outcomeItem = OutcomeItemContainer(parent=self) FillUnderlay(bgParent=self, opacity=0.5) def LoadProbabilityTooltipPanel(self, tooltipPanel, *args): if not self.jobData: return self.tooltipPanel = ProbabilityTooltipPanel(jobData=self.jobData, tooltipPanel=tooltipPanel) def GetProbabilityTooltipDelay(self): return TOOLTIP_DELAY_GAMEPLAY def AnimEntry(self): if self.jobData: color = GetJobColor(self.jobData) for pattern in (self.bgPattern, self.outcomeCaption): uicore.animations.SpColorMorphTo(pattern, pattern.GetRGBA(), color, duration=0.3) self.errorFrame.Hide() def UpdateState(self): if self.jobData: self.outcomeLabel.text = self.jobData.GetProductLabel() self.UpdateCopyInfo() if self.jobData.activityID == industry.INVENTION: self.probabilityLabel.Show() color = Color.RGBtoHex(*GetJobColor(self.jobData)) self.probabilityLabel.text = localization.GetByLabel( 'UI/Industry/SuccessProbabilityPerRun', probability=self.jobData.probability * 100, color=color) else: self.probabilityLabel.Hide() else: self.outcomeLabel.text = '' self.probabilityLabel.Hide() def OnNewJobData(self, jobData): self.jobData = jobData self.UpdateState() self.outcomeItem.OnNewJobData(jobData) self.AnimEntry() def OnRunsChanged(self): self.UpdateState() def UpdateCopyInfo(self): bpData = self.jobData.GetProductNewBlueprint() if not bpData: self.copyInfoCont.Hide() return self.copyInfoCont.Show() self.containerME.SetValue(bpData.materialEfficiency) self.containerTE.SetValue(bpData.timeEfficiency) if bpData.original: self.runsPerCopyCont.Hide() else: self.runsPerCopyCont.Show() self.bpRunsLabel.text = '%s' % bpData.runsRemaining
class BlueprintCenter(Container): __notifyevents__ = ('OnIndustryWndMouseWheel', 'OnIndustryWndClick', 'OnBlueprintBrowserNumericInput') def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) sm.RegisterNotify(self) self.jobData = attributes.jobData self.newNumRuns = None self.setJobRunsThread = None self.oldJobData = None self.numericInputTimer = None self.iconCont = ItemIcon(parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=64, height=64, opacity=0.0) self.errorFrame = ErrorFrame(parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=80, height=80) self.ConstructBackground() self.runsCont = ContainerAutoSize(parent=self, align=uiconst.CENTER, top=100) self.runsCaption = IndustryCaptionLabel( name='runsCaption', parent=self.runsCont, align=uiconst.CENTERTOP, text=GetByLabel('UI/Industry/JobRuns')) self.runsEdit = BlueprintSingleLineEdit(parent=self.runsCont, align=uiconst.CENTERTOP, pos=(0, 12, 62, 0), OnChange=self.OnRunsEdit, autoselect=True) self.runsPerCopyCont = ContainerAutoSize(name='runsPerCopyCont', parent=self.runsCont, align=uiconst.CENTERTOP, top=38, state=uiconst.UI_HIDDEN) IndustryCaptionLabel(name='runsPerCopyCaption', parent=self.runsPerCopyCont, align=uiconst.CENTERTOP, text=GetByLabel('UI/Industry/RunsPerCopy')) self.runsPerCopyEdit = BlueprintSingleLineEdit( parent=self.runsPerCopyCont, align=uiconst.CENTERTOP, pos=(0, 12, 62, 0), OnChange=self.OnRunsPerCopyEdit, autoselect=True) self.gauge = None self.skillSprite = SkillIcon(parent=self, align=uiconst.CENTERBOTTOM, top=5, jobData=self.jobData) self.containerME = ContainerME(parent=self, align=uiconst.CENTER, pos=(113, -25, 71, 30), jobData=self.jobData, opacity=0.0) self.containerTE = ContainerTE(parent=self, align=uiconst.CENTER, pos=(113, 25, 71, 30), jobData=self.jobData, opacity=0.0) self.runsRemainingCont = ContainerAutoSize(name='bpCopyCont', parent=self, align=uiconst.CENTERTOP, state=uiconst.UI_NORMAL, top=90) self.runsRemainingCont.OnClick = self.OnRunsRemainingContClicked self.runsRemainingCaption = IndustryCaptionLabel( parent=self.runsRemainingCont, align=uiconst.CENTERTOP) self.runsRemainingLabel = EveLabelMediumBold( name='runsRemainingLabel', parent=self.runsRemainingCont, align=uiconst.CENTERTOP, top=14) self.UpdateState() self.AnimEntry() def OnRunsRemainingContClicked(self, *args): if self.runsEdit.state == uiconst.UI_NORMAL: self.runsEdit.SetValue(self.jobData.maxRuns) def OnBlueprintBrowserNumericInput(self, key, flag): if not self.numericInputTimer: self.runsEdit.SelectAll() else: self.numericInputTimer.kill() self.numericInputTimer = uthread.new(self.NumericInputTimer) self.runsEdit.OnChar(key, flag) def NumericInputTimer(self): blue.synchro.SleepWallclock(1000) self.numericInputTimer = None def OnJobUpdated(self, job): if self.jobData and self.jobData == job: self.UpdateStateJob() def UpdateStateJob(self): self.iconCont.Show() typeID = self.jobData.blueprint.blueprintTypeID self.iconCont.SetTypeID(typeID=typeID, bpData=self.jobData.blueprint) self.UpdateGaugeValue() self.UpdateStateRunsEdit() self.UpdateStateRunsPerCopyEdit() self.skillSprite.Show() self.UpdateRunsRemainingLabel() self.containerME.SetValue(self.jobData.blueprint.materialEfficiency) self.containerTE.SetValue(self.jobData.blueprint.timeEfficiency) self.jobData.on_updated.connect(self.OnJobUpdated) def UpdateRunsRemainingLabel(self): if not self.jobData: return if self.jobData.IsInstalled(): self.runsRemainingCont.Hide() else: runsText = self.jobData.GetRunsRemainingLabel() if runsText: self.runsRemainingCont.Show() self.runsRemainingLabel.text = runsText self.runsRemainingCaption.text = self.jobData.GetRunsRemainingCaption( ) else: self.runsRemainingCont.Hide() def SetNumRuns(self, numRuns): if not self.jobData.IsInstalled(): self.runsEdit.SetValue(numRuns) def UpdateStateRunsEdit(self): if self.jobData.IsInstalled(): self.runsEdit.IntMode(self.jobData.runs, self.jobData.runs) self.runsEdit.Show() self.runsCaption.Show() self.runsEdit.Disable() else: self.runsEdit.IntMode(1, self.jobData.maxRuns) self.runsEdit.Enable() self.runsEdit.Show() self.runsCaption.Show() self.runsEdit.SetValue(self.jobData.runs) def UpdateStateRunsPerCopyEdit(self): if self.jobData.activityID == industry.COPYING: if self.jobData.IsInstalled(): self.runsPerCopyEdit.IntMode(self.jobData.licensedRuns, self.jobData.licensedRuns) self.runsPerCopyEdit.Disable() else: self.runsPerCopyEdit.IntMode(1, self.jobData.maxLicensedRuns) self.runsPerCopyEdit.Enable() self.runsPerCopyEdit.SetValue(self.jobData.licensedRuns) self.runsPerCopyCont.Show() else: self.runsPerCopyCont.Hide() def UpdateState(self): if self.jobData: self.UpdateStateJob() else: self.iconCont.Hide() self.runsEdit.Hide() self.runsPerCopyCont.Hide() self.runsCaption.Hide() self.skillSprite.Hide() self.runsRemainingCont.Hide() self.containerME.SetValue(0.0) self.containerTE.SetValue(0.0) def ReconstructGauge(self): if self.gauge: self.gauge.Close() self.gauge = None if not self.jobData: return color = GetJobColor(self.jobData) h, s, b = Color(*color).GetHSB() colorEnd = Color(*color).SetBrightness(b * 0.5).GetRGBA() self.gauge = BlueprintGaugeCircular(name='gauge', parent=self, align=uiconst.CENTER, radius=64, lineWidth=4, colorStart=color, colorEnd=colorEnd, jobData=self.jobData) def AnimWedges(self, startVal, endVal, duration, curveType=None): uicore.animations.MorphScalar(self.topWedge, 'top', startVal, endVal, duration=duration, curveType=curveType) uicore.animations.MorphScalar(self.bottomWedge, 'top', startVal, endVal, duration=duration, curveType=curveType) uicore.animations.MorphScalar(self.leftWedge, 'left', startVal, endVal, duration=duration, curveType=curveType) uicore.animations.MorphScalar(self.rightWedge, 'left', startVal, endVal, duration=duration, curveType=curveType) def AnimEntry(self): duration = 0.7 if self.jobData: self.HideDashes() if self.topWedge.top < WEDGE_TRAVEL: self.AnimWedges(0, WEDGE_TRAVEL, duration) else: self.AnimWedges(WEDGE_TRAVEL, 18, 0.5, curveType=uiconst.ANIM_WAVE) if not self.IsSameBlueprint(): uicore.animations.FadeTo(self.iconCont, 0.0, 1.0, duration=0.5) for obj in (self.containerME, self.containerTE): obj.Enable() uicore.animations.FadeIn(obj, duration=duration) else: self.AnimWedges(self.topWedge.top, 0.0, duration) for obj in (self.containerME, self.containerTE): obj.Disable() uicore.animations.FadeOut(obj, duration=duration) self.ShowDashes() if self.jobData and self.jobData.IsPreview(): uicore.animations.FadeTo(self.iconCont, 0.0, 0.65, duration=0.5) self.errorFrame.Show() wedgeColor = industryUIConst.COLOR_NOTREADY else: self.errorFrame.Hide() wedgeColor = Color.WHITE for dots in self.wedgeDots: dots.SetRGBA(*wedgeColor) if self.gauge: uicore.animations.BlinkIn(self.gauge, 0.0, 1.0, timeOffset=0.98) for dots in self.wedgeDots: uicore.animations.BlinkIn(dots, 0.0, 0.85, timeOffset=0.78) for pattern in self.wedgeBg: if self.jobData and self.jobData.IsPreview(): color = industryUIConst.COLOR_NOTREADY else: color = GetJobColor(self.jobData) uicore.animations.SpColorMorphTo(pattern, pattern.GetRGBA(), color, duration=0.3) def IsSameBlueprint(self): if not self.oldJobData or not self.jobData: return False if self.jobData: return self.jobData.blueprint.IsSameBlueprint( self.oldJobData.blueprint) return False def UpdateGaugeValue(self): if not self.gauge or not self.jobData: return self.gauge.SetValue(self.jobData.GetGaugeValue()) def SetJobRuns(self, value): if self.setJobRunsThread is None: self.setJobRunsThread = uthread.new(self._SetJobRuns) self.newNumRuns = value def _SetJobRuns(self): while self.jobData and self.newNumRuns is not None: if self.newNumRuns != self.jobData.runs: newNumRuns = self.newNumRuns self.newNumRuns = None self.jobData.runs = newNumRuns sm.GetService('audio').SendUIEvent('ind_runsChanged') blue.synchro.SleepWallclock(100) self.setJobRunsThread = None def OnRunsEdit(self, value): try: value = int(value) except ValueError: return if self.jobData and not self.jobData.IsInstalled(): self.SetJobRuns(value) def OnRunsChanged(self): self.UpdateGaugeValue() self.UpdateRunsRemainingLabel() def OnRunsPerCopyEdit(self, value): try: value = int(value) except ValueError: return self.jobData.licensedRuns = value def ConstructBackground(self): Frame(name='bgFrame', parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=75, height=75, opacity=0.1) blueprintBg = FrameThemeColored( name='blueprintBgFill', parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Industry/Center/bgFrame.png', width=90, height=90) self.dashesCont = Container(name='dashesCont', parent=self, state=uiconst.UI_DISABLED, pos=(75, 0, 150, 150), align=uiconst.CENTER) self.bgCont = Container(name='bgCont', parent=self, state=uiconst.UI_DISABLED, width=150, height=150, align=uiconst.CENTER) self.topWedge = Container(name='topWedge', parent=self.bgCont, align=uiconst.CENTERTOP, pos=(0, 0, 84, 60)) topLines = Sprite( bgParent=self.topWedge, texturePath= 'res:/UI/Texture/classes/Industry/Center/wedgeTopBottom.png') topDots = Sprite( bgParent=self.topWedge, texturePath= 'res:/UI/Texture/classes/Industry/Center/dotsTopBottom.png') topBg = Sprite( bgParent=self.topWedge, texturePath='res:/UI/Texture/classes/Industry/Center/bgTop.png', color=COLOR_FRAME) self.bottomWedge = Container(name='bottomWedge', parent=self.bgCont, align=uiconst.CENTERBOTTOM, pos=(0, 0, 84, 60)) bottomLines = Sprite( bgParent=self.bottomWedge, texturePath= 'res:/UI/Texture/classes/Industry/Center/wedgeTopBottom.png', rotation=pi) bottomDots = Sprite( bgParent=self.bottomWedge, texturePath= 'res:/UI/Texture/classes/Industry/Center/dotsTopBottom.png', rotation=pi) bottomBg = Sprite( bgParent=self.bottomWedge, texturePath='res:/UI/Texture/classes/Industry/Center/bgBottom.png', color=COLOR_FRAME) self.leftWedge = Container(name='leftWedge', parent=self.bgCont, align=uiconst.CENTERLEFT, pos=(0, 0, 60, 84)) leftLines = Sprite( bgParent=self.leftWedge, texturePath= 'res:/UI/Texture/classes/Industry/Center/wedgeLeftRight.png') leftDots = Sprite( bgParent=self.leftWedge, texturePath= 'res:/UI/Texture/classes/Industry/Center/dotsLeftRight.png') leftBg = Sprite( bgParent=self.leftWedge, texturePath='res:/UI/Texture/classes/Industry/Center/bgLeft.png', color=COLOR_FRAME) self.rightWedge = Container(name='rightWedge', parent=self.bgCont, align=uiconst.CENTERRIGHT, pos=(0, 0, 60, 84)) rightLines = Sprite( bgParent=self.rightWedge, texturePath= 'res:/UI/Texture/classes/Industry/Center/wedgeLeftRight.png', rotation=pi) rightDots = Sprite( bgParent=self.rightWedge, texturePath= 'res:/UI/Texture/classes/Industry/Center/dotsLeftRight.png', rotation=pi) rightBg = Sprite( bgParent=self.rightWedge, texturePath='res:/UI/Texture/classes/Industry/Center/bgRight.png', color=COLOR_FRAME) self.wedgeLines = [topLines, bottomLines, leftLines, rightLines] self.wedgeDots = [topDots, bottomDots, leftDots, rightDots] self.wedgeBg = [topBg, bottomBg, leftBg, rightBg] def ShowDashes(self): for rotation in (0, pi / 2, pi, 3 * pi / 2): BlueDash(parent=self.dashesCont, align=uiconst.CENTERLEFT, rotation=pi / 4 + rotation, rotationCenter=(0.0, 0.5)) def HideDashes(self): self.dashesCont.Flush() def OnNewJobData(self, jobData): self.oldJobData = self.jobData self.jobData = jobData self.skillSprite.OnNewJobData(jobData) self.containerME.OnNewJobData(jobData) self.containerTE.OnNewJobData(jobData) self.ReconstructGauge() if self.gauge: self.gauge.OnNewJobData(jobData) self.UpdateState() self.AnimEntry() self.numericInputTimer = None def OnIndustryWndMouseWheel(self, *args): if not self.jobData: return self.runsEdit.OnMouseWheel() if uicore.registry.GetFocus() != self.runsEdit: uicore.registry.SetFocus(self.runsEdit) def OnIndustryWndClick(self): if not self.jobData: return uicore.registry.SetFocus(self.runsEdit)
class DecorationsPanel(Container): default_name = 'DecorationsPanel' __notifyevents__ = [ 'OnRankChange', 'OnUpdatedMedalsAvailable', 'OnUpdatedMedalStatusAvailable' ] def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) btns = [(GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/SaveDecorationPermissionChanges' ), self.SaveDecorationPermissionsChanges, (), 64), (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/SetAllDecorationPermissions' ), self.SetAllDecorationPermissions, (), 64)] self.mainAreaButtons = ContainerAutoSize(align=uiconst.TOBOTTOM, parent=self) ButtonGroup(btns=btns, parent=self.mainAreaButtons, line=False) self.decoMedalList = None self.decoRankList = None self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4)) self.mydecorationstabs = TabGroup( name='tabparent', parent=self, idx=0, tabs= [[ GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Ranks'), self.scroll, self, PANEL_RANKS ], [ GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Medals'), self.scroll, self, PANEL_MEDALS ], [ GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Permissions' ), self.scroll, self, PANEL_PERMISSIONS ]], groupID='cs_decorations') def LoadPanel(self, *args): self.mydecorationstabs.AutoSelect() def SaveDecorationPermissionsChanges(self): promptForDelete = False changes = {} for entry in self.scroll.GetNodes(): if entry.panel and hasattr(entry.panel, 'flag'): if entry.panel.HasChanged(): if entry.panel.flag == 1: promptForDelete = True changes[entry.panel.sr.node.itemID] = entry.panel.flag if promptForDelete == False or uicore.Message( 'DeleteMedalConfirmation', {}, uiconst.YESNO) == uiconst.ID_YES: if len(changes) > 0: sm.StartService('medals').SetMedalStatus(changes) self.decoMedalList = None def SetAllDecorationPermissions(self): permissionList = [ (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Private'), 2), (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Public'), 3) ] pickedPermission = ListWnd( permissionList, 'generic', GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/SetAllDecorationPermissions' ), GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/PilotLicense/SaveAllChangesImmediately' ), windowName='permissionPickerWnd') if not pickedPermission: return permissionID = pickedPermission[1] m, _ = sm.StartService('medals').GetMedalsReceived(session.charid) myDecos = [] for each in m: if each.status != 1: myDecos.append(each.medalID) myDecos = list(set(myDecos)) updateDict = {} for decoID in myDecos: updateDict[decoID] = permissionID if len(updateDict) > 0: sm.StartService('medals').SetMedalStatus(updateDict) self.decoMedalList = None self.ShowMyDecorations('mydecorations_permissions') def Load(self, key): self.ShowMyDecorations(key) def ShowMyDecorations(self, key=None): if key == PANEL_RANKS: self.ShowMyRanks() elif key == PANEL_MEDALS: self.ShowMyMedals() elif key == PANEL_PERMISSIONS: self.ShowMyDecorationPermissions() def ShowMyMedals(self, charID=None): self.mainAreaButtons.Hide() if charID is None: charID = session.charid if self.decoMedalList is None: self.decoMedalList = GetMedalScrollEntries(charID) self.scroll.sr.id = 'charsheet_mymedals' self.scroll.Load( contentList=self.decoMedalList, noContentHint=GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/NoMedals')) def ShowMyRanks(self): self.mainAreaButtons.Hide() if self.decoRankList is None: scrolllist = [] characterRanks = sm.StartService( 'facwar').GetCharacterRankOverview(session.charid) for characterRank in characterRanks: entry = sm.StartService('info').GetRankEntry(characterRank) if entry: scrolllist.append(entry) self.decoRankList = scrolllist[:] self.scroll.sr.id = 'charsheet_myranks' self.scroll.Load( contentList=self.decoRankList, noContentHint=GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/NoRanks')) def ShowMyDecorationPermissions(self): self.mainAreaButtons.Show() scrollHeaders = [ GetByLabel('UI/CharacterCreation/FirstName'), GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Private'), GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Public'), GetByLabel('UI/PI/Common/Remove') ] self.scroll.sr.fixedColumns = { GetByLabel('UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Private'): 60, GetByLabel('UI/CharacterSheet/CharacterSheetWindow/DecoTabs/Public'): 60 } self.scroll.sr.id = 'charsheet_decopermissions' self.scroll.Load(contentList=[], headers=scrollHeaders) self.scroll.OnColumnChanged = self.OnDecorationPermissionsColumnChanged publicDeco = sm.StartService('medals').GetMedalsReceivedWithFlag( session.charid, [3]) privateDeco = sm.StartService('medals').GetMedalsReceivedWithFlag( session.charid, [2]) ppKeys = [each for each in publicDeco.keys() + privateDeco.keys()] scrolllist = [] inMedalList = [] characterMedals, characterMedalInfo = sm.StartService( 'medals').GetMedalsReceived(session.charid) for characterMedal in characterMedals: medalID = characterMedal.medalID if medalID not in ppKeys: continue if medalID in inMedalList: continue inMedalList.append(medalID) details = characterMedalInfo.Filter('medalID') if details and details.has_key(medalID): details = details.get(medalID) entry = self.CreateDecorationPermissionsEntry(characterMedal) if entry: scrolllist.append(entry) self.scroll.Load(contentList=scrolllist, headers=scrollHeaders, noContentHint=GetByLabel('UI/Common/NothingFound')) self.OnDecorationPermissionsColumnChanged() def CreateDecorationPermissionsEntry(self, data): entry = { 'line': 1, 'label': data.title + '<t><t><t>', 'itemID': data.medalID, 'visibilityFlags': data.status, 'indent': 3, 'selectable': 0 } return entries.Get('DecorationPermissions', entry) def OnDecorationPermissionsColumnChanged(self, *args, **kwargs): for entry in self.scroll.GetNodes(): if entry.panel and getattr(entry.panel, 'OnColumnChanged', None): entry.panel.OnColumnChanged() def OnRankChange(self, oldrank, newrank): if not session.warfactionid: return self.decoRankList = None if self.display: self.LoadPanel() def OnUpdatedMedalsAvailable(self): self.ReloadMedals() def OnUpdatedMedalStatusAvailable(self): self.ReloadMedals() def ReloadMedals(self): self.decoMedalList = None if self.display: self.LoadPanel()