public OptionCommands CallDialog(string text, OptionCommands command) { visible = true; nextVisibleChar = 0; this.text = text; visibleText = ""; options = null; usedOp = false; //method for returning... this.command = command; Next(); return command; }
public OptionCommands CallDialog(string text, OptionCommands command) { visible = true; nextVisibleChar = 0; this.text = text; visibleText = ""; options = null; usedOp = false; //method for returning... this.command = command; Next(); return(command); }
/// <summary> /// Method for Option Commands /// </summary> /// <param name="command">Enum for OptionCommand</param> private void DesignOptionCommand(OptionCommands command) { try { switch (command) { case OptionCommands.Set: DesignAndProcessCommand(new SetDialog(mainForm)); break; default: break; } //switch } //try finally { //programEditor.SavePGM(Files.LastPgm); }//finally }
/// <summary> /// Method for Option Commands /// </summary> /// <param name="command">Enum for OptionCommand</param> private void DesignOptionCommand(OptionCommands command) { try { switch (command) { case OptionCommands.Set: DesignAndProcessCommand(new SetDialog(mainForm)); break; default: break; }//switch } //try finally { //programEditor.SavePGM(Files.LastPgm); }//finally }
public void Next() { string res = ""; //Given a queue of text, need to keep track of where we're showing text from //and when to stop showing, as well as when we hit an options menu //when it comes across an open tag, it should process it and then delete it //from the text. if (nextVisibleChar == -1){ text = ""; visibleText = ""; visible = false; if (usedOp && command != null){ res = options[optionCursor]; options = null; usedOp = false; optionCursor = 0; //is not letting you get that option in thurr if(command != null) command = command(res); //what happens is that the first command gets here, drops the second one, which returns (it shouldn't...) //and the third command is overriden by null here... I think command should return the next command?? } return; } int j = 0; for (int i = nextVisibleChar; i < text.Length; i++){ //Found option tag!! if (i + startOp.Length < text.Length && text.Substring(i, startOp.Length).CompareTo(startOp) == 0){ //problem is youre setting up the option but split word chops off that last end //You get in here when you hit the startOp //then you wanna make a temp string minus the op and split it //if the string is done, use op, else, send the op //to the beginning of the nextVisibleChar string debug = text.Substring(nextVisibleChar); int cutoutLen = text.Substring(i).IndexOf(endOp) + endOp.Length; string temp = text.Substring(nextVisibleChar).Remove(i-nextVisibleChar, cutoutLen); //temp has removed option data... split it!! see if it fits... string option = text.Substring(i + startOp.Length, text.Substring(i + startOp.Length).IndexOf(endOp)); string textPt1 = text.Substring(0, i); visibleText = temp; if (visibleText.Length > charsPerLine){ wordSplit s = SplitWords(visibleText, i); visibleText = s.s; //there is either leftover or not //if leftover, then def proceed and adjust nextVisibleChar AND send option to next piece //if no leftover, then you either got a clean break or really are done AND do option... if (s.iOff < 0){ nextVisibleChar += visibleText.Length;//for newline if (text.Length > i + startOp.Length + cutoutLen + endOp.Length) textPt1 += text.Substring(i + startOp.Length + cutoutLen + endOp.Length); text = textPt1.Trim(); //then add option back in.. text = text.Insert(nextVisibleChar, startOp + option + endOp); }else{ string d = text.Substring(nextVisibleChar + visibleText.Length); int a = nextVisibleChar + visibleText.Length - 1 + text.Count((c)=>{ return (c == ' '); }); int b = text.Length - 1 - startOp.Length - cutoutLen - endOp.Length; if (a < b){ nextVisibleChar += visibleText.Length - 1; if (text.Length > i + startOp.Length + cutoutLen + endOp.Length) textPt1 += text.Substring(i + startOp.Length + cutoutLen + endOp.Length); text = textPt1.Trim(); //then add option back in.. text = text.Insert(nextVisibleChar, startOp + option + endOp); }else{ nextVisibleChar = -1; usedOp = true; options = option.Split(new char[1] { ';' }); //this is the modification of text to remove the option once it has been processed.. if (text.Length > i + startOp.Length + cutoutLen + endOp.Length) textPt1 += text.Substring(i + startOp.Length + cutoutLen + endOp.Length); text = textPt1.Trim(); } } //it is going to break and return here to command = null check. //proceed with next command here?? return; }else{ usedOp = true; options = option.Split(new char[1] { ';' }); //this is the modification of text to remove the option once it has been processed.. int m = i + cutoutLen; if (text.Length > m) textPt1 += text.Substring(i + cutoutLen); text = textPt1.Trim(); visibleText = text.Substring(nextVisibleChar); nextVisibleChar = -1; break; } } if (i >= text.Length - 1){ visibleText = text.Substring(nextVisibleChar); if (visibleText.Length > charsPerLine){ wordSplit s = SplitWords(visibleText, i); visibleText = s.s; //there is either leftover or not //if leftover, then def proceed and adjust nextVisibleChar //if no leftover, then you either got a clean break or really are done if (s.iOff < 0){ nextVisibleChar += visibleText.Length;//for newline }else{ if (nextVisibleChar + visibleText.Length - 1 < text.Length - 1){ nextVisibleChar += visibleText.Length - 1; }else{ nextVisibleChar = -1; } } }else{ //DONE!!!! nextVisibleChar = -1; break; } break; }else if (j > (charsPerLine * 2)){ visibleText = text.Substring(nextVisibleChar, j); nextVisibleChar = i; wordSplit s = SplitWords(visibleText, i); visibleText = s.s; //if leftover, then def proceed and adjust nextVisibleChar //if no leftover, then you either got a clean break or really are done nextVisibleChar += s.iOff; break; } j++; } return; }
public void Next() { string res = ""; //Given a queue of text, need to keep track of where we're showing text from //and when to stop showing, as well as when we hit an options menu //when it comes across an open tag, it should process it and then delete it //from the text. if (nextVisibleChar == -1) { text = ""; visibleText = ""; visible = false; if (usedOp && command != null) { res = options[optionCursor]; options = null; usedOp = false; optionCursor = 0; //is not letting you get that option in thurr if (command != null) { command = command(res); } //what happens is that the first command gets here, drops the second one, which returns (it shouldn't...) //and the third command is overriden by null here... I think command should return the next command?? } return; } int j = 0; for (int i = nextVisibleChar; i < text.Length; i++) { //Found option tag!! if (i + startOp.Length < text.Length && text.Substring(i, startOp.Length).CompareTo(startOp) == 0) { //problem is youre setting up the option but split word chops off that last end //You get in here when you hit the startOp //then you wanna make a temp string minus the op and split it //if the string is done, use op, else, send the op //to the beginning of the nextVisibleChar string debug = text.Substring(nextVisibleChar); int cutoutLen = text.Substring(i).IndexOf(endOp) + endOp.Length; string temp = text.Substring(nextVisibleChar).Remove(i - nextVisibleChar, cutoutLen); //temp has removed option data... split it!! see if it fits... string option = text.Substring(i + startOp.Length, text.Substring(i + startOp.Length).IndexOf(endOp)); string textPt1 = text.Substring(0, i); visibleText = temp; if (visibleText.Length > charsPerLine) { wordSplit s = SplitWords(visibleText, i); visibleText = s.s; //there is either leftover or not //if leftover, then def proceed and adjust nextVisibleChar AND send option to next piece //if no leftover, then you either got a clean break or really are done AND do option... if (s.iOff < 0) { nextVisibleChar += visibleText.Length;//for newline if (text.Length > i + startOp.Length + cutoutLen + endOp.Length) { textPt1 += text.Substring(i + startOp.Length + cutoutLen + endOp.Length); } text = textPt1.Trim(); //then add option back in.. text = text.Insert(nextVisibleChar, startOp + option + endOp); } else { string d = text.Substring(nextVisibleChar + visibleText.Length); int a = nextVisibleChar + visibleText.Length - 1 + text.Count((c) => { return(c == ' '); }); int b = text.Length - 1 - startOp.Length - cutoutLen - endOp.Length; if (a < b) { nextVisibleChar += visibleText.Length - 1; if (text.Length > i + startOp.Length + cutoutLen + endOp.Length) { textPt1 += text.Substring(i + startOp.Length + cutoutLen + endOp.Length); } text = textPt1.Trim(); //then add option back in.. text = text.Insert(nextVisibleChar, startOp + option + endOp); } else { nextVisibleChar = -1; usedOp = true; options = option.Split(new char[1] { ';' }); //this is the modification of text to remove the option once it has been processed.. if (text.Length > i + startOp.Length + cutoutLen + endOp.Length) { textPt1 += text.Substring(i + startOp.Length + cutoutLen + endOp.Length); } text = textPt1.Trim(); } } //it is going to break and return here to command = null check. //proceed with next command here?? return; } else { usedOp = true; options = option.Split(new char[1] { ';' }); //this is the modification of text to remove the option once it has been processed.. int m = i + cutoutLen; if (text.Length > m) { textPt1 += text.Substring(i + cutoutLen); } text = textPt1.Trim(); visibleText = text.Substring(nextVisibleChar); nextVisibleChar = -1; break; } } if (i >= text.Length - 1) { visibleText = text.Substring(nextVisibleChar); if (visibleText.Length > charsPerLine) { wordSplit s = SplitWords(visibleText, i); visibleText = s.s; //there is either leftover or not //if leftover, then def proceed and adjust nextVisibleChar //if no leftover, then you either got a clean break or really are done if (s.iOff < 0) { nextVisibleChar += visibleText.Length;//for newline } else { if (nextVisibleChar + visibleText.Length - 1 < text.Length - 1) { nextVisibleChar += visibleText.Length - 1; } else { nextVisibleChar = -1; } } } else { //DONE!!!! nextVisibleChar = -1; break; } break; } else if (j > (charsPerLine * 2)) { visibleText = text.Substring(nextVisibleChar, j); nextVisibleChar = i; wordSplit s = SplitWords(visibleText, i); visibleText = s.s; //if leftover, then def proceed and adjust nextVisibleChar //if no leftover, then you either got a clean break or really are done nextVisibleChar += s.iOff; break; } j++; } return; }