Esempio n. 1
0
    def _format(self, condition, event):
        result = []
        if event is None or not event.isGuiDisabled():
            camos = []
            for camoTypeName, camoID in CAMOUFLAGE_KINDS.iteritems():
                if camoID in condition.getValue():
                    camos.append(
                        formatters.packMissionCamoElement(camoTypeName))

            if camos:
                mapsTypesStr = i18n.makeString(
                    '#quests:details/conditions/mapsType')
                mapsTypeLabels = [iconData.iconLabel for iconData in camos]
                maps = ', '.join(mapsTypeLabels)
                tooltipBody = i18n.makeString(
                    QUESTS.MISSIONDETAILS_CONDITIONS_MAPSTYPE_BODY, maps=maps)
                tooltip = makeTooltip(mapsTypesStr, tooltipBody)
                if len(camos) > 1:
                    label = text_styles.main(
                        '#quests:missionDetails/conditions/mapsType')
                    iconsData = ''.join([iconData.icon for iconData in camos])
                else:
                    iconData = findFirst(None, camos)
                    label = text_styles.main(iconData.iconLabel)
                    iconsData = iconData.icon
                result.append(
                    formatters.packMissionPrebattleCondition(label,
                                                             icons=iconsData,
                                                             tooltip=tooltip))
        return result
 def __onChangeVehicleCamouflage(self, price, kind, resultID):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SERVER_ERROR)
         self.onCustomizationChangeFailed(message)
         return
     else:
         item = self.currentItemsByKind.get(kind)
         g_tankActiveCamouflage[g_currentVehicle.item.intCD] = kind
         item['id'] = item.get('newItemID')
         item['lifeCycle'] = None
         item['newItemID'] = None
         if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
             self._itemsDP.currentItemID = item['id']
         cost, isGold = price
         if cost == 0:
             key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_FREE
             typeValue = SystemMessages.SM_TYPE.Information
             str = i18n.makeString(key)
         else:
             if isGold:
                 key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_GOLD
                 fCost = BigWorld.wg_getGoldFormat(cost)
                 typeValue = SystemMessages.SM_TYPE.CustomizationForGold
             else:
                 key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_CREDITS
                 fCost = BigWorld.wg_getIntegralFormat(cost)
                 typeValue = SystemMessages.SM_TYPE.CustomizationForCredits
             str = i18n.makeString(key, fCost)
         self.onCustomizationChangeSuccess(str, typeValue)
         return
Esempio n. 3
0
    def __getKindById(self, kindId):
        kind = 'winter'
        for k, v in CAMOUFLAGE_KINDS.iteritems():
            if v == kindId:
                kind = k

        return kind
Esempio n. 4
0
 def __onChangeVehicleCamouflage(self, price, kind, resultID):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SERVER_ERROR)
         self.onCustomizationChangeFailed(message)
         return
     else:
         item = self.currentItemsByKind.get(kind)
         g_tankActiveCamouflage[g_currentVehicle.item.intCD] = kind
         item['id'] = item.get('newItemID')
         item['lifeCycle'] = None
         item['newItemID'] = None
         if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
             self._itemsDP.currentItemID = item['id']
         cost, isGold = price
         if isGold:
             key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_GOLD
             fCost = BigWorld.wg_getGoldFormat(cost)
             typeValue = SystemMessages.SM_TYPE.CustomizationForGold
         else:
             key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_CREDITS
             fCost = BigWorld.wg_getIntegralFormat(cost)
             typeValue = SystemMessages.SM_TYPE.CustomizationForCredits
         str = i18n.makeString(key, fCost)
         self.onCustomizationChangeSuccess(str, typeValue)
         return
Esempio n. 5
0
    def __getKindById(self, kindId):
        kind = 'winter'
        for k, v in CAMOUFLAGE_KINDS.iteritems():
            if v == kindId:
                kind = k

        return kind
Esempio n. 6
0
    def onRequestList(self, groupName):
        self.currentGroup = groupName
        customization = vehicles.g_cache.customization(self.nationID)
        result = []
        if customization is not None:
            groups = customization.get('camouflageGroups', {})
            group = groups.get(groupName, {})
            camouflages = customization.get('camouflages', {})
            armorColor = customization.get('armorColor', 0)
            ids = group.get('ids', [])
            currIntDescr = g_currentVehicle.item.intCD
            for id in ids:
                camouflageInfo = self._constructCamouflage(id, groups, camouflages, armorColor, isCurrent=self.currentItemID == id, isInHangar=CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, id, self.nationID), withoutCheck=False, currVehIntD=currIntDescr)
                if camouflageInfo is not None:
                    if not self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.NONE or self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.PREMIUM:
                        result.append(camouflageInfo)

            if gui.GUI_SETTINGS.igrEnabled:
                for name, group in groups.iteritems():
                    if name not in CAMOUFLAGE_KINDS:
                        ids = group.get('ids', [])
                        for cID in ids:
                            camouflage = camouflages.get(cID, None)
                            if camouflage.get('kind', 0) == CAMOUFLAGE_KINDS.get(groupName, 0):
                                camouflageInfo = self._constructCamouflage(cID, groups, camouflages, armorColor, isCurrent=self.currentItemID == cID, isInHangar=CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, cID, self.nationID), withoutCheck=False, currVehIntD=currIntDescr)
                                if camouflageInfo is not None and camouflageInfo:
                                    if not self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.NONE or self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.PREMIUM:
                                        result.append(camouflageInfo)

        return sorted(result, cmp=self.__comparator)
 def __onDropVehicleCamouflage(self, resultID, kind):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SERVER_ERROR)
         self.onCustomizationDropFailed(message)
         return
     item = self.currentItemsByKind.get(kind)
     hangarItem = CustomizationHelper.getItemFromHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE_TYPE, item.get('id'), self._nationID)
     if hangarItem:
         intCD = g_currentVehicle.item.intCD
         vehicle = vehicles.getVehicleType(int(intCD))
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_STORED_SUCCESS, vehicle=vehicle.userString)
     else:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SUCCESS)
     if g_tankActiveCamouflage.has_key(g_currentVehicle.item.intCD):
         del g_tankActiveCamouflage[g_currentVehicle.item.intCD]
     newID = None
     newLifeCycle = None
     if gui.game_control.g_instance.igr.getRoomType() != IGR_TYPE.NONE:
         camouflages = g_currentVehicle.item.descriptor.camouflages
         camo = camouflages[kind]
         if camo[0] is not None:
             newID = camo[0]
             newLifeCycle = (camo[1], camo[2])
     item['id'] = newID
     item['lifeCycle'] = newLifeCycle
     if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
         self._itemsDP.currentItemID = newID
     self.onCustomizationDropSuccess(message)
 def __onDropVehicleCamouflage(self, resultID, kind):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SERVER_ERROR)
         self.onCustomizationDropFailed(message)
         return
     else:
         item = self.currentItemsByKind.get(kind)
         hangarItem = CustomizationHelper.getItemFromHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE_TYPE, item.get('id'), self._nationID)
         if hangarItem:
             intCD = g_currentVehicle.item.intCD
             vehicle = vehicles.getVehicleType(int(intCD))
             message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_STORED_SUCCESS, vehicle=vehicle.userString)
         else:
             message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SUCCESS)
         if g_tankActiveCamouflage.has_key(g_currentVehicle.item.intCD):
             del g_tankActiveCamouflage[g_currentVehicle.item.intCD]
         newID = None
         newLifeCycle = None
         if gui.game_control.g_instance.igr.getRoomType() != IGR_TYPE.NONE:
             camouflages = g_currentVehicle.item.descriptor.camouflages
             camo = camouflages[kind]
             if camo[0] is not None:
                 newID = camo[0]
                 newLifeCycle = (camo[1], camo[2])
         item['id'] = newID
         item['lifeCycle'] = newLifeCycle
         if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
             self._itemsDP.currentItemID = newID
         self.onCustomizationDropSuccess(message)
         return
Esempio n. 9
0
 def py_onSyncData(self):
     # noinspection PyUnresolvedReferences
     texts = {
         'header': _config.i18n['UI_flash_header'],
         'nations': map(lambda x: i18n.makeString('#nations:%s' % x), nations.NAMES) + [
             _config.i18n['UI_flash_camoMode_modded'], _config.i18n['UI_flash_camoMode_international']],
         'camouflages': [[] for _ in xrange(len(nations.NAMES) + 2)],
         'randomOptions': {'text': _config.i18n['UI_flash_randomOptions_text'],
                           'tooltip': _config.tb.createTooltip('randomOptions', 'flash'),
                           'options': [_config.i18n['UI_flash_randomOptions_OFF'],
                                       _config.i18n['UI_flash_randomOptions_overrideRandom'],
                                       _config.i18n['UI_flash_randomOptions_includeInRandom']]},
         'useFor': {'header': _config.tb.createLabel('useFor_header', 'flash'),
                    'ally': _config.tb.createLabel('useFor_ally', 'flash'),
                    'enemy': _config.tb.createLabel('useFor_enemy', 'flash')},
         'kinds': {'header': _config.tb.createLabel('kinds_header', 'flash'),
                   'winter': _config.tb.createLabel('kinds_winter', 'flash'),
                   'summer': _config.tb.createLabel('kinds_summer', 'flash'),
                   'desert': _config.tb.createLabel('kinds_desert', 'flash')},
         'installTooltip': _config.i18n['UI_flash_installTooltip'],
         'save': _config.i18n['UI_flash_save']}
     settings = [[] for _ in xrange(len(nations.NAMES) + 2)]
     for idx, nation in enumerate(nations.NAMES + ('modded', 'international')):
         nationID = min(idx, len(nations.NAMES) - 1)
         camouflages = items.vehicles.g_cache.customization(nationID)['camouflages']
         camoNames = {camouflage['name']: camoID for camoID, camouflage in camouflages.items()}
         for camoName in camoNames.keys():
             if nation == 'modded':
                 if camoName not in _config.camouflages['modded']:
                     del camoNames[camoName]
             elif nation == 'international':
                 if camoName not in _config.origInterCamo:
                     del camoNames[camoName]
             elif camoName in _config.interCamo:
                 del camoNames[camoName]
         for camoName in sorted(camoNames.keys()):
             camoID = camoNames[camoName]
             camouflageDesc = camouflages[camoID]
             camouflage = _config.camouflages.get(nation, {}).get(camoName, {})
             texts['camouflages'][idx].append(camoName)
             camoSettings = {'randomOption': camouflage.get('random_mode', 2),
                             'camoInShop': g_customizationController.dataAggregator._elementIsInShop(
                                 camoID, 0, nationID),
                             'isInternational': camoName in _config.interCamo,
                             'useFor': {'ally': camouflage.get('useForAlly', True),
                                        'enemy': camouflage.get('useForEnemy', True)},
                             'kinds': {}}
             for key, kind in CAMOUFLAGE_KINDS.items():
                 if camouflage.get('kinds') is not None:
                     camoSettings['kinds'][key] = key in camouflage['kinds']
                 else:
                     camoSettings['kinds'][key] = kind == camouflageDesc['kind']
             settings[idx].append(camoSettings)
     self.flashObject.as_syncData({'texts': texts, 'settings': settings, 'ids': _config.backup})
     self.changeNation(self.getCurrentNation())
Esempio n. 10
0
 def refreshViewData(self, vehType, refresh=False):
     if vehType is not None:
         self._groupsDP.buildList()
         self._itemsDP.setVehicleTypeParams(
             self.getItemPriceFactor(vehType),
             self.getItemDefaultPriceFactor(vehType),
             self.currentItemsByKind.get(CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup, 0), {"id": None}).get(
                 "id"
             ),
         )
     self._rentalPackageDP.refreshList()
     return
Esempio n. 11
0
    def buildList(self):
        customization = vehicles.g_cache.customization(self._nationID)
        result = []
        if customization is not None:
            groups = customization.get('camouflageGroups', {})
            for name, info in groups.iteritems():
                result.append({'name': name,
                 'userString': info.get('userString', name),
                 'hasNew': info.get('hasNew', False),
                 'kind': CAMOUFLAGE_KINDS.get(name)})

        self.__list = sorted(result, cmp=self.__comparator)
        return
Esempio n. 12
0
    def buildList(self):
        customization = vehicles.g_cache.customization(self._nationID)
        result = []
        if customization is not None:
            groups = customization.get('camouflageGroups', {})
            for name, info in groups.iteritems():
                result.append({
                    'name': name,
                    'userString': info.get('userString', name),
                    'hasNew': info.get('hasNew', False),
                    'kind': CAMOUFLAGE_KINDS.get(name)
                })

        self.__list = sorted(result, cmp=self.__comparator)
        return
Esempio n. 13
0
 def __onDropVehicleCamouflage(self, resultID, kind):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SERVER_ERROR)
         self.onCustomizationDropFailed(message)
         return
     else:
         item = self.currentItemsByKind.get(kind)
         if g_tankActiveCamouflage.has_key(g_currentVehicle.item.intCD):
             del g_tankActiveCamouflage[g_currentVehicle.item.intCD]
         item['id'] = None
         item['lifeCycle'] = None
         if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
             self._itemsDP.currentItemID = None
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SUCCESS)
         self.onCustomizationDropSuccess(message)
         return
Esempio n. 14
0
    def update(self, vehicleDescr):
        camouflages = vehicleDescr.camouflages
        isUpdated = False
        for index, camouflage in enumerate(camouflages):
            camouflageID = camouflage[0] if camouflage is not None else None
            item = self.currentItemsByKind[index]
            if camouflageID != item.get('id'):
                isUpdated = True
                item['id'] = camouflageID
                if camouflage is not None:
                    _, startTime, days = camouflage
                    startTime = time_utils.makeLocalServerTime(startTime)
                    item['lifeCycle'] = (startTime, days)
                else:
                    item['lifeCycle'] = None
                if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == index:
                    self._itemsDP.currentItemID = item['id']

        if isUpdated:
            self.onCurrentItemChange(self._name)
Esempio n. 15
0
    def buildList(self):
        customization = vehicles.g_cache.customization(self._nationID)
        result = []
        compactDescr = g_currentVehicle.item.descriptor.type.compactDescr
        activeGroup = g_tankActiveCamouflage['historical'].get(compactDescr)
        if activeGroup is None:
            activeGroup = g_tankActiveCamouflage.get(compactDescr, 0)
        if customization is not None:
            groups = customization.get('camouflageGroups', {})
            for name, info in groups.iteritems():
                isHasNew = self._hasNewItems(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE_TYPE, info.get('ids', []))
                if name in CAMOUFLAGE_KINDS:
                    groupId = CAMOUFLAGE_KINDS.get(name)
                    result.append({'name': name,
                     'userString': info.get('userString', name),
                     'hasNew': isHasNew,
                     'kind': groupId,
                     'enabled': True,
                     'selected': activeGroup == groupId})

        self._list = sorted(result, cmp=self.__comparator)
Esempio n. 16
0
 def __onDropVehicleCamouflage(self, resultID, kind):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SERVER_ERROR)
         self.onCustomizationDropFailed(message)
         return
     item = self.currentItemsByKind.get(kind)
     if g_tankActiveCamouflage.has_key(g_currentVehicle.item.intCD):
         del g_tankActiveCamouflage[g_currentVehicle.item.intCD]
     newID = None
     newLifeCycle = None
     if gui.game_control.g_instance.igr.getRoomType() != IGR_TYPE.NONE:
         camouflages = g_currentVehicle.item.descriptor.camouflages
         camo = camouflages[kind]
         if camo[0] is not None:
             newID = camo[0]
             newLifeCycle = (camo[1], camo[2])
     item['id'] = newID
     item['lifeCycle'] = newLifeCycle
     if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
         self._itemsDP.currentItemID = newID
     message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SUCCESS)
     self.onCustomizationDropSuccess(message)
Esempio n. 17
0
def __readVehicleCamouflageKind(section):
    kindName = section.readString('vehicleCamouflageKind')
    kind = CAMOUFLAGE_KINDS.get(kindName)
    if kind is None:
        raise Exception("missing or wrong section 'vehicleCamouflageKind'")
    return kind
Esempio n. 18
0
def __readVehicleCamouflageKind(section):
    kindName = section.readString('vehicleCamouflageKind')
    kind = CAMOUFLAGE_KINDS.get(kindName)
    if kind is None:
        raise Exception("missing or wrong section 'vehicleCamouflageKind'")
    return kind
Esempio n. 19
0
    def resetCurrentItems(self):
        for k, v in CAMOUFLAGE_KINDS.iteritems():
            self.setCurrentItem(v, None, None, None, None)
            self.indexToKind[v] = k

        return
Esempio n. 20
0
 def refreshViewData(self, vehType, refresh = False):
     if vehType is not None:
         self._groupsDP.buildList()
         self._itemsDP.setVehicleTypeParams(self.getItemPriceFactor(vehType), self.getItemDefaultPriceFactor(vehType), self.currentItemsByKind.get(CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup, 0), {'id': None}).get('id'))
     self._rentalPackageDP.refreshList()
    def resetCurrentItems(self):
        for k, v in CAMOUFLAGE_KINDS.iteritems():
            self.setCurrentItem(v, None, None, None, None)
            self.indexToKind[v] = k

        return