/// <summary> /// Constructs a new selection dialog with just an identifier. /// </summary> /// <param name="identifier">The text identifier of the dialog.</param> /// <param name="pages">The list of lines in the dialog.</param> public SelectionDialog( string identifier, SelectionDialogPattern pattern, params TokenText[] pages ) { Name = identifier; Pattern = pattern; Options = pages.ToList(); }
/// <summary> /// Constructs a new selection dialog with just an identifier. /// </summary> /// <param name="identifier">The text identifier of the window.</param> public SelectionDialog( string identifier, SelectionDialogPattern pattern = SelectionDialogPattern.Top ) { Name = identifier; Pattern = pattern; Options = new List<TokenText>(); }
/// <summary> /// Constructs a new selection dialog with just an identifier. /// </summary> /// <param name="identifier">The text identifier of the dialog.</param> /// <param name="pages">The list of lines in the dialog.</param> public SelectionDialog( string identifier, SelectionDialogPattern pattern, List<TokenText> pages ) { Name = identifier; Pattern = pattern; Options = pages; }
private bool TryCompileSelectionDialog(MessageScriptParser.SelectionDialogContext context, out SelectionDialog selectionWindow) { LogContextInfo(context); selectionWindow = null; // // Parse identifier // string identifier; { if (!TryGetFatal(context, context.Identifier, "Expected selection window name", out var identifierNode)) { return(false); } identifier = ParseIdentifier(identifierNode); } LogInfo(context, $"Compiling selection window: {identifier}"); // // Parse pattern // SelectionDialogPattern pattern = SelectionDialogPattern.Top; { if (TryGet(context, context.selectionDialogPattern, out var patternCtx)) { if (TryGet(patternCtx, patternCtx.SelectionDialogPatternId, out var patternIdNode)) { switch (patternIdNode.Symbol.Text) { case "top": pattern = SelectionDialogPattern.Top; break; case "bottom": pattern = SelectionDialogPattern.Bottom; break; default: LogError(patternCtx, $"Unknown selection dialog pattern: {patternIdNode.Symbol.Text}"); return(false); } } else if (TryParseShortIntLiteral(context, "Failed to parse selection dialog pattern ID", patternCtx.IntLiteral, out var patternId)) { pattern = (SelectionDialogPattern)patternId; } else { LogError(patternCtx, "Invalid selection dialog pattern"); return(false); } } } // // Parse text content // List <TokenText> options; { if (!TryGetFatal(context, context.tokenText, "Expected selection window text", out var tagTextContext)) { return(false); } if (!TryCompileTokenText(tagTextContext, out options)) { LogError(tagTextContext, "Failed to compile selection window text"); return(false); } } // // Create Selection window // selectionWindow = new SelectionDialog(identifier, pattern, options); return(true); }