Пример #1
0
 def CreateCurrentShipCont(self):
     self.shipCont.Flush()
     Frame(parent=self.shipCont, color=(1, 1, 1, 0.1))
     activeShip = GetActiveShip()
     clientDogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
     shipDogmaItem = clientDogmaLocation.GetShip()
     shipTypeID = shipDogmaItem.typeID
     icon = Icon(parent=self.shipCont,
                 pos=(0, 0, 40, 40),
                 ignoreSize=True,
                 state=uiconst.UI_DISABLED)
     if self.fittingSvc.IsShipSimulated():
         self.shipCont.OnClick = self.ExitSimulation
         icon.LoadIconByTypeID(shipTypeID)
     else:
         self.shipCont.OnClick = self.LoadCurrentShip
         hologramTexture = inventorycommon.typeHelpers.GetHoloIconPath(
             shipTypeID)
         icon.LoadTexture(hologramTexture)
     shipName = cfg.evelocations.Get(activeShip).name
     text = '%s<br>%s' % (evetypes.GetName(shipTypeID), shipName)
     self.shipnametext = EveLabelMedium(text=text,
                                        parent=self.shipCont,
                                        align=uiconst.TOTOP,
                                        top=2,
                                        padLeft=48)
Пример #2
0
    def LoadTooltipPanel(self, tooltipPanel, *args):
        typeID, reprocessingYield, stationTaxHint, itemYieldHint, stationEfficiency = self.hintInfo
        tooltipPanel.LoadGeneric1ColumnTemplate()
        rowSpan = 1
        if self.itemState:
            rowSpan = 2
        subGrid1 = LayoutGrid()
        icon = Icon(width=64, height=64, align=CENTER)
        icon.LoadIconByTypeID(typeID=self.typeID, ignoreSize=True)
        subGrid1.AddCell(icon, rowSpan=rowSpan)
        yieldText = '<color=%s>%s%%</color>' % (Color.RGBtoHex(*COL_LIGHTBLUE), FmtAmt(reprocessingYield * 100.0, showFraction=1))
        topLabel = EveLabelMedium(text=GetByLabel('UI/Reprocessing/ReprocessingWindow/ItemYieldHint', itemName=cfg.invtypes.Get(self.typeID).name, itemYield=yieldText), width=170, autoFitToText=True, left=6, top=4, bold=True)
        subGrid1.AddCell(topLabel)
        if self.itemState:
            hintText = ''
            hintColor = None
            if self.itemState == STATE_REPROCESS:
                hintText = GetByLabel('UI/Reprocessing/ReprocessingWindow/ReprocessedFurtherHint')
                hintColor = COL_GREEN
            elif self.itemState == STATE_RESTRICTED:
                portionSize = GetPortionSize(typeID)
                if portionSize > self.quantity:
                    noOfItems = FmtAmt(portionSize, showFraction=0)
                    hintText = GetByLabel('UI/Reprocessing/ReprocessingWindow/CannotReprocessHint', noOfItems=noOfItems)
                else:
                    hintText = GetByLabel('UI/Reprocessing/ReprocessingWindow/CannotReprocessNoValueHint')
                hintColor = COL_RED
            elif self.itemState == STATE_SUSPICIOUS:
                hintText = GetByLabel('UI/Reprocessing/ReprocessingWindow/ReprocessingWarningHint')
                hintColor = COL_YELLOW
            stateHint = EveLabelMedium(text=hintText, width=170, autoFitToText=True, left=6, top=4, color=hintColor)
            subGrid1.AddCell(stateHint)
        tooltipPanel.AddCell(subGrid1)
        subGrid = LayoutGrid()
        subGrid.AddCell(cellPadding=6, colSpan=2)
        subGrid.AddCell(EveLabelMedium(text=GetByLabel('UI/Reprocessing/ReprocessingWindow/DetailedYieldHint'), color=COL_BLUE, bold=True), colSpan=2)
        for label in GetReprocessingModifiersAsLabels(typeID, stationEfficiency, stationTaxHint, self.getTypeAttribute, self.getSkillLevel):
            subGrid.AddCell(label)

        if itemYieldHint:
            subGrid.AddCell(cellPadding=6, colSpan=2)
            subGrid.AddCell(EveLabelMedium(text=GetByLabel('UI/Reprocessing/ReprocessingWindow/YouWillReceiveHint'), color=COL_BLUE, bold=True), colSpan=2)
            for typeID, qty in itemYieldHint:
                subGrid.AddCell(EveLabelMedium(text=FmtAmt(qty, showFraction=False), colSpan=1, align=uiconst.TORIGHT, padRight=3, color=COL_LIGHTBLUE, bold=True))
                subGrid.AddCell(EveLabelMedium(text='%s' % GetTypeName(typeID), colSpan=1, padLeft=3))

        tooltipPanel.AddCell(subGrid)
Пример #3
0
 def AddTypeAndIcon(self,
                    label,
                    typeID,
                    moduleShortcut=None,
                    moduleDamageAmount=0,
                    iconSize=26,
                    minRowSize=30):
     self.FillRow()
     self.AddSpacer(height=minRowSize, width=0)
     iconCont = Container(pos=(0, 0, iconSize, iconSize),
                          align=uiconst.CENTER)
     iconObj = Icon(parent=iconCont,
                    pos=(0, 0, iconSize, iconSize),
                    align=uiconst.TOPLEFT,
                    ignoreSize=True)
     iconObj.LoadIconByTypeID(typeID, size=iconSize, ignoreSize=True)
     techIcon = Icon(parent=iconCont,
                     width=16,
                     height=16,
                     align=uiconst.TOPLEFT,
                     idx=0,
                     top=0)
     GetTechLevelIcon(techIcon, typeID=typeID)
     self.AddCell(iconCont, cellPadding=2)
     if moduleShortcut:
         nameColSpan = self.columns - 3
     else:
         nameColSpan = self.columns - 2
     if moduleDamageAmount > 0:
         damagedText = localization.GetByLabel(
             'UI/Inflight/ModuleRacks/ModuleDamaged',
             color='<color=red>',
             percentageNum=moduleDamageAmount)
         label += '<br>' + damagedText
     labelObj = self.AddLabelMedium(text=label,
                                    align=uiconst.CENTERLEFT,
                                    cellPadding=self.labelPadding,
                                    colSpan=nameColSpan)
     if moduleShortcut:
         shortcutObj = ShortcutHint(text=moduleShortcut)
         shortcutObj.width += 10
         shortcutObj.padLeft = 10
         self.AddCell(shortcutObj)
     return (iconObj, labelObj)
Пример #4
0
    def LoadTooltipPanel(self, tooltipPanel, *args):
        tooltipPanel.LoadGeneric1ColumnTemplate()
        subGrid1 = LayoutGrid()
        icon = Icon(width=64, height=64, align=CENTER)
        icon.LoadIconByTypeID(typeID=self.typeID, ignoreSize=True)
        subGrid1.AddCell(cellObject=icon)
        subGrid1.AddCell(EveLabelMedium(text=cfg.invtypes.Get(self.typeID).name, width=170, autoFitToText=True, left=6, top=4, bold=True))
        tooltipPanel.AddCell(subGrid1)
        subGrid = LayoutGrid()
        subGrid.columns = 2
        l1 = EveLabelMedium(text=GetByLabel('UI/Reprocessing/ReprocessingWindow/ReprocessedFrom'), color=COL_BLUE, bold=True)
        subGrid.AddCell(l1, colSpan=2)
        for typeID, quantity in self.typeInfo.iteritems():
            subGrid.AddCell(EveLabelMedium(text=FmtAmt(quantity, showFraction=0), align=uiconst.TORIGHT, padRight=3, color=COL_LIGHTBLUE, bold=True))
            subGrid.AddCell(EveLabelMedium(text=GetByLabel('UI/Reprocessing/ReprocessingWindow/ReprocessedFromType', typeName=GetTypeName(typeID)), padLeft=3))

        subGrid.AddCell(EveLabelMedium(text=FmtAmt(self.stationQty, showFraction=0), colSpan=1, align=uiconst.TORIGHT, padRight=2, color=COL_RED, bold=True))
        subGrid.AddCell(EveLabelMedium(text=GetByLabel('UI/Reprocessing/ReprocessingWindow/OutputTaxHint'), colSpan=1, padLeft=2))
        subGrid.AddCell(EveLabelMedium(text=FmtAmt(self.unrecoverableQty, showFraction=0), colSpan=1, align=uiconst.TORIGHT, padRight=2, color=COL_RED, bold=True))
        subGrid.AddCell(EveLabelMedium(text=GetByLabel('UI/Reprocessing/ReprocessingWindow/NotRecoverableHint'), colSpan=1, padLeft=2))
        subGrid.AddCell(EveLabelMedium(text=FmtAmt(self.quantity, showFraction=0), colSpan=1, align=uiconst.TORIGHT, padRight=2, color=COL_GREEN, bold=True))
        subGrid.AddCell(EveLabelMedium(text=GetByLabel('UI/Reprocessing/ReprocessingWindow/TotalOutputHint'), colSpan=1, padLeft=2))
        tooltipPanel.AddCell(subGrid)
Пример #5
0
class MultiFitWnd(Window):
    __guid__ = 'form.MultiFitWnd'
    __notifyevents__ = ['OnSessionChanged']
    default_topParentHeight = 70
    default_height = 400
    default_width = 320
    default_windowID = 'multiFitWnd'
    default_captionLabelPath = 'UI/Fitting/FittingWindow/FittingManagement/MultiFitHeader'
    layoutColumns = 3

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        self.fitting = None
        self.MakeUnResizeable()
        self.MakeUnstackable()
        self.canFitNum = 0
        self.tryingToFitNum = 1
        self.currentProgress = 0
        self.ConstructUI()
        fitting = attributes.fitting
        self.tryingToFitNum = attributes.get('qty', 1)
        self.LoadWindow(fitting, self.tryingToFitNum)
        self.SetInventoryStatus()
        sm.RegisterNotify(self)

    def ConstructUI(self):
        self.BuildTopParentUI()
        self.AddButtons()
        numColumns = 2
        self.layoutGrid = layoutGrid = LayoutGrid(parent=self.sr.main,
                                                  columns=numColumns,
                                                  cellSpacing=(4, 10))
        spacer = Container(pos=(0, 0, 50, 0), align=uiconst.TOPLEFT)
        layoutGrid.AddCell(cellObject=spacer, colSpan=1)
        layoutGrid.FillRow()
        self.BuildNumToFitUI()
        self.BuildWarningUI()
        self.BuildRefreshInventory()
        self.missingLayoutGrid = LayoutGrid(parent=self.layoutGrid,
                                            columns=2,
                                            cellSpacing=(4, 10))
        self.BuildAvailableShipsUI()
        self.BuildEquipmentUI()
        self.BuildProgressUI()
        self.MakeRigCbUI()

    def BuildTopParentUI(self):
        self.sr.topParent.padding = (2 * const.defaultPadding, 0,
                                     2 * const.defaultPadding, 0)
        self.shipIcon = Icon(name='shipIcon',
                             parent=self.sr.topParent,
                             state=uiconst.UI_NORMAL,
                             size=64,
                             ignoreSize=True)
        self.shipIcon.GetDragData = self.GetFittingDragData
        self.shipIcon.OnClick = self.OpenFitting
        self.shipIcon.hint = GetByLabel('UI/Fitting/ShowFitting')
        self.techSprite = Sprite(name='techIcon',
                                 parent=self.sr.topParent,
                                 align=uiconst.RELATIVE,
                                 width=16,
                                 height=16,
                                 idx=0)
        self.fitNameEdit = SinglelineEdit(
            name='fitNameEdit',
            parent=self.sr.topParent,
            left=72,
            width=150,
            maxLength=20,
            hint=GetByLabel('UI/Common/ShipName'))
        top = self.fitNameEdit.top + self.fitNameEdit.height + 5
        self.shipNameLabel = EveLabelMedium(name='shipNameLabel',
                                            parent=self.sr.topParent,
                                            left=77,
                                            top=top,
                                            state=uiconst.UI_NORMAL)

    def AddButtons(self):
        btnCont = FlowContainer(name='buttonParent',
                                parent=self.sr.main,
                                align=uiconst.TOBOTTOM,
                                padding=6,
                                autoHeight=True,
                                centerContent=True,
                                contentSpacing=uiconst.BUTTONGROUPMARGIN,
                                idx=0)
        text = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/FitShips', numToFit=1)
        self.fitBtn = Button(parent=btnCont,
                             label=text,
                             func=self.DoFitShips,
                             align=uiconst.NOALIGN)
        self.cancelBtn = Button(parent=btnCont,
                                label=GetByLabel('UI/Commands/Cancel'),
                                func=self.Cancel,
                                align=uiconst.NOALIGN)

    def BuildNumToFitUI(self):
        maxShipsAllowed = int(
            sm.GetService('machoNet').GetGlobalConfig().get(
                'bulkFit_maxShips', 30))
        numCont = Container(name='numCont',
                            align=uiconst.TOTOP,
                            height=30,
                            padLeft=LEFT_EDGE)
        text = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/NumShipsToFit')
        self.numToFitLabel = EveLabelLarge(name='numToFitLabel',
                                           parent=numCont,
                                           text=text,
                                           width=250,
                                           autoFitToText=True)
        left = self.numToFitLabel.left + self.numToFitLabel.textwidth + 10
        self.numToFitEdit = SinglelineEdit(name='numToFitEdit',
                                           parent=numCont,
                                           ints=[1, maxShipsAllowed],
                                           OnChange=self.OnNumChanged,
                                           left=left,
                                           align=uiconst.CENTERLEFT)
        numCont.height = max(self.numToFitLabel.textheight,
                             self.numToFitEdit.height)
        self.layoutGrid.AddCell(cellObject=numCont,
                                colSpan=self.layoutGrid.columns)

    def BuildWarningUI(self):
        self.numWarningLabel = EveCaptionSmall(name='numWarningLabel',
                                               state=uiconst.UI_NORMAL,
                                               align=uiconst.CENTERTOP,
                                               width=MAX_TEXT_WIDTH,
                                               autoFitToText=True)
        self.numWarningLabel.SetRGBA(*WARNING_COLOR)
        self.numWarningLabel.LoadTooltipPanel = self.LoadMissingTooltip
        self.layoutGrid.AddCell(cellObject=self.numWarningLabel,
                                colSpan=self.layoutGrid.columns)
        self.layoutGrid.FillRow()

    def BuildRefreshInventory(self):
        self.refreshCont = Transform(parent=self.layoutGrid,
                                     pos=(0, 0, 32, 32),
                                     align=uiconst.CENTER)
        self.refreshIcon = ButtonIcon(name='refreshSprite',
                                      parent=self.refreshCont,
                                      width=32,
                                      height=32,
                                      align=uiconst.CENTER,
                                      texturePath=REFRESH_TEXTUREPATH,
                                      iconSize=32,
                                      func=self.OnRefreshClicked)
        self.refreshIcon.hint = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/RefreshInventoryStatusHint'
        )

    def OnRefreshClicked(self, *args):
        uthread.new(self.refreshCont.StartRotationCycle, cycles=1)
        self.SetInventoryStatus()

    def BuildAvailableShipsUI(self):
        self.shipCounter = EveCaptionMedium(name='shipCounter',
                                            parent=self.missingLayoutGrid,
                                            state=uiconst.UI_NORMAL,
                                            align=uiconst.CENTERRIGHT,
                                            left=4)
        self.shipCounter.LoadTooltipPanel = self.LoadShipCounterTooltipPanel
        self.shipCounter.missingDict = {}
        shipText = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/PackagedShipsInHangar')
        self.availableShipsLabel = EveLabelLarge(name='availableShipsLabel',
                                                 parent=self.missingLayoutGrid,
                                                 state=uiconst.UI_NORMAL,
                                                 text=shipText,
                                                 align=uiconst.CENTERLEFT,
                                                 width=MAX_TEXT_WIDTH,
                                                 autoFitToText=True)
        self.availableShipsLabel.hint = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/PackagedShipsInHangarHint'
        )
        self.layoutGrid.FillRow()

    def BuildEquipmentUI(self):
        self.equipmentCounter = EveCaptionMedium(name='equipmentCounter',
                                                 parent=self.missingLayoutGrid,
                                                 state=uiconst.UI_NORMAL,
                                                 align=uiconst.CENTERRIGHT,
                                                 left=4)
        self.equipmentCounter.LoadTooltipPanel = self.LoadEqCounterTooltipPanel
        self.equipmentCounter.missingDict = {}
        eqText = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/RoundsOfFittingsInHangar'
        )
        self.availableEquipmentLabel = EveLabelLarge(
            name='availableEquipmentLabel',
            parent=self.missingLayoutGrid,
            state=uiconst.UI_NORMAL,
            text=eqText,
            align=uiconst.CENTERLEFT,
            width=MAX_TEXT_WIDTH,
            autoFitToText=True)
        self.layoutGrid.FillRow()

    def BuildProgressUI(self):
        self.progressCont = Container(parent=self.sr.main,
                                      height=36,
                                      align=uiconst.TOBOTTOM,
                                      padding=(10, 0, 10, 10))
        self.progressCounter = EveCaptionMedium(name='progressCounter',
                                                parent=self.progressCont,
                                                state=uiconst.UI_NORMAL,
                                                align=uiconst.CENTERTOP)
        self.progressBar = ProgressBar(parent=self.progressCont,
                                       height=10,
                                       align=uiconst.TOBOTTOM)
        self.progressCont.display = False

    def MakeRigCbUI(self):
        checked = settings.user.ui.Get('fitting_rigCB', True)
        text = GetByLabel('UI/Fitting/FittingWindow/FittingManagement/FitRigs')
        self.rigCB = Checkbox(name='rigCB',
                              text=text,
                              OnChange=self.OnCbChanged,
                              left=LEFT_EDGE,
                              checked=checked,
                              prefstype=('user', 'ui'),
                              configName='fitting_rigCB')
        self.rigCB.hint = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/FitRigsHint')
        self.layoutGrid.AddCell(cellObject=self.rigCB,
                                colSpan=self.layoutGrid.columns)

    def OnNumChanged(self, *args):
        self.onNumChangedTimer = AutoTimer(100, self.SetInventoryStatus)

    def OnCbChanged(self, *args):
        self.SetInventoryStatus()

    def OpenFitting(self, *args):
        sm.GetService('fittingSvc').DisplayFitting(self.fitting)

    def LoadWindow(self, fitting, qty=1):
        self.fitting = fitting
        self.shipCounter.missingDict = {}
        self.equipmentCounter.missingDict = {}
        shipTypeID = fitting.shipTypeID
        self.shipIcon.LoadIconByTypeID(shipTypeID)
        uix.GetTechLevelIcon(self.techSprite, typeID=shipTypeID)
        self.numToFitEdit.text = qty
        self.fitNameEdit.SetValue(fitting.name)
        self.shipNameLabel.text = GetShowInfoLink(shipTypeID,
                                                  evetypes.GetName(shipTypeID))
        self.SetInventoryStatus()
        self.missingLayoutGrid.RefreshGridLayout()
        self.layoutGrid.RefreshGridLayout()
        layoutWidth, layoutHeight = self.layoutGrid.GetSize()
        newHeight = layoutHeight + self.fitBtn.height + self.progressCont.height + self.sr.topParent.height + 20
        self.height = max(newHeight, self.default_height)
        self.width = max(layoutWidth + 20, self.default_width)

    def SetInventoryStatus(self):
        self.onNumChangedTimer = None
        fitting = self.fitting
        shipTypeID = fitting.shipTypeID
        fittingSvc = sm.GetService('fittingSvc')
        chargesByType, dronesByType, fightersByTypeID, iceByType, itemTypes, modulesByFlag, rigsToFit, subsystems = fittingSvc.GetTypesToFit(
            fitting, None)
        if rigsToFit:
            self.rigCB.display = True
        else:
            self.rigCB.display = False
        numToFit = self.numToFitEdit.GetValue()
        self.tryingToFitNum = numToFit
        maxAvailableFitting, missingForFullFit = self._GetMaxAvailabeAndMissingForFullFit(
            itemTypes, modulesByFlag, numToFit)
        nonSingletonShipsNumDict = fittingSvc.GetQt0yInHangarByTypeIDs(
            [shipTypeID], onlyGetNonSingletons=True)
        packagedShipsNum = nonSingletonShipsNumDict.get(shipTypeID, 0)
        self.canFitNum = min(packagedShipsNum, maxAvailableFitting, numToFit)
        btnText = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/FitShips',
            numToFit=self.canFitNum)
        self.fitBtn.SetLabel(btnText)
        if self.canFitNum < 1:
            self.fitBtn.Disable()
        else:
            self.fitBtn.Enable()
        missingNumShips = max(0, numToFit - packagedShipsNum)
        if missingNumShips:
            missingDict = {shipTypeID: missingNumShips}
        else:
            missingDict = {}
        self.shipCounter.missingDict = missingDict
        if missingForFullFit:
            missingDict = missingForFullFit
        else:
            missingDict = {}
        self.equipmentCounter.missingDict = missingDict
        if missingForFullFit or missingNumShips:
            missingText = GetByLabel(
                'UI/Fitting/FittingWindow/FittingManagement/MissingShipEquipment'
            )
            self.numWarningLabel.text = missingText
        else:
            self.numWarningLabel.text = ''
            self.numWarningLabel.height = 0
        self.SetAvailabilityShipOrEq(self.shipCounter, packagedShipsNum,
                                     numToFit)
        self.SetAvailabilityShipOrEq(self.equipmentCounter,
                                     maxAvailableFitting, numToFit)

    def _GetMaxAvailabeAndMissingForFullFit(self, itemTypes, modulesByFlag,
                                            numToFit):
        fittingSvc = sm.GetService('fittingSvc')
        qtyByTypeID = fittingSvc.GetQt0yInHangarByTypeIDs(itemTypes)
        rigTypeIDs = {
            t
            for f, t in modulesByFlag.iteritems() if f in const.rigSlotFlags
        }
        maxAvailableFitting, missingForFullFit = fittingSvc.GetMaxAvailabeAndMissingForFullFit(
            True, itemTypes, numToFit, qtyByTypeID, rigTypeIDs)
        return (maxAvailableFitting, missingForFullFit)

    def SetAvailabilityShipOrEq(self, label, available, numToFit):
        label.text = available
        if available < numToFit:
            label.SetRGB(*WARNING_COLOR)
        else:
            label.SetRGB(*NORMAL_COLOR)

    def DoFitShips(self, *args):
        fitting = self.fitting
        fitRigs = self.rigCB.GetValue()
        toActuallyFit = self.canFitNum
        fittingName = self.fitNameEdit.GetValue()
        fittingSvc = sm.GetService('fittingSvc')
        chargesByType, dronesByType, fightersByTypeID, iceByType, itemTypes, modulesByFlag, rigsToFit, subsystems = fittingSvc.GetTypesToFit(
            fitting, None)
        if fitRigs or not rigsToFit:
            cargoItemsByType = {}
        else:
            cargoItemsByType = defaultdict(int)
            for flagID, typeID in modulesByFlag.iteritems():
                if flagID in const.rigSlotFlags:
                    cargoItemsByType[typeID] += 1

            cargoItemsByType = dict(cargoItemsByType)
        lobby = GetLobbyClass().GetIfOpen()
        if lobby is None:
            return
        lobby.CheckCanAccessService('fitting')
        maxAvailableFitting, missingForFullFit = self._GetMaxAvailabeAndMissingForFullFit(
            itemTypes, modulesByFlag, toActuallyFit)
        if missingForFullFit:
            self.SetInventoryStatus()
            eve.Message('uiwarning03')
            return
        try:
            self.PrepareForMultiFitCall()
            fittingSvc.DoFitManyShips(chargesByType, dronesByType,
                                      fightersByTypeID, fitRigs, fitting,
                                      iceByType, cargoItemsByType,
                                      toActuallyFit, modulesByFlag,
                                      fittingName)
        finally:
            uthread.new(self.ResetUIAfterFitting)

    def PrepareForMultiFitCall(self):
        self.fitBtn.Disable()
        self.cancelBtn.Disable()
        self.currentProgress = 0
        self.progressCounter.text = self.currentProgress
        self.progressCont.display = True
        self.layoutGrid.Disable()
        self.layoutGrid.opacity = 0.2
        sm.RegisterForNotifyEvent(self, 'OnItemChange')

    def ResetUIAfterFitting(self):
        sm.UnregisterForNotifyEvent(self, 'OnItemChange')
        self.currentProgress = 0
        uicore.animations.BlinkOut(self.progressCont,
                                   startVal=0.0,
                                   endVal=1.0,
                                   duration=0.5,
                                   loops=3,
                                   sleep=True)
        self.progressCont.display = False
        self.progressCounter.text = self.currentProgress
        self.cancelBtn.Enable()
        self.layoutGrid.Enable()
        self.layoutGrid.opacity = 1.0
        self.SetInventoryStatus()

    def Cancel(self, *args):
        self.CloseByUser()

    def GetFittingDragData(self):
        entry = KeyVal()
        entry.fitting = self.fitting
        entry.label = self.fitting.name
        entry.displayText = self.fitting.name
        entry.__guid__ = 'listentry.FittingEntry'
        return [entry]

    def LoadMissingTooltip(self, tooltipPanel, *args):
        text = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/MissingItems',
            numToFit=self.tryingToFitNum,
            fittingName=self.fitting.name)
        tooltipPanel.AddLabelLarge(text=text, padBottom=8)
        self.LoadShipCounterTooltipPanel(tooltipPanel,
                                         singleGroupShowing=False)
        self.LoadEqCounterTooltipPanel(tooltipPanel, singleGroupShowing=False)
        missingDict = {}
        missingDict.update(self.shipCounter.missingDict)
        missingDict.update(self.equipmentCounter.missingDict)
        self.AddBuyAllBtn(tooltipPanel, missingDict)

    def LoadShipCounterTooltipPanel(self, tooltipPanel, *args, **kwargs):
        missingDict = self.shipCounter.missingDict
        if not missingDict:
            return
        singleGroupShowing = kwargs.get('singleGroupShowing', True)
        text = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/MissingShips',
            numToFit=self.tryingToFitNum,
            fittingName=self.fitting.name)
        return self.LoadCounterTooltip(tooltipPanel, missingDict, text,
                                       singleGroupShowing)

    def LoadEqCounterTooltipPanel(self, tooltipPanel, *args, **kwargs):
        missingDict = self.equipmentCounter.missingDict
        if not missingDict:
            return
        singleGroupShowing = kwargs.get('singleGroupShowing', True)
        text = GetByLabel(
            'UI/Fitting/FittingWindow/FittingManagement/MissingEquipment',
            numToFit=self.tryingToFitNum,
            fittingName=self.fitting.name)
        self.LoadCounterTooltip(tooltipPanel, missingDict, text,
                                singleGroupShowing)

    def LoadCounterTooltip(self,
                           tooltipPanel,
                           missingDict,
                           text,
                           singleGroupShowing=True):
        tooltipPanel.LoadGeneric1ColumnTemplate()
        tooltipPanel.state = uiconst.UI_NORMAL
        if singleGroupShowing:
            tooltipPanel.AddLabelLarge(text=text, padBottom=8)
        typeList = []
        for eachTypeID, eachQty in missingDict.iteritems():
            typeName = evetypes.GetName(eachTypeID)
            typeList.append((typeName.lower(), (eachTypeID, eachQty)))

        typeList = SortListOfTuples(typeList)
        for eachTypeID, eachQty in typeList[:MAX_TOOLTIP_ENTRIES]:
            typeCont = TooltipEntry(parent=tooltipPanel,
                                    typeID=eachTypeID,
                                    qty=eachQty)

        if len(typeList) > MAX_TOOLTIP_ENTRIES:
            numItemsNotDisplayed = len(typeList) - MAX_TOOLTIP_ENTRIES
            text = GetByLabel(
                'UI/Fitting/FittingWindow/FittingManagement/MoreItemTypesMissing',
                numMoreItems=numItemsNotDisplayed)
            tooltipPanel.AddLabelMedium(text=text, align=uiconst.CENTERLEFT)
        if singleGroupShowing:
            self.AddBuyAllBtn(tooltipPanel, missingDict)

    def AddBuyAllBtn(self, tooltipPanel, missingDict):
        def BuyAll(*args):
            BuyMultipleTypesWithQty(missingDict)

        Button(parent=tooltipPanel,
               label=GetByLabel('UI/Market/MarketQuote/BuyAll'),
               func=BuyAll,
               align=uiconst.CENTER)
        if session.role & ROLE_GMH == ROLE_GMH:
            Button(parent=tooltipPanel,
                   label='GM: Give all',
                   func=self.GiveAllGM,
                   align=uiconst.CENTERRIGHT,
                   args=(missingDict, ))

    def GiveAllGM(self, missingDict):
        numToCountTo = len(missingDict) + 1
        header = 'GM Item Gift'
        sm.GetService('loading').ProgressWnd(header, '', 1, numToCountTo)
        counter = 1
        for typeID, qty in missingDict.iteritems():
            counter += 1
            sm.GetService('loading').ProgressWnd(header, '', counter,
                                                 numToCountTo)
            sm.RemoteSvc('slash').SlashCmd('/create %s %s' % (typeID, qty))

        sm.GetService('loading').ProgressWnd('Done', '', numToCountTo,
                                             numToCountTo)

    def OnItemChange(self, item, change):
        if item.typeID != self.fitting.shipTypeID:
            return
        if const.ixSingleton in change:
            self.currentProgress += 1
            self.progressCounter.text = '%s / %s' % (self.currentProgress,
                                                     self.canFitNum)

    def OnSessionChanged(self, isRemote, sess, change):
        if not IsDocked():
            self.CloseByUser()
Пример #6
0
class FacilityContainer(BaseFramedContainer):
    default_name = 'facilityContainer'

    def ApplyAttributes(self, attributes):
        BaseFramedContainer.ApplyAttributes(self, attributes)
        self.labelCont = Container(parent=self.contentCont, align=uiconst.CENTERLEFT, left=8, width=237, height=38)
        IndustryCaptionLabel(parent=self.labelCont, align=uiconst.TOTOP, text=localization.GetByLabel('UI/Industry/Facility'))
        self.label = Label(parent=self.labelCont, align=uiconst.TOTOP, fontsize=10)
        self.icon = Icon(name='installationIcon', parent=self.contentCont, align=CENTERRIGHT, state=UI_DISABLED, pos=(1, 0, 43, 42))
        self.removeIcon = Sprite(parent=self.contentCont, align=uiconst.TOPRIGHT, state=uiconst.UI_DISABLED, texturePath='res:/ui/texture/icons/73_16_45.png', pos=(46, 2, 12, 12), color=Color.RED, opacity=0.0)

    @telemetry.ZONE_METHOD
    def UpdateState(self):
        if self.jobData:
            if self.jobData.facilityID:
                self.icon.Show()
                self.icon.LoadIconByTypeID(typeID=self.jobData.GetFacilityType(), ignoreSize=True)
                self.label.text = self.jobData.GetFacilityName()
                if self.IsFacilityChanged():
                    uicore.animations.FadeTo(self.labelCont, 0.0, 1.0, duration=0.6)
            else:
                self.icon.Hide()
                self.label.text = localization.GetByLabel('UI/Industry/NoneSelected')
            if self.IsInPreviewMode():
                self.errorFrame.Show()
            else:
                self.errorFrame.Hide()

    def GetMenu(self):
        if self.jobData.facility:
            return sm.GetService('menu').GetMenuFormItemIDTypeID(self.jobData.facility.facilityID, self.jobData.facility.typeID)

    def OnMouseEnter(self):
        BaseFramedContainer.OnMouseEnter(self)
        if self.IsInPreviewMode():
            uicore.animations.FadeIn(self.removeIcon, duration=0.3)

    def OnMouseExit(self):
        BaseFramedContainer.OnMouseExit(self)
        uicore.animations.FadeOut(self.removeIcon, duration=0.3)

    def OnClick(self, *args):
        if not self.jobData:
            return
        if self.IsInPreviewMode():
            facilityID = self.jobData.blueprint.facilityID
            if facilityID:
                self.jobData.facility = sm.GetService('facilitySvc').GetFacility(facilityID)
            else:
                self.jobData.facility = None
            uicore.animations.FadeOut(self.removeIcon, duration=0.1)
        elif self.jobData.facility:
            sm.GetService('info').ShowInfo(self.jobData.facility.typeID, self.jobData.facility.facilityID)
            sm.GetService('audio').SendUIEvent('ind_click')

    def IsInPreviewMode(self):
        if not self.jobData:
            return False
        if self.jobData.facility is None:
            return False
        return self.jobData.blueprint.facilityID != self.jobData.facility.facilityID

    def GetHint(self):
        if self.IsInPreviewMode():
            return localization.GetByLabel('UI/Industry/PreviewModeHint')

    def IsFacilityChanged(self):
        if not self.oldJobData:
            return False
        if not self.jobData.facility or not self.oldJobData.facility:
            return False
        return self.jobData.facility.facilityID != self.oldJobData.facility.facilityID
Пример #7
0
 def _construct_reward_icon(self, reward_id, reward, reward_icon_container):
     reward_icon = Icon(name='reward_%d_icon' % reward_id, parent=reward_icon_container, align=uiconst.TOALL, padding=defaultPadding)
     reward_icon.LoadIconByTypeID(reward['reward_type_id'])
Пример #8
0
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)
        FrameThemeColored(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 = FillThemeColored(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 or self.jobData and self.jobData.activityID != industry.MANUFACTURING:
            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)
Пример #9
0
class ReprocessingItemContainer(Container):
    """
    This class draws a reprocessing item
    """
    default_width = 64
    default_height = 64
    default_align = uiconst.TOALL
    default_state = uiconst.UI_NORMAL

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.isSelected = False
        self.typeID = attributes.typeID
        self.invType = cfg.invtypes.Get(self.typeID)
        typeName = self.invType.name
        self.quantity = attributes.quantity
        self.stacksize = attributes.get('stacksize', None)
        self.itemState = attributes.get('itemState', None)
        singleton = attributes.get('singleton', 0)
        isBlueprint = cfg.invtypes.Get(self.typeID).categoryID == const.categoryBlueprint
        isCopy = isBlueprint and singleton == const.singletonBlueprintCopy
        self.stateIcon = None
        self.spriteCont = self.spriteCont = Container(name='spriteCont', parent=self, align=CENTER, width=ICON_SIZE, height=ICON_SIZE, state=uiconst.UI_PICKCHILDREN)
        self.icon = Icon(name=typeName, parent=self.spriteCont, width=ICON_SIZE, height=ICON_SIZE, align=CENTER, state=uiconst.UI_DISABLED, saturation=1.0, effectOpacity=0.0, spriteEffect=trinity.TR2_SFX_SOFTLIGHT)
        self.icon.LoadIconByTypeID(typeID=self.typeID, ignoreSize=True, isCopy=isCopy)
        self.hint = typeName
        self.techIcon = Sprite(name='techIcon', parent=self.spriteCont, width=16, height=16, idx=0, saturation=1.0, effectOpacity=0.0, spriteEffect=trinity.TR2_SFX_SOFTLIGHT)
        uix.GetTechLevelIcon(self.techIcon, 0, self.typeID)
        if self.itemState:
            resPath, stateColor = self.GetStateResPathAndColor(self.itemState)
            self.stateIcon = Sprite(name='stateIcon', parent=self.spriteCont, width=32, height=32, idx=0, left=-4, top=-4, align=uiconst.TOPRIGHT, texturePath=resPath, color=stateColor, state=uiconst.UI_DISABLED)
        self.entryHilite = Sprite(name='hilite', align=uiconst.TOALL, parent=self.spriteCont, texturePath='res:/UI/Texture/classes/InvItem/bgHover.png', blendMode=trinity.TR2_SBM_ADD, opacity=0.0, idx=0, state=uiconst.UI_DISABLED)
        self.entryHilite.hint = typeName
        self.quantityParent = Container(parent=self, idx=0, name='qtyCont', pos=(3, 38, 32, 11), align=uiconst.TOPRIGHT, bgColor=(0, 0, 0, 0.95), state=uiconst.UI_HIDDEN)
        self.qtyLabel = Label(parent=self.quantityParent, left=2, maxLines=1, fontsize=9)
        self._SetQtyText()

    def _SetQtyText(self):
        if self.stacksize:
            numberOfItems = self.stacksize
        else:
            numberOfItems = self.quantity
        self.qtyLabel.text = FmtAmt(numberOfItems, 'ss')
        if numberOfItems:
            self.quantityParent.state = uiconst.UI_DISABLED
        else:
            self.quantityParent.state = uiconst.UI_HIDDEN

    def GetStateResPathAndColor(self, state):
        if state == STATE_REPROCESS:
            resPath = 'res:/UI/Texture/Reprocessing/Reprocess.png'
            stateColor = COL_GREEN
        elif state == STATE_RESTRICTED:
            resPath = 'res:/UI/Texture/Reprocessing/Restricted.png'
            stateColor = COL_RED
        elif state == STATE_SUSPICIOUS:
            resPath = 'res:/UI/Texture/Reprocessing/Suspicious.png'
            stateColor = COL_YELLOW
        return (resPath, stateColor)

    def BlinkHilite(self):
        uicore.animations.FadeIn(self.entryHilite, duration=0.5)

    def ShowHilited(self):
        uicore.animations.FadeIn(self.entryHilite, duration=0.2)

    def ShowNotHilited(self):
        uicore.animations.FadeOut(self.entryHilite, duration=0.2)
Пример #10
0
class FittingServiceSlot(FittingSlotBase):
    SLOT_SIZE = 48
    default_align = uiconst.BOTTOMLEFT
    default_height = SLOT_SIZE
    default_width = SLOT_SIZE
    isDragObject = True
    underlayTexturePath = 'res:/UI/Texture/classes/Fitting/stationServiceSlotFrame.png'

    def ApplyAttributes(self, attributes):
        FittingSlotBase.ApplyAttributes(self, attributes)
        self.sr.underlay = Sprite(bgParent=self,
                                  name='underlay',
                                  state=uiconst.UI_DISABLED,
                                  padding=(0, 0, 0, 0),
                                  texturePath=self.underlayTexturePath)
        self.flagIcon = Icon(parent=self,
                             name='flagIcon',
                             align=uiconst.CENTER,
                             state=uiconst.UI_DISABLED,
                             width=self.width,
                             height=self.height)
        self.UpdateFitting()

    def UpdateFitting(self):
        if not self.controller.SlotExists() and not self.controller.GetModule(
        ):
            self.DisableSlot()
            return
        self.EnableSlot()
        self.SetDragState()
        self.PrepareUtilButtons()
        iconSize = int(self.SLOT_SIZE * GetScaleFactor())
        self.flagIcon.SetSize(iconSize, iconSize)
        if self.controller.GetModule():
            self.flagIcon.LoadIconByTypeID(self.controller.GetModule().typeID,
                                           ignoreSize=True)
        else:
            slotIcon = 'res:/UI/Texture/classes/Fitting/stationServiceSlot.png'
            self.flagIcon.LoadIcon(slotIcon, ignoreSize=True)
        if self.controller.GetModule():
            self.tooltipPanelClassInfo = TooltipModuleWrapper()
            modulehint = evetypes.GetName(self.controller.GetModuleTypeID())
            if not self.controller.SlotExists():
                modulehint = GetByLabel('UI/Fitting/SlotDoesNotExist')
            self.hint = modulehint
        else:
            self.tooltipPanelClassInfo = None
            self.hint = self._emptyHint
        self.Hilite(0)
        self.UpdateOnlineDisplay()

    def OnDropData(self, dragObj, nodes):
        if self.controller.GetModule(
        ) is not None and not self.controller.SlotExists():
            return
        items = self.GetDroppedItems(nodes)
        for item in items:
            if not getattr(item, 'typeID', None):
                return
            uthread.new(self.AddItem, item)

    def AddItem(self, item, sourceLocation=None):
        if not getattr(item, 'typeID', None):
            return
        validFitting = False
        for effect in cfg.dgmtypeeffects.get(item.typeID, []):
            if effect.effectID in (const.effectServiceSlot, ):
                validFitting = True
                if effect.effectID == self.controller.GetPowerType():
                    self.controller.FitModule(item)
                    return
                uicore.Message(
                    'ItemDoesntFitPower', {
                        'item':
                        evetypes.GetName(item.typeID),
                        'slotpower':
                        cfg.dgmeffects.Get(
                            self.controller.GetPowerType()).displayName,
                        'itempower':
                        cfg.dgmeffects.Get(effect.effectID).displayName
                    })

        if not validFitting:
            raise UserError('ItemNotHardware', {'itemname': item.typeID})

    def OnMouseEnter(self, *args):
        if self.controller.GetModule() is not None:
            self.ShowUtilButtons()
        else:
            self.hint = self._emptyHint
            self.Hilite(1)
            uicore.Message('ListEntryEnter')

    def OnMouseExit(self, *args):
        if not self.controller.GetModule():
            self.Hilite(0)

    def PrepareUtilButtons(self):
        for btn in self.utilButtons:
            btn.Close()

        self.utilButtons = []
        if not self.controller.GetModule():
            return
        btns = self.GetUtilBtns()
        i = 0
        for btnData in btns:
            left = int(self.left + self.width / 2.0 - 8)
            top = self.height + 20 + i * 16
            utilBtn = FittingUtilBtn(parent=self.parent,
                                     icon=btnData.iconPath,
                                     left=left,
                                     top=top,
                                     btnData=btnData,
                                     mouseOverFunc=self.ShowUtilButtons,
                                     align=uiconst.BOTTOMLEFT,
                                     controller=self.controller)
            if btnData.onlineBtn == 1:
                self.sr.onlineButton = utilBtn
            self.utilButtons.append(utilBtn)
            i += 1

    def GetUtilBtns(self):
        btns = []
        isRig = False
        for effect in cfg.dgmtypeeffects.get(self.controller.GetModuleTypeID(),
                                             []):
            if effect.effectID == const.effectRigSlot:
                isRig = True
                break

        isOnlinable = self.controller.IsOnlineable()
        if isRig:
            btns += self.GetRigsBtns()
        else:
            btns = self.GetModuleBtns(isOnlinable)
        return btns
Пример #11
0
class ScanProbeEntryNew(SE_BaseClassCore):
    def Startup(self, *args):
        self.icon = Icon(parent=self,
                         pos=(1, 0, 24, 24),
                         align=uiconst.CENTERLEFT)
        self.labelLeft = EveLabelMedium(parent=self,
                                        align=uiconst.CENTERLEFT,
                                        state=uiconst.UI_DISABLED,
                                        left=26)
        self.probeExpiry = EveLabelMediumBold(parent=self,
                                              align=uiconst.CENTERRIGHT,
                                              state=uiconst.UI_DISABLED,
                                              left=66)
        self.probeScanRange = EveLabelMediumBold(parent=self,
                                                 align=uiconst.CENTERRIGHT,
                                                 state=uiconst.UI_DISABLED,
                                                 left=6)

    def Load(self, node):
        if node.Get('selectable', 1) and node.Get('selected', 0):
            self.Select()
        else:
            self.Deselect()
        probeName = sm.GetService('scanSvc').GetProbeLabel(node.probe.probeID)
        self.labelLeft.text = probeName
        self.icon.LoadIconByTypeID(node.probe.typeID, ignoreSize=True)
        self.icon.hint = evetypes.GetName(node.probe.typeID)
        self.UpdateProbeState()
        self.updateStateTimer = AutoTimer(500, self.UpdateProbeState)

    def UpdateProbeState(self):
        if self.destroyed:
            self.updateStateTimer = None
            return
        probe = self.sr.node.probe
        if probe.expiry is None:
            expiryText = localization.GetByLabel('UI/Generic/None')
        else:
            expiry = max(0L, long(probe.expiry) - blue.os.GetSimTime())
            if expiry <= 0:
                expiryText = localization.GetByLabel(
                    'UI/Inflight/Scanner/Expired')
            elif expiry >= const.MIN:
                expiryText = localization.formatters.FormatTimeIntervalShortWritten(
                    expiry, showFrom='day', showTo='minute')
            else:
                expiryText = localization.formatters.FormatTimeIntervalShortWritten(
                    expiry, showFrom='day', showTo='second')
        self.probeExpiry.text = expiryText
        if probe.state == const.probeStateInactive:
            self.opacity = 0.5
        else:
            self.opacity = 1.0
        if probe.scanRange < const.AU:
            probeScanRangeText = FmtDist(probe.scanRange, maxdemicals=2)
        else:
            probeScanRangeText = FmtDist(probe.scanRange, maxdemicals=0)
        self.probeScanRange.text = probeScanRangeText

    def OnDblClick(self, *args):
        sm.ScatterEvent('OnProbeScanner_FocusOnProbe', self.sr.node.probeID)

    def GetHeight(self, *args):
        node, width = args
        node.height = 26
        return node.height

    def OnMouseEnter(self, *args):
        SE_BaseClassCore.OnMouseEnter(self, *args)
        sm.ScatterEvent('OnProbeScanner_ProbeEntryMouseEnter',
                        self.sr.node.probeID)

    def OnMouseExit(self, *args):
        SE_BaseClassCore.OnMouseExit(self, *args)
        sm.ScatterEvent('OnProbeScanner_ProbeEntryMouseExit',
                        self.sr.node.probeID)

    def OnClick(self, *args):
        if self.sr.node:
            if self.sr.node.Get('selectable', 1):
                self.sr.node.scroll.SelectNode(self.sr.node)
            eve.Message('ListEntryClick')
            if self.sr.node.Get('OnClick', None):
                self.sr.node.OnClick(self)

    def GetMenu(self):
        if self.sr.node and self.sr.node.Get('GetMenu', None):
            return self.sr.node.GetMenu(self)
        if getattr(self, 'itemID', None) or getattr(self, 'typeID', None):
            return sm.GetService('menu').GetMenuFormItemIDTypeID(
                getattr(self, 'itemID', None), getattr(self, 'typeID', None))
        return []
Пример #12
0
class FightersHealthGauge(Container):
    default_height = 86
    default_width = 86
    default_align = uiconst.TOPLEFT
    default_state = uiconst.UI_PICKCHILDREN
    isDragObject = True

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.shipFighterState = GetShipFighterState()
        self.typeID = None
        self.squadronSize = None
        self.squadronMaxSize = None
        self.noHealthyFighters = 0
        self.squadronState = attributes.get('state', None)
        self.tubeFlagID = attributes.get('tubeFlagID', None)
        dashColors = self.GetDashColors()
        self.classIcon = Sprite(name='classIcon',
                                parent=self,
                                align=uiconst.CENTERBOTTOM,
                                width=16,
                                height=16,
                                top=18)
        self.classIcon.OnMouseEnter = self.OnMouseEnter
        self.classIcon.OnMouseExit = self.OnMouseExit
        self.classIcon.GetDragData = self.GetDragData
        self.fightersGauge = FighterHealthGaugeLine(parent=self,
                                                    dashColors=dashColors,
                                                    align=uiconst.CENTER)
        Sprite(
            parent=self,
            align=uiconst.CENTER,
            width=86,
            height=86,
            texturePath=
            'res:/UI/Texture/classes/ShipUI/Fighters/fighterItemOverlay.png',
            state=uiconst.UI_DISABLED)
        self.fighterIcon = Icon(
            parent=self,
            align=uiconst.CENTER,
            width=52,
            height=52,
            state=uiconst.UI_DISABLED,
            blendMode=1,
            textureSecondaryPath=
            'res:/UI/Texture/classes/ShipUI/Fighters/fighterItemMask.png',
            spriteEffect=trinity.TR2_SFX_MODULATE)
        Sprite(
            parent=self,
            align=uiconst.CENTER,
            width=86,
            height=86,
            texturePath=
            'res:/UI/Texture/classes/ShipUI/Fighters/fighterItemUnderlay.png',
            state=uiconst.UI_DISABLED)
        self.hilite = Sprite(
            parent=self,
            name='hilite',
            width=86,
            height=86,
            align=uiconst.CENTER,
            state=uiconst.UI_DISABLED,
            texturePath=
            'res:/UI/Texture/classes/ShipUI/Fighters/fighterItemUnderlayOver.png'
        )
        self.hilite.display = False

    def LoadFighterToSquadron(self, typeID):
        if typeID == self.typeID:
            return
        self.typeID = typeID
        self.fighterIcon.LoadIconByTypeID(typeID=typeID)
        self.squadronMaxSize = GetMaxSquadronSize(self.typeID)
        roleTexturePath = GetSquadronRoleResPath(self.typeID)
        self.classIcon.LoadTexture(roleTexturePath)
        hintString = HINTTEXT_BY_ROLE[GetSquadronRole(self.typeID)]
        self.classIcon.hint = GetByLabel(hintString)
        self.UpdateHint()

    def ClearFighters(self):
        self.fightersGauge.ClearFighters()

    def UpdateHint(self, damage=None):
        typeName = evetypes.GetName(self.typeID)
        if self.tubeFlagID is not None:
            tubeStatus = self.shipFighterState.GetTubeStatus(self.tubeFlagID)
            if tubeStatus.statusID not in TUBE_STATES_INSPACE:
                damage = None
        if damage and damage < 0.99:
            damageNumber = round((1.0 - damage) * 100)
            hintText = GetByLabel(
                'UI/Inventory/Fighters/SquadronHintWithDamage',
                typeName=typeName,
                numFighters=int(self.noHealthyFighters),
                damagePercentage=damageNumber)
        else:
            hintText = GetByLabel('UI/Inventory/Fighters/SquadronHint',
                                  typeName=typeName,
                                  numFighters=int(self.noHealthyFighters))
        self.hint = hintText

    def SetSquadronSize(self, squadronSize):
        self.squadronSize = squadronSize
        self.UpdateFighters()

    def GetDashColors(self, damage=None):
        self.noHealthyFighters = 0
        dashColors = []
        if self.tubeFlagID is not None:
            tubeStatus = self.shipFighterState.GetTubeStatus(self.tubeFlagID)
            if tubeStatus.statusID not in TUBE_STATES_INSPACE:
                damage = None
        if not self.typeID:
            return dashColors
        for i in xrange(1, self.squadronMaxSize + 1):
            if i <= self.squadronSize:
                self.noHealthyFighters += 1
                dashColor = self.GetHealthyFighterColor()
                if damage and damage < 0.99:
                    if i == self.squadronSize:
                        dashColor = DAMAGED_FIGHTER
                        self.noHealthyFighters -= 1
            else:
                dashColor = DEAD_FIGHTER
            dashColors.append(dashColor)

        return dashColors

    def GetHealthyFighterColor(self):
        if self.tubeFlagID is None:
            return HEALTHY_FIGHTER_SPACE
        else:
            tubeStatus = self.shipFighterState.GetTubeStatus(self.tubeFlagID)
            if tubeStatus.statusID in TUBE_STATES_INSPACE:
                return HEALTHY_FIGHTER_SPACE
            return HEALTHY_FIGHTER_TUBE

    def GetDragData(self):
        if self.squadronState is not None:
            squadronData = util.KeyVal()
            squadronData.tubeFlagID = self.tubeFlagID
            squadronData.squadronState = self.squadronState
            squadronData.typeID = self.typeID
            squadronData.__guid__ = 'uicls.FightersHealthGauge'
            return [squadronData]
        else:
            return []

    def UpdateFighters(self, damage=None):
        if not self.typeID:
            return
        dashColors = self.GetDashColors(damage)
        self.fightersGauge.UpdateFighterColors(dashColors)
        self.UpdateHint(damage)

    def LoadBySlimItem(self, slimItem):
        self.LoadFighterToSquadron(slimItem.typeID)
        squadronSize = GetSquadronSizeFromSlimItem(slimItem)
        self.SetSquadronSize(squadronSize)
        self.UpdateFighters()

    def OnMouseEnter(self, *args):
        self.hilite.display = True

    def OnMouseExit(self, *args):
        self.hilite.display = False