コード例 #1
0
def _readProjectionDecalSlot(ctx, subsection, slotType):
    descr = shared_components.ProjectionDecalSlotDescription(
        slotType=slotType,
        slotId=_xml.readInt(ctx, subsection, 'slotId'),
        position=_xml.readVector3OrNone(ctx, subsection, 'position'),
        rotation=_xml.readVector3OrNone(ctx, subsection, 'rotation'),
        scale=_xml.readVector3OrNone(ctx, subsection, 'scale'),
        scaleFactors=_xml.readVector3(
            ctx, subsection, 'scaleFactors',
            c11n_constants.DEFAULT_DECAL_SCALE_FACTORS),
        doubleSided=_xml.readBool(ctx, subsection, 'doubleSided', False),
        hiddenForUser=_xml.readBool(ctx, subsection, 'hiddenForUser', False),
        canBeMirroredVertically=_xml.readBool(ctx, subsection,
                                              'verticalMirror', False),
        showOn=_xml.readIntOrNone(ctx, subsection, 'showOn'),
        tags=readOrderedTagsOrEmpty(ctx, subsection,
                                    _customizationSlotTagsValidator),
        clipAngle=_xml.readFloat(ctx, subsection, 'clipAngle',
                                 c11n_constants.DEFAULT_DECAL_CLIP_ANGLE),
        anchorShift=_xml.readFloat(ctx, subsection, 'anchorShift',
                                   c11n_constants.DEFAULT_DECAL_ANCHOR_SHIFT))
    _verifySlotId(ctx, slotType, descr.slotId)
    _verifyMatchingSlotSettings(ctx, descr)
    if descr.showOn is not None:
        availableShowOnRegions = c11n_constants.ApplyArea.HULL | c11n_constants.ApplyArea.TURRET | c11n_constants.ApplyArea.GUN
        if descr.showOn | availableShowOnRegions != availableShowOnRegions:
            _xml.raiseWrongSection(ctx, 'showOn')
    if subsection.has_key('compatibleModels'):
        descr.compatibleModels = _xml.readTupleOfStrings(
            ctx, subsection, 'compatibleModels')
    if subsection.has_key('itemId'):
        descr.itemId = _xml.readInt(ctx, subsection, 'itemId')
    if subsection.has_key('options'):
        descr.options = _xml.readNonNegativeInt(ctx, subsection, 'options')
    return descr
コード例 #2
0
ファイル: chains.py プロジェクト: webiumsk/WOT-0.9.12-CT
def _readHintSection(xmlCtx, section, flags):
    hintID = sub_parsers.parseID(xmlCtx, section, 'Specify a hint ID')
    if 'item-id' in section.keys():
        itemID = sub_parsers.parseID(xmlCtx, section['item-id'], 'Specify a item ID')
    else:
        _xml.raiseWrongXml(xmlCtx, section.name, 'Specify a item ID')
        return
    tags = section.keys()
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    if 'arrow' in tags:
        subSec = section['arrow']
        direction = _xml.readString(xmlCtx, subSec, 'direction')
        if direction not in _AVAILABLE_DIRECTIONS:
            _xml.raiseWrongXml(xmlCtx, section, 'Arrow direction {} is invalid.'.format(direction))
        arrow = _ArrowProps(direction, _xml.readBool(xmlCtx, subSec, 'loop'))
    else:
        arrow = None
    if 'padding' in tags:
        subSec = section['padding']
        padding = _Padding(_xml.readFloat(xmlCtx, subSec, 'left'), _xml.readFloat(xmlCtx, subSec, 'top'), _xml.readFloat(xmlCtx, subSec, 'right'), _xml.readFloat(xmlCtx, subSec, 'bottom'))
    else:
        padding = None
    hint = chapter.ChainHint(hintID, itemID, text, section.readBool('has-box', True), arrow, padding)
    hint.setActions(sub_parsers.parseActions(xmlCtx, _xml.getSubsection(xmlCtx, section, 'actions'), flags))
    return hint
コード例 #3
0
def readGroundNodesAndGroups(xmlCtx, section):
    if section['groundNodes'] is None:
        return (component_constants.EMPTY_TUPLE,
                component_constants.EMPTY_TUPLE)
    else:
        groundGroups = []
        groundNodes = []
        for sname, subsection in _xml.getChildren(xmlCtx, section,
                                                  'groundNodes'):
            if sname == 'group':
                ctx = (xmlCtx, 'groundNodes/group')
                group = chassis_components.GroundNodeGroup(
                    isLeft=_xml.readBool(ctx, subsection, 'isLeft'),
                    minOffset=_xml.readFloat(ctx, subsection, 'minOffset'),
                    maxOffset=_xml.readFloat(ctx, subsection, 'maxOffset'),
                    template=intern(
                        _xml.readNonEmptyString(ctx, subsection, 'template')),
                    count=_xml.readInt(ctx, subsection, 'count', 1),
                    startIndex=subsection.readInt('startIndex', 0))
                groundGroups.append(group)
            if sname == 'node':
                ctx = (xmlCtx, 'groundNodes/node')
                groundNode = chassis_components.GroundNode(
                    name=intern(
                        _xml.readNonEmptyString(ctx, subsection, 'name')),
                    isLeft=_xml.readBool(ctx, subsection, 'isLeft'),
                    minOffset=_xml.readFloat(ctx, subsection, 'minOffset'),
                    maxOffset=_xml.readFloat(ctx, subsection, 'maxOffset'))
                groundNodes.append(groundNode)

        return (tuple(groundGroups), tuple(groundNodes))
コード例 #4
0
ファイル: chains.py プロジェクト: jamesxia4/wot_client
def _readHintSection(xmlCtx, section, flags):
    hintID = sub_parsers.parseID(xmlCtx, section, 'Specify a hint ID')
    if 'item-id' in section.keys():
        itemID = sub_parsers.parseID(xmlCtx, section['item-id'],
                                     'Specify a item ID')
    else:
        _xml.raiseWrongXml(xmlCtx, section.name, 'Specify a item ID')
        return
    tags = section.keys()
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    if 'arrow' in tags:
        subSec = section['arrow']
        direction = _xml.readString(xmlCtx, subSec, 'direction')
        if direction not in _AVAILABLE_DIRECTIONS:
            _xml.raiseWrongXml(
                xmlCtx, section,
                'Arrow direction {} is invalid.'.format(direction))
        arrow = _ArrowProps(direction, _xml.readBool(xmlCtx, subSec, 'loop'))
    else:
        arrow = None
    if 'padding' in tags:
        subSec = section['padding']
        padding = _Padding(_xml.readFloat(xmlCtx, subSec, 'left'),
                           _xml.readFloat(xmlCtx, subSec, 'top'),
                           _xml.readFloat(xmlCtx, subSec, 'right'),
                           _xml.readFloat(xmlCtx, subSec, 'bottom'))
    else:
        padding = None
    hint = chapter.ChainHint(hintID, itemID, text,
                             section.readBool('has-box', True), arrow, padding)
    hint.setActions(
        sub_parsers.parseActions(
            xmlCtx, _xml.getSubsection(xmlCtx, section, 'actions'), flags))
    return hint
コード例 #5
0
def readTrackNodes(xmlCtx, section):
    if section['trackNodes'] is None:
        return component_constants.EMPTY_TUPLE
    else:
        defElasticity = _xml.readFloat(xmlCtx, section, 'trackNodes/elasticity', 1500.0)
        defDamping = _xml.readFloat(xmlCtx, section, 'trackNodes/damping', 1.0)
        defForwardElastK = _xml.readFloat(xmlCtx, section, 'trackNodes/forwardElastK', 1.0)
        defBackwardElastK = _xml.readFloat(xmlCtx, section, 'trackNodes/backwardElastK', 1.0)
        defOffset = _xml.readFloat(xmlCtx, section, 'trackNodes/offset', 0.0)
        trackNodes = []
        xmlCtx = (xmlCtx, 'trackNodes')
        for sname, subsection in _xml.getChildren(xmlCtx, section, 'trackNodes'):
            if sname == 'node':
                ctx = (xmlCtx, 'trackNodes/node')
                name = _xml.readStringOrNone(ctx, subsection, 'leftSibling')
                if name is not None:
                    leftNodeName = intern(name)
                else:
                    leftNodeName = None
                name = _xml.readStringOrNone(ctx, subsection, 'rightSibling')
                if name is not None:
                    rightNodeName = intern(name)
                else:
                    rightNodeName = None
                trackNode = chassis_components.TrackNode(name=intern(_xml.readNonEmptyString(ctx, subsection, 'name')), isLeft=_xml.readBool(ctx, subsection, 'isLeft'), initialOffset=_xml.readFloat(ctx, subsection, 'offset', defOffset), leftNodeName=leftNodeName, rightNodeName=rightNodeName, damping=_xml.readFloat(ctx, subsection, 'damping', defDamping), elasticity=_xml.readFloat(ctx, subsection, 'elasticity', defElasticity), forwardElasticityCoeff=_xml.readFloat(ctx, subsection, 'forwardElastK', defForwardElastK), backwardElasticityCoeff=_xml.readFloat(ctx, subsection, 'backwardElastK', defBackwardElastK))
                trackNodes.append(trackNode)

        return tuple(trackNodes)
コード例 #6
0
ファイル: __init__.py プロジェクト: webiumsk/WOT-0.9.15-CT
def parseHint(xmlCtx, section):
    sectionInfo = dict()
    sectionInfo['hintID'] = parseID(xmlCtx, section, 'Specify a hint ID')
    if 'item-id' in section.keys():
        sectionInfo['itemID'] = parseID(xmlCtx, section['item-id'], 'Specify a item ID')
    else:
        _xml.raiseWrongXml(xmlCtx, section.name, 'Specify a item ID')
        return
    tags = section.keys()
    sectionInfo['text'] = translation(_xml.readString(xmlCtx, section, 'text'))
    if 'arrow' in tags:
        subSec = section['arrow']
        direction = _xml.readString(xmlCtx, subSec, 'direction')
        if direction not in _AVAILABLE_DIRECTIONS:
            _xml.raiseWrongXml(xmlCtx, section, 'Arrow direction {} is invalid.'.format(direction))
        sectionInfo['arrow'] = _ArrowProps(direction, _xml.readBool(xmlCtx, subSec, 'loop'))
    else:
        sectionInfo['arrow'] = None
    if 'padding' in tags:
        subSec = section['padding']
        sectionInfo['padding'] = _Padding(_xml.readFloat(xmlCtx, subSec, 'left'), _xml.readFloat(xmlCtx, subSec, 'top'), _xml.readFloat(xmlCtx, subSec, 'right'), _xml.readFloat(xmlCtx, subSec, 'bottom'))
    else:
        sectionInfo['padding'] = None
    sectionInfo['hasBox'] = section.readBool('has-box', True)
    return sectionInfo
コード例 #7
0
def parseHint(xmlCtx, section):
    sectionInfo = dict()
    sectionInfo['hintID'] = parseID(xmlCtx, section, 'Specify a hint ID')
    if 'item-id' in section.keys():
        sectionInfo['itemID'] = parseID(xmlCtx, section['item-id'], 'Specify a item ID')
    else:
        _xml.raiseWrongXml(xmlCtx, section.name, 'Specify a item ID')
        return
    tags = section.keys()
    sectionInfo['text'] = translation(_xml.readString(xmlCtx, section, 'text'))
    if 'arrow' in tags:
        subSec = section['arrow']
        direction = _xml.readString(xmlCtx, subSec, 'direction')
        if direction not in _AVAILABLE_DIRECTIONS:
            _xml.raiseWrongXml(xmlCtx, section, 'Arrow direction {} is invalid.'.format(direction))
        positionValue = _xml.readFloat(xmlCtx, subSec, 'position-value', 0.5)
        textPadding = _xml.readFloat(xmlCtx, subSec, 'text-padding', 0)
        sectionInfo['arrow'] = _ArrowProps(direction, _xml.readBool(xmlCtx, subSec, 'loop'), positionValue, textPadding)
    else:
        sectionInfo['arrow'] = None
    if 'padding' in tags:
        subSec = section['padding']
        sectionInfo['padding'] = _Padding(_xml.readFloat(xmlCtx, subSec, 'left'), _xml.readFloat(xmlCtx, subSec, 'top'), _xml.readFloat(xmlCtx, subSec, 'right'), _xml.readFloat(xmlCtx, subSec, 'bottom'))
    else:
        sectionInfo['padding'] = None
    sectionInfo['hasBox'] = section.readBool('has-box', True)
    sectionInfo['conditions'] = _parseConditions(xmlCtx, section, [])
    sectionInfo['checked-ui-state'] = _parseNeededState(xmlCtx, section)
    sectionInfo['equalActions'] = section.readBool('equal-actions', False)
    sectionInfo['ignoreOutsideClick'] = section.readBool('ignore-outside-click', False)
    sectionInfo['updateRuntime'] = section.readBool('update-runtime', False)
    sectionInfo['hideImmediately'] = section.readBool('hide-immediately', False)
    sectionInfo['checkViewArea'] = section.readBool('check-view-area', False)
    return sectionInfo
コード例 #8
0
def readGroundNodesAndGroups(xmlCtx, section):
    """Reads section 'groundNodes' for each chassis if it has.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :return: tuple(sequence of groups, sequence of nodes).
    """
    if section['groundNodes'] is None:
        return (component_constants.EMPTY_TUPLE,
                component_constants.EMPTY_TUPLE)
    else:
        groundGroups = []
        groundNodes = []
        for sname, subsection in _xml.getChildren(xmlCtx, section,
                                                  'groundNodes'):
            if sname == 'group':
                ctx = (xmlCtx, 'groundNodes/group')
                group = chassis_components.GroundNodeGroup(
                    isLeft=_xml.readBool(ctx, subsection, 'isLeft'),
                    minOffset=_xml.readFloat(ctx, subsection, 'minOffset'),
                    maxOffset=_xml.readFloat(ctx, subsection, 'maxOffset'),
                    template=_xml.readNonEmptyString(ctx, subsection,
                                                     'template'),
                    count=_xml.readInt(ctx, subsection, 'count', 1),
                    startIndex=subsection.readInt('startIndex', 0))
                groundGroups.append(group)
            elif sname == 'node':
                ctx = (xmlCtx, 'groundNodes/node')
                groundNode = chassis_components.GroundNode(
                    name=_xml.readNonEmptyString(ctx, subsection, 'name'),
                    isLeft=_xml.readBool(ctx, subsection, 'isLeft'),
                    minOffset=_xml.readFloat(ctx, subsection, 'minOffset'),
                    maxOffset=_xml.readFloat(ctx, subsection, 'maxOffset'))
                groundNodes.append(groundNode)

        return (tuple(groundGroups), tuple(groundNodes))
コード例 #9
0
ファイル: sub_parsers__init__.py プロジェクト: Difrex/wotsdk
def parseHint(xmlCtx, section):
    sectionInfo = dict()
    sectionInfo['hintID'] = parseID(xmlCtx, section, 'Specify a hint ID')
    if 'item-id' in section.keys():
        sectionInfo['itemID'] = parseID(xmlCtx, section['item-id'], 'Specify a item ID')
    else:
        _xml.raiseWrongXml(xmlCtx, section.name, 'Specify a item ID')
        return
    tags = section.keys()
    sectionInfo['text'] = translation(_xml.readString(xmlCtx, section, 'text'))
    if 'arrow' in tags:
        subSec = section['arrow']
        direction = _xml.readString(xmlCtx, subSec, 'direction')
        if direction not in _AVAILABLE_DIRECTIONS:
            _xml.raiseWrongXml(xmlCtx, section, 'Arrow direction {} is invalid.'.format(direction))
        sectionInfo['arrow'] = _ArrowProps(direction, _xml.readBool(xmlCtx, subSec, 'loop'))
    else:
        sectionInfo['arrow'] = None
    if 'padding' in tags:
        subSec = section['padding']
        sectionInfo['padding'] = _Padding(_xml.readFloat(xmlCtx, subSec, 'left'), _xml.readFloat(xmlCtx, subSec, 'top'), _xml.readFloat(xmlCtx, subSec, 'right'), _xml.readFloat(xmlCtx, subSec, 'bottom'))
    else:
        sectionInfo['padding'] = None
    sectionInfo['hasBox'] = section.readBool('has-box', True)
    return sectionInfo
コード例 #10
0
def _readWorldMarkerSection(xmlCtx, section):
    subSec = _xml.getSubsection(xmlCtx, section, 'world')
    return {
        'shape': _xml.readString(xmlCtx, subSec, 'shape'),
        'min-distance': _xml.readFloat(xmlCtx, subSec, 'min-distance'),
        'max-distance': _xml.readFloat(xmlCtx, subSec, 'max-distance'),
        'offset': _xml.readVector3(xmlCtx, subSec, 'offset')
    }
コード例 #11
0
def readTrackParams(xmlCtx, section):
    trackParams = None
    if section['trackNodes'] is not None:
        ctx = (xmlCtx, 'trackNodes')
        trackParams = chassis_components.TrackParams(thickness=_xml.readFloat(ctx, section, 'trackThickness'), maxAmplitude=_xml.readFloat(ctx, section, 'trackNodes/maxAmplitude'), maxOffset=_xml.readFloat(ctx, section, 'trackNodes/maxOffset'), gravity=_xml.readFloat(ctx, section, 'trackNodes/gravity'))
    if section['trackNodes'] is None and section['splineDesc'] is not None:
        trackParams = chassis_components.TrackParams(thickness=_xml.readFloat(xmlCtx, section, 'trackThickness'), maxAmplitude=component_constants.ZERO_FLOAT, maxOffset=component_constants.ZERO_FLOAT, gravity=component_constants.ZERO_FLOAT)
    return trackParams
コード例 #12
0
def readGroundNodesAndGroups(xmlCtx, section, cache):
    if section['groundNodes'] is None:
        return (component_constants.EMPTY_TUPLE,
                component_constants.EMPTY_TUPLE, False, None)
    else:
        groundGroups = []
        groundNodes = []
        for sname, subsection in _xml.getChildren(xmlCtx, section,
                                                  'groundNodes'):
            if sname == 'group':
                ctx = (xmlCtx, 'groundNodes/group')
                group = chassis_components.GroundNodeGroup(
                    isLeft=_xml.readBool(ctx, subsection, 'isLeft'),
                    minOffset=_xml.readFloat(ctx, subsection, 'minOffset'),
                    maxOffset=_xml.readFloat(ctx, subsection, 'maxOffset'),
                    nodesTemplate=intern(
                        _xml.readNonEmptyString(ctx, subsection, 'template')),
                    affectedWheelsTemplate=_xml.readStringOrNone(
                        ctx, subsection, 'affectedWheelsTemplate'),
                    nodesCount=_xml.readInt(ctx, subsection, 'count', 1),
                    startIndex=subsection.readInt('startIndex', 0),
                    collisionSamplesCount=subsection.readInt(
                        'collisionSamplesCount', 1),
                    hasLiftMode=_xml.readBool(ctx, subsection, 'hasLiftMode',
                                              False))
                groundGroups.append(group)
            if sname == 'node':
                ctx = (xmlCtx, 'groundNodes/node')
                groundNode = chassis_components.GroundNode(
                    nodeName=intern(
                        _xml.readNonEmptyString(ctx, subsection, 'name')),
                    affectedWheelName=_xml.readStringOrEmpty(
                        ctx, subsection, 'affectedWheelName'),
                    isLeft=_xml.readBool(ctx, subsection, 'isLeft'),
                    minOffset=_xml.readFloat(ctx, subsection, 'minOffset'),
                    maxOffset=_xml.readFloat(ctx, subsection, 'maxOffset'),
                    collisionSamplesCount=_xml.readInt(
                        ctx, subsection, 'collisionSamplesCount', 1),
                    hasLiftMode=_xml.readBool(ctx, subsection, 'hasLiftMode',
                                              False))
                groundNodes.append(groundNode)

        activePostmortem = _xml.readBool(xmlCtx, section,
                                         'groundNodes/activePostmortem', False)
        lodSettingsSection = section['groundNodes/lodSettings']
        if lodSettingsSection is not None:
            lodSettings = shared_readers.readLodSettings(
                xmlCtx, section['groundNodes'], cache)
        else:
            lodSettings = None
        return (tuple(groundGroups), tuple(groundNodes), activePostmortem,
                lodSettings)
コード例 #13
0
def __readSettings():
    ctx = (None, DYNAMIC_OBJECTS_CONFIG_FILE + '/' + AREA_VISUAL_TAG)
    settings = ResMgr.openSection(DYNAMIC_OBJECTS_CONFIG_FILE)[AREA_VISUAL_TAG]
    return InspireVisualSettings(
        modelPath=_xml.readString(ctx, settings, 'visual'),
        color=int(_xml.readString(ctx, settings, 'color'), 0),
        enableAccurateCollision=_xml.readBool(ctx, settings,
                                              'enableAccrurateCollision'),
        maxUpdateInterval=max(
            MIN_UPDATE_INTERVAL,
            _xml.readFloat(ctx, settings, 'maxUpdateInterval')),
        overTerrainHeight=max(
            MIN_OVER_TERRAIN_HEIGHT,
            _xml.readFloat(ctx, settings, 'overTerrainHeight')))
コード例 #14
0
ファイル: c11n_readers.py プロジェクト: kusaku/wot_scripts
 def _readFromXml(self, target, xmlCtx, section):
     super(PaintXmlReader, self)._readFromXml(target, xmlCtx, section)
     if section.has_key('color'):
         target.color = iv._readColor(xmlCtx, section, 'color')
     if section.has_key('gloss'):
         target.gloss = ix.readFloat(xmlCtx, section, 'gloss', 0.0)
     if section.has_key('metallic'):
         target.metallic = ix.readFloat(xmlCtx, section, 'metallic', 0.0)
     if section.has_key('usages'):
         xmlSubCtx = (xmlCtx, 'usages')
         for name, sub in ix.getChildren(xmlCtx, section, 'usages'):
             ctype, cost = self._readUsage(xmlSubCtx, sub)
             for i in ApplyArea.RANGE:
                 if ctype & i:
                     target.usageCosts[i] = cost
コード例 #15
0
def readTrackSplineParams(xmlCtx, section):
    trackSplineParams = None
    if IS_EDITOR:
        if not section.has_key('trackThickness'):
            return
    if section['trackNodes'] is not None:
        ctx = (xmlCtx, 'trackNodes')
        trackSplineParams = chassis_components.TrackSplineParams(thickness=_xml.readFloat(ctx, section, 'trackThickness'), maxAmplitude=_xml.readFloat(ctx, section, 'trackNodes/maxAmplitude'), maxOffset=_xml.readFloat(ctx, section, 'trackNodes/maxOffset'), gravity=_xml.readFloat(ctx, section, 'trackNodes/gravity'))
        if IS_EDITOR:
            trackSplineParams.editorData._enable = _xml.readBool(ctx, section, 'trackNodes/enable', True)
            trackSplineParams.editorData.elasticity = _xml.readFloat(ctx, section, 'trackNodes/elasticity', 1500.0)
            trackSplineParams.editorData.linkBones = _xml.readBool(ctx, section, 'trackNodes/linkBones', False)
    elif section['splineDesc'] is not None or section['physicalTracks'] is not None:
        trackSplineParams = chassis_components.TrackSplineParams(thickness=_xml.readFloat(xmlCtx, section, 'trackThickness'), maxAmplitude=component_constants.ZERO_FLOAT, maxOffset=component_constants.ZERO_FLOAT, gravity=component_constants.ZERO_FLOAT)
    return trackSplineParams
コード例 #16
0
def readTerrainCircleSettings(xmlSection, xmlCtx, xmlTag):
    settings = xmlSection[xmlTag]
    return TerrainCircleSettings(
        modelPath=_xml.readString(xmlCtx, settings, 'visual'),
        color=int(_xml.readString(xmlCtx, settings, 'color'), 0),
        enableAccurateCollision=_xml.readBool(xmlCtx, settings,
                                              'enableAccurateCollision'),
        maxUpdateInterval=max(
            MIN_UPDATE_INTERVAL,
            _xml.readFloat(xmlCtx, settings, 'maxUpdateInterval')),
        overTerrainHeight=max(
            MIN_OVER_TERRAIN_HEIGHT,
            _xml.readFloat(xmlCtx, settings, 'overTerrainHeight')),
        cutOffYDistance=_xml.readFloat(xmlCtx, settings, 'cutOffYDistance',
                                       -1.0))
コード例 #17
0
def readSplineTrackPairDesc(xmlCtx, section, cache):
    splineSegmentModelSets = {'default': chassis_components.SplineSegmentModelSet(left=_xml.readNonEmptyString(xmlCtx, section, 'segmentModelLeft'), right=_xml.readNonEmptyString(xmlCtx, section, 'segmentModelRight'), secondLeft=_xml.readStringOrNone(xmlCtx, section, 'segment2ModelLeft') or '', secondRight=_xml.readStringOrNone(xmlCtx, section, 'segment2ModelRight') or '')}
    modelSetsSection = section['modelSets']
    if modelSetsSection:
        for sname, subSection in modelSetsSection.items():
            splineSegmentModelSets[sname] = chassis_components.SplineSegmentModelSet(left=_xml.readNonEmptyString(xmlCtx, subSection, 'segmentModelLeft'), right=_xml.readNonEmptyString(xmlCtx, subSection, 'segmentModelRight'), secondLeft=_xml.readStringOrNone(xmlCtx, subSection, 'segment2ModelLeft') or '', secondRight=_xml.readStringOrNone(xmlCtx, subSection, 'segment2ModelRight') or '')

    length = _xml.readFloat(xmlCtx, section, 'segmentLength')
    offset = _xml.readFloat(xmlCtx, section, 'segmentOffset', 0)
    offset2 = _xml.readFloat(xmlCtx, section, 'segment2Offset', 0)
    trackPairIdx = section.readInt('trackPairIdx', 0)
    atlasUTiles = section.readInt('atlas/UTiles', 1)
    atlasVTiles = section.readInt('atlas/VTiles', 1)
    leftDesc = _xml.readStringOrNone(xmlCtx, section, 'left')
    rightDesc = _xml.readStringOrNone(xmlCtx, section, 'right')
    return SplineTrackPairDesc(trackPairIdx, splineSegmentModelSets, leftDesc, rightDesc, length, offset, offset2, atlasUTiles, atlasVTiles)
コード例 #18
0
def _readTeleportMarkerSection(xmlCtx, section, markerID, varRef):
    subSec = _xml.getSubsection(xmlCtx, section, 'world')
    worldData = {
        'offset': _xml.readVector3(xmlCtx, subSec, 'offset'),
        'yaw': _xml.readFloat(xmlCtx, subSec, 'yaw')
    }
    return chapter.AreaMarker(markerID, varRef, {}, {}, worldData, {})
コード例 #19
0
def readLeveredSuspension(xmlCtx, section, cache):
    leveredSection = section['leveredSuspension']
    if leveredSection is None:
        return
    else:
        levers = []
        for sname, subsection in _xml.getChildren(xmlCtx, section,
                                                  'leveredSuspension'):
            if sname != 'lever':
                continue
            ctx = (xmlCtx, 'leveredSuspension/lever')
            limits = _xml.readVector2(ctx, subsection, 'limits')
            lever = chassis_components.SuspensionLever(
                startNodeName=intern(
                    _xml.readNonEmptyString(ctx, subsection, 'startNode')),
                jointNodeName=intern(
                    _xml.readNonEmptyString(ctx, subsection, 'jointNode')),
                trackNodeName=intern(
                    _xml.readNonEmptyString(ctx, subsection, 'trackNode')),
                minAngle=math.radians(limits.x),
                maxAngle=math.radians(limits.y))
            levers.append(lever)

        ctx = (xmlCtx, 'leveredSuspension')
        leveredSuspensionConfig = chassis_components.LeveredSuspensionConfig(
            levers=levers,
            interpolationSpeedMul=_xml.readFloat(ctx, leveredSection,
                                                 'interpolationSpeedMul',
                                                 10.0),
            lodSettings=shared_readers.readLodSettings(ctx, leveredSection,
                                                       cache))
        return leveredSuspensionConfig
コード例 #20
0
def readSplineConfig(xmlCtx, section, cache):
    """Reads levered suspension section.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :param cache: instance of vehicles.Cache.
    :return: instance of SplineConfig or None.
    """
    if section['splineDesc'] is None:
        return
    else:
        return chassis_components.SplineConfig(
            segmentModelLeft=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelLeft'),
            segmentModelRight=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelRight'),
            segmentLength=_xml.readFloat(xmlCtx, section,
                                         'splineDesc/segmentLength'),
            leftDesc=_xml.readStringOrNone(xmlCtx, section, 'splineDesc/left'),
            rightDesc=_xml.readStringOrNone(xmlCtx, section,
                                            'splineDesc/right'),
            lodDist=shared_readers.readLodDist(xmlCtx, section,
                                               'splineDesc/lodDist', cache),
            segmentOffset=section.readFloat('splineDesc/segmentOffset', 0),
            segment2ModelLeft=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelLeft'),
            segment2ModelRight=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelRight'),
            segment2Offset=section.readFloat('splineDesc/segment2Offset', 0),
            atlasUTiles=section.readInt('splineDesc/atlas/UTiles', 1),
            atlasVTiles=section.readInt('splineDesc/atlas/VTiles', 1))
コード例 #21
0
def readTrackMaterials(xmlCtx, section, cache):
    return chassis_components.TrackMaterials(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'tracks/lodDist',
                                           cache),
        leftMaterial=intern(
            _xml.readNonEmptyString(xmlCtx, section, 'tracks/leftMaterial')),
        rightMaterial=intern(
            _xml.readNonEmptyString(xmlCtx, section, 'tracks/rightMaterial')),
        textureScale=_xml.readFloat(xmlCtx, section, 'tracks/textureScale'))
コード例 #22
0
def _readExitSection(xmlCtx, section, _):
    exitID = sub_parsers.parseID(xmlCtx, section, 'Specify a exit ID')
    return chapter.Exit(exitID,
                        nextChapter=_xml.readString(xmlCtx, section,
                                                    'chapter-id'),
                        nextDelay=_xml.readFloat(xmlCtx, section,
                                                 'next-delay'),
                        finishDelay=section.readFloat('finish-delay'),
                        isSpeakOver=section.readBool('is-speak-over'))
コード例 #23
0
def readTrackBasicParams(xmlCtx, section, cache):
    tracksSection = section['tracks']
    return None if tracksSection is None else chassis_components.TrackBasicParams(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'tracks/lodDist',
                                           cache),
        leftMaterial=intern(
            _xml.readNonEmptyString(xmlCtx, section, 'tracks/leftMaterial')),
        rightMaterial=intern(
            _xml.readNonEmptyString(xmlCtx, section, 'tracks/rightMaterial')),
        textureScale=_xml.readFloat(xmlCtx, section, 'tracks/textureScale'),
        pairsCount=section.readInt('tracks/pairsCount', 1))
コード例 #24
0
def readTrackParams(xmlCtx, section):
    """Reads section 'trackNodes' for each chassis if it has.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :return: instance of TrackParams or None.
    """
    trackParams = None
    if section['trackNodes'] is not None:
        ctx = (xmlCtx, 'trackNodes')
        trackParams = chassis_components.TrackParams(
            thickness=_xml.readFloat(ctx, section, 'trackThickness'),
            maxAmplitude=_xml.readFloat(ctx, section,
                                        'trackNodes/maxAmplitude'),
            maxOffset=_xml.readFloat(ctx, section, 'trackNodes/maxOffset'),
            gravity=_xml.readFloat(ctx, section, 'trackNodes/gravity'))
    if section['trackNodes'] is None and section['splineDesc'] is not None:
        trackParams = chassis_components.TrackParams(
            thickness=_xml.readFloat(xmlCtx, section, 'trackThickness'),
            maxAmplitude=component_constants.ZERO_FLOAT,
            maxOffset=component_constants.ZERO_FLOAT,
            gravity=component_constants.ZERO_FLOAT)
    return trackParams
コード例 #25
0
def _readVisualSettings():
    ctx = (None, CONFIG_FILE + '/' + BORDER_VISUAL_TAG)
    settings = ResMgr.openSection(CONFIG_FILE)[BORDER_VISUAL_TAG]
    return VisualSetting(
        modelPath=_xml.readString(ctx, settings, 'modelPath'),
        overTerrainHeight=_xml.readFloat(ctx, settings, 'overTerrainHeight'),
        modelSettings={
            getattr(SECTOR_EDGE_STATE,
                    item[1][1]['edgeState'].asString.upper()):
            _readModelSetting(*item[1])
            for item in _xml.getItemsWithContext(ctx, settings, 'modelSetting')
            if SECTOR_EDGE_STATE.hasKey(item[1][1]
                                        ['edgeState'].asString.upper())
        })
コード例 #26
0
def readSplineConfig(xmlCtx, section, cache):
    return None if section[
        'splineDesc'] is None else chassis_components.SplineConfig(
            segmentModelLeft=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelLeft'),
            segmentModelRight=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelRight'),
            segmentLength=_xml.readFloat(xmlCtx, section,
                                         'splineDesc/segmentLength'),
            leftDesc=_xml.readStringOrNone(xmlCtx, section, 'splineDesc/left'),
            rightDesc=_xml.readStringOrNone(xmlCtx, section,
                                            'splineDesc/right'),
            lodDist=shared_readers.readLodDist(xmlCtx, section,
                                               'splineDesc/lodDist', cache),
            segmentOffset=_xml.readFloat(xmlCtx, section,
                                         'splineDesc/segmentOffset', 0),
            segment2ModelLeft=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelLeft'),
            segment2ModelRight=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelRight'),
            segment2Offset=_xml.readFloat(xmlCtx, section,
                                          'splineDesc/segment2Offset', 0),
            atlasUTiles=section.readInt('splineDesc/atlas/UTiles', 1),
            atlasVTiles=section.readInt('splineDesc/atlas/VTiles', 1))
コード例 #27
0
def readTrackMaterials(xmlCtx, section, cache):
    """Reads section 'tracks' for each chassis to fetch configuration of materials.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :param cache: instance of vehicles.Cache.
    :return: instance of TrackMaterials.
    """
    return chassis_components.TrackMaterials(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'tracks/lodDist',
                                           cache),
        leftMaterial=_xml.readNonEmptyString(xmlCtx, section,
                                             'tracks/leftMaterial'),
        rightMaterial=_xml.readNonEmptyString(xmlCtx, section,
                                              'tracks/rightMaterial'),
        textureScale=_xml.readFloat(xmlCtx, section, 'tracks/textureScale'))
コード例 #28
0
def readShot(xmlCtx, section, nationID, projectileSpeedFactor, cache):
    shellName = section.name
    shellID = cache.shellIDs(nationID).get(shellName)
    if shellID is None:
        _xml.raiseWrongXml(xmlCtx, '', 'unknown shell type name')
    shellDescr = cache.shells(nationID)[shellID]
    return gun_components.GunShot(
        shellDescr, ZERO_FLOAT if not section.has_key('defaultPortion') else
        _xml.readFraction(xmlCtx, section, 'defaultPortion'),
        _xml.readVector2(xmlCtx, section, 'piercingPower'),
        _xml.readPositiveFloat(xmlCtx, section, 'speed') *
        projectileSpeedFactor,
        _xml.readNonNegativeFloat(xmlCtx, section, 'gravity') *
        projectileSpeedFactor**2,
        _xml.readPositiveFloat(xmlCtx, section, 'maxDistance'),
        _xml.readFloat(xmlCtx, section, 'maxHeight', 1000000.0))
コード例 #29
0
ファイル: c11n_readers.py プロジェクト: kusaku/wot_scripts
    def _readClientOnlyFromXml(self, target, xmlCtx, section):
        super(ModificationXmlReader,
              self)._readClientOnlyFromXml(target, xmlCtx, section)
        if section.has_key('texture'):
            target.texture = section.readString('texture')
        if section.has_key('effects'):
            xmlSubCtx = (xmlCtx, 'effects')
            i = 0
            result = {}
            for name, sub in ix.getChildren(xmlCtx, section, 'effects'):
                itemCtx = (xmlSubCtx, '{}[{}]'.format(name, i))
                mtype = readEnum(itemCtx, sub, 'type', ModificationType)
                result[mtype] = ix.readFloat(itemCtx, sub, 'value', 0.0)
                i += 1

            target.effects = result
コード例 #30
0
def readHullAimingSound(xmlCtx, section, cache):
    if section['hullAiming'] is None:
        return
    else:
        try:
            lodDist = shared_readers.readLodDist(xmlCtx, section,
                                                 'hullAiming/audio/lodDist',
                                                 cache)
            angleLimit = math.radians(
                _xml.readFloat(xmlCtx, section,
                               'hullAiming/audio/angleLimitValue',
                               component_constants.ZERO_FLOAT))
            sounds = []
            for actionName, actionSection in _xml.getChildren(
                    xmlCtx, section, 'hullAiming/audio/sounds'):
                ctx = (xmlCtx, 'hullAiming/audio/sounds')
                underLimitSouns = sound_components.SoundPair(
                    PC=intern(
                        _xml.readNonEmptyString(ctx, actionSection,
                                                'underLimitSounds/wwsoundPC')),
                    NPC=intern(
                        _xml.readNonEmptyString(
                            ctx, actionSection,
                            'underLimitSounds/wwsoundNPC')))
                overLimitSounds = sound_components.SoundPair(
                    PC=intern(
                        _xml.readNonEmptyString(ctx, actionSection,
                                                'overLimitSounds/wwsoundPC')),
                    NPC=intern(
                        _xml.readNonEmptyString(ctx, actionSection,
                                                'overLimitSounds/wwsoundNPC')))
                sound = sound_components.StatedSounds(
                    state=actionName,
                    underLimitSounds=underLimitSouns,
                    overLimitSounds=overLimitSounds)
                sounds.append(sound)

            hullAimingSound = sound_components.HullAimingSound(
                lodDist=lodDist,
                angleLimitValue=_xml.cachedFloat(angleLimit),
                sounds=sounds)
            return hullAimingSound
        except:
            LOG_DEBUG('Incorrect hullAiming/audio section')
            return

        return
コード例 #31
0
def _readProjectionDecalSlot(ctx, subsection, slotType):
    descr = shared_components.ProjectionDecalSlotDescription(
        slotType=slotType,
        slotId=_xml.readInt(ctx, subsection, 'slotId'),
        anchorPosition=_xml.readVector3OrNone(ctx, subsection,
                                              'anchorPosition'),
        anchorDirection=_xml.readVector3OrNone(ctx, subsection,
                                               'anchorDirection'),
        position=_xml.readVector3OrNone(ctx, subsection, 'position'),
        rotation=_xml.readVector3OrNone(ctx, subsection, 'rotation'),
        scale=_xml.readVector3OrNone(ctx, subsection, 'scale'),
        scaleFactors=_xml.readVector3(
            ctx, subsection, 'scaleFactors',
            c11n_constants.DEFAULT_DECAL_SCALE_FACTORS),
        doubleSided=_xml.readBool(ctx, subsection, 'doubleSided', False),
        canBeMirroredVertically=_xml.readBool(ctx, subsection,
                                              'verticalMirror', False),
        showOn=_xml.readIntOrNone(ctx, subsection, 'showOn'),
        tags=readOrderedTagsOrEmpty(ctx, subsection,
                                    _customizationSlotTagsValidator),
        clipAngle=_xml.readFloat(ctx, subsection, 'clipAngle',
                                 c11n_constants.DEFAULT_DECAL_CLIP_ANGLE))
    _verifySlotId(ctx, slotType, descr.slotId)
    if descr.showOn is not None:
        availableShowOnRegions = c11n_constants.ApplyArea.HULL | c11n_constants.ApplyArea.TURRET | c11n_constants.ApplyArea.GUN
        if descr.showOn | availableShowOnRegions != availableShowOnRegions:
            _xml.raiseWrongSection(ctx, 'showOn')
    if subsection.has_key('attachedPart'):
        attachedPartsData = _xml.readString(ctx, subsection, 'attachedPart')
        descr.attachedParts = defaultdict(set)
        for partData in attachedPartsData.split():
            pType, pName = partData.split(':')
            if pType != 'hull':
                descr.attachedParts[pType].add(pName)

    if subsection.has_key('compatibleModels'):
        descr.compatibleModels = _xml.readTupleOfStrings(
            ctx, subsection, 'compatibleModels')
    if subsection.has_key('itemId'):
        descr.itemId = _xml.readInt(ctx, subsection, 'itemId')
    if subsection.has_key('options'):
        descr.options = _xml.readNonNegativeInt(ctx, subsection, 'options')
    return descr
コード例 #32
0
def readLeveredSuspension(xmlCtx, section, cache):
    leveredSection = section['leveredSuspension']
    if leveredSection is None:
        return
    else:
        levers = []
        for sname, subsection in _xml.getChildren(xmlCtx, section,
                                                  'leveredSuspension'):
            if sname != 'lever':
                continue
            ctx = (xmlCtx, 'leveredSuspension/lever')
            limits = _xml.readVector2(ctx, subsection, 'limits')
            lever = chassis_components.SuspensionLever(
                startNodeName=intern(
                    _xml.readNonEmptyString(ctx, subsection, 'startNode')),
                jointNodeName=intern(
                    _xml.readNonEmptyString(ctx, subsection, 'jointNode')),
                trackNodeName=intern(
                    _xml.readNonEmptyString(ctx, subsection, 'trackNode')),
                minAngle=math.radians(limits.x),
                maxAngle=math.radians(limits.y),
                collisionSamplesCount=subsection.readInt(
                    'collisionSamplesCount', 1),
                hasLiftMode=_xml.readBool(ctx, subsection, 'hasLiftMode',
                                          False),
                affectedWheelName=_xml.readStringOrEmpty(
                    ctx, subsection, 'affectedWheelName'))
            levers.append(lever)

        ctx = (xmlCtx, 'leveredSuspension')
        leveredSuspensionConfig = chassis_components.LeveredSuspensionConfig(
            levers=levers,
            interpolationSpeedMul=_xml.readFloat(ctx, leveredSection,
                                                 'interpolationSpeedMul',
                                                 10.0),
            lodSettings=shared_readers.readLodSettings(ctx, leveredSection,
                                                       cache),
            activePostmortem=_xml.readBool(ctx, leveredSection,
                                           'activePostmortem', False))
        return leveredSuspensionConfig
コード例 #33
0
ファイル: artefacts.py プロジェクト: webiumsk/WOT0.9.10
 def _readConfig(self, xmlCtx, section):
     self.__value = _xml.readFloat(xmlCtx, section, 'value')
     self.__attr = _xml.readNonEmptyString(xmlCtx, section, 'attribute').split('/', 1)
コード例 #34
0
ファイル: battle.py プロジェクト: webiumsk/WOT0.9.10
def _readExitSection(xmlCtx, section, _):
    exitID = sub_parsers.parseID(xmlCtx, section, 'Specify a exit ID')
    return chapter.Exit(exitID, nextChapter=_xml.readString(xmlCtx, section, 'chapter-id'), nextDelay=_xml.readFloat(xmlCtx, section, 'next-delay'), finishDelay=section.readFloat('finish-delay'), isSpeakOver=section.readBool('is-speak-over'))
コード例 #35
0
ファイル: battle.py プロジェクト: webiumsk/WOT0.9.10
def _readTeleportMarkerSection(xmlCtx, section, markerID, varRef):
    subSec = _xml.getSubsection(xmlCtx, section, 'world')
    worldData = {'offset': _xml.readVector3(xmlCtx, subSec, 'offset'),
     'yaw': _xml.readFloat(xmlCtx, subSec, 'yaw')}
    return chapter.AreaMarker(markerID, varRef, {}, {}, worldData, {})
コード例 #36
0
ファイル: battle.py プロジェクト: webiumsk/WOT0.9.10
def _readVehicleMarkerSection(xmlCtx, section, markerID, varRef):
    return chapter.VehicleMarker(markerID, varRef, _xml.readFloat(xmlCtx, section, 'period'), createInd=section.readBool('create-indicator', True))
コード例 #37
0
ファイル: battle.py プロジェクト: webiumsk/WOT0.9.10
def _readWorldMarkerSection(xmlCtx, section):
    subSec = _xml.getSubsection(xmlCtx, section, 'world')
    return {'shape': _xml.readString(xmlCtx, subSec, 'shape'),
     'min-distance': _xml.readFloat(xmlCtx, subSec, 'min-distance'),
     'max-distance': _xml.readFloat(xmlCtx, subSec, 'max-distance'),
     'offset': _xml.readVector3(xmlCtx, subSec, 'offset')}