public void Clone(ctLine _line) { this.name = _line.name; this.moves = _line.moves; cgNotation not = new cgNotation(new cgBoard()); not.Read(this.moves); }
/// <summary> /// Paste the game notation from clipboard onto the board. /// </summary> private void _pasteGameFromClipboard() { string curgame = GUIUtility.systemCopyBuffer; _abstractBoard = new cgBoard(); Debug.Log("Pasted game from clipboard: " + curgame); cgNotation notation = new cgNotation(_abstractBoard); notation.Read(curgame); _abstractBoard.LoadGame(notation); _setBoardTo(_abstractBoard); }
public void OnSelectPGN(string _path) { try { StreamReader sr = new StreamReader(_path); string line; string strNot = ""; bool started = false; using (sr) { while ((line = sr.ReadLine()) != null) { if (!started) { if (line.Equals("") || line[0] == '[') { continue; } else { started = true; } } line = line.Trim(); strNot += line + " "; if (strNot.Contains("1-0") || strNot.Contains("0-1") || strNot.Contains("1/2-1/2")) { break; } } } int nCommentStart = 0; while ((nCommentStart = strNot.IndexOf("{")) != -1) { int nCommentEnd = strNot.IndexOf("}"); if (nCommentEnd != -1) { strNot = strNot.Remove(nCommentStart, nCommentEnd - nCommentStart + 1); } else { strNot = strNot.Remove(nCommentStart, strNot.Length - nCommentStart); } nCommentStart = strNot.IndexOf("{"); } while ((nCommentStart = strNot.IndexOf("(")) != -1) { int nCommentEnd = strNot.IndexOf(")"); if (nCommentEnd != -1) { strNot = strNot.Remove(nCommentStart, nCommentEnd - nCommentStart + 1); } else { strNot = strNot.Remove(nCommentStart, strNot.Length - nCommentStart); } } cgNotation not = new cgNotation(new cgBoard()); not.Read(strNot); loadedNotation = not.writeFullNotation(cgNotation.NotationType.Algebraic); if (!loadedNotation.Equals("")) { WndManager.Singleton.OpenInputBox("Enter line name:", CallBackAdd); } else { WndManager.Singleton.OpenMsgBox("Invalid file format"); } } catch (System.Exception e) { WndManager.Singleton.OpenMsgBox(string.Format("Failed to open \"{0}\"file.", _path)); } }