/// <summary> /// XMLファイルからSongDBクラスを生成する /// </summary> /// <param name="path">xmlファイルのパス</param> /// <returns></returns> public static SongDB ReadSongXML(string path) { var songdb = new SongDB(); var xdoc = XDocument.Load(path); IEnumerable<XElement> xel = xdoc.Element("Songs").Elements("Song"); foreach(XElement xe in xel) { var s = new Song(); s.hash = xe.Element("Hash").Value; s.title = xe.Element("Title").Value; s.subtitle = xe.Element("SubTitle").Value; s.genre = xe.Element("Genre").Value; s.artist = xe.Element("Artist").Value; s.subartist = xe.Element("SubArtist").Value; s.path = xe.Element("Path").Value; s.level = Convert.ToInt32(xe.Element("Level").Value); s.difficulty = (Song.Difficulty)Convert.ToInt32(xe.Element("Difficulty").Value); s.maxbpm = Convert.ToUInt32(xe.Element("MaxBPM").Value); s.minbpm = Convert.ToUInt32(xe.Element("MinBPM").Value); s.mode = Convert.ToByte(xe.Element("Mode").Value); s.judge = (Song.Judge)Convert.ToInt32(xe.Element("Judge").Value); s.longnote = Convert.ToBoolean(xe.Element("LongNote").Value); s.random = Convert.ToBoolean(xe.Element("Random").Value); s.karinotes = Convert.ToUInt32(xe.Element("KariNotes").Value); s.exlevel = Convert.ToByte(xe.Element("ExLevel").Value); songdb.AddSong(s.hash, s); } return songdb; }
public MainWindow() { InitializeComponent(); //初期設定 if(Properties.Settings.Default.LR2Path == "") { //必要なフォルダを作成 Directory.CreateDirectory(@"./XML/Songs/"); Directory.CreateDirectory(@"./XML/Scores/"); Directory.CreateDirectory(@"./XML/Rival/"); //LR2のパスの設定 using(var fbd = new System.Windows.Forms.FolderBrowserDialog()) { fbd.Description = "LR2があるフォルダを指定してください"; fbd.ShowNewFolderButton = false; while (true) { //LR2のパスが正しく設定されてたらsong.xmlを作成する if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Properties.Settings.Default.LR2Path = fbd.SelectedPath; Properties.Settings.Default.Save(); break; } } } //Song.dbからxmlを作成 DBToXML.MakeXML(DBToXML.MakeXMLMode.Songs, Properties.Settings.Default.LR2Path + @"/LR2files/Database/song.db", @"./XML/Songs/songs.xml"); //存在を確認した全てのプレイヤーのxmlを作成する foreach (string path in Directory.GetFiles(Properties.Settings.Default.LR2Path + @"/LR2files/Database/Score/", "*.db")) { string name = System.IO.Path.GetFileNameWithoutExtension(path); if (name != "") { DBToXML.MakeXML(DBToXML.MakeXMLMode.Scores, path, @"./XML/Scores/" + name + @".xml"); } } //存在を確認した全てのライバルのxmlを作成する foreach (string path in Directory.GetFiles(Properties.Settings.Default.LR2Path + @"/LR2files/Rival/", "*.db")) { string name = System.IO.Path.GetFileNameWithoutExtension(path); using (StreamReader reader = new StreamReader(Properties.Settings.Default.LR2Path + @"/LR2files/Rival/" + name + @".lr2folder", ShiftJIS)) { string rivalname = LR2folder.SearchRivalName(reader); if (rivalname != null) { DBToXML.MakeXML(DBToXML.MakeXMLMode.Rival, path, @"./XML/Rival/" + name + @".xml", rivalname); } } } } //ユーザー選択のコンボボックスの項目作成 foreach(string path in Directory.GetFiles(@"./XML/Scores/","*.xml")) { string user = System.IO.Path.GetFileNameWithoutExtension(path); UserComboBox.Items.Add(user); } songdb = XML.ReadSongXML(@"./XML/Songs/songs.xml"); listView.DataContext = scores; }
public void MakeList(SongDB songdb, ScoreDB scoredb) { scores.Clear(); foreach (Score score in scoredb.db.Values) { try { Song song = songdb.db[score.hash]; scores.Add(new ScoreView(song, score)); } catch { } } }