Пример #1
0
        public static int GetPlaytestParentID(int playtestNodeID)
        {
            switch (MerinoPrefs.playtestScope)
            {
            case MerinoPrefs.PlaytestScope.AllFiles:
                return(-1);

            case MerinoPrefs.PlaytestScope.SameFile:
                return(MerinoData.GetFileParent(playtestNodeID).id);

            case MerinoPrefs.PlaytestScope.NodeOnly:
                return(playtestNodeID);

            default:
                return(-1);
            }
        }
        /// <summary>
        /// Logs errors from the playtest engine and Yarn Loader.
        /// </summary>
        public void PlaytestErrorLog(string message)
        {
            string fileName   = "unknown";
            string nodeName   = "unknown";
            int    lineNumber = -1;

            // detect file name
            if (message.Contains("file"))
            {
                fileName = message.Split(new string[] { "file" }, StringSplitOptions.None)[1].Split(new string[] { " ", ":" }, StringSplitOptions.None)[1];
            }

            // detect node name
            if (message.Contains("node"))
            {
                nodeName = message.Split(new string[] { "node" }, StringSplitOptions.None)[1].Split(new string[] { " ", ":" }, StringSplitOptions.None)[1];

                // detect line numbers, if any, by grabbing the first digit after nodeName
                string numberLog = "";
                for (int index = message.IndexOf(nodeName); index < message.Length; index++)
                {
                    if (Char.IsDigit(message[index]))
                    {
                        numberLog += message[index];
                    }
                    else if (numberLog.Length > 0)                      // did we hit a non-number, after already hitting numbers? then stop
                    {
                        break;
                    }
                }

                int.TryParse(numberLog, out lineNumber);
            }

            var nodeRef = MerinoData.TreeElements.Find(x => x.name == nodeName);

            // v0.6, resolved: "todo: replace "<input>" in parsing errors with the name of the file instead."
            // if filename is default "<input>" then guess filename via cached parentID data in TreeElements
            if (fileName == "<input>" && nodeRef != null)
            {
                fileName = MerinoData.GetFileParent(nodeRef.id).name;
            }

            MerinoEditorWindow.errorLog.Add(new MerinoEditorWindow.MerinoErrorLine(message, fileName, nodeRef != null ? nodeRef.id : -1, Mathf.Max(0, lineNumber)));
            MerinoDebug.Log(LoggingLevel.Error, message);
        }