def ApplyAttributes(self, attributes): uiprimitives.Container.ApplyAttributes(self, attributes) self.btnData = attributes.btnData self.btnNum = attributes.btnNum self.width = attributes.width self._isDraggable = attributes.get('isDraggable', self.default_isDraggable) self._openNeocomPanel = None self.height = self.width self.top = self.height * self.btnNum self.panel = None self.blinkThread = None self.realTop = self.top self.dragEventCookie = None self.disableClick = False self.iconSize = self.height - 2 * self.PADVERTICAL self.iconTransform = uiprimitives.Transform(name='iconTransform', parent=self, align=uiconst.TOALL, scalingCenter=(0.5, 0.5)) self.iconLabelCont = None if self.btnData.id == 'map_beta': Sprite(parent=self.iconTransform, align=uiconst.TOPLEFT, pos=(0, 0, 11, 29), texturePath='res:/UI/Texture/Shared/betaTag.png', state=uiconst.UI_DISABLED) self.icon = GlowSprite(parent=self.iconTransform, name='icon', state=uiconst.UI_DISABLED, align=uiconst.CENTER, width=self.iconSize, height=self.iconSize, iconOpacity=1.0) self.UpdateIcon() PAD = 1 self.blinkSprite = SpriteUnderlay(bgParent=self, name='blinkSprite', texturePath='res:/UI/Texture/classes/Neocom/buttonBlink.png', state=uiconst.UI_HIDDEN, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW) self.activeFrame = FrameUnderlay(bgParent=self, name='hoverFill', texturePath='res:/UI/Texture/classes/Neocom/buttonActive.png', cornerSize=5, state=uiconst.UI_HIDDEN, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW) self.CheckIfActive() self.dropFrame = uicontrols.Frame(parent=self, name='hoverFrame', color=util.Color.GetGrayRGBA(1.0, 0.5), state=uiconst.UI_HIDDEN) sm.RegisterNotify(self)
def ConstructBackground(self): self.mouseEnterBG = SpriteUnderlay( name='mouseEnterBG', bgParent=self.bgContainer, texturePath='res:/UI/Texture/classes/ButtonIcon/mouseEnter.png', opacity=0.0, color=self.colorSelected) self.mouseDownBG = SpriteUnderlay( name='mouseEnterBG', bgParent=self.bgContainer, texturePath='res:/UI/Texture/classes/ButtonIcon/mouseDown.png', opacity=0.0, color=self.colorSelected)
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.texturePath = attributes.Get('texturePath', self.default_texturePath) self.color = attributes.Get('color', None) self.rotation = attributes.Get('rotation', self.default_rotation) self.iconOpacity = attributes.Get('iconOpacity', self.default_iconOpacity) self.gradientStrength = attributes.get('gradientStrength', self.default_gradientStrength) self.color = attributes.get('color', self.default_color) self._glowAmount = 0.0 self.spriteEffect = None self.glowExpand = None self.icon = SpriteUnderlay(bgParent=self, name='icon', state=uiconst.UI_DISABLED, align=uiconst.TOALL, blendMode=trinity.TR2_SBM_ADD, opacity=self.iconOpacity, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, color=self.color, texturePath=self.texturePath, rotation=self.rotation) self.glowIcon = None self.bgGradient = None
def ApplyAttributes(self, attributes): uiprimitives.Container.ApplyAttributes(self, attributes) self.SetSliderLabel = attributes.get('setlabelfunc', self.default_setlabelfunc) self.GetSliderHint = attributes.get('gethintfunc', self.GetSliderHint) self.GetSliderValue = attributes.get('getvaluefunc', self.default_getvaluefunc) self.EndSetSliderValue = attributes.get('endsliderfunc', self.default_endsliderfunc) self.OnSetValue = attributes.get('onsetvaluefunc', self.default_onsetvaluefunc) self.value = None self.valueproportion = None self.increments = [] self.label = None self.top = 0 self.dragging = False self.valueHint = TooltipGeneric(parent=uicore.layer.hint, idx=0) self.valueHint.textLabel.align = uiconst.CENTER self.valueHint.textLabel.left = 0 self.valueHint.textLabel.top = 0 self.valueHint.display = False SpriteUnderlay(parent=self, name='handle', state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Slider/handle.png', align=uiconst.TOALL) Frame(parent=self.parent, color=(0.5, 0.5, 0.5, 0.3))
def ConstructBlinkBackground(self): if self.blinkBg: return self.blinkBg = SpriteUnderlay( name='blinkBG', bgParent=self.bgContainer, texturePath='res:/UI/Texture/classes/ButtonIcon/mouseEnter.png', opacity=0.0)
def ApplyAttributes(self, attributes): uiprimitives.Container.ApplyAttributes(self, attributes) overlay = uiprimitives.Sprite(parent=self, name='overlay', align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Fitting/fittingbase_overlay.png', color=(1.0, 1.0, 1.0, 0.39)) self.sr.calibrationStatusPoly = uicls.Polygon(parent=self, name='calibrationStatusPoly', align=uiconst.CENTER, spriteEffect=trinity.TR2_SFX_FILL, blendMode=trinity.TR2_SBM_ADD) self.sr.powergridStatusPoly = uicls.Polygon(parent=self, name='powergridStatusPoly', align=uiconst.CENTER, spriteEffect=trinity.TR2_SFX_FILL, blendMode=trinity.TR2_SBM_ADD) self.sr.cpuStatusPoly = uicls.Polygon(parent=self, name='cpuStatusPoly', align=uiconst.CENTER, spriteEffect=trinity.TR2_SFX_FILL, blendMode=trinity.TR2_SBM_ADD) baseDOT = uiprimitives.Sprite(parent=self, name='baseDOT', align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Fitting/fittingbase_dotproduct.png', spriteEffect=trinity.TR2_SFX_DOT, blendMode=trinity.TR2_SBM_ADD) self.sr.baseColor = SpriteUnderlay(parent=self, name='baseColor', align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Fitting/fittingbase_basecircle.png', colorType=uiconst.COLORTYPE_UIBASE) self.sr.baseShape = uiprimitives.Sprite(parent=self, name='baseShape', align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Fitting/fittingbase.png', color=(0.0, 0.0, 0.0, 0.86))
def OnMouseEnter(self, *args): if not self.callback: self.opacity = DISABLED_OPACITY else: self.opacity = MOUSEOVER_OPACITY uicore.Message('ListEntryEnter') if not self._hiliteSprite: self._hiliteSprite = SpriteUnderlay(parent=self, name='hiliteSprite', texturePath='res:/UI/Texture/classes/UtilMenu/entryHilite.png', opacity=0.0, padding=(1, 0, 1, 0), align=uiconst.TOALL, state=uiconst.UI_DISABLED) uicore.animations.FadeIn(self._hiliteSprite, 0.2, duration=uiconst.TIME_ENTRY) self.hiliteTimer = AutoTimer(1, self._CheckIfStillHilited)
def ApplyAttributes(self, attributes): uiprimitives.Container.ApplyAttributes(self, attributes) self._fixedFromProportion = None self._fixedToProportion = None self._minRange = None rangeParent = uiprimitives.Container(parent=self, align=uiconst.TOTOP, height=attributes.barHeight or 9, padding=(MAINSIDEMARGIN, 8, MAINSIDEMARGIN, 0), state=uiconst.UI_NORMAL) rangeParent.OnMouseDown = (self.StartMoveRange, rangeParent) rangeParent.OnMouseUp = (self.StopMoveRange, rangeParent) rangeParent.OnMouseMove = (self.MoveRange, rangeParent) for name in ('from', 'to'): parent = uiprimitives.Container(parent=rangeParent) rangeContainer = SizeCappedContainer(parent=parent, align=uiconst.TOLEFT_PROP) rangeContainer._background = FillUnderlay(bgParent=rangeContainer, opacity=0.8) rangeContainer._pointer = SpriteUnderlay(parent=rangeContainer, align=uiconst.TOPRIGHT, pos=(-8, -7, 16, 16)) setattr(self, '_' + name + 'Range', rangeContainer) configName = '_' + name + 'Handle' handle = uiprimitives.Container(parent=self, name=configName, align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL, pos=(0, 0, MAINSIDEMARGIN * 2, 32), idx=0) handle.OnMouseDown = (self.StartMoveHandle, handle) handle.OnMouseUp = (self.StopMoveHandle, handle) handle.OnMouseMove = (self.MoveHandle, handle) setattr(self, configName, handle) self._background = FillUnderlay(bgParent=rangeParent, opacity=0.8) self._incrementsParent = uiprimitives.Container( parent=self, align=uiconst.TOTOP, height=16, padding=(MAINSIDEMARGIN, 2, MAINSIDEMARGIN, 0), name='_incrementsParent') self._increments = None self._callbackData = None self._fromProportion = attributes.fromProportion or 0.0 self._toProportion = attributes.toProportion or 1.0 self._canInvert = bool(attributes.canInvert) self.height = 48 self.UpdateRanges() self.UpdateHandles() self.OnIncrementChange = attributes.OnIncrementChange self.OnChange = attributes.OnChange self.OnEndDragChange = attributes.OnEndDragChange
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) skinName = attributes.get('skinName', 'general') actualSkinClass = SKIN_NAME_TO_CLASS.get(skinName) if not FrameWithPointer.skinCache.get(skinName): FrameWithPointer.skinCache[skinName] = actualSkinClass() self.skin = FrameWithPointer.skinCache[skinName] self._pointer = SpriteUnderlay( texturePath= 'res:/UI/Texture/classes/FrameWithPointer/pointer_down_02.png', parent=self, colorType=attributes.colorType or uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.95) self._background = FrameUnderlay( name='__underlay', bgParent=self, cornerSize=self.skin.backgroundCornerSize, offset=self.skin.backgroundOffset, texturePath=self.skin.backgroundTexture, colorType=attributes.colorType or uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.95)
def ApplyAttributes(self, attributes): Transform.ApplyAttributes(self, attributes) self.display = False rangeSize = attributes.rangeSize self.rangeMeterLeftSide = SpriteUnderlay( parent=self, name='rangeMeterLeftSide', pos=(0, 0, rangeSize, rangeSize), state=uiconst.UI_PICKCHILDREN, texturePath='res:/UI/Texture/classes/RadialMenu/rangeMaskL.png', textureSecondaryPath= 'res:/UI/Texture/classes/RadialMenu/gaugeFill.png', colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.5, align=uiconst.CENTER, blendMode=1, spriteEffect=trinity.TR2_SFX_MODULATE) self.rangeMeterLeftSide.display = True self.rangeMeterRightSide = SpriteUnderlay( parent=self, name='rangeMeterRightSide', pos=(0, 0, rangeSize, rangeSize), state=uiconst.UI_PICKCHILDREN, texturePath='res:/UI/Texture/classes/RadialMenu/rangeMaskR.png', textureSecondaryPath= 'res:/UI/Texture/classes/RadialMenu/gaugeFill.png', colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.5, align=uiconst.CENTER, blendMode=1, spriteEffect=trinity.TR2_SFX_MODULATE) self.rangeMeterRightSide.display = True self.rangeMeterFull = Sprite( parent=self, name='rangeMeterFull', pos=(0, 0, rangeSize, rangeSize), state=uiconst.UI_PICKCHILDREN, texturePath='res:/UI/Texture/classes/RadialMenu/rangeShadow.png', align=uiconst.CENTER, color=(1.0, 1.0, 1.0, 0.4))
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) labelLeft = 22 iconLeft = 3 if attributes.indentation: labelLeft += attributes.indentation iconLeft += attributes.indentation self.label = EveLabelMedium(parent=self, text=attributes.text, align=uiconst.CENTERLEFT, left=labelLeft, state=uiconst.UI_DISABLED) icon = attributes.Get('icon', self.default_icon) if icon is not None: self.icon = SpriteUnderlay(parent=self, texturePath=icon, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, state=uiconst.UI_DISABLED, left=iconLeft, width=16, height=16, align=uiconst.CENTERLEFT, ignoreSize=True) self.ResetOpacity() self.UpdateEntryHeight()
def Prepare_Handle_(self): self.handleOffset = 2 self.handle = SpriteUnderlay( name='diode', parent=self.barCont, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL, pos=(-self.handleOffset, 0, 12, 12), idx=0, texturePath='res:/UI/Texture/classes/Slider/handle.png') self.handle.OnMouseEnter = self.OnHandleMouseEnter self.handle.OnMouseExit = self.OnHandleMouseExit self.handle.OnMouseDown = self.OnHandleMouseDown self.handle.OnMouseUp = self.OnHandleMouseUp self.handle.OnMouseMove = self.OnHandleMouseMove
def CreateSectionContainer(parent): Line(parent=parent, align=uiconst.TOTOP, color=LINE_COLOR) container = ContainerAutoSize(parent=parent, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, state=uiconst.UI_PICKCHILDREN, bgColor=BACKGROUND_GRAY_COLOR) Line(parent=parent, align=uiconst.TOTOP, color=LINE_COLOR) SpriteUnderlay( bgParent=container, name='blinkSprite', texturePath='res:/UI/Texture/classes/Neocom/buttonBlink.png', state=uiconst.UI_HIDDEN, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW) return container
class ButtonBase(uiprimitives.Container): """ An abstract button that others inherit from """ __guid__ = 'neocom.ButtonBase' __notifyevents__ = ['ProcessNeocomBlinkPulse'] default_name = 'ButtonBase' default_state = uiconst.UI_NORMAL default_align = uiconst.TOPLEFT default_isDraggable = True PADHORIZONTAL = 6 PADVERTICAL = 4 ACTIVEFILL_DEFAULTALPHA = 0.5 ACTIVEFILL_HOVERALPHA = 0.8 def ApplyAttributes(self, attributes): uiprimitives.Container.ApplyAttributes(self, attributes) self.btnData = attributes.btnData self.btnNum = attributes.btnNum self.width = attributes.width self._isDraggable = attributes.get('isDraggable', self.default_isDraggable) self._openNeocomPanel = None self.height = self.width self.top = self.height * self.btnNum self.panel = None self.blinkThread = None self.realTop = self.top self.dragEventCookie = None self.disableClick = False self.iconSize = self.height - 2 * self.PADVERTICAL self.iconTransform = uiprimitives.Transform(name='iconTransform', parent=self, align=uiconst.TOALL, scalingCenter=(0.5, 0.5)) self.iconLabelCont = None if self.btnData.id == 'map_beta': Sprite(parent=self.iconTransform, align=uiconst.TOPLEFT, pos=(0, 0, 11, 29), texturePath='res:/UI/Texture/Shared/betaTag.png', state=uiconst.UI_DISABLED) self.icon = GlowSprite(parent=self.iconTransform, name='icon', state=uiconst.UI_DISABLED, align=uiconst.CENTER, width=self.iconSize, height=self.iconSize, iconOpacity=1.0) self.UpdateIcon() PAD = 1 self.blinkSprite = SpriteUnderlay(bgParent=self, name='blinkSprite', texturePath='res:/UI/Texture/classes/Neocom/buttonBlink.png', state=uiconst.UI_HIDDEN, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW) self.activeFrame = FrameUnderlay(bgParent=self, name='hoverFill', texturePath='res:/UI/Texture/classes/Neocom/buttonActive.png', cornerSize=5, state=uiconst.UI_HIDDEN, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW) self.CheckIfActive() self.dropFrame = uicontrols.Frame(parent=self, name='hoverFrame', color=util.Color.GetGrayRGBA(1.0, 0.5), state=uiconst.UI_HIDDEN) sm.RegisterNotify(self) def UpdateIcon(self): texturePath = self._GetPathFromIconNum(self.btnData.iconPath) self.icon.SetTexturePath(texturePath) def CheckIfActive(self): if self.btnData.isActive: self.activeFrame.Show() else: self.activeFrame.Hide() def GetIconPath(self): return self._GetPathFromIconNum(self.btnData.iconPath) def _GetPathFromIconNum(self, iconNum): if iconNum.startswith('res:/'): return iconNum parts = iconNum.split('_') if len(parts) == 2: sheet, iconNum = parts iconSize = uix.GetIconSize(sheet) return 'res:/ui/texture/icons/%s_%s_%s.png' % (int(sheet), int(iconSize), int(iconNum)) elif len(parts) == 4: root, sheet, iconSize, iconNum = parts if root == 'ui': root = 'icons' return 'res:/ui/texture/%s/%s_%s_%s.png' % (root, int(sheet), int(iconSize), int(iconNum)) else: return neocomCommon.ICONPATH_DEFAULT def IsDraggable(self): return self._isDraggable def SetDraggable(self, isDraggable): self._isDraggable = isDraggable def GetMenu(self): return self.btnData.GetMenu() def LoadTooltipPanel(self, tooltipPanel, *args): isOpen = self._openNeocomPanel and not self._openNeocomPanel.destroyed if isOpen: return tooltipPanel.LoadGeneric3ColumnTemplate() blinkHintStr = None if getattr(self.btnData, 'cmdName', None): cmd = uicore.cmd.commandMap.GetCommandByName(self.btnData.cmdName) tooltipPanel.AddCommandTooltip(cmd) blinkHintStr = self.btnData.blinkHint else: label = None if self.IsSingleWindow(): wnd = self.GetWindow() if not wnd.destroyed: label = wnd.GetCaption() elif self.btnData.children: label = self.btnData.children[0].wnd.GetNeocomGroupLabel() mainStr = label or self.btnData.label tooltipPanel.AddLabelMedium(text=mainStr) self.LoadTooltipPanelDetails(tooltipPanel, self.btnData) if blinkHintStr: tooltipPanel.AddLabelMedium(text=blinkHintStr, width=200, colSpan=tooltipPanel.columns) def LoadTooltipPanelDetails(cls, tooltipPanel, btnData): if btnData.id == 'wallet': showFractions = settings.user.ui.Get('walletShowCents', 1) personalWealth = util.FmtISK(sm.GetService('wallet').GetWealth(), showFractions) tooltipPanel.AddLabelValue(label=localization.GetByLabel('Tooltips/Neocom/Balance'), value=personalWealth) canAccess = sm.GetService('wallet').HaveReadAccessToCorpWalletDivision(session.corpAccountKey) if canAccess: corpWealth = util.FmtISK(sm.GetService('wallet').GetCorpWealthCached1Min(session.corpAccountKey), showFractions) tooltipPanel.AddLabelValue(label=localization.GetByLabel('Tooltips/Neocom/CorporationBalance'), value=corpWealth) def GetTooltipPointer(self): return uiconst.POINT_LEFT_2 def IsSingleWindow(self): return False def OnMouseEnter(self, *args): self.btnData.SetBlinkingOff() self.icon.OnMouseEnter() def OnMouseExit(self, *args): self.icon.OnMouseExit() def OnMouseDown(self, *args): if not self.IsDraggable(): return if not uicore.uilib.leftbtn: return self.isDragging = False self.mouseDownY = uicore.uilib.y if self.dragEventCookie is not None: uicore.event.UnregisterForTriuiEvents(self.dragEventCookie) self.dragEventCookie = uicore.event.RegisterForTriuiEvents(uiconst.UI_MOUSEMOVE, self.OnDrag) uicore.animations.Tr2DScaleTo(self.iconTransform, self.iconTransform.scale, (0.95, 0.95), duration=0.1) self.icon.OnMouseDown() def OnMouseUp(self, *args): if uicore.uilib.mouseOver == self: uicore.animations.Tr2DScaleTo(self.iconTransform, self.iconTransform.scale, (1.0, 1.0), duration=0.1) if self.dragEventCookie is not None: uicore.event.UnregisterForTriuiEvents(self.dragEventCookie) self.dragEventCookie = None self.icon.OnMouseUp() def OnDragEnd(self, *args): uicore.event.UnregisterForTriuiEvents(self.dragEventCookie) self.dragEventCookie = None self.isDragging = False sm.GetService('neocom').OnButtonDragEnd(self) self.CheckIfActive() def OnDrag(self, *args): if math.fabs(self.mouseDownY - uicore.uilib.y) > 5 or self.isDragging: if not self.isDragging: uicore.event.RegisterForTriuiEvents(uiconst.UI_MOUSEUP, self.OnDragEnd) self.disableClick = True self.isDragging = True sm.GetService('neocom').OnButtonDragged(self) return True def OnClick(self, *args): if not self or self.destroyed: return self.btnData.CheckContinueBlinking() if not self.disableClick: self.OnClickCommand() if not self or self.destroyed: return self.disableClick = False if self.dragEventCookie: uicore.event.UnregisterForTriuiEvents(self.dragEventCookie) def OnDblClick(self, *args): """ Swallow double click event so that we don't get two OnClick events """ pass def OnClickCommand(self): """ Overridden by subclasses """ pass def OnSwitched(self): uicore.effect.MorphUIMassSpringDamper(item=self, attrname='opacity', float=1, newVal=1.0, minVal=0, maxVal=2.0, dampRatio=0.45, frequency=15.0, initSpeed=0, maxTime=4.0, callback=None, initVal=0.0) self.isDragging = False self.disableClick = False def GetDragData(self, *args): if self.btnData.isDraggable: return [self.btnData] def BlinkOnce(self, duration = 0.7): self.blinkSprite.Show() uicore.animations.SpSwoopBlink(self.blinkSprite, rotation=math.pi * 0.75, duration=duration) def ProcessNeocomBlinkPulse(self): if self.btnData.isBlinking: self.BlinkOnce() def OnDropData(self, source, dropData): if not sm.GetService('neocom').IsValidDropData(dropData): return index = self.btnData.parent.children.index(self.btnData) sm.GetService('neocom').OnBtnDataDropped(dropData[0], index) def OnDragEnter(self, panelEntry, dropData): if not sm.GetService('neocom').IsValidDropData(dropData): return sm.GetService('neocom').OnButtonDragEnter(self.btnData, dropData[0]) uthread.new(self.ShowPanelOnMouseHoverThread) def OnDragExit(self, *args): sm.GetService('neocom').OnButtonDragExit(self.btnData, args) def ToggleNeocomPanel(self): isOpen = self._openNeocomPanel and not self._openNeocomPanel.destroyed sm.GetService('neocom').CloseAllPanels() if isOpen: self._openNeocomPanel = None else: self._openNeocomPanel = sm.GetService('neocom').ShowPanel(triggerCont=self, panelClass=self.GetPanelClass(), panelAlign=neocomCommon.PANEL_SHOWONSIDE, parent=uicore.layer.abovemain, btnData=self.btnData) RefreshTooltipForOwner(self) def ShowPanelOnMouseHoverThread(self): if len(self.btnData.children) <= 1: return blue.pyos.synchro.Sleep(500) if not self or self.destroyed: return if uicore.uilib.mouseOver == self: self.ToggleNeocomPanel() def GetPanelClass(self): return neocomPanels.PanelGroup def SetAsActive(self): self.btnData.isActive = True self.activeFrame.state = uiconst.UI_DISABLED def SetAsInactive(self): self.btnData.isActive = False self.activeFrame.state = uiconst.UI_HIDDEN
def ApplyAttributes(self, attributes): uiprimitives.Transform.ApplyAttributes(self, attributes) self.degree = attributes.get('degree', 0) self.func = None self.funcArgs = None self.itemID = attributes.itemID self.isDisabled = False self.degreeWidth = attributes.degreeWidth self.labelPath = '' self.labelText = '' self.isEmpty = attributes.get('isEmpty', False) self.commandName = None self.isHilighted = False self.fullWidth = attributes.sizeInfo.buttonWidth self.fullHeight = attributes.sizeInfo.buttonHeight iconPar = uiprimitives.Transform(parent=self, name='iconPar', pos=(0, 3, 32, 32), state=uiconst.UI_DISABLED, align=uiconst.CENTER) iconPar.rotation = mathUtil.DegToRad(self.degree) self.icon = GlowSprite(parent=iconPar, name='icon', pos=(0, 0, 32, 32), state=uiconst.UI_DISABLED, align=uiconst.CENTER) selectionSlice = SpriteUnderlay(parent=self, name='selectionSlice', state=uiconst.UI_DISABLED, texturePath=self.selelectedBasePath % self.degreeWidth, align=uiconst.TOALL, opacity=0.9) selectionSlice.display = False self.selectionSlice = selectionSlice if self.isEmpty: sliceTexturePath = self.emptySliceBasePath % self.degreeWidth else: sliceTexturePath = self.sliceBasePath % self.degreeWidth self.hilite = SpriteUnderlay(parent=self, name='hilite', state=uiconst.UI_DISABLED, texturePath=self.selelectedBasePath % self.degreeWidth, align=uiconst.TOALL, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.0) self.availableSlice = SpriteUnderlay(parent=self, name='availableSlice', state=uiconst.UI_DISABLED, texturePath=sliceTexturePath, align=uiconst.TOALL, opacity=attributes.get( 'buttonBackgroundOpacity', 0.8)) self.unavailableSlice = SpriteUnderlay( parent=self, name='unavailableSlice', state=uiconst.UI_DISABLED, texturePath=sliceTexturePath, align=uiconst.TOALL, colorType=uiconst.COLORTYPE_UIBASE, opacity=0.85) self.unavailableSlice.display = False self.sliceInUse = self.availableSlice
def ApplyAttributes(self, attributes): SpriteUnderlay.ApplyAttributes(self, attributes) self.shadowSize = attributes.shadowSize
class FrameWithPointer(Container): pointerOffset = None skinCache = {} def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) skinName = attributes.get('skinName', 'general') actualSkinClass = SKIN_NAME_TO_CLASS.get(skinName) if not FrameWithPointer.skinCache.get(skinName): FrameWithPointer.skinCache[skinName] = actualSkinClass() self.skin = FrameWithPointer.skinCache[skinName] self._pointer = SpriteUnderlay( texturePath= 'res:/UI/Texture/classes/FrameWithPointer/pointer_down_02.png', parent=self, colorType=attributes.colorType or uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.95) self._background = FrameUnderlay( name='__underlay', bgParent=self, cornerSize=self.skin.backgroundCornerSize, offset=self.skin.backgroundOffset, texturePath=self.skin.backgroundTexture, colorType=attributes.colorType or uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.95) def SetColor(self, color): self._background.color = color self._pointer.color = color def SetAlpha(self, alphaValue): self._background.SetAlpha(alphaValue) self._pointer.SetAlpha(alphaValue) def UpdatePointerPosition(self, positionFlag): if positionFlag == uiconst.POINTER_NONE: self._pointer.display = False return (0, 0) SIZE = 24 BACKOFFSET = 8 x, y = positionFlag self._pointer.displayX = [ -SIZE + BACKOFFSET, 0, (self.displayWidth - SIZE) / 2, self.displayWidth - SIZE, self.displayWidth - BACKOFFSET ][x] self._pointer.displayY = [ -SIZE + BACKOFFSET, 0, (self.displayHeight - SIZE) / 2, self.displayHeight - SIZE, self.displayHeight - BACKOFFSET ][y] self._pointer.displayWidth = SIZE self._pointer.displayHeight = SIZE if y == 0: if x == 0: self._pointer.displayX = -11 self._pointer.displayY = -11 resPath = self.skin.topLeftTexture self.pointerOffset = [ self._pointer.displayX + 5, self._pointer.displayY + 5 ] elif x == 4: self._pointer.displayX = self.displayWidth - 13 self._pointer.displayY = -11 resPath = self.skin.topRightTexture self.pointerOffset = [ self._pointer.displayX + 19, self._pointer.displayY + 5 ] else: resPath = self.skin.upTexture self.pointerOffset = [ self._pointer.displayX + SIZE / 2, self._pointer.displayY + 10 ] elif y == 4: if x == 0: self._pointer.displayX = -11 self._pointer.displayY = self.displayHeight - 13 resPath = self.skin.bottomLeftTexture self.pointerOffset = [ self._pointer.displayX + 5, self._pointer.displayY + 19 ] elif x == 4: self._pointer.displayX = self.displayWidth - 13 self._pointer.displayY = self.displayHeight - 13 resPath = self.skin.bottomRightTexture self.pointerOffset = [ self._pointer.displayX + 19, self._pointer.displayY + 19 ] else: resPath = self.skin.downTexture self.pointerOffset = [ self._pointer.displayX + SIZE / 2, self._pointer.displayY + 14 ] elif x == 0: resPath = self.skin.leftTexture self.pointerOffset = [ self._pointer.displayX + 10, self._pointer.displayY + SIZE / 2 ] elif x == 4: resPath = self.skin.rightTexture self.pointerOffset = [ self._pointer.displayX + 14, self._pointer.displayY + SIZE / 2 ] self._pointer.SetTexturePath(resPath) self._pointer.display = True return self.pointerOffset
class ButtonIcon(Container): """ A button that is only a white icon without background (until hovered over) """ __guid__ = 'uicontrols.ButtonIcon' OPACITY_IDLE = 0.0 OPACITY_INACTIVE = 0.0 OPACITY_MOUSEHOVER = 1.1 OPACITY_MOUSECLICK = 2.5 OPACITY_SELECTED = 0.5 COLOR_DEFAULT = (1, 1, 1, 1.0) OPACITY_GLOW_IDLE = 0.0 OPACITY_GLOW_MOUSEHOVER = 0.3 OPACITY_GLOW_MOUSECLICK = 0.6 default_func = None default_args = None default_width = 32 default_height = 32 default_align = uiconst.TOPLEFT default_state = uiconst.UI_NORMAL default_texturePath = None default_isActive = True default_iconSize = 16 default_rotation = 0 default_noBgSize = 1 default_iconColor = None default_colorSelected = None default_isHoverBGUsed = None def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.func = attributes.get('func', self.default_func) self.args = attributes.get('args', self.default_args) self.isActive = attributes.get('isActive', True) self.texturePath = attributes.get('texturePath', self.default_texturePath) self.iconSize = attributes.get('iconSize', self.default_iconSize) self.iconColor = attributes.get('iconColor', self.default_iconColor) self.isHoverBGUsed = attributes.Get('isHoverBGUsed', self.default_isHoverBGUsed) self.colorSelected = attributes.Get('colorSelected', self.default_colorSelected) self.rotation = attributes.Get('rotation', self.default_rotation) if self.isHoverBGUsed is None: if self.iconSize < self.default_noBgSize: self.isHoverBGUsed = True else: self.isHoverBGUsed = False self.isSelected = False self.enabled = True self.icon = self.ConstructIcon() self.glowIcon = None width, height = self.GetAbsoluteSize() size = min(width, height) bgCont = Container(name='bgCont', parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=size, height=size) self.bgContainer = bgCont self.selectedBG = None self.ConstructBackground() self.blinkBg = None self.SetActive(self.isActive, animate=False) def ConstructBackground(self): self.mouseEnterBG = SpriteUnderlay( name='mouseEnterBG', bgParent=self.bgContainer, texturePath='res:/UI/Texture/classes/ButtonIcon/mouseEnter.png', opacity=0.0, color=self.colorSelected) self.mouseDownBG = SpriteUnderlay( name='mouseEnterBG', bgParent=self.bgContainer, texturePath='res:/UI/Texture/classes/ButtonIcon/mouseDown.png', opacity=0.0, color=self.colorSelected) def ConstructIcon(self): sprite = GlowSprite(name='icon', parent=self, align=uiconst.CENTER, width=self.iconSize, height=self.iconSize, texturePath=self.texturePath, state=uiconst.UI_DISABLED, color=self.iconColor, iconOpacity=0.5, gradientStrength=0.5, rotation=self.rotation) return sprite def SetTexturePath(self, texturePath): self.icon.SetTexturePath(texturePath) def SetColor(self, color): self.mouseEnterBG.SetFixedColor(color) self.mouseDownBG.SetFixedColor(color) def ConstructBlinkBackground(self): if self.blinkBg: return self.blinkBg = SpriteUnderlay( name='blinkBG', bgParent=self.bgContainer, texturePath='res:/UI/Texture/classes/ButtonIcon/mouseEnter.png', opacity=0.0) def ConstructSelectedBackground(self): if self.selectedBG: return self.selectedBG = FillUnderlay(name='selectedBG', bgParent=self.bgContainer, colorType=uiconst.COLORTYPE_UIHILIGHT, idx=0, color=self.colorSelected) def AccessIcon(self): return self.icon def AccessBackground(self): return self.bgContainer def Disable(self, opacity=0.5): self.opacity = opacity self.enabled = 0 if self.mouseEnterBG: self.mouseEnterBG.StopAnimations() self.mouseEnterBG.opacity = 0.0 def Enable(self): self.opacity = 1.0 self.enabled = 1 def SetRotation(self, value): self.icon.SetRotation(value) def UpdateIconState(self, animate=True): if self.isSelected: glowAmount = 0.3 elif uicore.uilib.mouseOver == self: if uicore.uilib.leftbtn: glowAmount = self.OPACITY_MOUSECLICK else: glowAmount = self.OPACITY_MOUSEHOVER elif self.isActive: glowAmount = self.OPACITY_IDLE else: glowAmount = self.OPACITY_INACTIVE if animate: uicore.animations.MorphScalar(self.icon, 'glowAmount', self.icon.glowAmount, glowAmount, duration=0.2) else: self.icon.glowAmount = glowAmount def SetActive(self, isActive, animate=True): self.UpdateIconState(animate) def SetSelected(self): self.isSelected = True self.ConstructSelectedBackground() self.selectedBG.opacity = self.OPACITY_SELECTED iconColor = GetIconColor(self.colorSelected) self.icon.SetRGBA(*iconColor) self.UpdateIconState() def SetDeselected(self): self.isSelected = False if self.selectedBG: self.selectedBG.opacity = 0.0 self.icon.SetRGBA(*self.COLOR_DEFAULT) self.UpdateIconState() def Blink(self, duration=0.8, loops=1): self.ConstructBlinkBackground() uicore.animations.FadeTo(self.blinkBg, 0.0, 0.9, duration=duration, curveType=uiconst.ANIM_WAVE, loops=loops) def StopBlink(self): if self.blinkBg: uicore.animations.FadeOut(self.blinkBg, 0.3) def OnClick(self, *args): if not self.func or not self.enabled: return if audioConst.BTNCLICK_DEFAULT: uicore.Message(audioConst.BTNCLICK_DEFAULT) if type(self.args) == tuple: self.func(*self.args) elif self.args: self.func(self.args) else: self.func() def OnMouseEnter(self, *args): self.StopBlink() if not self.enabled or self.isSelected: return self.UpdateIconState() if self.isHoverBGUsed: uicore.animations.FadeIn(self.mouseEnterBG, 0.5, duration=0.2) def OnMouseExit(self, *args): self.SetActive(self.isActive) self.UpdateIconState() if self.isHoverBGUsed: uicore.animations.FadeOut(self.mouseEnterBG, duration=0.2) def OnMouseDown(self, *args): if not self.enabled: return self.SetActive(self.isActive) if self.isHoverBGUsed: uicore.animations.FadeTo(self.mouseDownBG, self.mouseDownBG.opacity, 1.0, duration=0.1) uicore.animations.FadeOut(self.mouseEnterBG, duration=0.1) self.UpdateIconState() def OnMouseUp(self, *args): if self.isHoverBGUsed: uicore.animations.FadeOut(self.mouseDownBG, duration=0.1) if not self.enabled: return self.UpdateIconState() if uicore.uilib.mouseOver == self: if self.isHoverBGUsed: uicore.animations.FadeIn(self.mouseEnterBG, 0.5, duration=0.1) def OnEndDrag(self, *args): if uicore.uilib.mouseOver != self: uicore.animations.FadeOut(self.mouseEnterBG, duration=0.2) elif self.isHoverBGUsed: uicore.animations.FadeIn(self.mouseEnterBG, duration=0.1) uicore.animations.FadeOut(self.mouseDownBG, duration=0.1)
class GlowSprite(Container): default_name = 'GlowSprite' default_texturePath = '' default_state = uiconst.UI_NORMAL default_align = uiconst.TOPLEFT default_glowExpand = 0 default_color = None default_rotation = 0.0 default_iconOpacity = 0.9 default_gradientStrength = 1.0 default_color = None def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.texturePath = attributes.Get('texturePath', self.default_texturePath) self.color = attributes.Get('color', None) self.rotation = attributes.Get('rotation', self.default_rotation) self.iconOpacity = attributes.Get('iconOpacity', self.default_iconOpacity) self.gradientStrength = attributes.get('gradientStrength', self.default_gradientStrength) self.color = attributes.get('color', self.default_color) self._glowAmount = 0.0 self.spriteEffect = None self.glowExpand = None self.icon = SpriteUnderlay(bgParent=self, name='icon', state=uiconst.UI_DISABLED, align=uiconst.TOALL, blendMode=trinity.TR2_SBM_ADD, opacity=self.iconOpacity, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, color=self.color, texturePath=self.texturePath, rotation=self.rotation) self.glowIcon = None self.bgGradient = None def ConstructGlow(self): if not self.glowIcon: self.OnSizeUpdate() self.glowIcon = SpriteUnderlay(name='glowIcon', bgParent=self, state=uiconst.UI_DISABLED, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, spriteEffect=self.spriteEffect, padding=-self.glowExpand, blendMode=trinity.TR2_SBM_ADDX2, opacity=0.0, texturePath=self.texturePath, rotation=self.rotation, color=self.color) self.bgGradient = SpriteUnderlay(name='bgGradient', bgParent=self, texturePath='res:/UI/Texture/shared/circularGradient.png', opacity=0.0, padding=-self.glowExpand, color=self.color) def UpdateSpriteEffect(self, size): """ Use BLUR effect for small icons and GLOW for larger """ if size > 20: self.spriteEffect = trinity.TR2_SFX_GLOW else: self.spriteEffect = trinity.TR2_SFX_BLUR def OnSizeUpdate(self): w, h = self.GetAbsoluteSize() size = max(w, h) self.UpdateSpriteEffect(size) self.UpdateGlowExpand(size) def _OnResize(self, *args): self.OnSizeUpdate() def UpdateGlowExpand(self, size): """ Make glow expand more for larger icons """ g = size / 20 g = max(1, min(g, 3)) self.glowExpand = g if self.glowIcon: self.glowIcon.padding = (-g, -g, -g, -g) self.bgGradient.padding = (-g, -g, -g, -g) def SetTexturePath(self, texturePath): self.texturePath = texturePath self.icon.SetTexturePath(texturePath) if self.glowIcon: self.glowIcon.SetTexturePath(texturePath) def LoadTexture(self, texturePath): self.SetTexturePath(texturePath) def LoadIcon(self, iconNo, ignoreSize = False): texturePath, _ = Icon.ConvertIconNoToResPath(iconNo) self.SetTexturePath(texturePath) def LoadIconByTypeID(self, typeID, itemID, *args, **kw): """ Hack needed since loading texturePaths by typeID/itemID is locked within the Icon class """ icon = Icon(typeID=typeID, itemID=itemID) self.SetTexturePath(icon.texturePath) def SetRGBA(self, *color): self.color = color if self.glowIcon: self.glowIcon.SetFixedColor(color) self.bgGradient.SetFixedColor(color) def SetRGB(self, *args): self.SetRGBA(*args) def GetRGBA(self): return self.icon.GetRGBA() def OnMouseEnter(self, *args): uicore.animations.MorphScalar(self, 'glowAmount', self.glowAmount, 1.0, duration=uiconst.TIME_ENTRY) def OnMouseExit(self, *args): uicore.animations.MorphScalar(self, 'glowAmount', self.glowAmount, 0.0, duration=uiconst.TIME_EXIT) def OnMouseDown(self, *args): uicore.animations.MorphScalar(self, 'glowAmount', self.glowAmount, 1.5, duration=0.1) def OnMouseUp(self, *args): uicore.animations.MorphScalar(self, 'glowAmount', self.glowAmount, 1.0, duration=0.3) @property def glowAmount(self): return self._glowAmount @glowAmount.setter def glowAmount(self, value): self.ConstructGlow() self._glowAmount = value self.icon.opacity = self.iconOpacity + value * 0.5 self.glowIcon.opacity = value * 0.2 self.bgGradient.opacity = value * 0.3 * self.gradientStrength self.glowIcon.display = value > 0.0001 def SetRotation(self, value): self.rotation = value self.icon.rotation = value if self.glowIcon: self.glowIcon.rotation = value
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) SpriteUnderlay(bgParent=self, texturePath='res:/UI/Texture/Shared/checkboxShapeOval.png') self.glowSprite = SpriteUnderlay(bgParent=self, texturePath='res:/UI/Texture/shared/buttonGlow.png', colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, blendMode=trinity.TR2_SBM_ADD, padding=0, opacity=0.0)
def ApplyAttributes(self, attributes): WrapperButton.ApplyAttributes(self, attributes) self.btnData = attributes.btnData uiprimitives.Sprite(parent=self, name='EVEMenuIcon', align=uiconst.CENTER, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Icons/79_64_11.png', width=20, height=20, color=util.Color.GetGrayRGBA(1.0, 0.85), idx=0) SpriteUnderlay(bgParent=self, align=uiconst.TOALL, texturePath='res:/UI/Texture/classes/Neocom/panelEntryBG.png', colorType=uiconst.COLORTYPE_UIHILIGHT)
def ConstructGlow(self): if not self.glowIcon: self.OnSizeUpdate() self.glowIcon = SpriteUnderlay(name='glowIcon', bgParent=self, state=uiconst.UI_DISABLED, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, spriteEffect=self.spriteEffect, padding=-self.glowExpand, blendMode=trinity.TR2_SBM_ADDX2, opacity=0.0, texturePath=self.texturePath, rotation=self.rotation, color=self.color) self.bgGradient = SpriteUnderlay(name='bgGradient', bgParent=self, texturePath='res:/UI/Texture/shared/circularGradient.png', opacity=0.0, padding=-self.glowExpand, color=self.color)