예제 #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)
예제 #2
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', '')
    customID = bSec.readString('custom', '')
    content = {
        'type':
        dialogType,
        'dialogID':
        dialogID,
        'submitID':
        submitID,
        'cancelID':
        cancelID,
        'customID':
        customID,
        'title':
        translation(_xml.readStringOrNone(xmlCtx, section, 'title') or ''),
        'message':
        translation(_xml.readStringOrNone(xmlCtx, section, 'text') or ''),
        'imageUrl':
        _xml.readStringOrNone(xmlCtx, section, 'image') or ''
    }
    parser = _DIALOG_SUB_PARERS.get(dialogType)
    if parser is not None:
        dialog = parser(xmlCtx, section, flags, dialogID, dialogType, content)
    else:
        dialog = tutorial_chapter.PopUp(dialogID, dialogType, content)
    dialog.setActions(
        parseActions(xmlCtx, _xml.getSubsection(xmlCtx, section, 'actions'),
                     flags))
    return dialog
예제 #3
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
예제 #4
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)
def __readChapters(ctx, root, filterFunction):
    ctx, section = resource_helper.getSubSection(ctx, root, 'chapters')
    chapters = []
    index = 0
    for chapterCtx, chapterSection in resource_helper.getIterator(ctx, section):
        filePath = __getCustomSectionValue(chapterCtx, chapterSection, 'file-path')
        title = __getCustomSectionValue(chapterCtx, chapterSection, 'title')
        background = __getCustomSectionValue(chapterCtx, chapterSection, 'background')
        attributes = __getChapterAttributes(filePath, filterFunction)
        ids = attributes.get('ids', [])
        if len(ids) != len(set(ids)):
            _logger.warning('chapter %s has duplicate page ids', title)
        chapter = {'filePath': filePath,
         'pageIDs': ids,
         'newPageIDs': attributes.get('newIds', []),
         'uiData': {'index': int(index),
                    'label': translation(title),
                    'image': background,
                    'tooltip': makeTooltip(translation(title), '\n'.join(attributes.get('chaptersTitles', [])))}}
        if any((ids in chapter['pageIDs'] for chapter in chapters)):
            _logger.warning('chapter %s has duplicate page ids from another chapters', title)
        _logger.debug('ManualXMLDataReader: Read chapters. Chapter: %s', chapter)
        chapters.append(chapter)
        index += 1

    return chapters
예제 #6
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'))
예제 #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)
예제 #8
0
def readQuestAwardWindowSection(xmlCtx, section, _, windowID, windowType, content):
    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)
예제 #9
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)
예제 #10
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)
예제 #11
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
예제 #12
0
def readQuestAwardWindowSection(xmlCtx, section, _, windowID, windowType, content):
    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 tutorial_chapter.PopUp(windowID, windowType, content, varRef, forcedQuery=True)
예제 #13
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)
def __readChapter(ctx, root, isBootcampEnabled, bootcampRunCount):
    pages = []
    details = []
    index = 0
    ctx, section = resource_helper.getSubSection(ctx, root, 'lessons')
    for lessonCtx, lessonSection in resource_helper.getIterator(ctx, section):
        template = __getCustomSectionValue(lessonCtx, lessonSection,
                                           'template')
        title = translation(
            __getCustomSectionValue(lessonCtx, lessonSection, 'title'))
        background = __getCustomSectionValue(lessonCtx, lessonSection,
                                             'background')
        description = __getCustomSectionValue(lessonCtx,
                                              lessonSection,
                                              'description',
                                              safe=True)
        if description is None:
            description = ''
        else:
            description = translation(description)
        contentRendererLinkage = ''
        if template is _BOOTCAMP_PAGE:
            if not isBootcampEnabled:
                continue
            contentRendererData = __getBootcampRendererData(bootcampRunCount)
            contentRendererLinkage = _MANUAL_LESSON_TEMPLATES.get(template)
        else:
            contentRendererData, hintsCount = __getHintsRendererData(
                lessonCtx, lessonSection)
            if hintsCount > 0:
                contentRendererLinkage = _MANUAL_LESSON_TEMPLATES.get(template)
        pages.append({
            'buttonsGroup': 'ManualChapterGroup',
            'pageIndex': int(index),
            'selected': False,
            'label': str(int(index) + 1),
            'tooltip': {
                'tooltip': makeTooltip(title)
            }
        })
        details.append({
            'title': title,
            'description': description,
            'background': background,
            'contentRendererLinkage': contentRendererLinkage,
            'contentRendererData': contentRendererData
        })
        index += 1

    chapterData = {'pages': pages, 'details': details}
    _logger.debug('ManualXMLDataReader:  Read chapter: %s', chapterData)
    return chapterData
def __readChapter(ctx, root, filterFunction, bootcampRunCount, chapterTitle=''):
    pages = []
    details = []
    index = 0
    ctx, section = resource_helper.getSubSection(ctx, root, 'lessons')
    for lessonCtx, lessonSection in resource_helper.getIterator(ctx, section):
        template = __getCustomSectionValue(lessonCtx, lessonSection, 'template')
        if not filterFunction(template):
            continue
        title = translation(__getCustomSectionValue(lessonCtx, lessonSection, 'title'))
        background = __getCustomSectionValue(lessonCtx, lessonSection, 'background')
        description = __getCustomSectionValue(lessonCtx, lessonSection, 'description', safe=True)
        pageId = __getCustomSectionValue(lessonCtx, lessonSection, 'id')
        if description is None:
            description = ''
        else:
            description = translation(description)
        contentRendererLinkage = ''
        if template == ManualPageTypes.MAPS_TRAINING_PAGE:
            contentRendererData = {'text': backport.text(R.strings.maps_training.manualPage.button())}
            contentRendererLinkage = _MANUAL_LESSON_TEMPLATES.get(template)
        elif template == ManualPageTypes.BOOTCAMP_PAGE:
            contentRendererData = __getBootcampRendererData(bootcampRunCount)
            contentRendererLinkage = _MANUAL_LESSON_TEMPLATES.get(template)
        elif template == ManualPageTypes.VIDEO_PAGE:
            contentRendererData = __getVideoRendererData(lessonCtx, lessonSection)
            contentRendererLinkage = _MANUAL_LESSON_TEMPLATES.get(template)
        else:
            contentRendererData, hintsCount = __getHintsRendererData(lessonCtx, lessonSection)
            if hintsCount > 0:
                contentRendererLinkage = _MANUAL_LESSON_TEMPLATES.get(template)
        pages.append({'buttonsGroup': 'ManualChapterGroup',
         'pageIndex': int(index),
         'selected': False,
         'hasNewContent': __isNew(lessonCtx, lessonSection),
         'label': str(int(index) + 1),
         'tooltip': {'tooltip': makeTooltip(title)}})
        details.append({'title': title,
         'chapterTitle': chapterTitle,
         'description': description,
         'background': background,
         'contentRendererLinkage': contentRendererLinkage,
         'contentRendererData': contentRendererData,
         'id': pageId,
         'pageType': template})
        index += 1

    chapterData = {'pages': pages,
     'details': details}
    _logger.debug('ManualXMLDataReader:  Read chapter: %s', chapterData)
    return chapterData
예제 #16
0
    def _make(self, source):
        keys = source.keys()
        ctx = None
        srcDict = {}
        if len(keys) > 0:
            for key in keys:
                if 'context' == key:
                    ctx = dict(map(lambda item: (item[0], item[1].asString), source['context'].items()))
                else:
                    srcDict[key] = html.translation(source.readString(key))

        else:
            srcDict['text'] = html.translation(source.asString)
        return Template(srcDict, ctx)
예제 #17
0
    def _make(self, source):
        keys = source.keys()
        ctx = None
        srcDict = {}
        if keys:
            for key in keys:
                if key == 'context':
                    ctx = dict(((item[0], item[1].asString)
                                for item in source['context'].items()))
                srcDict[key] = html.translation(source.readString(key))

        else:
            srcDict['text'] = html.translation(source.asString)
        return Template(srcDict, ctx)
예제 #18
0
    def _make(self, source):
        keys = source.keys()
        ctx = None
        srcDict = {}
        if len(keys) > 0:
            for key in keys:
                if 'context' == key:
                    ctx = dict(map(lambda item: (item[0], item[1].asString), source['context'].items()))
                else:
                    srcDict[key] = html.translation(source.readString(key))

        else:
            srcDict['text'] = html.translation(source.asString)
        return Template(srcDict, ctx)
예제 #19
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'))
예제 #20
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'))
예제 #21
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)
예제 #22
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
예제 #23
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
예제 #24
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
예제 #25
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)
예제 #26
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)
예제 #27
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)
예제 #28
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)
예제 #29
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
예제 #30
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
예제 #31
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))
예제 #32
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)
예제 #33
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)
예제 #34
0
def __readChapters(ctx, root, isBootcampEnabled):
    ctx, section = resource_helper.getSubSection(ctx, root, 'chapters')
    chapters = []
    index = 0
    for chapterCtx, chapterSection in resource_helper.getIterator(ctx, section):
        filePath = __getCustomSectionValue(chapterCtx, chapterSection, 'file-path')
        title = __getCustomSectionValue(chapterCtx, chapterSection, 'title')
        background = __getCustomSectionValue(chapterCtx, chapterSection, 'background')
        lessonsTitlesList = __getChaptersTitlesList(filePath, isBootcampEnabled)
        chapter = {'filePath': filePath,
         'uiData': {'index': int(index),
                    'label': translation(title),
                    'image': background,
                    'tooltip': makeTooltip(translation(title), '\n'.join(lessonsTitlesList))}}
        _logger.debug('ManualXMLDataReader: Read chapters. Chapter: %s', chapter)
        chapters.append(chapter)
        index += 1

    return chapters
예제 #35
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'))
예제 #36
0
def _readMessages(ctx, root):
    ctx, section = resource_helper.getSubSection(ctx, root, 'messages')
    messages = {}
    for xmlCtx, subSection in resource_helper.getIterator(ctx, section):
        item = resource_helper.readItem(xmlCtx, subSection, 'message')
        text, aliases = item.value
        aliases = aliases.split(',', 1)
        if len(aliases) == 1:
            aliases *= 2
        messages[item.name] = (html.translation(text), tuple(aliases))

    return messages
예제 #37
0
def _readMessages(ctx, root):
    ctx, section = resource_helper.getSubSection(ctx, root, 'messages')
    messages = {}
    for ctx, subSection in resource_helper.getIterator(ctx, section):
        item = resource_helper.readItem(ctx, subSection, 'message')
        text, aliases = item.value
        aliases = aliases.split(',', 1)
        if len(aliases) == 1:
            aliases *= 2
        messages[item.name] = (html.translation(text), tuple(aliases))

    return messages
예제 #38
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)
예제 #39
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)
예제 #40
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)
예제 #41
0
def __getChaptersTitlesList(chapterFileName, isBootcampEnabled):
    chaptersTitles = []
    chapterPath = _CHAPTERS_DATA_PATH + chapterFileName
    with resource_helper.root_generator(chapterPath) as ctx, root:
        ctx, section = resource_helper.getSubSection(ctx, root, 'lessons')
        for lessonCtx, lessonSection in resource_helper.getIterator(ctx, section):
            title = translation(__getCustomSectionValue(lessonCtx, lessonSection, 'title'))
            template = __getCustomSectionValue(lessonCtx, lessonSection, 'template')
            if template is _BOOTCAMP_PAGE and not isBootcampEnabled:
                continue
            chaptersTitles.append(title)

    return chaptersTitles
예제 #42
0
def __getHintsRendererData(lessonCtx, lessonSection):
    hints = []
    contentRendererData = None
    hintsCtx, hintsSection = resource_helper.getSubSection(lessonCtx, lessonSection, 'hints', safe=True)
    if hintsSection is not None:
        for hintCtx, hintSection in resource_helper.getIterator(hintsCtx, hintsSection):
            hintText = translation(__getCustomSectionValue(hintCtx, hintSection, 'text'))
            hintIcon = __getCustomSectionValue(hintCtx, hintSection, 'icon')
            hints.append({'text': hintText,
             'icon': hintIcon})

        contentRendererData = {'hints': hints}
    return (contentRendererData, len(hints))
예제 #43
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
예제 #44
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)
def __getChapterAttributes(chapterFileName, filterFunction):
    chaptersTitles = []
    ids = []
    newIds = []
    chapterPath = _CHAPTERS_DATA_PATH + chapterFileName
    with resource_helper.root_generator(chapterPath) as ctx, root:
        ctx, section = resource_helper.getSubSection(ctx, root, 'lessons')
        for lessonCtx, lessonSection in resource_helper.getIterator(ctx, section):
            template = __getCustomSectionValue(lessonCtx, lessonSection, 'template')
            if not filterFunction(template):
                continue
            lessonId = int(__getCustomSectionValue(lessonCtx, lessonSection, 'id'))
            ids.append(lessonId)
            if __getCustomSectionValue(lessonCtx, lessonSection, 'new', safe=True):
                newIds.append(lessonId)
            chaptersTitles.append(translation(__getCustomSectionValue(lessonCtx, lessonSection, 'title')))

    return {'ids': ids,
     'newIds': newIds,
     'chaptersTitles': chaptersTitles}
예제 #46
0
def _parseMessage(xmlCtx, section, _):
    messageID = parseID(xmlCtx, section, 'Specify a message ID')
    guiType = _xml.readString(xmlCtx, section, 'type')
    text = translation(_xml.readString(xmlCtx, section, 'text'))
    return chapter.Message(messageID, guiType, text)
예제 #47
0
def _readNoResultsWindowSection(xmlCtx, section, _, windowID, windowType, content):
    content['text'] = translation(_xml.readString(xmlCtx, section, 'text'))
    return chapter.PopUp(windowID, windowType, content)
예제 #48
0
파일: lobby.py 프로젝트: webiumsk/WOT0.10.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
예제 #49
0
def _readConfirmRefuseDialogSection(xmlCtx, section, _, dialogID, dialogType, content):
    content['checkBoxLabel'] = translation(_xml.readString(xmlCtx, section, 'checkbox-label'))
    return chapter.PopUp(dialogID, dialogType, content)
예제 #50
0
파일: lobby.py 프로젝트: webiumsk/WOT0.10.0
def _readSubQuestDialogSection(xmlCtx, section, _, dialogID, type, content):
    content['questText'] = translation(_xml.readString(xmlCtx, section, 'quest'))
    return chapter.PopUp(dialogID, type, content)
예제 #51
0
파일: lobby.py 프로젝트: webiumsk/WOT0.10.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)
예제 #52
0
파일: lobby.py 프로젝트: webiumsk/WOT0.10.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)
예제 #53
0
def _readAsStringSection(name, section):
    return translation(getattr(section, name))
def _readSubQuestDialogSection(xmlCtx, section, _, dialogID, dialogType, content):
    content['questText'] = translation(_xml.readString(xmlCtx, section, 'quest'))
    return tutorial_chapter.PopUp(dialogID, dialogType, content)
예제 #55
0
def _readGreetingDialogSection(xmlCtx, section, _, dialogID, dialogType, content):
    content['timeNoteValue'] = translation(_xml.readString(xmlCtx, section, 'time-note'))
    return chapter.PopUp(dialogID, dialogType, content, None, forcedQuery=True)