class AchievementTaskEntry(ContainerAutoSize): default_padLeft = 0 default_padRight = 0 default_padTop = 0 default_padBottom = 4 default_state = uiconst.UI_NORMAL default_clipChildren = False default_alignMode = uiconst.TOTOP checkedTexturePath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesCheck.png' uncheckedTexturePath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesIncompleteBox.png' tooltipPointer = uiconst.POINT_LEFT_2 achievementGroup = None autoShowDetails = False detailsParent = None callbackTaskExpanded = None def ApplyAttributes(self, attributes): ContainerAutoSize.ApplyAttributes(self, attributes) self.autoShowDetails = bool(attributes.autoShowDetails) or True Fill(bgParent=self, color=(0, 0, 0, 0.3)) self.headerContainer = Container(parent=self, align=uiconst.TOTOP) self.mouseOverFill = FillThemeColored(bgParent=self.headerContainer, colorType=uiconst.COLORTYPE_UIHILIGHT, opacity=0.0) self.completedFill = FillThemeColored(bgParent=self.headerContainer, colorType=uiconst.COLORTYPE_UIHILIGHT, opacity=0.0) self.backgroundContainer = InfoPanelHeaderBackground(bgParent=self.headerContainer) self.achievementTask = attributes.achievement self.achievementGroup = attributes.achievementGroup self.callbackTaskExpanded = attributes.callbackTaskExpanded self.checkbox = Sprite(parent=self.headerContainer, texturePath=self.uncheckedTexturePath, pos=(4, 3, 14, 14)) self.achievementText = EveLabelMedium(name='achievementText', text=self.achievementTask.name, parent=self.headerContainer, padLeft=2 * self.checkbox.left + self.checkbox.width, align=uiconst.TOTOP, padTop=2) self.UpdateAchievementTaskState() newHeight = max(self.checkbox.height + 2 * self.checkbox.top, self.achievementText.textheight + 2 * self.achievementText.padTop) self.headerContainer.height = newHeight if attributes.blinkIn and self.achievementTask.completed: uthread.new(uicore.animations.BlinkIn, self, duration=0.2, loops=4) def ToggleDetails(self): if self.detailsParent and not self.detailsParent.destroyed: self.HideDetails() else: self.ShowDetails() def HideDetails(self, *args): if self.detailsParent and not self.detailsParent.destroyed: detailsParent = self.detailsParent self.detailsParent = None detailsParent.DisableAutoSize() uicore.animations.FadeOut(detailsParent, duration=0.15) uicore.animations.MorphScalar(detailsParent, 'height', detailsParent.height, 0, duration=0.15, callback=detailsParent.Close) def ShowDetails(self): if self.detailsParent and not self.detailsParent.destroyed: return uthread.new(self._ShowDetails) def _ShowDetails(self): if not self.autoShowDetails: return self.detailsParent = ContainerAutoSize(align=uiconst.TOTOP, parent=self, clipChildren=True) if self.callbackTaskExpanded: self.callbackTaskExpanded(self) self.detailsParent.DisableAutoSize() label = EveLabelMedium(parent=self.detailsParent, text=self.achievementTask.description, align=uiconst.TOTOP, padding=(6, 3, 6, 2)) extraInfo = ACHIEVEMENT_TASK_EXTRAINFO.get(self.achievementTask.achievementID, None) if extraInfo: grid = LayoutGrid(parent=self.detailsParent, align=uiconst.TOTOP, cellPadding=1, columns=2, padLeft=4, padBottom=2) for taskInfoEntry in extraInfo: if isinstance(taskInfoEntry, TaskInfoEntry_Text): label = EveLabelMedium(text=taskInfoEntry.text, color=taskInfoEntry.textColor, width=240, state=uiconst.UI_NORMAL) grid.AddCell(label, colSpan=2) elif isinstance(taskInfoEntry, TaskInfoEntry_ImageText): texturePath = taskInfoEntry.GetTexturePath() icon = Sprite(name='icon', parent=grid, pos=(0, 0, taskInfoEntry.imageSize, taskInfoEntry.imageSize), texturePath=texturePath, state=uiconst.UI_DISABLED, align=uiconst.CENTER, color=taskInfoEntry.imageColor) text = GetByLabel(taskInfoEntry.textPath) label = EveLabelMedium(text=text, color=taskInfoEntry.textColor, width=220, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL) grid.AddCell(label) blue.synchro.Yield() height = self.detailsParent.GetAutoSize()[1] uicore.animations.FadeIn(self.detailsParent, duration=0.3) uicore.animations.MorphScalar(self.detailsParent, 'height', self.detailsParent.height, height, duration=0.25, sleep=True) self.detailsParent.EnableAutoSize() def OnMouseEnter(self, *args): if self.autoShowDetails: return uicore.animations.MorphScalar(self, 'opacity', startVal=self.opacity, endVal=2.0, curveType=uiconst.ANIM_OVERSHOT3, duration=0.5) CheckMouseOverUtil(self, self.ResetMouseOverState) def ResetMouseOverState(self, *args): if self.destroyed: return uicore.animations.MorphScalar(self, 'opacity', startVal=self.opacity, endVal=1.0, duration=0.1) def OnClick(self, *args): if self.autoShowDetails: self.ToggleDetails() else: aura = AchievementAuraWindow.GetIfOpen() if aura: aura.Step_TaskInfo_Manual(self.achievementTask, self.achievementGroup) else: AchievementAuraWindow.Open(loadAchievementTask=self.achievementTask, loadAchievementGroup=self.achievementGroup) def UpdateAchievementTaskState(self, animate = False): if self.achievementTask.completed: self.checkbox.SetTexturePath(self.checkedTexturePath) uicore.animations.FadeTo(self.completedFill, startVal=self.completedFill.opacity, endVal=0.75) else: self.checkbox.SetTexturePath(self.uncheckedTexturePath) uicore.animations.FadeTo(self.completedFill, startVal=self.completedFill.opacity, endVal=0.0) def LoadTooltipPanel(self, tooltipPanel, *args, **kwds): return if uicore.uilib.tooltipHandler.IsUnderTooltip(self): return achievementID = self.achievementTask.achievementID tooltipPanel.LoadGeneric2ColumnTemplate() if self.achievementTask.description: tooltipPanel.AddLabelMedium(text=self.achievementTask.description, colSpan=tooltipPanel.columns, wrapWidth=200) extraInfo = ACHIEVEMENT_TASK_EXTRAINFO.get(achievementID, None) if extraInfo: for taskInfoEntry in extraInfo: if isinstance(taskInfoEntry, TaskInfoEntry_Text): tooltipPanel.AddLabelMedium(text=taskInfoEntry.text, color=taskInfoEntry.textColor, colSpan=tooltipPanel.columns, wrapWidth=200) elif isinstance(taskInfoEntry, TaskInfoEntry_ImageText): texturePath = taskInfoEntry.GetTexturePath() icon = Sprite(name='icon', parent=tooltipPanel, pos=(0, 0, taskInfoEntry.imageSize, taskInfoEntry.imageSize), texturePath=texturePath, state=uiconst.UI_DISABLED, align=uiconst.CENTER, color=taskInfoEntry.imageColor) text = GetByLabel(taskInfoEntry.textPath) label = EveLabelMedium(text=text, color=taskInfoEntry.textColor, width=180, align=uiconst.CENTERLEFT) tooltipPanel.AddCell(label) def GetHint(self): return None
class TreeViewEntry(ContainerAutoSize): default_name = 'TreeViewEntry' default_align = uiconst.TOTOP default_state = uiconst.UI_NORMAL default_settingsID = '' LEFTPUSH = 10 default_height = 22 isDragObject = True noAccessColor = (0.33, 0.33, 0.33, 1.0) iconColor = util.Color.WHITE @telemetry.ZONE_METHOD def ApplyAttributes(self, attributes): ContainerAutoSize.ApplyAttributes(self, attributes) self.level = attributes.get('level', 0) self.data = attributes.get('data') self.eventListener = attributes.get('eventListener', None) self.parentEntry = attributes.get('parentEntry', None) self.settingsID = attributes.get('settingsID', self.default_settingsID) self.defaultExpanded = attributes.get('defaultExpanded', self.level < 1) self.childrenInitialized = False self.isToggling = False self.canAccess = True self.isSelected = False self.childSelectedBG = False self.icon = None self.childCont = None self.topRightCont = Container(name='topCont', parent=self, align=uiconst.TOTOP, height=self.default_height) self.topRightCont.GetDragData = self.GetDragData left = self.GetSpacerContWidth() if self.data.IsRemovable(): removeBtn = Sprite( texturePath='res:/UI/Texture/icons/73_16_210.png', parent=self.topRightCont, align=uiconst.CENTERLEFT, width=16, height=16, left=left, hint=localization.GetByLabel('UI/Common/Buttons/Close')) left += 20 removeBtn.OnClick = self.Remove icon = self.data.GetIcon() if icon: iconSize = self.height - 2 self.icon = Icon(icon=icon, parent=self.topRightCont, pos=(left, 0, iconSize, iconSize), align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, ignoreSize=True) left += iconSize self.label = Label(parent=self.topRightCont, align=uiconst.CENTERLEFT, text=self.data.GetLabel(), left=left + 4) self.UpdateLabel() self.hoverBG = None self.selectedBG = None self.blinkBG = None if self.data.HasChildren(): self.spacerCont = Container(name='spacerCont', parent=self.topRightCont, align=uiconst.TOLEFT, width=self.GetSpacerContWidth()) self.toggleBtn = Container(name='toggleBtn', parent=self.spacerCont, align=uiconst.CENTERRIGHT, width=16, height=16, state=uiconst.UI_HIDDEN) self.toggleBtn.OnClick = self.OnToggleBtnClick self.toggleBtn.OnDblClick = lambda: None self.toggleBtnSprite = Sprite( bgParent=self.toggleBtn, texturePath='res:/UI/Texture/classes/Neocom/arrowDown.png', rotation=pi / 2, padding=(4, 4, 5, 5)) expandChildren = False if not self.data.IsForceCollapsed(): toggleSettingsDict = settings.user.ui.Get( 'invTreeViewEntryToggle_%s' % self.settingsID, {}) expandChildren = toggleSettingsDict.get( self.data.GetID(), self.defaultExpanded) self.ConstructChildren() else: self.toggleBtn.state = uiconst.UI_NORMAL self.ShowChildCont(expandChildren, animate=False) else: self.ShowChildCont(False, animate=False) if self.eventListener and hasattr(self.eventListener, 'RegisterID'): self.eventListener.RegisterID(self, self.data.GetID()) def GetSpacerContWidth(self): return (1 + self.level) * self.LEFTPUSH + 8 def Close(self): try: if self.eventListener and hasattr(self.eventListener, 'UnregisterID'): self.eventListener.UnregisterID(self.data.GetID()) if self.parentEntry and self.data in self.parentEntry.data._children: self.parentEntry.data._children.remove(self.data) finally: ContainerAutoSize.Close(self) @telemetry.ZONE_METHOD def ConstructChildren(self): self.childrenInitialized = True children = self.data.GetChildren() if self.destroyed: return if self.childCont is None: self.childCont = ContainerAutoSize(parent=self, name='childCont', align=uiconst.TOTOP, clipChildren=True, state=uiconst.UI_HIDDEN) if children: for child in children: cls = self.GetTreeViewEntryClassByTreeData(child) child = cls(parent=self.childCont, parentEntry=self, level=self.level + 1, eventListener=self.eventListener, data=child, settingsID=self.settingsID, state=uiconst.UI_HIDDEN) child.UpdateLabel() if self.childCont.children: self.childCont.children[-1].padBottom = 5 self.toggleBtn.state = uiconst.UI_NORMAL def GetTreeViewEntryClassByTreeData(self, treeData): """ Can be overridden to return custom tree view entry classes """ return TreeViewEntry def ShowChildCont(self, show=True, animate=True): if self.childCont is None or self.childCont.display == show or not self.data.HasChildren( ): return for child in self.childCont.children: child.display = show self.isToggling = True if animate: if show: self.childCont.display = True uicore.animations.Tr2DRotateTo(self.toggleBtnSprite, pi / 2, 0.0, duration=0.15) self.childCont.DisableAutoSize() _, height = self.childCont.GetAutoSize() uicore.animations.FadeIn(self.childCont, duration=0.3) uicore.animations.MorphScalar(self.childCont, 'height', self.childCont.height, height, duration=0.15, sleep=True) self.childCont.EnableAutoSize() else: uicore.animations.Tr2DRotateTo(self.toggleBtnSprite, 0.0, pi / 2, duration=0.15) self.childCont.DisableAutoSize() uicore.animations.FadeOut(self.childCont, duration=0.15) uicore.animations.MorphScalar(self.childCont, 'height', self.childCont.height, 0, duration=0.15, sleep=True) self.childCont.display = False self.toggleBtn.Enable() else: self.childCont.display = show if show: self.toggleBtnSprite.rotation = 0.0 self.childCont.opacity = 1.0 else: self.toggleBtnSprite.rotation = pi / 2 self.childCont.DisableAutoSize() self.childCont.opacity = 0.0 self.isToggling = False def UpdateSelectedState(self, selectedIDs): invID = self.data.GetID() isSelected = selectedIDs[-1] == invID isChildSelected = not isSelected and invID in selectedIDs self.SetSelected(isSelected, isChildSelected) def SetSelected(self, isSelected, isChildSelected=False): self.isSelected = isSelected if isSelected or self.selectedBG: self.CheckConstructSelectedBG() self.selectedBG.display = isSelected self.UpdateLabel() if isChildSelected: if not self.childSelectedBG: self.childSelectedBG = GradientThemeColored( bgParent=self.spacerCont, rotation=0, alphaData=[(0, 0.5), (1.0, 0.0)], padBottom=1, colorType=uiconst.COLORTYPE_UIHILIGHT) else: self.childSelectedBG.Show() elif self.childSelectedBG: self.childSelectedBG.Hide() if isSelected and self.parentEntry: self.parentEntry.ExpandFromRoot() @telemetry.ZONE_METHOD def UpdateLabel(self): if self.isSelected and self.canAccess: self.label.color = util.Color.WHITE elif self.canAccess: self.label.color = Label.default_color else: self.label.color = self.noAccessColor if session.role & (service.ROLE_GML | service.ROLE_WORLDMOD): if settings.user.ui.Get('invPrimingDebugMode', False) and hasattr( self.data, 'invController') and self.data.invController.IsPrimed(): self.label.color = util.Color.RED def ExpandFromRoot(self): """ Make sure a selected item is visible in the tree """ self.ToggleChildren(forceShow=True) if self.parentEntry: self.parentEntry.ExpandFromRoot() def OnClick(self, *args): if self.eventListener and hasattr(self.eventListener, 'OnTreeViewClick'): self.eventListener.OnTreeViewClick(self, *args) def OnDblClick(self, *args): if self.eventListener and hasattr(self.eventListener, 'OnTreeViewDblClick'): self.eventListener.OnTreeViewDblClick(self, *args) def OnToggleBtnClick(self, *args): if not self.isToggling: self.ToggleChildren() def ToggleChildren(self, forceShow=False): show = forceShow or self.childCont is None or not self.childCont.display toggleSettingsDict = settings.user.ui.Get( 'invTreeViewEntryToggle_%s' % self.settingsID, {}) toggleSettingsDict[self.data.GetID()] = show settings.user.ui.Set('invTreeViewEntryToggle_%s' % self.settingsID, toggleSettingsDict) if not self.data.HasChildren(): return if not self.childrenInitialized: self.ConstructChildren() self.ShowChildCont(show) def GetMenu(self): m = self.data.GetMenu() if session.role & service.ROLE_PROGRAMMER: idString = repr(self.data.GetID()) m.append((idString, blue.pyos.SetClipboardData, (idString, ))) if self.data.IsRemovable(): m.append(None) m.append((localization.GetByLabel('UI/Common/Buttons/Close'), self.Remove, ())) return m def GetHint(self): return self.data.GetHint() def GetFullPathLabelList(self): labelTuple = [self.data.GetLabel()] if self.parentEntry: labelTuple = self.parentEntry.GetFullPathLabelList() + labelTuple return labelTuple def Remove(self, *args): self.eventListener.RemoveTreeEntry(self, byUser=True) def OnMouseDown(self, *args): if self.eventListener and hasattr(self.eventListener, 'OnTreeViewMouseDown'): self.eventListener.OnTreeViewMouseDown(self, *args) def OnMouseUp(self, *args): if self.eventListener and hasattr(self.eventListener, 'OnTreeViewMouseUp'): self.eventListener.OnTreeViewMouseUp(self, *args) def CheckConstructHoverBG(self): if self.hoverBG is None: self.hoverBG = ListEntryUnderlay(bgParent=self.topRightCont) def CheckConstructSelectedBG(self): if self.selectedBG is None: self.selectedBG = FillThemeColored( bgParent=self.topRightCont, colorType=uiconst.COLORTYPE_UIHILIGHT, state=uiconst.UI_HIDDEN, opacity=0.5) def CheckConstructBlinkBG(self): if self.blinkBG is None: self.blinkBG = Fill(bgParent=self.topRightCont, color=(1.0, 1.0, 1.0, 0.0)) def OnMouseEnter(self, *args): self.CheckConstructHoverBG() self.hoverBG.ShowHilite() if self.eventListener and hasattr(self.eventListener, 'OnTreeViewMouseEnter'): self.eventListener.OnTreeViewMouseEnter(self, *args) def OnMouseExit(self, *args): self.CheckConstructHoverBG() self.hoverBG.HideHilite() if self.eventListener and hasattr(self.eventListener, 'OnTreeViewMouseExit'): self.eventListener.OnTreeViewMouseExit(self, *args) def OnDropData(self, *args): if self.eventListener and hasattr(self.eventListener, 'OnTreeViewDropData'): self.eventListener.OnTreeViewDropData(self, *args) def OnDragEnter(self, dragObj, nodes): self.CheckConstructHoverBG() self.hoverBG.ShowHilite() if self.eventListener and hasattr(self.eventListener, 'OnTreeViewDragEnter'): self.eventListener.OnTreeViewDragEnter(self, dragObj, nodes) def GetDragData(self): if self.data.IsDraggable(): self.eventListener.OnTreeViewGetDragData(self) return [self.data] def OnDragExit(self, *args): self.CheckConstructHoverBG() self.hoverBG.HideHilite() if self.eventListener and hasattr(self.eventListener, 'OnTreeViewDragExit'): self.eventListener.OnTreeViewDragExit(self, *args) def Blink(self): self.CheckConstructBlinkBG() uicore.animations.FadeTo(self.blinkBG, 0.0, 0.25, duration=0.25, curveType=uiconst.ANIM_WAVE, loops=2) @telemetry.ZONE_METHOD def SetAccessability(self, canAccess): self.canAccess = canAccess if self.icon: self.icon.color = self.iconColor if canAccess else util.Color( *self.iconColor).SetAlpha(0.5).GetRGBA() self.UpdateLabel()
def GetTopContAutoSize(self): w, h = ContainerAutoSize.GetAutoSize(self.topCont) return (w, max(h + 6, 40))
class QuestEntry(ContainerAutoSize): default_alignMode = uiconst.TOTOP default_clipChildren = False default_state = uiconst.UI_NORMAL default_padTop = 4 def ApplyAttributes(self, attributes): super(QuestEntry, self).ApplyAttributes(attributes) self.quest = attributes.quest self.isCompleteMode = self.quest.isComplete self._updateThread = None self.details = None self.Layout() self.UpdateQuest() if self.isCompleteMode: self.ShowCompleted() else: self.ShowDetails() def Layout(self): Fill(bgParent=self, color=(0, 0, 0, 0.2)) BlurredBackgroundSprite(bgParent=self, color=(1, 1, 1, 0.9)) headerContainer = ContainerAutoSize(parent=self, align=uiconst.TOTOP, alignMode=uiconst.TOPLEFT) self.completedFill = FillThemeColored( bgParent=headerContainer, colorType=uiconst.COLORTYPE_UIHILIGHT, opacity=0.0) self.headerFill = InfoPanelHeaderBackground(bgParent=headerContainer) headerGrid = LayoutGrid(parent=headerContainer) if self.quest.isComplete: texturePath = RES_COMPLETED else: texturePath = RES_AVAILABLE self.check = Sprite(align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, texturePath=texturePath, width=14, height=14) headerGrid.AddCell(self.check, cellPadding=(4, 3, 4, 3)) headerGrid.AddCell(EveLabelMedium(align=uiconst.TOPLEFT, text=self.quest.titleLabel), cellPadding=(0, 2, 0, 2)) self.timer = EveLabelMedium(parent=headerContainer, align=uiconst.CENTERRIGHT, state=uiconst.UI_DISABLED, left=4, opacity=0.0) def ShowCompleted(self): self.check.SetTexturePath(RES_COMPLETED) self.completedFill.opacity = 0.5 self.timer.opacity = 0.6 self.timer.state = uiconst.UI_NORMAL def UpdateQuest(self, quest=None): if quest is None: quest = self.quest if self.quest.id != quest.id: return self.quest = quest if not self.isCompleteMode and self.quest.isComplete: self.isCompleteMode = True self.AnimComplete() self.timer.state = uiconst.UI_NORMAL elif self.isCompleteMode and not self.quest.isComplete: self.isCompleteMode = False self.AnimAvailable() self.timer.state = uiconst.UI_DISABLED if self.isCompleteMode: if not self._updateThread: self._updateThread = uthread.new(self._UpdateThread) self.timer.text = self.quest.nextAvailableShortLabel self.timer.hint = self.quest.nextAvailableLabel def AnimComplete(self): self.check.SetTexturePath(RES_COMPLETED) animations.BlinkIn(self.check) animations.MorphScalar(self.completedFill, 'displayWidth', startVal=0.0, endVal=self.displayWidth) animations.FadeTo(self.completedFill, startVal=1.5, endVal=0.5, duration=1.5, timeOffset=0.5) animations.FadeIn(self.timer, endVal=0.6, timeOffset=0.5) def AnimAvailable(self): self.check.SetTexturePath(RES_AVAILABLE) animations.BlinkIn(self.check) animations.FadeTo(self.completedFill, startVal=self.completedFill.opacity, endVal=0.0) animations.FadeOut(self.timer, duration=0.3) def OnClick(self, *args): self.ToggleDetails() def ToggleDetails(self): if self.details and not self.details.destroyed: self.HideDetails() else: self.ShowDetails() def HideDetails(self): if not self.details or self.details.destroyed: return details = self.details self.details = None details.DisableAutoSize() animations.FadeOut(details, duration=0.15) animations.MorphScalar(details, 'height', startVal=details.height, endVal=0, duration=0.15, callback=details.Close) def ShowDetails(self): if self.details: return def thread(): self.details = ContainerAutoSize(parent=self, align=uiconst.TOTOP, clipChildren=True) self.details.DisableAutoSize() EveLabelMedium(parent=self.details, align=uiconst.TOTOP, padding=(6, 3, 6, 2), text=self.quest.descriptionLabel) EveLabelMedium( parent=self.details, align=uiconst.TOTOP, padding=(6, 3, 6, 2), text=localization.GetByLabel('UI/Quest/RewardTitle')) EveLabelMedium(parent=self.details, align=uiconst.TOTOP, padding=(12, 6, 6, 12), text=self.quest.rewardLabel) _, height = self.details.GetAutoSize() animations.FadeIn(self.details, duration=0.3) animations.MorphScalar(self.details, 'height', startVal=self.details.height, endVal=height, duration=0.25, callback=self.details.EnableAutoSize) uthread.new(thread) def OnMouseEnter(self, *args): animations.FadeTo(self.headerFill.colorFill, startVal=self.headerFill.colorFill.opacity, endVal=0.3, curveType=uiconst.ANIM_OVERSHOT3, duration=0.5) def OnMouseExit(self, *args): animations.FadeTo(self.headerFill.colorFill, startVal=self.headerFill.colorFill.opacity, endVal=0.15, duration=0.1) def _UpdateThread(self): while self and not self.destroyed and self.isCompleteMode: self.UpdateQuest() blue.pyos.synchro.SleepWallclock(1000) self._updateThread = None
class BuyItemContainer(BuySellItemContainerBase): __guid__ = 'uicls.BuytemContainer' default_height = 52 belowColor = '<color=0xff00ff00>' aboveColor = '<color=0xffff5050>' totaLabelPath = 'UI/Market/MarketQuote/PayTotal' def ApplyAttributes(self, attributes): self.blinkBG = None self.typeID = attributes.typeID self.dropParentFunc = attributes.dropParentFunc BuySellItemContainerBase.ApplyAttributes(self, attributes) self.adjustQtyTimer = None self.isUpdating = False self.totalSum = 0.0 self.orderMultiplier = attributes.orderMultiplier self.qty = attributes.qty self.stationID = attributes.stationID self.newBestPrice, self.numOrders = self.quoteSvc.GetBestAskPriceInStationAndNumberOrders( self.typeID, self.stationID, self.qty) self.DrawUI() self.UpdateUIElements() self.GetBestPrice() def DrawUI(self): self.errorBg = ErrorFrame(bgParent=self) self.deltaCont = Container(parent=self, align=uiconst.TORIGHT, width=30) theRestCont = Container(parent=self, align=uiconst.TOALL) self.totalCont = Container(parent=theRestCont, align=uiconst.TORIGHT_PROP, width=0.3) self.priceCont = Container(parent=theRestCont, align=uiconst.TORIGHT_PROP, width=0.22) self.qtyCont = Container(parent=theRestCont, align=uiconst.TORIGHT_PROP, width=0.15) self.itemCont = Container(parent=theRestCont, align=uiconst.TORIGHT_PROP, width=0.33) self.deleteCont = Container(parent=self.itemCont, align=uiconst.TORIGHT, width=24) self.deleteButton = ButtonIcon( texturePath='res:/UI/Texture/Icons/73_16_210.png', pos=(0, 0, 16, 16), align=uiconst.CENTERRIGHT, parent=self.deleteCont, hint=GetByLabel('UI/Generic/RemoveItem'), idx=0, func=self.RemoveItem) self.deleteCont.display = False self.textCont = Container(parent=self.itemCont, align=uiconst.TOALL) self.DrawItem() self.DrawQty() self.DrawPrice() self.DrawTotal() self.DrawDelta() def UpdateUIElements(self): self.UpdateOrderStateInUI() self.GetBestPrice() self.SetPrice() self.UpdateDelta() def GetBestOrderInRange(self): stationID = self.stationID bidRange = None return self.quoteSvc.GetBestAskInRange(typeID=self.typeID, stationID=stationID, bidRange=bidRange, amount=self.qty) def ShowNoSellOrders(self): if self.newBestPrice is None: uicore.animations.FadeIn(self.errorBg, 0.35, duration=0.3) def DrawQty(self): self.qtySubCont = ContainerAutoSize(name='qtySubCont', parent=self.qtyCont, align=uiconst.TOTOP, callback=self.PositionQtyContainer) qty = self.qty self.qtyEdit = SinglelineEdit(name='qtyEdit', parent=self.qtySubCont, align=uiconst.TOTOP, padLeft=4, ints=[1, None], setvalue=qty, OnChange=self.OnChange, hint=GetByLabel('UI/Common/Quantity')) self.qtyEdit.OnMouseWheel = self.OnMouseWheelForQtyEdit self.qtyTotal = EveLabelMediumBold(text='', parent=self.qtySubCont, padLeft=8, padTop=6, align=uiconst.TOTOP, state=uiconst.UI_NORMAL, autoFadeSides=35) self.SetTotalQtyText() def OnMouseWheelForQtyEdit(self, *args): if uicore.registry.GetFocus() != self.qtyEdit: return SinglelineEdit.MouseWheel(self.qtyEdit, *args) def PositionQtyContainer(self): subContTop = self.height / 2.0 - self.qtySubCont.GetAutoSize()[1] / 2.0 self.qtySubCont.top = int(subContTop) def DrawPrice(self): self.priceLabel = EveLabelMediumBold(name='priceLabel', text='', parent=self.priceCont, left=4, align=uiconst.CENTERRIGHT, state=uiconst.UI_NORMAL) def DrawDelta(self): self.deltaContainer = BuyDeltaContainer(parent=self.deltaCont, delta=self.GetDelta(), func=self.OpenMarket, align=uiconst.CENTERRIGHT) self.deltaContainer.LoadTooltipPanel = self.LoadDeltaTooltip def DrawItem(self): iconCont = Container(name='iconCont', parent=self.textCont, align=uiconst.TOLEFT, width=32, padding=4) iconInnerCont = Container(name='iconInnerCont', parent=iconCont, align=uiconst.CENTER, pos=(0, 0, 32, 32)) self.wheel = LoadingWheel(parent=iconCont, pos=(0, 0, 48, 48), align=uiconst.CENTER, idx=0) self.wheel.display = False self.techIcon = Sprite(parent=iconInnerCont, pos=(0, 0, 16, 16), align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL) GetTechLevelIcon(self.techIcon, 1, self.typeID) self.icon = Icon(parent=iconInnerCont, typeID=self.typeID, state=uiconst.UI_DISABLED, align=uiconst.CENTER) self.icon.SetSize(32, 32) itemName = GetShowInfoLink(typeID=self.typeID, text=evetypes.GetName(self.typeID)) self.itemNameLabel = Label(text=itemName, parent=self.textCont, left=40, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL, autoFadeSides=35, fontsize=12) def SetPrice(self): self.priceLabel.text = self.GetPriceText() def GetPriceText(self): if self.newBestPrice: return FmtISK(self.newBestPrice) else: return NA_CHAR def GetBestPrice(self): totalQty = self.qty * self.orderMultiplier self.newBestPrice, self.numOrders = self.quoteSvc.GetBestAskPriceInStationAndNumberOrders( self.typeID, self.stationID, totalQty) self.UpdateOrderStateInUI() def UpdateOrderStateInUI(self): if self.newBestPrice: self.HideNoSellOrders() else: self.ShowNoSellOrders() def GetTotalSum(self): price = self.GetPrice() or 0 totalQty = self.GetQty() * self.orderMultiplier self.totalSum = price * totalQty self.SetTotalText(self.totalSum) return self.totalSum def SetTotalText(self, totalSum): if totalSum: self.totalLabel.text = FmtISK(totalSum) else: self.totalLabel.text = NA_CHAR def UpdateOrderMultiplier(self, multiplier): self.orderMultiplier = multiplier self.OnChange() def UpdateStationID(self, stationID): self.stationID = stationID self.UpdateUIElements() def OnChange(self, *args): if self.adjustQtyTimer: self.adjustQtyTimer.KillTimer() self.adjustQtyTimer = AutoTimer(1000, self.AdjustQty_thread, *args) self.SetItemLoading() def SetItemLoading(self): self.wheel.display = True self.qtyTotal.text = '' self.totalLabel.text = '' self.priceLabel.text = NA_CHAR self.deltaContainer.display = False self.totalLabel.text = NA_CHAR self.isUpdating = True def AdjustQty_thread(self, *args): self.adjustQtyTimer = None if self.destroyed: return self.qty = self.GetQty() self.SetTotalQtyText() self.GetBestPrice() self.SetPrice() self.deltaContainer.display = True self.UpdateDelta() self.GetTotalSum() self.wheel.display = False self.isUpdating = False if self.parentEditFunc: self.parentEditFunc(args) def SetTotalQtyText(self): totalQty = self.GetTotalQty() if totalQty is None: self.qtyTotal.text = '' self.qtyTotal.hint = '' elif self.orderMultiplier > 1: self.qtyTotal.display = True self.qtyTotal.text = '= %s' % FmtAmt(totalQty) self.qtyTotal.hint = GetByLabel( 'UI/Market/MarketQuote/TotalAmountToBuy', numOrders=self.orderMultiplier, qty=self.GetQty()) else: self.qtyTotal.display = False def GetPrice(self): return self.newBestPrice def GetQty(self): qty = self.qtyEdit.GetValue() return qty def GetTotalQty(self): qty = self.GetQty() return self.orderMultiplier * qty def GetTradeWndClass(self): from eve.client.script.ui.shared.market.buyMultiFromBase import MultiBuy return MultiBuy def GetDiffFromAvgText(self): return '%s %s' % (GetByLabel('UI/Market/MarketQuote/RegionalAdverage'), self.GetDeltaText()) def LoadDeltaTooltip(self, tooltipPanel, *args): tooltipPanel.LoadGeneric2ColumnTemplate() tooltipPanel.cellPadding = (4, 1, 4, 1) tooltipPanel.AddLabelLarge( text=GetByLabel('UI/Market/Marketbase/PricePerUnit')) tooltipPanel.AddLabelLarge(text=self.GetPriceText(), align=uiconst.CENTERRIGHT) bestMatchDetails = tooltipPanel.AddLabelSmall( text='', align=uiconst.CENTERRIGHT, colSpan=tooltipPanel.columns) tooltipPanel.AddSpacer(1, 8, colSpan=tooltipPanel.columns) tooltipPanel.AddLabelMedium(text=self.GetDiffFromAvgText(), align=uiconst.CENTERRIGHT) tooltipPanel.AddLabelMedium(text=FmtISK(self.averagePrice), align=uiconst.CENTERRIGHT) tooltipPanel.AddSpacer(1, 8, colSpan=tooltipPanel.columns) tooltipPanel.AddLabelMedium( text=GetByLabel('UI/Market/MarketQuote/BestInStation')) stationBestPrice = self.GetBestMatchText(rangeStation) tooltipPanel.AddLabelMedium(text=stationBestPrice, align=uiconst.CENTERRIGHT) tooltipPanel.AddLabelMedium( text=GetByLabel('UI/Market/MarketQuote/BestInSystem')) stationBestPrice = self.GetBestMatchText(rangeSolarSystem) tooltipPanel.AddLabelMedium(text=stationBestPrice, align=uiconst.CENTERRIGHT) tooltipPanel.AddLabelMedium( text=GetByLabel('UI/Market/MarketQuote/BestRegional')) regBestPrice = self.GetBestMatchText(rangeRegion) tooltipPanel.AddLabelMedium(text=regBestPrice, align=uiconst.CENTERRIGHT) if not self.newBestPrice: bestMatchDetails.text = GetByLabel( 'UI/Market/MarketQuote/NoMatchForOrder') bestMatchDetails.color = (1.0, 0.275, 0.0, 1.0) else: bestMatchDetails.text = GetByLabel( 'UI/Market/MarketQuote/FromNumberOfOrders', numOrders=self.numOrders) bestMatchDetails.SetAlpha(0.6) def GetBestMatchText(self, orderRange): bestOrder = self.quoteSvc.GetBestAskInRange(self.typeID, self.stationID, orderRange) if bestOrder: return FmtISK(bestOrder.price) return NA_CHAR def AddQtyToEntry(self, extraQty): self.Blink() qty = self.qtyEdit.GetValue() newQty = extraQty + qty self.qtyEdit.SetValue(newQty) def Blink(self): self.ConstructBlinkBG() uicore.animations.FadeTo(self.blinkBG, 0.0, 0.25, duration=0.25, curveType=uiconst.ANIM_WAVE, loops=2) def ConstructBlinkBG(self): if self.blinkBG is None: self.blinkBG = Sprite( name='blinkBg', bgParent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/InvItem/bgSelected.png', opacity=0.0, idx=0) def OnDropData(self, dragSource, dragData): if self.dropParentFunc: self.dropParentFunc(dragSource, dragData)