Ejemplo n.º 1
0
def FmtAmt(amount, fmt='ln', showFraction=0, *args):
    if amount == None:
        amount = 0
    orgamount = amount
    try:
        amount = long(amount)
    except:
        raise RuntimeError('Amount (%s) is not an integer' % str(amount))

    if fmt[0] == 'l':
        amt = orgamount
        if showFraction == 0:
            amt = amount
        return localizationUtil.FormatNumeric(amt,
                                              useGrouping=True,
                                              decimalPlaces=showFraction)
    if fmt[0] == 's':
        amt = amount
        val = abs(amount)
        labelPathDict = {
            ('thousand', 'short'):
            '/Carbon/UI/Common/Formatting/FmtThousandShort',
            ('thousand', 'long'):
            '/Carbon/UI/Common/Formatting/FmtThousandLong',
            ('million', 'short'):
            '/Carbon/UI/Common/Formatting/FmtMillionShort',
            ('million', 'long'): '/Carbon/UI/Common/Formatting/FmtMillionLong',
            ('billion', 'short'):
            '/Carbon/UI/Common/Formatting/FmtBillionShort',
            ('billion', 'long'): '/Carbon/UI/Common/Formatting/FmtBillionLong',
            ('trillion', 'short'):
            '/Carbon/UI/Common/Formatting/FmtTrillionShort',
            ('trillion', 'long'):
            '/Carbon/UI/Common/Formatting/FmtTrillionLong'
        }
        if fmt[1] == 'l':
            labelLength = 'long'
        else:
            labelLength = 'short'
        if val >= 100000000000000.0:
            raise UserError('WhatKindOfAmountIsThis', {'amount': amount})
        if val < 10000.0:
            return localizationUtil.FormatNumeric(amt, useGrouping=True)
        if val < 100000.0:
            amt = float(amt) / long(1000.0)
            labelPath = labelPathDict.get(('thousand', labelLength))
        elif val < 100000000.0:
            amt = float(amt) / long(1000000.0)
            labelPath = labelPathDict.get(('million', labelLength))
        elif val < 100000000000.0:
            amt = float(amt) / long(1000000000.0)
            labelPath = labelPathDict.get(('billion', labelLength))
        elif val < 100000000000000.0:
            amt = float(amt) / long(1000000000000.0)
            labelPath = labelPathDict.get(('trillion', labelLength))
        return localization.GetByLabel(labelPath, amount=amt)
    return localizationUtil.LocalizationSafeString(orgamount)
Ejemplo n.º 2
0
def FmtTime(time):
    hours = localizationUtil.FormatNumeric(time / const.HOUR, leadingZeroes=2)
    mins = localizationUtil.FormatNumeric(time % const.HOUR / const.MIN,
                                          leadingZeroes=2)
    secs = localizationUtil.FormatNumeric(time % const.MIN / const.SEC,
                                          leadingZeroes=2)
    return localization.GetByLabel(
        '/Carbon/UI/Common/DateTimeQuantity/DateTimeShort3Elements',
        value1=hours,
        value2=mins,
        value3=secs)
Ejemplo n.º 3
0
    def Load(self, *args):
        if not eve.session.charid or not self or self.destroyed:
            return
        dogmaLM = self.godma.GetDogmaLM()
        attrDict = dogmaLM.GetCharacterBaseAttributes()
        unspentPts = const.respecTotalRespecPoints
        for x in xrange(0, 5):
            attr = self.attributes[x]
            if attr in attrDict:
                attrValue = attrDict[attr]
                if attrValue > const.respecMaximumAttributeValue:
                    attrValue = const.respecMaximumAttributeValue
                if attrValue < const.respecMinimumAttributeValue:
                    attrValue = const.respecMinimumAttributeValue
                self.currentAttributes[attr] = attrValue
                self.respecBar[x].SetValue(attrValue -
                                           const.respecMinimumAttributeValue)
                unspentPts -= attrValue
            modifiers = self.skillHandler.GetCharacterAttributeModifiers(attr)
            implantBonus = 0
            for itemID, typeID, operation, value in modifiers:
                categoryID = cfg.invtypes.Get(typeID).categoryID
                if categoryID == const.categoryImplant:
                    implantBonus += value

            totalAttributesText = localizationUtil.FormatNumeric(
                int(self.currentAttributes[attr]) + implantBonus,
                decimalPlaces=0)
            self.totalLabels[
                x].text = '<right>%s</right>' % totalAttributesText
            self.implantModifier[x] = implantBonus
            label, icon = self.implantLabels[x]
            if implantBonus == 0:
                icon.SetAlpha(0.5)
                label.text = localization.GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/Attributes/ImplantBonusZero'
                )
                label.SetAlpha(0.5)
            else:
                label.text = localization.GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/Attributes/ImplantBonus',
                    implantBonus=int(implantBonus))

        if not self.readOnly:
            self.unspentPts = unspentPts
            self.sr.unassignedBar.SetValue(unspentPts)
            unspentPtsText = localizationUtil.FormatNumeric(self.unspentPts,
                                                            decimalPlaces=0)
            self.availableLabel.text = '<right>%s</right>' % unspentPtsText
            if self.unspentPts <= 0:
                self.sr.saveWarningText.state = uiconst.UI_HIDDEN
            else:
                self.sr.saveWarningText.state = uiconst.UI_DISABLED
Ejemplo n.º 4
0
    def CreateWindow(self):
        toppar = uicls.Container(name='options', parent=self, align=uiconst.TOTOP, height=54)
        sidepar = uicls.Container(name='sidepar', parent=toppar, align=uiconst.TORIGHT, width=54)
        icon = uicls.Button(parent=toppar, icon='ui_77_32_41', iconSize=20, align=uiconst.BOTTOMRIGHT, left=6, func=self.Navigate, args=1)
        icon.hint = localization.GetByLabel('UI/Common/Next')
        self.sr.fwdBtn = icon
        icon = uicls.Button(parent=toppar, icon='ui_77_32_42', iconSize=20, align=uiconst.BOTTOMRIGHT, left=26, func=self.Navigate, args=-1)
        icon.hint = localization.GetByLabel('UI/Common/Previous')
        self.sr.backBtn = icon
        uicls.Container(name='push', parent=toppar, align=uiconst.TOTOP, height=6)
        optlist = [[localizationUtil.FormatNumeric(10), 10],
         [localizationUtil.FormatNumeric(25), 25],
         [localizationUtil.FormatNumeric(50), 50],
         [localizationUtil.FormatNumeric(100), 100],
         [localizationUtil.FormatNumeric(500), 500]]
        countcombo = uicls.Combo(label=localization.GetByLabel('UI/Common/PerPage'), parent=toppar, options=optlist, name='membersperpage', callback=self.OnComboChange, width=92, pos=(2, 36, 0, 0))
        self.sr.MembersPerPage = countcombo
        viewOptionsList1 = [[localization.GetByLabel('UI/Corporations/Common/Roles'), VIEW_ROLES], [localization.GetByLabel('UI/Corporations/Common/GrantableRoles'), VIEW_GRANTABLE_ROLES], [localization.GetByLabel('UI/Corporations/Common/Titles'), VIEW_TITLES]]
        viewOptionsList2 = []
        for roleGrouping in self.sr.roleGroupings.itervalues():
            viewOptionsList2.append([localization.GetByMessageID(roleGrouping.roleGroupNameID), roleGrouping.roleGroupID])

        i = 0
        for optlist, label, config, defval in [(viewOptionsList1,
          localization.GetByLabel('UI/Common/ViewMode'),
          'viewtype',
          1000), (viewOptionsList2,
          localization.GetByLabel('UI/Common/Type'),
          'rolegroup',
          None)]:
            combo = uicls.Combo(label=label, parent=toppar, options=optlist, name=config, callback=self.OnComboChange, width=146, pos=(countcombo.left + countcombo.width + 6 + i * 152,
             countcombo.top,
             0,
             0))
            setattr(self.sr, config + 'Combo', combo)
            i += 1

        self.sr.scroll = uicls.Scroll(name='journal', parent=self, padding=(const.defaultPadding,
         const.defaultPadding,
         const.defaultPadding,
         const.defaultPadding))
        self.sr.scroll.OnColumnChanged = self.OnColumnChanged
        buttons = [[localization.GetByLabel('UI/Common/Buttons/SaveChanges'),
          self.SaveChanges,
          (),
          81]]
        btns = uicls.ButtonGroup(btns=buttons)
        self.children.insert(0, btns)
Ejemplo n.º 5
0
 def UpdateMyLPToIHubLabel(self, refreshTax=False):
     lpAmount = self.donateAmountEdit.GetValue()
     donationTax = facwarCommon.GetDonationTax(session.warfactionid)
     tax = math.ceil(donationTax * lpAmount)
     if self.myLPToIhubLabel:
         self.myLPToIhubLabel.Close()
     self.myLPToIhubLabel = uicls.Label(
         name='myLPToIhubLabel',
         parent=self.bottomTaxCont,
         align=uiconst.TOLEFT,
         idx=0,
         text=localization.GetByLabel(
             'UI/FactionWarfare/IHub/TotalDonated',
             loyaltyPoints=localizationUtil.FormatNumeric(
                 int(lpAmount - tax), useGrouping=True)))
     if refreshTax:
         if self.myLPTaxLabel:
             self.myLPTaxLabel.Close()
         self.myLPTaxLabel = uicls.Label(
             name='myLPTaxLabel',
             parent=self.bottomTaxCont,
             text=localization.GetByLabel(
                 'UI/FactionWarfare/IHub/maintenanceTax',
                 tax=int(donationTax * 100)),
             align=uiconst.TOLEFT,
             state=uiconst.UI_NORMAL,
             left=5)
     self.myLPTaxLabel.hint = localization.GetByLabel(
         'UI/FactionWarfare/LPAmount', lps=tax)
Ejemplo n.º 6
0
 def UpdateValues(self):
     friendProportion = self.friendPoints / self.totalPoints
     foeProportion = self.foePoints / self.totalPoints
     self.friendBar.width = friendProportion
     self.foeBar.width = foeProportion
     self.friendBar.hint = localization.GetByLabel('UI/FactionWarfare/WarzoneProgress', points=self.friendPoints, pointsTotal=int(self.totalPoints))
     self.foeBar.hint = localization.GetByLabel('UI/FactionWarfare/WarzoneProgress', points=self.foePoints, pointsTotal=int(self.totalPoints))
     self.friendPointer.left = SIDE_WIDTH + (1.0 - 2 * SIDE_WIDTH) * friendProportion
     self.foePointer.left = 1.0 - SIDE_WIDTH - (1.0 - 2 * SIDE_WIDTH) * foeProportion
     self.friendPointerTxt.text = '%s%%' % localizationUtil.FormatNumeric(100 * friendProportion, decimalPlaces=1)
     self.foePointerTxt.text = '%s%%' % localizationUtil.FormatNumeric(100 * foeProportion, decimalPlaces=1)
     self.ConstructFriendSquares(friendProportion)
     self.ConstructFoeSquares(foeProportion)
     iconID = self.friendIcon.GetFactionIconID(self.friendID, True)
     self.friendIcon.LoadIcon(iconID, True)
     iconID = self.foeIcon.GetFactionIconID(self.foeID, True)
     self.foeIcon.LoadIcon(iconID, True)
Ejemplo n.º 7
0
 def UpdateLabel(self):
     if self.label:
         if self.SetSliderLabel:
             self.SetSliderLabel(self.label, self.sliderID, self.displayName, self.GetValue())
         elif self.displayName:
             self.label.text = self.displayName
         else:
             self.label.text = localizationUtil.FormatNumeric(self.GetValue(), decimalPlaces=2)
Ejemplo n.º 8
0
 def EncodeOutput(self, otext):
     if not otext:
         return ''
     if self.integermode or self.floatmode:
         elem = [each for each in otext if each not in ('-', '.')]
         if not len(elem):
             return ''
     if self.integermode:
         return localizationUtil.FormatNumeric(long(float(otext)),
                                               useGrouping=True)
     if self.floatmode:
         decimalPlaces = self.floatmode[2]
         return localizationUtil.FormatNumeric(float(otext),
                                               useGrouping=True,
                                               decimalPlaces=decimalPlaces)
     if not isinstance(otext, basestring):
         otext = str(otext)
     return otext
Ejemplo n.º 9
0
 def Startup(self, now, withTime = False, timeparts = 4, startYear = None, yearRange = None):
     self.timeparts = timeparts
     if now is None:
         now = time.gmtime()
     if startYear is None:
         startYear = const.calendarStartYear
     year = max(startYear, now[0])
     month = now[1]
     day = now[2]
     left = 0
     if yearRange is None:
         yRange = year - startYear + 1
     else:
         yRange = yearRange
     yearops = [ (localizationUtil.FormatNumeric(startYear + i, decimalPlaces=0), startYear + i) for i in xrange(yRange) ]
     self.ycombo = uicls.Combo(parent=self, label=localization.GetByLabel('UI/Common/DateWords/Year'), options=yearops, name='year', select=year, callback=self.OnComboChange, pos=(left,
      0,
      0,
      0), align=uiconst.TOPLEFT, adjustWidth=True)
     left += self.ycombo.width + 4
     monthops = [ (self.months[i], i + 1) for i in xrange(12) ]
     self.mcombo = uicls.Combo(parent=self, label=localization.GetByLabel('UI/Common/DateWords/Month'), options=monthops, name='month', select=month, callback=self.OnComboChange, pos=(left,
      0,
      0,
      0), align=uiconst.TOPLEFT, adjustWidth=True)
     left += self.mcombo.width + 4
     firstday, numdays = calendar.monthrange(year, month)
     dayops = [ (localizationUtil.FormatNumeric(i + 1, decimalPlaces=0), i + 1) for i in xrange(numdays) ]
     self.dcombo = uicls.Combo(parent=self, label=localization.GetByLabel('UI/Common/DateWords/Day'), options=dayops, name='day', select=day, callback=self.OnComboChange, pos=(left,
      0,
      0,
      0), align=uiconst.TOPLEFT, adjustWidth=True)
     self.width = self.dcombo.left + self.dcombo.width
     self.height = self.ycombo.height
     if withTime:
         index = self.GetTimeIndex(now)
         hourops = self.GetTimeOptions()
         left += self.dcombo.width + 4
         self.hcombo = uicls.Combo(parent=self, label=localization.GetByLabel('UI/Common/DateWords/Time'), options=hourops, name='time', select=index, callback=self.OnComboChange, pos=(left,
          0,
          0,
          0), align=uiconst.TOPLEFT, adjustWidth=True)
         self.width = self.hcombo.left + self.hcombo.width
         self.height = self.hcombo.height
Ejemplo n.º 10
0
    def OnMemberBoxClick(self, oldValue, newValue):
        if oldValue is None or oldValue == newValue:
            return
        if self.readOnly:
            return
        self.unspentPts -= newValue - oldValue
        self.sr.unassignedBar.SetValue(self.unspentPts)
        unspentPtsText = localizationUtil.FormatNumeric(self.unspentPts,
                                                        decimalPlaces=0)
        self.availableLabel.text = '<right>%s</right>' % unspentPtsText
        for x in xrange(0, 5):
            totalPts = const.respecMinimumAttributeValue + self.respecBar[
                x].GetValue() + self.implantModifier[x]
            totalPtsText = localizationUtil.FormatNumeric(int(totalPts),
                                                          decimalPlaces=0)
            self.totalLabels[x].text = '<right>%s</right>' % totalPtsText

        if self.unspentPts <= 0:
            self.sr.saveWarningText.state = uiconst.UI_HIDDEN
Ejemplo n.º 11
0
 def GetLPOwnedLabel(self):
     amount = self.GetMyLPs()
     factionID = sm.GetService('facwar').GetSystemOccupier(
         session.solarsystemid)
     militiaCorpID = sm.GetService('facwar').GetFactionMilitiaCorporation(
         factionID)
     return localization.GetByLabel(
         'UI/FactionWarfare/IHub/LPOwned',
         LPCount=localizationUtil.FormatNumeric(amount, useGrouping=True),
         corpName=cfg.eveowners.Get(militiaCorpID).name)
Ejemplo n.º 12
0
 def OnTabGeneral(self):
     scrolllist = []
     canEditBase = corputil.CanEditBase(self.playerIsCEO, self.userIsCEO, eve.session.corprole & const.corpRoleDirector == const.corpRoleDirector)
     if not self.title:
         self.title = ''
     if canEditBase:
         scrolllist.append(listentry.Get('Edit', {'OnReturn': None,
          'label': localization.GetByLabel('UI/Corporations/EditMemberDialog/CorpMemberTitleCaption'),
          'setValue': self.title,
          'name': 'general_title',
          'lines': 1,
          'maxLength': 100}))
         data = {'options': self.bases,
          'label': localization.GetByLabel('UI/Corporations/EditMemberDialog/CorpMemberBaseCaption'),
          'cfgName': 'baseID',
          'setValue': self.baseID,
          'OnChange': self.OnComboChange,
          'name': 'baseID'}
         scrolllist.append(listentry.Get('Combo', data))
     else:
         scrolllist.append(listentry.Get('LabelText', {'label': localization.GetByLabel('UI/Corporations/EditMemberDialog/CorpMemberTitleCaption'),
          'text': self.title}))
         if self.baseID:
             baseText = localization.GetByLabel('UI/Corporations/EditMemberDialog/CorpMemberBase', station=self.baseID)
         else:
             baseText = ''
         scrolllist.append(listentry.Get('LabelText', {'label': localization.GetByLabel('UI/Corporations/EditMemberDialog/CorpMemberBaseCaption'),
          'text': baseText}))
     scrolllist.append(listentry.Get('LabelText', {'label': localization.GetByLabel('UI/Corporations/EditMemberDialog/CorpMemberJoined'),
      'text': localizationUtil.FormatDateTime(self.member.startDateTime, dateFormat='short')}))
     scrolllist.append(listentry.Get('Divider'))
     scrolllist.append(listentry.Get('LabelText', {'label': localization.GetByLabel('UI/Corporations/EditMemberDialog/Name'),
      'text': cfg.eveowners.Get(self.memberinfo.characterID).name}))
     if self.memberinfo.gender:
         scrolllist.append(listentry.Get('LabelText', {'label': localization.GetByLabel('UI/Common/Gender/Gender'),
          'text': localization.GetByLabel('UI/Common/Gender/Male')}))
     else:
         scrolllist.append(listentry.Get('LabelText', {'label': localization.GetByLabel('UI/Common/Gender/Gender'),
          'text': localization.GetByLabel('UI/Common/Gender/Female')}))
     race = sm.GetService('cc').GetRaceDataByID(self.memberinfo.raceID)
     scrolllist.append(listentry.Get('LabelText', {'label': localization.GetByLabel('UI/Common/Race'),
      'text': localization.GetByMessageID(race.raceNameID)}))
     bloodline = sm.GetService('cc').GetData('bloodlines', ['bloodlineID', self.memberinfo.bloodlineID])
     scrolllist.append(listentry.Get('LabelText', {'label': localization.GetByLabel('UI/Common/Bloodline'),
      'text': localization.GetByMessageID(bloodline.bloodlineNameID)}))
     scrolllist.append(listentry.Get('LabelText', {'label': localization.GetByLabel('UI/Corporations/EditMemberDialog/DateOfBirth'),
      'text': localizationUtil.FormatDateTime(self.memberinfo.createDateTime, dateFormat='short')}))
     scrolllist.append(listentry.Get('LabelText', {'label': localization.GetByLabel('UI/Corporations/EditMemberDialog/SecurityStatus'),
      'text': localizationUtil.FormatNumeric(float(self.security), decimalPlaces=1)}))
     self.sr.scroll.Load(fixedEntryHeight=18, contentList=scrolllist)
     if canEditBase:
         self.ddxFunction = self.DDXTabGeneral
Ejemplo n.º 13
0
 def GetExtraColumnsText(cls, node, *args):
     blueprint = node.blueprint
     if blueprint.copy:
         isCopy = localization.GetByLabel('UI/Common/Yes')
     else:
         isCopy = localization.GetByLabel('UI/Common/No')
     ml = blueprint.materialLevel
     pl = blueprint.productivityLevel
     lprr = blueprint.licensedProductionRunsRemaining
     if lprr == -1:
         lprr = ''
     else:
         lprr = localizationUtil.FormatNumeric(lprr,
                                               decimalPlaces=0,
                                               useGrouping=True)
     label = '<t>%s<t><right>%s<t><right>%s<t><right>%s' % (
         isCopy,
         localizationUtil.FormatNumeric(
             ml, decimalPlaces=0, useGrouping=True),
         localizationUtil.FormatNumeric(
             pl, decimalPlaces=0, useGrouping=True), lprr)
     return label
Ejemplo n.º 14
0
 def ApplyAttributes(self, attributes):
     uicls.Container.ApplyAttributes(self, attributes)
     self.lowerLimit = attributes.lowerLimit
     self.upperLimit = attributes.upperLimit
     self.lpAmount = attributes.lpAmount
     self.lastAmount = 0
     self.level = attributes.level
     self.leftCont = uicls.Container(name='leftCont',
                                     parent=self,
                                     align=uiconst.TOLEFT_PROP,
                                     width=0.75)
     self.rightCont = uicls.Container(name='rightCont', parent=self)
     self.bgFrame = uicls.Frame(bgParent=self.leftCont,
                                frameConst=uiconst.FRAME_BORDER1_CORNER1)
     self.bgGradient = uicls.GradientSprite(bgParent=self.leftCont,
                                            rotation=-pi / 2)
     levelName = uicls.EveCaptionLarge(parent=self.leftCont,
                                       text=self.GetLevelName(),
                                       top=5,
                                       left=10)
     if self.level == 6:
         levelName.fontsize = 16
     self.progressGauge = uicls.Gauge(parent=self.leftCont,
                                      value=0.0,
                                      color=(0.0, 0.31, 0.4, 1.0),
                                      backgroundColor=(0.1, 0.1, 0.1, 1.0),
                                      align=uiconst.TOBOTTOM,
                                      gaugeHeight=15,
                                      padding=2,
                                      opacity=0.0)
     self.progressGauge.GetHint = self.GetProgressGaugeHint
     self.iconCont = uicls.Container(name='iconCont',
                                     parent=self.leftCont,
                                     align=uiconst.TOPRIGHT,
                                     pos=(10, 4, 300, 20))
     self.ConstructIcons()
     self.checkboxSprite = uicls.Sprite(name='checkboxSprite',
                                        parent=self.rightCont,
                                        align=uiconst.CENTERLEFT,
                                        pos=(15, 0, 16, 16))
     uicls.EveLabelLarge(parent=self.rightCont,
                         text=localizationUtil.FormatNumeric(
                             self.upperLimit, useGrouping=True),
                         align=uiconst.CENTERLEFT,
                         left=50)
     self.SetLPAmount(self.lpAmount, init=True)
Ejemplo n.º 15
0
    def __BuildTreeList(self, tree, indent = 0):
        ret = []
        lscSvc = None
        h = [localization.GetByLabel('UI/Chat/ChannelWindow/Name'), localization.GetByLabel('UI/Chat/ChannelWindow/Members')]
        guid = 'ChannelField'
        lscSvc = sm.StartService('LSC')
        for k, v in tree.iteritems():
            if isinstance(v, dict):
                data = {'GetSubContent': self.__GetSubContent,
                 'RefreshScroll': self.RefreshMine,
                 'label': k,
                 'sublevel': indent,
                 'id': ('CHANNELSchannels', k),
                 'groupItems': (indent, v),
                 'headers': h,
                 'iconMargin': 18,
                 'showlen': 0,
                 'state': 'locked',
                 'allowCopy': 0,
                 'showicon': 'ui_22_32_32',
                 'posttext': localization.GetByLabel('UI/Chat/NumChannels', numChannels=len(v)),
                 'allowGuids': ['listentry.Group', 'listentry.%s' % guid]}
                ret.append((k, listentry.Get('Group', data)))
            else:
                data = util.KeyVal()
                data.channel = v
                if v.estimatedMemberCount:
                    emc = localizationUtil.FormatNumeric(v.estimatedMemberCount)
                    data.label = '%s<t>%s' % (k, emc)
                else:
                    data.label = '%s<t>' % (k,)
                data.sublevel = indent
                data.isJoined = lscSvc.IsJoined(v.channelID)
                ret.append((v.displayName, listentry.Get(guid, data=data)))

        ret.sort()
        ret2 = []
        for each in ret:
            ret2.append(each[1])

        return ret2
Ejemplo n.º 16
0
def FmtDist(dist, maxdemicals=2, signed=False):
    if signed and dist < 0.0:
        dist = abs(dist)
    dist = max(0, dist)
    if dist < 10000.0:
        if dist == 0 or dist >= 1.0:
            dist = int(dist)
            maxdemicals = None
        fmtUrl = '/Carbon/UI/Common/FormatDistance/fmtDistInMeters'
    elif dist < 10000000000.0:
        dist = long(dist / 1000.0)
        maxdemicals = None
        fmtUrl = '/Carbon/UI/Common/FormatDistance/fmtDistInKiloMeters'
    else:
        dist = round(dist / const.AU, maxdemicals)
        fmtUrl = '/Carbon/UI/Common/FormatDistance/fmtDistInAU'
    if maxdemicals == 0:
        maxdemicals = None
        dist = int(dist)
    distStr = localizationUtil.FormatNumeric(dist,
                                             useGrouping=True,
                                             decimalPlaces=maxdemicals)
    return localization.GetByLabel(fmtUrl, distance=distStr)
Ejemplo n.º 17
0
 def PanelUpgrade(self):
     cont = uicls.Container(parent=self.actionCont,
                            pos=(0, 0, 0, 0),
                            align=uiconst.TOTOP,
                            state=uiconst.UI_HIDDEN)
     link = self.pin.link
     nextLevel = link.level + 1
     currentCpu = link.GetCpuUsage()
     currentPower = link.GetPowerUsage()
     nextLvlCpu = planetCommon.GetCpuUsageForLink(link.typeID,
                                                  link.GetDistance(),
                                                  nextLevel)
     nextLvlPower = planetCommon.GetPowerUsageForLink(
         link.typeID, link.GetDistance(), nextLevel)
     addlCpu = max(0, nextLvlCpu - currentCpu)
     addlPower = max(0, nextLvlPower - currentPower)
     colony = self.planetUISvc.GetCurrentPlanet().GetColony(session.charid)
     if not colony or colony.colonyData is None:
         raise RuntimeError('Unable to upgrade link - colony not set up')
     colonyCpuUsage = colony.colonyData.GetColonyCpuUsage()
     colonyCpuSupply = colony.colonyData.GetColonyCpuSupply()
     colonyPowerUsage = colony.colonyData.GetColonyPowerUsage()
     colonyPowerSupply = colony.colonyData.GetColonyPowerSupply()
     if addlPower + colonyPowerUsage > colonyPowerSupply or addlCpu + colonyCpuUsage > colonyCpuSupply:
         text = localization.GetByLabel(
             'UI/PI/Common/LinkCannotUpgradePowerCPU',
             linkTypeName=cfg.invtypes.Get(link.typeID).name)
         editBox = self._DrawEditBox(cont, text)
         self.upgradeStatsScroll = scroll = uicls.Scroll(
             parent=cont,
             name='upgradeStatsScroll',
             align=uiconst.TOTOP,
             height=58)
         self.upgradeStatsScroll.sr.id = 'planetLinkUpgradeStats'
         scroll.HideUnderLay()
         uicls.Frame(parent=scroll, color=(1.0, 1.0, 1.0, 0.2))
         scrolllist = []
         link = self.pin.link
         strCurrentCpu = localization.GetByLabel(
             'UI/PI/Common/TeraFlopsAmount', amount=currentCpu)
         strNextCpu = localization.GetByLabel(
             'UI/PI/Common/TeraFlopsAmount', amount=nextLvlCpu)
         cpuDeficit = nextLvlCpu - (colonyCpuSupply - colonyCpuUsage)
         if cpuDeficit > 0:
             cerberusLabel = 'UI/PI/Common/TeraFlopsAmountRed'
         else:
             cerberusLabel = 'UI/PI/Common/TeraFlopsAmountGreen'
         strCpuDeficit = localization.GetByLabel(cerberusLabel,
                                                 amount=max(0, cpuDeficit))
         strCurrentPower = localization.GetByLabel(
             'UI/PI/Common/MegaWattsAmount', amount=currentPower)
         strNextPower = localization.GetByLabel(
             'UI/PI/Common/MegaWattsAmount', amount=nextLvlPower)
         powerDeficit = nextLvlPower - (colonyPowerSupply -
                                        colonyPowerUsage)
         if powerDeficit > 0:
             cerberusLabel = 'UI/PI/Common/MegaWattsAmountRed'
         else:
             cerberusLabel = 'UI/PI/Common/MegaWattsAmountGreen'
         strPowerDeficit = localization.GetByLabel(cerberusLabel,
                                                   amount=max(
                                                       0, powerDeficit))
         data = util.KeyVal(
             label='%s<t>%s<t>%s<t>%s' %
             (localization.GetByLabel('UI/PI/Common/CpuUsage'),
              strCurrentCpu, strNextCpu, strCpuDeficit))
         scrolllist.append(listentry.Get('Generic', data=data))
         data = util.KeyVal(
             label='%s<t>%s<t>%s<t>%s' %
             (localization.GetByLabel('UI/PI/Common/PowerUsage'),
              strCurrentPower, strNextPower, strPowerDeficit))
         scrolllist.append(listentry.Get('Generic', data=data))
         scroll.Load(
             contentList=scrolllist,
             headers=[
                 '',
                 localization.GetByLabel('UI/Common/Current'),
                 localization.GetByLabel('UI/PI/Common/UpgradeNoun'),
                 localization.GetByLabel('UI/PI/Common/PowerOrCPUDeficit')
             ])
         cont.height = editBox.height + 58
     elif nextLevel > planetCommon.LINK_MAX_UPGRADE:
         text = localization.GetByLabel(
             'UI/PI/Common/LinkMaxUpgradeReached',
             linkTypeName=cfg.invtypes.Get(link.typeID).name)
         editBox = self._DrawEditBox(cont, text)
         cont.height = editBox.height
     else:
         text = localization.GetByLabel('UI/PI/Common/LinkUpgradePrompt',
                                        level=nextLevel)
         self.upgradeStatsScroll = scroll = uicls.Scroll(
             parent=cont,
             name='UpgradeStatsScroll',
             align=uiconst.TOTOP,
             height=96)
         self.upgradeStatsScroll.sr.id = 'planetLinkUpgradeStats'
         scroll.HideUnderLay()
         uicls.Frame(parent=scroll, color=(1.0, 1.0, 1.0, 0.2))
         scrolllist = []
         link = self.pin.link
         totalBandwidth = link.GetTotalBandwidth()
         nextLvlBandwidth = link.GetBandwidthForLevel(nextLevel)
         strCurrentBandwidth = totalBandwidth
         strNextLvlBandwidth = nextLvlBandwidth
         strBandwidthDelta = max(0, nextLvlBandwidth - totalBandwidth)
         strBandwidthUsage = link.GetBandwidthUsage()
         strCurrentCpu = localization.GetByLabel(
             'UI/PI/Common/TeraFlopsAmount', amount=currentCpu)
         strNextCpu = localization.GetByLabel(
             'UI/PI/Common/TeraFlopsAmount', amount=nextLvlCpu)
         strCpuDelta = localization.GetByLabel(
             'UI/PI/Common/TeraFlopsAmount',
             amount=max(0, nextLvlCpu - currentCpu))
         strCpuUsage = localization.GetByLabel(
             'UI/PI/Common/TeraFlopsAmount', amount=int(colonyCpuUsage))
         strCurrentPower = localization.GetByLabel(
             'UI/PI/Common/MegaWattsAmount', amount=currentPower)
         strNextPower = localization.GetByLabel(
             'UI/PI/Common/MegaWattsAmount', amount=nextLvlPower)
         strPowerDelta = localization.GetByLabel(
             'UI/PI/Common/MegaWattsAmount',
             amount=max(0, nextLvlPower - currentPower))
         strPowerUsage = localization.GetByLabel(
             'UI/PI/Common/MegaWattsAmount', amount=int(colonyPowerUsage))
         data = util.KeyVal(label='%s<t>%s<t>%s<t>%s' %
                            (localization.GetByLabel('UI/Common/Current'),
                             localizationUtil.FormatNumeric(
                                 strCurrentBandwidth, decimalPlaces=1),
                             strCurrentCpu, strCurrentPower))
         scrolllist.append(listentry.Get('Generic', data=data))
         data = util.KeyVal(
             label='%s<t>%s<t>%s<t>%s' %
             (localization.GetByLabel('UI/PI/Common/UpgradeNoun'),
              localizationUtil.FormatNumeric(strNextLvlBandwidth,
                                             decimalPlaces=1), strNextCpu,
              strNextPower))
         scrolllist.append(listentry.Get('Generic', data=data))
         data = util.KeyVal(
             label='%s<t>%s<t>%s<t>%s' %
             (localization.GetByLabel('UI/PI/Common/ChangeNoun'),
              localizationUtil.FormatNumeric(strBandwidthDelta,
                                             decimalPlaces=1), strCpuDelta,
              strPowerDelta))
         scrolllist.append(listentry.Get('Generic', data=data))
         data = util.KeyVal(label='%s<t>%s<t>%s<t>%s' %
                            (localization.GetByLabel('UI/Common/Usage'),
                             localizationUtil.FormatNumeric(
                                 strBandwidthUsage, decimalPlaces=1),
                             strCpuUsage, strPowerUsage))
         scrolllist.append(listentry.Get('Generic', data=data))
         scroll.Load(contentList=scrolllist,
                     headers=[
                         '',
                         localization.GetByLabel('UI/PI/Common/Capacity'),
                         localization.GetByLabel('UI/Common/Cpu'),
                         localization.GetByLabel('UI/Common/Power')
                     ])
         btns = [[
             localization.GetByLabel('UI/PI/Common/Upgrade'),
             self._UpgradeSelf,
             (link.endpoint1.id, link.endpoint2.id, nextLevel)
         ]]
         uicls.ButtonGroup(btns=btns,
                           parent=cont,
                           line=False,
                           alwaysLite=True)
         editBox = self._DrawEditBox(cont, text)
         cont.height = editBox.height + 115
     return cont
Ejemplo n.º 18
0
    def CountDown(self, tid):
        if self.destroyed:
            return
        self.countDown = 1
        self.scanAttributeChangeFlag = False
        slimItem = sm.GetService('michelle').GetBallpark().GetInvItem(tid)
        source = self.sr.sourceID
        time = sm.GetService('bracket').GetScanSpeed(source, slimItem)
        if hasattr(self, 'sr') and self.sr.Get('targetContainer'):
            par = uicls.Container(parent=self.sr.targetContainer,
                                  width=52,
                                  height=13,
                                  left=6,
                                  top=62,
                                  align=uiconst.TOPLEFT,
                                  state=uiconst.UI_DISABLED)
            t = uicls.EveHeaderSmall(text='',
                                     parent=par,
                                     width=200,
                                     left=6,
                                     top=1,
                                     state=uiconst.UI_NORMAL)
            p = uicls.Fill(parent=par,
                           align=uiconst.RELATIVE,
                           width=48,
                           height=11,
                           left=1,
                           top=1,
                           color=(1.0, 1.0, 1.0, 0.25))
            uicls.Frame(parent=par, color=(1.0, 1.0, 1.0, 0.5))
            startTime = blue.os.GetSimTime()
            while not self.destroyed and self.countDown:
                now = blue.os.GetSimTime()
                dt = blue.os.TimeDiffInMs(startTime, now)
                if self.scanAttributeChangeFlag:
                    waitRatio = dt / float(time)
                    self.scanAttributeChangeFlag = False
                    time = sm.GetService('bracket').GetScanSpeed(
                        source, slimItem)
                    startTime = now - long(time * waitRatio * 10000)
                    dt = blue.os.TimeDiffInMs(startTime, now)
                if t.destroyed:
                    return
                t.text = localizationUtil.FormatNumeric((time - dt) / 1000.0,
                                                        decimalPlaces=3)
                if dt > time:
                    t.text = localization.GetByLabel(
                        'UI/Inflight/Brackets/TargetLocked')
                    break
                p.width = int(48 * ((time - dt) / time))
                blue.pyos.synchro.Sleep(51)

            if self.destroyed:
                return
            if not self.countDown:
                par.Close()
            p.width = 0
            blue.pyos.synchro.SleepWallclock(250)
            if t.destroyed:
                return
            t.text = ''
            blue.pyos.synchro.SleepWallclock(250)
            if t.destroyed:
                return
            t.text = localization.GetByLabel(
                'UI/Inflight/Brackets/TargetLocked')
            blue.pyos.synchro.SleepWallclock(250)
            if t.destroyed:
                return
            t.text = ''
            blue.pyos.synchro.SleepWallclock(250)
            if t.destroyed:
                return
            t.text = localization.GetByLabel(
                'UI/Inflight/Brackets/TargetLocked')
            blue.pyos.synchro.SleepWallclock(250)
            par.Close()
Ejemplo n.º 19
0
    def Load(self, populateView=1, *args):
        sm.GetService('corpui').LoadTop(
            'ui_7_64_11',
            localization.GetByLabel('UI/Corporations/Common/Members'))
        if not self.sr.Get('inited', 0):
            self.sr.inited = 1
            toppar = uicls.Container(name='options',
                                     parent=self,
                                     align=uiconst.TOTOP,
                                     height=54)
            self.sr.fwdBtn = uicls.Button(
                parent=toppar,
                icon='ui_77_32_41',
                iconSize=20,
                align=uiconst.BOTTOMRIGHT,
                left=6,
                func=self.Navigate,
                args=1,
                hint=localization.GetByLabel(
                    'UI/Corporations/CorporationWindow/Members/ViewMoreCorpMembers'
                ))
            self.sr.backBtn = uicls.Button(
                parent=toppar,
                icon='ui_77_32_42',
                iconSize=20,
                align=uiconst.BOTTOMRIGHT,
                left=32,
                func=self.Navigate,
                args=-1,
                hint=localization.GetByLabel(
                    'UI/Corporations/CorporationWindow/Members/ViewPreviousCorpMembers'
                ))
            uicls.Container(name='push',
                            parent=toppar,
                            align=uiconst.TOTOP,
                            height=6)
            optlist = [[localizationUtil.FormatNumeric(10), 10],
                       [localizationUtil.FormatNumeric(25), 25],
                       [localizationUtil.FormatNumeric(50), 50],
                       [localizationUtil.FormatNumeric(100), 100],
                       [localizationUtil.FormatNumeric(500), 500]]
            countcombo = uicls.Combo(
                label=localization.GetByLabel('UI/Common/PerPage'),
                parent=toppar,
                options=optlist,
                name='membersperpage',
                callback=self.OnComboChange,
                width=92,
                pos=(5, 36, 0, 0))
            self.sr.MembersPerPage = countcombo
            viewOptionsList1 = [
                [
                    localization.GetByLabel('UI/Corporations/Common/Roles'),
                    VIEW_ROLES
                ],
                [
                    localization.GetByLabel(
                        'UI/Corporations/Common/GrantableRoles'),
                    VIEW_GRANTABLE_ROLES
                ],
                [
                    localization.GetByLabel('UI/Corporations/Common/Titles'),
                    VIEW_TITLES
                ]
            ]
            viewOptionsList2 = []
            for roleGrouping in self.sr.roleGroupings.itervalues():
                viewOptionsList2.append([
                    localization.GetByMessageID(roleGrouping.roleGroupNameID),
                    roleGrouping.roleGroupID
                ])

            i = 0
            for optlist, label, config, defval, width in [
                (viewOptionsList1, localization.GetByLabel('UI/Common/View'),
                 'viewtype', 1000, 146),
                (viewOptionsList2, localization.GetByLabel('UI/Common/Type'),
                 'rolegroup', None, 146)
            ]:
                combo = uicls.Combo(label=label,
                                    parent=toppar,
                                    options=optlist,
                                    name=config,
                                    callback=self.OnComboChange,
                                    width=width,
                                    pos=(5 + countcombo.left +
                                         countcombo.width + i * (width + 4),
                                         countcombo.top, 0, 0))
                combo.OnChange = self.OnComboChange
                setattr(self.sr, config + 'Combo', combo)
                i += 1

            self.sr.scroll = uicls.Scroll(
                name='journal',
                parent=self,
                padding=(const.defaultPadding, const.defaultPadding,
                         const.defaultPadding, const.defaultPadding))
            self.sr.scroll.OnColumnChanged = self.OnColumnChanged
            buttons = [[
                localization.GetByLabel('UI/Common/Buttons/SaveChanges'),
                self.SaveChanges, (), 81
            ]]
            btns = uicls.ButtonGroup(btns=buttons)
            self.children.insert(0, btns)
        if populateView:
            self.PopulateView()
Ejemplo n.º 20
0
    def ConstructLayout(self):
        self.sr.topPar = uicls.Container(name='topPar',
                                         align=uiconst.TOTOP,
                                         parent=self.sr.main,
                                         height=64,
                                         top=0)
        headingPar = uicls.Container(name='headingPar',
                                     align=uiconst.TOBOTTOM,
                                     parent=self.sr.topPar,
                                     height=14,
                                     top=2)
        self.sr.topText = uicls.EveLabelMedium(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/Attributes/CharacterRespecMessage'
        ),
                                               parent=self.sr.topPar,
                                               left=9,
                                               width=485,
                                               maxLines=None,
                                               state=uiconst.UI_NORMAL,
                                               top=4)
        self.sr.topPar.height = 28 + self.sr.topText.textheight
        barColor = (0.5, 0.5, 0.5, 0.75)
        c = uicls.Container(name='',
                            align=uiconst.TOTOP,
                            parent=self.sr.main,
                            height=2,
                            top=0)
        uicls.Line(parent=c,
                   align=uiconst.TOALL,
                   left=10,
                   width=10,
                   height=1,
                   color=barColor)
        self.sr.intPar = uicls.Container(name='intPar',
                                         align=uiconst.TOTOP,
                                         parent=self.sr.main,
                                         height=40)
        self.sr.memPar = uicls.Container(name='memPar',
                                         align=uiconst.TOTOP,
                                         parent=self.sr.main,
                                         height=40)
        self.sr.chaPar = uicls.Container(name='chaPar',
                                         align=uiconst.TOTOP,
                                         parent=self.sr.main,
                                         height=40)
        self.sr.perPar = uicls.Container(name='perPar',
                                         align=uiconst.TOTOP,
                                         parent=self.sr.main,
                                         height=40)
        self.sr.wilPar = uicls.Container(name='wilPar',
                                         align=uiconst.TOTOP,
                                         parent=self.sr.main,
                                         height=40)
        if not self.readOnly:
            c = uicls.Container(name='',
                                align=uiconst.TOTOP,
                                parent=self.sr.main,
                                height=2,
                                top=0)
            uicls.Line(parent=c,
                       align=uiconst.TOALL,
                       left=10,
                       width=10,
                       height=1,
                       color=barColor)
            self.sr.bottomPar = uicls.Container(name='bottomPar',
                                                align=uiconst.TOTOP,
                                                parent=self.sr.main,
                                                top=8,
                                                height=65)
        else:
            self.sr.bottomPar = uicls.Container(name='bottomPar',
                                                align=uiconst.TOTOP,
                                                parent=self.sr.main,
                                                top=8,
                                                height=5)
        leftMargin = 8
        self.attributePars = [
            self.sr.intPar, self.sr.memPar, self.sr.chaPar, self.sr.perPar,
            self.sr.wilPar
        ]
        self.sprites = []
        iconsize = 32
        for x in xrange(0, 5):
            icon = uicls.Icon(parent=self.attributePars[x],
                              width=iconsize,
                              height=iconsize,
                              size=iconsize,
                              icon=self.attributeIcons[x],
                              left=leftMargin,
                              align=uiconst.TOLEFT)

        leftMargin += iconsize + 3
        self.totalLabels = []
        maxTextWidth = 10
        attributeLabel = uicls.EveLabelMedium(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/NavScroll/Attributes'),
                                              parent=headingPar,
                                              maxLines=1,
                                              left=leftMargin - iconsize / 2)
        for x in xrange(0, 5):
            label1 = uicls.EveLabelMedium(text=self.attributeLabels[x],
                                          parent=self.attributePars[x],
                                          maxLines=1,
                                          state=uiconst.UI_DISABLED,
                                          align=uiconst.CENTERLEFT,
                                          left=leftMargin)
            maxTextWidth = max(label1.textwidth, maxTextWidth)

        leftMargin += maxTextWidth + 20
        baseLabel = uicls.EveLabelMedium(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/Attributes/BaseStatPoints'
        ),
                                         parent=headingPar,
                                         left=leftMargin,
                                         maxLines=1)
        for x in xrange(0, 5):
            minText = localizationUtil.FormatNumeric(
                const.respecMinimumAttributeValue, decimalPlaces=0)
            label2 = uicls.EveLabelMedium(text=minText,
                                          parent=self.attributePars[x],
                                          width=20,
                                          maxLines=1,
                                          state=uiconst.UI_DISABLED,
                                          left=leftMargin +
                                          baseLabel.textwidth / 2 - 10,
                                          top=10)
            label2.bold = 1

        leftMargin += baseLabel.textwidth + 20
        implantLabel = uicls.EveLabelMedium(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/Attributes/CharacterImplants'
        ),
                                            parent=headingPar,
                                            left=leftMargin,
                                            maxLines=1)
        self.implantLabels = []
        for x in xrange(0, 5):
            icon = uicls.Icon(parent=self.attributePars[x],
                              width=32,
                              height=32,
                              size=32,
                              icon=util.IconFile(
                                  cfg.invtypes.Get(
                                      self.implantTypes[x]).iconID),
                              left=leftMargin - 4,
                              align=uiconst.TOPLEFT,
                              ignoreSize=True)
            label2 = uicls.EveLabelMedium(text='',
                                          parent=self.attributePars[x],
                                          maxLines=1,
                                          left=leftMargin + 28,
                                          top=10)
            self.implantLabels.append((label2, icon))

        boxWidth = 6
        boxHeight = 12
        boxMargin = 1
        boxSpacing = 1
        barHeight = boxHeight + 2 * boxMargin
        backgroundColor = (0.0, 0.0, 0.0, 0.0)
        leftMargin += implantLabel.textwidth
        leftMargin += (450 - (leftMargin + 130)) / 2
        buttonSize = 24
        if not self.readOnly:
            for x in xrange(0, 5):
                minusText = localization.GetByLabel('UI/Common/Buttons/Minus')
                uicls.Button(parent=self.attributePars[x],
                             label=minusText,
                             fixedwidth=buttonSize,
                             pos=(leftMargin, 4, 0, 0),
                             func=self.DecreaseAttribute,
                             args=(x, ))

        leftMargin += buttonSize + 4
        numBoxes = const.respecMaximumAttributeValue - const.respecMinimumAttributeValue
        barWidth = numBoxes * boxSpacing + 2 * boxMargin + numBoxes * boxWidth - 1
        remappableLabel = uicls.EveLabelMedium(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/Attributes/RemappableStat'
        ),
                                               parent=headingPar,
                                               left=leftMargin,
                                               maxLines=1)
        remappableLabel.left = remappableLabel.left - remappableLabel.textwidth / 2 + barWidth / 2
        colorDict = {
            uicls.ClickableBoxBar.COLOR_UNSELECTED: (0.2, 0.2, 0.2, 1.0),
            uicls.ClickableBoxBar.COLOR_SELECTED: (0.2, 0.8, 0.2, 1.0)
        }
        self.respecBar = []
        for x in xrange(0, 5):
            bar = uicls.Container(parent=self.attributePars[x],
                                  align=uiconst.TOPLEFT,
                                  left=leftMargin,
                                  top=7,
                                  width=barWidth,
                                  height=barHeight)
            bar.state = uiconst.UI_PICKCHILDREN
            bar = uicls.ClickableBoxBar(parent=bar,
                                        numBoxes=numBoxes,
                                        boxWidth=boxWidth,
                                        boxHeight=boxHeight,
                                        boxMargin=boxMargin,
                                        boxSpacing=boxSpacing,
                                        backgroundColor=backgroundColor,
                                        colorDict=colorDict)
            bar.OnValueChanged = self.OnMemberBoxClick
            bar.OnAttemptBoxClicked = self.ValidateBoxClick
            self.respecBar.append(bar)

        leftMargin += barWidth + 4
        if not self.readOnly:
            for x in xrange(0, 5):
                plusText = localization.GetByLabel('UI/Common/Buttons/Plus')
                uicls.Button(parent=self.attributePars[x],
                             label=plusText,
                             fixedwidth=24,
                             pos=(leftMargin, 4, 0, 0),
                             func=self.IncreaseAttribute,
                             args=(x, ))

        barEnd = leftMargin
        leftMargin += buttonSize + 20
        leftMargin = 450
        totalLabel = uicls.EveLabelMedium(text=localization.GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/Attributes/StatTotal'),
                                          parent=headingPar,
                                          left=leftMargin,
                                          maxLines=1)
        totalLabelPos = leftMargin + totalLabel.textwidth / 2 - 15
        for x in xrange(0, 5):
            label3 = uicls.EveLabelMedium(name='',
                                          parent=self.attributePars[x],
                                          width=20,
                                          maxLines=1,
                                          left=totalLabelPos,
                                          top=10)
            label3.bold = 1
            self.totalLabels.append(label3)

        if not self.readOnly:
            textObj = uicls.EveLabelMedium(text=localization.GetByLabel(
                'UI/CharacterSheet/CharacterSheetWindow/Attributes/UnassignedAttributePoints'
            ),
                                           parent=self.sr.bottomPar,
                                           left=16)
            numBoxes = const.respecTotalRespecPoints - const.respecMinimumAttributeValue * 5
            barWidth = numBoxes * boxSpacing + 2 * boxMargin + numBoxes * boxWidth - 1
            colorDict = {
                uicls.ClickableBoxBar.COLOR_UNSELECTED: (0.2, 0.2, 0.2, 1.0),
                uicls.ClickableBoxBar.COLOR_SELECTED: (0.2, 0.8, 0.2, 1.0)
            }
            self.sr.unassignedBar = uicls.Container(parent=self.sr.bottomPar,
                                                    align=uiconst.TOPLEFT,
                                                    left=barEnd - barWidth +
                                                    24,
                                                    top=0,
                                                    width=barWidth,
                                                    height=barHeight)
            self.sr.unassignedBar.state = uiconst.UI_PICKCHILDREN
            self.sr.unassignedBar = uicls.ClickableBoxBar(
                parent=self.sr.unassignedBar,
                numBoxes=numBoxes,
                boxWidth=boxWidth,
                boxHeight=boxHeight,
                boxMargin=boxMargin,
                boxSpacing=boxSpacing,
                backgroundColor=backgroundColor,
                colorDict=colorDict,
                readonly=True,
                hintFormat=
                'UI/CharacterSheet/CharacterSheetWindow/Attributes/UnassignedPointsHint'
            )
            self.availableLabel = uicls.EveLabelMedium(
                text='',
                parent=self.sr.bottomPar,
                width=20,
                maxLines=1,
                left=totalLabelPos)
            self.sr.saveWarningText = uicls.EveLabelMedium(
                text=localization.GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/Attributes/CannotSaveUnassignedPoints'
                ),
                parent=self.sr.bottomPar,
                left=16,
                top=16,
                color=(1.0, 0.0, 0.0, 0.9))
            btns = uicls.ButtonGroup(btns=[[
                localization.GetByLabel(
                    'UI/CharacterSheet/CharacterSheetWindow/Attributes/SaveStatChanges'
                ), self.SaveChanges, (), None
            ],
                                           [
                                               localization.GetByLabel(
                                                   'UI/Common/Buttons/Cancel'),
                                               self.CloseByUser, (), None
                                           ]],
                                     parent=self.sr.main,
                                     idx=0)
        heightTotal = self.sr.topParent.height + self.sr.headerParent.height
        for child in self.sr.main.children:
            width, height = child.GetAbsoluteSize()
            heightTotal += height

        self.SetMinSize([self.GetMinWidth(), heightTotal], refresh=1)
Ejemplo n.º 21
0
 def SetDayNumber(self, text=None, *args):
     self.AddDayNumber()
     if text is not None:
         text = localizationUtil.FormatNumeric(text, decimalPlaces=0)
         self.sr.dayNumberText.text = text
Ejemplo n.º 22
0
 def GetSliderHint(self, idname, dname, value):
     return localizationUtil.FormatNumeric(value, decimalPlaces=2)
Ejemplo n.º 23
0
 def SetLPPoolAmount(self, amount):
     self.lpPoolLabel.SetText(
         localizationUtil.FormatNumeric(amount, useGrouping=True))
Ejemplo n.º 24
0
    def ConstructSlider(self):
        sliderTextCont = uicls.GridContainer(name='mainCont',
                                             parent=self.sliderCont,
                                             align=uiconst.TOTOP,
                                             height=16)
        sliderTextCont.lines = 1
        sliderTextCont.columns = SLIDER_COLUMNS * 2
        sliderCont = uicls.GridContainer(name='mainCont',
                                         parent=self.sliderCont,
                                         align=uiconst.TOALL)
        sliderCont.lines = 1
        sliderCont.columns = SLIDER_COLUMNS
        for i in xrange(1, SLIDER_COLUMNS + 1):
            textcontLeft = uicls.Container(parent=sliderTextCont,
                                           align=uiconst.TOALL,
                                           state=uiconst.UI_NORMAL)
            textcontLeft.OnClick = (self.OnLevelClick, i)
            textcontRight = uicls.Container(parent=sliderTextCont,
                                            align=uiconst.TOALL,
                                            state=uiconst.UI_NORMAL)
            textcontRight.OnClick = (self.OnLevelClick, i + 1)
            cont = uicls.Container(parent=sliderCont, align=uiconst.TOALL)
            label = uicls.Label(text='',
                                parent=textcontRight,
                                align=uiconst.TOPRIGHT,
                                state=uiconst.UI_NORMAL,
                                left=-6,
                                fontsize=18,
                                top=-4)
            label.SetAlpha(NORMAL_ALPHA)
            label.OnClick = (self.OnLevelClick, i + 1)
            label.GetMenu = []
            label.OnMouseExit = (self.OnAdjusterMouseExit, label)
            label.OnMouseEnter = (self.OnAdjusterMouseEnter, label)
            labelName = 'level%d' % i
            setattr(self.sr, labelName, label)
            uicls.Line(name='scaleBase',
                       parent=cont,
                       align=uiconst.TOBOTTOM,
                       color=LINE_COLOR)
            if i == 1:
                labelTxt = localizationUtil.FormatNumeric(i, decimalPlaces=0)
                firstLabel = uicls.Label(text=labelTxt,
                                         parent=textcontLeft,
                                         left=-4,
                                         state=uiconst.UI_NORMAL,
                                         fontsize=18,
                                         top=-4)
                labelName = 'label%s' % i
                setattr(self, labelName, firstLabel)
                firstLabel.SetAlpha(NORMAL_ALPHA)
                firstLabel.GetMenu = []
                firstLabel.OnClick = (self.OnLevelClick, i)
                firstLabel.OnMouseExit = (self.OnAdjusterMouseExit, firstLabel)
                firstLabel.OnMouseEnter = (self.OnAdjusterMouseEnter,
                                           firstLabel)
                textcontLeft.OnMouseEnter = (self.OnAdjusterMouseEnter,
                                             firstLabel)
                textcontLeft.OnMouseExit = (self.OnAdjusterMouseExit,
                                            firstLabel)
                uicls.Line(name='leftTick',
                           parent=cont,
                           align=uiconst.TOLEFT,
                           color=LINE_COLOR)
            else:
                prevLabel = self.sr.Get('level%d' % (i - 1))
                textcontLeft.OnMouseEnter = (self.OnAdjusterMouseEnter,
                                             prevLabel)
                textcontLeft.OnMouseExit = (self.OnAdjusterMouseExit,
                                            prevLabel)
            textcontRight.OnMouseEnter = (self.OnAdjusterMouseEnter, label)
            textcontRight.OnMouseExit = (self.OnAdjusterMouseExit, label)
            label.text = localizationUtil.FormatNumeric(i + 1, decimalPlaces=0)
            uicls.Line(name='rightTick',
                       parent=cont,
                       align=uiconst.TORIGHT,
                       color=LINE_COLOR)

        self.leftSpacer = uicls.Container(parent=self.sliderAdjusterCont,
                                          name='leftSpacer',
                                          align=uiconst.TOLEFT,
                                          pos=(-ADJUSTER_WIDTH / 2, 0,
                                               ADJUSTER_WIDTH, ADJUSTER_WIDTH),
                                          state=uiconst.UI_PICKCHILDREN)
        adjuster = uicls.Icon(name='adjuster',
                              icon='38_230',
                              parent=self.leftSpacer,
                              align=uiconst.TORIGHT,
                              pos=(0, 0, ADJUSTER_WIDTH, ADJUSTER_WIDTH),
                              state=uiconst.UI_NORMAL,
                              color=LINE_COLOR)
        adjuster.OnMouseDown = self.OnAdjustMouseDown
        adjuster.OnMouseUp = self.OnAdjustMouseUp
        adjuster.OnMouseMove = self.OnAdjustMouseMove
        adjuster.OnMouseEnter = (self.OnAdjusterMouseEnter, adjuster)
        adjuster.OnMouseExit = (self.OnAdjusterMouseExit, adjuster)
        self.adjuster = adjuster
        self.UpdateAdjuster()
Ejemplo n.º 25
0
    def ApplyAttributes(self, attributes):
        self.decimalSign = eveLocalization.GetDecimalSeparator(
            localization.SYSTEM_LANGUAGE)
        self.digitSign = eveLocalization.GetThousandSeparator(
            localization.SYSTEM_LANGUAGE)
        self.PopulateKnownKeys()
        uicls.Window.ApplyAttributes(self, attributes)
        self.scope = 'all'
        self.SetCaption(
            localization.GetByLabel('UI/Accessories/Calculator/Calculator'))
        self.MakeUnResizeable()
        self.SetWndIcon('ui_49_64_1')
        self.HideMainIcon()
        self.SetTopparentHeight(0)
        self.inputParent = uicls.Container(name='inputParent',
                                           parent=self.sr.main,
                                           padding=const.defaultPadding,
                                           align=uiconst.TOTOP)
        icon = xtriui.MiniButton(icon='ui_38_16_156',
                                 parent=self.inputParent,
                                 size=16,
                                 align=uiconst.CENTERRIGHT)
        icon.groupID = 'viewMode'
        self.sr.viewModeBtn = icon
        icon.Click = self.ViewModeBtnClick
        inpt = uicls.SinglelineEdit(name='inpt',
                                    parent=self.inputParent,
                                    align=uiconst.TOTOP,
                                    padRight=20)
        inpt.OnChar = self.OnCharInput
        inpt.Paste = self.OnInputPasted
        self.inputParent.height = inpt.height
        self.sr.inpt = inpt
        self.SetInpt('0')
        hist = settings.public.ui.Get('CalculatorHistory', [])
        if hist:
            ops = [(v, v) for v in hist]
        else:
            ops = [('0', '0')]
        inpt.LoadCombo('urlcombo', ops, self.OnComboChange)
        uicls.Line(parent=self.sr.main,
                   align=uiconst.TOTOP,
                   padTop=const.defaultPadding)
        self.sr.mem = uicls.Container(name='mem',
                                      parent=self.sr.main,
                                      height=16,
                                      align=uiconst.TOTOP)
        uicls.Line(parent=self.sr.main, align=uiconst.TOTOP)
        self.sr.work = uicls.Container(name='work',
                                       parent=self.sr.main,
                                       align=uiconst.TOTOP,
                                       padding=const.defaultPadding)
        size = 24
        self.buttons = [
            (0, 0, '7', localizationUtil.FormatNumeric(7)),
            (1, 0, '8', localizationUtil.FormatNumeric(8)),
            (2, 0, '9', localizationUtil.FormatNumeric(9)),
            (3, 0, 'divide',
             localization.GetByLabel('UI/Accessories/Calculator/DivideSymbol')
             ), (0, 1, '4', localizationUtil.FormatNumeric(4)),
            (1, 1, '5', localizationUtil.FormatNumeric(5)),
            (2, 1, '6', localizationUtil.FormatNumeric(6)),
            (3, 1, 'times',
             localization.GetByLabel(
                 'UI/Accessories/Calculator/MultiplySymbol')),
            (0, 2, '1', localizationUtil.FormatNumeric(1)),
            (1, 2, '2', localizationUtil.FormatNumeric(2)),
            (2, 2, '3', localizationUtil.FormatNumeric(3)),
            (3, 2, 'minus',
             localization.GetByLabel(
                 'UI/Accessories/Calculator/SubtractSymbol')),
            (0, 3, '0', localizationUtil.FormatNumeric(0)),
            (1, 3, 'dot', self.decimalSign),
            (2, 3, 'equal',
             localization.GetByLabel('UI/Accessories/Calculator/EqualsSymbol')
             ),
            (3, 3, 'plus',
             localization.GetByLabel('UI/Accessories/Calculator/AddSymbol')),
            (4.5, 0, 'clear',
             localization.GetByLabel('UI/Accessories/Calculator/ClearSymbol')),
            (5.5, 0, 'clearall',
             localization.GetByLabel(
                 'UI/Accessories/Calculator/ClearAllSymbol')),
            (4.5, 1, 'bo',
             localization.GetByLabel(
                 'UI/Accessories/Calculator/BracketOpenSymbol')),
            (5.5, 1, 'bc',
             localization.GetByLabel(
                 'UI/Accessories/Calculator/BracketCloseSymbol')),
            (4.5, 2, 'percent',
             localization.GetByLabel('UI/Accessories/Calculator/PercentSymbol')
             ),
            (5.5, 2, 'square',
             localization.GetByLabel('UI/Accessories/Calculator/SquareSymbol')
             ),
            (4.5, 3, 'plusminus',
             localization.GetByLabel(
                 'UI/Accessories/Calculator/PlusMinusSymbol')),
            (5.5, 3, 'root', u'\u221a&macr;')
        ]
        for x, y, label, cap in self.buttons:
            btn = uix.GetBigButton(size=size,
                                   where=self.sr.work,
                                   left=int(x * size),
                                   top=int(y * size),
                                   iconMargin=10,
                                   align=uiconst.RELATIVE)
            btn.SetInCaption(cap)
            btn.Click = self.OnBtnClick
            btn.OnDblClick = None
            btn.name = label
            setattr(self.sr, 'btn%s' % label, btn)
            self.sr.work.height = max(self.sr.work.height,
                                      btn.top + btn.height)

        uicls.Line(parent=self.sr.mem,
                   align=uiconst.TOLEFT,
                   padLeft=const.defaultPadding)
        for i in xrange(1, 7):
            opt = uicls.WindowDropDownMenu(name='memoption',
                                           parent=self.sr.mem,
                                           align=uiconst.TOLEFT,
                                           state=uiconst.UI_NORMAL)
            opt.Setup(
                localization.GetByLabel(
                    'UI/Accessories/Calculator/AbbreviatedMemory', index=i),
                getattr(self, 'GetMem%sMenu' % i, None))
            opt.OnClick = (self.OnClickMemory, opt)
            opt.sr.memHilite = uicls.Fill(parent=opt,
                                          color=(0.0, 0.0, 1.0, 0.2),
                                          state=uiconst.UI_HIDDEN)
            opt.name = 'mem%s' % i
            opt.label = settings.public.ui.Get(
                'CalculatorMem%sName' % i,
                localization.GetByLabel('UI/Accessories/Calculator/Memory',
                                        index=i))
            setattr(self.sr, 'memBtn%s' % i, opt)
            opt.mem = settings.public.ui.Get('CalculatorMem%s' % i, None)
            opt.nr = i
            if opt.mem:
                opt.hint = '%s:<br>%s' % (opt.label, opt.mem)
                opt.sr.memHilite.state = uiconst.UI_DISABLED
            else:
                opt.hint = localization.GetByLabel(
                    'UI/Accessories/Calculator/EmptyBank',
                    label=opt.label,
                    empty=localization.GetByLabel(
                        'UI/Accessories/Calculator/Empty'))
                opt.sr.memHilite.state = uiconst.UI_HIDDEN

        self.sr.mem.height = self.sr.mem.children[1].GetTextHeight()
        self.SetLayout()
        self.newNumber = True
        self.stack = []
        self.opStack = []
        self.lastOp = 0
        uicore.registry.SetFocus(self.sr.inpt)