// This will later be handled by a separate selection panel, but for now it's fine. public void SaveBoard(string filename) { var obj = new BoardSerializer.SerializedBoard(sudoku); filename = "Testing/" + filename; StreamWriter sr = File.CreateText(filename); sr.WriteLine(JsonUtility.ToJson(obj)); sr.Close(); }
public void LoadBoard(string filename) { filename = "Testing/" + filename; var subs = filename.Split('.'); var newSubs = new string[subs.Length - 1]; for (int i = 0; i < newSubs.Length; i++) { newSubs[i] = subs[i]; } this.boardName = string.Join(".", newSubs); StreamReader sr = File.OpenText(filename); BoardSerializer.SerializedBoard obj = JsonUtility.FromJson <BoardSerializer.SerializedBoard>(sr.ReadToEnd()); sudoku = obj.Deserialized(); ResetView(); }
public void Submit() { string title = transform.Find("Filename").GetComponent <TMP_InputField>().text; var variant_strings = new string[selectedVariants.Count]; for (int i = 0; i < selectedVariants.Count; i++) { variant_strings[i] = selectedVariants[i].ToString(); } Sudoku s = new Sudoku(variant_strings); var obj = new BoardSerializer.SerializedBoard(s); string filename = "Testing/" + title + ".json"; StreamWriter sr = File.CreateText(filename); sr.WriteLine(JsonUtility.ToJson(obj)); sr.Close(); VisualBoardController.instance.sudoku = obj.Deserialized(); VisualBoardController.instance.ResetView(); VisualBoardController.instance.boardName = title; SceneController.instance.LoadEdit(); Destroy(this.gameObject); }
public void SetBoard(BoardSerializer.SerializedBoard b) { board = b; TagsField.text = string.Join(" ", b.sudoku.variant_strings); }