Example #1
0
 def UpdateCounter(self, current=None):
     if current is None:
         current = 0
     maxCount = self.limits['cnt']
     self.sr.counter.text = localization.GetByLabel(
         'UI/Market/Orders/OrdersRemaining',
         remaining=maxCount - current,
         maxCount=maxCount,
         escrow=util.FmtISK(self.totalEscrow, showFractionsAlways=False),
         totalLeft=util.FmtISK(self.totalLeft, showFractionsAlways=False),
         feeLimit=round(self.limits['fee'] * 100, 2),
         accLimit=round(self.limits['acc'] * 100, 2),
         income=util.FmtISK(self.totalIncome, showFractionsAlways=False),
         expenses=util.FmtISK(self.totalExpenses,
                              showFractionsAlways=False))
     askLimit = self.limits['ask']
     bidLimit = self.limits['bid']
     modLimit = self.limits['mod']
     visLimit = self.limits['vis']
     if askLimit == -1 and bidLimit == -1 and modLimit == -1 and visLimit == -1:
         self.sr.counter2.text = localization.GetByLabel(
             'UI/Market/Orders/OrderRangesWithoutRemote')
     else:
         self.sr.counter2.text = localization.GetByLabel(
             'UI/Market/Orders/OrderRanges',
             askLimit=self.GetLimitText(askLimit),
             bidLimit=self.GetLimitText(bidLimit),
             modLimit=self.GetLimitText(modLimit),
             visLimit=self.GetLimitText(visLimit))
     self.sr.counter.parent.height = max(
         60, self.sr.counter.textheight + const.defaultPadding * 2,
         self.sr.counter2.textheight + const.defaultPadding * 2)
Example #2
0
def CSPAChargedActionForMany(message, obj, function, *args):
    try:
        func = getattr(obj, function)
        return func(*args)
    except UserError as e:
        if e.msg == 'ContactCostNotApprovedForMany':
            listOfMessage = e.dict['costNotApprovedFor']
            totalCost = 0
            totalApprovedCost = 0
            listingOutPlayers = []
            for each in listOfMessage:
                totalCost += each['totalCost']
                totalApprovedCost += each['approvedCost']
                charID = each['charID']
                listingOutPlayers.append('%s : %s' %
                                         (cfg.eveowners.Get(charID).name,
                                          util.FmtISK(each['totalCost'])))

            namelist = '<br>'.join(listingOutPlayers)
            if eve.Message(message, {
                    'amountISK': util.FmtISK(totalCost),
                    'namelist': namelist
            }, uiconst.YESNO) != uiconst.ID_YES:
                return None
            kwArgs = {'approvedCost': totalCost}
            return apply(getattr(obj, function), args, kwArgs)
        raise
Example #3
0
 def LoadTooltipPanelDetails(cls, tooltipPanel, btnData):
     if btnData.id == 'wallet':
         showFractions = settings.user.ui.Get('walletShowCents', 1)
         personalWealth = util.FmtISK(sm.GetService('wallet').GetWealth(), showFractions)
         tooltipPanel.AddLabelValue(label=localization.GetByLabel('Tooltips/Neocom/Balance'), value=personalWealth)
         canAccess = sm.GetService('wallet').HaveReadAccessToCorpWalletDivision(session.corpAccountKey)
         if canAccess:
             corpWealth = util.FmtISK(sm.GetService('wallet').GetCorpWealthCached1Min(session.corpAccountKey), showFractions)
             tooltipPanel.AddLabelValue(label=localization.GetByLabel('Tooltips/Neocom/CorporationBalance'), value=corpWealth)
    def DrawKillsByGroup(self):
        self.killGroupsTextCont.Flush()
        self.killGroupsDataCont.Flush()
        self.killGroupsLegendCont.Flush()
        top = 2
        self.groupLabels = []
        for shipGroup in self.shipGroupList:
            killsByShipGroup = self.GetKillsByGroup(shipGroup)
            labelText = self.GetShipGroupName(shipGroup)
            groupLabel = uicontrols.EveLabelSmall(
                text=localization.GetByLabel(labelText),
                parent=self.killGroupsTextCont,
                top=top,
                left=const.defaultPadding,
                state=uiconst.UI_NORMAL,
                align=uiconst.TOPRIGHT)
            groupLabel.OnClick = (self.GetBarAndClick, shipGroup)
            if killsByShipGroup.attackerKills == 0 and killsByShipGroup.defenderKills == 0:
                groupLabel.SetAlpha(0.5)
            top += 18
            self.groupLabels.append(groupLabel)
            self.CreateBarContainer(shipGroup, killsByShipGroup.attackerKills,
                                    killsByShipGroup.defenderKills,
                                    killsByShipGroup.attackerKillsIsk,
                                    killsByShipGroup.defenderKillsIsk)

        w, h = self.killGroupsDataCont.GetAbsoluteSize()
        l = 0.1
        max = 1.0
        legendmin = uicontrols.EveLabelSmall(parent=self.killGroupsLegendCont,
                                             text=localization.GetByLabel(
                                                 'UI/Corporations/Wars/Legend',
                                                 legend=util.FmtISK(0)),
                                             align=uiconst.TOPLEFT)
        legendmax = uicontrols.EveLabelSmall(
            parent=self.killGroupsLegendCont,
            text=localization.GetByLabel('UI/Corporations/Wars/Legend',
                                         legend=util.FmtISK(self.maxKills)),
            align=uiconst.TOPRIGHT)
        while l <= max:
            lineCont = uiprimitives.Container(parent=self.killGroupsDataCont,
                                              align=uiconst.TOPLEFT_PROP,
                                              width=l,
                                              height=h)
            uiprimitives.Line(parent=lineCont,
                              align=uiconst.TORIGHT,
                              color=(1.0, 1.0, 1.0, 0.1))
            l += 0.1

        self.displayGroup = settings.user.ui.Get('killGroupDisplayed',
                                                 const.GROUP_CAPSULES)
        maxWidth = self.GetGroupLabelWidth()
        self.killGroupsTextCont.width = maxWidth + 10
        self.GetBarAndClick(self.displayGroup)
        self.graphLoaded = True
    def ConstructLayout(self):
        contName = 'group_%d' % self.groupID
        self.sr.selected = uiprimitives.Fill(bgParent=self,
                                             color=(1.0, 1.0, 1.0, 0.15),
                                             state=uiconst.UI_HIDDEN)
        self.sr.hilite = uiprimitives.Fill(parent=self,
                                           color=(1.0, 1.0, 1.0, 0.1),
                                           state=uiconst.UI_HIDDEN)
        self.OnMouseEnter = self.BarOnMouseEnter
        self.OnMouseExit = self.BarOnMouseExit
        attackerName = cfg.eveowners.Get(self.attackerID).name
        defenderName = cfg.eveowners.Get(self.defenderID).name
        hintText = localization.GetByLabel(
            'UI/Corporations/Wars/AggressorDefenderKillsHint',
            aggressorName=attackerName,
            aggressorKillsIsk=util.FmtISK(self.attackerKillsIsk, 0),
            aggressorKills=util.FmtAmt(self.attackerKills),
            defenderName=defenderName,
            defenderKillsIsk=util.FmtISK(self.defenderKillsIsk, 0),
            defenderKills=util.FmtAmt(self.defenderKills))
        self.hint = hintText
        topbar = uiprimitives.Container(name='topbar',
                                        parent=self,
                                        align=uiconst.TOTOP,
                                        height=5,
                                        padTop=4)
        try:
            redwith = float(self.attackerKillsIsk) / float(self.maxKills)
        except:
            redwith = 0.0

        redbar = uiprimitives.Container(parent=topbar,
                                        align=uiconst.TOLEFT_PROP,
                                        width=redwith,
                                        height=5,
                                        bgColor=ATTACKER_COLOR)
        bottombar = uiprimitives.Container(name='bluebar',
                                           parent=self,
                                           align=uiconst.TOBOTTOM,
                                           height=5,
                                           padBottom=4)
        try:
            bluewith = float(self.defenderKillsIsk) / float(self.maxKills)
        except:
            bluewith = 0.0

        bluebar = uiprimitives.Container(parent=bottombar,
                                         align=uiconst.TOLEFT_PROP,
                                         width=bluewith,
                                         height=5,
                                         bgColor=DEFENDER_COLOR)
Example #6
0
 def OnMoneyOffer(self, money):
     myMoney = util.FmtISK(money[self.sr.myIx])
     if money[self.sr.myIx] > 0:
         myMoney = localization.GetByLabel('UI/PVPTrade/NegativeChangeInFunds', amount=myMoney)
     else:
         myMoney = localization.GetByLabel('UI/PVPTrade/NoChangeInFunds', amount=myMoney)
     herMoney = util.FmtISK(money[self.sr.herIx])
     if money[self.sr.herIx] > 0:
         herMoney = localization.GetByLabel('UI/PVPTrade/PositiveChangeInFunds', amount=herMoney)
     else:
         herMoney = localization.GetByLabel('UI/PVPTrade/NoChangeInFunds', amount=herMoney)
     self.sr.myMoney.text = localization.GetByLabel('UI/PVPTrade/Money', formattedAmount=myMoney)
     self.sr.herMoney.text = localization.GetByLabel('UI/PVPTrade/Money', formattedAmount=herMoney)
     self.OnStateToggle([0, 0])
def ProcessTypeAndQuantity(typeID, quantity, extra = None):
    if typeID == const.typeCredits:
        return util.FmtISK(quantity)
    elif extra is None:
        return cfg.FormatConvert(const.UE_TYPEIDANDQUANTITY, typeID, quantity)
    else:
        specificItemID = extra.get('specificItemID', 0)
        blueprintInfo = extra.get('blueprintInfo', None)
        if blueprintInfo is None:
            if specificItemID:
                props = [localization.GetByLabel('UI/Agents/Items/SpecificItems')]
            else:
                return cfg.FormatConvert(const.UE_TYPEIDANDQUANTITY, typeID, quantity)
        else:
            props = []
            if specificItemID:
                props.append(localization.GetByLabel('UI/Agents/Items/SpecificItems'))
            if blueprintInfo.get('licensedProductionRunsRemaining', 0) > 1:
                runsRemaining = blueprintInfo.get('licensedProductionRunsRemaining', 0)
                props.append(localization.GetByLabel('UI/Agents/Items/BlueprintInfoMultirun', runsRemaining=runsRemaining))
            elif blueprintInfo.get('licensedProductionRunsRemaining', 0) == 1:
                props.append(localization.GetByLabel('UI/Agents/Items/BlueprintInfoSingleRun'))
            if blueprintInfo.get('copy', 0):
                props.append(localization.GetByLabel('UI/Agents/Items/BlueprintInfoCopy'))
            else:
                props.append(localization.GetByLabel('UI/Agents/Items/BlueprintInfoOriginal'))
            if blueprintInfo.get('materialLevel', 0):
                props.append(localization.GetByLabel('UI/Agents/Items/BlueprintInfoMaterialLevel', materialLevel=blueprintInfo.get('materialLevel', 0)))
            if blueprintInfo.get('productivityLevel', 0):
                props.append(localization.GetByLabel('UI/Agents/Items/ProductivityLevel', productivityLevel=blueprintInfo.get('productivityLevel', 0)))
        return localization.GetByLabel('UI/Agents/Items/NumItemsAndProperties', itemAndQuantity=cfg.FormatConvert(const.UE_TYPEIDANDQUANTITY, typeID, quantity), propertyList=localization.formatters.FormatGenericList(props))
    def OnTabOffices(self):
        scrolllist = []
        scrollHeaders = [localization.GetByLabel('UI/Corporations/Common/Offices'),
         localization.GetByLabel('UI/Station/OfficeNumber'),
         localization.GetByLabel('UI/Station/StationManagment/OfficeRentedBy'),
         localization.GetByLabel('UI/Station/StationManagment/RentStartDate'),
         localization.GetByLabel('UI/Station/StationManagment/RentPeriod'),
         localization.GetByLabel('UI/Station/StationManagment/RentPeriodCost'),
         localization.GetByLabel('UI/Station/StationManagment/RentBalanceDue')]
        for each in self.rentableItems:
            if each.typeID == const.typeOfficeFolder:
                pass
            else:
                log.LogError('Unknown typeID on Corporation Folder %s (typeID) %s (CorpID)' % each.typeID, eve.session.corpid)
                continue
            rname = ''
            if each.rentedToID is not None:
                rname = localization.GetByLabel('UI/Station/StationManagment/OfficesTableRentedBy', rentername=cfg.eveowners.Get(each.rentedToID).name)
            dataLabel = '<t>'.join([localization.GetByLabel('UI/Station/StationManagment/OfficesTablePubliclyAvailable'),
             util.FmtAmt(each.number),
             rname,
             util.FmtDate(each.startDate, 'ln') if each.startDate else u'',
             util.FmtAmt(each.rentPeriodInDays) if each.rentPeriodInDays else u'',
             util.FmtISK(each.periodCost) if each.periodCost else u'',
             util.FmtDate(each.balanceDueDate, 'ln') if each.balanceDueDate else u''])
            data = {'label': dataLabel,
             'checked': each.publiclyAvailable,
             'cfgname': 'offices',
             'retval': 'type%s_number%s' % (each.typeID, each.number),
             'OnChange': self.CheckBoxChange,
             'name': 'offices_type%s_number%s' % (each.typeID, each.number)}
            scrolllist.append(listentry.Get('Checkbox', data))

        self.ddxFunction = self.DDXTabOffices
        self.sr.scroll2.Load(fixedEntryHeight=24, contentList=scrolllist, headers=scrollHeaders)
Example #9
0
    def OnShipJumpCloneInstallationOffered(self, args):
        offeringCharID, targetCharID, shipID, b = (args[0], args[1], args[2],
                                                   args[3])
        self.cloneInstallOfferActive = 1
        cfg.eveowners.Prime([offeringCharID, targetCharID])
        offeringChar = cfg.eveowners.Get(offeringCharID)
        cfg.evelocations.Prime([shipID])
        ship = cfg.evelocations.Get(shipID)
        lm = self.GetLM()
        costs = lm.GetPriceForClone()
        ret = eve.Message(
            'JumpCloneInstallationOffered', {
                'offerer': offeringChar.name,
                'shipname': ship.name,
                'costs': util.FmtISK(costs)
            }, uiconst.YESNO)
        try:
            if ret == uiconst.ID_YES:
                lm.AcceptShipCloneInstallation()
            elif ret != uiconst.ID_CLOSE:
                lm.CancelShipCloneInstallation()
        except UserError as e:
            eve.Message(e.msg, e.dict)
            sys.exc_clear()

        self.cloneInstallOfferActive = 0
 def GetWantedTemplateData(self):
     topBounties = sm.GetService('bountySvc').GetTopPilotBounties()
     if not topBounties:
         return None
     chosenBounty = random.choice(topBounties)
     bountyAmount = util.FmtISK(chosenBounty.bounty, 0)
     data = util.KeyVal()
     data.introVideoPath = 'res:/video/cq/LOGO_SCOPE.bik'
     data.charID = chosenBounty.targetID
     data.heading = localization.GetByLabel(
         'UI/Station/Holoscreen/Wanted/BountyOffer')
     data.mainText = '<fontsize=30>' + localization.GetByLabel(
         'UI/Station/Holoscreen/Wanted/BountyPost') + '\n'
     data.mainText += '<fontsize=40><color=yellow>' + localization.GetByLabel(
         'UI/Station/Holoscreen/Wanted/WantedCharacter', wanted=data.charID)
     data.mainText += '</color>\n'
     data.mainText += '<fontsize=30>' + localization.GetByLabel(
         'UI/Station/Holoscreen/Wanted/BountyOffer') + '\n'
     data.mainText += '<fontsize=40>' + localization.GetByLabel(
         'UI/Station/Holoscreen/Wanted/BountyAmount',
         amount=bountyAmount) + '\n'
     data.mainText += '<fontsize=20>' + localization.GetByLabel(
         'UI/Station/Holoscreen/Wanted/WantedDisclaimer')
     data.bottomText = localization.GetByLabel(
         'UI/Station/Holoscreen/Wanted/MostWantedNewsFeed')
     data.isWanted = True
     data.wantedHeading = localization.GetByLabel(
         'UI/Station/Holoscreen/Wanted/Header')
     data.wantedText = localization.GetByLabel(
         'UI/Station/Holoscreen/Wanted/Warning')
     data.clickFunc = uicore.cmd.OpenBountyOffice
     data.clickFuncLabel = localization.GetByLabel(
         'UI/Station/Holoscreen/Wanted/ShowBountyOffice')
     return data
Example #11
0
def FmtISKWithDescription(isk, justDesc=False):
    iskFmt = util.FmtISK(isk, showFractionsAlways=0)
    isk = float(isk)
    if abs(isk) >= 1000000000:
        isk = long(isk / 10000000L)
        if justDesc:
            iskFmt = localization.GetByLabel(
                'UI/Contracts/Util/AmountInBillions', amount=isk / 100.0)
        else:
            iskFmt = localization.GetByLabel(
                'UI/Contracts/Util/AmountInBillionsDetailed',
                iskAmount=iskFmt,
                amount=isk / 100.0)
    elif abs(isk) >= 1000000:
        isk = long(isk / 10000L)
        if justDesc:
            iskFmt = localization.GetByLabel(
                'UI/Contracts/Util/AmountInMillions', amount=isk / 100.0)
        else:
            iskFmt = localization.GetByLabel(
                'UI/Contracts/Util/AmountInMillionDetailed',
                iskAmount=iskFmt,
                amount=isk / 100.0)
    elif abs(isk) >= 10000:
        isk = long(isk / 10L)
        if justDesc:
            iskFmt = localization.GetByLabel(
                'UI/Contracts/Util/AmountInThousands', amount=isk / 100.0)
        else:
            iskFmt = localization.GetByLabel(
                'UI/Contracts/Util/AmountInThousandsDetailed',
                iskAmount=iskFmt,
                amount=isk / 100.0)
    return iskFmt
Example #12
0
    def CreateMedal(self, title, description, graphics):
        roles = const.corpRoleDirector | const.corpRolePersonnelManager
        if session.corprole & roles == 0:
            raise UserError(
                'CrpAccessDenied', {
                    'reason':
                    localization.GetByLabel(
                        'UI/Corporations/CreateDecorationWindow/NeedRolesError'
                    )
                })
        if len(title) > const.medalMaxNameLength:
            raise UserError('MedalNameTooLong',
                            {'maxLength': str(const.medalMaxNameLength)})
        if len(description) > const.medalMaxDescriptionLength:
            raise UserError(
                'MedalDescriptionTooLong',
                {'maxLength': str(const.medalMaxDescriptionLength)})
        closeParent = True
        try:
            sm.RemoteSvc('corporationSvc').CreateMedal(title, description,
                                                       graphics)
        except UserError as e:
            if e.args[0] == 'ConfirmCreatingMedal':
                d = dict(cost=localization.GetByLabel(
                    'UI/Map/StarMap/lblBoldName',
                    name=util.FmtISK(e.dict.get('cost', 0))))
                ret = eve.Message(e.msg,
                                  d,
                                  uiconst.YESNO,
                                  suppress=uiconst.ID_YES)
                if ret == uiconst.ID_YES:
                    try:
                        sm.RemoteSvc('corporationSvc').CreateMedal(
                            title, description, graphics, True)
                    except UserError as e:
                        if e.args[0] in [
                                'MedalNameInvalid2', 'MedalDescriptionInvalid2'
                        ]:
                            eve.Message(e.msg, e.args[1])
                            closeParent = False
                        else:
                            eve.Message(e.msg)
                            closeParent = False

            elif e.args[0] == 'NotEnoughMoney':
                eve.Message(e.msg, e.dict)
                closeParent = False
            elif e.args[0] in ['MedalNameInvalid']:
                eve.Message(e.msg)
                closeParent = False
            elif e.args[0] in [
                    'MedalNameTooLong', 'MedalDescriptionTooLong',
                    'MedalDescriptionTooShort'
            ]:
                eve.Message(e.msg, e.args[1])
                closeParent = False
            else:
                raise
        finally:
            return closeParent
 def UpdateBounty(self):
     self.LogInfo('Updating bounty')
     currBounty = None
     if len(self.bountyInfo):
         m = self.bountyInfo[random.randint(0, len(self.bountyInfo) - 1)]
         currBounty = [m.targetID, cfg.eveowners.Get(m.targetID).ownerName, m.bounty]
     self.facePath = None
     if currBounty is not None:
         characterID, charName, bounty = currBounty
         serverLink = sm.RemoteSvc('charMgr').GetImageServerLink()
         if not serverLink:
             self.LogWarn("UpdateBounty: Couldn't find server Link")
             self.facePath = 'res:/UI/Texture/defaultFace.jpg'
             portraitURL = '<serverlink not found>'
             width = 256
             height = 32
         else:
             portraitURL = '%sCharacter/%d_256.jpg' % (serverLink, characterID)
             tex = self.photo.GetTextureFromURL(portraitURL, None)
             texture = tex[0]
             if 'none.dds' in texture.resPath:
                 self.facePath = None
                 self.LogError('Failed opening jpg picture for character', characterID)
             else:
                 self.facePath = texture.resPath
         amountText = util.FmtISK(bounty, showFractionsAlways=0)
         wantedText = localization.GetByLabel('UI/Inflight/Billboards/WantedCharacter', character=characterID, bountyAmount=amountText)
         self.RenderText(wantedText, 'bounty_caption')
         self.LogInfo('Updating billboard with bounty portrait', portraitURL, 'for character', charName, ', ID= ', characterID)
Example #14
0
 def PreLoad(node):
     data = node
     charinfo = data.Get('info', None) or cfg.eveowners.Get(data.charID)
     data.info = charinfo
     if data.GetLabel:
         data.label = data.GetLabel(data)
     elif not data.Get('label', None):
         label = charinfo.name
         if data.bounty:
             label += '<br>'
             label += localization.GetByLabel('UI/Common/BountyAmount',
                                              bountyAmount=util.FmtISK(
                                                  data.bounty.bounty, 0))
         elif data.killTime:
             label += '<br>' + localization.GetByLabel(
                 'UI/PeopleAndPlaces/ExpiresTime', expires=data.killTime)
         data.label = label
     groupID = evetypes.GetGroupID(data.info.typeID)
     data.invtype = data.info.typeID
     data.IsCharacter = groupID == const.groupCharacter
     data.IsCorporation = groupID == const.groupCorporation
     data.IsFaction = groupID == const.groupFaction
     data.IsAlliance = groupID == const.groupAlliance
     if data.IsCharacter and util.IsDustCharacter(data.charID):
         data.isDustCharacter = True
     if data.IsCorporation and not util.IsNPC(data.charID):
         logoData = cfg.corptickernames.Get(data.charID)
Example #15
0
 def GetForSaleText(self):
     amount = util.FmtISK(self.price, 0)
     saleText = localization.GetByLabel(
         'UI/CharacterSheet/CharacterSheetWindow/ForSale', amount=amount)
     if self.restrictedTo is None:
         availableText = localization.GetByLabel(
             'UI/CharacterSheet/CharacterSheetWindow/AvailableToAll')
     else:
         entityName = cfg.eveowners.Get(self.restrictedTo).name
         entityType = cfg.eveowners.Get(self.restrictedTo).typeID
         entityText = localization.GetByLabel(
             'UI/Contracts/ContractsWindow/ShowInfoLink',
             showInfoName=entityName,
             info=('showinfo', entityType, self.restrictedTo))
         if util.IsCorporation(
                 self.restrictedTo) and not util.IsNPC(self.restrictedTo):
             corpInfo = sm.RemoteSvc('corpmgr').GetPublicInfo(
                 self.restrictedTo)
             allianceID = corpInfo.allianceID
             if allianceID:
                 allianceName = cfg.allianceshortnames.Get(
                     allianceID).shortName
                 allianceType = const.typeAlliance
                 allianceText = localization.GetByLabel(
                     'UI/Contracts/ContractsWindow/ShowInfoLink',
                     showInfoName=allianceName,
                     info=('showinfo', allianceType, allianceID))
                 entityText += ' [%s]' % allianceText
         availableText = localization.GetByLabel(
             'UI/CharacterSheet/CharacterSheetWindow/AvailableToSpecific',
             entityName=entityText)
     return (saleText, availableText)
 def ActivateKillRightMenu(self, menuParent):
     cont = menuParent.AddContainer(align=uiconst.TOTOP,
                                    padding=const.defaultPadding)
     cont.GetEntryWidth = lambda mc=cont: 230
     charName = cfg.eveowners.Get(self.charID).name
     charNamelabel = localization.GetByLabel(
         'UI/Contracts/ContractsWindow/ShowInfoLink',
         showInfoName=charName,
         info=('showinfo', const.typeCharacterAmarr, self.charID))
     if self.price is not None:
         headerText = localization.GetByLabel(
             'UI/CharacterSheet/CharacterSheetWindow/BuyKillRight')
         explainText = localization.GetByLabel(
             'UI/CharacterSheet/CharacterSheetWindow/PurchaseLabel',
             charName=charNamelabel)
         priceText = localization.GetByLabel(
             'UI/CharacterSheet/CharacterSheetWindow/AcativationCost',
             costAmount=util.FmtISK(self.price, 0))
     else:
         headerText = localization.GetByLabel(
             'UI/CharacterSheet/CharacterSheetWindow/ActivateKillRight')
         explainText = localization.GetByLabel(
             'UI/CharacterSheet/CharacterSheetWindow/ActivateLabel',
             charName=charNamelabel)
         priceText = ''
     headerLabel = uicontrols.EveLabelLarge(text=headerText,
                                            parent=cont,
                                            align=uiconst.TOTOP,
                                            state=uiconst.UI_NORMAL,
                                            bold=True)
     helpTextCont = uiprimitives.Container(name='helpTextCont',
                                           parent=cont,
                                           align=uiconst.TOTOP,
                                           height=40,
                                           padTop=const.defaultPadding)
     helpText = uicontrols.EveLabelMedium(text=explainText,
                                          parent=helpTextCont,
                                          state=uiconst.UI_NORMAL,
                                          align=uiconst.TOTOP,
                                          color=(1.0, 0.0, 0.0, 0.8))
     buttonCont = uiprimitives.Container(name='buttonCont',
                                         parent=cont,
                                         align=uiconst.TOTOP,
                                         height=20)
     priceLabel = uicontrols.EveLabelMedium(text=priceText,
                                            parent=buttonCont)
     buttonLabel = localization.GetByLabel(
         'UI/CharacterSheet/CharacterSheetWindow/Activate')
     if self.price is None:
         self.func = 'ActivateKillRight'
         self.params = (self.killRightID, self.charID, self.shipID)
     else:
         self.func = 'BuyKillRight'
         self.params = (self.killRightID, self.charID, self.shipID,
                        self.price)
     self.activateBtn = uicontrols.Button(parent=buttonCont,
                                          label=buttonLabel,
                                          align=uiconst.TORIGHT,
                                          func=self.ActivateKillRight)
Example #17
0
    def RepairItems(self, items):
        totalcost = 0
        hasModule = False
        for item in items:
            damage = math.ceil(item.damage)
            totalcost = totalcost + math.ceil(
                item.damage) * item.costToRepairOneUnitOfDamage
            categoryID = evetypes.GetCategoryIDByGroup(item.groupID)
            if IsFittingModule(categoryID):
                hasModule = True

        btnSetup = {
            self.sr.selBtn: uiconst.UI_HIDDEN,
            self.sr.pickBtn: uiconst.UI_NORMAL
        }
        if hasModule:
            if eve.Message('RepairNonPartialConfirmation',
                           {'isk': util.FmtISK(totalcost)},
                           uiconst.YESNO) != uiconst.ID_YES:
                amount = None
            else:
                amount = {'qty': totalcost}
        else:
            amount = uix.QtyPopup(totalcost,
                                  0,
                                  totalcost,
                                  hint=localization.GetByLabel(
                                      'UI/Station/Repair/FullRepair',
                                      isk=totalcost),
                                  label=localization.GetByLabel(
                                      'UI/Station/Repair/RepairCostLabel'),
                                  digits=2)
        if amount is not None:
            itemIDs = []
            try:
                for item in items:
                    if self.invCache.IsItemLocked(item.itemID):
                        raise UserError(
                            'ItemLocked',
                            {'item': evetypes.GetName(item.typeID)})
                    if not self.invCache.TryLockItem(
                            item.itemID, 'lockUnassemblingItem', {}, 1):
                        raise UserError(
                            'ItemLocked',
                            {'item': evetypes.GetName(item.typeID)})
                    itemIDs.append(item.itemID)

                if len(itemIDs):
                    self.repairSvc.RepairItems(itemIDs, amount['qty'])
            finally:
                for itemID in itemIDs:
                    self.invCache.UnlockItem(itemID)

                sm.ScatterEvent('OnRepairDone', itemIDs)
                uthread.new(self.DisplayRepairQuote, self.GetAll())

        else:
            btnSetup[self.sr.repairAllBtn] = uiconst.UI_NORMAL
        self.DisplayButtons(btnSetup)
Example #18
0
 def GetMenu(self, *args):
     if isinstance(self.sr.node.invtype, tuple):
         typeID = self.sr.node.invtype[0]
     else:
         typeID = self.sr.node.invtype
     groupID = evetypes.GetGroupID(typeID)
     catID = evetypes.GetCategoryIDByGroup(groupID)
     graphicID = evetypes.GetGraphicID(typeID)
     graphicFileMenu = []
     if evetypes.Exists(typeID) and evetypes.GetGraphicID(
             typeID) is not None:
         graphic = GetGraphic(evetypes.GetGraphicID(typeID))
         if graphic is not None:
             graphicFile = GetGraphicFile(graphic)
             graphicFileMenu = [
                 [
                     'Copy graphicID (%s)' % graphicID,
                     lambda *x: blue.pyos.SetClipboardData(str(graphicID)),
                     ()
                 ],
                 [
                     'Copy graphicFile (%s)' % graphicFile,
                     lambda *x: blue.pyos.SetClipboardData(graphicFile), ()
                 ]
             ]
     averagePrice = inventorycommon.typeHelpers.GetAveragePrice(typeID)
     if averagePrice is None:
         averagePrice = 'n/a'
     else:
         averagePrice = util.FmtISK(averagePrice)
     menu = [[
         'Preview', lambda *x: uthread.new(
             sm.StartService('preview').PreviewType, typeID), ()
     ]]
     menu += graphicFileMenu
     menu += [[
         'Copy typeID (%s)' % typeID,
         lambda *x: blue.pyos.SetClipboardData(str(typeID)), ()
     ],
              [
                  'Copy groupID (%s)' % groupID,
                  lambda *x: blue.pyos.SetClipboardData(str(groupID)), ()
              ],
              [
                  'Copy categoryID (%s)' % catID,
                  lambda *x: blue.pyos.SetClipboardData(str(catID)), ()
              ],
              [
                  'Average price: %s' % averagePrice,
                  lambda *x: blue.pyos.SetClipboardData(averagePrice), ()
              ],
              [
                  'View market details', lambda *x: uthread.new(
                      sm.StartService('marketutils').ShowMarketDetails,
                      typeID, None), ()
              ], None]
     menu += sm.GetService('menu').GetGMTypeMenu(typeID)
     return menu
Example #19
0
 def _AnimateTransaction(self):
     blue.synchro.Sleep(self.initialDelay)
     difference = self.transaction
     totalIterations = 20
     for i in range(totalIterations):
         increment = (i + 1) / (1.0 * totalIterations)
         value = self.startBalance + difference * increment
         self.balanceValueLabel.SetText(util.FmtISK(value, showFractionsAlways=self.showFractions))
         blue.synchro.Sleep(25)
 def _GetActionButtons(self):
     typeObj = cfg.invtypes.Get(self.pin.typeID)
     btns = [
         util.KeyVal(id=planetCommon.PANEL_DECOMMISSION,
                     panelCallback=self.PanelDecommissionPin,
                     hint=localization.GetByLabel(
                         'UI/PI/Common/ObsoletePinReimbursementHint',
                         pinName=typeObj.typeName,
                         iskAmount=util.FmtISK(typeObj.basePrice)))
     ]
     return btns
 def RefreshCostText(self):
     cost = self.GetCost()
     if cost is not None:
         costStr = util.FmtISK(cost)
         if cost > 0:
             costStr = '<color=red>%s</color>' % costStr
         self.sr.transferCostLabel.text = localization.GetByLabel('UI/PI/Common/TransferCost', iskAmount=costStr)
     if self.taxRate is not None:
         self.windowCaption.SetSubcaption(localization.GetByLabel('UI/PI/Common/CustomsOfficeTaxRate', taxRate=self.taxRate * 100))
     else:
         self.windowCaption.SetSubcaption(localization.GetByLabel('UI/PI/Common/CustomsOfficeAccessDenied'))
Example #22
0
def DeclareWarAgainst(againstID):
    cost = sm.GetService('war').GetCostOfWarAgainst(againstID)
    allianceLabel = localization.GetByLabel('UI/Common/Alliance')
    svc = sm.GetService('alliance') if session.allianceid else sm.GetService(
        'corp')
    messageName = 'WarDeclareConfirmAlliance' if session.allianceid is not None else 'WarDeclareConfirmCorporation'
    if eve.Message(
            messageName, {
                'against': cfg.eveowners.Get(againstID).ownerName,
                'price': util.FmtISK(cost, showFractionsAlways=0)
            }, uiconst.YESNO) == uiconst.ID_YES:
        svc.DeclareWarAgainst(againstID, cost)
Example #23
0
 def GetMenu(self, *args):
     row = self.sr.node.invtype
     catID = cfg.invgroups.Get(row.groupID).categoryID
     it = cfg.invtypes.GetIfExists(row.typeID)
     graphicFileMenu = []
     if it.graphicID is not None:
         graphic = cfg.graphics.GetIfExists(it.graphicID)
         if graphic is not None:
             graphicFile = getattr(graphic, 'graphicFile', 'None')
             graphicFileMenu = [[
                 'Copy graphicID (%s)' % row.graphicID,
                 lambda *x: blue.pyos.SetClipboardData(str(row.graphicID)),
                 ()
             ],
                                [
                                    'Copy graphicFile (%s)' % graphicFile,
                                    lambda *x: blue.pyos.SetClipboardData(
                                        graphicFile), ()
                                ]]
     averagePrice = cfg.invtypes.Get(row.typeID).averagePrice
     if averagePrice is None:
         averagePrice = 'n/a'
     else:
         averagePrice = util.FmtISK(averagePrice)
     menu = [[
         'Preview', lambda *x: uthread.new(
             sm.StartService('preview').PreviewType, row.typeID), ()
     ]]
     menu += graphicFileMenu
     menu += [[
         'Copy typeID (%s)' % row.typeID,
         lambda *x: blue.pyos.SetClipboardData(str(row.typeID)), ()
     ],
              [
                  'Copy groupID (%s)' % row.groupID,
                  lambda *x: blue.pyos.SetClipboardData(str(row.groupID)),
                  ()
              ],
              [
                  'Copy categoryID (%s)' % catID,
                  lambda *x: blue.pyos.SetClipboardData(str(catID)), ()
              ],
              [
                  'Average price: %s' % averagePrice,
                  lambda *x: blue.pyos.SetClipboardData(averagePrice), ()
              ],
              [
                  'View market details', lambda *x: uthread.new(
                      sm.StartService('marketutils').ShowMarketDetails, row.
                      typeID, None), ()
              ], None]
     menu += sm.GetService('menu').GetGMTypeMenu(row.typeID)
     return menu
Example #24
0
    def PostValidateCreatePin(self, charID, typeID, latitude, longitude):
        typeObj = cfg.invtypes.Get(typeID)
        if typeObj.groupID != const.groupCommandPins:
            totalIskCost = self.cumulativePinCreationCost + typeObj.basePrice
            currentBalance = sm.GetService('wallet').GetWealth()
            if totalIskCost > currentBalance:
                raise UserError('CannotBuildNotEnoughCash',
                                {'cost': util.FmtISK(typeObj.basePrice)})
            self.cumulativePinCreationCost += typeObj.basePrice
        else:
            planetRows = sm.GetService('planetSvc').GetMyPlanets()
            if len(planetRows) > 0 and sm.GetService('skills').HasSkill(
                    const.typeOmnipotent) is None:
                deploymentSkill = sm.GetService('skills').HasSkill(
                    const.typeInterplanetaryConsolidation)
                if deploymentSkill is None:
                    raise UserError('CannotPlaceCommandCenterNotEnoughSkill',
                                    {'maxPlanets': 1})
                elif deploymentSkill.skillLevel < len(planetRows):
                    raise UserError('CannotPlaceCommandCenterNotEnoughSkill',
                                    {'maxPlanets': len(planetRows)})
            if session.solarsystemid2 not in sm.GetService(
                    'facwar').GetFacWarSystems():
                sovInfo = sm.GetService('sov').GetSystemSovereigntyInfo(
                    self.planet.solarSystemID)
                allianceID = sovInfo.allianceID if sovInfo else None
                if allianceID is not None and allianceID != session.allianceid:
                    raise UserError('SovPreventsCommandPin')
        requiredSkills = sm.GetService('info').GetRequiredSkills(typeID)
        lackingSkills = []
        for skillTypeID, level in requiredSkills:
            myLevel = sm.GetService('skills').HasSkill(skillTypeID)
            if myLevel is None or myLevel.skillLevel < level:
                if level:
                    levelTxt = localization.GetByLabel(
                        'UI/PI/Common/SkillLevel', skillLevel=level)
                else:
                    levelTxt = ''
                lacked = localization.GetByLabel(
                    'UI/PI/Common/SkillNameAndLevel',
                    skillName=cfg.invtypes.Get(skillTypeID).name,
                    skillLevel=levelTxt)
                lackingSkills.append(lacked)

        if len(lackingSkills) > 0:
            raise UserError(
                'CannotPlacePinNotEnoughSkill', {
                    'requiredSkills': ', '.join(lackingSkills),
                    'itemName': cfg.invtypes.Get(typeID).name
                })
Example #25
0
 def UpdateCounter(self, orders=None):
     if orders is None:
         current = 0
     else:
         current = len(orders)
     maxCount = self.limits['cnt']
     self.sr.counter.text = localization.GetByLabel(
         'UI/Market/Orders/OrdersRemaining',
         remaining=maxCount - current,
         maxCount=maxCount,
         escrow=util.FmtISK(self.totalEscrow, showFractionsAlways=False),
         totalLeft=util.FmtISK(self.totalLeft, showFractionsAlways=False),
         feeLimit=const.marketCommissionPercentage if not orders else round(
             sum((self.limits.GetBrokersFeeForLocation(o.stationID) * 100
                  for o in orders)) / len(orders), 2),
         accLimit=round(self.limits['acc'], 2) * 100,
         income=util.FmtISK(self.totalIncome, showFractionsAlways=False),
         expenses=util.FmtISK(self.totalExpenses,
                              showFractionsAlways=False))
     askLimit = self.limits['ask']
     bidLimit = self.limits['bid']
     modLimit = self.limits['mod']
     visLimit = self.limits['vis']
     if askLimit == -1 and bidLimit == -1 and modLimit == -1 and visLimit == -1:
         self.sr.counter2.text = localization.GetByLabel(
             'UI/Market/Orders/OrderRangesWithoutRemote')
     else:
         self.sr.counter2.text = localization.GetByLabel(
             'UI/Market/Orders/OrderRanges',
             askLimit=self.GetLimitText(askLimit),
             bidLimit=self.GetLimitText(bidLimit),
             modLimit=self.GetLimitText(modLimit),
             visLimit=self.GetLimitText(visLimit))
     self.sr.counter.parent.height = max(
         60, self.sr.counter.textheight + const.defaultPadding * 2,
         self.sr.counter2.textheight + const.defaultPadding * 2)
Example #26
0
 def GiveMedalToCharacters(self, medalID, recipientID, reason=''):
     roles = const.corpRoleDirector | const.corpRolePersonnelManager
     if session.corprole & roles == 0:
         raise UserError(
             'CrpAccessDenied', {
                 'reason':
                 localization.GetByLabel(
                     'UI/Corporations/CreateDecorationWindow/NeedRolesError'
                 )
             })
     if reason == '':
         ret = uiutil.NamePopup(
             localization.GetByLabel(
                 'UI/Corporations/CorporationWindow/Members/AwardReasonTitle'
             ),
             localization.GetByLabel(
                 'UI/Corporations/CorporationWindow/Members/PromptForReason'
             ),
             reason,
             maxLength=200)
         if ret:
             reason = ret
         else:
             return
     if type(recipientID) == types.IntType:
         recipientID = [recipientID]
     try:
         sm.RemoteSvc('corporationSvc').GiveMedalToCharacters(
             medalID, recipientID, reason)
     except UserError as e:
         if e.args[0].startswith('ConfirmGivingMedal'):
             d = dict(amount=len(recipientID),
                      members=localization.GetByLabel(
                          'UI/Corporations/MedalsToUsers',
                          numMembers=len(recipientID)),
                      cost=util.FmtISK(e.dict.get('cost', 0)))
             ret = eve.Message(e.msg,
                               d,
                               uiconst.YESNO,
                               suppress=uiconst.ID_YES)
             if ret == uiconst.ID_YES:
                 sm.RemoteSvc('corporationSvc').GiveMedalToCharacters(
                     medalID, recipientID, reason, True)
         elif e.args[0] == 'NotEnoughMoney':
             eve.Message(e.msg, e.dict)
         else:
             raise
Example #27
0
    def _ReloadScrolls(self):
        scrolllist = []
        for typeID, amount in self.contentsCommodities.iteritems():
            data = util.KeyVal()
            data.label = '<t>%s<t>%s' % (cfg.invtypes.Get(typeID).name, amount)
            data.typeID = typeID
            data.itemID = None
            data.getIcon = True
            sortBy = amount
            scrolllist.append((sortBy, listentry.Get('Item', data=data)))

        scrolllist = uiutil.SortListOfTuples(scrolllist)
        self.contentsScroll.Load(
            contentList=scrolllist,
            noContentHint=localization.GetByLabel(
                'UI/PI/Common/StorehouseIsEmpty'),
            headers=[
                '',
                localization.GetByLabel('UI/PI/Common/Type'),
                localization.GetByLabel('UI/Common/Quantity')
            ])
        scrolllist = []
        for typeID, amount in self.payloadCommodities.iteritems():
            data = util.KeyVal()
            data.label = '<t>%s<t>%s' % (cfg.invtypes.Get(typeID).name, amount)
            data.typeID = typeID
            data.itemID = None
            data.getIcon = True
            sortBy = amount
            scrolllist.append((sortBy, listentry.Get('Item', data=data)))

        scrolllist = uiutil.SortListOfTuples(scrolllist)
        self.payloadScroll.Load(
            contentList=scrolllist,
            noContentHint=localization.GetByLabel(
                'UI/PI/Common/PayloadIsEmpty'),
            headers=[
                '',
                localization.GetByLabel('UI/PI/Common/Type'),
                localization.GetByLabel('UI/Common/Quantity')
            ])
        self.costText.text = localization.GetByLabel(
            'UI/PI/Common/LaunchCost',
            iskAmount=util.FmtISK(
                self.pin.GetExportTax(self.payloadCommodities)))
Example #28
0
    def PostValidateCreatePin(self, charID, typeID, latitude, longitude):
        skills = sm.GetService('skills').GetSkills()
        if evetypes.GetGroupID(typeID) != const.groupCommandPins:
            basePrice = evetypes.GetBasePrice(typeID)
            totalIskCost = self.cumulativePinCreationCost + basePrice
            currentBalance = sm.GetService('wallet').GetWealth()
            if totalIskCost > currentBalance:
                raise UserError('CannotBuildNotEnoughCash',
                                {'cost': util.FmtISK(basePrice)})
            self.cumulativePinCreationCost += basePrice
        else:
            planetRows = sm.GetService('planetSvc').GetMyPlanets()
            if len(planetRows) > 0 and skills.get(const.typeOmnipotent,
                                                  None) is None:
                deploymentSkill = skills.get(
                    const.typeInterplanetaryConsolidation, None)
                if deploymentSkill is None:
                    raise UserError('CannotPlaceCommandCenterNotEnoughSkill',
                                    {'maxPlanets': 1})
                elif deploymentSkill.skillLevel < len(planetRows):
                    raise UserError('CannotPlaceCommandCenterNotEnoughSkill',
                                    {'maxPlanets': len(planetRows)})
        requiredSkills = sm.GetService('skills').GetRequiredSkills(typeID)
        lackingSkills = []
        for skillTypeID, level in requiredSkills.iteritems():
            skillRec = skills.get(skillTypeID, None)
            myLevel = getattr(skillRec, 'skillLevel', -1)
            if myLevel < level:
                if level:
                    levelTxt = localization.GetByLabel(
                        'UI/PI/Common/SkillLevel', skillLevel=level)
                else:
                    levelTxt = ''
                lacked = localization.GetByLabel(
                    'UI/PI/Common/SkillNameAndLevel',
                    skillName=evetypes.GetName(skillTypeID),
                    skillLevel=levelTxt)
                lackingSkills.append(lacked)

        if len(lackingSkills) > 0:
            raise UserError(
                'CannotPlacePinNotEnoughSkill', {
                    'requiredSkills': ', '.join(lackingSkills),
                    'itemName': evetypes.GetName(typeID)
                })
Example #29
0
def zhFmtISKWithDescription(isk, justDesc = False):
    iskFmt = util.FmtISK(isk, showFractionsAlways=0)
    
    if abs(isk) >= 1000000000000:
        cnISKfmt = u"%s \u4e07\u4ebf ISK" % FormatDigit(isk / 10000000000)
        iskFmt = u"%s (%s)" % (iskFmt, cnISKfmt)
    elif abs(isk) >= 100000000:
        cnISKfmt = u"%s \u4ebf ISK" % FormatDigit(isk / 1000000)
        iskFmt = u"%s (%s)" % (iskFmt, cnISKfmt)
    elif abs(isk) >= 10000:
        cnISKfmt = u"%s \u4e07 ISK" % FormatDigit(isk / 100)
        iskFmt = u"%s (%s)" % (iskFmt, cnISKfmt)
    else:
        cnISKfmt = iskFmt
    
    if justDesc:
        return cnISKfmt
    else:
        return iskFmt
Example #30
0
 def OnUpgradeBarValueChanged(self, oldValue, newValue):
     self.newLevel = newValue
     txt = localization.GetByLabel(
         'UI/PI/Common/UpgradeFromLevelXToY',
         currLevel=util.IntToRoman(self.currLevel + 1),
         newLevel=util.IntToRoman(self.newLevel + 1))
     skill = sm.GetService('skills').GetMySkillsFromTypeID(
         const.typeCommandCenterUpgrade)
     commandCenterSkillLevel = 0
     if skill is not None:
         commandCenterSkillLevel = skill.skillLevel
     if commandCenterSkillLevel < newValue:
         skillType = cfg.invtypes.Get(const.typeCommandCenterUpgrade)
         hint = localization.GetByLabel(
             'UI/PI/Common/NeedSkillToUpgrade',
             skillLevel=util.IntToRoman(newValue),
             skillName=skillType.typeName)
         txt = localization.GetByLabel(
             'UI/PI/Common/InsufficientSkillForUpgrade')
         self.upgradeButton.Disable()
     else:
         hint = ''
         self.upgradeButton.Enable()
     self.upgradeText.SetCaption(txt)
     self.upgradeText.hint = hint
     newPowerOutput = planetCommon.GetPowerOutput(self.newLevel)
     self.upgradePowerGauge.SetValue(gaugeNum=1,
                                     value=newPowerOutput /
                                     self.maxPowerOutput)
     self.upgradePowerGauge.hint = self._GetPowerGaugeHint(newPowerOutput)
     self._SetPowerGaugeSubText(newPowerOutput)
     newCPUOutput = planetCommon.GetCPUOutput(self.newLevel)
     self.upgradeCPUGauge.SetValue(gaugeNum=1,
                                   value=newCPUOutput / self.maxCPUOutput)
     self.upgradeCPUGauge.hint = self._GetCPUGaugeHint(newCPUOutput)
     self._SetCPUGaugeSubText(newCPUOutput)
     iskCost = util.FmtISK(planetCommon.GetUpgradeCost(
         self.currLevel, self.newLevel),
                           showFractionsAlways=0)
     self.costText.SetSubtext(iskCost)