示例#1
0
    def SortIconsBy(self, sortby, direction):
        self.sortIconsBy = sortby
        self.sortIconsDir = direction
        settings.user.ui.Set('containerSortIconsBy_%s' % self.name, (sortby, direction))
        sortData = []
        for rec in self.items:
            if rec is None:
                continue
            name = uiutil.StripTags(uix.GetItemName(rec).lower())
            type = uiutil.StripTags(uix.GetCategoryGroupTypeStringForItem(rec).lower())
            id = rec.itemID
            qty = 0
            if not (rec.singleton or rec.typeID in (const.typeBookmark,)):
                qty = rec.stacksize
            if sortby == 'name':
                sortKey = (name,
                 type,
                 qty,
                 id,
                 rec)
            elif sortby == 'qty':
                sortKey = (qty,
                 type,
                 name,
                 id,
                 rec)
            elif sortby == 'type':
                sortKey = (type,
                 name,
                 qty,
                 id,
                 rec)
            else:
                log.LogError('Unknown sortkey used in container sorting', sortby, direction)
                continue
            sortData.append((sortKey, rec))

        locCmpFunc = localization.util.GetSortFunc(localization.util.GetLanguageID())

        def _sort(left, right):
            if len(left) == 0:
                return 0
            if isinstance(left[0], basestring):
                res = locCmpFunc(left[0], right[0])
            else:
                res = cmp(left[0], right[0])
            if res == 0:
                return _sort(left[1:], right[1:])
            return res

        sortedList = sorted(sortData, cmp=_sort, key=lambda x: x[0])
        sortedList = [ x[1] for x in sortedList ]
        if direction:
            sortedList.reverse()
        self.items = sortedList
        self.RefreshView()
示例#2
0
 def SetNameLabels(self, fullLabel, *args):
     hintMarkupStart = ''
     hintMarkupEnd = ''
     localizedHintPos = fullLabel.find('<localized hint')
     if localizedHintPos >= 0:
         strippedLabel = uiutil.StripTags(fullLabel, stripOnly=['localized'])
         hintEndIndex = fullLabel.find('">')
         if hintEndIndex > 0:
             hintMarkupStart = fullLabel[localizedHintPos:hintEndIndex + 2]
             hintMarkupEnd = '</localized>'
     else:
         strippedLabel = fullLabel
     self.sr.label.text = strippedLabel
     indexAtMaxLenght = self.sr.label.GetIndexUnderPos(self.width)
     if indexAtMaxLenght[0] < len(strippedLabel):
         lastBreak = strippedLabel.rfind(' ', 0, indexAtMaxLenght[0])
         if lastBreak != -1:
             self.sr.label.text = strippedLabel[:lastBreak]
         self.sr.label2.text = '<center>' + hintMarkupStart + strippedLabel[lastBreak:].strip() + hintMarkupEnd
         self.FadeText(self.sr.label2)
         self.sr.label2.display = True
     else:
         self.sr.label2.text = ''
         self.sr.label2.display = False
     self.sr.label.text = '<center>' + hintMarkupStart + self.sr.label.text + hintMarkupEnd
     self.lastTextUsedForLabel = self.label
示例#3
0
 def AddLink(self, text, link=None, addLineBreak=False):
     self.SetSelectionRange(None, None)
     node = self.GetActiveNode()
     if node is None:
         return
     text = uiutil.StripTags(text, stripOnly=['localized'])
     shiftCursor = len(text)
     stackCursorIndex = self.globalCursorPos - node.startCursorIndex + node.stackCursorIndex
     glyphString = node.glyphString
     glyphStringIndex = self.GetGlyphStringIndex(glyphString)
     shift = 0
     if stackCursorIndex != 0:
         currentParams = self._activeParams.Copy()
         self.InsertToGlyphString(glyphString, currentParams, ' ',
                                  stackCursorIndex)
         shift += 1
     currentParams = self._activeParams.Copy()
     currentParams.url = link
     self.InsertToGlyphString(glyphString, currentParams, text,
                              stackCursorIndex + shift)
     shift += shiftCursor
     currentParams = self._activeParams.Copy()
     self.InsertToGlyphString(glyphString, currentParams, ' ',
                              stackCursorIndex + shift)
     shift += 1
     self.UpdateGlyphString(glyphString,
                            advance=shiftCursor,
                            stackCursorIndex=stackCursorIndex)
     self.SetCursorPos(self.globalCursorPos + shift)
     self.UpdatePosition()
     cursorAdvance = 1
     if addLineBreak:
         self.Insert(uiconst.VK_RETURN)
示例#4
0
 def SetValue(self,
              text,
              add=0,
              keepSelection=0,
              updateIndex=1,
              docallback=1):
     text = text or ''
     isString = isinstance(text, basestring)
     if isString:
         text = uiutil.StripTags(text, stripOnly=['localized'])
     if self.floatmode:
         if isString:
             text = self.PrepareFloatString(text)
         text = self.CheckBounds(text, 0, bool(self.hinttext))
     elif self.integermode:
         text = self.CheckBounds(text, 0, bool(self.hinttext))
     else:
         text = text.replace('&lt;', '<').replace('&gt;', '>')
         if self.maxletters:
             text = text[:self.maxletters]
     if updateIndex:
         self.SetText(text, 0)
         self.caretIndex = self.GetCursorFromIndex(-1)
     self.SetText(text, 1)
     self.selFrom = self.selTo = None
     self.RefreshSelectionDisplay()
     self.OnTextChange(docallback)
示例#5
0
def CleanKillMail(killMailText):
    ret = killMailText
    import uiutil
    if '<localized' in ret:
        ret = ret.replace('*</localized>', '</localized>')
        ret = uiutil.StripTags(ret, stripOnly=['localized'])
    return ret.replace('<br>', '\r\n').replace('<t>', '   ')
def GetStrippedLabel(path, **kwargs):
    """
        gets the cerberus string from the path and strips of the localization tag
    """
    label = localization.GetByLabel(path, **kwargs)
    if isinstance(label, basestring):
        label = uiutil.StripTags(label, stripOnly=['localized'])
    return label
示例#7
0
    def ShowContent_thread(self, reload = 1):
        if getattr(self, 'loadingShowcontent', 0):
            return
        self.loadingShowcontent = 1
        try:
            channels = sm.GetService('LSC').GetChannels(reload)
            myChannels = localization.GetByLabel('UI/Chat/ChannelWindow/MyChannels')
            playerChannels = localization.GetByLabel('UI/Chat/ChannelWindow/PlayerChannels')
            otherChannels = localization.GetByLabel('UI/Chat/ChannelWindow/Other')
            tree = defaultdict(dict)
            tree[otherChannels] = {}
            groupNames = set([ row.groupMessageID for row in channels if row.groupMessageID and not row.temporary ])
            for groupMessageID in groupNames:
                tree[self.GetNameFromMessageIDWithReplacement(groupMessageID)] = {}

            for channel in channels:
                if channel.temporary:
                    continue
                if channel.groupMessageID:
                    groupName = self.GetNameFromMessageIDWithReplacement(channel.groupMessageID)
                    groupName = uiutil.StripTags(groupName, stripOnly=['localized'])
                    channelGroup = tree[groupName]
                    if channel.channelMessageID == const.CHAT_SYSTEM_CHANNEL:
                        if channel.displayName is not None:
                            channelName = localization.GetByLabel('UI/Chat/ChannelWindow/ChannelWithForienDisplay2', msg=localization.GetByLabel('UI/Chat/SystemChannels'), displayName=channel.displayName)
                        else:
                            channelName = localization.GetByLabel('UI/Chat/SystemChannels')
                        channelGroup[channelName] = channel
                    elif isinstance(channel.channelMessageID, unicode):
                        channelGroup[channel.channelMessageID] = channel
                    else:
                        if channel.displayName is not None:
                            channelName = localization.GetByLabel('UI/Chat/ChannelWindow/ChannelWithForienDisplay', msgID=channel.channelMessageID, displayName=channel.displayName)
                        else:
                            channelName = localization.GetByMessageID(channel.channelMessageID)
                        channelGroup[channelName] = channel
                else:
                    channelGroup = None
                    if channel.ownerID == const.ownerSystem:
                        channelGroup = tree[otherChannels]
                        channelName = self.GetNameFromMessageIDWithReplacement(channel.channelMessageID)
                    elif channel.ownerID == eve.session.charid:
                        channelGroup = tree[myChannels]
                        channelName = channel.displayName
                    else:
                        channelGroup = tree[playerChannels]
                        channelName = channel.displayName
                    if channelGroup is not None:
                        channelGroup[channelName] = channel

            if not self or self.destroyed:
                return
            scrolllist = self.__BuildTreeList(tree)
            h = [localization.GetByLabel('UI/Chat/ChannelWindow/Name'), localization.GetByLabel('UI/Chat/ChannelWindow/Members')]
            self.sr.scroll.Load(fixedEntryHeight=24, contentList=scrolllist, headers=h)
        finally:
            if self and not self.destroyed:
                self.loadingShowcontent = 0
 def OnEditChange(self, updatedText):
     self.LogInfo('OnEditChange', updatedText)
     if self.sr.columns:
         if len(self.sr.columns):
             if self.sr.columns[0] is not None and len(self.sr.columns[0]):
                 column = self.sr.columns[0][0]
                 rec = self.GetRec()
                 rec.titleName = uiutil.StripTags(
                     updatedText, stripOnly=['font', 'fontsize', 'br'])
def CleanKillMail(killMailText):
    """
        Unified place to strip formatting from killMails
    """
    ret = killMailText
    import uiutil
    if '<localized' in ret:
        ret = ret.replace('*</localized>', '</localized>')
        ret = uiutil.StripTags(ret, stripOnly=['localized'])
    return ret.replace('<br>', '\r\n').replace('<t>', '   ')
示例#10
0
 def PrepareDrag(cls, dragContainer, dragSource, *args):
     dragData = dragContainer.dragData[0]
     displayText = uiutil.TruncateStringTo(dragData.displayText, 24, '...')
     label = uicls.Label(parent=dragContainer,
                         text=uiutil.StripTags(displayText),
                         align=uiconst.TOPLEFT,
                         bold=True)
     uicls.Fill(parent=dragContainer,
                color=(0, 0, 0, 0.3),
                padding=(-10, -2, -10, -2))
     dragContainer.width = label.textwidth
     dragContainer.height = label.textheight
     return (2, label.textheight)
示例#11
0
 def ShowAgentAlert(self, agentID, message):
     agentService = sm.GetService('agents')
     agentInfo = agentService.GetAgentByID(agentID)
     agentSays = agentService.ProcessMessage(message, agentID)
     agentLocationWrap = agentService.GetAgentMoniker(agentID).GetAgentLocationWrap()
     html = '\n            <html>\n                <body background-color=#00000000 link=#FFA800>\n                    <br>\n                    %(agentHeader)s\n                    <table width=480 cellpadding=2>\n                        <tr>\n                            <td width=40 valign=top>\n                                <img style:vertical-align:bottom src="icon:ui_9_64_2" size="32">\n                            </td>\n                            <td>\n                                <font size=12>%(agentSays)s</font>\n                            </td>\n                        </tr>\n                    </table>\n                </body>\n            </html>\n        ' % {'agentHeader': agentDialogueUtil.GetAgentLocationHeader(agentInfo, agentLocationWrap, 0),
      'agentSays': agentSays}
     conversationTitle = uiutil.StripTags(localization.GetByLabel('UI/Agents/Dialogue/AgentConversationWith', agentID=agentID), stripOnly=['localized'])
     browser = form.AgentBrowser.Open(windowID='agentalert_%s' % agentID)
     browser.SetMinSize([512, 512])
     browser.LockWidth(512)
     browser.SetCaption(conversationTitle)
     uthread.new(browser.LoadHTML, html)
示例#12
0
    def GetSolarSystemTrace(self, itemID, altText=None, traceFontSize=12):
        if util.IsStation(itemID):
            solarSystemID = cfg.stations.Get(itemID).solarSystemID
        elif util.IsSolarSystem(itemID):
            solarSystemID = itemID
        else:
            structure = sm.GetService('structureDirectory').GetStructureInfo(
                itemID)
            if structure is None:
                raise RuntimeError('Invalid destination')
            solarSystemID = structure.solarSystemID
        try:
            sec, col = util.FmtSystemSecStatus(
                sm.GetService('map').GetSecurityStatus(solarSystemID), 1)
            col.a = 1.0
            securityLabel = "</b> <color=%s><hint='%s'>%s</hint></color>" % (
                util.StrFromColor(col),
                localization.GetByLabel('UI/Map/StarMap/SecurityStatus'), sec)
        except KeyError:
            self.LogError('Neocom failed to get security status for item',
                          solarSystemID, 'displaying BROKEN')
            log.LogException()
            sys.exc_clear()
            securityLabel = ''

        si = cfg.mapSystemCache.Get(solarSystemID)
        constellationID = si.constellationID
        regionID = si.regionID
        if altText:
            solarSystemAlt = " alt='%s'" % uiutil.StripTags(
                altText, stripOnly=['localized'])
        else:
            solarSystemAlt = ''
        locationTrace = '<url=showinfo:%s//%s%s>%s</url>%s' % (
            const.typeSolarSystem, solarSystemID, solarSystemAlt,
            cfg.evelocations.Get(solarSystemID).locationName, securityLabel)
        if traceFontSize:
            locationTrace += '<fontsize=12>'
        if not util.IsWormholeRegion(regionID):
            seperator = '<fontsize=%(fontsize)s> </fontsize>&lt;<fontsize=%(fontsize)s> </fontsize>' % {
                'fontsize': 8
            }
            locationTrace += seperator
            locationTrace += '<url=showinfo:%s//%s>%s</url>' % (
                const.typeConstellation, constellationID,
                cfg.evelocations.Get(constellationID).locationName)
            locationTrace += seperator
            locationTrace += '<url=showinfo:%s//%s>%s</url>' % (
                const.typeRegion, regionID,
                cfg.evelocations.Get(regionID).locationName)
        return locationTrace
示例#13
0
def Sort(iterable, cmp=None, key=lambda x: x, reverse=False, languageID=None):
    if cmp:
        raise ValueError(
            "Passing a compare function into Sort defeats the purpose of using a language-aware sort.  You probably want to use the 'key' parameter instead."
        )
    languageID = languageID or localizationInternalUtil.StandardizeLanguageID(
        languageID) or GetLanguageID()
    collator = eveLocalization.Collator()
    collator.locale = str(languageID)

    def caseSensitiveSubsort(left, right):
        if left.lower() == right.lower():
            return collator.Compare(unicode(right), unicode(left))
        return collator.Compare(unicode(left.lower()), unicode(right.lower()))

    if all([isinstance(key(each), (int, type(None))) for each in iterable]):

        def getPronunciation(messageID):
            if not messageID:
                return ''
            ret = ''
            try:
                ret = localization.GetMetaData(messageID,
                                               'pronounciation',
                                               languageID=languageID)
            except KeyError:
                ret = localization.GetByMessageID(messageID, languageID)

            return ret

        return sorted(iterable,
                      cmp=caseSensitiveSubsort,
                      key=lambda x: uiutil.StripTags(getPronunciation(key(x))),
                      reverse=reverse)
    return sorted(iterable,
                  cmp=caseSensitiveSubsort,
                  key=lambda x: uiutil.StripTags(key(x)),
                  reverse=reverse)
示例#14
0
    def GetStaticLabelsGroups(self):
        scrolllist = []
        lastViewedID = settings.char.ui.Get('mail_lastnotification', None)
        for groupID, labelPath in notificationUtil.groupNamePaths.iteritems():
            label = localization.GetByLabel(labelPath)
            entry = self.GetGroupEntry(groupID, label, groupID == lastViewedID)
            strippedLabel = uiutil.StripTags(label, stripOnly=['localized'])
            scrolllist.append((strippedLabel.lower(), entry))

        scrolllist = uiutil.SortListOfTuples(scrolllist)
        entry = self.GetGroupEntry(const.notificationGroupUnread, localization.GetByLabel('UI/Mail/Unread'), const.notificationGroupUnread == lastViewedID)
        scrolllist.insert(0, entry)
        scrolllist.insert(1, listentry.Get('Space', {'height': 12}))
        return scrolllist
示例#15
0
 def SaveNote(self, closing=0, *args):
     if not self.itemID:
         return
     if self.oldText is None:
         return
     text = self.edit.GetValue()
     if text is None:
         return
     toSave = None
     if len(uiutil.StripTags(text)):
         if self.oldText != text:
             toSave = text[:5000]
     elif self.oldText:
         toSave = ''
     if toSave is not None:
         uthread.new(sm.RemoteSvc('charMgr').SetNote, self.itemID, toSave)
示例#16
0
def GetAgentLocationHeader(agentInfo, agentLocation, loyaltyPoints=None):
    cfgAgent = cfg.eveowners.Get(agentInfo.agentID)
    if agentInfo.agentTypeID == const.agentTypeAura:
        agentInfoIcon = ''
        blurbEffectiveStanding = ''
        blurbDivision = ''
    else:
        agentInfoIcon = '<a href=showinfo:%d//%d><img src=icon:38_208 size=16 alt="%s"></a>' % (
            cfgAgent.typeID, agentInfo.agentID,
            uiutil.StripTags(localization.GetByLabel('UI/Commands/ShowInfo'),
                             stripOnly=['localized']))
        divisions = sm.GetService('agents').GetDivisions()
        blurbDivision = localization.GetByLabel(
            'UI/Agents/Dialogue/Division',
            divisionName=divisions[agentInfo.divisionID].divisionName)
    s = [
        sm.GetService('standing').GetEffectiveStanding(agentInfo.factionID,
                                                       session.charid)[0],
        sm.GetService('standing').GetEffectiveStanding(agentInfo.corporationID,
                                                       session.charid)[0],
        sm.GetService('standing').GetEffectiveStanding(agentInfo.agentID,
                                                       session.charid)[0]
    ]
    if min(*s) <= -2.0:
        blurbEffectiveStanding = localization.GetByLabel(
            'UI/Agents/Dialogue/EffectiveStandingLow',
            effectiveStanding=min(*s))
    else:
        es = max(*s) or 0.0
        blurbEffectiveStanding = localization.GetByLabel(
            'UI/Agents/Dialogue/EffectiveStanding', effectiveStanding=es)
    if loyaltyPoints:
        loyaltyPointsBlurb = localization.GetByLabel(
            'UI/Agents/Dialogue/LoyaltyPointsTableRow',
            loyaltyPoints=loyaltyPoints)
    else:
        loyaltyPointsBlurb = ''
    return '\n        <table border=0 cellpadding=0 cellspacing=0>\n            <tr>\n                <td valign=top width=140>\n                    <img src="portrait:%(agentID)d" width=128 height=128 size=256 style=margin-right:10>\n                </td>\n                <td valign=top>\n                    <font size=18>%(agentName)s</font> %(showInfoLink)s\n                    <br>\n                    %(blurbDivision)s\n                    <br><br>\n                    %(agentLocation)s\n                    <br>\n                    <br>\n                    %(blurbEffectiveStanding)s\n                    <br>\n                    %(loyaltyPoints)s\n                </td>\n            </tr>\n        </table>\n    ' % {
        'agentID': agentInfo.agentID,
        'agentName': cfgAgent.name,
        'showInfoLink': agentInfoIcon,
        'blurbDivision': blurbDivision,
        'agentLocation': LocationWrapper(agentLocation),
        'blurbEffectiveStanding': blurbEffectiveStanding,
        'loyaltyPoints': loyaltyPointsBlurb
    }
示例#17
0
def _RetChannelsTree(channels):
    """
    Convert the big list of channels into a shallow "tree" of grouped channels,
    from which we can eventually build a scroll-list for the UI.
    
    Returns a defaultdict of dicts of channels; keyed by groupName and channelName respectively.
    
    
    Each channel is an object-like thing -- in practice, is seems to be either
    a KeyVal or a blue.DBRow object, with fields including:
    
      channelID, groupMessageID, channelMessageID, ownerID, displayName
    
    (You can enumerate the column-named of a DBRow via its __columns__ member.)
    
    Refactored out of Channels::ShowContent_thread in an effort to make it clearer.
    """
    tree = defaultdict(dict)
    myChannels = localization.GetByLabel('UI/Chat/ChannelWindow/MyChannels')
    playerChannels = localization.GetByLabel('UI/Chat/ChannelWindow/PlayerChannels')
    otherChannels = localization.GetByLabel('UI/Chat/ChannelWindow/Other')
    tree[otherChannels] = {}
    for channel in channels:
        if channel.temporary:
            continue
        if channel.groupMessageID:
            groupName = _RetNameFromMessageID(channel.groupMessageID)
            groupName = uiutil.StripTags(groupName, stripOnly=['localized'])
            channelGroup = tree[groupName]
            channelName = _RetDetailedChannelName(channel)
            channelGroup[channelName] = channel
        else:
            if channel.ownerID == const.ownerSystem:
                channelGroup = tree[otherChannels]
                channelName = _RetNameFromMessageID(channel.channelMessageID)
            elif channel.ownerID == eve.session.charid:
                channelGroup = tree[myChannels]
                channelName = channel.displayName
            else:
                channelGroup = tree[playerChannels]
                channelName = channel.displayName
            channelGroup[channelName] = channel

    return tree
    def LoadData(self):
        self.services = self.corpStationMgr.GetStationServiceIdentifiers()
        self.servicesByID = {}
        self.serviceAccessRulesByServiceID = {}
        self.modifiedServiceAccessRulesByServiceID = {}
        self.modifiedServiceCostModifiers = []
        self.modifiedRentableItems = []
        serviceMask = self.GetStationServiceMask()
        for service in self.services:
            if not self.IsActiveService(service.serviceID):
                continue
            if service.serviceID == serviceMask & service.serviceID:
                self.servicesByID[service.serviceID] = service
                serviceAccessRule = self.corpStationMgr.GetStationServiceAccessRule(eve.session.stationid, service.serviceID)
                self.serviceAccessRulesByServiceID[service.serviceID] = serviceAccessRule
                log.LogInfo('serviceAccessRule:', serviceAccessRule)

        self.serviceCostModifiers = self.corpStationMgr.GetStationManagementServiceCostModifiers(eve.session.stationid)
        self.station = self.corpStationMgr.GetStationDetails(eve.session.stationid)
        orbitName = cfg.evelocations.Get(self.station.orbitID).GetRawName(localization.const.LOCALE_SHORT_ENGLISH)
        if self.station.stationName.startswith(orbitName):
            orbitNameStripped = uiutil.StripTags(orbitName)
            orbitNameStripped += ' - '
            self.station.stationName = uiutil.ReplaceStringWithTags(self.station.stationName, old=orbitNameStripped, new='')
        if self.station.description is None:
            self.station.description = ''
        log.LogInfo('GetStationDetails:', self.station)
        rentableItems = self.corpStationMgr.GetRentableItems()
        self.rentableItems = []
        for rentableItem in rentableItems:
            self.rentableItems.append(rentableItem)
            log.LogInfo('RentableItem:', rentableItem)

        self.rentableItems.sort(lambda x, y: -cmp(y.number, x.number))
        owners = []
        for each in self.rentableItems:
            if each.typeID != const.typeOfficeFolder:
                continue
            if each.rentedToID is not None and each.rentedToID not in owners:
                owners.append(each.rentedToID)

        if len(owners):
            cfg.eveowners.Prime(owners)
示例#19
0
 def SetText(self, text, format=0):
     if not isinstance(text, basestring):
         if self.integermode:
             text = repr(int(text))
         elif self.floatmode:
             text = '%.*f' % (self.floatmode[2], float(text))
         else:
             text = str(text)
     if self.passwordchar is not None:
         displayText = self.passwordchar * len(text.replace('<br>', ''))
     elif format:
         displayText = self.EncodeOutput(text) + self.suffix
     elif self.floatmode:
         displayText = text.replace(self.DECIMAL,
                                    self.GetLocalizedDecimal())
     else:
         displayText = text
     displayText = uiutil.StripTags(displayText, stripOnly=['localized'])
     self.sr.text.text = displayText.replace('<',
                                             '&lt;').replace('>', '&gt;')
     self.text = text
示例#20
0
文件: font.py 项目: R4M80MrX/eve-1
 def GetTextWidth(self,
                  strng,
                  fontsize=12,
                  letterspace=0,
                  uppercase=0,
                  font=None,
                  fontPath=None,
                  fontStyle=None,
                  fontFamily=None):
     if not strng:
         return 0
     font = font
     fontsize = fontsize or fontConst.DEFAULT_FONTSIZE
     letterspace = letterspace or fontConst.DEFAULT_LETTERSPACE
     uppercase = uppercase or fontConst.DEFAULT_UPPERCASE
     cacheKey = (strng, fontsize, letterspace, uppercase, font,
                 uicore.fontSizeFactor)
     if cacheKey in self.textMeasureCache:
         return self.textMeasureCache[cacheKey]
     if '<br>' in strng:
         val = max([
             self.GetTextWidth(line, fontsize, letterspace, uppercase, font)
             for line in strng.split('<br>')
         ])
     else:
         textmeasurer = uicls.Label(text=uiutil.StripTags(strng,
                                                          ignoredTags=['b'
                                                                       ]),
                                    parent=None,
                                    align=uiconst.TOPLEFT,
                                    fontsize=fontsize,
                                    letterspace=letterspace,
                                    uppercase=uppercase,
                                    measuringText=True,
                                    fontPath=fontPath,
                                    fontStyle=fontStyle,
                                    fontFamily=fontFamily)
         val = textmeasurer.textwidth
     self.textMeasureCache[cacheKey] = val
     return val
 def SetNameLabels(self, fullLabel, *args):
     """
         this function sets the name of item that's targeted.
         It first strips the localization tags if needed, that is if they have special localization hints,
         but does keep track of those hints to add later (to make sure we get special hints for other languages).
         Then the 1st label is set, and then we react if it's too long:
             find the index of the last  character that fits
             if the text is longer than that, break on the first (from end) space that is found, and put
             the remainder in the 2nd line. Then the 2nd line is faded out in the end if it's too long
             to fit.
     """
     hintMarkupStart = ''
     hintMarkupEnd = ''
     localizedHintPos = fullLabel.find('<localized hint')
     if localizedHintPos >= 0:
         strippedLabel = uiutil.StripTags(fullLabel,
                                          stripOnly=['localized'])
         hintEndIndex = fullLabel.find('">')
         if hintEndIndex > 0:
             hintMarkupStart = fullLabel[localizedHintPos:hintEndIndex + 2]
             hintMarkupEnd = '</localized>'
     else:
         strippedLabel = fullLabel
     self.sr.label.text = strippedLabel
     indexAtMaxLenght = self.sr.label.GetIndexUnderPos(self.width)
     if indexAtMaxLenght[0] < len(strippedLabel):
         lastBreak = strippedLabel.rfind(' ', 0, indexAtMaxLenght[0])
         if lastBreak != -1:
             self.sr.label.text = strippedLabel[:lastBreak]
         self.sr.label2.text = '<center>' + hintMarkupStart + strippedLabel[
             lastBreak:].strip() + hintMarkupEnd
         self.FadeText(self.sr.label2)
         self.sr.label2.display = True
     else:
         self.sr.label2.text = ''
         self.sr.label2.display = False
     self.sr.label.text = '<center>' + hintMarkupStart + self.sr.label.text + hintMarkupEnd
     self.lastTextUsedForLabel = self.label
示例#22
0
    def _PrepareListEntries(self, messages):
        """
        Prepares scroll list entries from message data as received from the logger.
        """
        showmsgs = []
        dateSortKey = 'sort_%s' % localization.GetByLabel(
            'UI/Common/DateWords/Time')
        openMsgTitle = localization.GetByLabel('UI/Accessories/Log/LogMessage')
        for msg in messages:
            msgtext, msgtype, timestamp = msg
            if not self.ShowMessage(msgtype):
                continue
            color = COLORS_BY_TYPE.get(msgtype, '<color=0xffffffff>')
            if msgtype:
                if msgtype in self.localizedMessages:
                    label = self.localizedMessages[msgtype]
                else:
                    label = msgtype
            else:
                label = localization.GetByLabel('UI/Accessories/Log/Generic')
            text = localization.GetByLabel('UI/Accessories/Log/MessageOutput',
                                           logtime=timestamp,
                                           color=color,
                                           label=label,
                                           message=uiutil.StripTags(
                                               msgtext, stripOnly=['t']))
            data = {
                'label': text,
                'canOpen': openMsgTitle,
                dateSortKey: timestamp,
                'line': 1
            }
            entry = listentry.Get('Generic', data=data)
            showmsgs.append(entry)

        return showmsgs
示例#23
0
 def AddLink(self, text, link=None):
     self.SetSelectionRange(None, None)
     text = uiutil.StripTags(text, stripOnly=['localized'])
     shiftCursor = len(text)
     node, obj, npos = self.GetNodeAndTextObjectFromGlobalCursor()
     if obj.letters:
         orgString = obj.letters
         orgIndex = node.stack.index(obj)
         obj.letters = orgString[:npos]
         firstSpaceObj = self.GetTextObject(' ')
         firstSpaceObj.a = None
         node.stack.insert(orgIndex + 1, firstSpaceObj)
         newObject = self.GetTextObject(' ')
         newObject.a = None
         node.stack.insert(orgIndex + 2, newObject)
         restObj = obj.Copy()
         restObj.letters = orgString[npos:]
         if restObj.letters:
             node.stack.insert(orgIndex + 3, restObj)
     else:
         newObject = obj
         newObject.a = None
     newObject.letters = text
     if link is not None:
         anchor = link
         attr = util.KeyVal()
         attr.href = anchor
         attr.alt = anchor
         newObject.a = attr
     endSpaceObj = newObject.Copy()
     endSpaceObj.letters = ' '
     endSpaceObj.a = None
     node.stack.insert(node.stack.index(newObject) + 1, endSpaceObj)
     self._OnResize(0)
     self.SetCursorPosAtObjectEnd(newObject)
     uicore.registry.SetFocus(self)
示例#24
0
 def SetCaption(self, caption):
     captionString = localizationUtil.LocalizationSafeString(uiutil.StripTags(caption)[:50])
     uicls.Window.SetCaption(self, captionString)
示例#25
0
    def GetMenu(self, *args):
        if eve.rookieState and eve.rookieState < 32:
            return []
        m = []
        if self.sr.Get('groupByType', 0):
            typedict = {}
            if self.sr.typeID and self.sr.itemID:
                m += [(uiutil.MenuLabel('UI/Commands/ShowInfo'), sm.GetService('menu').ShowInfo, (self.sr.typeID, self.sr.itemID))]
            menuItems = {const.groupAsteroidBelt: uiutil.MenuLabel('UI/Common/LocationTypes/AsteroidBelts'),
             const.groupPlanet: uiutil.MenuLabel('UI/Common/LocationTypes/Planets'),
             const.groupStargate: uiutil.MenuLabel('UI/Common/LocationTypes/Stargates'),
             const.groupStation: uiutil.MenuLabel('UI/Common/LocationTypes/Stations')}
            for item in self.sr.mapitems:
                if item.groupID in (const.groupMoon, const.groupSun, const.groupSecondarySun):
                    continue
                if item.groupID not in typedict:
                    typedict[item.groupID] = []
                typedict[item.groupID].append(item)

            listToSort = []
            for groupID, itemList in typedict.iteritems():
                menuLabel = menuItems[groupID]
                path = menuLabel[0]
                listToSort.append((localization.GetByLabel(path), (menuLabel, itemList)))

            sortedList = uiutil.SortListOfTuples(listToSort)
            for entry in sortedList:
                menuLabel, itemList = entry
                m.append((menuLabel, ('isDynamic', self.ExpandTypeMenu, (itemList,))))

            bookmarks = {}
            folders = {}
            b, f = sm.GetService('bookmarkSvc').GetBookmarksAndFolders()
            bookmarks.update(b)
            folders.update(f)
            bookmarkMenu = bookmarkUtil.GetBookmarkMenuForSystem(bookmarks, folders)
            if bookmarkMenu:
                m += bookmarkMenu
            agentMenu = sm.GetService('journal').GetMyAgentJournalBookmarks()
            if agentMenu:
                agentMenu2 = []
                for missionNameID, bms, agentID in agentMenu:
                    if isinstance(missionNameID, (int, long)):
                        missionName = localization.GetByMessageID(missionNameID)
                    else:
                        missionName = missionNameID
                    agentMenuText = uiutil.MenuLabel('UI/Neocom/MissionNameSubmenu', {'missionName': missionName,
                     'agent': agentID})
                    tmp = [agentMenuText, []]
                    for bm in bms:
                        if bm.solarsystemID == session.solarsystemid2:
                            txt = bm.hint
                            systemName = cfg.evelocations.Get(bm.solarsystemID).name
                            if bm.locationType == 'dungeon':
                                txt = txt.replace(' - %s' % systemName, '')
                            if '- Moon ' in txt:
                                txt = txt.replace(' - Moon ', ' - M')
                            if txt.endswith('- '):
                                txt = txt[:-2]
                            tmp[1].append((txt, ('isDynamic', self.CelestialMenu, (bm.itemID,
                               None,
                               None,
                               0,
                               None,
                               None,
                               bm))))

                    if tmp[1]:
                        agentMenu2.append(tmp)

                if agentMenu2:
                    agentMenuText = uiutil.MenuLabel('UI/Neocom/AgentMissionsSubmenu')
                    m += [None, (agentMenuText, lambda : None)] + agentMenu2
            contractsMenu = sm.GetService('contracts').GetContractsBookmarkMenu()
            if contractsMenu:
                m += contractsMenu
        else:
            if not self.itemssorted:
                self.sr.mapitems = uiutil.SortListOfTuples([ (item.itemName.lower(), item) for item in self.sr.mapitems ])
                self.itemssorted = 1
            maxmenu = 25
            if len(self.sr.mapitems) > maxmenu:
                groups = []
                approxgroupcount = len(self.sr.mapitems) / float(maxmenu)
                counter = 0
                while counter < len(self.sr.mapitems):
                    groups.append(self.sr.mapitems[counter:counter + maxmenu])
                    counter = counter + maxmenu

                for group in groups:
                    groupmenu = []
                    for item in group:
                        groupmenu.append((item.itemName or 'no name!', self.CelestialMenu(item.itemID, item)))

                    if len(groupmenu):
                        fromLetter = '???'
                        if group[0].itemName:
                            fromLetter = uiutil.StripTags(group[0].itemName)[0]
                        toLetter = '???'
                        if group[-1].itemName:
                            toLetter = uiutil.StripTags(group[-1].itemName)[0]
                        m.append((fromLetter + '...' + toLetter, groupmenu))

                return m
            for item in self.sr.mapitems[:30]:
                m.append((item.itemName or 'no name!', self.CelestialMenu(item.itemID, item)))

        m.append(None)
        starmapSvc = sm.GetService('starmap')
        showRoute = settings.user.ui.Get('neocomRouteVisible', 1)
        infoSettings = sm.GetService('infoPanel').GetLocationInfoSettings()
        if len(starmapSvc.GetWaypoints()) > 0:
            m.append((uiutil.MenuLabel('UI/Neocom/ClearAllAutopilotWaypoints'), starmapSvc.ClearWaypoints, (None,)))
        m.append(None)
        m.append((uiutil.MenuLabel('UI/Neocom/ConfigureSubmenu'), self.ConfigureLocationInfo))
        return m
示例#26
0
def GetStrippedLabel(path, **kwargs):
    label = localization.GetByLabel(path, **kwargs)
    if isinstance(label, basestring):
        label = uiutil.StripTags(label, stripOnly=['localized'])
    return label
示例#27
0
    def ShowOrders(self, isCorp=False, refreshing=0):
        if isCorp is None:
            isCorp = False
        if self.isCorp is None:
            self.isCorp = isCorp
        sscrollList = []
        sheaders = self.sr.sellScroll.sr.headers = [
            localization.GetByLabel('UI/Common/Type'),
            localization.GetByLabel('UI/Common/Quantity'),
            localization.GetByLabel('UI/Market/MarketQuote/headerPrice'),
            localization.GetByLabel('UI/Common/Station'),
            localization.GetByLabel('UI/Common/LocationTypes/Region'),
            localization.GetByLabel('UI/Market/Marketbase/ExpiresIn')
        ]
        if self.isCorp:
            sheaders.append(
                localization.GetByLabel(
                    'UI/Market/MarketQuote/headerIssuedBy'))
            sheaders.append(
                localization.GetByLabel(
                    'UI/Market/MarketQuote/headerWalletDivision'))
        visibleSHeaders = self.sr.sellScroll.GetColumns()
        bscrollList = []
        bheaders = self.sr.buyScroll.sr.headers = [
            localization.GetByLabel('UI/Common/Type'),
            localization.GetByLabel('UI/Common/Quantity'),
            localization.GetByLabel('UI/Market/MarketQuote/headerPrice'),
            localization.GetByLabel('UI/Common/Station'),
            localization.GetByLabel('UI/Common/LocationTypes/Region'),
            localization.GetByLabel('UI/Common/Range'),
            localization.GetByLabel('UI/Market/MarketQuote/HeaderMinVolumn'),
            localization.GetByLabel('UI/Market/Marketbase/ExpiresIn')
        ]
        if self.isCorp:
            bheaders.append(
                localization.GetByLabel(
                    'UI/Market/MarketQuote/headerIssuedBy'))
            bheaders.append(
                localization.GetByLabel(
                    'UI/Market/MarketQuote/headerWalletDivision'))
        visibleBHeaders = self.sr.buyScroll.GetColumns()
        marketUtil = sm.GetService('marketutils')
        if self.isCorp:
            orders = sm.GetService('marketQuote').GetCorporationOrders()
        else:
            orders = sm.GetService('marketQuote').GetMyOrders()
        if self.destroyed:
            return
        self.totalEscrow = 0.0
        self.totalLeft = 0.0
        self.totalIncome = 0.0
        self.totalExpenses = 0.0
        buySelected = self.sr.buyScroll.GetSelected()
        sellSelected = self.sr.sellScroll.GetSelected()
        funcs = sm.GetService('marketutils').GetFuncMaps()
        for order in orders:
            scroll = [self.sr.sellScroll, self.sr.buyScroll][order.bid]
            if scroll == self.sr.sellScroll:
                self.totalIncome += order.price * order.volRemaining
            else:
                self.totalExpenses += order.price * order.volRemaining
            data = util.KeyVal()
            data.label = ''
            data.typeID = order.typeID
            data.order = order
            data.OnDblClick = self.ShowMarketDetilsForTypeInOrder
            if cfg.invtypes.GetIfExists(order.typeID) is not None:
                data.showinfo = 1
            selected = [sellSelected, buySelected][order.bid]
            if selected and selected[0].order.orderID == order.orderID:
                data.isSelected = 1
            visibleHeaders = [visibleSHeaders, visibleBHeaders][order.bid]
            for header in visibleHeaders:
                header = uiutil.StripTags(header, stripOnly=['localized'])
                funcName = funcs.get(header, None)
                if funcName == 'GetQuantity':
                    funcName = 'GetQuantitySlashVolume'
                if funcName and hasattr(marketUtil, funcName):
                    apply(getattr(marketUtil, funcName, None), (order, data))
                else:
                    log.LogWarn('Unsupported header in record', header, order)
                    data.label += '###<t>'

            data.label = data.label.rstrip('<t>')
            [sscrollList, bscrollList
             ][order.bid].append(listentry.Get('OrderEntry', data=data))
            if order.bid:
                self.totalEscrow += order.escrow
                self.totalLeft += order.volRemaining * order.price - order.escrow

        buyScrollTo = None
        sellScrollTo = None
        if refreshing:
            buyScrollTo = self.sr.buyScroll.GetScrollProportion()
            sellScrollTo = self.sr.sellScroll.GetScrollProportion()
        self.sr.sellScroll.Load(contentList=sscrollList,
                                headers=sheaders,
                                scrollTo=sellScrollTo,
                                noContentHint=localization.GetByLabel(
                                    'UI/Market/Orders/NoOrdersFound'))
        self.sr.buyScroll.Load(contentList=bscrollList,
                               headers=bheaders,
                               scrollTo=buyScrollTo,
                               noContentHint=localization.GetByLabel(
                                   'UI/Market/Orders/NoOrdersFound'))
        if not isCorp:
            self.UpdateCounter(len(orders))
    def GetChart(self, typeID, days):
        history = sm.GetService('marketQuote').GetPriceHistory(typeID)
        timeStamps = []
        volData = []
        closeData = []
        lowData = []
        highData = []
        for x in history:
            if x[0] in timeStamps:
                continue
            timeStamps.append(x[0])
            volData.append(x[4])
            closeData.append(x[3])
            lowData.append(x[1])
            highData.append(x[2])

        availableData = len(timeStamps)
        windowData = settings.user.ui.Get('pricehistorytime', 90)
        fontFace = uicore.font.GetFontDefault()
        fontSize = int(8 * uicore.desktop.dpiScaling)
        trimData = availableData - windowData
        graphWidth, graphHeight = self.GetSize()
        graphWidth = int(graphWidth * uicore.desktop.dpiScaling)
        graphHeight = int(graphHeight * uicore.desktop.dpiScaling)
        for i in range(len(timeStamps)):
            stamp = timeStamps[i]
            year, month, wd, day, hour, min, sec, ms = util.GetTimeParts(stamp)
            timeStamps[i] = chartTime(year, month, day)

        isExtrapolated = 0
        daysAdded = 0
        if trimData < 0:
            daysAdded = -trimData
            isExtrapolated = 1
            trimData = 0
        elif windowData < 30:
            daysAdded = 5
            isExtrapolated = 1
        lastStamp = timeStamps[-1]
        for i in range(daysAdded):
            timeStamps.append(lastStamp + (i + 1) * 86400)

        actualData = availableData - trimData
        if windowData > 90:
            labels = ArrayMath(timeStamps).trim(
                trimData).selectStartOfMonth().result()
        elif windowData >= 10:
            labels = ArrayMath(timeStamps).trim(
                trimData).selectStartOfWeek().result()
        else:
            labels = ArrayMath(timeStamps).trim(
                trimData).selectStartOfDay().result()
        priceWidth = graphWidth
        priceHeight = graphHeight
        c = XYChart(priceWidth, priceHeight, Transparent)
        c.setMonthNames(self.months)
        palette = whiteOnBlackPalette
        BORDER_COLOR = 8947848
        palette[1] = BORDER_COLOR
        c.setColors(whiteOnBlackPalette)
        c.setBackground(Transparent)
        c.setTransparentColor(-1)
        c.setAntiAlias(1, 1)
        if availableData == 0:
            textBox = c.addText(
                20, graphHeight / 5,
                localization.GetByLabel('UI/PriceHistory/NoDataAvailable'),
                'normal', 24)
            return c.makeChart2(PNG)
        axis = c.yAxis()
        axis.setLabelStyle(fontFace, fontSize)
        axis.setAutoScale(0.1, 0.1, 0.3)
        axis.setTickDensity(int(40 * uicore.desktop.dpiScaling), -1)
        axis = c.yAxis2()
        axis.setLabelFormat('{value|,}')
        axis.setLabelStyle(fontFace, fontSize)
        axis.setAutoScale(0.8, 0.0, 1.0)
        axis.setColors(BORDER_COLOR, Transparent)
        labelFormatter = localization.GetByLabel(
            'UI/PriceHistory/PriceHistoryXAxisFormatter')
        labelFormatter = labelFormatter.replace('(', '{').replace(')', '}')
        c.xAxis().setLabels2(labels, labelFormatter)
        if windowData == 90:
            c.xAxis().setLabelStep(2)
        elif windowData == 365:
            c.xAxis().setLabelStep(2)
        c.xAxis().setLabelStyle(fontFace, fontSize)
        c.setXAxisOnTop()
        paLeft = int(70 * uicore.desktop.dpiScaling)
        paTop = int(20 * uicore.desktop.dpiScaling)
        if boot.region == 'optic':
            paRight = int(130 * uicore.desktop.dpiScaling)
        else:
            paRight = int(112 * uicore.desktop.dpiScaling)
        paBottom = int(40 * uicore.desktop.dpiScaling)
        c.setPlotArea(paLeft, paTop, priceWidth - paRight,
                      priceHeight - paBottom, 1711276032, -1, -1, 5592405)
        legendLeft = int(105 * uicore.desktop.dpiScaling)
        legendTop = int(18 * uicore.desktop.dpiScaling)
        legend = c.addLegend(legendLeft, legendTop, 0, fontFace, fontSize)
        legend.setBackground(Transparent)
        legend.setWidth(priceWidth - 150)
        trimmedCloseData = ArrayMath(closeData).trim(trimData).result()
        lst = []
        if not settings.user.ui.Get('market_setting_minmax',
                                    1) and not settings.user.ui.Get(
                                        'market_setting_donchian', 1):
            highData = lowData = closeData
        hloLayer = c.addHLOCLayer(
            ArrayMath(highData).trim(trimData).result(),
            ArrayMath(lowData).trim(trimData).result(), trimmedCloseData, [])
        hiloCol = mathUtil.LtoI(3724541696L) if settings.user.ui.Get(
            'market_setting_minmax', 1) else Transparent
        hloLayer.getDataSet(0).setDataColor(hiloCol)
        hloLayer.getDataSet(2).setDataColor(Transparent)
        hloLayer.getDataSet(3).setDataColor(Transparent)
        if settings.user.ui.Get('market_setting_movingavg5',
                                1) or settings.user.ui.Get(
                                    'market_setting_movingavg20', 1):
            if isExtrapolated:
                if settings.user.ui.Get('market_setting_movingavg5', 1):
                    avg5 = c.addLineLayer2()
                    lineColor = avg5.xZoneColor(
                        actualData - 1, 16711680,
                        c.dashLineColor(13647936, DashLine))
                    daysText = uiutil.StripTags(localization.GetByLabel(
                        '/Carbon/UI/Common/WrittenDateTimeQuantityShort/Day',
                        value=5),
                                                stripOnly=['localized'])
                    label = uiutil.StripTags(localization.GetByLabel(
                        'UI/PriceHistory/MovingAvg', numDays=daysText),
                                             stripOnly=['localized'])
                    avg5.addDataSet(
                        ArrayMath(closeData +
                                  5 * isExtrapolated * closeData[-1:]).movAvg(
                                      5).trim(trimData).result(), lineColor,
                        label)
                if settings.user.ui.Get('market_setting_movingavg20', 1):
                    avg20 = c.addLineLayer2()
                    lineColor = avg20.xZoneColor(
                        actualData - 1, 6750054,
                        c.dashLineColor(4247616, DashLine))
                    daysText = uiutil.StripTags(localization.GetByLabel(
                        '/Carbon/UI/Common/WrittenDateTimeQuantityShort/Day',
                        value=20),
                                                stripOnly=['localized'])
                    label = uiutil.StripTags(localization.GetByLabel(
                        'UI/PriceHistory/MovingAvg', numDays=daysText),
                                             stripOnly=['localized'])
                    avg20.addDataSet(
                        ArrayMath(closeData +
                                  5 * isExtrapolated * closeData[-1:]).movAvg(
                                      20).trim(trimData).result(), lineColor,
                        label)
            else:
                if settings.user.ui.Get('market_setting_movingavg5', 1):
                    daysText = uiutil.StripTags(localization.GetByLabel(
                        '/Carbon/UI/Common/WrittenDateTimeQuantityShort/Day',
                        value=5),
                                                stripOnly=['localized'])
                    avg5 = c.addLineLayer(
                        ArrayMath(closeData).movAvg(5).trim(trimData).result(),
                        16711680,
                        uiutil.StripTags(localization.GetByLabel(
                            'UI/PriceHistory/MovingAvg', numDays=daysText),
                                         stripOnly=['localized']))
                if settings.user.ui.Get('market_setting_movingavg20', 1):
                    daysText = uiutil.StripTags(localization.GetByLabel(
                        '/Carbon/UI/Common/WrittenDateTimeQuantityShort/Day',
                        value=20),
                                                stripOnly=['localized'])
                    avg20 = c.addLineLayer(
                        ArrayMath(closeData).movAvg(20).trim(
                            trimData).result(), 6750054,
                        uiutil.StripTags(localization.GetByLabel(
                            'UI/PriceHistory/MovingAvg', numDays=daysText),
                                         stripOnly=['localized']))
        if settings.user.ui.Get('market_setting_donchian', 1):
            upperBand = ArrayMath(highData).movMax(5).trim(trimData).result()
            lowerBand = ArrayMath(lowData).movMin(5).trim(trimData).result()
            uLayer = c.addLineLayer(
                upperBand, mathUtil.LtoI(2868864614L),
                GetStrippedLabel('UI/PriceHistory/DonchianChannel'))
            lLayer = c.addLineLayer(lowerBand, mathUtil.LtoI(2868864614L))
            c.addInterLineLayer(uLayer.getLine(), lLayer.getLine(),
                                mathUtil.LtoI(3674170982L))
        if settings.user.ui.Get('market_setting_mediandayprice', 1):
            lineLayer = c.addLineLayer(
                ArrayMath(closeData).trim(trimData).result(), Transparent,
                GetStrippedLabel('UI/PriceHistory/MedianDayPrice'))
            lineLayer.getDataSet(0).setDataSymbol(SquareSymbol,
                                                  5,
                                                  fillColor=16776960,
                                                  edgeColor=3355392)
        if settings.user.ui.Get('market_setting_volume', 1):
            barLayer = c.addBarLayer(
                ArrayMath(volData).trim(trimData).result(), 10092441)
            barLayer.setBorderColor(Transparent)
            barLayer.getDataSet(0).setUseYAxis2(1)
            if windowData <= 30:
                barLayer.setBarWidth(3)
        val = max(trimmedCloseData)
        lf = '{value|2,.}'
        if val < 10000L:
            lf = '{value|2,.}'
        elif val < 1000000L:
            lf = GetStrippedLabel(
                'UI/Market/PriceHistory/YaxisFormattingThousand',
                fmtString='{={value}/1000|2,.}')
        elif val < 1000000000L:
            lf = GetStrippedLabel(
                'UI/Market/PriceHistory/YaxisFormattingMillion',
                fmtString='{={value}/1000000|2,.}')
        elif val < 1000000000000L:
            lf = GetStrippedLabel(
                'UI/Market/PriceHistory/YaxisFormattingBillion',
                fmtString='{={value}/1000000000|2,.}')
        else:
            lf = GetStrippedLabel(
                'UI/Market/PriceHistory/YaxisFormattingTrillion',
                fmtString='{={value}/1000000000000|2,.}T')
        c.yAxis().setLabelFormat(lf)
        c.layout()
        yAxis = c.yAxis2()
        ticks = yAxis.getTicks()
        if len(ticks) > 2:
            for i in range(3):
                markValue = ticks[i]
                label = uiutil.StripTags(util.FmtAmt(markValue,
                                                     fmt='ss',
                                                     showFraction=1),
                                         stripOnly=['localized'])
                mark = yAxis.addMark(markValue, Transparent, label, fontFace,
                                     fontSize)
                mark.setMarkColor(Transparent, 16777215, 16777215)

        return c.makeChart2(PNG)
    def OnTabStationDetails(self):
        scrolllist = []
        scrolllist.append(listentry.Get('Header', {'label': localization.GetByLabel('UI/Station/StationManagment/StationDetails')}))
        orbitName = cfg.evelocations.Get(self.station.orbitID).name
        strippedOrbitName = uiutil.StripTags(orbitName)
        if orbitName != strippedOrbitName:
            orbitName = strippedOrbitName
        if orbitName[-1] == '*':
            orbitName = orbitName[:-1]
        if self.station.stationName.startswith(orbitName):
            editName = self.station.stationName[len(orbitName) + 3:]
        else:
            editName = self.station.stationName
        scrolllist.append(listentry.Get('Edit', {'label': localization.GetByLabel('UI/Station/StationManagment/Name'),
         'setValue': editName[:32],
         'name': 'details_name',
         'lines': 1,
         'maxLength': 32}))
        scrolllist.append(listentry.Get('TextEdit', {'label': localization.GetByLabel('UI/Common/Description'),
         'setValue': self.station.description,
         'name': 'details_description',
         'lines': 5,
         'maxLength': 5000,
         'killFocus': True}))
        scrolllist.append(listentry.Get('LabelTextTop', {'line': 1,
         'label': localization.GetByLabel('UI/Common/Security'),
         'text': self.station.security}))
        scrolllist.append(listentry.Get('Edit', {'label': localization.GetByLabel('UI/Station/StationManagment/DockingCostPerVolume'),
         'setValue': self.station.dockingCostPerVolume,
         'name': 'details_dockingCostPerVolume',
         'floatmode': (0.0, 1000.0)}))
        scrolllist.append(listentry.Get('Edit', {'label': localization.GetByLabel('UI/Station/StationManagment/OfficeRentalCost'),
         'setValue': self.station.officeRentalCost,
         'name': 'details_officeRentalCost',
         'intmode': (0, sys.maxint)}))
        exitTime = self.station.exitTime
        if exitTime is None:
            exitTime = 1200
        scrolllist.append(listentry.Get('Combo', {'options': self.GetHours(),
         'label': localization.GetByLabel('UI/Station/StationManagment/ReinforcedModeExitTime'),
         'cfgName': 'StationReinforcmentExitTimeCFG',
         'setValue': exitTime / 100,
         'OnChange': self.OnComboChange,
         'name': 'details_exitTime'}))
        maxshipvoldockable = localization.GetByLabel('UI/Station/StationManagment/MaxShipVolumeDockableAmount', maxshipvolume=util.FmtAmt(self.station.maxShipVolumeDockable), squaremeters=FormatUnit(cfg.dgmattribs.Get(const.attributeVolume).unitID))
        scrolllist.append(listentry.Get('LabelTextTop', {'line': 1,
         'label': localization.GetByLabel('UI/Station/StationManagment/MaxShipVolumeDockable'),
         'text': maxshipvoldockable}))
        if self.IsServiceAvailable(const.stationServiceReprocessingPlant):
            scrolllist.append(listentry.Get('Edit', {'OnReturn': None,
             'label': localization.GetByLabel('UI/Station/StationManagment/ReprocessingStationsTake'),
             'setValue': self.station.reprocessingStationsTake * 100,
             'name': 'details_reprocessingStationsTake',
             'floatmode': (0.0, 100.0)}))
            options = self.GetAvailableHangars()
            if len(options) == 0:
                scrolllist.append(listentry.Get('Header', {'label': localization.GetByLabel('UI/Station/StationManagment/NoDivisionHangarsWarning')}))
            else:
                default = None
                if self.station.reprocessingHangarFlag is not None:
                    for description, flag in options:
                        if self.station.reprocessingHangarFlag == flag:
                            default = flag
                            break

                data = {'options': options,
                 'label': localization.GetByLabel('UI/Station/StationManagment/ReprocessingOutput'),
                 'cfgName': 'reprocessingHangarFlag',
                 'setValue': default,
                 'OnChange': self.OnComboChange,
                 'name': 'reprocessingHangarFlag'}
                scrolllist.append(listentry.Get('Combo', data))
                if default is None:
                    self.station.reprocessingHangarFlag = options[0][1]
        scrolllist.append(listentry.Get('Divider'))
        scrolllist.append(listentry.Get('Button', {'label': '',
         'caption': localization.GetByLabel('UI/Station/StationManagment/IndustrySettings'),
         'OnClick': self.OpenFacilityStandingsConfiguration}))
        if eve.session.allianceid:
            scrolllist.append(listentry.Get('Divider'))
            scrolllist.append(listentry.Get('Button', {'label': '',
             'caption': localization.GetByLabel('UI/Inflight/POS/TransferSovStructureOwnership'),
             'OnClick': self.TransferStation}))
        self.ddxFunction = self.DDXTabStationDetails
        self.sr.scroll.Load(fixedEntryHeight=24, contentList=scrolllist)
示例#30
0
 def CleanHeaderValue(self, value):
     if localization.UseImportantTooltip():
         value = uiutil.StripTags(value)
     if localization.HighlightImportant() and isinstance(value, basestring) and value[-1] == localization.HIGHLIGHT_IMPORTANT_MARKER:
         value = value[:-1]
     return value