Example #1
0
    def __init__(self, jobData, tooltipPanel):
        tooltipPanel.state = uiconst.UI_NORMAL
        tooltipPanel.margin = MARGIN
        tooltipPanel.columns = 2
        AddModifierRow(
            '<color=gray>%s</color>' %
            localization.GetByLabel('UI/Industry/BaseItemCost'),
            FmtISK(jobData.base_cost, 0), tooltipPanel)
        AddSystemCostIndexRow(jobData.activityID,
                              jobData.facility,
                              tooltipPanel,
                              cellPadding=(0, 0, 0, 4))
        tooltipPanel.AddSpacer(colSpan=2, width=0, height=6)
        modifiers = jobData.GetModifiers(industry.CostModifier)
        if modifiers or jobData.facility.tax:
            caption = jobData.GetModifierCaption(industry.CostModifier)
            label = IndustryCaptionLabel(text=caption, width=220)
            tooltipPanel.AddCell(label, colSpan=2, cellPadding=(0, 0, 0, 2))
            if modifiers:
                for modifier in modifiers:
                    AddModifierRow(modifier.GetName(),
                                   modifier.GetPercentageLabel(), tooltipPanel)

            if jobData.facility.tax is not None:
                taxLabel = '<color=red>+%s%%</color>' % FormatNumeric(
                    jobData.facility.tax * 100,
                    useGrouping=True,
                    decimalPlaces=1)
                AddModifierRow(
                    localization.GetByLabel('UI/Industry/FacilityTax'),
                    taxLabel, tooltipPanel)
        tooltipPanel.AddSpacer(width=0, height=6)
Example #2
0
 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)
 def ApplyAttributes(self, attributes):
     BaseFramedContainer.ApplyAttributes(self, attributes)
     self.locationByInvID = {}
     self.label = IndustryCaptionLabel(parent=self.contentCont,
                                       pos=(5, 5, 0, 0),
                                       text=localization.GetByLabel(
                                           self.CAPTION_TEXT))
     self.combo = IndustryOutputCombo(parent=self.contentCont,
                                      align=uiconst.TOBOTTOM,
                                      callback=self.OnCombo,
                                      height=22)
     self.invController = None
Example #4
0
def AddMaterialGroupRow(materialGroupID, panel):
    cont = ContainerAutoSize(align=uiconst.TOPLEFT)
    icon = Sprite(
        parent=cont,
        align=uiconst.TOPLEFT,
        texturePath=industryUIConst.ICON_BY_INDUSTRYGROUP[materialGroupID],
        pos=(4, 0, 12, 12),
        color=industryUIConst.COLOR_FRAME)
    label = IndustryCaptionLabel(
        parent=cont,
        align=uiconst.TOPLEFT,
        text=localization.GetByLabel(
            industryUIConst.LABEL_BY_INDUSTRYGROUP[materialGroupID]),
        left=24)
    panel.AddCell(cont, colSpan=3, cellPadding=(0, 0, 0, 5))
Example #5
0
class TimeContainer(Container):
    default_state = uiconst.UI_NORMAL

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.jobData = None
        self.updateTimeThread = None
        self.timeCaption = IndustryCaptionLabel(name='timeCaption', parent=self)
        self.timeLabel = EveLabelLarge(name='timeLabel', parent=self, top=13)
        self.errorFrame = ErrorFrame(bgParent=self, padding=(-2, -2, 0, -2))

    def UpdateState(self):
        if self.updateTimeThread:
            self.updateTimeThread.kill()
            self.updateTimeThread = None
        if not self.jobData:
            self.timeLabel.text = ''
            return
        if self.jobData.IsInstalled():
            self.timeCaption.text = GetByLabel('UI/Industry/TimeLeft')
            self.updateTimeThread = uthread.new(self.UpdateTimeThread)
        else:
            self.timeCaption.text = GetByLabel('UI/Industry/JobDuration')
            self.timeLabel.text = self.jobData.GetJobTimeLeftLabel()

    def UpdateTimeThread(self):
        while not self.destroyed:
            self.timeLabel.text = self.jobData.GetJobTimeLeftLabel()
            blue.synchro.SleepWallclock(200)

    def OnNewJobData(self, jobData):
        self.jobData = jobData
        self.UpdateState()

    def LoadTooltipPanel(self, tooltipPanel, *args):
        TimeContainerTooltipPanel(jobData=self.jobData, tooltipPanel=tooltipPanel)

    def GetTooltipDelay(self):
        return TOOLTIP_DELAY_GAMEPLAY

    def GetTooltipPosition(self):
        return self.timeCaption.GetAbsolute()
 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)
     FillThemeColored(bgParent=self, opacity=0.5)
    def __init__(self, facilityData, activityID, tooltipPanel):
        tooltipPanel.margin = MARGIN
        tooltipPanel.columns = 2
        tooltipPanel.state = uiconst.UI_NORMAL
        text = localization.GetByLabel(industryUIConst.ACTIVITY_NAMES.get(activityID))
        tooltipPanel.AddLabelMedium(text=text, cellPadding=PADBOTTOM, colSpan=2, bold=True)
        if activityID not in facilityData.activities:
            text = localization.GetByLabel('UI/Industry/ActivityNotSupported')
            tooltipPanel.AddLabelMedium(text=text, cellPadding=PADBOTTOM, colSpan=2)
            return
        if activityID == industry.MANUFACTURING:
            activity = facilityData.activities[activityID]
            categoryGroupData = self.GetTypesSupportedWithModifiers(activity, facilityData.modifiers)
            if categoryGroupData:
                label = IndustryCaptionLabel(text=localization.GetByLabel('UI/Industry/ManufacturingTypesHint'))
                tooltipPanel.AddCell(label, colSpan=2)
                self.scroll = ScrollContainer(align=uiconst.TOTOP, showUnderlay=True)
                for text, modifierME, modifierTE in categoryGroupData:
                    Label(parent=self.scroll, align=uiconst.TOTOP, text=text, padding=2)
                    if modifierME:
                        Label(parent=self.scroll, align=uiconst.TOTOP, text='<color=gray>%s:</color> %s' % (localization.GetByLabel('UI/Industry/MaterialConsumption'), modifierME.GetPercentageLabel()), fontsize=10, padding=(2, 0, 2, 2))
                    if modifierTE:
                        Label(parent=self.scroll, align=uiconst.TOTOP, text='<color=gray>%s</color> %s' % (localization.GetByLabel('UI/Industry/JobDuration'), modifierTE.GetPercentageLabel()), fontsize=10, padding=(2, -3, 2, 3))

                self.scroll.height = min(150, len(categoryGroupData) * 20)
                tooltipPanel.AddCell(self.scroll, cellPadding=PADBOTTOM, colSpan=2)
        modifiers = facilityData.GetFacilityModifiersByActivityID().get(activityID, None)
        if modifiers:
            for modifierCls, label in ((industry.TimeModifier, 'UI/Industry/ModifierTimeCaption'), (industry.MaterialModifier, 'UI/Industry/ModifierMaterialCaption'), (industry.CostModifier, 'UI/Industry/ModifierCostCaption')):
                clsModifiers = [ modifier for modifier in modifiers if isinstance(modifier, modifierCls) ]
                if clsModifiers:
                    AddModifierRows(localization.GetByLabel(label), clsModifiers, tooltipPanel)
                    tooltipPanel.AddSpacer(0, 6, colSpan=2)

        costIndexes = facilityData.GetCostIndexByActivityID()
        costIndex = costIndexes.get(activityID, None)
        if costIndex:
            AddSystemCostIndexRow(activityID, facilityData, tooltipPanel)
def AddModifierRows(caption, modifiers, panel):
    label = IndustryCaptionLabel(text=caption, width=220)
    panel.AddCell(label, colSpan=2, cellPadding=(0, 0, 0, 2))
    for modifier in modifiers:
        AddModifierRow(modifier.GetName(), modifier.GetPercentageLabel(), panel)
Example #9
0
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     sm.RegisterNotify(self)
     self.jobData = attributes.jobData
     self.newNumRuns = None
     self.setJobRunsThread = None
     self.oldJobData = None
     self.numericInputTimer = None
     self.iconCont = ItemIcon(parent=self,
                              align=uiconst.CENTER,
                              state=uiconst.UI_DISABLED,
                              width=64,
                              height=64,
                              opacity=0.0)
     self.errorFrame = ErrorFrame(parent=self,
                                  align=uiconst.CENTER,
                                  state=uiconst.UI_DISABLED,
                                  width=80,
                                  height=80)
     self.ConstructBackground()
     self.runsCont = ContainerAutoSize(parent=self,
                                       align=uiconst.CENTER,
                                       top=100)
     self.runsCaption = IndustryCaptionLabel(
         name='runsCaption',
         parent=self.runsCont,
         align=uiconst.CENTERTOP,
         text=GetByLabel('UI/Industry/JobRuns'))
     self.runsEdit = BlueprintSingleLineEdit(parent=self.runsCont,
                                             align=uiconst.CENTERTOP,
                                             pos=(0, 12, 62, 0),
                                             OnChange=self.OnRunsEdit,
                                             autoselect=True)
     self.runsPerCopyCont = ContainerAutoSize(name='runsPerCopyCont',
                                              parent=self.runsCont,
                                              align=uiconst.CENTERTOP,
                                              top=38,
                                              state=uiconst.UI_HIDDEN)
     IndustryCaptionLabel(name='runsPerCopyCaption',
                          parent=self.runsPerCopyCont,
                          align=uiconst.CENTERTOP,
                          text=GetByLabel('UI/Industry/RunsPerCopy'))
     self.runsPerCopyEdit = BlueprintSingleLineEdit(
         parent=self.runsPerCopyCont,
         align=uiconst.CENTERTOP,
         pos=(0, 12, 62, 0),
         OnChange=self.OnRunsPerCopyEdit,
         autoselect=True)
     self.gauge = None
     self.skillSprite = SkillIcon(parent=self,
                                  align=uiconst.CENTERBOTTOM,
                                  top=5,
                                  jobData=self.jobData)
     self.containerME = ContainerME(parent=self,
                                    align=uiconst.CENTER,
                                    pos=(113, -25, 71, 30),
                                    jobData=self.jobData,
                                    opacity=0.0)
     self.containerTE = ContainerTE(parent=self,
                                    align=uiconst.CENTER,
                                    pos=(113, 25, 71, 30),
                                    jobData=self.jobData,
                                    opacity=0.0)
     self.runsRemainingCont = ContainerAutoSize(name='bpCopyCont',
                                                parent=self,
                                                align=uiconst.CENTERTOP,
                                                state=uiconst.UI_NORMAL,
                                                top=90)
     self.runsRemainingCont.OnClick = self.OnRunsRemainingContClicked
     self.runsRemainingCaption = IndustryCaptionLabel(
         parent=self.runsRemainingCont, align=uiconst.CENTERTOP)
     self.runsRemainingLabel = EveLabelMediumBold(
         name='runsRemainingLabel',
         parent=self.runsRemainingCont,
         align=uiconst.CENTERTOP,
         top=14)
     self.UpdateState()
     self.AnimEntry()
Example #10
0
class BlueprintCenter(Container):
    __notifyevents__ = ('OnIndustryWndMouseWheel', 'OnIndustryWndClick',
                        'OnBlueprintBrowserNumericInput')

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        sm.RegisterNotify(self)
        self.jobData = attributes.jobData
        self.newNumRuns = None
        self.setJobRunsThread = None
        self.oldJobData = None
        self.numericInputTimer = None
        self.iconCont = ItemIcon(parent=self,
                                 align=uiconst.CENTER,
                                 state=uiconst.UI_DISABLED,
                                 width=64,
                                 height=64,
                                 opacity=0.0)
        self.errorFrame = ErrorFrame(parent=self,
                                     align=uiconst.CENTER,
                                     state=uiconst.UI_DISABLED,
                                     width=80,
                                     height=80)
        self.ConstructBackground()
        self.runsCont = ContainerAutoSize(parent=self,
                                          align=uiconst.CENTER,
                                          top=100)
        self.runsCaption = IndustryCaptionLabel(
            name='runsCaption',
            parent=self.runsCont,
            align=uiconst.CENTERTOP,
            text=GetByLabel('UI/Industry/JobRuns'))
        self.runsEdit = BlueprintSingleLineEdit(parent=self.runsCont,
                                                align=uiconst.CENTERTOP,
                                                pos=(0, 12, 62, 0),
                                                OnChange=self.OnRunsEdit,
                                                autoselect=True)
        self.runsPerCopyCont = ContainerAutoSize(name='runsPerCopyCont',
                                                 parent=self.runsCont,
                                                 align=uiconst.CENTERTOP,
                                                 top=38,
                                                 state=uiconst.UI_HIDDEN)
        IndustryCaptionLabel(name='runsPerCopyCaption',
                             parent=self.runsPerCopyCont,
                             align=uiconst.CENTERTOP,
                             text=GetByLabel('UI/Industry/RunsPerCopy'))
        self.runsPerCopyEdit = BlueprintSingleLineEdit(
            parent=self.runsPerCopyCont,
            align=uiconst.CENTERTOP,
            pos=(0, 12, 62, 0),
            OnChange=self.OnRunsPerCopyEdit,
            autoselect=True)
        self.gauge = None
        self.skillSprite = SkillIcon(parent=self,
                                     align=uiconst.CENTERBOTTOM,
                                     top=5,
                                     jobData=self.jobData)
        self.containerME = ContainerME(parent=self,
                                       align=uiconst.CENTER,
                                       pos=(113, -25, 71, 30),
                                       jobData=self.jobData,
                                       opacity=0.0)
        self.containerTE = ContainerTE(parent=self,
                                       align=uiconst.CENTER,
                                       pos=(113, 25, 71, 30),
                                       jobData=self.jobData,
                                       opacity=0.0)
        self.runsRemainingCont = ContainerAutoSize(name='bpCopyCont',
                                                   parent=self,
                                                   align=uiconst.CENTERTOP,
                                                   state=uiconst.UI_NORMAL,
                                                   top=90)
        self.runsRemainingCont.OnClick = self.OnRunsRemainingContClicked
        self.runsRemainingCaption = IndustryCaptionLabel(
            parent=self.runsRemainingCont, align=uiconst.CENTERTOP)
        self.runsRemainingLabel = EveLabelMediumBold(
            name='runsRemainingLabel',
            parent=self.runsRemainingCont,
            align=uiconst.CENTERTOP,
            top=14)
        self.UpdateState()
        self.AnimEntry()

    def OnRunsRemainingContClicked(self, *args):
        if self.runsEdit.state == uiconst.UI_NORMAL:
            self.runsEdit.SetValue(self.jobData.maxRuns)

    def OnBlueprintBrowserNumericInput(self, key, flag):
        if not self.numericInputTimer:
            self.runsEdit.SelectAll()
        else:
            self.numericInputTimer.kill()
        self.numericInputTimer = uthread.new(self.NumericInputTimer)
        self.runsEdit.OnChar(key, flag)

    def NumericInputTimer(self):
        blue.synchro.SleepWallclock(1000)
        self.numericInputTimer = None

    def OnJobUpdated(self, job):
        if self.jobData and self.jobData == job:
            self.UpdateStateJob()

    def UpdateStateJob(self):
        self.iconCont.Show()
        typeID = self.jobData.blueprint.blueprintTypeID
        self.iconCont.SetTypeID(typeID=typeID, bpData=self.jobData.blueprint)
        self.UpdateGaugeValue()
        self.UpdateStateRunsEdit()
        self.UpdateStateRunsPerCopyEdit()
        self.skillSprite.Show()
        self.UpdateRunsRemainingLabel()
        self.containerME.SetValue(self.jobData.blueprint.materialEfficiency)
        self.containerTE.SetValue(self.jobData.blueprint.timeEfficiency)
        self.jobData.on_updated.connect(self.OnJobUpdated)

    def UpdateRunsRemainingLabel(self):
        if not self.jobData:
            return
        if self.jobData.IsInstalled():
            self.runsRemainingCont.Hide()
        else:
            runsText = self.jobData.GetRunsRemainingLabel()
            if runsText:
                self.runsRemainingCont.Show()
                self.runsRemainingLabel.text = runsText
                self.runsRemainingCaption.text = self.jobData.GetRunsRemainingCaption(
                )
            else:
                self.runsRemainingCont.Hide()

    def SetNumRuns(self, numRuns):
        if not self.jobData.IsInstalled():
            self.runsEdit.SetValue(numRuns)

    def UpdateStateRunsEdit(self):
        if self.jobData.IsInstalled():
            self.runsEdit.IntMode(self.jobData.runs, self.jobData.runs)
            self.runsEdit.Show()
            self.runsCaption.Show()
            self.runsEdit.Disable()
        else:
            self.runsEdit.IntMode(1, self.jobData.maxRuns)
            self.runsEdit.Enable()
            self.runsEdit.Show()
            self.runsCaption.Show()
        self.runsEdit.SetValue(self.jobData.runs)

    def UpdateStateRunsPerCopyEdit(self):
        if self.jobData.activityID == industry.COPYING:
            if self.jobData.IsInstalled():
                self.runsPerCopyEdit.IntMode(self.jobData.licensedRuns,
                                             self.jobData.licensedRuns)
                self.runsPerCopyEdit.Disable()
            else:
                self.runsPerCopyEdit.IntMode(1, self.jobData.maxLicensedRuns)
                self.runsPerCopyEdit.Enable()
            self.runsPerCopyEdit.SetValue(self.jobData.licensedRuns)
            self.runsPerCopyCont.Show()
        else:
            self.runsPerCopyCont.Hide()

    def UpdateState(self):
        if self.jobData:
            self.UpdateStateJob()
        else:
            self.iconCont.Hide()
            self.runsEdit.Hide()
            self.runsPerCopyCont.Hide()
            self.runsCaption.Hide()
            self.skillSprite.Hide()
            self.runsRemainingCont.Hide()
            self.containerME.SetValue(0.0)
            self.containerTE.SetValue(0.0)

    def ReconstructGauge(self):
        if self.gauge:
            self.gauge.Close()
            self.gauge = None
        if not self.jobData:
            return
        color = GetJobColor(self.jobData)
        h, s, b = Color(*color).GetHSB()
        colorEnd = Color(*color).SetBrightness(b * 0.5).GetRGBA()
        self.gauge = BlueprintGaugeCircular(name='gauge',
                                            parent=self,
                                            align=uiconst.CENTER,
                                            radius=64,
                                            lineWidth=4,
                                            colorStart=color,
                                            colorEnd=colorEnd,
                                            jobData=self.jobData)

    def AnimWedges(self, startVal, endVal, duration, curveType=None):
        uicore.animations.MorphScalar(self.topWedge,
                                      'top',
                                      startVal,
                                      endVal,
                                      duration=duration,
                                      curveType=curveType)
        uicore.animations.MorphScalar(self.bottomWedge,
                                      'top',
                                      startVal,
                                      endVal,
                                      duration=duration,
                                      curveType=curveType)
        uicore.animations.MorphScalar(self.leftWedge,
                                      'left',
                                      startVal,
                                      endVal,
                                      duration=duration,
                                      curveType=curveType)
        uicore.animations.MorphScalar(self.rightWedge,
                                      'left',
                                      startVal,
                                      endVal,
                                      duration=duration,
                                      curveType=curveType)

    def AnimEntry(self):
        duration = 0.7
        if self.jobData:
            self.HideDashes()
            if self.topWedge.top < WEDGE_TRAVEL:
                self.AnimWedges(0, WEDGE_TRAVEL, duration)
            else:
                self.AnimWedges(WEDGE_TRAVEL,
                                18,
                                0.5,
                                curveType=uiconst.ANIM_WAVE)
            if not self.IsSameBlueprint():
                uicore.animations.FadeTo(self.iconCont, 0.0, 1.0, duration=0.5)
            for obj in (self.containerME, self.containerTE):
                obj.Enable()
                uicore.animations.FadeIn(obj, duration=duration)

        else:
            self.AnimWedges(self.topWedge.top, 0.0, duration)
            for obj in (self.containerME, self.containerTE):
                obj.Disable()
                uicore.animations.FadeOut(obj, duration=duration)

            self.ShowDashes()
        if self.jobData and self.jobData.IsPreview():
            uicore.animations.FadeTo(self.iconCont, 0.0, 0.65, duration=0.5)
            self.errorFrame.Show()
            wedgeColor = industryUIConst.COLOR_NOTREADY
        else:
            self.errorFrame.Hide()
            wedgeColor = Color.WHITE
        for dots in self.wedgeDots:
            dots.SetRGBA(*wedgeColor)

        if self.gauge:
            uicore.animations.BlinkIn(self.gauge, 0.0, 1.0, timeOffset=0.98)
        for dots in self.wedgeDots:
            uicore.animations.BlinkIn(dots, 0.0, 0.85, timeOffset=0.78)

        for pattern in self.wedgeBg:
            if self.jobData and self.jobData.IsPreview():
                color = industryUIConst.COLOR_NOTREADY
            else:
                color = GetJobColor(self.jobData)
            uicore.animations.SpColorMorphTo(pattern,
                                             pattern.GetRGBA(),
                                             color,
                                             duration=0.3)

    def IsSameBlueprint(self):
        if not self.oldJobData or not self.jobData:
            return False
        if self.jobData:
            return self.jobData.blueprint.IsSameBlueprint(
                self.oldJobData.blueprint)
        return False

    def UpdateGaugeValue(self):
        if not self.gauge or not self.jobData:
            return
        self.gauge.SetValue(self.jobData.GetGaugeValue())

    def SetJobRuns(self, value):
        if self.setJobRunsThread is None:
            self.setJobRunsThread = uthread.new(self._SetJobRuns)
        self.newNumRuns = value

    def _SetJobRuns(self):
        while self.jobData and self.newNumRuns is not None:
            if self.newNumRuns != self.jobData.runs:
                newNumRuns = self.newNumRuns
                self.newNumRuns = None
                self.jobData.runs = newNumRuns
                sm.GetService('audio').SendUIEvent('ind_runsChanged')
            blue.synchro.SleepWallclock(100)

        self.setJobRunsThread = None

    def OnRunsEdit(self, value):
        try:
            value = int(value)
        except ValueError:
            return

        if self.jobData and not self.jobData.IsInstalled():
            self.SetJobRuns(value)

    def OnRunsChanged(self):
        self.UpdateGaugeValue()
        self.UpdateRunsRemainingLabel()

    def OnRunsPerCopyEdit(self, value):
        try:
            value = int(value)
        except ValueError:
            return

        self.jobData.licensedRuns = value

    def ConstructBackground(self):
        Frame(name='bgFrame',
              parent=self,
              align=uiconst.CENTER,
              state=uiconst.UI_DISABLED,
              width=75,
              height=75,
              opacity=0.1)
        blueprintBg = FrameThemeColored(
            name='blueprintBgFill',
            parent=self,
            align=uiconst.CENTER,
            state=uiconst.UI_DISABLED,
            texturePath='res:/UI/Texture/classes/Industry/Center/bgFrame.png',
            width=90,
            height=90)
        self.dashesCont = Container(name='dashesCont',
                                    parent=self,
                                    state=uiconst.UI_DISABLED,
                                    pos=(75, 0, 150, 150),
                                    align=uiconst.CENTER)
        self.bgCont = Container(name='bgCont',
                                parent=self,
                                state=uiconst.UI_DISABLED,
                                width=150,
                                height=150,
                                align=uiconst.CENTER)
        self.topWedge = Container(name='topWedge',
                                  parent=self.bgCont,
                                  align=uiconst.CENTERTOP,
                                  pos=(0, 0, 84, 60))
        topLines = Sprite(
            bgParent=self.topWedge,
            texturePath=
            'res:/UI/Texture/classes/Industry/Center/wedgeTopBottom.png')
        topDots = Sprite(
            bgParent=self.topWedge,
            texturePath=
            'res:/UI/Texture/classes/Industry/Center/dotsTopBottom.png')
        topBg = Sprite(
            bgParent=self.topWedge,
            texturePath='res:/UI/Texture/classes/Industry/Center/bgTop.png',
            color=COLOR_FRAME)
        self.bottomWedge = Container(name='bottomWedge',
                                     parent=self.bgCont,
                                     align=uiconst.CENTERBOTTOM,
                                     pos=(0, 0, 84, 60))
        bottomLines = Sprite(
            bgParent=self.bottomWedge,
            texturePath=
            'res:/UI/Texture/classes/Industry/Center/wedgeTopBottom.png',
            rotation=pi)
        bottomDots = Sprite(
            bgParent=self.bottomWedge,
            texturePath=
            'res:/UI/Texture/classes/Industry/Center/dotsTopBottom.png',
            rotation=pi)
        bottomBg = Sprite(
            bgParent=self.bottomWedge,
            texturePath='res:/UI/Texture/classes/Industry/Center/bgBottom.png',
            color=COLOR_FRAME)
        self.leftWedge = Container(name='leftWedge',
                                   parent=self.bgCont,
                                   align=uiconst.CENTERLEFT,
                                   pos=(0, 0, 60, 84))
        leftLines = Sprite(
            bgParent=self.leftWedge,
            texturePath=
            'res:/UI/Texture/classes/Industry/Center/wedgeLeftRight.png')
        leftDots = Sprite(
            bgParent=self.leftWedge,
            texturePath=
            'res:/UI/Texture/classes/Industry/Center/dotsLeftRight.png')
        leftBg = Sprite(
            bgParent=self.leftWedge,
            texturePath='res:/UI/Texture/classes/Industry/Center/bgLeft.png',
            color=COLOR_FRAME)
        self.rightWedge = Container(name='rightWedge',
                                    parent=self.bgCont,
                                    align=uiconst.CENTERRIGHT,
                                    pos=(0, 0, 60, 84))
        rightLines = Sprite(
            bgParent=self.rightWedge,
            texturePath=
            'res:/UI/Texture/classes/Industry/Center/wedgeLeftRight.png',
            rotation=pi)
        rightDots = Sprite(
            bgParent=self.rightWedge,
            texturePath=
            'res:/UI/Texture/classes/Industry/Center/dotsLeftRight.png',
            rotation=pi)
        rightBg = Sprite(
            bgParent=self.rightWedge,
            texturePath='res:/UI/Texture/classes/Industry/Center/bgRight.png',
            color=COLOR_FRAME)
        self.wedgeLines = [topLines, bottomLines, leftLines, rightLines]
        self.wedgeDots = [topDots, bottomDots, leftDots, rightDots]
        self.wedgeBg = [topBg, bottomBg, leftBg, rightBg]

    def ShowDashes(self):
        for rotation in (0, pi / 2, pi, 3 * pi / 2):
            BlueDash(parent=self.dashesCont,
                     align=uiconst.CENTERLEFT,
                     rotation=pi / 4 + rotation,
                     rotationCenter=(0.0, 0.5))

    def HideDashes(self):
        self.dashesCont.Flush()

    def OnNewJobData(self, jobData):
        self.oldJobData = self.jobData
        self.jobData = jobData
        self.skillSprite.OnNewJobData(jobData)
        self.containerME.OnNewJobData(jobData)
        self.containerTE.OnNewJobData(jobData)
        self.ReconstructGauge()
        if self.gauge:
            self.gauge.OnNewJobData(jobData)
        self.UpdateState()
        self.AnimEntry()
        self.numericInputTimer = None

    def OnIndustryWndMouseWheel(self, *args):
        if not self.jobData:
            return
        self.runsEdit.OnMouseWheel()
        if uicore.registry.GetFocus() != self.runsEdit:
            uicore.registry.SetFocus(self.runsEdit)

    def OnIndustryWndClick(self):
        if not self.jobData:
            return
        uicore.registry.SetFocus(self.runsEdit)
Example #11
0
class CostContainer(Container):
    default_state = uiconst.UI_NORMAL
    default_padLeft = 4

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.jobData = None
        self.costCaption = IndustryCaptionLabel(name='costCaption', parent=self, align=uiconst.TOTOP, text=GetByLabel('UI/Industry/JobCost'))
        textCont = Container(parent=self)
        self.walletCombo = Combo(parent=textCont, align=uiconst.TOLEFT, state=uiconst.UI_HIDDEN, callback=self.OnWalletCombo, iconOnly=True, width=33, top=1)
        self.walletCombo.GetHint = self.GetWalletComboHint
        self.costLabel = EveLabelLarge(name='costLabel', parent=textCont, align=uiconst.TOTOP, padLeft=4)
        self.errorFrame = ErrorFrame(bgParent=self, padding=(0, -2, 0, -2))

    def UpdateWalletCombo(self):
        if not self.jobData or not self.jobData.accounts or len(self.jobData.accounts) <= 1:
            self.walletCombo.Hide()
            return
        self.walletCombo.Show()
        options = []
        for ownerID, divisionID in sorted(self.jobData.accounts):
            label = self.GetWalletName(ownerID, divisionID)
            texturePath = self.GetWalletIcon(ownerID)
            options.append((label,
             (ownerID, divisionID),
             None,
             texturePath))

        self.walletCombo.LoadOptions(options)
        if self.jobData:
            self.walletCombo.SelectItemByValue(self.jobData.account)

    def OnWalletCombo(self, combo, key, value):
        self.jobData.account = value

    def GetWalletName(self, ownerID, divisionID):
        if ownerID == session.charid:
            return GetByLabel('UI/Industry/PersonalWallet')
        else:
            divisionName = sm.GetService('wallet').GetDivisionName(divisionID)
            return GetByLabel('UI/Industry/CorporateWallet', divisionName=divisionName)

    def GetWalletIcon(self, ownerID):
        if ownerID == session.charid:
            return 'res:/UI/Texture/Classes/Industry/iconPersonal.png'
        else:
            return 'res:/UI/Texture/Classes/Industry/iconCorp.png'

    def GetWalletComboHint(self):
        ownerID, divisionID = self.jobData.account
        iskAmount = self.jobData.accounts[ownerID, divisionID]
        iskAmount = FmtISK(iskAmount)
        walletName = self.GetWalletName(ownerID, divisionID)
        return GetByLabel('UI/Industry/WalletSelectionHint', walletName=walletName, iskAmount=iskAmount)

    def OnNewJobData(self, jobData):
        self.jobData = jobData
        self.UpdateState()

    def UpdateState(self):
        if not self.jobData:
            self.costLabel.text = ''
            self.walletCombo.Hide()
            return
        if self.jobData.facility and self.jobData.activityID in self.jobData.facility.activities:
            manufacturingCost = self.jobData.total_cost
            self.costLabel.text = FmtISK(manufacturingCost, showFractionsAlways=False)
        else:
            self.costLabel.text = '-'
        self.UpdateWalletCombo()

    def LoadTooltipPanel(self, tooltipPanel, *args):
        if self.jobData.facility:
            CostContainerTooltipPanel(jobData=self.jobData, tooltipPanel=tooltipPanel)

    def GetTooltipDelay(self):
        return TOOLTIP_DELAY_GAMEPLAY

    def GetTooltipPosition(self):
        return self.costCaption.GetAbsolute()