protected IEnumerator HighlightPseudoCode(string text, Color color) { // Invalid pseudocode linenr check if (text != Util.INVALID_PSEUDO_CODE_LINE) { string[] lineOfCodeSplit = text.Split(Util.PSEUDO_SPLIT_LINE_ID); // Check if LineNr + pseudocode line is present if (lineOfCodeSplit.Length == 2) { int index = UtilGraph.ConvertCostToInt(lineOfCodeSplit[0]); string pseudoCodeLine = lineOfCodeSplit[1]; /* If a calculation takes place, then first display formula/pseudocode -> insert values -> result * E.g.: * Step 1: i = i + 1 * Step 2: i = 1 + 1 * Step 3: i = 2 */ if (pseudoCodeViewer.InDetailStep) { bool valuesNotInserted = true; // First show step 1 for (int x = 0; x < 2; x++) { string pseudoCodeLineStep = PseudocodeLineIntoSteps(index, valuesNotInserted); if (pseudoCodeLineStep == Util.INVALID_PSEUDO_CODE_LINE) { break; } pseudoCodeViewer.SetCodeLine(index, pseudoCodeLineStep, color); yield return(stepDuration); valuesNotInserted = false; // Then show step 2 } } // At last show step 3 (result) pseudoCodeViewer.SetCodeLine(index, pseudoCodeLine, color); } else { Debug.LogError("Incorrect splitlength! Split char found within pseudocode line!!!"); } } if (pseudoCodeViewer.InDetailStep) { yield return(stepDuration); } else { yield return(demoStepDuration); } }
public void SetCodeLine(string text, Color color) { string[] lineOfCodeSplit = text.Split(Util.PSEUDO_SPLIT_LINE_ID); int index = UtilGraph.ConvertCostToInt(lineOfCodeSplit[0]); if (ValidIndex(index)) { if (includeLineNr) { codeLines[index].text = AdjustLineNr(index, lineOfCodeSplit[1]); } else { codeLines[index].text = lineOfCodeSplit[1]; } codeLines[index].color = color; } }