Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
 public ScoreView(Song song, Score player, RivalScore rival)
 {
     title = song.title;
     subtitle = song.subtitle;
     artist = song.artist;
     subartist = song.subartist;
     difficulty = song.difficulty;
     judge = song.judge;
     level = song.level;
     this.player = player;
     this.rival = rival;
 }
Ejemplo n.º 3
0
 public ScoreView(Song song, Score score)
 {
     title = song.title;
     subtitle = song.subtitle;
     artist = song.artist;
     subartist = song.subartist;
     difficulty = song.difficulty;
     judge = song.judge;
     level = song.level;
     player = score;
     rival = new RivalScore();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Dictionaryに要素を与える
 /// </summary>
 /// <param name="hash">TKeyに相当するハッシュ値</param>
 /// <param name="song">TValueに相当するScoreクラス</param>
 public void AddSong(string hash,Song song)
 {
     db[hash] = song;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// dbファイルからXDocumentを作成する
        /// </summary>
        /// <param name="mode">MakeXMLのモード</param>
        /// <param name="file_path">読み込むdbのパス</param>
        /// <param name="save_path">保存するxmlのパス</param>
        /// <param name="rival_name">ライバルの名前</param>
        public static void MakeXML(MakeXMLMode mode,string file_path, string save_path, string rival_name = null)
        {
            string path = null;
            string db_path = null;

            switch(mode)
            {
                case MakeXMLMode.Scores:
                case MakeXMLMode.Rival:
                    db_path = file_path;
                    path = @"./XML/scores.xml";
                    break;
                case MakeXMLMode.Songs:
                    db_path = file_path;
                    path = @"./XML/song.xml";
                    break;
            }

            var xdoc = XDocument.Load(path);

            //dbファイルの読み込み
            using (var conn = new SQLiteConnection("Data Source=" + db_path))
            {

                conn.Open();
                using (var command = conn.CreateCommand())
                {
                    switch (mode)
                    {
                        //songs.dbからsongs.xmlを作る
                        case MakeXMLMode.Songs:
                            command.CommandText = "SELECT * from song";
                            using (SQLiteDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    var song = new Song();

                                    song.hash = reader["hash"].ToString();
                                    song.title = reader["title"].ToString();
                                    song.subtitle = reader["subtitle"].ToString();
                                    song.genre = reader["genre"].ToString();
                                    song.artist = reader["artist"].ToString();
                                    song.subartist = reader["subartist"].ToString();
                                    song.path = reader["path"].ToString();
                                    song.level = Convert.ToInt32(reader["level"].ToString());
                                    song.difficulty = (Song.Difficulty)Convert.ToInt32(reader["difficulty"].ToString());
                                    song.maxbpm = Convert.ToUInt32(reader["maxbpm"].ToString());
                                    song.minbpm = Convert.ToUInt32(reader["minbpm"].ToString());
                                    song.mode = Convert.ToByte(reader["mode"].ToString());
                                    song.judge = (Song.Judge)Convert.ToInt32(reader["judge"].ToString());
                                    song.longnote = ToBool(reader["longnote"].ToString());
                                    song.random = ToBool(reader["random"].ToString());
                                    song.karinotes = Convert.ToUInt32(reader["karinotes"].ToString());
                                    song.exlevel = Convert.ToByte(reader["exlevel"].ToString());

                                    SongToXDoc(song, ref xdoc);
                                }
                            }
                            break;

                        //player情報のdbからxmlを作る
                        case MakeXMLMode.Scores:
                            //プレイヤーデータを保存する
                            command.CommandText = "SELECT * from player";
                            using(SQLiteDataReader reader = command.ExecuteReader())
                            {
                                reader.Read();

                                var player = new Player();

                                player.name = reader["name"].ToString();
                                player.hash = reader["hash"].ToString();
                                player.irid = Convert.ToUInt32(reader["irid"].ToString());
                                player.playcount = Convert.ToUInt32(reader["playcount"].ToString());
                                player.clear = Convert.ToUInt32(reader["clear"].ToString());
                                player.fail = Convert.ToUInt32(reader["fail"].ToString());
                                player.perfect = Convert.ToUInt32(reader["perfect"].ToString());
                                player.great = Convert.ToUInt32(reader["great"].ToString());
                                player.good = Convert.ToUInt32(reader["good"].ToString());
                                player.bad = Convert.ToUInt32(reader["bad"].ToString());
                                player.poor = Convert.ToUInt32(reader["poor"].ToString());
                                player.playtime = Convert.ToUInt32(reader["playtime"].ToString());

                                PlayerToDoc(player, ref xdoc);
                            }

                            //スコアを保存する
                            command.CommandText = "SELECT * from score";
                            using(SQLiteDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    var score = new Score();

                                    score.hash = reader["hash"].ToString();
                                    score.clear = (Score.Clear)Convert.ToInt32(reader["clear"].ToString());
                                    score.totalnotes = Convert.ToUInt32(reader["totalnotes"].ToString());
                                    score.perfect = Convert.ToUInt32(reader["perfect"].ToString());
                                    score.great = Convert.ToUInt32(reader["great"].ToString());
                                    score.good = Convert.ToUInt32(reader["good"].ToString());
                                    score.bad = Convert.ToUInt32(reader["bad"].ToString());
                                    score.poor = Convert.ToUInt32(reader["poor"].ToString());
                                    score.maxcombo = Convert.ToUInt32(reader["maxcombo"].ToString());
                                    score.minbp = Convert.ToInt32(reader["minbp"].ToString());
                                    score.playcount = Convert.ToUInt16(reader["playcount"].ToString());
                                    score.clearcount = Convert.ToUInt16(reader["clearcount"].ToString());
                                    score.failcount = Convert.ToUInt16(reader["failcount"].ToString());
                                    score.rank = (Score.Rank)Convert.ToInt32(reader["rank"].ToString());
                                    score.complete = ToBool(reader["complete"].ToString());
                                    score.SetExScore();
                                    score.SetRate();

                                    ScoreToXDoc(score, ref xdoc);
                                }
                            }
                            break;

                        //ライバルのdbからxmlを作る
                        case MakeXMLMode.Rival:
                            //スコアを保存する
                            command.CommandText = "SELECT * from rival";
                            using(SQLiteDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    var rival = new RivalScore();

                                    rival.hash = reader["hash"].ToString();
                                    rival.clear = (Score.Clear)Convert.ToInt32(reader["r_clear"].ToString());
                                    rival.totalnotes = Convert.ToUInt32(reader["r_totalnotes"].ToString());
                                    rival.maxcombo = Convert.ToUInt32(reader["r_maxcombo"].ToString());
                                    rival.perfect = Convert.ToUInt32(reader["r_perfect"].ToString());
                                    rival.great = Convert.ToUInt32(reader["r_great"].ToString());
                                    rival.good = Convert.ToUInt32(reader["r_good"].ToString());
                                    rival.bad = Convert.ToUInt32(reader["r_bad"].ToString());
                                    rival.poor = Convert.ToUInt32(reader["r_poor"].ToString());
                                    rival.minbp = Convert.ToInt32(reader["r_minbp"].ToString());
                                    rival.SetExscore();
                                    rival.SetRate();

                                    RivalToXDoc(rival, ref xdoc);
                                }
                            }

                            xdoc.Element("Data").Add(new XElement("RivalName", rival_name));

                            break;
                    }
                }
            }

            //作成したxmlファイルを保存する
            xdoc.Save(save_path);
        }
Ejemplo n.º 6
0
 private static void SongToXDoc(Song s,ref XDocument xdoc)
 {
     xdoc.Element("Songs").Add(new XElement("Song",
         new XElement("Hash", s.hash),
         new XElement("Title", s.title),
         new XElement("SubTitle", s.subtitle),
         new XElement("Genre", s.genre),
         new XElement("Artist", s.artist),
         new XElement("SubArtist", s.subartist),
         new XElement("Path", s.path),
         new XElement("Level", s.level),
         new XElement("Difficulty", (int)s.difficulty),
         new XElement("MaxBPM", s.maxbpm),
         new XElement("MinBPM", s.minbpm),
         new XElement("Mode", s.mode),
         new XElement("Judge", (int)s.judge),
         new XElement("LongNote", s.longnote),
         new XElement("Random", s.random),
         new XElement("KariNotes", s.karinotes),
         new XElement("ExLevel", s.exlevel)));
 }