Example #1
0
 def changeSlotItem(self, slotID, itemIntCD):
     if itemIntCD is not None:
         cmp_helpers.getCmpConfiguratorMainView().installBattleBooster(
             itemIntCD)
     else:
         cmp_helpers.getCmpConfiguratorMainView().removeBattleBooster()
     _sendSelectSlotAction(self, slotID, itemIntCD)
     return
Example #2
0
 def changeSlotItem(self, slotID, itemIntCD):
     if itemIntCD is not None:
         cmp_helpers.getCmpConfiguratorMainView().installEquipment(
             itemIntCD, slotID)
     else:
         cmp_helpers.getCmpConfiguratorMainView().removeEquipment(slotID)
     _sendSelectSlotAction(self, slotID, itemIntCD)
     return
 def __onPanelSectionSelected(args):
     selectedSection = args.get('selectedSection')
     if selectedSection == TankSetupConstants.TOGGLE_SHELLS:
         selectedSlot = int(args['selectedSlot'])
         cmp_helpers.getCmpConfiguratorMainView().selectShell(selectedSlot)
     elif selectedSection == TankSetupConstants.TOGGLE_CAMOUFLAGE:
         cmpMainView = cmp_helpers.getCmpConfiguratorMainView()
         cmpMainView.selectCamouflage(not cmpMainView.isCamouflageSet())
     else:
         showCompareAmmunitionSelectorView(**args)
 def __onDragDropSwap(self, args):
     sectionName = args['sectionType']
     leftID, rightID = sorted((int(args['dragId']), int(args['dropId'])))
     if sectionName == TankSetupConstants.OPT_DEVICES:
         cmp_helpers.getCmpConfiguratorMainView().swapOptionalDevice(
             leftID, rightID)
         self.__sendDragAndDropSlotAction(
             sectionName,
             self.__vehItem.getItem().optDevices.layout, leftID, rightID)
     elif sectionName == TankSetupConstants.CONSUMABLES:
         cmp_helpers.getCmpConfiguratorMainView().swapEquipment(
             leftID, rightID)
         self.__sendDragAndDropSlotAction(
             sectionName,
             self.__vehItem.getItem().consumables.layout, leftID, rightID)
    def __packSkillsBlock():
        def __packSkill(crewRole, skills):
            skills = cmp_helpers.sortSkills(skills)
            skillsStr = ' '.join(
                (icons.makeImageTag(getSkillSmallIconPath(skillType), 14, 14,
                                    0, 0) for skillType in skills))
            return formatters.packCrewSkillsBlockData(
                text_styles.main(ITEM_TYPES.tankman_roles(crewRole)),
                skillsStr,
                getRoleWhiteIconPath(crewRole),
                padding={'left': -10})

        blocks = [
            formatters.packImageTextBlockData(title=text_styles.middleTitle(
                VEH_COMPARE.VEHCONF_TOOLTIPS_SKILLS_SKILLSLIST),
                                              padding={'bottom': 10})
        ]
        configurator_view = cmp_helpers.getCmpConfiguratorMainView()
        configured_vehicle = configurator_view.getCurrentVehicle()
        skills_by_roles = cmp_helpers.getVehicleCrewSkills(configured_vehicle)
        skills_by_roles.sort(
            key=lambda (role, skillsSet): Tankman.TANKMEN_ROLES_ORDER[role])
        blocks.extend((__packSkill(*data) for data in skills_by_roles))
        return formatters.packBuildUpBlockData(blocks,
                                               gap=0,
                                               padding={'bottom': -10})
Example #6
0
 def __packBonusBlock(self):
     blocks = []
     vehicle = cmp_helpers.getCmpConfiguratorMainView().getCurrentVehicle()
     camo = cmp_helpers.getSuitableCamouflage(vehicle)
     bonusTitleLocal = makeHtmlString(
         'html_templates:lobby/textStyle', 'bonusLocalText',
         {'message': '+{}'.format(camo.bonus.getFormattedValue(vehicle))})
     blocks.append(
         formatters.packImageTextBlockData(
             title=text_styles.concatStylesWithSpace(bonusTitleLocal),
             desc=text_styles.main(camo.bonus.description),
             img=camo.bonus.icon,
             imgPadding={
                 'left': 11,
                 'top': 3
             },
             txtGap=-4,
             txtOffset=65,
             padding={
                 'top': -1,
                 'left': 7
             }))
     if not self._showTTC and vehicle is not None:
         stockVehicle = self.itemsCache.items.getStockVehicle(vehicle.intCD)
         comparator = params_helper.camouflageComparator(vehicle, camo)
         stockParams = params_helper.getParameters(stockVehicle)
         simplifiedBlocks = SimplifiedStatsBlockConstructor(
             stockParams, comparator).construct()
         if simplifiedBlocks:
             blocks.extend(simplifiedBlocks)
     return formatters.packBuildUpBlockData(
         blocks,
         linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE
     )
 def _updateVehicle(self, isReset=False, *args, **kwargs):
     mainCfgView = cmp_helpers.getCmpConfiguratorMainView()
     self._vehicle = mainCfgView.getInitialVehicleData(
     )[0] if isReset else mainCfgView.getCurrentVehicle()
     self._selectionProvider.setPostProgression(
         self._vehicle.postProgression.clone())
     self._notifyCustomState(needDiff=False)
 def _onLoading(self, *args, **kwargs):
     super(CompareAmmunitionPanelView, self)._onLoading(*args, **kwargs)
     self.__vehItem = cmp_helpers.getCmpConfiguratorMainView(
     ).getCurrentVehicleItem()
     self.__ammunitionPanel = CompareAmmunitionPanel(
         self.viewModel.ammunitionPanel, self.__vehItem.getItem())
     self.__ammunitionPanel.onLoading()
Example #9
0
 def __init__(self, ctx=None):
     data_ = ctx['data']
     self.__initialLoad = True
     self.cmpVeh = cmp_helpers.getCmpConfiguratorMainView().getCurrentVehicle()
     slotType = data_.slotType
     slotIndex = data_.slotIndex
     logicProvider = _CmpVehBattleBoosterLogicProvider(slotType, slotIndex, self.cmpVeh)
     super(VehCmpBattleBoosterSelectPopover, self).__init__(ctx, logicProvider)
 def _createSlots(self):
     array = Array()
     slot = self._createAmmunitionSlot(0)
     slot.setIsSelected(
         cmp_helpers.getCmpConfiguratorMainView().isCamouflageSet())
     slot.setIsLocked(self._vehicle.isOutfitLocked)
     array.addViewModel(slot)
     return array
 def _onLoading(self, selectedSection='', selectedSlot=None):
     super(CompareAmmunitionSelectorView, self)._onLoading()
     self._vehItem = cmp_helpers.getCmpConfiguratorMainView(
     ).getCurrentVehicleItem()
     self._selectedSlotID = int(selectedSlot)
     self._tankSetup = MainTankSetupView(
         self.viewModel.tankSetup, CompareTankSetupBuilder(self._vehItem))
     self.viewModel.setSelectedSlot(self._selectedSlotID)
     self._tankSetup.onLoading(selectedSection, selectedSlot)
     fillVehicleInfo(self.viewModel.vehicleInfo, self._vehItem.getItem())
 def _packBlocks(self, *args):
     self._customCamo = args[0]
     self.__vehicle = cmp_helpers.getCmpConfiguratorMainView(
     ).getCurrentVehicle()
     self.__camo = cmp_helpers.getSuitableCamouflage(self.__vehicle)
     items = [
         self.__packTitleBlock(),
         self.__packBonusBlock(),
         self.__packBottomPanelBlock()
     ]
     return items
 def _fillControlsModel(self, model, postProgression=None):
     compareControl = model.compareControl
     cmpMainView = cmp_helpers.getCmpConfiguratorMainView()
     currentProgressionState = cmpMainView.getCurrentVehicle(
     ).postProgression.getState(implicitCopy=False)
     initialProgressionState = cmpMainView.getBasketVehCmpData(
     ).getInvPostProgressionState()
     customProgressionState = self._selectionProvider.getCustomProgressionState(
     )
     compareControl.setHasInitChanges(
         initialProgressionState != customProgressionState)
     compareControl.setHasChanges(
         currentProgressionState != customProgressionState)
 def _packBlocks(self, *args):
     self._customCamo = args[0]
     self.__vehicle = cmp_helpers.getCmpConfiguratorMainView(
     ).getCurrentVehicle()
     self.__camo = cmp_helpers.getSuitableCamouflage(self.__vehicle)
     camouflage = self.__vehicle.getBonusCamo()
     if camouflage is not None and not self.__camo:
         self.__camo = self.itemsCache.items.getItemByCD(
             camouflage.compactDescr)
         self._customCamo = False
     items = [
         self.__packTitleBlock(),
         self.__packBonusBlock(),
         self.__packBottomPanelBlock()
     ]
     return items
Example #15
0
 def __init__(self, ctx=None):
     data_ = ctx['data']
     slotType = data_.slotType
     slotIndex = data_.slotIndex
     cmpVeh = cmp_helpers.getCmpConfiguratorMainView().getCurrentVehicle()
     if self.__isEquipment(slotType):
         logicProvider = _CmpVehEquipmentLogicProvider(slotType, slotIndex, cmpVeh)
     elif self.__isOptionalDevice(slotType):
         logicProvider = _CmpVehOptDevicesLogicProvider(slotType, slotIndex, cmpVeh)
         self._TABS = [{'label': MENU.OPTIONALDEVICESELECTPOPOVER_TABS_SIMPLE,
           'id': 'simpleOptDevices'}, {'label': MENU.OPTIONALDEVICESELECTPOPOVER_TABS_DELUXE,
           'id': 'deluxeOptDevices'}]
     else:
         logicProvider = None
         LOG_ERROR('Unsupported slotType: {}'.format(slotType))
     super(VehCmpConfigSelectPopover, self).__init__(cmpVeh, logicProvider, ctx)
     return
 def __onPanelSlotClear(self, args):
     slotID = int(args.get('slotId'))
     sectionName = args.get('sectionType')
     if sectionName == TankSetupConstants.OPT_DEVICES:
         cmp_helpers.getCmpConfiguratorMainView().removeOptionalDevice(
             slotID)
     elif sectionName == TankSetupConstants.CONSUMABLES:
         cmp_helpers.getCmpConfiguratorMainView().removeEquipment(slotID)
     elif sectionName == TankSetupConstants.BATTLE_BOOSTERS:
         cmp_helpers.getCmpConfiguratorMainView().removeBattleBooster()
     self.__onSlotAction(setupName=sectionName,
                         actionType=BaseSetupModel.REVERT_SLOT_ACTION,
                         slotID=slotID)
Example #17
0
 def __packBonusBlock(self):
     blocks = []
     vehicle = cmp_helpers.getCmpConfiguratorMainView().getCurrentVehicle()
     itemID, camo = cmp_helpers.getSuitableCamouflage(vehicle)
     if camo:
         camo['itemID'] = itemID
     cmpItem = self.__getItem(camo, VEHICLE_CAMOUFLAGE_BONUS[vehicle.type])
     bonusTitleLocal = makeHtmlString('html_templates:lobby/textStyle', 'bonusLocalText', {'message': '{0}{1}'.format(cmpItem.qualifier.getFormattedValue(), '')})
     blocks.append(formatters.packImageTextBlockData(title=text_styles.concatStylesWithSpace(bonusTitleLocal), desc=text_styles.main(cmpItem.qualifier.getExtendedName()), img=cmpItem.qualifier.getIcon42x42(), imgPadding={'left': 11,
      'top': 3}, txtGap=-4, txtOffset=65, padding={'top': -1,
      'left': 7}))
     if not self._showTTC and vehicle is not None:
         stockVehicle = self.itemsCache.items.getStockVehicle(vehicle.intCD)
         comparator = params_helper.camouflageComparator(vehicle, cmpItem)
         stockParams = params_helper.getParameters(stockVehicle)
         simplifiedBlocks = SimplifiedStatsBlockConstructor(stockParams, comparator).construct()
         if len(simplifiedBlocks) > 0:
             blocks.extend(simplifiedBlocks)
     return formatters.packBuildUpBlockData(blocks, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)
 def _packBlocks(self, *args):
     self.__skillType = args[0]
     self.__showParams = args[1]
     items = [self.__packTitleBlock(), self.__packStatusBlock()]
     if self.__showParams:
         configuratorView = cmp_helpers.getCmpConfiguratorMainView()
         stockvehicle = configuratorView.getCurrentVehicle()
         stockParams = params_helper.getParameters(stockvehicle)
         currentParams = params.VehicleParams(stockvehicle).getParamsDict()
         vehicleWithSkill = configuratorView.getVehicleWithAppliedSkill(
             self.__skillType)
         if vehicleWithSkill is not None:
             updatedParams = params.VehicleParams(
                 vehicleWithSkill).getParamsDict()
             comparator = VehiclesComparator(updatedParams, currentParams)
             paramBlocks = self.__packParamsBlock(stockParams, comparator)
             if paramBlocks:
                 items.insert(
                     1,
                     formatters.packBuildUpBlockData(
                         paramBlocks,
                         linkage=BLOCKS_TOOLTIP_TYPES.
                         TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE))
     return items
 def __onApplyAction(self):
     customProgressionState = self._selectionProvider.getCustomProgressionState(
     )
     cmp_helpers.getCmpConfiguratorMainView().installPostProgression(
         customProgressionState)
     self.__onExitAction()
 def _onLoading(self, *args, **kwargs):
     super(CompareModificationsPanelView, self)._onLoading(*args, **kwargs)
     self.__vehItem = cmp_helpers.getCmpConfiguratorMainView(
     ).getCurrentVehicleItem()
     self.update()
 def _getDiffVehicle(self):
     return cmp_helpers.getCmpConfiguratorMainView().getInitialVehicleData(
     )[0]
 def setModule(self, newId, oldId, isRemove):
     cmp_config_view = cmp_helpers.getCmpConfiguratorMainView()
     if isRemove:
         cmp_config_view.removeBattleBooster()
     else:
         cmp_config_view.installBattleBooster(newId)
 def setModule(self, newId, oldId, isRemove):
     cmp_config_view = cmp_helpers.getCmpConfiguratorMainView()
     if isRemove:
         self._removeArtifact(cmp_config_view, self._slotIndex)
     else:
         self._installArtifact(cmp_config_view, newId, self._slotIndex)
 def __onClose(self):
     cmp_helpers.getCmpConfiguratorMainView().closeView()
 def __onClearModifications(self):
     cmp_helpers.getCmpConfiguratorMainView().removePostProgression()
 def updateBlock(self, viewModel):
     self.__selectedIndex = cmp_helpers.getCmpConfiguratorMainView(
     ).getCurrentShellIndex()
     super(CompareShellsBlock, self).updateBlock(viewModel)
def _getCmpVehicle():
    return cmp_helpers.getCmpConfiguratorMainView().getCurrentVehicle()
 def _getModVehicle(self):
     return cmp_helpers.getCmpConfiguratorMainView().getCurrentVehicleCopy()
def _getCmpInitialVehicle():
    return cmp_helpers.getCmpConfiguratorMainView().getInitialVehicleData()
 def updateBlock(self, viewModel):
     if not viewModel.getSlots():
         viewModel.setSlots(self._createSlots())
     else:
         isSet = cmp_helpers.getCmpConfiguratorMainView().isCamouflageSet()
         viewModel.getSlots()[0].setIsSelected(isSet)