Ejemplo n.º 1
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.º 2
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.º 3
0
 public ScoreView()
 {
     title = null;
     subtitle = null;
     artist = null;
     subartist = null;
     difficulty = 0;
     judge = 0;
     level = 0;
     player = new Score();
     rival = new RivalScore();
 }
Ejemplo n.º 4
0
 public void AddScore(string hash, RivalScore score)
 {
     scoredb[hash] = score;
 }
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 RivalToXDoc(RivalScore s,ref XDocument xdoc)
 {
     xdoc.Element("Data").Element("Scores").Add(new XElement("Score",
         new XElement("Clear", (int)s.clear),
         new XElement("TotalNotes", s.totalnotes),
         new XElement("MaxCombo", s.maxcombo),
         new XElement("Perfect", s.perfect),
         new XElement("Great", s.great),
         new XElement("Good", s.good),
         new XElement("Bad", s.bad),
         new XElement("Poor", s.poor),
         new XElement("Rate", s.rate),
         new XElement("ExScore", s.exscore),
         new XElement("MinBP", s.minbp)));
 }