public void Setup(HashSet <LargeCard> largeCards) { cards.Clear(); foreach (LargeCard lCard in largeCards) { cards.Add(lCard.GetCardData()); } //Need refence of the user/language folder that this card came from MenuTreeGenerator generator = GameObject.FindObjectOfType <MenuTreeGenerator>(); Folder = generator.StoryFolder; PathType = generator.PathType; }
void OnGUI() { GUILayout.Label("Card Editor", EditorStyles.boldLabel); pathType = (SerializationManager.SavePathType)EditorGUILayout.EnumPopup("Save path:", pathType); filename = EditorGUILayout.TextField("File Name", filename); string filePath = SerializationManager.CreatePath(filename, pathType); GUILayout.Label($"Path:\n{filePath}"); bool fileExists = File.Exists(filePath); if (!fileExists) { EditorGUILayout.HelpBox("File does not exist at path!", MessageType.Error, true); } EditorGUI.BeginDisabledGroup(!fileExists); if (GUILayout.Button("Load Card", new GUILayoutOption[] { GUILayout.Width(300), GUILayout.Height(32) })) { cardData = SerializationManager.LoadJsonObject <CardData>(filePath); } EditorGUI.EndDisabledGroup(); //Card Data editing here GUILayout.FlexibleSpace(); GUILayout.Label("CardData", EditorStyles.boldLabel); cardData.From = EditorGUILayout.TextField("From", cardData.From); cardData.To = EditorGUILayout.TextField("To", cardData.To); GUILayout.FlexibleSpace(); if (fileExists) { EditorGUILayout.HelpBox("File already exists at path.\nAre you sure you want to overrite?", MessageType.Warning, true); } if (GUILayout.Button("Save Card", new GUILayoutOption[] { GUILayout.Width(300), GUILayout.Height(32) })) { if (fileExists) { if (!EditorUtility.DisplayDialog("Overrite card?", "Card will be replaced:\n" + filePath + "\nThis cannot be undone.", "Yes", "Cancel")) { return; } } SerializationManager.SaveJsonObject(filePath, cardData, true); } }
void OnGUI() { GUILayout.Label("Story Parser", EditorStyles.boldLabel); pathType = (SerializationManager.SavePathType)EditorGUILayout.EnumPopup("Save path:", pathType); userFolder = EditorGUILayout.TextField("User Path", userFolder); folderPath = EditorGUILayout.TextField("Folder Path", folderPath); string path = SerializationManager.CreatePath(folderPath, pathType); GUILayout.Label($"Path:\n{path}"); bool dirExists = Directory.Exists(path); if (!dirExists) { EditorGUILayout.HelpBox("Directory does not exist at path.", MessageType.Warning, true); } else { EditorGUILayout.HelpBox("Directory already exists at path!", MessageType.Warning, true); } GUILayout.Label("Story Raw Text", EditorStyles.boldLabel); scroll = EditorGUILayout.BeginScrollView(scroll); rawText = EditorGUILayout.TextArea(rawText); EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Parse/Save Cards", new GUILayoutOption[] { GUILayout.Width(300), GUILayout.Height(32) })) { if (!EditorUtility.DisplayDialog("Parse text into current path?", "Cards will be added to path:\n" + path + "\nThis cannot be undone.", "Yes", "Cancel")) { return; } //Load user cards first CardManager.UnloadAll(); CardManager.LoadFolder(userFolder); RawStoryParser parser = new RawStoryParser(); parser.folderPath = folderPath; parser.SavePath = pathType; parser.ParseData(rawText); CardManager.UnloadAll(); } }
public void Setup(CardData card, string folder, SerializationManager.SavePathType PathType) { this.PathType = PathType; LanguageFolder = folder; //To Broken up //Direction = CardManager.Direction.To; //Line = card.BrokenUpTo; //To with phrases //Direction = CardManager.Direction.To; //Line = card.To; //From Direction = CardManager.Direction.From; Line = card.From; }
List <CardData> loadFolder(string folderName, bool placeInDictionary = true, SerializationManager.SavePathType PathType = SerializationManager.SavePathType.Streaming, SearchOption searchOption = SearchOption.AllDirectories) { string folderPath = SerializationManager.CreatePath(folderName, PathType); folderPath = folderPath.TrimEnd(new char[] { '\\', '/' }) + "/"; var info = new DirectoryInfo(folderPath); if (!info.Exists) { Debug.LogWarning($"Folder {folderPath} doesn't exist!"); return(new List <CardData>()); } var fileInfo = info.GetFiles("*.json", searchOption); List <CardData> cardsLoaded = new List <CardData>(); foreach (FileInfo file in fileInfo) { cardsLoaded.Add(LoadCard(file.FullName, placeInDictionary)); } return(cardsLoaded); }
public static List <CardData> LoadFolder(string folderName, bool placeInDictionary = true, SerializationManager.SavePathType PathType = SerializationManager.SavePathType.Streaming, SearchOption searchOption = SearchOption.AllDirectories) { return(Instance.loadFolder(folderName, placeInDictionary, PathType, searchOption)); }