Beispiel #1
0
        private static void LoadModules(ModuleContainer moduleContainer)
        {
            //Global resource/s.
            var baseFont = new Font(AssPath + "/Resources/Fonts/SourceSansPro-Regular.otf");

            baseFont.GetTexture(14).Smooth = false;
            //Modules

            /*  Modules shouldn't depend on other modules unless absolutely neccessary.
             *  Draw order is determined by the order they are added to the container.
             */
            var pBar     = new ProgressBar();
            var songList = new SongList(baseFont);

            Audio.CurrentSongList = songList;
            var dragWindow    = new DragWindow();
            var playButton    = new PlayButton();
            var border        = new Border();
            var volumeControl = new VolumeControl();
            var shuffle       = new ShuffleButton();
            var repeat        = new RepeatButton();
            var add           = new AddSource();
            var spriteBatch   = new SpriteBatchMod(SpriteBatch);
            var search        = new TextSearch(songList, baseFont);
            var hotkeys       = new HotKeys(pBar, songList, volumeControl);

            moduleContainer.AddModule(pBar);
            moduleContainer.AddModule(songList);
            moduleContainer.AddModule(dragWindow);
            moduleContainer.AddModule(playButton);
            moduleContainer.AddModule(volumeControl);
            moduleContainer.AddModule(shuffle);
            moduleContainer.AddModule(repeat);
            moduleContainer.AddModule(add);
            moduleContainer.AddModule(spriteBatch);
            moduleContainer.AddModule(border);
            moduleContainer.AddModule(search);
            moduleContainer.AddModule(hotkeys);

            //Module specific resources
            songList.LoadFromMultipleDirectories(Config.musicDirectories);
            songList.SortByArtist();

            //Remove duplicates.
            var duplicates = songList.GroupBy(x => x.Name).Where(x => x.Count() > 1);

            foreach (Song song in duplicates
                     .SelectMany(duplicate => duplicate.Take(duplicate.Count() - 1)))
            {
                songList.Remove(song);
            }
        }