Example #1
0
    def _getCommonChapterValues(self, bonuses, subSection, xmlCtx):
        chapterID = _xml.readString(xmlCtx, subSection, 'chapter-id')
        title = translation(_xml.readString(xmlCtx, subSection, 'title'))
        descSec = _xml.getSubsection(xmlCtx, subSection, 'description')
        defDesc = translation(descSec.asString)
        abDesc = translation(descSec.readString('after-battle', defDesc))
        descriptions = (defDesc, abDesc)
        bonus = self._parseBonus(xmlCtx, subSection, bonuses)
        forcedLoading = subSection.readInt('forced-loading', -1)
        pathSec = _xml.getSubsection(xmlCtx, subSection, 'file-path')
        defFilePath = pathSec.asString
        afterBattleFilePath = pathSec.readString('after-battle', defFilePath)
        filePaths = (defFilePath, afterBattleFilePath)
        sharedScene = subSection.readString('shared-scene')
        predefinedVars = []
        varsSection = subSection['vars'] or {}
        for name, varSection in varsSection.items():
            if name == 'var-set':
                predefinedVars.append(
                    sub_parsers.parseVarSet(xmlCtx, varSection, ()))
            else:
                _xml.raiseWrongXml(xmlCtx, name, 'Unknown tag')

        return (chapterID, title, descriptions, bonus, forcedLoading,
                filePaths, sharedScene, predefinedVars)
Example #2
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))
        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
Example #3
0
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
Example #4
0
def _readFinalWindowSection(xmlCtx, section, _, windowID, windowType, content):
    bSec = _xml.getSubsection(xmlCtx, section, 'buttons')
    content['restartID'] = _xml.readString(xmlCtx, bSec, 'restart')
    content['showVideoID'] = _xml.readString(xmlCtx, bSec, 'show-video')
    content['imageUrl'] = section.readString('image')
    hintsSec = _xml.getSubsection(xmlCtx, section, 'battle-hints')
    hints = []
    for typeName, hintSec in hintsSec.items():
        if len(hintSec.keys()):
            data = {'type': typeName}
            for key, subSec in hintSec.items():
                data[key] = translation(subSec.asString)

            hints.append(data)
        else:
            hints.append({
                'type': typeName,
                'label': translation(hintSec.asString)
            })

    content['battleHints'] = hints
    content['restartHint'] = translation(
        _xml.readString(xmlCtx, section, 'restart-hint'))
    return chapter.PopUp(windowID, windowType, content,
                         _xml.readString(xmlCtx, section, 'var-ref'))
Example #5
0
 def _readConfig(self, xmlCtx, section):
     self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay')
     self.modelName = _xml.readString(xmlCtx, section, 'modelName')
     self.soundEvent = _xml.readString(xmlCtx, section, 'soundEvent')
     self.speed = _xml.readInt(xmlCtx, section, 'speed')
     self.heights = _xml.readTupleOfPositiveInts(xmlCtx, section, 'heights', 2)
     self.areaLength = _xml.readPositiveFloat(xmlCtx, section, 'areaLength')
     self.areaWidth = _xml.readPositiveFloat(xmlCtx, section, 'areaWidth')
     self.antepositions = _xml.readTupleOfFloats(xmlCtx, section, 'antepositions')
     self.lateropositions = _xml.readTupleOfFloats(xmlCtx, section, 'lateropositions')
     self.bombingMask = tuple((bool(v) for v in _xml.readTupleOfInts(xmlCtx, section, 'bombingMask')))
     if not len(self.antepositions) == len(self.lateropositions) == len(self.bombingMask):
         _xml.raiseWrongSection(xmlCtx, 'bombers number mismatch')
     self.waveFraction = _xml.readPositiveFloat(xmlCtx, section, 'waveFraction')
     self.bombsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'bombsNumber')
     self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr')
     self.tracerKind = _xml.readInt(xmlCtx, section, 'tracerKind')
     self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2)
     self.gravity = _xml.readPositiveFloat(xmlCtx, section, 'gravity')
     self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual')
     self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor')
     self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker')
     self.reusable = _xml.readBool(xmlCtx, section, 'reusable')
     self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0
     self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
Example #6
0
def _readChapterTaskSection(xmlCtx, section, _):
    taskID = sub_parsers.parseID(xmlCtx, section, 'Specify a task ID')
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    flagID = None
    if 'flag' in section.keys():
        flagID = _xml.readString(xmlCtx, section, 'flag')
    return chapter.ChapterTask(taskID, text, flagID=flagID)
Example #7
0
def _readQuestCompletedDialogSection(xmlCtx, section, _, dialogID, type,
                                     content):
    content = _readBonusSection(xmlCtx, section, content)
    content['hintText'] = translation(_xml.readString(xmlCtx, section, 'hint'))
    content['submitLabel'] = translation(
        _xml.readString(xmlCtx, section, 'submit-label'))
    return chapter.PopUp(dialogID, type, content)
Example #8
0
def _readReplenishAmmoDialogSection(xmlCtx, section, _, dialogID, type, content):
    content['_submitLabel'] = translation(_xml.readString(xmlCtx, section, 'submit-label'))
    content['_align'] = _xml.readString(xmlCtx, section, 'align')
    vector = _xml.readVector2(xmlCtx, section, 'offset')
    content['_popupOffsetX'] = vector.x
    content['_popupOffsetY'] = vector.y
    return chapter.PopUp(dialogID, type, content)
Example #9
0
def _parseDialog(xmlCtx, section, flags):
    dialogID = _parseID(xmlCtx, section, 'Specify a dialog ID')
    dialogType = _xml.readString(xmlCtx, section, 'type')
    bSec = _xml.getSubsection(xmlCtx, section, 'buttons')
    submitID = bSec.readString('submit', '')
    cancelID = bSec.readString('cancel', '')
    if not len(submitID) and not len(cancelID):
        _xml.raiseWrongXml(xmlCtx, '',
                           'Tag submit or cancel must be specified.')
    content = {
        'type': dialogType,
        'dialogID': dialogID,
        'submitID': submitID,
        'cancelID': cancelID,
        'title': translation(_xml.readString(xmlCtx, section, 'title')),
        'message': translation(_xml.readString(xmlCtx, section, 'text')),
        'imageUrl': section.readString('image')
    }
    parser = _DIALOG_SUB_PARERS.get(dialogType)
    if parser is not None:
        dialog = parser(xmlCtx, section, flags, dialogID, dialogType, content)
    else:
        dialog = chapter.PopUp(dialogID, dialogType, content)
    dialog.setActions(
        _parseActions(xmlCtx, _xml.getSubsection(xmlCtx, section, 'actions'),
                      flags))
    return dialog
Example #10
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))
        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
Example #11
0
    def __readSharedMetrics(self, shared, xmlCtx, section):
        precessed = _xml.getChildren(xmlCtx, section, 'grids')
        for name, gridSection in precessed:
            gridName = gridSection.asString
            xPath = '{0:>s}/{1:>s}/{2:>s}'.format(TREE_SHARED_REL_FILE_PATH,
                                                  name, gridName)
            gridCtx = (None, xPath)
            subSec = _xml.getSubsection(xmlCtx, gridSection, 'root')
            xmlCtx = (None, '{0:>s}/root'.format(xPath))
            rootPos = {
                'start': _xml.readVector2(xmlCtx, subSec, 'start').tuple(),
                'step': _xml.readInt(xmlCtx, subSec, 'step')
            }
            subSec = _xml.getSubsection(gridCtx, gridSection, 'vertical')
            xmlCtx = (None, '{0:>s}/vertical'.format(xPath))
            vertical = (_xml.readInt(xmlCtx, subSec, 'start'),
                        _xml.readInt(xmlCtx, subSec, 'step'))
            subSec = _xml.getSubsection(gridCtx, gridSection, 'horizontal')
            xmlCtx = (None, '{0:>s}/horizontal'.format(xPath))
            horizontal = (_xml.readInt(xmlCtx, subSec, 'start'),
                          _xml.readInt(xmlCtx, subSec, 'step'))
            shared['grids'][gridName] = {
                'root': rootPos,
                'vertical': vertical,
                'horizontal': horizontal
            }

        precessed = _xml.getChildren(xmlCtx, section, 'lines')
        lines = shared['lines']
        for name, sub in precessed:
            xPath = '{0:>s}/{1:>s}'.format(TREE_SHARED_REL_FILE_PATH, name)
            xmlCtx = (None, xPath)
            pinsSec = _xml.getChildren(xmlCtx, sub, 'inPin')
            inPins = dict(
                ((pName, pSec.asVector2.tuple()) for pName, pSec in pinsSec))
            pinsSec = _xml.getChildren(xmlCtx, sub, 'outPin')
            outPins = dict(
                ((pName, pSec.asVector2.tuple()) for pName, pSec in pinsSec))
            pinsSec = _xml.getChildren(xmlCtx, sub, 'viaPin')
            viaPins = defaultdict(dict)
            for outPin, setSec in pinsSec:
                for inPin, pSec in setSec.items():
                    viaPins[outPin][inPin] = map(
                        lambda section: section[1].asVector2.tuple(),
                        pSec.items())

            defSec = sub['default']
            default = {}
            if defSec is not None:
                xmlCtx = (None, '{0:>s}/default'.format(xPath))
                default = {
                    'outPin': _xml.readString(xmlCtx, defSec, 'outPin'),
                    'inPin': _xml.readString(xmlCtx, defSec, 'inPin')
                }
            lines[name] = {
                'inPins': inPins,
                'outPins': outPins,
                'viaPins': viaPins,
                'default': default
            }
Example #12
0
 def _readConfig(self, xmlCtx, section):
     self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay')
     self.modelName = _xml.readString(xmlCtx, section, 'modelName')
     if IS_CLIENT:
         self.soundEvent = _xml.readString(xmlCtx, section, 'wwsoundEvent')
     self.speed = _xml.readInt(xmlCtx, section, 'speed')
     self.heights = _xml.readTupleOfPositiveInts(xmlCtx, section, 'heights', 2)
     self.areaLength = _xml.readPositiveFloat(xmlCtx, section, 'areaLength')
     self.areaWidth = _xml.readPositiveFloat(xmlCtx, section, 'areaWidth')
     self.antepositions = _xml.readTupleOfFloats(xmlCtx, section, 'antepositions')
     self.lateropositions = _xml.readTupleOfFloats(xmlCtx, section, 'lateropositions')
     self.bombingMask = tuple((bool(v) for v in _xml.readTupleOfInts(xmlCtx, section, 'bombingMask')))
     if not len(self.antepositions) == len(self.lateropositions) == len(self.bombingMask):
         _xml.raiseWrongSection(xmlCtx, 'bombers number mismatch')
     self.waveFraction = _xml.readPositiveFloat(xmlCtx, section, 'waveFraction')
     self.bombsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'bombsNumber')
     self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr')
     self.tracerKind = _xml.readInt(xmlCtx, section, 'tracerKind')
     self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2)
     self.gravity = _xml.readPositiveFloat(xmlCtx, section, 'gravity')
     self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual')
     self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor')
     self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker')
     self.reusable = _xml.readBool(xmlCtx, section, 'reusable')
     self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0
     self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
Example #13
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
Example #14
0
    def init(self, xmlPath):
        section = ResMgr.openSection(xmlPath)
        if section is None:
            _xml.raiseWrongXml(None, xmlPath, 'cannot open or read')
        xmlCtx = (None, xmlPath)
        readIdentifiers = set()
        for name, subsection in section.items():
            ctx = (xmlCtx, name)
            if name != 'item':
                _xml.raiseWrongXml(
                    ctx, '',
                    "Wrong section: '{}', only 'item' sections expected.".
                    format(name))
            identifier = _xml.readString(ctx, subsection, 'identifier')
            if identifier in readIdentifiers:
                _xml.raiseWrongXml(
                    ctx, identifier,
                    "Identifier '{}' defined multiple times.".format(
                        identifier))
            readIdentifiers.add(identifier)
            self.__tooltipsSettings[identifier] = ConsumableTooltipEntry(
                _xml.readString(ctx, subsection, 'name'),
                _xml.readString(ctx, subsection, 'renderer'))

        if IS_DEVELOPMENT:
            self._validateTooltipsData(self.__tooltipsSettings)
        return
Example #15
0
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
Example #16
0
def _readQuestAndHelpDialogSection(xmlCtx, section, _, dialogID, type,
                                   content):
    content = _readBonusSection(xmlCtx, section, content)
    content['questText'] = translation(
        _xml.readString(xmlCtx, section, 'quest'))
    content['helpSource'] = _xml.readString(xmlCtx, section, 'help')
    return chapter.PopUp(dialogID, type, content)
Example #17
0
def _readFonts(cache, xmlCtx, section, sectionName):
    if IS_EDITOR:
        itemType = CUSTOMIZATION_CLASSES[cc.Font]
        sourceFiles = set()
    for tag, iSection in section.items():
        if tag != sectionName:
            continue
        font = cc.Font()
        font.id = ix.readInt(xmlCtx, iSection, 'id', 1)
        iCtx = (xmlCtx, 'id %s' % font.id)
        if font.id in cache.fonts:
            ix.raiseWrongXml(iCtx, 'id', 'duplicate price group id')
        font.texture = ix.readString(xmlCtx, iSection, 'texture')
        font.alphabet = ix.readString(xmlCtx, iSection, 'alphabet')
        if iSection.has_key('mask'):
            font.mask = ix.readString(xmlCtx, iSection, 'mask')
        cache.fonts[font.id] = font
        if IS_EDITOR:
            refs = iSection.references
            if len(refs) == 1:
                font.editorData.sourceXml = refs[0]
                sourceFiles.add(refs[0])

    if IS_EDITOR:
        cache.editorData.sourceFiles[itemType] = list(sourceFiles)
Example #18
0
    def _getCommonChapterValues(self, bonuses, subSection, xmlCtx):
        chapterID = _xml.readString(xmlCtx, subSection, 'chapter-id')
        title = translation(_xml.readString(xmlCtx, subSection, 'title'))
        descSec = _xml.getSubsection(xmlCtx, subSection, 'description')
        defDesc = translation(descSec.asString)
        abDesc = translation(descSec.readString('after-battle', defDesc))
        descriptions = (defDesc, abDesc)
        bonus = self._parseBonus(xmlCtx, subSection, bonuses)
        forcedLoading = subSection.readInt('forced-loading', -1)
        pathSec = _xml.getSubsection(xmlCtx, subSection, 'file-path')
        defFilePath = pathSec.asString
        afterBattleFilePath = pathSec.readString('after-battle', defFilePath)
        filePaths = (defFilePath, afterBattleFilePath)
        sharedScene = subSection.readString('shared-scene')
        predefinedVars = []
        varsSection = subSection['vars'] or {}
        for name, varSection in varsSection.items():
            if name == 'var-set':
                predefinedVars.append(sub_parsers.parseVarSet(xmlCtx, varSection, ()))
            else:
                _xml.raiseWrongXml(xmlCtx, name, 'Unknown tag')

        return (chapterID,
         title,
         descriptions,
         bonus,
         forcedLoading,
         filePaths,
         sharedScene,
         predefinedVars)
Example #19
0
def _readChapterTaskSection(xmlCtx, section, _):
    taskID = sub_parsers.parseID(xmlCtx, section, 'Specify a task ID')
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    flagID = None
    if 'flag' in section.keys():
        flagID = _xml.readString(xmlCtx, section, 'flag')
    return chapter.ChapterTask(taskID, text, flagID=flagID)
Example #20
0
def _readReplenishAmmoDialogSection(xmlCtx, section, _, dialogID, type, content):
    content['_submitLabel'] = translation(_xml.readString(xmlCtx, section, 'submit-label'))
    content['_align'] = _xml.readString(xmlCtx, section, 'align')
    vector = _xml.readVector2(xmlCtx, section, 'offset')
    content['_popupOffsetX'] = vector.x
    content['_popupOffsetY'] = vector.y
    return chapter.PopUp(dialogID, type, content)
Example #21
0
def _readCloseViewEffectSection(xmlCtx, section, flags, conditions):
    layer = LAYER_NAMES.LAYER_ORDER.index(
        _xml.readString(xmlCtx, section, 'type'))
    viewAlias = _xml.readString(xmlCtx, section, 'alias')
    return effects.HasTargetEffect((layer, viewAlias),
                                   effects.EFFECT_TYPE.CLOSE_VIEW,
                                   conditions=conditions)
Example #22
0
def _readGreetingSection(xmlCtx, section, _):
    greetingID = sub_parsers.parseID(xmlCtx, section, 'Specify a greeting ID')
    title = translation(_xml.readString(xmlCtx, section, 'title'))
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    speakID = None
    if 'wwspeak' in section.keys():
        speakID = _xml.readString(xmlCtx, section, 'wwspeak')
    return chapter.Greeting(greetingID, title, text, speakID=speakID)
Example #23
0
def _readModelMarkerSection(xmlCtx, section, name = 'model'):
    result = {}
    if name in section.keys():
        subSec = _xml.getSubsection(xmlCtx, section, name)
        result = {'path': _xml.readString(xmlCtx, subSec, 'path'),
         'action': _xml.readString(xmlCtx, subSec, 'action'),
         'offset': _xml.readVector3(xmlCtx, subSec, 'offset')}
    return result
Example #24
0
 def _readModificationID(xmlCtx, section, modificationIDs):
     xmlCtx = (xmlCtx, section.name)
     name = _xml.readString(xmlCtx, section, 'name')
     priceTag = _xml.readString(xmlCtx, section, 'price')
     modificationID = modificationIDs.get(name)
     if modificationID is None:
         _xml.raiseWrongXml(xmlCtx, name, 'Unknown modification')
     return (modificationID, priceTag)
Example #25
0
def _readBonusSection(xmlCtx, section, content):
    bonusSec = _xml.getSubsection(xmlCtx, section, 'bonus')
    content['bonusValue'] = translation(
        _xml.readString(xmlCtx, bonusSec, 'value'))
    content['bonusLabel'] = translation(
        _xml.readString(xmlCtx, bonusSec, 'label'))
    content['bonusImageUrl'] = _xml.readString(xmlCtx, bonusSec, 'background')
    return content
Example #26
0
def _readModelMarkerSection(xmlCtx, section, name = 'model'):
    result = {}
    if name in section.keys():
        subSec = _xml.getSubsection(xmlCtx, section, name)
        result = {'path': _xml.readString(xmlCtx, subSec, 'path'),
         'action': _xml.readString(xmlCtx, subSec, 'action'),
         'offset': _xml.readVector3(xmlCtx, subSec, 'offset')}
    return result
Example #27
0
def _readVehicleItemsChangedTrigger(xmlCtx, section, triggerID, clazz):
    validateVarID = _xml.readString(xmlCtx, section, 'validate-var')
    vehicleVarID = _xml.readString(xmlCtx, section, 'vehicle-var')
    validateUpdateOnly = 'validate-update-only' in section.keys()
    return clazz(triggerID,
                 validateVarID,
                 vehicleVarID,
                 validateUpdateOnly=validateUpdateOnly)
Example #28
0
def _readGreetingSection(xmlCtx, section, _):
    greetingID = sub_parsers.parseID(xmlCtx, section, 'Specify a greeting ID')
    title = translation(_xml.readString(xmlCtx, section, 'title'))
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    speakID = None
    if 'speak' in section.keys():
        speakID = _xml.readString(xmlCtx, section, 'speak')
    return chapter.Greeting(greetingID, title, text, speakID=speakID)
Example #29
0
def _readGuiItemDefinition(xmlCtx, section, _, conditions):
    newGuiItemId = _parseID(xmlCtx, section, 'Specify a new gui item ID')
    parentReferenceId = _xml.readString(xmlCtx, section, 'parent-ref')
    extraReferenceId = _xml.readString(xmlCtx, section, 'extra-ref')
    return chapter.DefineGuiItemEffect(newGuiItemId,
                                       chapter.Effect.DEFINE_GUI_ITEM,
                                       parentReferenceId,
                                       extraReferenceId,
                                       conditions=conditions)
Example #30
0
 def __readDefaultLine(self, shared, xmlCtx, section):
     defSec = _xml.getSubsection(xmlCtx, section, 'default-line')
     xPath = '{0:>s}/default-line'.format(TREE_SHARED_REL_FILE_PATH)
     xmlCtx = (None, xPath)
     name = _xml.readString(xmlCtx, defSec, 'line')
     outPin = _xml.readString(xmlCtx, defSec, 'outPin')
     inPin = _xml.readString(xmlCtx, defSec, 'inPin')
     self.__getLineInfo(xmlCtx, name, 0, outPin, inPin, shared['lines'])
     shared['default'] = {'line': name, 'inPin': inPin, 'outPin': outPin}
 def readLevelsFactor(xmlCtx, factorSection):
     attrName = _xml.readString(xmlCtx, factorSection, 'attribute')
     opTypeName = _xml.readString(xmlCtx, factorSection, 'type')
     if opTypeName not in AttrsOperation.ALL:
         raise SoftException(
             'Unknown opTypeName ({}) for LevelsFactor'.format(opTypeName))
     values = LevelsFactor._readFactorValues(xmlCtx, factorSection,
                                             'valueByLevel')
     return (attrName, LevelsFactor(values, opTypeName))
Example #32
0
 def parse(self, filePath):
     descriptor = DescriptorData()
     section = ResMgr.openSection(filePath)
     if section is None:
         _xml.raiseWrongXml(None, filePath, 'can not open or read')
     xmlCtx = (None, filePath)
     descriptor.setGuiFilePath(_xml.readString(xmlCtx, section, 'gui'))
     descriptor.setInitialChapterID(_xml.readString(xmlCtx, section, 'initial-chapter'))
     self.__parseChapterSummaries(xmlCtx, section, descriptor)
     return descriptor
Example #33
0
def _readMarkerSection(xmlCtx, section, _):
    markerID = sub_parsers.parseID(xmlCtx, section, 'Specify a marker ID')
    type = _xml.readString(xmlCtx, section, 'type')
    marker = None
    if type in _MARKER_TYPES:
        parser = _MARKER_TYPES[type]
        marker = parser(xmlCtx, section, markerID, _xml.readString(xmlCtx, section, 'var-ref'))
    else:
        LOG_ERROR('Marker is not supported:', type)
    return marker
Example #34
0
 def parse(self, filePath):
     descriptor = DescriptorData()
     section = ResMgr.openSection(filePath)
     if section is None:
         _xml.raiseWrongXml(None, filePath, 'can not open or read')
     xmlCtx = (None, filePath)
     descriptor.setGuiFilePath(_xml.readString(xmlCtx, section, 'gui'))
     descriptor.setInitialChapterID(_xml.readString(xmlCtx, section, 'initial-chapter'))
     self.__parseChapterSummaries(xmlCtx, section, descriptor)
     return descriptor
Example #35
0
def _readHintSection(xmlCtx, section, _):
    hintID = sub_parsers._parseID(xmlCtx, section, 'Specify a hint ID')
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    image = None
    if 'image' in section.keys():
        image = _xml.readString(xmlCtx, section, 'image')
    speakID = None
    if 'speak' in section.keys():
        speakID = _xml.readString(xmlCtx, section, 'speak')
    return chapter.SimpleHint(hintID, text, image=image, speakID=speakID)
Example #36
0
def _readHintSection(xmlCtx, section, _):
    hintID = sub_parsers._parseID(xmlCtx, section, 'Specify a hint ID')
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    image = None
    if 'image' in section.keys():
        image = _xml.readString(xmlCtx, section, 'image')
    speakID = None
    if 'speak' in section.keys():
        speakID = _xml.readString(xmlCtx, section, 'speak')
    return chapter.SimpleHint(hintID, text, image=image, speakID=speakID)
Example #37
0
def _readMarkerSection(xmlCtx, section, _):
    markerID = sub_parsers.parseID(xmlCtx, section, 'Specify a marker ID')
    type = _xml.readString(xmlCtx, section, 'type')
    marker = None
    if type in _MARKER_TYPES:
        parser = _MARKER_TYPES[type]
        marker = parser(xmlCtx, section, markerID, _xml.readString(xmlCtx, section, 'var-ref'))
    else:
        LOG_ERROR('Marker is not supported:', type)
    return marker
Example #38
0
def _readStateComponent(xmlCtx, section):
    destructible = _xml.readBool(xmlCtx, section, 'destructible')
    physicsModel = _xml.readString(xmlCtx, section, 'physics_model')
    component = DestructibleEntityStateComponent(destructible, physicsModel)
    if IS_CLIENT:
        visualModel = _xml.readString(xmlCtx, section, 'visual_model')
        guiNodeName = section.readString('gui_node', '')
        if guiNodeName == '':
            guiNodeName = None
        component.setClientProperties(guiNodeName, visualModel)
    return (_xml.readString(xmlCtx, section, 'id'), component)
Example #39
0
def _readTankmanLevelTriggerSection(xmlCtx, section, _, triggerID):
    role = _xml.readString(xmlCtx, section, 'role')
    roleLevel = _xml.readInt(xmlCtx, section, 'role-level')
    inVehicleFlagID = _xml.readString(xmlCtx, section, 'in-vehicle')
    specVehicleFlagID = section.readString('spec-vehicle')
    if not len(specVehicleFlagID):
        specVehicleFlagID = None
    setVarID = section.readString('set-var')
    if not len(setVarID):
        setVarID = None
    return triggers.TankmanLevelTrigger(triggerID, role, roleLevel, setVarID, inVehicleFlagID, specVehicleFlagID)
Example #40
0
 def __readDefaultLine(self, shared, xmlCtx, section):
     defSec = _xml.getSubsection(xmlCtx, section, 'default-line')
     xPath = '{0:>s}/default-line'.format(TREE_SHARED_REL_FILE_PATH)
     xmlCtx = (None, xPath)
     name = _xml.readString(xmlCtx, defSec, 'line')
     outPin = _xml.readString(xmlCtx, defSec, 'outPin')
     inPin = _xml.readString(xmlCtx, defSec, 'inPin')
     self.__getLineInfo(xmlCtx, name, 0, outPin, inPin, shared['lines'])
     shared['default'] = {'line': name,
      'inPin': inPin,
      'outPin': outPin}
Example #41
0
def readQuestAwardWindowSection(xmlCtx, section, _, windowID, windowType, content):
    bSec = _xml.getSubsection(xmlCtx, section, 'buttons')
    content['nextID'] = _xml.readString(xmlCtx, bSec, 'next')
    content['closeID'] = _xml.readString(xmlCtx, bSec, 'close')
    content['description'] = translation(section.readString('description'))
    content['header'] = translation(section.readString('header'))
    content['bgImage'] = section.readString('image')
    varRef = None
    if 'var-ref' in section.keys():
        varRef = _xml.readString(xmlCtx, section, 'var-ref')
    return chapter.PopUp(windowID, windowType, content, varRef, forcedQuery=True)
Example #42
0
def _readTankmanLevelTriggerSection(xmlCtx, section, _, triggerID):
    role = _xml.readString(xmlCtx, section, 'role')
    roleLevel = _xml.readInt(xmlCtx, section, 'role-level')
    inVehicleFlagID = _xml.readString(xmlCtx, section, 'in-vehicle')
    specVehicleFlagID = section.readString('spec-vehicle')
    if not len(specVehicleFlagID):
        specVehicleFlagID = None
    setVarID = section.readString('set-var')
    if not len(setVarID):
        setVarID = None
    return triggers.TankmanLevelTrigger(triggerID, role, roleLevel, setVarID,
                                        inVehicleFlagID, specVehicleFlagID)
Example #43
0
    def __readCommandsSection(self, xmlCtx, section):
        self.__commands.clear()
        for _, subSection in _xml.getChildren(xmlCtx, section, 'gui-commands'):
            commandID = sub_parsers._parseID(xmlCtx, subSection, 'Specify a command ID')
            cmdType = _xml.readString(xmlCtx, subSection, 'type')
            command = _xml.readString(xmlCtx, subSection, 'name')
            argsSec = _xml.getChildren(xmlCtx, subSection, 'args')
            args = []
            for name, argSec in argsSec:
                args.append(sub_parsers._readVarValue(name, argSec))

            self.__commands[commandID] = CommandData(cmdType, command, args)
Example #44
0
def _readVarCondition(xmlCtx, section, _):
    varID = parseID(xmlCtx, section, 'Specify a var ID')
    tags = section.keys()
    if 'is-none' in tags:
        return conditions.VarDefinedCondition(varID, ~_COND_STATE.ACTIVE)
    if 'is-not-none' in tags:
        return conditions.VarDefinedCondition(varID, _COND_STATE.ACTIVE)
    if 'equals' in tags:
        return conditions.VarCompareCondition(varID, _xml.readString(xmlCtx, section, 'equals'), _COND_STATE.EQUALS)
    if 'not-equals' in tags:
        return conditions.VarCompareCondition(varID, _xml.readString(xmlCtx, section, 'not-equals'), ~_COND_STATE.EQUALS)
    _xml.raiseWrongXml(xmlCtx, 'var', 'State of var condition is not found')
Example #45
0
def _readVarCondition(xmlCtx, section, _):
    varID = parseID(xmlCtx, section, 'Specify a var ID')
    tags = section.keys()
    if 'is-none' in tags:
        return conditions.VarDefinedCondition(varID, ~_COND_STATE.ACTIVE)
    if 'is-not-none' in tags:
        return conditions.VarDefinedCondition(varID, _COND_STATE.ACTIVE)
    if 'equals' in tags:
        return conditions.VarCompareCondition(varID, _xml.readString(xmlCtx, section, 'equals'), _COND_STATE.EQUALS)
    if 'not-equals' in tags:
        return conditions.VarCompareCondition(varID, _xml.readString(xmlCtx, section, 'not-equals'), ~_COND_STATE.EQUALS)
    _xml.raiseWrongXml(xmlCtx, 'var', 'State of var condition is not found')
Example #46
0
def _parseHint(xmlCtx, section, _):
    hintID = sub_parsers._parseID(xmlCtx, section, 'Specify a hint ID')
    targetID = _xml.readString(xmlCtx, section, 'gui-item-ref')
    containerID = section.readString('container-ref')
    if not len(containerID):
        containerID = None
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    inPin = _xml.readString(xmlCtx, section, 'inPin')
    outPin = _xml.readString(xmlCtx, section, 'outPin')
    line = _xml.readString(xmlCtx, section, 'line')
    position = section.readVector2('position')
    topmostLevel = section.readBool('topmost-level', True)
    return chapter.ItemHint(hintID, targetID, containerID, position, text, inPin, outPin, line, topmostLevel)
Example #47
0
def _readHintSection(xmlCtx, section, _):
    hintID = sub_parsers.parseID(xmlCtx, section, 'Specify a hint ID')
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    if 'image' in section.keys():
        image = chapter.SimpleImagePath(None, _xml.readString(xmlCtx, section, 'image'))
    elif 'image-ref' in section.keys():
        image = _xml.readString(xmlCtx, section, 'image-ref')
    else:
        image = chapter.SimpleImagePath()
    speakID = None
    if 'wwspeak' in section.keys():
        speakID = _xml.readString(xmlCtx, section, 'wwspeak')
    return chapter.SimpleHint(hintID, text, image, speakID=speakID)
Example #48
0
def _parseWindow(xmlCtx, section, flags):
    windowID = parseID(xmlCtx, section, 'Specify a window ID')
    windowType = _xml.readString(xmlCtx, section, 'type')
    bSec = _xml.getSubsection(xmlCtx, section, 'buttons')
    content = {'closeID': _xml.readString(xmlCtx, bSec, 'close')}
    parser = _WINDOW_SUB_PARERS.get(windowType)
    if parser is not None:
        window = parser(xmlCtx, section, flags, windowID, windowType, content)
        window.setActions(parseActions(xmlCtx, _xml.getSubsection(xmlCtx, section, 'actions'), flags))
    else:
        window = None
        LOG_ERROR('Type of window is not supported: ', windowType)
    return window
Example #49
0
def _readQueueDialogSection(xmlCtx, section, _, dialogID, dialogType, content):
    content['avgTimeTextFormat'] = translation(_xml.readString(xmlCtx, section, 'avg-time-text'))
    subSec = _xml.getSubsection(xmlCtx, section, 'player-time-text')
    content['playerTimeTextStart'] = translation(_xml.readString(xmlCtx, subSec, 'start'))
    content['playerTimeTextEnd'] = translation(_xml.readString(xmlCtx, subSec, 'end'))
    pointcuts = []
    for _, subSec in _xml.getChildren(xmlCtx, section, 'time-pointcuts'):
        value = subSec.asFloat
        if value > 0:
            pointcuts.append(subSec.asInt)

    if len(pointcuts) < 2:
        _xml.raiseWrongSection(xmlCtx, 'time-pointcuts: should be the minimum and maximum value')
    content['timePointcuts'] = sorted(pointcuts)
    return chapter.PopUp(dialogID, dialogType, content, _xml.readString(xmlCtx, section, 'var-ref'))
Example #50
0
 def __readSceneAliasesSection(self, xmlCtx, section):
     self.__sceneAliases.clear()
     self.__sceneMethods.clear()
     for tagName, subSection in _xml.getChildren(xmlCtx, section, 'scene-aliases'):
         sceneID = subSection.asString
         self.__sceneAliases[tagName] = sceneID
         self.__sceneMethods[sceneID] = _xml.readString(xmlCtx, subSection, 'go-to')
Example #51
0
 def __readGuiItemsSection(self, xmlCtx, section):
     self.__guiItems.clear()
     for _, subSection in _xml.getChildren(xmlCtx, section, 'gui-items'):
         itemID = sub_parsers._parseID(xmlCtx, subSection, 'Specify a GUI item ID')
         path = _xml.readString(xmlCtx, subSection, 'path')
         self.__guiItems[itemID] = {'path': path,
          'locked': True}
Example #52
0
def parseTrigger(xmlCtx, section, flags, chapter):
    triggerID = parseID(xmlCtx, section, 'Specify a trigger ID')
    trigger = None
    triggerType = _xml.readString(xmlCtx, section, 'type')
    parser = _TRIGGER_SUB_PARSERS.get(triggerType)
    if parser is not None:
        trigger = parser(xmlCtx, section, chapter, triggerID)
        if 'on-effects' in section.keys():
            for _, effectSec in _xml.getChildren(xmlCtx, section, 'on-effects'):
                effect = _parseEffect(xmlCtx, effectSec, flags)
                if effect is not None:
                    trigger.addOnEffect(effect)

        if 'off-effects' in section.keys():
            for _, effectSec in _xml.getChildren(xmlCtx, section, 'off-effects'):
                effect = _parseEffect(xmlCtx, effectSec, flags)
                if effect is not None:
                    trigger.addOffEffect(effect)

        if 'exclude-triggers' in section.keys():
            for _, triggerSec in _xml.getChildren(xmlCtx, section, 'exclude-triggers'):
                trigger.addExcludeTriggerID(triggerSec.asString)

    else:
        LOG_ERROR('Trigger is not supported:', triggerType)
    return trigger
Example #53
0
    def __readSharedMetrics(self, shared, xmlCtx, section):
        precessed = _xml.getChildren(xmlCtx, section, 'grids')
        for name, gridSection in precessed:
            gridName = gridSection.asString
            xPath = '{0:>s}/{1:>s}/{2:>s}'.format(TREE_SHARED_REL_FILE_PATH, name, gridName)
            gridCtx = (None, xPath)
            subSec = _xml.getSubsection(xmlCtx, gridSection, 'root')
            xmlCtx = (None, '{0:>s}/root'.format(xPath))
            rootPos = {'start': _xml.readVector2(xmlCtx, subSec, 'start').tuple(),
             'step': _xml.readInt(xmlCtx, subSec, 'step')}
            subSec = _xml.getSubsection(gridCtx, gridSection, 'vertical')
            xmlCtx = (None, '{0:>s}/vertical'.format(xPath))
            vertical = (_xml.readInt(xmlCtx, subSec, 'start'), _xml.readInt(xmlCtx, subSec, 'step'))
            subSec = _xml.getSubsection(gridCtx, gridSection, 'horizontal')
            xmlCtx = (None, '{0:>s}/horizontal'.format(xPath))
            horizontal = (_xml.readInt(xmlCtx, subSec, 'start'), _xml.readInt(xmlCtx, subSec, 'step'))
            shared['grids'][gridName] = {'root': rootPos,
             'vertical': vertical,
             'horizontal': horizontal}

        precessed = _xml.getChildren(xmlCtx, section, 'lines')
        lines = shared['lines']
        for name, sub in precessed:
            xPath = '{0:>s}/{1:>s}'.format(TREE_SHARED_REL_FILE_PATH, name)
            xmlCtx = (None, xPath)
            pinsSec = _xml.getChildren(xmlCtx, sub, 'inPin')
            inPins = dict(((pName, pSec.asVector2.tuple()) for pName, pSec in pinsSec))
            pinsSec = _xml.getChildren(xmlCtx, sub, 'outPin')
            outPins = dict(((pName, pSec.asVector2.tuple()) for pName, pSec in pinsSec))
            pinsSec = _xml.getChildren(xmlCtx, sub, 'viaPin')
            viaPins = defaultdict(dict)
            for outPin, setSec in pinsSec:
                for inPin, pSec in setSec.items():
                    viaPins[outPin][inPin] = map(lambda section: section[1].asVector2.tuple(), pSec.items())

            defSec = sub['default']
            default = {}
            if defSec is not None:
                xmlCtx = (None, '{0:>s}/default'.format(xPath))
                default = {'outPin': _xml.readString(xmlCtx, defSec, 'outPin'),
                 'inPin': _xml.readString(xmlCtx, defSec, 'inPin')}
            lines[name] = {'inPins': inPins,
             'outPins': outPins,
             'viaPins': viaPins,
             'default': default}

        return
Example #54
0
    def parse(self, chapter, afterBattle = False, initial = False):
        filePath = chapter.getFilePath(afterBattle=afterBattle)
        section = ResMgr.openSection(filePath)
        if section is None:
            _xml.raiseWrongXml(None, filePath, 'can not open or read')
        xmlCtx = (None, filePath)
        chapter.clear()
        flags = []
        itemFlags = []
        if 'initial-scene' in section.keys():
            chapter.setInitialSceneID(_xml.readString(xmlCtx, section, 'initial-scene'))
        if 'default-scene' in section.keys():
            chapter.setDefaultSceneID(_xml.readString(xmlCtx, section, 'default-scene'))
        for name, subSec in _xml.getChildren(xmlCtx, section, 'has-id'):
            entity = sub_parsers._parseEntity(xmlCtx, name, subSec, flags)
            if entity is not None:
                chapter.addHasIDEntity(entity)

        for _, subSec in _xml.getChildren(xmlCtx, section, 'triggers'):
            trigger = sub_parsers._parseTrigger(xmlCtx, subSec, flags, chapter)
            if trigger is not None:
                chapter.addTrigger(trigger)

        gVarIDs = []
        for name, subSec in _xml.getChildren(xmlCtx, section, 'vars'):
            if name == 'var-set':
                chapter.addVarSet(sub_parsers._parseVarSet(xmlCtx, subSec, flags))
            elif name == 'var-set-ref':
                gVarIDs.append(sub_parsers._parseID(xmlCtx, subSec, 'Specify a var ID'))
            else:
                _xml.raiseWrongXml(xmlCtx, name, 'Unknown tag')

        if len(gVarIDs):
            GlobalRefParser().parse(chapter, varIDs=gVarIDs, flags=flags)
        for _, sceneSec in _xml.getChildren(xmlCtx, section, 'scenes'):
            sceneID = sub_parsers._parseID(xmlCtx, sceneSec, 'Specify a unique name for the scene')
            scene = Scene(entityID=sceneID)
            self.__parseScene(xmlCtx, sceneSec, scene, flags, itemFlags, afterBattle=afterBattle)
            chapter.addScene(scene)

        if initial:
            scene = chapter.getInitialScene()
            self.__parseSharedScene(chapter, scene, flags, itemFlags)
        flags = filter(lambda flag: flag not in itemFlags, flags)
        chapter.setFlags(flags)
        chapter.setValid(True)
        return chapter
Example #55
0
def _readGuiItemCriteria(xmlCtx, section, _):
    criteriaID = parseID(xmlCtx, section, 'Specify a criteria ID')
    itemID = None
    if 'item-id' in section.keys():
        itemID = parseID(xmlCtx, section['item-id'], 'Specify a item ID')
    else:
        _xml.raiseWrongXml(xmlCtx, section.name, 'Specify a item ID')
    return chapter.GuiItemCriteria(criteriaID, itemID, _xml.readString(xmlCtx, section, 'value'), _xml.readBool(xmlCtx, section, 'cached'))
Example #56
0
 def __parseChapterSummaries(self, xmlCtx, section, descriptor):
     for _, subSection in _xml.getChildren(xmlCtx, section, 'chapters'):
         chapterID = _xml.readString(xmlCtx, subSection, 'chapter-id')
         title = translation(_xml.readString(xmlCtx, subSection, 'title'))
         descSec = _xml.getSubsection(xmlCtx, subSection, 'description')
         defDesc = translation(descSec.asString)
         abDesc = translation(descSec.readString('after-battle', defDesc))
         descriptions = (defDesc, abDesc)
         bonusSec = _xml.getSubsection(xmlCtx, subSection, 'bonus')
         bonus = Bonus(bonusSec.readInt('id', -1), bonusSec.readString('message'), sub_parsers._readBonusValues(bonusSec))
         forcedLoading = subSection.readInt('forced-loading', -1)
         pathSec = _xml.getSubsection(xmlCtx, subSection, 'file-path')
         defFilePath = pathSec.asString
         afterBattleFilePath = pathSec.readString('after-battle', defFilePath)
         filePaths = (defFilePath, afterBattleFilePath)
         sharedScene = subSection.readString('shared-scene')
         descriptor.addChapter(Chapter(chapterID, title, descriptions, bonus, forcedLoading, filePaths, sharedScene))
Example #57
0
def _readTags(xmlCtx, section, subsectionName):
    tagNames = _xml.readString(xmlCtx, section, subsectionName).split()
    res = set()
    for tagName in tagNames:
        if tagName not in _ALLOWED_TAG_NAMES:
            _xml.raiseWrongXml(xmlCtx, subsectionName, "unknown tag '%s'" % tagName)
        res.add(intern(tagName))

    return frozenset(res)
Example #58
0
def _readDynamicGuiItemSection(xmlCtx, section, itemFlags, itemID, props, conditions):
    item = chapter.DynamicGuiItemRef(itemID, props, conditions=conditions)
    if 'find-criteria' in section.keys():
        subSec = _xml.getSubsection(xmlCtx, section, 'find-criteria')
        parentID = _xml.readString(xmlCtx, subSec, 'parent-ref')
        varPath = _xml.readString(xmlCtx, subSec, 'var-path')
        varRef = _xml.readString(xmlCtx, subSec, 'var-ref')
        item.setFindCriteria([parentID, varPath, varRef])
    for _, effectSec in _xml.getChildren(xmlCtx, section, 'not-on-scene-effects'):
        effect = _parseEffect(xmlCtx, effectSec, itemFlags)
        if effect is not None:
            item.addNotOnSceneEffect(effect)

    for _, effectSec in _xml.getChildren(xmlCtx, section, 'on-scene-effects'):
        effect = _parseEffect(xmlCtx, effectSec, itemFlags)
        if effect is not None:
            item.addOnSceneEffect(effect)

    return item
Example #59
0
def _readImageSection(xmlCtx, section, _):
    imageID = sub_parsers.parseID(xmlCtx, section, 'Specify a image ID')
    imageType = _xml.readString(xmlCtx, section, 'type')
    image = None
    if imageType in _IMAGE_TYPES:
        parser = _IMAGE_TYPES[imageType]
        image = parser(xmlCtx, section, imageID)
    else:
        LOG_ERROR('Image is not supported:', imageType)
    return image