Пример #1
0
        /// <summary>
        /// Parses provided managed text <see cref="Script"/> document.
        /// </summary>
        /// <remarks>
        /// Kinda hacky, but we treat managed text documents as naninovel scripts here for convenience.
        /// Managed field ID is assoicated with actor name and value is the text of the <see cref="PrintText"/>.
        /// </remarks>
        public static HashSet <ManagedText> GetManagedTextFromScript(Script managedTextScript)
        {
            var managedTextSet = new HashSet <ManagedText>();
            var printActions   = managedTextScript.CollectAllCommandLines().Select(l => Command.FromScriptLine(l)).OfType <PrintText>();

            foreach (var printTextAction in printActions)
            {
                var fieldId = printTextAction.AuthorId;
                if (string.IsNullOrEmpty(fieldId))
                {
                    continue;
                }
                var fieldValue = printTextAction.Text;
                // When actual value is not set in the document, set ID instead to make it clear which field is missing.
                if (string.IsNullOrEmpty(fieldValue))
                {
                    fieldValue = fieldId;
                }
                var category    = managedTextScript.Name;
                var comment     = managedTextScript.GetCommentForLine(printTextAction.LineIndex);
                var managedText = new ManagedText(fieldId, fieldValue, category, comment);
                managedTextSet.Add(managedText);
            }

            return(managedTextSet);
        }
Пример #2
0
        public ScriptPlaylist(Script script)
        {
            ScriptName = script.Name;
            var commands = script.CollectAllCommandLines()
                           .Select(l => Command.FromScriptLine(l))
                           .Where(cmd => cmd != null);

            AddRange(commands);
        }