Esempio n. 1
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()
Esempio n. 2
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()