/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step Data</param> /// <param name="npc">Npc to which the dialog belongs</param> /// <returns>Dialog Step Render Result</returns> public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, KortistoNpc npc) { ConditionNode conditionNode = data.Condition; if (conditionNode == null) { return(null); } ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleCondition); ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult(); renderResult.StepCode = ReplaceNodeId(template.Code, data); renderResult.StepCode = ExportUtil.BuildRangePlaceholderRegex(Placeholder_ConditionsStart, Placeholder_ConditionsEnd).Replace(renderResult.StepCode, m => { return(ExportUtil.TrimEmptyLines(ExportUtil.IndentListTemplate(BuildConditions(m.Groups[1].Value, data, conditionNode, npc, false), m.Groups[2].Value))); }); renderResult.StepCode = ExportUtil.BuildRangePlaceholderRegex(Placeholder_AllConditionsStart, Placeholder_AllConditionsEnd).Replace(renderResult.StepCode, m => { return(ExportUtil.TrimEmptyLines(ExportUtil.IndentListTemplate(BuildConditions(m.Groups[1].Value, data, conditionNode, npc, true), m.Groups[2].Value))); }); renderResult.StepCode = ExportUtil.BuildRangePlaceholderRegex(Placeholder_ElseStart, Placeholder_ElseEnd).Replace(renderResult.StepCode, m => { return(ExportUtil.IndentListTemplate(BuildElsePart(m.Groups[1].Value, data), m.Groups[2].Value)); }); return(renderResult); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step Data</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <returns>Dialog Step Render Result</returns> public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, FlexFieldObject flexFieldObject) { KortistoNpc npc = flexFieldObject as KortistoNpc; if (npc == null) { return(null); } TextNode textNode = GetValidTextNode(data); if (textNode == null) { return(null); } ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, _isPlayerLine?TemplateType.TalePlayerTextLine : TemplateType.TaleNpcTextLine); ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult(); renderResult.StepCode = ReplaceBaseStepPlaceholders(template.Code, data, data.Children.FirstOrDefault() != null ? data.Children.FirstOrDefault().Child : null); renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TextLine).Replace(renderResult.StepCode, ExportUtil.EscapeCharacters(textNode.Text, _exportSettings.EscapeCharacter, _exportSettings.CharactersNeedingEscaping, _exportSettings.NewlineCharacter)); renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TextLine_Preview).Replace(renderResult.StepCode, ExportUtil.BuildTextPreview(textNode.Text)); renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TextLine_LangKey).Replace(renderResult.StepCode, m => { return(_languageKeyGenerator.GetDialogTextLineKey(npc.Id, npc.Name, _isPlayerLine ? ExportConstants.LanguageKeyTypePlayer : ExportConstants.LanguageKeyTypeNpc, textNode.Id, textNode.Text).Result); }); return(renderResult); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step Data</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <returns>Dialog Step Render Result</returns> public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, FlexFieldObject flexFieldObject) { KortistoNpc npc = flexFieldObject as KortistoNpc; if (npc == null) { return(null); } TaleChoiceNode choiceNode = data.Choice; if (choiceNode == null) { return(null); } ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleChoice); ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult(); renderResult.StepCode = ReplaceNodeId(template.Code, data); renderResult.StepCode = ExportUtil.BuildRangePlaceholderRegex(Placeholder_ChoicesStart, Placeholder_ChoicesEnd).Replace(renderResult.StepCode, m => { return(ExportUtil.TrimEmptyLines(ExportUtil.IndentListTemplate(BuildChoices(m.Groups[1].Value, data, choiceNode, npc), m.Groups[2].Value))); }); return(renderResult); }
/// <summary> /// Renders a list of dialog steps /// </summary> /// <param name="functionSteps">Steps to render</param> /// <param name="npc">Npc to which the dialog belongs</param> /// <returns>Renderd code for list of dialog steps</returns> private async Task <string> RenderDialogStepList(List <ExportDialogData> functionSteps, KortistoNpc npc) { string stepListCode = string.Empty; foreach (ExportDialogData curData in functionSteps) { ExportDialogStepRenderResult renderResult = await RenderDialogStep(curData, npc); stepListCode += renderResult.StepCode; } return(stepListCode); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="exportDialog">Cur Data to render</param> /// <param name="npc">Npc to which the dialog belongs</param> /// <returns>Result of the rendering of the step</returns> private async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData exportDialog, KortistoNpc npc) { foreach (IExportDialogStepRenderer curRenderer in _stepRenderers) { ExportDialogStepRenderResult result = await curRenderer.RenderDialogStep(exportDialog, npc); if (result != null) { return(result); } } _errorCollection.AddUnknownDialogStepError(); return(null); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step Data</param> /// <param name="npc">Npc to which the dialog belongs</param> /// <returns>Dialog Step Render Result</returns> public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, KortistoNpc npc) { ActionNode actionNode = data.Action; if (actionNode == null) { return(null); } string actionContent = await BuildActionContent(actionNode, data, npc); ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleAction); ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult(); renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ActionContent).Replace(template.Code, actionContent); renderResult.StepCode = ReplaceBaseStepPlaceholders(renderResult.StepCode, data, data.Children.FirstOrDefault() != null ? data.Children.FirstOrDefault().Child : null); return(renderResult); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step Data</param> /// <param name="flexFieldObject">Flex Field to which the dialog belongs</param> /// <returns>Dialog Step Render Result</returns> public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, FlexFieldObject flexFieldObject) { ActionNode actionNode = data.Action; if (actionNode == null) { return(null); } IActionRenderer actionRenderer = GetActionRenderForNode(actionNode); ExportDialogDataChild nextStep = null; if (data.Children != null) { if (actionRenderer != null) { nextStep = actionRenderer.GetNextStep(data.Children); } else { nextStep = data.Children.FirstOrDefault(); } } string actionContent = await BuildActionContent(actionRenderer, actionNode, data, flexFieldObject); ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleAction); ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult(); renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ActionContent).Replace(template.Code, actionContent); renderResult.StepCode = ReplaceBaseStepPlaceholders(renderResult.StepCode, data, nextStep != null ? nextStep.Child : null); return(renderResult); }