예제 #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;
 }
예제 #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();
 }
예제 #3
0
 public ScoreView()
 {
     title = null;
     subtitle = null;
     artist = null;
     subartist = null;
     difficulty = 0;
     judge = 0;
     level = 0;
     player = new Score();
     rival = new RivalScore();
 }
예제 #4
0
        /// <summary>
        /// XMLファイルからPlayerクラスを生成する
        /// </summary>
        /// <param name="path">xmlファイルのパス</param>
        /// <returns></returns>
        public static Player ReadPlayerXML(string path)
        {
            var p = new Player();
            var xdoc = XDocument.Load(path);

            //xmlファイルからプレイヤー情報を取得する。
            XElement xplayer = xdoc.Element("Data").Element("Player");

            p.name = xplayer.Element("Name").Value;
            p.hash = xplayer.Element("Hash").Value;
            p.irid = Convert.ToUInt32(xplayer.Element("IRId").Value);
            p.playcount = Convert.ToUInt32(xplayer.Element("PlayCount").Value);
            p.clear = Convert.ToUInt32(xplayer.Element("Clear").Value);
            p.fail = Convert.ToUInt32(xplayer.Element("Fail").Value);
            p.perfect = Convert.ToUInt32(xplayer.Element("Perfect").Value);
            p.great = Convert.ToUInt32(xplayer.Element("Great").Value);
            p.good = Convert.ToUInt32(xplayer.Element("Good").Value);
            p.bad = Convert.ToUInt32(xplayer.Element("Bad").Value);
            p.poor = Convert.ToUInt32(xplayer.Element("Poor").Value);
            p.playtime = Convert.ToUInt32(xplayer.Element("PlayTime").Value);

            //xmlファイルからスコア一覧を取得する
            IEnumerable<XElement> xel = xdoc.Element("Data").Element("Scores").Elements("Score");

            foreach(XElement xe in xel)
            {
                var s = new Score();
                s.hash = xe.Element("Hash").Value;
                s.clear = (Score.Clear)Convert.ToInt32(xe.Element("Clear").Value);
                s.totalnotes = Convert.ToUInt32(xe.Element("TotalNotes").Value);
                s.perfect = Convert.ToUInt32(xe.Element("Perfect").Value);
                s.great = Convert.ToUInt32(xe.Element("Great").Value);
                s.good = Convert.ToUInt32(xe.Element("Good").Value);
                s.bad = Convert.ToUInt32(xe.Element("Bad").Value);
                s.poor = Convert.ToUInt32(xe.Element("Poor").Value);
                s.maxcombo = Convert.ToUInt32(xe.Element("MaxCombo").Value);
                s.minbp = Convert.ToInt32(xe.Element("MinBP").Value);
                s.playcount = Convert.ToUInt16(xe.Element("PlayCount").Value);
                s.clearcount = Convert.ToUInt16(xe.Element("ClearCount").Value);
                s.failcount = Convert.ToUInt16(xe.Element("FailCount").Value);
                s.rank = (Score.Rank)Convert.ToInt32(xe.Element("Rank").Value);
                s.exscore = Convert.ToUInt32(xe.Element("Exscore").Value);
                s.rate = Convert.ToSingle(xe.Element("Rate").Value);
                s.complete = Convert.ToBoolean(xe.Element("Complete").Value);

                p.scoredb.AddScore(s.hash, s);
            }

            return p;
        }
예제 #5
0
 public void AddScore(string hash,Score score)
 {
     scoredb.AddScore(hash, score);
 }
예제 #6
0
 /// <summary>
 /// Dictionaryに要素を与える
 /// </summary>
 /// <param name="hash">TKeyに相当するハッシュ値</param>
 /// <param name="score">TValueに相当するScoreクラス</param>
 public void AddScore(string hash,Score score)
 {
     db[hash] = score;
 }
예제 #7
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);
        }
예제 #8
0
 private static void ScoreToXDoc(Score s, ref XDocument xdoc)
 {
     xdoc.Element("Data").Element("Scores").Add(new XElement("Score",
         new XElement("Hash", s.hash),
         new XElement("Clear", (int)s.clear),
         new XElement("TotalNotes", s.totalnotes),
         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("MaxCombo", s.maxcombo),
         new XElement("MinBP", s.minbp),
         new XElement("PlayCount", s.playcount),
         new XElement("ClearCount", s.clearcount),
         new XElement("FailCount", s.failcount),
         new XElement("Rank", (int)s.rank),
         new XElement("Exscore", s.exscore),
         new XElement("Rate", s.rate),
         new XElement("Complete", s.complete)));
 }