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 Prepare_Header_(self):
     top = uiprimitives.Container(parent=self.sr.headerParent,
                                  name='top',
                                  align=uiconst.TOALL,
                                  padding=(2, 2, 2, 0))
     self.sr.captionParent = uiprimitives.Container(parent=top,
                                                    name='captionParent',
                                                    align=uiconst.TOALL,
                                                    clipChildren=True)
     self.sr.caption = EveLabelSmall(text='',
                                     parent=self.sr.captionParent,
                                     left=8,
                                     state=uiconst.UI_DISABLED,
                                     align=uiconst.CENTERLEFT)
     self.headerFill = FillUnderlay(bgParent=top, opacity=0.5)
Example #3
0
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     self.jobData = attributes.jobData
     self.oldJobData = None
     self.pattern = Frame(
         parent=self,
         texturePath=
         'res:/UI/Texture/Classes/Industry/Output/boxPattern.png',
         align=TOALL,
         state=UI_DISABLED,
         opacity=0.0,
         cornerSize=5)
     FrameUnderlay(parent=self, state=UI_DISABLED, align=TOALL, opacity=0.3)
     FillUnderlay(bgParent=self, opacity=0.5)
     self.contentCont = Container(name='contentCont', parent=self)
     self.errorFrame = ErrorFrame(bgParent=self, padding=1)
     self.openInventoryBtn = ButtonIcon(
         name='openInventoryBtn ',
         parent=self,
         align=uiconst.TOPRIGHT,
         pos=(1, 1, 21, 21),
         iconSize=16,
         texturePath='res:/UI/Texture/Vgs/Search_icon.png',
         func=self.OnOpenInventoryBtn)
     self.UpdateState()
     self.AnimEntry()
Example #4
0
 def DrawPointer(self, alignToTop):
     pointerWidth = DOCK_POINTER_LENGTH * 2
     pointerSideWidth = int(DOCK_POINTER_LENGTH * 2 / sqrt(2))
     pointerSideWidthHalf = pointerSideWidth / 2
     if alignToTop:
         clipperAlign = uiconst.CENTERTOP
         transformAlign = uiconst.CENTERBOTTOM
     else:
         clipperAlign = uiconst.CENTERBOTTOM
         transformAlign = uiconst.CENTERTOP
     clipperCont = uiprimitives.Container(name='clipper',
                                          parent=self,
                                          width=pointerWidth,
                                          height=DOCK_POINTER_LENGTH,
                                          clipChildren=True,
                                          align=clipperAlign,
                                          top=-DOCK_POINTER_LENGTH)
     transform = uiprimitives.Transform(name='transform',
                                        parent=clipperCont,
                                        align=transformAlign,
                                        rotation=pi / 4,
                                        width=pointerSideWidth,
                                        height=pointerSideWidth,
                                        top=-pointerSideWidthHalf)
     FillUnderlay(bgParent=transform, opacity=OPACITY_BG)
Example #5
0
 def ConstructHiliteFill(self):
     if not self._hiliteFill:
         self._hiliteFill = FillUnderlay(
             bgParent=self,
             colorType=uiconst.COLORTYPE_UIHILIGHT,
             opacity=OPACITY_IDLE,
             padding=(-5, -4, -5, -6))
Example #6
0
 def ExpandMenu(self, *args):
     if self.destroyed:
         return
     if self.IsExpanded():
         self.CloseMenu()
         return
     background = self.AccessBackground()
     icon = self.AccessIcon()
     l, t, w, h = background.GetAbsolute()
     buttonCopy = Container(parent=uicore.layer.utilmenu, align=uiconst.TOPLEFT, pos=(l,
      t,
      self.GetFullWidth(),
      h), state=uiconst.UI_NORMAL, idx=0)
     buttonCopy.OnMouseDown = self.CloseMenu
     if self._label is not None:
         label = EveLabelMedium(parent=buttonCopy, text=self._label.text, align=self._label.align, bold=True, left=self._label.left)
     Sprite(parent=buttonCopy, texturePath=self.closeTexturePath, state=uiconst.UI_DISABLED, align=icon.align, width=icon.width, height=icon.height, left=icon.left)
     topOrBottomLine = LineUnderlay(parent=buttonCopy, align=uiconst.TOTOP, opacity=OPACITY_LINES)
     if self.menuAlign in (uiconst.BOTTOMLEFT, uiconst.BOTTOMRIGHT):
         topOrBottomLine.align = uiconst.TOBOTTOM
     LineUnderlay(parent=buttonCopy, align=uiconst.TOLEFT, opacity=OPACITY_LINES)
     LineUnderlay(parent=buttonCopy, align=uiconst.TORIGHT, opacity=OPACITY_LINES)
     FillUnderlay(bgParent=buttonCopy, opacity=OPACITY_BG)
     menuParent = ExpandedUtilMenu(parent=uicore.layer.utilmenu, controller=self, GetUtilMenu=self._getMenuFunction, minWidth=self.GetFullWidth() + 16, idx=1, menuAlign=self.menuAlign)
     self._menu = weakref.ref(menuParent)
     self._menuButton = weakref.ref(buttonCopy)
     uicore.animations.MorphScalar(buttonCopy, 'opacity', startVal=0.5, endVal=1.0, duration=0.2)
     uthread.new(uicore.registry.SetFocus, menuParent)
Example #7
0
 def CheckConstructSelectedBG(self):
     if self.selectedBG is None:
         self.selectedBG = FillUnderlay(
             bgParent=self.topRightCont,
             colorType=uiconst.COLORTYPE_UIHILIGHT,
             state=uiconst.UI_HIDDEN,
             opacity=OPACITY_SELECTED)
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     self.value = 0.0
     iconPath = attributes.iconPath
     iconSize = attributes.iconSize
     minValue = attributes.minValue
     maxValue = attributes.maxValue
     showBG = attributes.get('showBG', True)
     isCompact = attributes.get('isCompact', False)
     self.jobData = attributes.jobData
     self.gauge = Gauge(parent=self,
                        align=uiconst.TOBOTTOM,
                        state=uiconst.UI_DISABLED,
                        height=6,
                        gaugeHeight=6,
                        padTop=1,
                        backgroundColor=(1.0, 1.0, 1.0, 0.05))
     if isCompact:
         self.icon = None
         self.valueLabel = None
         return
     mainCont = Container(name='mainCont', parent=self)
     if showBG:
         self.bg = StretchSpriteHorizontal(
             bgParent=mainCont,
             texturePath='res:/UI/Texture/Classes/Industry/Center/bgMETE.png'
         )
         FillUnderlay(bgParent=self, opacity=0.5)
     else:
         self.bg = None
     left = 8 if showBG else 2
     self.icon = Sprite(name='icon',
                        parent=mainCont,
                        align=uiconst.TOPLEFT,
                        state=uiconst.UI_DISABLED,
                        pos=(left, 3, self.ICONSIZE, self.ICONSIZE),
                        texturePath=self.ICONPATH,
                        opacity=0.6)
     self.valueLabel = EveLabelMediumBold(parent=mainCont,
                                          align=uiconst.TOPRIGHT,
                                          top=4,
                                          left=left)
     self.removeIcon = Sprite(
         parent=mainCont,
         align=uiconst.CENTERRIGHT,
         state=uiconst.UI_HIDDEN,
         texturePath='res:/ui/texture/icons/73_16_45.png',
         pos=(0, 0, 12, 12),
         color=Color.RED,
         hint=localization.GetByLabel('UI/Industry/PreviewModeHint'))
     self.removeIcon.OnClick = self.OnRemoveIconClick
     self.previewEdit = SinglelineEdit(name='previewEdit',
                                       parent=mainCont,
                                       align=uiconst.CENTERRIGHT,
                                       state=uiconst.UI_HIDDEN,
                                       ints=(0, self.MAXVAL),
                                       OnChange=self.OnPreviewEdit,
                                       pos=(12, 0, 34, 20))
     self.errorFrame = ErrorFrame(bgParent=self, padding=(1, 1, 1, 8))
Example #9
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)
Example #10
0
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     self.jobData = attributes.jobData
     self.skills = []
     self.skillIcon = Sprite(name='skillIcon', parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, pos=(0, -1, 33, 33))
     self.patternSprite = Sprite(name='patternSprite', bgParent=self, texturePath='res:/UI/Texture/classes/Industry/Center/skillFramePattern.png')
     FillUnderlay(bgParent=self, padding=3)
     self.UpdateState()
Example #11
0
    def CreateColumns(self, columns, fixedColumns=None):
        self.headerContainer.Flush()
        self.columnIDs = columns
        self.fixedColumns = fixedColumns
        if columns:
            sizes = self.GetCurrentSizes()
            for columnID in columns:
                header = uiprimitives.Container(parent=self.headerContainer,
                                                align=uiconst.TOLEFT,
                                                state=uiconst.UI_NORMAL)
                header.OnClick = (self.ClickHeader, header)
                header.OnDblClick = (self.DblClickHeader, header)
                header.columnID = columnID
                header.sortTriangle = None
                headerDivider = LineUnderlay(parent=header,
                                             align=uiconst.TORIGHT,
                                             opacity=uiconst.OPACITY_FRAME)
                if columnID not in fixedColumns:
                    scaler = uiprimitives.Container(parent=header,
                                                    align=uiconst.TOPRIGHT,
                                                    width=4,
                                                    height=self.height - 1,
                                                    state=uiconst.UI_NORMAL)
                    scaler.OnMouseDown = (self.StartHeaderScale, header)
                    scaler.OnMouseEnter = (self.OnHeaderMouseEnter, header)
                    scaler.OnMouseExit = (self.OnHeaderMouseExit, header)
                    header.OnMouseEnter = (self.OnHeaderMouseEnter, header)
                    header.OnMouseExit = (self.OnHeaderMouseExit, header)
                    scaler.cursor = 16
                label = uicontrols.EveLabelSmall(
                    parent=header,
                    text=sm.GetService('tactical').GetColumnLabel(
                        columnID, addFormatUnit=True),
                    align=uiconst.CENTERLEFT,
                    left=6,
                    state=uiconst.UI_DISABLED,
                    maxLines=1)
                header.label = label
                if fixedColumns and columnID in fixedColumns:
                    header.width = fixedColumns[columnID]
                    if header.width <= 32:
                        label.Hide()
                elif columnID in sizes:
                    header.width = max(COLUMNMINSIZE, sizes[columnID])
                else:
                    header.width = max(
                        COLUMNMINSIZE,
                        max(COLUMNMINDEFAULTSIZE, label.textwidth + 24))
                header.fill = FillUnderlay(
                    parent=header,
                    colorType=uiconst.COLORTYPE_UIHILIGHT,
                    padLeft=-1,
                    padRight=-1,
                    opacity=0.75)

            self.UpdateActiveState()
    def UpdateIntersectionBackground(self):
        desktop = uicore.uilib.desktopBlurredBg
        if not desktop:
            return
        rects = self.GetWindowIntersectionRects()
        desktop.Flush()
        for x1, y1, x2, y2 in rects:
            cont = Container(parent=desktop,
                             pos=(x1, y1, x2 - x1, y2 - y1),
                             align=uiconst.TOPLEFT,
                             padding=1)
            fill = FillUnderlay(bgParent=cont, opacity=0.5)

        desktop.UpdateAlignmentAsRoot()
 def CreateToolbar(self):
     self.toolbarContainer = Container(parent=self.headerParent,
                                       align=uiconst.CENTERTOP,
                                       width=TOOLBARWIDTH_FULLSCREEN,
                                       height=TOOLBARHEIGHT)
     self.caption = EveLabelMedium(parent=self.toolbarContainer,
                                   align=uiconst.CENTER,
                                   bold=True)
     FillUnderlay(bgParent=self.toolbarContainer,
                  opacity=0.9,
                  padding=(1, 1, 1, 0))
     grid = LayoutGrid(parent=self.toolbarContainer,
                       columns=5,
                       cellPadding=2,
                       align=uiconst.CENTERRIGHT,
                       left=6,
                       opacity=0.6)
     dockViewMode = DockablePanelHeaderButtonMenu(
         parent=grid,
         dockViewModeCallback=self.ChangeViewMode,
         panelID=self.panelID)
     closeButton = DockablePanelHeaderButton(
         parent=grid,
         hint='Close',
         texturePath='res:/UI/Texture/classes/DockPanel/closeButton.png',
         func=self.CloseByUser)
     tOutline = StretchSpriteHorizontalUnderlay(
         texturePath='res:/UI/Texture/classes/MapView/toolbarLine.png',
         colorType=uiconst.COLORTYPE_UIHILIGHT,
         opacity=uiconst.OPACITY_FRAME,
         leftEdgeSize=64,
         rightEdgeSize=64,
         parent=self.toolbarContainer,
         align=uiconst.TOBOTTOM_NOPUSH,
         padding=(-48, 0, -48, -15),
         height=64)
     tFill = StretchSpriteHorizontalUnderlay(
         texturePath='res:/UI/Texture/classes/MapView/toolbarFill.png',
         colorType=uiconst.COLORTYPE_UIBASE,
         leftEdgeSize=64,
         rightEdgeSize=64,
         parent=self.toolbarContainer,
         align=uiconst.TOBOTTOM_NOPUSH,
         padding=(-48, 0, -48, -15),
         height=64)
Example #14
0
 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 = FillUnderlay(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)
Example #15
0
 def ApplyAttributes(self, attributes):
     attributes.align = uiconst.TOPLEFT
     attributes.width = 128
     attributes.height = 128
     ContainerAutoSize.ApplyAttributes(self, attributes)
     if attributes.GetUtilMenu:
         self._getMenuFunction = attributes.GetUtilMenu
     else:
         raise RuntimeError('GetUtilMenu has to be provided in order to use UtilMenu')
     self.controller = attributes.controller
     self.isTopLevelWindow = True
     self.menuAlign = attributes.Get('menuAlign', self.default_menuAlign)
     self.minWidth = attributes.minWidth or 0
     FrameUnderlay(bgParent=self, colorType=uiconst.COLORTYPE_UIHILIGHT, opacity=OPACITY_LINES)
     FillUnderlay(bgParent=self, opacity=OPACITY_BG)
     FrameUnderlay(bgParent=self, frameConst=('ui_105_32_26', 15, 0), padding=(-12, -5, -12, -15))
     uicore.uilib.RegisterForTriuiEvents([uiconst.UI_MOUSEDOWN], self.OnGlobalMouseDown)
     self.ReloadMenu()
     self.AnimFadeIn()
     self.UpdateMenuPosition()
Example #16
0
 def Startup(self, *etc):
     self.sr.expander = GlowSprite(parent=self, pos=(3, 0, 16, 16), name='expander', state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Shared/expanderDown.png', align=uiconst.CENTERLEFT)
     self.sr.expander.OnClick = self.Toggle
     self.sr.icon = uicontrols.Icon(parent=self, pos=(4, 0, 16, 16), name='icon', state=uiconst.UI_DISABLED, icon='ui_22_32_28', align=uiconst.CENTERLEFT, ignoreSize=True)
     self.sr.labelClipper = uiprimitives.Container(parent=self, name='labelClipper', align=uiconst.TOALL, pos=(0,
      0,
      const.defaultPadding,
      0), clipChildren=1)
     self.sr.labelClipper.OnClick = self.OnClick
     self.sr.labelClipper.GetMenu = self.GetMenu
     self.sr.label = uicontrols.EveLabelMedium(text='', parent=self.sr.labelClipper, left=5, state=uiconst.UI_DISABLED, maxLines=1, align=uiconst.CENTERLEFT)
     if self.sr.node.sublevel > 0:
         self.sr.fill = None
     else:
         self.sr.fill = FillUnderlay(parent=self, padding=(1, 0, 1, 1), colorType=uiconst.COLORTYPE_UIHEADER, opacity=0.15)
     mainLinePar = uiprimitives.Container(parent=self, name='mainLinePar', align=uiconst.TOALL, idx=0, pos=(0, 0, 0, 0), state=uiconst.UI_DISABLED)
     bottomLineContainer = uiprimitives.Container(parent=mainLinePar, name='bottomLineContainer', align=uiconst.TOBOTTOM, height=16)
     self.sr.bottomLineLeft = uiprimitives.Container(parent=bottomLineContainer, align=uiconst.TOLEFT)
     uiprimitives.Line(parent=self.sr.bottomLineLeft, align=uiconst.TOBOTTOM, color=uiconst.ENTRY_LINE_COLOR)
     self.sr.bottomLineArrow = uicontrols.Icon(icon='ui_73_16_39', parent=bottomLineContainer, align=uiconst.TOLEFT, state=uiconst.UI_NORMAL, color=uiconst.ENTRY_LINE_COLOR, top=15)
     uiprimitives.Line(parent=uiprimitives.Container(parent=bottomLineContainer), align=uiconst.TOBOTTOM, color=uiconst.ENTRY_LINE_COLOR)
 def IndicateStackable(self, wnd=None):
     if wnd is None:
         if self.sr.snapIndicator:
             self.sr.snapIndicator.Close()
             self.sr.snapIndicator = None
         return
     if not wnd.IsStackable() or not self.IsStackable():
         return
     if self.sr.snapIndicator is None:
         self.sr.snapIndicator = FillUnderlay(
             parent=None,
             colorType=uiconst.COLORTYPE_UIHILIGHTGLOW,
             align=uiconst.TOTOP_NOPUSH,
             height=20,
             padding=(2, 2, 2, 0))
     si = self.sr.snapIndicator
     si.state = uiconst.UI_DISABLED
     if si.parent != wnd:
         uiutil.Transplant(si, wnd, idx=0)
     else:
         uiutil.SetOrder(si, 0)
Example #18
0
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     sm.RegisterNotify(self)
     self.jobData = attributes.jobData
     self.materialData = attributes.materialData
     self.materialData.on_updated.connect(self.OnMaterialUpdated)
     self.materialData.on_errors.connect(self.OnMaterialErrors)
     self.isReady = None
     self.icon = ItemIcon(parent=self, typeID=self.materialData.typeID, align=CENTERTOP, state=UI_DISABLED, pos=(0, 6, 32, 32))
     self.label = Label(parent=self, align=CENTERBOTTOM, top=-1, fontsize=10)
     self.bgGlow = Sprite(name='bgGlow', parent=self, align=TOALL, state=UI_DISABLED, texturePath='res:/UI/Texture/Classes/Industry/Input/bgGlow.png', color=COLOR_READY, opacity=OPACITY_DEFAULT)
     self.bgFrame = Sprite(name='bgFrame', parent=self, align=TOALL, state=UI_DISABLED, texturePath='res:/UI/Texture/Classes/Industry/Input/bgFrame.png', color=COLOR_FRAME)
     FillUnderlay(bgParent=self, opacity=0.5)
     Sprite(name='valueBg', parent=self, align=TOALL, state=UI_DISABLED, texturePath='res:/UI/Texture/Classes/Industry/Input/valueBg.png', color=COLOR_FRAME, opacity=0.1)
     self.gauge = Gauge(parent=self, align=BOTTOMLEFT, state=UI_DISABLED, pos=(0,
      13,
      self.width + 1,
      0), gaugeHeight=3, gradientBrightnessFactor=1.0, backgroundColor=(0, 0, 0, 0))
     self.bgFill = Sprite(name='bgFill', parent=self, align=TOALL, state=UI_DISABLED, texturePath='res:/UI/Texture/Classes/Industry/Input/bg.png', color=COLOR_FRAME, opacity=0.1)
     self.ConstructBackground()
     self.UpdateState()
Example #19
0
 def Prepare_OptionMenu_(self):
     ClearMenuLayer()
     menu = uiprimitives.Container(parent=uicore.layer.menu,
                                   pos=(0, 0, 200, 200),
                                   align=uiconst.RELATIVE)
     menu.sr.scroll = Scroll(parent=menu)
     menu.sr.scroll.OnKillFocus = self.OnScrollFocusLost
     menu.sr.scroll.OnSelectionChange = self.OnScrollSelectionChange
     menu.sr.scroll.Confirm = self.Confirm
     menu.sr.scroll.OnUp = self.OnUp
     menu.sr.scroll.OnDown = self.OnDown
     menu.sr.scroll.OnRight = self.Confirm
     menu.sr.scroll.OnLeft = self.Confirm
     menu.sr.scroll.sr.underlay.opacity = 0.0
     BumpedUnderlay(bgParent=menu,
                    opacity=1.0,
                    isInFocus=True,
                    isWindowActive=True)
     FillUnderlay(bgParent=menu,
                  colorType=uiconst.COLORTYPE_UIBASECONTRAST,
                  opacity=1.0)
     return (menu, menu.sr.scroll)
Example #20
0
 def ConstructLayout(self):
     self.topFill = uiprimitives.Container(parent=self,
                                           name='topFill',
                                           align=uiconst.TOTOP,
                                           height=30)
     BlurredSceneUnderlay(bgParent=self.topFill)
     self.topBG = uiprimitives.Sprite(
         parent=self.topFill,
         align=uiconst.TOALL,
         texturePath='res:/UI/Texture/classes/Neocom/eveButtonBg.png',
         blendMode=trinity.TR2_SBM_ADD)
     self.main = uiprimitives.Container(name='main', parent=self, padTop=3)
     self.bgFill = FillUnderlay(parent=self,
                                align=uiconst.TOTOP,
                                colorType=uiconst.COLORTYPE_UIBASE,
                                opacity=0.8)
     GradientUnderlay(parent=self,
                      align=uiconst.TOALL,
                      colorType=uiconst.COLORTYPE_UIBASE,
                      rgbData=[(0.0, (1.0, 1.0, 1.0))],
                      alphaData=[(0.0, 0.8), (0.4, 0.3), (1.0, 0.1)],
                      rotation=-pi / 2)
     BlurredSceneUnderlay(bgParent=self, isPinned=True, opacity=0.8)
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     sm.RegisterNotify(self)
     self.jobData = attributes.jobData
     self.videoThread = None
     self.iconCont = Container(name='iconCont',
                               parent=self,
                               align=CENTER,
                               state=uiconst.UI_NORMAL,
                               width=64,
                               height=64)
     self.errorFrame = ErrorFrame(parent=self,
                                  align=uiconst.CENTER,
                                  pos=(0, 0, 64, 64),
                                  state=uiconst.UI_HIDDEN)
     self.qtyLabel = EveLabelLargeBold(parent=self, align=CENTER, top=42)
     FrameUnderlay(name='bgVignette',
                   parent=self,
                   texturePath=
                   'res:/UI/Texture/Classes/Industry/Output/bgVignette.png',
                   cornerSize=30)
     self.videoCont = Container(name='videoCont',
                                parent=self,
                                align=uiconst.CENTER,
                                width=324,
                                height=199)
     self.previewContFill = FillUnderlay(parent=self)
     self.previewCont = PreviewContainer(parent=self,
                                         align=uiconst.TOALL,
                                         state=uiconst.UI_HIDDEN)
     self.leftProbabilityGradient = GradientSprite(
         name='leftProbabilityGradient',
         parent=self,
         align=uiconst.CENTERLEFT,
         state=uiconst.UI_HIDDEN,
         pos=(0, 0, 160, 64),
         rgbData=((0, (1.0, 1.0, 1.0)), ),
         alphaData=((0.0, 0.5), (1.0, 0.0)))
     self.rightProbabilityGradient = GradientSprite(
         name='rightProbabilityGradient',
         parent=self,
         align=uiconst.CENTERRIGHT,
         state=uiconst.UI_HIDDEN,
         pos=(0, 0, 160, 64),
         rgbData=((0, (1.0, 1.0, 1.0)), ),
         alphaData=((0.0, 0.0), (1.0, 0.5)))
     self.previewCont.navigation.LoadTooltipPanel = self.LoadIconContTooltipPanel
     self.previewCont.navigation.GetTooltipDelay = self.GetIconContTooltipDelay
     self.previewCont.navigation.GetMenu = self.GetMenu
     self.iconCont.LoadTooltipPanel = self.LoadIconContTooltipPanel
     self.iconCont.GetTooltipDelay = self.GetIconContTooltipDelay
     self.iconCont.OnMouseEnter = self.OnIconContMouseEnter
     self.iconCont.OnMouseExit = self.OnIconContMouseExit
     self.iconCont.OnClick = self.OnIconContClick
     self.iconCont.GetMenu = self.GetMenu
     self.iconCont.GetDragData = self.GetIconContDragData
     self.iconCont.isDragObject = True
     self.techIcon = Sprite(name='techIcon',
                            parent=self.iconCont,
                            width=16,
                            height=16)
     self.icon = Icon(parent=self.iconCont,
                      align=CENTER,
                      state=uiconst.UI_DISABLED)
     self.bgCont = Container(name='bgCont',
                             parent=self,
                             align=uiconst.CENTER,
                             width=201,
                             height=192)
     self.bg = Sprite(
         bgParent=self.bgCont,
         texturePath='res:/UI/Texture/Classes/Industry/Output/itemBg.png')
     self.itemPattern = Sprite(
         bgParent=self.bgCont,
         texturePath=
         'res:/UI/Texture/Classes/Industry/Output/itemBgColor.png')
     self.UpdateState()
     self.AnimEntry()
class Window(WindowCore):
    __guid__ = 'uicontrols.Window'
    default_state = uiconst.UI_HIDDEN
    default_pinned = False
    default_isPinable = True
    default_iconNum = 'res:/UI/Texture/WindowIcons/other.png'
    default_topParentHeight = 52
    default_width = 256
    default_height = 128
    default_scope = None

    def ApplyAttributes(self, attributes):
        self.default_parent = uicore.layer.main
        self._pinned = False
        self._pinable = self.default_isPinable
        self.showforward = False
        self.showback = False
        self.isBlinking = False
        self.iconNum = attributes.get('iconNum', self.GetDefaultWndIcon())
        self.scope = attributes.get('scope', self.default_scope)
        self.topParentHeight = attributes.get('topParentHeight',
                                              self.default_topParentHeight)
        WindowCore.ApplyAttributes(self, attributes)

    def GetMainArea(self):
        return self.sr.main

    def Prepare_(self):
        self.Prepare_Layout()
        self.Prepare_Header_()
        self.Prepare_LoadingIndicator_()
        self.Prepare_Background_()
        self.Prepare_ScaleAreas_()

    def Prepare_Layout(self):
        self.sr.headerParent = uiprimitives.Container(
            parent=self.sr.maincontainer,
            name='headerParent',
            align=uiconst.TOTOP,
            pos=(0, 0, 0, 22))
        self.sr.topParent = uiprimitives.Container(
            parent=self.sr.maincontainer,
            name='topParent',
            align=uiconst.TOTOP,
            clipChildren=True)
        self.sr.mainIcon = GlowSprite(parent=self.sr.topParent,
                                      name='mainicon',
                                      pos=(0, 0, 64, 64),
                                      state=uiconst.UI_HIDDEN)
        self.sr.main = uiprimitives.Container(parent=self.sr.maincontainer,
                                              name='main',
                                              align=uiconst.TOALL)
        self.SetTopparentHeight(self.topParentHeight)

    def Prepare_Header_(self):
        top = uiprimitives.Container(parent=self.sr.headerParent,
                                     name='top',
                                     align=uiconst.TOALL,
                                     padding=(2, 2, 2, 0))
        self.sr.captionParent = uiprimitives.Container(parent=top,
                                                       name='captionParent',
                                                       align=uiconst.TOALL,
                                                       clipChildren=True)
        self.sr.caption = EveLabelSmall(text='',
                                        parent=self.sr.captionParent,
                                        left=8,
                                        state=uiconst.UI_DISABLED,
                                        align=uiconst.CENTERLEFT)
        self.headerFill = FillUnderlay(bgParent=top, opacity=0.5)

    def Prepare_LoadingIndicator_(self):
        WindowCore.Prepare_LoadingIndicator_(self)
        self.sr.loadingIndicator.icons = [
            'ui_38_16_%s' % (210 + i) for i in xrange(8)
        ]

    def Prepare_HeaderButtons_(self):
        self.sr.headerButtons = ContainerAutoSize(
            name='headerButtons',
            state=uiconst.UI_PICKCHILDREN,
            align=uiconst.TOPRIGHT,
            parent=self.sr.maincontainer,
            pos=(4, 4, 0, 16),
            idx=0)
        isStack = isinstance(self, self.GetStackClass())
        if isStack:
            closeHint = localization.GetByLabel(
                'UI/Control/EveWindow/CloseStack')
            minimizeHint = localization.GetByLabel(
                'UI/Control/EveWindow/MinimizeStack')
        else:
            closeHint = localization.GetByLabel('UI/Common/Buttons/Close')
            minimizeHint = localization.GetByLabel(
                'UI/Control/EveWindow/Minimize')
        helpHint = localization.GetByLabel('UI/Control/EveWindow/Help')
        pinFunc = self.TogglePinState
        if self.IsPinned():
            pinhint = localization.GetByLabel('UI/Control/EveWindow/Unpin')
        else:
            pinhint = localization.GetByLabel('UI/Control/EveWindow/Pin')
        if self.IsCompact():
            compactHint = localization.GetByLabel(
                '/Carbon/UI/Controls/Window/DisableCompactMode')
            compactFunc = self.UnCompact
            compactIcon = 'res:/UI/Texture/icons/38_16_258.png'
        else:
            compactHint = localization.GetByLabel(
                '/Carbon/UI/Controls/Window/EnableCompactMode')
            compactFunc = self.Compact
            compactIcon = 'res:/UI/Texture/icons/38_16_259.png'
        for texturePath, name, hint, showflag, clickfunc in [
            ('res:/UI/Texture/icons/38_16_220.png', 'close', closeHint,
             self.IsKillable(), self.CloseByUser),
            ('res:/UI/Texture/icons/38_16_221.png', 'minimize', minimizeHint,
             self.IsMinimizable(), self.Minimize),
            ('res:/UI/Texture/icons/38_16_222.png', 'pin', pinhint,
             self.IsPinable(), pinFunc),
            (compactIcon, 'compact', compactHint, self.IsCompactable(),
             compactFunc)
        ]:
            if not showflag:
                continue
            btn = ButtonIcon(parent=self.sr.headerButtons,
                             align=uiconst.TORIGHT,
                             width=16,
                             texturePath=texturePath,
                             hint=hint,
                             func=clickfunc)

    def Prepare_Background_(self):
        self.sr.underlay = WindowUnderlay(parent=self)
        self.sr.underlay.SetState(uiconst.UI_DISABLED)

    def GetDefaultWndIcon(self):
        return self.default_iconNum

    def GetNeocomGroupIcon(self):
        """ Returns the icon which should be used for this window in the Neocom """
        return self.iconNum

    def GetNeocomGroupLabel(self):
        """ Returns the label which should be used for this window in the Neocom """
        return self.GetCaption()

    def GetNeocomButtonType(self):
        return BTNTYPE_WINDOW

    def SetWndIcon(self,
                   iconNum=None,
                   headerIcon=0,
                   size=64,
                   fullPath=None,
                   mainTop=-3,
                   mainLeft=0,
                   hidden=False,
                   **kw):
        self.iconNum = iconNum or self.GetDefaultWndIcon()
        if hidden:
            return
        icon = self.sr.mainIcon
        if not icon:
            return
        if iconNum is None:
            icon.state = uiconst.UI_HIDDEN
            return
        icon.state = uiconst.UI_DISABLED
        icon.LoadIcon(iconNum or fullPath, ignoreSize=True)
        icon.top = mainTop
        icon.left = mainLeft
        if headerIcon:
            icon.width = icon.height = 16
            icon.left = 4
            icon.top = 0
            uiutil.Transplant(icon, uiutil.GetChild(self, 'captionParent'))
            if self.sr.caption:
                self.sr.caption.left = 24
            self.sr.headerIcon = icon

    def SetTopparentHeight(self, height):
        self.sr.topParent.height = height

    def HideMainIcon(self):
        self.sr.mainIcon.state = uiconst.UI_HIDDEN

    def SetUtilMenu(self, utilMenuFunc):
        if self.sr.tab:
            self.sr.tab.SetUtilMenu(utilMenuFunc)
        else:
            self.sr.caption.left = 20
            from eve.client.script.ui.control.utilMenu import UtilMenu
            utilMenu = UtilMenu(
                menuAlign=uiconst.TOPLEFT,
                parent=self.sr.captionParent,
                align=uiconst.TOPLEFT,
                GetUtilMenu=utilMenuFunc,
                texturePath='res:/UI/Texture/Icons/73_16_50.png',
                pos=(const.defaultPadding, 1, 14, 14))

    def SetHeaderIcon(self,
                      iconNo='ui_73_16_50',
                      shiftLabel=12,
                      hint=None,
                      size=16):
        par = self.sr.captionParent
        if self.sr.headerIcon:
            self.sr.headerIcon.Close()
            self.sr.headerIcon = None
        if iconNo is None:
            if self.sr.caption:
                self.sr.caption.left = 8
        else:
            self.sr.headerIcon = Icon(icon=iconNo,
                                      parent=par,
                                      pos=(4, 0, size, size),
                                      align=uiconst.RELATIVE,
                                      ignoreSize=True)
            self.sr.headerIcon.SetAlpha(0.8)
            self.sr.headerIcon.OnMouseEnter = self.HeaderIconMouseEnter
            self.sr.headerIcon.OnMouseExit = self.HeaderIconMouseExit
            self.sr.headerIcon.expandOnLeft = 1
            if self.sr.caption:
                self.sr.caption.left = 8 + shiftLabel
        self.headerIconNo = iconNo
        self.headerIconHint = hint
        if self.sr.tab:
            self.sr.tab.SetIcon(iconNo, 14, hint)

    def HeaderIconMouseEnter(self, *args):
        self.sr.headerIcon.SetAlpha(1.0)

    def HeaderIconMouseExit(self, *args):
        self.sr.headerIcon.SetAlpha(0.8)

    def TogglePinState(self, *args):
        if self.IsPinned():
            self.Unpin()
        else:
            self.Pin()

    def Pin(self, delegate=1, *args, **kwds):
        self.sr.underlay.Pin()
        if self.headerFill:
            self.headerFill.opacity = 0.2
        self._SetPinned(True)
        if delegate:
            shift = uicore.uilib.Key(uiconst.VK_SHIFT)
            ctrl = uicore.uilib.Key(uiconst.VK_CONTROL)
            if shift or ctrl:
                if shift:
                    alignedWindows = self.FindConnectingWindows()
                else:
                    alignedWindows = self.FindConnectingWindows('bottom')
                for each in alignedWindows:
                    if each == self:
                        continue
                    each.Pin(0)

        self.RefreshHeaderButtonsIfVisible()

    def Unpin(self, delegate=1, *args, **kwds):
        self.sr.underlay.UnPin()
        if self.headerFill:
            self.headerFill.opacity = 0.5
        self._SetPinned(False)
        if delegate:
            shift = uicore.uilib.Key(uiconst.VK_SHIFT)
            ctrl = uicore.uilib.Key(uiconst.VK_CONTROL)
            if shift or ctrl:
                if shift:
                    alignedWindows = self.FindConnectingWindows()
                else:
                    alignedWindows = self.FindConnectingWindows('bottom')
                for each in alignedWindows:
                    if each == self:
                        continue
                    each.Unpin(0)

        self.RefreshHeaderButtonsIfVisible()

    def HideHeaderFill(self):
        self.headerFill.Hide()

    def MakePinable(self):
        self._pinable = True
        self.RefreshHeaderButtonsIfVisible()

    def MakeUnpinable(self):
        self._pinable = False
        self.RefreshHeaderButtonsIfVisible()

    def SetActive(self, *args):
        if self.InStack():
            self.GetStack().SetActive()
        self.sr.underlay.AnimEntry()
        if self.display:
            self.SetNotBlinking()
        self.OnSetActive_(self)
        sm.ScatterEvent('OnWindowSetActive', self)

    def OnSetInactive(self, *args):
        if self.InStack():
            self.GetStack().OnSetInactive()
        self.sr.underlay.AnimExit()
        sm.ScatterEvent('OnWindowSetInctive', self)

    def SetBlinking(self):
        if uicore.registry.GetActive() == self:
            return
        self.isBlinking = True
        sm.ScatterEvent('OnWindowStartBlinking', self)

    def SetNotBlinking(self):
        self.isBlinking = False
        sm.ScatterEvent('OnWindowStopBlinking', self)

    def IsPinned(self):
        return self._pinned

    def IsPinable(self):
        return self._pinable

    def _SetPinned(self, isPinned):
        self._pinned = isPinned
        self.RegisterState('_pinned')

    def IsBlinking(self):
        return self.isBlinking

    def DefineButtons(self,
                      buttons,
                      okLabel=None,
                      okFunc='default',
                      args='self',
                      cancelLabel=None,
                      cancelFunc='default',
                      okModalResult='default',
                      default=None):
        if okLabel is None:
            okLabel = localization.GetByLabel('UI/Common/Buttons/OK')
        if cancelLabel is None:
            cancelLabel = localization.GetByLabel('UI/Common/Buttons/Cancel')
        if getattr(self.sr, 'bottom', None) is None:
            self.sr.bottom = uiutil.FindChild(self, 'bottom')
            if not self.sr.bottom:
                self.sr.bottom = uiprimitives.Container(
                    name='bottom',
                    parent=self.sr.maincontainer,
                    align=uiconst.TOBOTTOM,
                    height=24,
                    idx=0)
        if self.sr.bottom is None:
            return
        self.sr.bottom.Flush()
        if buttons is None:
            self.sr.bottom.state = uiconst.UI_HIDDEN
            return
        self.sr.bottom.height = 24
        if okModalResult == 'default':
            okModalResult = uiconst.ID_OK
        if okFunc == 'default':
            okFunc = self.ConfirmFunction
        if cancelFunc == 'default':
            cancelFunc = self.ButtonResult
        if isinstance(buttons, (types.ListType, types.TupleType)):
            btns = []
            for btn in buttons:
                if btn.id == uiconst.ID_CANCEL:
                    cancelButton = 1
                else:
                    cancelButton = 0
                btns.append([
                    btn.label, self.ButtonResult, None, None, btn.id, 0,
                    cancelButton
                ])

        elif buttons == uiconst.OK:
            btns = [[okLabel, okFunc, args, None, okModalResult, 1, 0]]
        elif buttons == uiconst.OKCANCEL:
            btns = [[okLabel, okFunc, args, None, okModalResult, 1, 0],
                    [
                        cancelLabel, cancelFunc, args, None, uiconst.ID_CANCEL,
                        0, 1
                    ]]
        elif buttons == uiconst.OKCLOSE:
            closeLabel = localization.GetByLabel('UI/Common/Buttons/Close')
            btns = [[okLabel, okFunc, args, None, okModalResult, 1, 0],
                    [
                        closeLabel, self.CloseByUser, args, None,
                        uiconst.ID_CLOSE, 0, 1
                    ]]
        elif buttons == uiconst.YESNO:
            yesLabel = localization.GetByLabel('UI/Common/Buttons/Yes')
            noLabel = localization.GetByLabel('UI/Common/Buttons/No')
            btns = [[
                yesLabel, self.ButtonResult, args, None, uiconst.ID_YES, 1, 0
            ], [noLabel, self.ButtonResult, args, None, uiconst.ID_NO, 0, 0]]
        elif buttons == uiconst.YESNOCANCEL:
            yesLabel = localization.GetByLabel('UI/Common/Buttons/Yes')
            noLabel = localization.GetByLabel('UI/Common/Buttons/No')
            btns = [[
                yesLabel, self.ButtonResult, args, None, uiconst.ID_YES, 1, 0
            ], [noLabel, self.ButtonResult, args, None, uiconst.ID_NO, 0, 0],
                    [
                        cancelLabel, cancelFunc, args, None, uiconst.ID_CANCEL,
                        0, 1
                    ]]
        elif buttons == uiconst.CLOSE:
            closeLabel = localization.GetByLabel('UI/Common/Buttons/Close')
            btns = [[
                closeLabel, self.CloseByUser, args, None, uiconst.ID_CANCEL, 0,
                1
            ]]
        elif type(okLabel) == types.ListType or type(
                okLabel) == types.TupleType:
            btns = []
            for index in xrange(len(okLabel)):
                label = okLabel[index]
                additionalArguments = {
                    'Function': okFunc,
                    'Arguments': args,
                    'Cancel Label': cancelLabel,
                    'Cancel Function': cancelFunc,
                    'Modal Result': okModalResult,
                    'Default': default
                }
                for argName in additionalArguments:
                    if type(additionalArguments[argName]) in (
                            types.ListType, types.TupleType) and len(
                                additionalArguments[argName]) > index:
                        additionalArguments[argName] = additionalArguments[
                            argName][index]

                cancel = additionalArguments[
                    'Modal Result'] == uiconst.ID_CANCEL
                btns.append([
                    label, additionalArguments['Function'],
                    additionalArguments['Arguments'], None,
                    additionalArguments['Modal Result'],
                    additionalArguments['Default'], cancel
                ])

        else:
            btns = [[okLabel, okFunc, args, None, okModalResult, 1, 0]]
        if default is not None:
            for each in btns:
                each[5] = each[4] == default

        buttonGroup = ButtonGroup(btns=btns, parent=self.sr.bottom, unisize=1)
        self.sr.bottom.height = max(24, buttonGroup.height)
        self.sr.bottom.state = uiconst.UI_PICKCHILDREN

    SetButtons = DefineButtons

    def NoSeeThrough(self):
        solidBackground = uiprimitives.Fill(name='solidBackground',
                                            color=(0.0, 0.0, 0.0, 1.0),
                                            padding=(2, 2, 2, 2))
        self.sr.underlay.background.append(solidBackground)
        self.MakeUnpinable()

    def SetScope(self, scope):
        self.scope = scope

    def CloseByUser(self, *args):
        """
        Calling this method to close a window registers the _open attribute as False, so
        the window will not open up automatically on session change.
        """
        if not self.IsKillable():
            return
        WindowCore.CloseByUser(self)

    def SetMainIconSize(self, size=64):
        self.sr.mainIcon.width = self.sr.mainIcon.height = size

    def Collapse(self, forceCollapse=False, checkchain=1, *args):
        if not self._collapseable or not forceCollapse and self.IsCollapsed():
            return
        if self.sr.topParent:
            self.sr.topParent.state = uiconst.UI_HIDDEN
        if self.sr.bottom:
            self.sr.bottom.state = uiconst.UI_HIDDEN
        if self.sr.main:
            self.sr.main.state = uiconst.UI_HIDDEN
        WindowCore.Collapse(self, forceCollapse, checkchain, args)

    def Expand(self, checkchain=1, *args):
        WindowCore.Expand(self, checkchain, args)
        if self.sr.topParent:
            self.sr.topParent.state = uiconst.UI_PICKCHILDREN
        if self.sr.bottom:
            self.sr.bottom.state = uiconst.UI_PICKCHILDREN
        if self.sr.main:
            self.sr.main.state = uiconst.UI_PICKCHILDREN

    def OnResize_(self, *args):
        self.OnResizeUpdate(self)

    def OnResizeUpdate(self, *args):
        pass

    def GetStackClass(self):
        from eve.client.script.ui.control.eveWindowStack import WindowStack
        return WindowStack

    def HideHeaderButtons(self):
        self._hideHeaderButtons = True

    def UnhideHeaderButtons(self):
        self._hideHeaderButtons = False

    def ShowHeaderButtons(self, refresh=False, *args):
        if getattr(self, '_hideHeaderButtons', False):
            return
        if refresh and self.sr.headerButtons:
            self.sr.headerButtons.Close()
            self.sr.headerButtons = None
        if self.sr.stack or self.GetAlign(
        ) != uiconst.RELATIVE or uicore.uilib.leftbtn or getattr(
                self, 'isImplanted', False):
            return
        if not self.sr.headerButtons:
            self.Prepare_HeaderButtons_()
        if self.sr.headerButtons:
            w = self.sr.headerButtons.width
            if self.sr.captionParent:
                self.sr.captionParent.padRight = w + 6
            if self.sr.loadingIndicator:
                self.sr.loadingIndicator.left = w + self.sr.headerButtons.left
            self.sr.headerButtons.Show()
            self.sr.headerButtonsTimer = base.AutoTimer(
                1000, self.CloseHeaderButtons)

    def IndicateStackable(self, wnd=None):
        if wnd is None:
            if self.sr.snapIndicator:
                self.sr.snapIndicator.Close()
                self.sr.snapIndicator = None
            return
        if not wnd.IsStackable() or not self.IsStackable():
            return
        if self.sr.snapIndicator is None:
            self.sr.snapIndicator = FillUnderlay(
                parent=None,
                colorType=uiconst.COLORTYPE_UIHILIGHTGLOW,
                align=uiconst.TOTOP_NOPUSH,
                height=20,
                padding=(2, 2, 2, 0))
        si = self.sr.snapIndicator
        si.state = uiconst.UI_DISABLED
        if si.parent != wnd:
            uiutil.Transplant(si, wnd, idx=0)
        else:
            uiutil.SetOrder(si, 0)

    def GetUtilMenuFunc(self):
        return getattr(self, 'utilMenuFunc', None)

    def InitializeStatesAndPosition(self, *args, **kwds):
        self.startingup = 1
        pinned = self.GetRegisteredState('pinned')
        if pinned:
            self.Pin(delegate=False)
        else:
            self.Unpin(delegate=False)
        WindowCore.InitializeStatesAndPosition(self, *args, **kwds)
        self.startingup = 0

    @classmethod
    def GetSideOffset(cls):
        if uicore.layer.sidePanels:
            return uicore.layer.sidePanels.GetSideOffset()
        return (0, 0)

    def GetRegisteredState(self, stateName):
        if stateName == 'locked':
            if self.GetRegisteredState('pinned') and settings.char.windows.Get(
                    'lockwhenpinned', False):
                return True
        return WindowCore.GetRegisteredState(self, stateName)

    def IsLocked(self):
        return self._locked or self.IsPinned() and settings.char.windows.Get(
            'lockwhenpinned', False)

    def DefineIcons(self, icon, customicon=None, mainTop=-3):
        import types
        if customicon is not None:
            iconNo = customicon
        else:
            mapping = {
                uiconst.INFO: 'res:/ui/Texture/WindowIcons/info.png',
                uiconst.WARNING: 'res:/ui/Texture/WindowIcons/warning.png',
                uiconst.QUESTION: 'res:/ui/Texture/WindowIcons/question.png',
                uiconst.ERROR: 'res:/ui/Texture/WindowIcons/stop.png',
                uiconst.FATAL: 'res:/UI/Texture/WindowICons/criminal.png'
            }
            if type(icon) == types.StringType:
                iconNo = icon
            else:
                iconNo = mapping.get(
                    icon, 'res:/ui/Texture/WindowIcons/warning.png')
        self.SetWndIcon(iconNo, mainTop=mainTop)

    def ConfirmFunction(self, button, *args):
        uicore.registry.Confirm(button)

    def HideBackground(self):
        self.HideUnderlay()
        for each in self.children[:]:
            if each.name.startswith('_lite'):
                each.Close()

    def ShowBackground(self):
        self.ShowUnderlay()
        liteState = self.IsPinned()

    def ShowDialog(self, modal=False, state=uiconst.UI_NORMAL):
        if modal:
            self.NoSeeThrough()
        return WindowCore.ShowDialog(self, modal, state)

    @classmethod
    def GetDefaultLeftOffset(cls, width, align=None, left=0):
        return sm.GetService('window').GetCameraLeftOffset(width, align, left)

    @classmethod
    def ToggleOpenClose(cls, *args, **kwds):
        """ 
            1) If window isn't open, open it
            2) Else, if window isn't fully visible and on top, make it
            3) Else, close the window
        """
        wnd = cls.GetIfOpen(windowID=kwds.get('windowID', None))
        if wnd:
            wasCollapsed = wnd.IsCollapsed()
            if wasCollapsed:
                wnd.Expand()
            if wnd.sr.stack:
                if wnd.sr.stack.GetActiveWindow() != wnd:
                    wnd.Maximize()
                    return wnd
                obscured = wnd.sr.stack.ObscuredByOtherWindows()
            else:
                obscured = wnd.ObscuredByOtherWindows()
            if wnd.IsMinimized():
                wnd.Maximize()
                return wnd
            if obscured:
                uicore.registry.SetFocus(wnd)
                return wnd
            if not wasCollapsed:
                wnd.CloseByUser()
        else:
            return cls.Open(*args, **kwds)

    def ObscuredByOtherWindows(self):
        """
        Finds out if another window overlapps self. Another window overlapps self if its area intersects us and
        it is higher than us in the window stack.
        """
        intersecting = self.GetIntersectingWindows()
        for wnd in intersecting:
            if self not in uicore.layer.main.children:
                return False
            if wnd not in uicore.layer.main.children:
                continue
            if uicore.layer.main.children.index(
                    self) > uicore.layer.main.children.index(wnd):
                return True

        return False

    def _Minimize(self, animate=True):
        if self.destroyed or self.IsMinimized():
            return
        self.OnStartMinimize_(self)
        self._changing = True
        self._SetMinimized(True)
        uicore.registry.CheckMoveActiveState(self)
        if animate:
            x, y = sm.GetService('neocom').GetMinimizeToPos(self)
            x = float(x) / uicore.desktop.width
            y = float(y) / uicore.desktop.height
            t = uiprimitives.Transform(parent=uicore.layer.main,
                                       state=uiconst.UI_DISABLED,
                                       align=uiconst.TOALL,
                                       scalingCenter=(x, y),
                                       idx=0)
            wasCacheContent = self.cacheContents
            self.cacheContents = False
            self.SetParent(t)
            uicore.animations.Tr2DFlipOut(t, duration=0.3)
            uicore.animations.FadeOut(t, duration=0.25, sleep=True)
            self.SetParent(uicore.layer.main)
            self.cacheContents = wasCacheContent
            t.Close()
        self.state = uiconst.UI_HIDDEN
        self.OnEndMinimize_(self)
        self._changing = False
        sm.ScatterEvent('OnWindowMinimized', self)

    @classmethod
    def GetSettingsVersion(cls):
        return 1
Example #23
0
 def ApplyAttributes(self, attributes):
     uiprimitives.Container.ApplyAttributes(self, attributes)
     self.abortbtn = None
     self.abortbtnpar = None
     self.confirmbtn = None
     self.abortconfirmbtnpar = None
     self.sr.progresstext = None
     self.sr.readprogress = util.KeyVal(text='', prev=0)
     self.scope = 'all'
     self.sr.main = uiprimitives.Container(parent=self,
                                           pos=(0, 0, 0, 0),
                                           name='maincontainer',
                                           state=uiconst.UI_PICKCHILDREN,
                                           align=uiconst.TOALL)
     self.sr.wndUnderlay = uicontrols.WindowUnderlay(parent=self,
                                                     transparent=False)
     par = uiprimitives.Container(name='progressParent',
                                  parent=self.sr.main,
                                  align=uiconst.TOBOTTOM,
                                  height=32)
     progress = uiprimitives.Container(parent=par,
                                       pos=(25, 10, self.width - 50, 10),
                                       name='progressbar',
                                       state=uiconst.UI_DISABLED,
                                       align=uiconst.RELATIVE)
     self.sr.glowClipper = uiprimitives.Container(parent=progress,
                                                  pos=(0, 0, 0, 10),
                                                  name='glowclipper',
                                                  state=uiconst.UI_DISABLED,
                                                  clipChildren=True,
                                                  align=uiconst.RELATIVE)
     self.sr.glow = uiprimitives.Container(parent=self.sr.glowClipper,
                                           pos=(0, 0, progress.width, 10),
                                           name='glow',
                                           state=uiconst.UI_DISABLED,
                                           align=uiconst.RELATIVE)
     glowFill = FillUnderlay(parent=self.sr.glow,
                             name='glowFill',
                             state=uiconst.UI_DISABLED,
                             colorType=uiconst.COLORTYPE_UIHILIGHT,
                             align=uiconst.TOALL,
                             opacity=0.4)
     shade = uiprimitives.Container(parent=progress,
                                    pos=(0, 0, 0, 0),
                                    name='shade',
                                    state=uiconst.UI_DISABLED,
                                    align=uiconst.TOALL)
     shadeFill = FillUnderlay(parent=shade,
                              name='shadeFill',
                              state=uiconst.UI_DISABLED,
                              colorType=uiconst.COLORTYPE_UIHILIGHT,
                              align=uiconst.TOALL)
     FrameUnderlay(parent=progress, colorType=uiconst.COLORTYPE_UIHILIGHT)
     self.sr.loading_progress = progress
     self.sr.progresstext = uicontrols.EveLabelMedium(
         text='',
         parent=progress,
         width=270,
         left=2,
         top=4,
         state=uiconst.UI_NORMAL)
     self.state = uiconst.UI_PICKCHILDREN
class RangeSelector(uiprimitives.Container):
    __guid__ = 'uicls.RangeSelector'
    default_state = uiconst.UI_NORMAL

    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 StartMoveHandle(self, handle, btn):
        l, t, w, h = handle.GetAbsolute()
        handle.grab = (uicore.uilib.x - l, uicore.uilib.y - t)

    def StopMoveHandle(self, handle, btn):
        handle.grab = None
        if self._increments and (self._fromProportion == self._toProportion
                                 or self._toProportion == 0
                                 and self._fromProportion == 1.0):
            if handle is self._toHandle:
                for increment, incrementData in self._increments:
                    if increment - self._minRange >= self._toProportion:
                        self._toProportion = increment
                        self.UpdateRanges()
                        self.UpdateHandles()
                        self._DoOnChangeCallback(onEndDrag=True)
                        return

                self._toProportion = self._increments[1][0]
                self.UpdateRanges()
                self.UpdateHandles()
                self._DoOnChangeCallback(onEndDrag=True)
                return
            if handle is self._fromHandle:
                for increment, incrementData in reversed(self._increments):
                    if increment + self._minRange <= self._fromProportion:
                        self._fromProportion = increment
                        self.UpdateRanges()
                        self.UpdateHandles()
                        self._DoOnChangeCallback(onEndDrag=True)
                        return

                self._fromProportion = self._increments[-2][0]
                self.UpdateRanges()
                self.UpdateHandles()
                self._DoOnChangeCallback(onEndDrag=True)
                return
        if self.OnEndDragChange:
            self._DoOnChangeCallback(onEndDrag=True)

    def MoveHandle(self, handle):
        if getattr(handle, 'grab', None):
            x, y = handle.grab
            l, t, w, h = handle.parent.GetAbsolute()
            handle.left = pos = min(w - handle.width,
                                    max(0, uicore.uilib.x - x - l))
            r = w - handle.width
            proportion = pos / float(r)
            incrementData = None
            closest = self.RoundToIncrement(proportion)
            if closest is not None:
                proportion = closest
            if not self._canInvert:
                if handle is self._fromHandle:
                    self._fromProportion = min(proportion, self._toProportion)
                if handle is self._toHandle:
                    self._toProportion = max(proportion, self._fromProportion)
            else:
                if handle is self._fromHandle:
                    self._fromProportion = proportion
                if handle is self._toHandle:
                    self._toProportion = proportion
            self.UpdateRanges()
            self.UpdateHandles()
            self._DoOnChangeCallback()

    def StartMoveRange(self, rangeParent, btn):
        l, t, w, h = rangeParent.GetAbsolute()
        rangeParent.startProportion = ((uicore.uilib.x - l) / float(w),
                                       self._fromProportion,
                                       self._toProportion)

    def StopMoveRange(self, rangeParent, btn):
        rangeParent.startProportion = None
        if self.OnEndDragChange:
            self._DoOnChangeCallback(onEndDrag=True)

    def MoveRange(self, rangeParent):
        if getattr(rangeParent, 'startProportion', None):
            l, t, w, h = rangeParent.GetAbsolute()
            newProportion = (uicore.uilib.x - l) / float(w)
            startProportion, fromProportion, toProportion = rangeParent.startProportion
            diff = newProportion - startProportion
            if fromProportion > toProportion:
                if diff < 0:
                    self._toProportion = max(0.0, toProportion + diff)
                    self._fromProportion = self._toProportion + (
                        fromProportion - toProportion)
                else:
                    self._fromProportion = min(1.0, fromProportion + diff)
                    self._toProportion = self._fromProportion - (
                        fromProportion - toProportion)
            elif diff < 0:
                self._fromProportion = max(0.0, fromProportion + diff)
                self._toProportion = self._fromProportion + (toProportion -
                                                             fromProportion)
            else:
                self._toProportion = min(1.0, toProportion + diff)
                self._fromProportion = self._toProportion - (toProportion -
                                                             fromProportion)
            closest = self.RoundToIncrement(self._fromProportion)
            if closest is not None:
                self._fromProportion = closest
            closest = self.RoundToIncrement(self._toProportion)
            if closest is not None:
                self._toProportion = closest
            self.UpdateRanges()
            self.UpdateHandles()
            self._DoOnChangeCallback()

    def SetMinRange(self, minRange):
        self._minRange = minRange
        self.UpdateRanges()
        self.UpdateHandles()

    def SetFixedRange(self, fixedFromProportion=None, fixedToProportion=None):
        self._fixedFromProportion = fixedFromProportion
        if fixedFromProportion is not None:
            self._fromProportion = fixedFromProportion
            self._fromHandle.display = False
            self._fromRange._pointer.display = False
        else:
            self._fromHandle.display = True
            self._fromRange._pointer.display = True
        self._fixedToProportion = fixedToProportion
        if fixedToProportion is not None:
            self._toProportion = fixedToProportion
            self._toHandle.display = False
            self._toRange._pointer.display = False
        else:
            self._toHandle.display = True
            self._toRange._pointer.display = True
        self.UpdateRanges()
        self.UpdateHandles()

    def SetIncrements(self, increments):
        self._incrementsParent.Flush()
        maxMarkerSize = 0
        labels = []
        self._increments = []
        if increments:
            last = increments.pop(-1)
            stepSize = 1.0 / len(increments)
            c = uicls.GridContainer(parent=self._incrementsParent,
                                    lines=1,
                                    columns=len(increments))
            i = 0
            for incrementData in increments:
                label = incrementData[0]
                markerSize = incrementData[1]
                inc = uiprimitives.Container(parent=c, align=uiconst.TOALL)
                if markerSize:
                    maxMarkerSize = max(maxMarkerSize, markerSize)
                    uiprimitives.Line(parent=inc,
                                      align=uiconst.TOPLEFT,
                                      width=1,
                                      height=markerSize)
                    self._increments.append((i * stepSize, incrementData))
                if label:
                    if label.startswith('res:'):
                        s = uiprimitives.Sprite(parent=inc,
                                                texturePath=label,
                                                width=16,
                                                height=16,
                                                align=uiconst.CENTER,
                                                idx=0,
                                                top=-2,
                                                color=(1, 1, 1, 0.7))
                        labels.append(s)
                    else:
                        l = uicontrols.EveLabelSmall(parent=inc,
                                                     text=label,
                                                     left=-MAINSIDEMARGIN)
                        if i == 0:
                            l.left = max(-MAINSIDEMARGIN, -l.textwidth / 2)
                        else:
                            l.left = -l.textwidth / 2
                        labels.append(l)
                i += 1

            label = last[0]
            markerSize = last[1]
            inc = uiprimitives.Container(parent=self._incrementsParent,
                                         align=uiconst.TORIGHT,
                                         width=1,
                                         idx=0)
            if markerSize:
                maxMarkerSize = max(maxMarkerSize, markerSize)
                uiprimitives.Line(parent=inc,
                                  align=uiconst.TOPLEFT,
                                  width=1,
                                  height=markerSize)
                self._increments.append((i * stepSize, last))
            if label:
                if label.startswith('res:'):
                    s = uiprimitives.Sprite(parent=inc,
                                            texturePath=label,
                                            width=16,
                                            height=16,
                                            align=uiconst.CENTER,
                                            idx=0,
                                            top=-2,
                                            color=(1, 1, 1, 0.7))
                    labels.append(s)
                else:
                    l = uicontrols.EveLabelSmall(parent=inc,
                                                 text=label,
                                                 align=uiconst.TOPRIGHT)
                    l.left = max(-MAINSIDEMARGIN, -l.textwidth / 2)
                    labels.append(l)
        maxHeight = 0
        for l in labels:
            l.top += maxMarkerSize
            maxHeight = max(l.top + l.height, maxHeight)

        self._incrementsParent.height = maxHeight
        self.height = sum([
            each.height + each.padTop + each.padBottom
            for each in self.children if each.align == uiconst.TOTOP
        ])

    def RoundToIncrement(self, proportion, getIncrementData=False):
        closest = None
        closestDiff = None
        closestData = None
        if self._increments:
            for increment, incrementData in self._increments:
                diff = abs(proportion - increment)
                if closestDiff is None or diff < closestDiff:
                    closest = increment
                    closestDiff = diff
                    closestData = incrementData

        if getIncrementData:
            return (closest, closestData)
        return closest

    def UpdateRanges(self):
        if self._fixedFromProportion is not None:
            fromProportion = self._fixedFromProportion
        else:
            fromProportion = self._fromProportion
        if self._fixedToProportion is not None:
            toProportion = self._fixedToProportion
        else:
            toProportion = self._toProportion
        self._fromRange.width = fromProportion
        self._toRange.width = toProportion
        if fromProportion > toProportion:
            self._toRange.parent.SetOrder(0)
            self._toRange._background.SetColorType(uiconst.COLORTYPE_UIHILIGHT)
            self._toRange._pointer.LoadTexture(
                'res:/UI/Texture/classes/RangeSelector/rightPointer.png')
            self._toRange._pointer.top = -7
            self._fromRange._background.SetColorType(
                uiconst.COLORTYPE_UIBASECONTRAST)
            self._fromRange._pointer.LoadTexture(
                'res:/UI/Texture/classes/RangeSelector/leftPointerDown.png')
            self._fromRange._pointer.top = 0
            self._background.SetColorType(uiconst.COLORTYPE_UIHILIGHT)
        else:
            self._fromRange.parent.SetOrder(0)
            self._fromRange._background.SetColorType(
                uiconst.COLORTYPE_UIBASECONTRAST)
            self._fromRange._pointer.LoadTexture(
                'res:/UI/Texture/classes/RangeSelector/leftPointer.png')
            self._fromRange._pointer.top = -7
            self._toRange._background.SetColorType(uiconst.COLORTYPE_UIHILIGHT)
            self._toRange._pointer.LoadTexture(
                'res:/UI/Texture/classes/RangeSelector/rightPointerDown.png')
            self._toRange._pointer.top = 0
            self._background.SetColorType(uiconst.COLORTYPE_UIBASECONTRAST)

    def UpdateHandles(self):
        l, t, w, h = self.GetAbsolute()
        r = w - self._fromHandle.width
        if self._fixedFromProportion is not None:
            fromProportion = self._fixedFromProportion
        else:
            fromProportion = self._fromProportion
        if self._fixedToProportion is not None:
            toProportion = self._fixedToProportion
        else:
            toProportion = self._toProportion
        self._fromHandle.left = int(r * fromProportion)
        self._toHandle.left = int(r * toProportion)

    def _DoOnChangeCallback(self, onEndDrag=False):
        if self._callbackData != (self._fromProportion, self._toProportion):
            if self.OnChange:
                self.OnChange(self._fromProportion, self._toProportion)
            if self.OnIncrementChange:
                fromIncr, fromData = self.RoundToIncrement(
                    self._fromProportion, getIncrementData=True)
                toIncr, toData = self.RoundToIncrement(self._toProportion,
                                                       getIncrementData=True)
                self.OnIncrementChange(self, fromData, toData, fromIncr,
                                       toIncr)
            self._callbackData = (self._fromProportion, self._toProportion)
        if onEndDrag and self.OnEndDragChange:
            fromIncr, fromData = self.RoundToIncrement(self._fromProportion,
                                                       getIncrementData=True)
            toIncr, toData = self.RoundToIncrement(self._toProportion,
                                                   getIncrementData=True)
            self.OnEndDragChange(self, fromData, toData, fromIncr, toIncr)

    def _OnSizeChange_NoBlock(self, *args):
        self.UpdateHandles()
 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)
Example #26
0
 def ConstructLayout(self):
     self.main = uiprimitives.Container(parent=self, align=uiconst.TOALL)
     FillUnderlay(parent=self,
                  colorType=uiconst.COLORTYPE_UIBASE,
                  opacity=0.8)
     BlurredSceneUnderlay(bgParent=self, isPinned=True)
Example #27
0
 def Startup(self, *args):
     super(FittingSlotEntry, self).Startup(*args)
     FillUnderlay(bgParent=self, colorType=uiconst.COLORTYPE_UIHEADER)
Example #28
0
    def ApplyAttributes(self, attributes):
        uiprimitives.Container.ApplyAttributes(self, attributes)
        currentSafetyLevel = attributes.get('safetyLevel')
        self.isTabStop = True
        self.confirmationButton = None
        self.anchor = attributes.get('anchor')
        FillUnderlay(bgParent=self, opacity=OPACITY_BG)
        self.lineTrace = None
        bodyText = '<center>%s</center>' % localization.GetByLabel(
            'UI/Crimewatch/SafetyLevel/SafetyLevelSelectionBody',
            suspectColor=crimewatchConst.Colors.Yellow.GetHex(),
            criminalColor=crimewatchConst.Colors.Red.GetHex())
        captionCont = uiprimitives.Container(parent=self,
                                             align=uiconst.TOTOP,
                                             name='captionCont',
                                             height=24)
        text = uicontrols.EveLabelMediumBold(
            parent=captionCont,
            align=uiconst.CENTERTOP,
            text='<center>%s</center>' % localization.GetByLabel(
                'UI/Crimewatch/SafetyLevel/SafetySettingsCaption'),
            width=self.width - 2 * TEXT_PADDING,
            padTop=TEXT_PADDING,
            color=util.Color.WHITE)
        textCont = uiprimitives.Container(parent=self,
                                          align=uiconst.TOTOP,
                                          name='textCont')
        text = uicontrols.EveLabelSmall(parent=textCont,
                                        align=uiconst.CENTERTOP,
                                        text=bodyText,
                                        width=self.width - 2 * TEXT_PADDING,
                                        padTop=TEXT_PADDING)
        textCont.height = text.textheight + 2 * TEXT_PADDING
        uiprimitives.Container(parent=self,
                               align=uiconst.TOTOP,
                               name='padding',
                               height=TEXT_PADDING)
        self.securityButtons = []
        for safetyLevel in (const.shipSafetyLevelNone,
                            const.shipSafetyLevelPartial,
                            const.shipSafetyLevelFull):
            cont = uiprimitives.Container(parent=self,
                                          name='SecButtonCont',
                                          align=uiconst.TOTOP,
                                          height=44)
            securityButton = SecurityButton(parent=cont,
                                            safetyLevel=safetyLevel,
                                            align=uiconst.CENTERTOP)
            securityButton.SetSelected(safetyLevel == currentSafetyLevel)
            securityButton.OnClick = (self.OnSecurityButtonClick,
                                      securityButton)
            self.securityButtons.append(securityButton)

        height = 0
        for container in self.children:
            if container.GetAlign() == uiconst.TOTOP:
                height += container.height

        self.height = height
        alignToTop = IsShipHudTopAligned()
        self.DrawFrame(alignToTop)
        self.DrawPointer(alignToTop)
        self.SetPosition(alignToTop)
        self.opacity = 0.0
        uicore.animations.FadeIn(self, duration=0.1, loops=1)
        uicore.registry.SetFocus(self)
class OutcomeItemContainer(Container):
    default_state = uiconst.UI_NORMAL
    default_clipChildren = True
    __notifyevents__ = ['OnIndustryViewExpandCollapse']

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        sm.RegisterNotify(self)
        self.jobData = attributes.jobData
        self.videoThread = None
        self.iconCont = Container(name='iconCont',
                                  parent=self,
                                  align=CENTER,
                                  state=uiconst.UI_NORMAL,
                                  width=64,
                                  height=64)
        self.errorFrame = ErrorFrame(parent=self,
                                     align=uiconst.CENTER,
                                     pos=(0, 0, 64, 64),
                                     state=uiconst.UI_HIDDEN)
        self.qtyLabel = EveLabelLargeBold(parent=self, align=CENTER, top=42)
        FrameUnderlay(name='bgVignette',
                      parent=self,
                      texturePath=
                      'res:/UI/Texture/Classes/Industry/Output/bgVignette.png',
                      cornerSize=30)
        self.videoCont = Container(name='videoCont',
                                   parent=self,
                                   align=uiconst.CENTER,
                                   width=324,
                                   height=199)
        self.previewContFill = FillUnderlay(parent=self)
        self.previewCont = PreviewContainer(parent=self,
                                            align=uiconst.TOALL,
                                            state=uiconst.UI_HIDDEN)
        self.leftProbabilityGradient = GradientSprite(
            name='leftProbabilityGradient',
            parent=self,
            align=uiconst.CENTERLEFT,
            state=uiconst.UI_HIDDEN,
            pos=(0, 0, 160, 64),
            rgbData=((0, (1.0, 1.0, 1.0)), ),
            alphaData=((0.0, 0.5), (1.0, 0.0)))
        self.rightProbabilityGradient = GradientSprite(
            name='rightProbabilityGradient',
            parent=self,
            align=uiconst.CENTERRIGHT,
            state=uiconst.UI_HIDDEN,
            pos=(0, 0, 160, 64),
            rgbData=((0, (1.0, 1.0, 1.0)), ),
            alphaData=((0.0, 0.0), (1.0, 0.5)))
        self.previewCont.navigation.LoadTooltipPanel = self.LoadIconContTooltipPanel
        self.previewCont.navigation.GetTooltipDelay = self.GetIconContTooltipDelay
        self.previewCont.navigation.GetMenu = self.GetMenu
        self.iconCont.LoadTooltipPanel = self.LoadIconContTooltipPanel
        self.iconCont.GetTooltipDelay = self.GetIconContTooltipDelay
        self.iconCont.OnMouseEnter = self.OnIconContMouseEnter
        self.iconCont.OnMouseExit = self.OnIconContMouseExit
        self.iconCont.OnClick = self.OnIconContClick
        self.iconCont.GetMenu = self.GetMenu
        self.iconCont.GetDragData = self.GetIconContDragData
        self.iconCont.isDragObject = True
        self.techIcon = Sprite(name='techIcon',
                               parent=self.iconCont,
                               width=16,
                               height=16)
        self.icon = Icon(parent=self.iconCont,
                         align=CENTER,
                         state=uiconst.UI_DISABLED)
        self.bgCont = Container(name='bgCont',
                                parent=self,
                                align=uiconst.CENTER,
                                width=201,
                                height=192)
        self.bg = Sprite(
            bgParent=self.bgCont,
            texturePath='res:/UI/Texture/Classes/Industry/Output/itemBg.png')
        self.itemPattern = Sprite(
            bgParent=self.bgCont,
            texturePath=
            'res:/UI/Texture/Classes/Industry/Output/itemBgColor.png')
        self.UpdateState()
        self.AnimEntry()

    def OnIndustryViewExpandCollapse(self):
        if not self.previewCont:
            return
        isCollapsed = settings.user.ui.Get('industryWndIsViewCollapsed', False)
        if not isCollapsed:
            self.AnimFadeSceneContIn()
        else:
            self.previewCont.Hide()
            self.previewContFill.opacity = 1.0

    def AnimFadeSceneContIn(self):
        self.previewCont.Hide()
        self.previewContFill.opacity = 1.0
        blue.synchro.SleepWallclock(250)
        self.previewCont.Show()
        uicore.animations.FadeTo(self.previewContFill, 1.0, 0.0, duration=0.6)

    def OnNewJobData(self, jobData):
        self.jobData = jobData
        self.UpdateState()
        if self.jobData:
            self.jobData.on_updated.connect(self.UpdateState)
        self.AnimEntry()

    def UpdateState(self, *args):
        if not self.jobData:
            self.previewCont.Hide()
            return
        typeID = self.jobData.GetProductTypeID()
        if IsPreviewable(
                typeID) and self.jobData.activityID == industry.MANUFACTURING:
            self.previewCont.Show()
            self.iconCont.Hide()
            newModel = self.previewCont.PreviewType(typeID)
            if newModel:
                self.previewContFill.Show()
                self.previewContFill.opacity = 1.0
                self.previewCont.AnimEntry(1.5, 0.0, 0.5, -0.3)
                self.previewCont.sceneContainer.scene.sunDirection = (-0.5,
                                                                      -1.0,
                                                                      -1.0)
            self.bg.Hide()
            self.qtyLabel.top = 86
            self.leftProbabilityGradient.Hide()
            self.rightProbabilityGradient.Hide()
        else:
            self.iconCont.Show()
            self.previewCont.Hide()
            self.bg.Show()
            self.qtyLabel.top = 42
            if self.jobData.activityID == industry.RESEARCH_MATERIAL:
                self.icon.LoadIcon(
                    'res:/UI/Texture/Classes/Industry/iconME.png')
                self.icon.width = self.icon.height = 17
                self.techIcon.texturePath = None
            elif self.jobData.activityID == industry.RESEARCH_TIME:
                self.icon.LoadIcon(
                    'res:/UI/Texture/Classes/Industry/iconTE.png')
                self.techIcon.texturePath = None
                self.icon.width = self.icon.height = 16
            else:
                isCopy = self.jobData.activityID in (industry.COPYING,
                                                     industry.INVENTION)
                oldTypeID = self.icon.typeID
                self.icon.LoadIconByTypeID(typeID,
                                           ignoreSize=True,
                                           isCopy=isCopy)
                self.icon.width = self.icon.height = 64
                texturePath, hint = GetTechLevelIconPathAndHint(typeID)
                self.techIcon.texturePath = texturePath
                self.techIcon.hint = hint
                if oldTypeID != typeID:
                    uicore.animations.FadeTo(self.icon, 0.0, 1.0, duration=0.6)
            if self.jobData.activityID == industry.INVENTION:
                width = self.jobData.probability * 160
                color = GetJobColor(self.jobData)
                for gradient in (self.leftProbabilityGradient,
                                 self.rightProbabilityGradient):
                    gradient.Show()
                    gradient.SetRGBA(*color)
                    uicore.animations.MorphScalar(gradient,
                                                  'width',
                                                  gradient.width,
                                                  width,
                                                  duration=0.6)

            else:
                self.leftProbabilityGradient.Hide()
                self.rightProbabilityGradient.Hide()
        if self.jobData and self.jobData.product:
            self.iconCont.opacity = 1.0
            uicore.animations.FadeTo(self.bgCont,
                                     self.bgCont.opacity,
                                     1.0,
                                     duration=0.3)
            self.errorFrame.Hide()
        else:
            self.iconCont.opacity = 0.0
            uicore.animations.FadeTo(self.bgCont,
                                     0.3,
                                     1.0,
                                     duration=2.0,
                                     curveType=uiconst.ANIM_WAVE,
                                     loops=uiconst.ANIM_REPEAT)
            self.errorFrame.Show()
        self.UpdateOutputQty()
        self.StopVideo()
        if self.jobData.status == industry.STATUS_DELIVERED:
            self.PlayVideoDelivered()

    def PlayVideoDelivered(self):
        self.PlayVideo(
            'res:/video/Industry/deliveredIntro.bk2',
            'res:/video/Industry/deliveredOutro.bk2',
            industryUIConst.GetActivityColor(self.jobData.activityID))

    def PlayVideoFailed(self):
        self.PlayVideo('res:/video/Industry/failedIntro.bk2',
                       'res:/video/Industry/failedOutro.bk2',
                       industryUIConst.COLOR_NOTREADY)

    def StopVideo(self):
        if self.videoThread:
            self.videoThread.kill()
            self.videoCont.Flush()

    def PlayVideo(self, introPath, outroPath, color):
        self.videoThread = uthread.new(self._PlayVideo, introPath, outroPath,
                                       color)

    def _PlayVideo(self, introPath, outroPath, color):
        self.videoCont.Flush()
        videoSprite = VideoSprite(parent=self.videoCont,
                                  align=uiconst.TOALL,
                                  spriteEffect=trinity.TR2_SFX_COPY,
                                  videoPath=introPath,
                                  color=color)
        while not videoSprite.isFinished:
            blue.synchro.Yield()

        blue.synchro.SleepWallclock(3000)
        videoSprite.Close()
        videoSprite = VideoSprite(parent=self.videoCont,
                                  align=uiconst.TOALL,
                                  spriteEffect=trinity.TR2_SFX_COPY,
                                  videoPath=outroPath,
                                  color=color)
        while not videoSprite.isFinished:
            blue.synchro.Yield()

        uicore.animations.FadeOut(videoSprite, callback=videoSprite.Close)

    def GetMenu(self):
        abstractInfo = KeyVal(bpData=self.GetBpData())
        return sm.GetService('menu').GetMenuFormItemIDTypeID(
            None,
            self.jobData.product.typeID,
            ignoreMarketDetails=False,
            abstractInfo=abstractInfo)

    def LoadIconContTooltipPanel(self, tooltipPanel, *args):
        if self.jobData.activityID in (industry.RESEARCH_TIME,
                                       industry.RESEARCH_MATERIAL):
            return
        self.tooltipPanel = OutcomeTooltipPanel(jobData=self.jobData,
                                                tooltipPanel=tooltipPanel)

    def GetIconContTooltipDelay(self):
        return TOOLTIP_DELAY_GAMEPLAY

    def GetIconContDragData(self, *args):
        typeID = self.jobData.GetProductTypeID()
        if not typeID:
            return
        if isinstance(self.jobData.product, industry.Blueprint):
            bpData = self.jobData.product.GetCopy()
        else:
            bpData = None
        return [
            KeyVal(__guid__='uicls.GenericDraggableForTypeID',
                   typeID=typeID,
                   label=cfg.invtypes.Get(typeID).name,
                   bpData=bpData)
        ]

    def UpdateOutputQty(self):
        if not self.jobData or not self.jobData.product:
            self.qtyLabel.text = ''
            return
        self.qtyLabel.text = self.jobData.GetProductAmountLabel()

    def AnimEntry(self):
        if not self.jobData:
            return
        uicore.animations.FadeTo(self.itemPattern,
                                 0.0,
                                 1.0,
                                 duration=0.6,
                                 timeOffset=1.35)
        uicore.animations.FadeTo(self.previewContFill,
                                 self.previewContFill.opacity,
                                 0.0,
                                 duration=0.6,
                                 timeOffset=0,
                                 callback=self.previewContFill.Hide)

    def GetBpData(self):
        if not isinstance(self.jobData.product, industry.Blueprint):
            return None
        return self.jobData.product.GetCopy()

    def OnIconContClick(self, *args):
        if not self.jobData:
            return
        if self.jobData.activityID in (industry.RESEARCH_MATERIAL,
                                       industry.RESEARCH_TIME):
            return
        typeID = self.jobData.GetProductTypeID()
        if not typeID:
            return
        sm.GetService('info').ShowInfo(
            typeID, abstractinfo=KeyVal(bpData=self.GetBpData()))
        sm.GetService('audio').SendUIEvent('ind_click')

    def OnIconContMouseEnter(self, *args):
        uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.5, duration=0.15)
        sm.GetService('audio').SendUIEvent('ind_mouseEnter')

    def OnIconContMouseExit(self, *args):
        uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.0, duration=0.3)
 def PrepareUnderlay_(self):
     """ Overwritten by game specific layout """
     self.underlay = FillUnderlay(name='underlay', bgParent=self)