Example #1
1
 def _successHandler(self, code, ctx=None):
     return makeI18nSuccess(
         "exchangeXP/success",
         gold=BigWorld.wg_getGoldFormat(self.gold),
         xp=BigWorld.wg_getIntegralFormat(self.xp),
         type=SM_TYPE.FinancialTransactionWithGold,
     )
Example #2
1
 def _request(self, callback):
     itemCD = self.item.intCD if self.install else 0
     newEqsLayout = map(lambda item: (item.intCD if item is not None else 0), self.vehicle.eqs)
     newEqsLayout[self.slotIdx] = itemCD
     BigWorld.player().inventory.equipEquipments(
         self.vehicle.invID, newEqsLayout, lambda code: self._response(code, callback)
     )
Example #3
1
 def stop(self):
     if self.__onStopCallbackId is not None:
         BigWorld.cancelCallback(self.__onStopCallbackId)
         self.__onStopCallbackId = None
     self.onStop(self)
     self.__isRunning = False
     return
Example #4
1
 def __init__(self, soundName, parent):
     fakeModelName = Settings.g_instance.scriptConfig.readString(Settings.KEY_FAKE_MODEL)
     self.soundModel = BigWorld.Model(fakeModelName)
     self.soundModel.addMotor(BigWorld.Servo(parent.root))
     BigWorld.addModel(self.soundModel)
     self.sound = self.soundModel.playSound(soundName)
     self.parent = parent
Example #5
1
 def __cameraUpdate(self):
     curTime = BigWorld.time()
     deltaTime = curTime - self.__prevTime
     self.__prevTime = curTime
     if not self.__autoUpdateDxDyDz.x == self.__autoUpdateDxDyDz.y == self.__autoUpdateDxDyDz.z == 0.0:
         self.__rotateAndZoom(self.__autoUpdateDxDyDz.x, self.__autoUpdateDxDyDz.y, self.__autoUpdateDxDyDz.z)
     self.__aimingSystem.update(deltaTime)
     localTransform, impulseTransform = self.__updateOscillators(deltaTime)
     ownVehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
     if ownVehicle is not None and ownVehicle.isStarted and ownVehicle.appearance.isUnderwater:
         self.__onChangeControlMode()
         return 0.0
     else:
         aimMatrix = cameras.getAimMatrix(*self.__defaultAimOffset)
         camMat = Matrix(aimMatrix)
         rodMat = mathUtils.createTranslationMatrix(-self.__dynamicCfg["pivotShift"])
         antiRodMat = mathUtils.createTranslationMatrix(self.__dynamicCfg["pivotShift"])
         camMat.postMultiply(rodMat)
         camMat.postMultiply(localTransform)
         camMat.postMultiply(antiRodMat)
         camMat.postMultiply(self.__aimingSystem.matrix)
         camMat.invert()
         self.__cam.set(camMat)
         replayCtrl = BattleReplay.g_replayCtrl
         if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
             aimOffset = replayCtrl.getAimClipPosition()
             binocularsOffset = aimOffset
         else:
             aimOffset = self.__calcAimOffset(impulseTransform)
             binocularsOffset = self.__calcAimOffset()
             if replayCtrl.isRecording:
                 replayCtrl.setAimClipPosition(aimOffset)
         self.__aim.offset((aimOffset.x, aimOffset.y))
         self.__binoculars.setMaskCenter(binocularsOffset.x, binocularsOffset.y)
         return 0.0
Example #6
1
    def __generateRetreatTrajectory(self, idealFlightHeight, bombingEndPosition, bombingDir, bombingEndTime):
        clientArena = BigWorld.player().arena
        endTrajectoryPosition = clientArena.collideWithSpaceBB(
            bombingEndPosition, bombingEndPosition + bombingDir * 9000.0
        )
        segmentLength = (endTrajectoryPosition - bombingEndPosition).length / _RETREAT_SUBDIVISION_FACTOR
        firstRetreatPoint = Vector3(bombingEndPosition + bombingDir * _INITIAL_RETREAT_SHIFT)
        positions = [firstRetreatPoint]
        positions += [
            firstRetreatPoint + bombingDir * (segmentLength * (idx + 1))
            for idx in xrange(_RETREAT_SUBDIVISION_FACTOR - 1)
        ]
        positions.append(endTrajectoryPosition - bombingDir * min(segmentLength * 0.1, 50.0))
        positions.append(endTrajectoryPosition + bombingDir * 100)
        retreatHeight = _MINIMAL_RETREAT_HEIGHT
        minFlightHeight = idealFlightHeight
        for position in positions:
            zeroHeightPos = Vector3(position)
            zeroHeightPos.y = 0
            collRes = BigWorld.wg_collideSegment(
                BigWorld.player().spaceID, zeroHeightPos + (0, 1000, 0), zeroHeightPos + (0, -1000, 0), 18
            )
            if collRes is not None:
                minFlightHeight = max(collRes[0].y + retreatHeight, minFlightHeight)
            else:
                minFlightHeight = max(position.y, minFlightHeight)
            position.y = minFlightHeight

        for idx in xrange(len(positions) - 1):
            positions[idx].y = (positions[idx].y + positions[idx + 1].y) / 2.0

        result = self.__generateRetreatPoints(bombingEndPosition, bombingEndTime, positions)
        return result
 def handleMouseEvent(self, comp, event):
     self.label2.visible = True
     self.label2.text = "handleMouseEvent (%s %s %s)" % (event.dx, event.dy, event.dz)
     if self.hideCBHandle is not None:
         BigWorld.cancelCallback(self.hideCBHandle)
     self.hideCBHandle = BigWorld.callback(2.0, self._hideLabel)
     return True
Example #8
1
 def changeComment(self, ctx, callback=None):
     if ctx.getRequestType() != REQUEST_TYPE.CHANGE_COMMENT:
         LOG_ERROR("Invalid context for request changeComment", ctx)
         if callback is not None:
             callback(False)
         return
     elif not ctx.isCommentChanged(self._settings):
         if callback is not None:
             callback(False)
         return
     elif self._cooldown.validate(REQUEST_TYPE.CHANGE_SETTINGS):
         if callback:
             callback(False)
         return
     else:
         pPermissions = self.getPermissions()
         if not pPermissions.canChangeComment():
             LOG_ERROR("Player can not change comment", pPermissions)
             if callback is not None:
                 callback(False)
             return
         ctx.startProcessing(callback)
         BigWorld.player().prb_changeComment(ctx.getComment(), ctx.onResponseReceived)
         self._cooldown.process(REQUEST_TYPE.CHANGE_SETTINGS)
         return
Example #9
1
    def __init__(self, data, position):
        super(_StaticObjectMarker3D, self).__init__()
        path = data.get('path')
        offset = data.get('offset', Math.Vector3(0, 0, 0))
        self.__model = None
        if path is not None:
            try:
                self.__model = BigWorld.Model(path)
                self.__model.position = Math.Vector3(position[:]) + offset
                self.__model.castsShadow = False
            except ValueError:
                LOG_CURRENT_EXCEPTION()
                LOG_ERROR('Model not found', path)
                return
            except AttributeError:
                LOG_CURRENT_EXCEPTION()
                return

            BigWorld.addModel(self.__model)
            action = data.get('action')
            if action is not None and len(action):
                try:
                    self.__model.action(action)()
                except ValueError:
                    LOG_ERROR('Action not found', path, action)

        return
Example #10
1
 def destroy(self):
     self.stop()
     self.__arcadeCamera = None
     self.__onStop = None
     BigWorld.player().onVehicleLeaveWorld -= self.__onVehicleLeaveWorld
     g_playerEvents.onArenaPeriodChange -= self.__onRoundFinished
     return
Example #11
1
 def start(self):
     if self.__bActive:
         return
     self.__bActive = True
     self.__fadeScreen()
     self.__moveCameraTo(BigWorld.player().playerVehicleID)
     self.__cbIDWait = BigWorld.callback(self.FADE_DELAY_TIME, self.__onFadeDelay)
Example #12
1
    def __onResourcesLoaded(self, resourceRefs):
        if self.guid not in BigWorld.userDataObjects:
            return
        else:
            self.__clear()
            if self.modelName in resourceRefs.failedIDs:
                return
            try:
                self.__model = resourceRefs[self.modelName]
                self.__modelMatrix = Matrix()
                self.__modelMatrix.setIdentity()
                servo = BigWorld.Servo(self.__modelMatrix)
                self.__model.addMotor(servo)
                BigWorld.addModel(self.__model)
                if self.actionName != "":
                    action = self.__model.action(self.actionName)
                    if action is not None:
                        action()
                if self.pixieName != "" and self.pixieName not in resourceRefs.failedIDs:
                    pixieNode = self.__model.node(self.pixieHardPoint)
                    pixieNode.attach(resourceRefs[self.pixieName])
                if self.soundName != "":
                    self.__sound = SoundGroups.g_instance.playSoundModel(self.__model, self.soundName)
            except:
                LOG_CURRENT_EXCEPTION()
                self.__model = None
                return

            self.__prevTime = BigWorld.time()
            self.__update()
            return
Example #13
1
 def changeDivision(self, ctx, callback=None):
     if ctx.getRequestType() != REQUEST_TYPE.CHANGE_DIVISION:
         LOG_ERROR("Invalid context for request changeDivision", ctx)
         if callback is not None:
             callback(False)
         return
     elif not ctx.isDivisionChanged(self._settings):
         if callback is not None:
             callback(False)
         return
     elif self._cooldown.validate(REQUEST_TYPE.CHANGE_SETTINGS):
         if callback is not None:
             callback(False)
         return
     elif ctx.getDivision() not in PREBATTLE_COMPANY_DIVISION.RANGE:
         LOG_ERROR("Division is invalid", ctx)
         if callback is not None:
             callback(False)
         return
     elif self.getTeamState().isInQueue():
         LOG_ERROR("Team is ready or locked", ctx)
         if callback is not None:
             callback(False)
         return
     else:
         pPermissions = self.getPermissions()
         if not pPermissions.canChangeDivision():
             LOG_ERROR("Player can not change division", pPermissions)
             if callback is not None:
                 callback(False)
             return
         ctx.startProcessing(callback)
         BigWorld.player().prb_changeDivision(ctx.getDivision(), ctx.onResponseReceived)
         self._cooldown.process(REQUEST_TYPE.CHANGE_SETTINGS)
         return
Example #14
1
def clear():
    for x in GUI.roots():
        GUI.delRoot(x)

    GUI.mcursor().visible = True
    GUI.mcursor().clipped = False
    BigWorld.setCursor(GUI.mcursor())
 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
Example #16
1
 def getStats(self):
     """
     Collecting stats data for personal case
     @return: list of stats items
     """
     nextSkillsBattlesLeft = self.getNextSkillBattlesLeft()
     if nextSkillsBattlesLeft is not None:
         nextSkillsBattlesLeft = BigWorld.wg_getIntegralFormat(nextSkillsBattlesLeft)
     nextSkillBattlesLeftExtra = ""
     if not self.getBattlesCount() or not self.extStats.getBattlesCount():
         nextSkillBattlesLeftExtra = "(%s)" % i18n.makeString("#menu:profile/stats/items/unknown")
     skillImgType, skillImg = self.__getCurrentSkillIcon()
     return (
         {
             "label": "common",
             "stats": (self.__packStat("battlesCount", BigWorld.wg_getNiceNumberFormat(self.getBattlesCount())),),
         },
         {
             "label": "studying",
             "stats": (
                 self.__packStat(
                     "nextSkillXPLeft",
                     BigWorld.wg_getIntegralFormat(self.getNextSkillXPLeft()),
                     imageType=skillImgType,
                     image=skillImg,
                 ),
                 self.__packStat("avgExperience", BigWorld.wg_getIntegralFormat(self.getAvgXP())),
                 self.__packStat("nextSkillBattlesLeft", nextSkillsBattlesLeft, nextSkillBattlesLeftExtra),
             ),
         },
     )
Example #17
1
    def save(self):
        tmpList = []
        for fireKey, listKeyInfo in self.__mapping.iteritems():
            for command, satelliteKeys, isDefault in listKeyInfo:
                if isDefault:
                    continue
                if len(satelliteKeys):
                    continue
                commandName = self.getName(command)
                listSatelliteKeyNames = []
                for key in satelliteKeys:
                    listSatelliteKeyNames.append("KEY_" + BigWorld.keyToString(key))

                strSatelliteKeyNames = ""
                for keyName in listSatelliteKeyNames:
                    strSatelliteKeyNames += keyName + " "

                strSatelliteKeyNames = strSatelliteKeyNames.strip()
                fireKeyName = "KEY_" + BigWorld.keyToString(fireKey)
                tmpList.append((commandName, fireKeyName, strSatelliteKeyNames))

        if len(tmpList):
            section = Settings.g_instance.userPrefs
            section.deleteSection(CommandMapping.__USER_CONFIG_SECTION_NAME)
            section = section.createSection(CommandMapping.__USER_CONFIG_SECTION_NAME)
            for commandName, fireKeyName, strSatelliteKeynames in tmpList:
                subsec = section.createSection(commandName)
                subsec.writeString("fireKey", fireKeyName)
                subsec.writeString("satelliteKeys", strSatelliteKeyNames)

            Settings.g_instance.save()
Example #18
1
 def _request(self, callback):
     BigWorld.player().inventory.setAndFillLayouts(
         self.vehicle.invID,
         self.shellsLayout,
         self.eqsLayout,
         lambda code, errStr, ext: self._response(code, callback, errStr=errStr, ctx=ext),
     )
Example #19
1
 def __setSoundMuted(self, isMuted):
     BigWorld.wg_setMovieSoundMuted(isMuted)
     SoundGroups.g_instance.enableAmbientAndMusic(isMuted)
     if isMuted:
         MusicController.g_musicController.play(MusicController.MUSIC_EVENT_LOBBY)
     else:
         MusicController.g_musicController.stop()
Example #20
0
 def __startKillerVision(self):
     if not self.__moveCameraTo(self.__killerVehicleID, BigWorld.player().playerVehicleID):
         LOG_DEBUG("<PostmortemDelay>: can't move camera to killer vehicle")
         self.__showChoiceWindow()
         return
     self.__bKillerVisionActive = True
     self.__cbIDWait = BigWorld.callback(self.KILLER_VISION_TIME, self.__onKillerVisionFinished)
 def _getHeaderData(self, data):
     return (
         PUtils.packLditItemData(
             BigWorld.wg_getIntegralFormat(data.getBattlesCount()),
             FORTIFICATIONS.CLANSTATS_PARAMS_PERIODDEFENCE_BATTLESCOUNT_LABEL,
             TOOLTIPS.FORTIFICATION_CLANSTATS_PERIODDEFENCE_BATTLES_BATTLESCOUNT,
             "battles40x32.png",
             PUtils.createToolTipData(
                 [
                     BigWorld.wg_getIntegralFormat(data.getWinsCount()),
                     BigWorld.wg_getIntegralFormat(data.getLossesCount()),
                 ]
             ),
         ),
         PUtils.packLditItemData(
             PUtils.getFormattedWinsEfficiency(data),
             FORTIFICATIONS.CLANSTATS_PARAMS_PERIODDEFENCE_WINS_LABEL,
             FORTIFICATIONS.CLANSTATS_PARAMS_PERIODDEFENCE_WINS_TOOLTIP,
             "wins40x32.png",
         ),
         PUtils.packLditItemData(
             PUtils.formatEfficiency(
                 self.__resourceLossCount, lambda: float(self.__resourceCaptureCount) / self.__resourceLossCount
             ),
             FORTIFICATIONS.CLANSTATS_PARAMS_PERIODDEFENCE_AVGDEFRES_LABEL,
             FORTIFICATIONS.CLANSTATS_PARAMS_PERIODDEFENCE_AVGDEFRES_TOOLTIP,
             "defresRatio40x32.png",
         ),
     )
Example #22
0
    def __onModelLoaded(self, applyOverlay, resourceRefs):
        if resourceRefs.failedIDs:
            LOG_ERROR("Failed to load flag model %s" % (resourceRefs.failedIDs,))
        else:
            model = resourceRefs[self.__flagModelFile]
            if not model is not None:
                raise AssertionError
                model.position = self.__flagPos
                BigWorld.addModel(model, BigWorld.player().spaceID)
                BigWorld.wg_applyOverlayToModel(model, applyOverlay)
                self.__flagModel = model
                if self.__flagAnimAction is not None:
                    try:
                        animAction = model.action(self.__flagAnimAction)
                        animAction()
                    except:
                        LOG_WARNING(
                            'Unable to start "%s" animation action for model "%s"'
                            % (self.__flagAnimAction, self.__flagModelFile)
                        )

                g_ctfManager.isNeedHideAll and self.__hidePointFlag()
            else:
                self.__hideListener = _GlobalHideListener(self.__hidePointFlag)
        return
Example #23
0
 def __update(self):
     self.__updateCallbackId = None
     self.__updateCallbackId = BigWorld.callback(0.0, self.__update)
     curTime = BigWorld.time()
     dt = curTime - self.__prevTime
     self.__prevTime = curTime
     self.__currentAngle += self.__angularVelocity * dt
     if self.__currentAngle > 2 * math.pi:
         self.__currentAngle -= 2 * math.pi
     elif self.__currentAngle < -2 * math.pi:
         self.__currentAngle += 2 * math.pi
     radialPosition = Vector3(
         self.radius * math.sin(self.__currentAngle), 0, self.radius * math.cos(self.__currentAngle)
     )
     modelYaw = self.__currentAngle
     if self.rotateClockwise:
         modelYaw += math.pi / 2
     else:
         modelYaw -= math.pi / 2
     localMatrix = Matrix()
     localMatrix.setRotateY(modelYaw)
     localMatrix.translation = radialPosition
     self.__modelMatrix.setRotateYPR((self.yaw, self.pitch, self.roll))
     self.__modelMatrix.translation = self.position
     self.__modelMatrix.preMultiply(localMatrix)
     return
Example #24
0
 def init(self):
     SoundGroups.g_instance.onVolumeChanged += self.__onVolumeChanged
     self.startFortListening()
     BigWorld.wg_setCategoryVolume("hangar_v2", 0.0)
     MusicController.g_musicController.stop()
     params = {"buildings_number": 0, "transport_mode": 0, "defence_period": 0}
     MusicController.g_musicController.play(MusicController.AMBIENT_EVENT_LOBBY_FORT, params)
Example #25
0
 def fini(self):
     BigWorld.wg_setCategoryVolume("hangar_v2", SoundGroups.g_instance.getVolume("ambient"))
     MusicController.g_musicController.stop()
     MusicController.g_musicController.play(MusicController.MUSIC_EVENT_LOBBY)
     MusicController.g_musicController.play(MusicController.AMBIENT_EVENT_LOBBY)
     self.stopFortListening()
     SoundGroups.g_instance.onVolumeChanged -= self.__onVolumeChanged
Example #26
0
 def clear(self):
     if self.__timerCallback is not None:
         BigWorld.cancelCallback(self.__timerCallback)
         self.__timerCallback = None
     self.isSubscribed = False
     self.isRunning = False
     return
Example #27
0
 def __init__(self, parent, component):
     self.component = component
     component.focus = True
     component.mouseButtonFocus = True
     component.crossFocus = True
     component.moveFocus = True
     component.dragFocus = True
     component.dropFocus = True
     self.parent = parent
     self.label1 = GUI.Text("")
     self.label1.colour = (255, 0, 0, 255)
     self.label1.verticalPositionMode = "CLIP"
     component.addChild(self.label1)
     self.label2 = GUI.Text("")
     self.label2.colour = (0, 0, 255, 255)
     self.label2.verticalPositionMode = "CLIP"
     self.label2.position.y = -0.5
     component.addChild(self.label2)
     self.label3 = GUI.Text("")
     self.label3.colour = (0, 255, 0, 255)
     self.label3.verticalPositionMode = "CLIP"
     self.label3.position.y = 0.5
     component.addChild(self.label3)
     self.startPosition = Math.Vector3(self.component.position)
     BigWorld.callback(0.01, self._animatePosition)
     self.hideCBHandle = None
     return
Example #28
0
 def changeOpened(self, ctx, callback=None):
     if ctx.getRequestType() != REQUEST_TYPE.CHANGE_OPENED:
         LOG_ERROR("Invalid context for request changeOpened", ctx)
         if callback is not None:
             callback(False)
         return
     elif not ctx.isOpenedChanged(self._settings):
         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:
         pPermissions = self.getPermissions()
         if not pPermissions.canMakeOpenedClosed():
             LOG_ERROR("Player can not change opened/closed", pPermissions)
             if callback is not None:
                 callback(False)
             return
         ctx.startProcessing(callback)
         BigWorld.player().prb_changeOpenStatus(ctx.isOpened(), ctx.onResponseReceived)
         self._cooldown.process(REQUEST_TYPE.CHANGE_SETTINGS)
         return
Example #29
0
 def getTargetMProv(self):
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.playerVehicleID != 0:
         vehicleID = replayCtrl.playerVehicleID
     else:
         vehicleID = BigWorld.player().playerVehicleID
     return BigWorld.entity(vehicleID).matrix
Example #30
0
    def start(self):
        g_guiResetters.add(self.__onRecreateDevice)
        import aims

        aims.clearState()
        self.__identifySPG()
        for control in self.__ctrls.itervalues():
            control.create()

        self.__addBattleCtrlListeners()
        g_cursorDelegator.detachCursor()
        if not self.__curCtrl.isManualBind():
            BigWorld.player().positionControl.bindToVehicle(True)
        self.__curCtrl.enable(ctrlState=control_modes.dumpStateEmpty())
        self.onCameraChanged("arcade")
        tmp = self.__curCtrl.getPreferredAutorotationMode()
        if tmp is not None:
            self.__isAutorotation = tmp
            self.__prevModeAutorotation = True
        else:
            self.__isAutorotation = True
            self.__prevModeAutorotation = None
        BigWorld.player().enableOwnVehicleAutorotation(self.__isAutorotation)
        self.__targeting.enable(True)
        self.__isStarted = True
        self.__isGUIVisible = True
        self.__killerVehicleID = None
        arena = BigWorld.player().arena
        arena.onPeriodChange += self.__onArenaStarted
        from account_helpers.settings_core.SettingsCore import g_settingsCore

        g_settingsCore.onSettingsChanged += self.__onSettingsChanged
        self.__onArenaStarted(arena.period)