public static Song[] readSongs(string cateID) { Song[] songList = new Song[9]; //gameObject.GetComponent<ManageHandler>().changeToSongTab(); //songContainer.name = cateID; try { List <XElement> xEleList = XDocument.Load(PATH.SONG + cateID + ".xml").Root.Elements("song").ToList(); for (int i = 0; i < 9; i++) { XElement xEle = xEleList[i]; string name = xEle.Value.Trim(); string file = xEle.Attribute("file").Value.Trim(); bool enabled = bool.Parse(xEle.Attribute("enabled").Value.Trim()); songList[i] = new Song(name, file, enabled); } } catch (System.Exception e) { Debug.Log(e.ToString()); WriteHandler.writeDefault(); } return(songList); }
public static void writeLyrics(string songName, List <Lyrics> lyricsList) { Debug.Log("writing lyrics..."); try { XDocument doc = new XDocument(new XElement("root")); XElement root = doc.Root; root.RemoveAll(); foreach (Lyrics lyrics in lyricsList) { string start = lyrics.start; string end = lyrics.end; string sentence = lyrics.sentence; int voice = lyrics.voice; XElement xEle = new XElement("lyrics", sentence); xEle.Add(new XAttribute("start", start)); xEle.Add(new XAttribute("end", end)); xEle.Add(new XAttribute("voice", voice)); root.Add(xEle); } doc.Save(PATH.LYRICS + songName + ".xml"); } catch (System.Exception e) { Debug.Log(e.ToString()); WriteHandler.writeDefault(); } }
public static void writeSongs(string parentID, Song[] songList) { try { XDocument doc = XDocument.Load(PATH.SONG + parentID + ".xml"); List <XElement> xEleList = doc.Root.Elements("song").ToList(); for (int i = 0; i < 9; i++) { XElement xEle = xEleList[i]; Song song = songList[i]; xEle.Value = song.name.Trim(); xEle.Attribute("file").Value = song.file; xEle.Attribute("enabled").Value = song.enabled.ToString(); } doc.Save(PATH.SONG + parentID + ".xml"); } catch (System.Exception e) { Debug.Log(e.ToString()); WriteHandler.writeDefault(); } }
public static void writeCategories(Cate[] cateList) { Debug.Log("writing..."); try { XDocument doc = XDocument.Load(PATH.CATEGORY + "category.xml"); List <XElement> xEleList = doc.Root.Elements("category").ToList(); for (int i = 0; i < 9; i++) { XElement xEle = xEleList[i]; Cate cate = cateList[i]; xEle.Attribute("id").Value = cate.ID; xEle.Value = cate.name.Trim(); xEle.Attribute("enabled").Value = cate.enabled.ToString(); } doc.Save(PATH.CATEGORY + "category.xml"); } catch (System.Exception e) { Debug.Log(e.ToString()); WriteHandler.writeDefault(); } }
public static List <Lyrics> readLyrics(string songName) { List <Lyrics> lyricsList = new List <Lyrics>(); try { IEnumerable <XElement> xEleList = XDocument.Load(PATH.LYRICS + songName + ".xml").Root.Elements("lyrics"); foreach (XElement xEle in xEleList) { string start = xEle.Attribute("start").Value.Trim(); string end = xEle.Attribute("end").Value.Trim(); string sentence = xEle.Value; XAttribute xVoice = xEle.Attribute("voice"); int voice = (xVoice != null) ? Int16.Parse(xVoice.Value.Trim()) : VOICE.NORMAL; lyricsList.Add(new Lyrics(start, end, sentence, voice)); } } catch (System.Exception e) { Debug.Log(e.ToString()); WriteHandler.writeDefault(); } return(lyricsList); }
public static Cate[] readCategories() { Cate[] cateList = new Cate[9]; try { List <XElement> xEleList = XDocument.Load(PATH.CATEGORY + "category.xml").Root.Elements("category").ToList(); for (int i = 0; i < 9; i++) { XElement xEle = xEleList[i]; string ID = xEle.Attribute("id").Value.Trim(); string name = xEle.Value.Trim(); bool enabled = bool.Parse(xEle.Attribute("enabled").Value.Trim()); cateList[i] = new Cate(ID, name, enabled); } } catch (System.Exception e) { Debug.Log(e.ToString()); WriteHandler.writeDefault(); } return(cateList); }