def addMutualListeners(self, mutualListeners): if isinstance(mutualListeners, ListenersCollection): self._mutualListeners = mutualListeners else: LOG_ERROR('Object is not extend {0:>s}'.format(ListenersCollection.__name__), mutualListeners)
def doAction(self, notID, actionsNames, actorName=''): if notID not in self.__nots: LOG_ERROR('Notification is not found', notID) return False return self.__nots[notID].invoke(actionsNames, actorName)
def join(self, ctx, callback=None): LOG_ERROR('NotSupportedEntry.join', ctx)
def getIndex(self, name): if not self.__texMap.has_key(name): if name != '': LOG_ERROR("Invalid texture name '%s'" % name) return -1 return self.__texMap[name]
def getNotItemByType(self, notID, name): if notID not in self.__nots: LOG_ERROR('Notification is not found', notID) return return self.__nots[notID].getItemByType(name)
def __getattr__(self, item): try: return self[item] except KeyError: LOG_ERROR("sync data object has no key '%s'", item)
def goToResearch(self): if g_currentVehicle.isPresent() and self.__isNavigationEnabled: shared_events.showResearchView(g_currentVehicle.item.intCD) else: LOG_ERROR( 'Current vehicle is not preset or navigation is disabled')
def error(self, area, message, *args): if area != CLIENT_LOG_AREA.GLOOX_XML: LOG_ERROR(self.__makeHeader(area, message), *args)
def show(self, notID): ctrl = getRefSysCtrl() if ctrl: ctrl.showReferralIntroWindow(self._referrer, self._isNewbie) else: LOG_ERROR('Referral system controller is not found')
def wrapper(*args, **kwargs): generator = func(*args, **kwargs) if not isinstance(generator, types.GeneratorType): LOG_ERROR('Method %s from %s marked as process is not a generator!' % (func.__name__, os.path.relpath(func.func_code.co_filename))) return generator doCall(func, partial(CallbackDispatcher, generator, stepCallback))
def _printOverrideError(self, methodName): LOG_ERROR('Method must be override!', methodName, self.__class__)
def createEntry(self, ctx): LOG_ERROR('preQueue functional has not any entries')
def _getTotalPrice(self): sellPrice = self.item.sellPrices.itemPrice.price if not sellPrice: LOG_ERROR('Attempt to sell item {} that is not sold.'.format( self.item)) return sellPrice * self.count
def _getTotalPrice(self): buyPrice = self.item.buyPrices.itemPrice.price if not buyPrice: LOG_ERROR('Incorrect attempt to buy item {}'.format(self.item)) return buyPrice * self.count
def new_setTipsInfo(self): DEFAULT_BATTLES_COUNT = 100 arena = getClientArena() isFallout = arena.guiType == constants.ARENA_GUI_TYPE.EVENT_BATTLES arenaDP = self._battleCtx.getArenaDP() if hasResourcePoints(): bgUrl = RES_ICONS.MAPS_ICONS_EVENTINFOPANEL_FALLOUTRESOURCEPOINTSEVENT elif hasFlags(): bgUrl = RES_ICONS.MAPS_ICONS_EVENTINFOPANEL_FALLOUTFLAGSEVENT else: bgUrl = '' if isFallout: self.as_setEventInfoPanelDataS({ 'bgUrl': bgUrl, 'items': getHelpTextAsDicts(arena.arenaType) }) if not self._BattleLoading__isTipInited: battlesCount = DEFAULT_BATTLES_COUNT if g_lobbyContext.getBattlesCount() is not None: battlesCount = g_lobbyContext.getBattlesCount() vType, vLvl, nation = arenaDP.getVehicleInfo().getTypeInfo() tipsIterator = tips.getTipsIterator(arena.guiType, battlesCount, vType, nation, vLvl) statusStr, tipStr = ('', '') if tipsIterator is not None: statusStr, tipStr = next(tipsIterator) else: LOG_ERROR('No required tips found') self.as_setTipTitleS(text_styles.highTitle(statusStr)) #------win chance---- content = text_styles.playerOnline(tipStr) if Statistics.myConf['win_chance_enable'] and Statistics.okCw(): win_chance = Statistics.getWinChance() if win_chance: arenaTypeID = getArenaTypeID() colour = '#ff0000' if win_chance < 49: colour = '#ff0000' elif win_chance >= 49 and win_chance <= 51: colour = '#ffff00' elif win_chance > 51: colour = '#00ff00' formatz = {'win_chance': win_chance, 'color': colour} content += Statistics.myConf['win_chance_text'].format( **formatz) self.as_setTipS(content) #--------------------- #----- table ---------- if Statistics.myConf['table_enable'] and Statistics.okCw(): x, y = GUI.screenResolution() Statistics.table = BattleLoadingBarTable( Statistics.myConf['table_texture']) Statistics.table.setWidthMode('PIXEL') Statistics.table.setHeightMode('PIXEL') Statistics.table.setVerticalPositionMode('PIXEL') Statistics.table.setHorizontalPositionMode('PIXEL') Statistics.table.setHorizontalAnchor('LEFT') Statistics.table.setVerticalAnchor('TOP') Statistics.table.setWidth( Statistics.myConf['table_width']) #400 Statistics.table.setHeight( Statistics.myConf['table_height']) #5 Statistics.table.setPosition( eval(Statistics.myConf['table_position'])) Statistics.table.setMaterialFx( Statistics.myConf['table_materialFX']) Statistics.table.setColor( eval(Statistics.myConf['table_color'])) Statistics.table.setVisible(True) Statistics.table.add() config = {} config['texture'] = Statistics.myConf['table_bars_texture'] config['width'] = Statistics.myConf['table_bars_width'] config['height'] = Statistics.myConf['table_bars_height'] config['position'] = eval( Statistics.myConf['table_bars_position']) config['delta'] = Statistics.myConf['table_bars_delta'] config['font'] = Statistics.myConf['table_bars_font'] config['materialFX'] = Statistics.myConf[ 'table_bars_materialFX'] config['color'] = ( eval(Statistics.myConf['table_bars_color'][0]), eval(Statistics.myConf['table_bars_color'][1])) config[VEHICLE_CLASS_NAME.LIGHT_TANK] = Statistics.myConf[ VEHICLE_CLASS_NAME.LIGHT_TANK] config[VEHICLE_CLASS_NAME.MEDIUM_TANK] = Statistics.myConf[ VEHICLE_CLASS_NAME.MEDIUM_TANK] config[VEHICLE_CLASS_NAME.HEAVY_TANK] = Statistics.myConf[ VEHICLE_CLASS_NAME.HEAVY_TANK] config[VEHICLE_CLASS_NAME.SPG] = Statistics.myConf[ VEHICLE_CLASS_NAME.SPG] config[VEHICLE_CLASS_NAME.AT_SPG] = Statistics.myConf[ VEHICLE_CLASS_NAME.AT_SPG] config['table_bars_label'] = Statistics.myConf[ 'table_bars_label'] config['table_bars_odd_pos'] = Statistics.myConf[ 'table_bars_label_pos'] config['show_label'] = Statistics.myConf[ 'table_bars_tankType_show'] config['show_perc'] = Statistics.myConf[ 'table_bars_label_show'] config['align'] = Statistics.myConf['table_bars_align'] Statistics.table.addBars(config) #--------------------- self._BattleLoading__isTipInited = True return
def unregisterOptimizationArea(self, optimizationID): if optimizationID in self.__cache: self.__cache.pop(optimizationID) self.__optimizer.unregisterRect(optimizationID) else: LOG_ERROR('Graphics optimization ID is not found', optimizationID)
def handleAction(self, model, entityID, action): super(DeclinePrbInviteHandler, self).handleAction(model, entityID, action) if entityID: self.prbInvites.declineInvite(entityID) else: LOG_ERROR('Invite is invalid', entityID)
def _readCfg(self, dataSec): if dataSec is None: LOG_ERROR('Invalid dataSection.') return else: criticalHitDecalAngle = dataSec.readFloat('criticalAngle', 30.0) BigWorld.setDamageStickerCriticalAngle(criticalHitDecalAngle) self.__cfg['groups'] = dict() groups = self.__cfg['groups'] for group in dataSec['groups'].values(): desc = dict() desc['lifeTime'] = _readFloat(group, 'lifeTime', 0, 1000, 1) desc['trianglesCount'] = _readFloat(group, 'trianglesCount', 1000, 100000, 1000) groups[group.name] = desc self.__cfg['textures'] = dict() textures = self.__cfg['textures'] for texture in dataSec['textures'].values(): textures[texture.name] = texture.readString('texture') chassisEffectsSection = ResMgr.openSection( 'scripts/item_defs/vehicles/common/chassis_effects.xml') if not chassisEffectsSection or chassisEffectsSection[ 'decals'] is None: LOG_ERROR('Failed to read chassis_effects.xml file') return dataSec = chassisEffectsSection['decals'] for group in dataSec['bufferPrefs'].values(): desc = dict() desc['lifeTime'] = _readFloat(group, 'lifeTime', 0, 1000, 1) desc['trianglesCount'] = _readFloat(group, 'trianglesCount', 1000, 100000, 1000) groups[group.name] = desc if IS_EDITOR: self.__chassisEffectGroups[group.name] = desc for sMatId in dataSec['scales'].values(): scaleU = _readFloat(sMatId, 'scaleU', 1, 2, 1) for matKind in material_kinds.EFFECT_MATERIAL_IDS_BY_NAMES[ sMatId.name]: BigWorld.wg_addMatkindScaleU(sMatId.name, matKind, scaleU) for dsTexSet in dataSec['textureSets'].values(): ts = {} _DIF_TEXT = 0 _BUMP_TEXT = 1 _STRAFE_DIF_TEXT = 2 _STRAFE_BUMP_TEXT = 3 for dsMaterial in dsTexSet.values(): tsMaterial = [None, None, None, None] ts[dsMaterial.name] = tsMaterial for dsTexture in dsMaterial.values(): texName = dsMaterial.readString(dsTexture.name) texIndex = BigWorld.wg_traceTextureIndex(texName) self.__texMap[texName] = texIndex textListIndex = _DIF_TEXT if dsTexture.name == 'ANM': textListIndex = _BUMP_TEXT elif dsTexture.name == 'STRAFE_AM': textListIndex = _STRAFE_DIF_TEXT elif dsTexture.name == 'STRAFE_ANM': textListIndex = _STRAFE_BUMP_TEXT tsMaterial[textListIndex] = texIndex self.__textureSets[dsTexSet.name] = ts return
def goToResearch(self): if g_currentVehicle.isPresent(): shared_events.showResearchView(g_currentVehicle.item.intCD) else: LOG_ERROR('Current vehicle is not preset')
def safeCancelCallback(callbackID): try: BigWorld.cancelCallback(callbackID) except ValueError: LOG_ERROR('Cannot cancel BigWorld callback: incorrect callback ID.')
def _initData(self, *args): stats = g_itemsCache.items.stats self.as_setGoldS(stats.gold) self.as_setCreditsS(stats.credits) windowExpanded = AccountSettings.getSettings(VEHICLE_BUY_WINDOW_SETTINGS) vehicle = g_itemsCache.items.getItem(GUI_ITEM_TYPE.VEHICLE, self.nationID, self.inNationID) if vehicle is None: LOG_ERROR("Vehicle Item mustn't be None!", 'NationID:', self.nationID, 'InNationID:', self.inNationID) elif vehicle.isInInventory and not vehicle.isRented: self.onWindowClose() else: shop = g_itemsCache.items.shop shopDefaults = shop.defaults tankMenCount = len(vehicle.crew) tankMenStudyPrice = shop.tankmanCostWithGoodyDiscount totalTankMenStudePrice = tankMenCount * Money(credits=tankMenStudyPrice[1]['credits'], gold=tankMenStudyPrice[2]['gold']) defTankMenStudyPrice = shopDefaults.tankmanCost defTotalTankMenStudePrice = tankMenCount * Money(credits=defTankMenStudyPrice[1]['credits'], gold=defTankMenStudyPrice[2]['gold']) studyPriceCreditsActionData = None if totalTankMenStudePrice != defTotalTankMenStudePrice: studyPriceCreditsActionData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'creditsTankmanCost', True, totalTankMenStudePrice, defTotalTankMenStudePrice) studyPriceGoldActionData = None if totalTankMenStudePrice != defTotalTankMenStudePrice: studyPriceGoldActionData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'goldTankmanCost', True, totalTankMenStudePrice, defTotalTankMenStudePrice) vehiclePricesActionData = None if vehicle.buyPrice != vehicle.defaultPrice: vehiclePricesActionData = packItemActionTooltipData(vehicle) ammoPrice = ZERO_MONEY defAmmoPrice = ZERO_MONEY for shell in vehicle.gun.defaultAmmo: ammoPrice += shell.buyPrice * shell.defaultCount defAmmoPrice += shell.defaultPrice * shell.defaultCount ammoActionPriceData = None if ammoPrice != defAmmoPrice: ammoActionPriceData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.AMMO, str(vehicle.intCD), True, ammoPrice, defAmmoPrice) slotPrice = shop.getVehicleSlotsPrice(stats.vehicleSlots) slotDefaultPrice = shopDefaults.getVehicleSlotsPrice(stats.vehicleSlots) slotActionPriceData = None if slotPrice != slotDefaultPrice: slotActionPriceData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'slotsPrices', True, Money(gold=slotPrice), Money(gold=slotDefaultPrice)) tankmenLabel = i18n.makeString(DIALOGS.BUYVEHICLEDIALOG_TANKMENLABEL, count=text_styles.titleFont(i18n.makeString(DIALOGS.BUYVEHICLEDIALOG_TANKMEN) + ' ' + str(tankMenCount))) initData = {'expanded': windowExpanded, 'name': vehicle.userName, 'shortName': vehicle.shortUserName, 'longName': vehicle.longUserName, 'description': vehicle.fullDescription, 'type': vehicle.type, 'icon': vehicle.icon, 'nation': self.nationID, 'level': vehicle.level, 'isElite': vehicle.isElite, 'tankmenLabel': tankmenLabel, 'studyPriceCredits': totalTankMenStudePrice.credits, 'studyPriceCreditsActionData': studyPriceCreditsActionData, 'studyPriceGold': totalTankMenStudePrice.gold, 'studyPriceGoldActionData': studyPriceGoldActionData, 'vehiclePrices': vehicle.buyPrice, 'vehiclePricesActionData': vehiclePricesActionData, 'ammoPrice': ammoPrice.credits, 'ammoActionPriceData': ammoActionPriceData, 'slotPrice': slotPrice, 'slotActionPriceData': slotActionPriceData, 'isRentable': vehicle.isRentable, 'isStudyDisabled': vehicle.hasCrew, 'isNoAmmo': not vehicle.hasShells, 'rentDataDD': self._getRentData(vehicle, vehiclePricesActionData)} self.as_setInitDataS(initData) return
def readConfDict(self, quiet, confdict, confPath, sourceModel=None, upperName=''): for confKey, configDict in confdict.items(): if upperName: confKey = upperName + '.' + confKey if confKey in ('enable', 'meta', 'attachToPlayer', 'attachToAlly', 'attachToEnemy'): continue if any(confKey in curConfigsDict for curConfigsDict in self.configsDict.values()): print self.ID + ':', confPath + ': overlap detected:', confKey, 'already exists.' continue model = None if 'model' in configDict['type']: try: model = BigWorld.Model(configDict['path']) except StandardError: print 'LampLights: model path incorrect: %s' % configDict[ 'path'] continue if not upperName: if configDict['place'] not in ('leftFront', 'rightFront', 'leftRear', 'rightRear', 'hull', 'wheels_left', 'wheels_right', 'turret', 'spot'): LOG_ERROR('Unknown place of %s: %s.' % (confKey, configDict['place'])) continue else: try: sourceModel.node(configDict['place']) except ValueError: LOG_ERROR('Unknown place of %s: %s.' % (confKey, configDict['place'])) continue if not configDict['visible']: if not quiet: print self.ID + ':', confKey, 'disabled in config.' continue self.configsDict[os.path.basename(confPath).split('.') [0]][confKey] = confDict = {} for key in ('type', 'place', 'mode', 'preRotate', 'postRotate', 'vect'): confDict[key] = listToTuple(configDict[key]) for key in ('attachToPlayer', 'attachToAlly', 'attachToEnemy'): confDict[key] = self.configsDict[os.path.basename( confPath).split('.')[0]][key] if confDict['mode'] not in self.modes: print self.ID + ': unknown mode in', confKey, 'detected:', confDict[ 'mode'] + '. This light will be off.' else: self.modes[confDict['mode']].append(confKey) if 'model' not in confDict['type']: for key in ('colour', 'bright', 'innerRadius', 'outerRadius', 'dur', 'cs'): confDict[key] = listToTuple(configDict[key]) if confDict['type'] == 'spotLight': confDict['ca'] = configDict['ca'] else: confDict['path'] = configDict['path'] if 'subLights' in configDict: self.readConfDict(quiet, configDict['subLights'], confPath, sourceModel=model, upperName=confKey) if self.data['Debug'] and not quiet: print self.ID + ':', confKey, 'loaded.'
def getTextureSet(self, name): if not self.__textureSets.has_key(name): LOG_ERROR("Invalid texture set name '%s'" % name) return dict() return self.__textureSets[name]
def readCurrentSettings(self, quiet=True): self.configsDict.clear() self.modes = { 'constant': [], 'stop': [], 'turn_left': [], 'turn_right': [], 'back': [], 'target': [], 'spot': [] } super(ConfigInterface, self).readCurrentSettings(quiet) if self.data['DebugModel']: if self.data['DebugPath']: try: _ = BigWorld.Model(self.data['DebugPath']) except StandardError: LOG_ERROR('Debug model path incorrect: %s' % self.data['DebugPath']) self.data['DebugModel'] = False else: LOG_NOTE('Debug disabled due to absence of DebugPath.') self.data['DebugModel'] = False if self.data['enabled']: configPath = self.configPath + 'configs/' if not os.path.exists(configPath): LOG_ERROR('%s config folder not found: %s' % (self.ID, configPath)) os.makedirs(configPath) for confPath in glob.iglob(configPath + '*.json'): confName = os.path.basename(confPath) try: confdict = loadJson( self.ID, confName.split('.')[0], self.configsDict.get(confName.split('.')[0], {}), os.path.dirname(confPath) + '/') except StandardError: print self.ID + ': config', confName, 'is invalid.' traceback.print_exc() continue if not confdict['enable'] or not any( x for x in (confdict.get(y, True) for y in ('attachToPlayer', 'attachToAlly', 'attachToEnemy'))): if not quiet: print self.ID + ': config', confName, 'is disabled.' continue if self.data['Debug']: print self.ID + ': loading', confName + ':' self.configsDict[confName.split('.')[0]] = configsDict = {} configsDict['meta'] = metaDict = { 'name': '<b>%s</b>' % confName, 'desc': self.i18n['UI_setting_meta_NDA'] } metaDict['name'] = confdict.get('meta', {}).get(self.lang, {}).get( 'name', metaDict['name']) metaDict['desc'] = confdict.get('meta', {}).get(self.lang, {}).get( 'desc', metaDict['desc']) for key in ['attachToPlayer', 'attachToAlly', 'attachToEnemy']: configsDict[key] = confdict.get(key, True) self.readConfDict(quiet, confdict, confPath) if not self.configsDict: print 'LampLights has not loaded any configs. Are you sure you need this .pyc?' if self.data['DebugModel'] and self.configsDict: if self.data['Debug'] and not quiet: print 'LampLights: loading configs for Debug:' for fileName, configsDict in self.configsDict.items(): for confKey in configsDict.keys(): if confKey in ('enable', 'meta', 'attachToPlayer', 'attachToAlly', 'attachToEnemy'): continue if configsDict.get(confKey + 'Debug') is None: if 'model' not in configsDict[confKey]['type']: self.configsDict[fileName][ confKey + 'Debug'] = confDict = {} confDict['type'] = 'model' for key in ('place', 'preRotate', 'postRotate', 'vect', 'mode', 'attachToPlayer', 'attachToAlly', 'attachToEnemy'): confDict[key] = listToTuple( configsDict[confKey][key]) if confDict['mode'] not in self.modes: print 'LampLights: unknown mode at %sDebug detected: %s. This light will be off.' \ % (confKey, confDict['mode']) else: self.modes[confDict['mode']].append( confKey + 'Debug') confDict['path'] = self.data['DebugPath'] if self.data['Debug'] and not quiet: print 'LampLights: config for %sDebug loaded.' % confKey elif self.data['Debug'] and not quiet: print 'LampLights: debug assignment failure: %sDebug' % confKey else: LOG_NOTE('LampLights mod fully disabled via main config.') self.isLampsVisible = False self.isTickRequired = any(self.modes[key] for key in ('stop', 'turn_left', 'turn_right', 'back')) self.updateMod()
def showNotItemByName(self, notID, target): if notID not in self.__nots: LOG_ERROR('Notification is not found', notID) return True self.__nots[notID].showItem(notID, target)
def lightsCreate(vehicleID, callPlace=''): try: vehicle = BigWorld.player().arena.vehicles[vehicleID] vEntity = BigWorld.entity(vehicleID) if vEntity is None: return vDesc = vEntity.typeDescriptor if vehicleID == BigWorld.player().playerVehicleID: print 'LampLights: Create at %s' % callPlace constNodesList = [ TankNodeNames.TRACK_LEFT_UP_FRONT, TankNodeNames.TRACK_LEFT_UP_REAR, TankNodeNames.TRACK_RIGHT_UP_FRONT, TankNodeNames.TRACK_RIGHT_UP_REAR ] compoundModel = vEntity.appearance.compoundModel nodeListML, nodeListNL = findWheelNodes(vehicleID, 'L') nodeListMR, nodeListNR = findWheelNodes(vehicleID, 'R') fakesDict[vehicleID] = fakeDict = {} fakeMotorsDict[vehicleID] = fakeMotorDict = {} sourcesDict = {TankPartNames.CHASSIS: None, TankPartNames.HULL: None} for tankPartName in sourcesDict.keys(): curSource = getattr(vDesc, tankPartName).models.undamaged modelSec = ResMgr.openSection(curSource) if modelSec is None: print 'LampLights: file not found:', curSource sourceSecStr = modelSec['nodefullVisual'].asString sourceSec = ResMgr.openSection(sourceSecStr + '.visual') if sourceSec is None: sourceSec = ResMgr.openSection(sourceSecStr + '.visual_processed') if sourceSec is None: print 'LampLights: visual not found for', curSource print callPlace else: sourcesDict[tankPartName] = sourceSec HullMat = math_utils.createIdentityMatrix() deHullMat = math_utils.createIdentityMatrix() if sourcesDict[TankPartNames.CHASSIS] is not None: deHullMat = nodeWatcher(sourcesDict[TankPartNames.CHASSIS], 'V') deHullMat.invert() for tankPartName in (TankPartNames.CHASSIS, TankPartNames.HULL): fakeDict[tankPartName] = BigWorld.Model('objects/fake_model.model') fakeDict[tankPartName + 'Root'] = BigWorld.Model('objects/fake_model.model') compoundModel.node(TankPartNames.HULL).attach( fakeDict[tankPartName + 'Root'], HullMat if 'hull' in tankPartName else deHullMat) if fakeMotorDict.get(tankPartName) not in tuple( fakeDict[tankPartName].motors): fakeMotorDict[tankPartName] = BigWorld.Servo( fakeDict[tankPartName + 'Root'].matrix) fakeDict[tankPartName].addMotor(fakeMotorDict[tankPartName]) if fakeDict[tankPartName] not in tuple(BigWorld.models()): BigWorld.addModel(fakeDict[tankPartName]) for idx, node in enumerate(nodeListNL): fakeDict[node] = BigWorld.Model('objects/fake_model.model') fakeDict[TankPartNames.CHASSIS].node('', nodeListML[idx]).attach( fakeDict[node]) for idx, node in enumerate(nodeListNR): fakeDict[node] = BigWorld.Model('objects/fake_model.model') fakeDict[TankPartNames.CHASSIS].node('', nodeListMR[idx]).attach( fakeDict[node]) for node in constNodesList: fakeDict[node] = BigWorld.Model('objects/fake_model.model') restoreMat = math_utils.createIdentityMatrix() transMat = None isChassis = False if sourcesDict[TankPartNames.HULL] is not None: transMat = nodeWatcher(sourcesDict[TankPartNames.HULL], node) if transMat is None and sourcesDict[ TankPartNames.CHASSIS] is not None: transMat = nodeWatcher(sourcesDict[TankPartNames.CHASSIS], node) if transMat is None: transMat = nodeWatcher(sourcesDict[TankPartNames.CHASSIS], node.replace('Up', '')) isChassis = True if transMat is None and isChassis: # wheeled placed = node.split('_')[-1] place, side = placed[:1], placed[1:] template = 'HP_Wheel_%s_0%s_%s' % (place, '%s', side) edge = None if side == 'Front': edge = nodeWatcher(sourcesDict[TankPartNames.CHASSIS], template % 1) else: for idx in xrange(1, 10): found = nodeWatcher(sourcesDict[TankPartNames.CHASSIS], template % idx) if found is None: break edge = found if edge is not None: wheels = nodeListML if place == 'L' else nodeListMR sign = 1 if side == 'Front' else -1 center = max(wheels, key=lambda x: x.translation.z * sign) rotator = Math.Matrix() rotator.setRotateX(-sign * 3.1415 * 3 / 4) transMat = Math.Matrix() transMat.setTranslate( center.applyPoint( rotator.applyPoint(edge.translation - center.translation))) if transMat is None: print _config.ID + ': restore Matrix not found for node', node, 'in', vDesc.hull.models.undamaged print callPlace else: restoreMat.setTranslate(transMat.translation) fakeDict[TankPartNames.HULL if not isChassis else TankPartNames. CHASSIS].node('', restoreMat).attach(fakeDict[node]) fakeDict[TankPartNames.GUN + 'Root'] = BigWorld.Model('objects/fake_model.model') compoundModel.node(TankPartNames.GUN).attach( fakeDict[TankPartNames.GUN + 'Root']) fakeDict[TankPartNames.GUN] = BigWorld.Model( 'objects/fake_model.model') if fakeMotorDict.get(TankPartNames.GUN) not in tuple( fakeDict[TankPartNames.GUN].motors): fakeMotorDict[TankPartNames.GUN] = BigWorld.Servo( fakeDict[TankPartNames.GUN + 'Root'].matrix) fakeDict[TankPartNames.GUN].addMotor( fakeMotorDict[TankPartNames.GUN]) if fakeDict[TankPartNames.GUN] not in tuple(BigWorld.models()): BigWorld.addModel(fakeDict[TankPartNames.GUN]) fakeDict[TankPartNames.TURRET] = BigWorld.Model( 'objects/fake_model.model') fakeDict[TankPartNames.TURRET + 'Root'] = BigWorld.Model('objects/fake_model.model') fakeDict[TankPartNames.TURRET + 'RootRoot'] = BigWorld.Model('objects/fake_model.model') hull_bbox_min, hull_bbox_max, _ = vDesc.hull.hitTester.bbox turret_pos_on_hull = vDesc.hull.turretPositions[0] turret_bbox_max = vDesc.turret.hitTester.bbox[1] gun_pos_on_turret = vDesc.turret.gunPosition gun_pos_on_hull = gun_pos_on_turret + turret_pos_on_hull gun_bbox_max = vDesc.gun.hitTester.bbox[1] if hull_bbox_max.y >= turret_pos_on_hull.y + turret_bbox_max.y: observer_pos = Math.Vector3(0, hull_bbox_max.y, 0) node = TankPartNames.HULL elif gun_pos_on_turret.y + gun_bbox_max.y >= turret_bbox_max.y: observer_pos = Math.Vector3(0, gun_bbox_max.y, 0) node = TankPartNames.GUN else: observer_pos = Math.Vector3(0, turret_bbox_max.y, 0) node = TankPartNames.TURRET mat = Math.Matrix() mat.setTranslate(observer_pos) compoundModel.node(node).attach(fakeDict[TankPartNames.TURRET + 'RootRoot']) if fakeMotorDict.get(TankPartNames.TURRET + 'Root') not in tuple( fakeDict[TankPartNames.TURRET + 'Root'].motors): fakeMotorDict[TankPartNames.TURRET + 'Root'] = BigWorld.Servo( fakeDict[TankPartNames.TURRET + 'RootRoot'].matrix) fakeDict[TankPartNames.TURRET + 'Root'].addMotor( fakeMotorDict[TankPartNames.TURRET + 'Root']) if fakeDict[TankPartNames.TURRET + 'Root'] not in tuple( BigWorld.models()): BigWorld.addModel(fakeDict[TankPartNames.TURRET + 'Root']) fakeDict[TankPartNames.TURRET + 'Root'].node('', mat).attach( fakeDict[TankPartNames.TURRET]) hullLocalCenterY = (hull_bbox_min.y + hull_bbox_max.y) / 2.0 hullLocalCenterZ = (hull_bbox_min.z + hull_bbox_max.z) / 2.0 nodes = { 'hullLocalPt1': Math.Vector3(0.0, hullLocalCenterY, hull_bbox_max.z), 'hullLocalPt2': Math.Vector3(0.0, hullLocalCenterY, hull_bbox_min.z), 'hullLocalPt3': Math.Vector3(hull_bbox_max.x, gun_pos_on_hull.y, hullLocalCenterZ), 'hullLocalPt4': Math.Vector3(hull_bbox_min.x, gun_pos_on_hull.y, hullLocalCenterZ), 'hullGunLocal': gun_pos_on_hull } for node in nodes: fakeDict[node] = BigWorld.Model('objects/fake_model.model') fakeDict[TankPartNames.HULL].node( '', math_utils.createTranslationMatrix(nodes[node])).attach( fakeDict[node]) lightDBDict.setdefault(vehicleID, {}) for configDict in _config.configsDict.values(): for name in sorted(configDict.keys()): try: if name in ('enable', 'meta', 'attachToPlayer', 'attachToAlly', 'attachToEnemy'): continue confDict = configDict[name] needToAttach = \ confDict['attachToPlayer'] and vehicleID == BigWorld.player().playerVehicleID or \ confDict['attachToEnemy'] and vehicle['team'] != BigWorld.player().team or \ confDict['attachToAlly'] and vehicleID != BigWorld.player().playerVehicleID and \ vehicle['team'] == BigWorld.player().team if not needToAttach: continue nodeL = [] if '.' in name: nodeL.append(confDict['place']) elif confDict['place'] == 'leftFront': nodeL.append(TankNodeNames.TRACK_LEFT_UP_FRONT) elif confDict['place'] == 'rightFront': nodeL.append(TankNodeNames.TRACK_RIGHT_UP_FRONT) elif confDict['place'] == 'leftRear': nodeL.append(TankNodeNames.TRACK_LEFT_UP_REAR) elif confDict['place'] == 'rightRear': nodeL.append(TankNodeNames.TRACK_RIGHT_UP_REAR) elif confDict['place'] == 'hull': nodeL.append(TankPartNames.HULL) elif confDict['place'] == 'turret': nodeL.append(TankPartNames.TURRET) elif confDict['place'] == 'spot': nodeL.extend([TankPartNames.TURRET, TankPartNames.GUN]) nodeL.extend( ['hullLocalPt%s' % num for num in xrange(1, 5)]) nodeL.append('hullGunLocal') elif 'wheels' in confDict['place']: if 'left' in confDict['place']: nodeL.extend(nodeListNL) else: nodeL.extend(nodeListNR) nameTree = name.split('.')[:-1] namesList = [] for curKey in lightDBDict[vehicleID].keys(): curTree = curKey.split('.') if len(curTree) != len(nameTree) or any( upperName not in curTree[depth] for depth, upperName in enumerate(nameTree)): continue namesList.append(curKey + '.' + name.split('.')[-1]) if not namesList: namesList = [name] for fullName in namesList: for node in nodeL: curName = fullName + ':' + node if 'model' not in confDict['type']: if confDict['type'] == 'spotLight': LightSource = BigWorld.PySpotLight() LightSource.coneAngle = confDict['ca'] else: LightSource = BigWorld.PyOmniLight() if confDict['type'] != 'omniLight': LOG_ERROR( 'Unknown type of %s: %s. Set to omniLight' % (name, confDict['type'])) LightSource.innerRadius = confDict[ 'innerRadius'] LightSource.outerRadius = confDict[ 'outerRadius'] LightSource.castShadows = confDict['cs'] LightSource.multiplier = confDict['bright'] if isinstance(confDict['colour'][0], tuple): if confDict['type'] != 'spotLight': FrontLightShader = Math.Vector4Animation( ) FrontLightShader.duration = confDict[ 'dur'] FrontLightShader.keyframes = confDict[ 'colour'] LightSource.colorAnimator = FrontLightShader else: LightSource.colour = confDict[ 'colour'][0][1] else: LightSource.colour = confDict['colour'] else: LightSource = BigWorld.Model(confDict['path']) if '.' not in name: if node in fakeDict: fakeNode = fakeDict[node].node( '', computeTransform(confDict)) else: if curName not in fakeDict: fakeDict[curName] = BigWorld.Model( 'objects/fake_model.model') lightDBDict[vehicleID][curName.rsplit( '.', 1)[0]].node(node).attach( fakeDict[curName]) fakeNode = fakeDict[curName].node( '', computeTransform(confDict)) if 'model' not in confDict['type']: # noinspection PyUnboundLocalVariable LightSource.source = fakeNode elif not LightSource.attached: fakeNode.attach(LightSource) lightVisible( LightSource, _config.isLampsVisible and name in _config.modes['constant']) lightDBDict[vehicleID][curName] = LightSource except StandardError: traceback.print_exc() print name print callPlace print vDesc.name except StandardError: traceback.print_exc() print callPlace
def create(self, ctx, callback=None): LOG_ERROR('NotSupportedEntry.create', ctx)
def changeSettings(self, ctx, callback=None): if ctx.getRequestType() != REQUEST_TYPE.CHANGE_SETTINGS: LOG_ERROR('Invalid context for request changeSettings', ctx) if callback is not None: callback(False) return elif self._cooldown.validate(REQUEST_TYPE.CHANGE_SETTINGS): if callback is not None: callback(False) return else: player = BigWorld.player() pPermissions = self.getPermissions() self.__settingRecords = [] rejected = False isOpenedChanged = ctx.isOpenedChanged(self._settings) isCommentChanged = ctx.isCommentChanged(self._settings) isArenaTypeIDChanged = ctx.isArenaTypeIDChanged(self._settings) isRoundLenChanged = ctx.isRoundLenChanged(self._settings) if isOpenedChanged: if pPermissions.canMakeOpenedClosed(): self.__settingRecords.append('isOpened') else: LOG_ERROR('Player can not make training opened/closed', pPermissions) rejected = True if isCommentChanged: if pPermissions.canChangeComment(): self.__settingRecords.append('comment') else: LOG_ERROR('Player can not change comment', pPermissions) rejected = True if isArenaTypeIDChanged: if pPermissions.canChangeArena(): self.__settingRecords.append('arenaTypeID') else: LOG_ERROR('Player can not change comment', pPermissions) rejected = True if isRoundLenChanged: if pPermissions.canChangeArena(): self.__settingRecords.append('roundLength') else: LOG_ERROR('Player can not change comment', pPermissions) rejected = True if rejected: self.__settingRecords = [] if callback is not None: callback(False) return elif not len(self.__settingRecords): if callback is not None: callback(False) return ctx.startProcessing(callback=callback) if isOpenedChanged: player.prb_changeOpenStatus( ctx.isOpened(), partial(self.__onSettingChanged, record='isOpened', callback=ctx.stopProcessing)) if isCommentChanged: player.prb_changeComment( ctx.getComment(), partial(self.__onSettingChanged, record='comment', callback=ctx.stopProcessing)) if isArenaTypeIDChanged: player.prb_changeArena( ctx.getArenaTypeID(), partial(self.__onSettingChanged, record='arenaTypeID', callback=ctx.stopProcessing)) if isRoundLenChanged: player.prb_changeRoundLength( ctx.getRoundLen(), partial(self.__onSettingChanged, record='roundLength', callback=ctx.stopProcessing)) if not len(self.__settingRecords): if callback is not None: callback(False) else: self._cooldown.process(REQUEST_TYPE.CHANGE_SETTINGS) return
def construct(self): block = [] module = self.module slotIdx = self.configuration.slotIdx vehicle = self.configuration.vehicle sellPrice = self.configuration.sellPrice buyPrice = self.configuration.buyPrice unlockPrice = self.configuration.unlockPrice inventoryCount = self.configuration.inventoryCount vehiclesCount = self.configuration.vehiclesCount researchNode = self.configuration.node if buyPrice and sellPrice: LOG_ERROR( 'You are not allowed to use buyPrice and sellPrice at the same time' ) return else: def checkState(state): if researchNode is not None: return bool(int(researchNode.state) & state) else: return False isEqOrDev = module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS isNextToUnlock = checkState(NODE_STATE_FLAGS.NEXT_2_UNLOCK) isInstalled = checkState(NODE_STATE_FLAGS.INSTALLED) isInInventory = checkState(NODE_STATE_FLAGS.IN_INVENTORY) isUnlocked = checkState(NODE_STATE_FLAGS.UNLOCKED) isAutoUnlock = checkState(NODE_STATE_FLAGS.AUTO_UNLOCKED) items = g_itemsCache.items money = items.stats.money itemPrice = ZERO_MONEY if module is not None: itemPrice = module.buyPrice isMoneyEnough = money >= itemPrice leftPadding = 92 if unlockPrice and not isEqOrDev: parentCD = vehicle.intCD if vehicle is not None else None isAvailable, cost, need = getUnlockPrice( module.intCD, parentCD) neededValue = None if not isUnlocked and isNextToUnlock and need > 0: neededValue = need if cost > 0: block.append( makePriceBlock(cost, CURRENCY_SETTINGS.UNLOCK_PRICE, neededValue, leftPadding=leftPadding, valueWidth=self._valueWidth)) creditsActionPercent, goldActionPercent = (0, 0) need = ZERO_MONEY if buyPrice and not isAutoUnlock: price = module.altPrice or module.buyPrice defPrice = module.defaultAltPrice or module.defaultPrice rootInInv = vehicle is not None and vehicle.isInInventory if researchNode: showNeeded = rootInInv and not isMoneyEnough and ( isNextToUnlock or isUnlocked) and not (isInstalled or isInInventory) else: isModuleUnlocked = module.isUnlocked isModuleInInventory = module.isInInventory showNeeded = not isModuleInInventory and isModuleUnlocked if isEqOrDev or showNeeded: need = price - money need = need.toNonNegative() if price.credits > 0: creditsActionPercent = getActionPrc( price.credits, defPrice.credits) block.append( makePriceBlock( price.credits, CURRENCY_SETTINGS.BUY_CREDITS_PRICE, need.credits if need.credits > 0 else None, defPrice.credits if defPrice.credits > 0 else None, creditsActionPercent, self._valueWidth, leftPadding)) if price.gold > 0: goldActionPercent = getActionPrc(price.gold, defPrice.gold) block.append( formatters.packTextBlockData( text=text_styles.standard( TOOLTIPS.VEHICLE_TEXTDELIMITER_OR), padding=formatters.packPadding( left=(101 if goldActionPercent > 0 else 81) + self.leftPadding))) block.append( makePriceBlock( price.gold, CURRENCY_SETTINGS.BUY_GOLD_PRICE, need.gold if need.gold > 0 else None, defPrice.gold if defPrice.gold > 0 else None, goldActionPercent, self._valueWidth, leftPadding)) if sellPrice: block.append( makePriceBlock(module.sellPrice.credits, CURRENCY_SETTINGS.SELL_PRICE, oldPrice=module.defaultSellPrice.credits, percent=module.sellActionPrc, valueWidth=self._valueWidth, leftPadding=leftPadding)) if inventoryCount: count = module.inventoryCount if count > 0: block.append( formatters.packTextParameterBlockData( name=text_styles.main( TOOLTIPS.VEHICLE_INVENTORYCOUNT), value=text_styles.stats(count), valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5))) if vehiclesCount: inventoryVehicles = items.getVehicles(REQ_CRITERIA.INVENTORY) count = len( module.getInstalledVehicles( inventoryVehicles.itervalues())) if count > 0: block.append( formatters.packTextParameterBlockData( name=text_styles.main( TOOLTIPS.VEHICLE_VEHICLECOUNT), value=text_styles.stats(count), valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5))) notEnoughMoney = need > ZERO_MONEY hasAction = creditsActionPercent > 0 or goldActionPercent > 0 or module.sellActionPrc > 0 return (block, notEnoughMoney or hasAction)
def resetArenaPeriod(self): if not self.isRecording: LOG_ERROR('Replay is not recorded on resetArenaPeriod') self.__replayCtrl.resetArenaPeriod()