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
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)
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)
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'))
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)
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
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)
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 _readBootcampMessageDialogSection(xmlCtx, section, _, dialogID, dialogType, content): content['sequence'] = [ _readMessageDialogSequenceItem(xmlCtx, messageSec) for _, messageSec in _xml.getChildren(xmlCtx, section, 'sequence') ] return chapter.PopUp(dialogID, dialogType, content, varRef=None, forcedQuery=True)
def _readVideoWindowSection(xmlCtx, section, _, windowID, windowType, content): fields = ('subtitle', 'video-path', 'event-start', 'event-stop', 'event-pause', 'event-resume', 'event-loop') content['sequence'] = [ _readSequenceItem(xmlCtx, messageSec, fields) for _, messageSec in _xml.getChildren(xmlCtx, section, 'sequence') ] return chapter.PopUp(windowID, windowType, content, varRef=None, forcedQuery=True)
def _readSubtitleWindowSection(xmlCtx, section, _, windowID, windowType, content): fields = ('subtitle', 'voiceover') content['sequence'] = [ _readSequenceItem(xmlCtx, messageSec, fields) for _, messageSec in _xml.getChildren(xmlCtx, section, 'sequence') ] return chapter.PopUp(windowID, windowType, content, varRef=None, forcedQuery=True)
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'))
def _readVarRefDialogSection(xmlCtx, section, _, dialogID, dialogType, content): return tutorial_chapter.PopUp(dialogID, dialogType, content, _xml.readString(xmlCtx, section, 'var-ref'))
def _readNoResultsWindowSection(xmlCtx, section, _, windowID, windowType, content): content['text'] = translation(_xml.readString(xmlCtx, section, 'text')) return chapter.PopUp(windowID, windowType, content)
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)
def _readGreetingDialogSection(xmlCtx, section, _, dialogID, dialogType, content): content = _readBonusSection(xmlCtx, section, content) return tutorial_chapter.PopUp(dialogID, dialogType, content)
def _readSubQuestDialogSection(xmlCtx, section, _, dialogID, dialogType, content): content['questText'] = translation(_xml.readString(xmlCtx, section, 'quest')) return tutorial_chapter.PopUp(dialogID, dialogType, content)
def _readConfirmRefuseDialogSection(xmlCtx, section, _, dialogID, dialogType, content): content['checkBoxLabel'] = translation(_xml.readString(xmlCtx, section, 'checkbox-label')) return chapter.PopUp(dialogID, dialogType, content)