Пример #1
0
        private void ProcessDatabase(GraphicsDevice graphicsDevice)
        {
            // TODO: Encapsulate work with the data base
            var dbConnection = new SQLiteConnection($"Data Source={ProcessorSettings.DatabaseName};Version=3;");

            dbConnection.Open();

            var dbCommand = dbConnection.CreateCommand();

            dbCommand.CommandText = "SELECT * FROM beatmaps";

            var dbDataReader = dbCommand.ExecuteReader();

            BeatmapReader bmReader = new BeatmapReader(ProcessorSettings);

            // Read all entries while there is any
            while (dbDataReader.Read())
            {
                // There are 22 values (from 0 to 21)
                // 0-3 values are information about beatmap location
                string beatmapFolder   = dbDataReader.GetString(0);
                string beatmapFilename = dbDataReader.GetString(1);
                string beatmapName     = dbDataReader.GetString(2);
                string beatmapVersion  = dbDataReader.GetString(3);

                // 4-17 values are beatmap settings data
                var bmSettingsGeneral = new BeatmapSettingsGeneral(
                    dbDataReader.GetString(4),
                    dbDataReader.GetInt32(5),
                    dbDataReader.GetString(6));
                var bmSettingsEditor   = new BeatmapSettingsEditor(dbDataReader.GetInt32(7));
                var bmSettingsMetadata = new BeatmapSettingsMetadata(dbDataReader.GetString(8),
                                                                     dbDataReader.GetString(9), dbDataReader.GetString(10), dbDataReader.GetString(11),
                                                                     dbDataReader.GetString(12), dbDataReader.GetInt32(13), dbDataReader.GetInt32(14));
                var bmSettingsDifficutly = new BeatmapSettingsDifficulty(dbDataReader.GetFloat(15),
                                                                         dbDataReader.GetFloat(16), dbDataReader.GetInt32(17));
                var bmSettings = new BeatmapSettings(bmSettingsGeneral, bmSettingsEditor, bmSettingsMetadata, bmSettingsDifficutly);

                // 20th - hit object count, 21st - the first beats per minute value
                var hitObjectCount = dbDataReader.GetInt32(20);
                var bpm            = dbDataReader.GetDouble(21);

                var bg    = bmReader.LoadBeatmapBackgroundTexture(graphicsDevice, bmSettings, GetBeatmapNameWithoutVersion(beatmapName));
                var music = bmReader.LoadBeatmapMusicTrack(bmSettings, GetBeatmapNameWithoutVersion(beatmapName));

                var entry = new BeatmapProcessorContainerEntry(bmSettings,
                                                               bg, music, beatmapFolder, beatmapFilename, beatmapName,
                                                               beatmapVersion, hitObjectCount, bpm);

                _beatmapSettingsList.Add(entry);
            }

            dbConnection.Close();
        }
Пример #2
0
        public BeatmapSettings(BeatmapSettingsGeneral general, BeatmapSettingsEditor editor,
                               BeatmapSettingsMetadata metadata, BeatmapSettingsDifficulty difficulty)
        {
            GameModeName = "Standard";

            General    = general;
            Editor     = editor;
            Metadata   = metadata;
            Difficulty = difficulty;

            TimingPointsFilename = "timing_points";
            HitObjectsFilename   = "hit_objects";
        }