Пример #1
0
 def IsValidTypeAndProperty(self, typeName, propertyName, languageID=None):
     IS_INVALID_TYPE = 0
     IS_INVALID_PROPERTY = 1
     IS_VALID_TYPE_AND_PROPERTY = 2
     result = None
     languageID = localizationInternalUtil.StandardizeLanguageID(
         languageID) or localizationUtil.GetLanguageID()
     foundType = self.languageTypesWithProperties.get(typeName, None)
     if foundType is not None:
         foundPropertyList = foundType.get(languageID, None)
         if foundPropertyList is not None:
             if propertyName in foundPropertyList:
                 result = IS_VALID_TYPE_AND_PROPERTY
             else:
                 result = IS_INVALID_PROPERTY
         else:
             result = IS_INVALID_PROPERTY
     else:
         result = IS_INVALID_TYPE
     if result == IS_INVALID_PROPERTY:
         LogError(
             "'%s' is not a valid property for '%s' in language '%s'." %
             (propertyName, typeName, languageID))
     elif result == IS_INVALID_TYPE:
         LogError(
             "'%s' is not a valid type; cannot retrieve properties for it."
             % typeName)
     elif result is None:
         LogError(
             'IsValidTypeAndProperty wasnt able to determine if type and property were valid: %s, %s'
             % (typeName, propertyName))
     return result == IS_VALID_TYPE_AND_PROPERTY
Пример #2
0
 def _QaTooltipOverride(self):
     if self._qaTooltipOverride is None:
         if localizationUtil.GetLanguageID() == self._primaryLanguageID:
             self._qaTooltipOverride = bool(
                 prefs.GetValue('simulateTooltip', False))
         else:
             self._qaTooltipOverride
     return self._qaTooltipOverride
Пример #3
0
 def UseImportantTooltip(self):
     if self._languageTooltipSetting is None:
         if localizationUtil.GetLanguageID() == self._primaryLanguageID:
             self._languageTooltipSetting = self._QaTooltipOverride()
         else:
             self._languageTooltipSetting = bool(
                 prefs.GetValue('languageTooltip', True))
     return self._languageTooltipSetting
Пример #4
0
 def HighlightImportant(self):
     if self._highlightImportantSetting is None:
         if localizationUtil.GetLanguageID() == self._primaryLanguageID:
             self._highlightImportantSetting = self._QaTooltipOverride()
         else:
             self._highlightImportantSetting = bool(
                 prefs.GetValue('localizationHighlightImportant', True))
     return self._highlightImportantSetting
Пример #5
0
 def UsePrimaryLanguageText(self):
     if self._importantNameSetting is None:
         if localizationUtil.GetLanguageID() == self._primaryLanguageID:
             self._importantNameSetting = 0
         else:
             self._importantNameSetting = int(
                 prefs.GetValue('localizationImportantNames', 0))
     return self._importantNameSetting == IMPORTANT_EN_OVERRIDE
Пример #6
0
 def GetMetaData(self, messageID, propertyName, languageID=None):
     languageID = localizationInternalUtil.StandardizeLanguageID(
         languageID) or localizationUtil.GetLanguageID()
     propertyString = self._GetMetaData(messageID, propertyName, languageID)
     if propertyString is not None:
         return localizationInternalUtil.PrepareLocalizationSafeString(
             propertyString, messageID=messageID)
     LogError(
         'a non existent property was requested. messageID,propertyName,languageID : %s,%s,%s'
         % (messageID, propertyName, languageID))
     return '[no property:%s,%s]' % (messageID, propertyName)
Пример #7
0
def ApplyQASettingsToString(textString):
    import localizationUtil
    import localization
    if textString and localizationUtil.IsHardcodedStringDetectionEnabled(
    ) and not IsLocalizationSafeString(textString):
        textString = localizationUtil.WrapHardcodedString(textString)
    elif textString and localizationUtil.GetLanguageID(
    ) == localization.LOCALE_SHORT_ENGLISH and localizationUtil.IsPseudolocalizationEnabled(
    ) and IsLocalizationSafeString(textString):
        textString = localization.Pseudolocalize(textString)
    return textString
Пример #8
0
def FormatGenericList(iterable, languageID=None, useConjunction=False):
    languageID = localizationInternalUtil.StandardizeLanguageID(
        languageID) or localizationUtil.GetLanguageID()
    stringList = [unicode(each) for each in iterable]
    delimiter = localization.GetByLabel(
        'UI/Common/Formatting/ListGenericDelimiter')
    if not useConjunction or len(stringList) < 2:
        listString = delimiter.join(stringList)
    elif len(stringList) == 2:
        listString = localization.GetByLabel(
            'UI/Common/Formatting/SimpleGenericConjunction',
            A=stringList[0],
            B=stringList[1])
    else:
        listPart = delimiter.join(stringList[:-1])
        listString = localization.GetByLabel(
            'UI/Common/Formatting/ListGenericConjunction',
            list=listPart,
            lastItem=stringList[-1])
    return localizationInternalUtil.PrepareLocalizationSafeString(
        listString, messageID='genericlist')
Пример #9
0
 def FormatImportantString(self, locText, englishText):
     if boot.region == 'optic':
         if not (session and session.role & ROLEMASK_ELEVATEDPLAYER):
             return locText
     playerLanguageID = localizationUtil.GetLanguageID()
     textString = None
     if playerLanguageID != self._primaryLanguageID:
         if self.UsePrimaryLanguageText():
             textString = englishText
             hintText = locText
         else:
             textString = locText
             hintText = englishText
         if self.HighlightImportant():
             textString = '%s*' % textString
         if self.UseImportantTooltip(
         ) and not localizationUtil.IsWrapModeOn():
             textString = '<localized hint="%s">%s</localized>' % (
                 hintText, textString)
     else:
         textString = locText
     return textString
Пример #10
0
 def GetByMessageID(self, messageID, languageID=None, **kwargs):
     if messageID is None:
         return ''
     if languageID is not None:
         languageID = localizationInternalUtil.StandardizeLanguageID(
             languageID)
     if languageID is None:
         languageID = localizationUtil.GetLanguageID()
     if session and 'player' not in kwargs:
         kwargs['player'] = session.charid
     try:
         textString = self._GetByMessageID(messageID, languageID, **kwargs)
         return localizationInternalUtil.PrepareLocalizationSafeString(
             textString, messageID=messageID)
     except KeyError:
         log.LogException()
         return u'[no messageID: %s]' % messageID
     except:
         log.LogException()
         try:
             return self._GetRawByMessageID(messageID)
         except:
             return u'[no messageID: %s]' % messageID
Пример #11
0
 def GetImportantByMessageID(self, messageID, **kwargs):
     if boot.region == 'optic':
         if not (session and session.role & ROLEMASK_ELEVATEDPLAYER):
             return self.GetByMessageID(messageID, **kwargs)
     if boot.role == 'proxy':
         return self.GetByMessageID(messageID, **kwargs)
     playerLanguageID = localizationUtil.GetLanguageID()
     textString = None
     if playerLanguageID != self._primaryLanguageID or self._QaTooltipOverride(
     ):
         if self.UsePrimaryLanguageText():
             textString = self.GetByMessageID(messageID,
                                              self._primaryLanguageID,
                                              **kwargs)
             hintLang = playerLanguageID
         else:
             textString = self.GetByMessageID(messageID, playerLanguageID,
                                              **kwargs)
             hintLang = self._primaryLanguageID
         if self.HighlightImportant():
             textString = '%s%s' % (textString, HIGHLIGHT_IMPORTANT_MARKER)
         if self.UseImportantTooltip(
         ) and not localizationUtil.IsWrapModeOn():
             if self._QaTooltipOverride(
             ) and playerLanguageID == self._primaryLanguageID:
                 hintString = textString[:-1][::-1]
             else:
                 hintString = self.GetByMessageID(messageID, hintLang,
                                                  **kwargs)
             hintString = hintString.replace('"', "'").replace('<',
                                                               '[').replace(
                                                                   '>', ']')
             textString = '<localized hint="%s">%s</localized>' % (
                 hintString or '', textString)
     else:
         textString = self.GetByMessageID(messageID, **kwargs)
     return textString
Пример #12
0
 def Search_thread(self, errorifnothing):
     if not self or self.destroyed:
         return
     self.searchresult = None
     search = self.sr.searchinput.GetValue().strip()
     if len(search) < 1:
         if errorifnothing:
             raise UserError('Min3Chars')
             return
     elif len(search) < 3 and not localizationUtil.IsSearchTextIdeographic(localizationUtil.GetLanguageID(), search):
         raise UserError('Min3Chars')
     else:
         self.SetHint()
         if self is not None and not self.destroyed:
             self.ShowLoad()
         else:
             return
         self.searchresult = sm.GetService('map').FindByName(search)
     if self is None or self.destroyed:
         return
     self.ShowSearchResult()
     if self == None:
         return
     self.HideLoad()
Пример #13
0
 def _GetRawByMessageID(self, messageID, languageID=None, **kwargs):
     languageID = languageID or localizationUtil.GetLanguageID()
     try:
         return eveLocalization.GetRawByMessageID(messageID, languageID)
     except:
         return '[no messageid: %s]' % messageID
Пример #14
0
 def IsValidMessageID(self, messageID, languageID=None):
     languageID = languageID or localizationUtil.GetLanguageID()
     return eveLocalization.IsValidMessageID(messageID, languageID)
Пример #15
0
    def DoRewardChart_Thread(self, rewardID, size, icon):
        reward = self.GetRewardData(rewardID)
        maxRewardValue = 0
        minPlayerCount = 0
        maxPlayerCount = 0
        allSecurityBandTable = None
        lowSecurityBandTable = None
        highSecurityBandTable = None
        for rewardCriteria, rewardTables in reward.immediateRewards.iteritems(
        ):
            if not rewardTables:
                continue
            if rewardCriteria == const.rewardCriteriaAllSecurityBands:
                maxRewardValue = self.GetMaxRewardValue(
                    rewardTables, const.rewardTypeISK)
                minPlayerCount = self.GetMinRewardPlayerCount(rewardTables)
                maxPlayerCount = self.GetMaxRewardPlayerCount(rewardTables)
                allSecurityBandTable = rewardTables[0]
                break
            if rewardCriteria == const.rewardCriteriaHighSecurity:
                highSecurityBandTable = rewardTables[0]
            elif rewardCriteria == const.rewardCriteriaLowSecurity:
                lowSecurityBandTable = rewardTables[0]
            else:
                continue
            maxRewardValue = max(
                maxRewardValue,
                self.GetMaxRewardValue(rewardTables, const.rewardTypeISK))
            minPlayerCount = min(minPlayerCount,
                                 self.GetMinRewardPlayerCount(rewardTables))
            maxPlayerCount = max(maxPlayerCount,
                                 self.GetMaxRewardPlayerCount(rewardTables))

        scale = 1.0 / maxRewardValue
        majorTick = (maxPlayerCount - minPlayerCount) / 4
        data = []
        labels = []
        for x in xrange(minPlayerCount, maxPlayerCount + 1):
            if allSecurityBandTable is not None:
                quantity = self.GetQuantityForCount(allSecurityBandTable,
                                                    x) * scale
                data.append(quantity)
            else:
                quantityHigh = self.GetQuantityForCount(
                    highSecurityBandTable, x) * scale
                quantityLow = self.GetQuantityForCount(lowSecurityBandTable,
                                                       x) * scale
                data.append((quantityHigh, quantityLow))
            labels.append(str(x))

        chart = XYChart(size, size, BLACK, GRAY, False)
        chart.setPlotArea(PLOT_OFFSET, PLOT_OFFSET,
                          size - PLOT_OFFSET - PLOT_RIGHT_MARGIN,
                          size - PLOT_OFFSET - PLOT_BOTTOM_MARGIN, DARKGRAY,
                          -1, -1, GRAY, Transparent)
        if localizationUtil.GetLanguageID(
        ) == localization.LOCALE_SHORT_ENGLISH:
            font = 'arial.ttf'
            titleFont = 'arialbd.ttf'
        else:
            font = titleFont = sm.GetService('font').GetFontDefault()
        chart.addLegend(LEGEND_OFFSET, LEGEND_OFFSET, 0, font,
                        8).setBackground(Transparent)
        legend = chart.getLegend()
        legend.setFontColor(WHITE)
        chart.addTitle(localization.GetByLabel('UI/Incursion/Reward/Title'),
                       titleFont, 12, WHITE).setBackground(Transparent)
        yAxis = chart.yAxis()
        yAxis.setTitle(
            localization.GetByLabel('UI/Incursion/Reward/PayoutMultiplier'),
            font, 10, WHITE)
        yAxis.setColors(GRAY, WHITE)
        yAxis.setLinearScale(0, 1.02, 0.5, 0.25)
        xAxis = chart.xAxis()
        xAxis.setLabels(labels)
        xAxis.setLabelStep(majorTick)
        xAxis.setColors(GRAY, WHITE)
        xAxis.setTitle(
            localization.GetByLabel('UI/Incursion/Reward/NumberPilots'), font,
            9, WHITE)
        layer = chart.addLineLayer2()
        layer.setLineWidth(1)
        if allSecurityBandTable is not None:
            layer.addDataSet(data, COLOR_HIGH_SEC,
                             localization.GetByLabel('UI/Common/Ratio'))
        else:
            dataHigh, dataLow = zip(*data)
            layer.addDataSet(dataHigh, COLOR_HIGH_SEC,
                             localization.GetByLabel('UI/Common/HighSec'))
            layer.addDataSet(dataLow, COLOR_NULL_SEC,
                             localization.GetByLabel('UI/Common/LowNullSec'))
        directory = os.path.normpath(
            os.path.join(blue.paths.ResolvePath(u'cache:/'), 'Pictures',
                         'Rewards'))
        if not os.path.exists(directory):
            os.makedirs(directory)
        pictureName = 'rewardchart2_%s_%d_%d.png' % (session.languageID, size,
                                                     rewardID)
        resPath = u'cache:/Pictures/Rewards/' + pictureName
        path = os.path.join(directory, pictureName)
        imageBuffer = chart.makeChart2(PNG)
        f = open(path, 'wb')
        f.write(imageBuffer)
        f.close()
        icon.LoadTexture(resPath)
        icon.SetRect(0, 0, size, size)