Esempio n. 1
0
        public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore <byte[]> resources, GameHost host = null,
                              WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false)
            : base(storage, contextFactory, api, new BeatmapStore(contextFactory), host)
        {
            this.rulesets     = rulesets;
            this.audioManager = audioManager;
            this.resources    = resources;
            this.host         = host;

            DefaultBeatmap = defaultBeatmap;

            beatmaps = (BeatmapStore)ModelStore;
            beatmaps.BeatmapHidden   += b => beatmapHidden.Value = new WeakReference <BeatmapInfo>(b);
            beatmaps.BeatmapRestored += b => beatmapRestored.Value = new WeakReference <BeatmapInfo>(b);
            beatmaps.ItemRemoved     += removeWorkingCache;
            beatmaps.ItemUpdated     += removeWorkingCache;

            if (performOnlineLookups)
            {
                onlineLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
            }

            largeTextureStore = new LargeTextureStore(host?.CreateTextureLoaderStore(Files.Store));
            trackStore        = audioManager.GetTrackStore(Files.Store);
        }
Esempio n. 2
0
 public WaveformTestBeatmap(AudioManager audioManager)
     : base(new BeatmapInfo(), audioManager)
 {
     stream     = TestResources.GetTestBeatmapStream();
     reader     = new ZipArchiveReader(stream);
     trackStore = audioManager.GetTrackStore(reader);
 }
            public override void RecycleTrack()
            {
                base.RecycleTrack();

                trackStore?.Dispose();
                trackStore = null;
            }
 public BeatmapManagerWorkingBeatmap(IResourceStore <byte[]> store, TextureStore textureStore, ITrackStore trackStore, BeatmapInfo beatmapInfo, AudioManager audioManager)
     : base(beatmapInfo, audioManager)
 {
     this.store        = store;
     this.textureStore = textureStore;
     this.trackStore   = trackStore;
 }
Esempio n. 5
0
        private void load(ITrackStore tracks)
        {
            bassTrack = (TrackBass)tracks.Get("sample-track.mp3");
            int length = bassTrack.CurrentAmplitudes.FrequencyAmplitudes.Length;

            Children = new Drawable[]
            {
                track = new DrawableTrack(bassTrack),
                new GridContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Content          = new[]
                    {
                        new Drawable[]
                        {
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Children         = new Drawable[]
                                {
                                    leftChannel = new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Anchor           = Anchor.Centre,
                                        Origin           = Anchor.CentreRight,
                                    },
                                    rightChannel = new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Anchor           = Anchor.Centre,
                                        Origin           = Anchor.CentreLeft,
                                    }
                                }
                            },
                        },
                        new Drawable[]
                        {
                            amplitudeBoxes = new Container
                            {
                                RelativeSizeAxes   = Axes.Both,
                                ChildrenEnumerable =
                                    Enumerable.Range(0, length)
                                    .Select(i => new Box
                                {
                                    RelativeSizeAxes     = Axes.Both,
                                    RelativePositionAxes = Axes.X,
                                    Anchor = Anchor.BottomLeft,
                                    Origin = Anchor.BottomLeft,
                                    Width  = 1f / length,
                                    X      = (float)i / length
                                })
                            },
                        }
                    }
                },
            };
        }
Esempio n. 6
0
        public WorkingBeatmapCache(ITrackStore trackStore, AudioManager audioManager, IResourceStore <byte[]> resources, IResourceStore <byte[]> files, WorkingBeatmap defaultBeatmap = null, GameHost host = null)
        {
            DefaultBeatmap = defaultBeatmap;

            this.audioManager = audioManager;
            this.resources    = resources;
            this.host         = host;
            this.files        = files;
            largeTextureStore = new LargeTextureStore(host?.CreateTextureLoaderStore(files));
            this.trackStore   = trackStore;
        }
Esempio n. 7
0
 protected override Track GetTrack()
 {
     try
     {
         return((trackStore ?? (trackStore = AudioManager.GetTrackStore(store))).Get(getPathForFile(Metadata.AudioFile)));
     }
     catch
     {
         return(null);
     }
 }
Esempio n. 8
0
 private void load(ITrackStore tracks)
 {
     Child = new DraggableAudioContainer
     {
         FillMode = FillMode.Fit,
         Child    = new DraggableAudioContainer
         {
             Child = new DraggableAudioContainer
             {
                 Child = new TrackPlayer(tracks.Get("sample-track.mp3"))
             }
         }
     };
 }
            private void load(ITrackStore tracks, ISampleStore samples)
            {
                track  = new DrawableTrack(tracks.Get("sample-track.mp3"));
                sample = new DrawableSample(samples.Get("long.mp3"));

                if (withMixer)
                {
                    InternalChild = new DrawableAudioMixer {
                        Children = new Drawable[] { track, sample }
                    }
                }
                ;
                else
                {
                    InternalChildren = new Drawable[] { track, sample }
                };
            }
Esempio n. 10
0
        public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore <byte[]> gameResources, GameHost host = null, WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false)
        {
            var userResources = new FileStore(contextFactory, storage).Store;

            BeatmapTrackStore = audioManager.GetTrackStore(userResources);

            beatmapModelManager = CreateBeatmapModelManager(storage, contextFactory, rulesets, api, host);
            workingBeatmapCache = CreateWorkingBeatmapCache(audioManager, gameResources, userResources, defaultBeatmap, host);

            workingBeatmapCache.BeatmapManager      = beatmapModelManager;
            beatmapModelManager.WorkingBeatmapCache = workingBeatmapCache;

            if (performOnlineLookups)
            {
                onlineBeatmapLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
                beatmapModelManager.OnlineLookupQueue = onlineBeatmapLookupQueue;
            }
        }
Esempio n. 11
0
        public BeatmapManager(Storage storage, RealmAccess realm, RulesetStore rulesets, IAPIProvider?api, AudioManager audioManager, IResourceStore <byte[]> gameResources, GameHost?host = null,
                              WorkingBeatmap?defaultBeatmap = null, bool performOnlineLookups = false)
            : base(storage, realm)
        {
            if (performOnlineLookups)
            {
                if (api == null)
                {
                    throw new ArgumentNullException(nameof(api), "API must be provided if online lookups are required.");
                }

                onlineBeatmapLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
            }

            var userResources = new RealmFileStore(realm, storage).Store;

            BeatmapTrackStore = audioManager.GetTrackStore(userResources);

            beatmapImporter = CreateBeatmapImporter(storage, realm, rulesets, onlineBeatmapLookupQueue);
            beatmapImporter.PostNotification = obj => PostNotification?.Invoke(obj);

            workingBeatmapCache = CreateWorkingBeatmapCache(audioManager, gameResources, userResources, defaultBeatmap, host);
        }
Esempio n. 12
0
 public WaveformTestBeatmap(AudioManager audioManager, Beatmap beatmap)
     : base(beatmap.BeatmapInfo, audioManager)
 {
     this.beatmap = beatmap;
     trackStore   = audioManager.GetTrackStore(getZipReader());
 }
Esempio n. 13
0
        private void Load(GameHost gameHost, CachedMap cachedMap)
        {
            IResourceStore <byte[]> store      = new StorageBackedResourceStore(gameHost.Storage);
            ITrackStore             trackStore = audio.GetTrackStore(store);

            var audioFile = $"{Path.GetDirectoryName(_map.Path)}{Path.DirectorySeparatorChar}{_map.AFileName}";

            track = trackStore.Get(audioFile);

            if (track != null)
            {
                track.Volume.Value = Gameini.Get <double>(SettingsConfig.Volume);
            }

            InternalChildren = new Drawable[]
            {
                GameplayScreenLoader = new GameplayScreenLoader
                {
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(1f),
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                },
                rhythmBoxClockContainer = new RhythmBoxClockContainer(0)
                {
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(1f)
                },
                BreakOverlay = new BreakOverlay(new Action[] { () => BreakOverlay.State.Value = Visibility.Hidden, () => ReturntoSongSelectionAfterFail.Value = true })
                {
                    RelativePositionAxes = Axes.Both,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(1f),
                    Alpha            = 0f,
                },
                KeyPress[0] = GetSprite("Skin/K1", 0.3f),
                KeyPress[1] = GetSprite("Skin/K2", 0.4f),
                KeyPress[2] = GetSprite("Skin/K3", 0.5f),
                KeyPress[3] = GetSprite("Skin/K4", 0.6f),
                volume      = new Volume(new Bindable <Track>(track))
                {
                    Anchor               = Anchor.Centre,
                    Origin               = Anchor.Centre,
                    RelativeSizeAxes     = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size  = new Vector2(1f, 0.3f),
                    X     = 0.4f,
                    Y     = 0.2f,
                    Alpha = 0f,
                },
            };

            BreakOverlay.State.Value         = Visibility.Hidden;
            BreakOverlay.State.ValueChanged += async(e) =>
            {
                if (e.NewValue == Visibility.Hidden)
                {
                    BreakOverlay.AnimationOut();
                    await Task.Delay(1500);

                    Resuming.Value = true;
                    rhythmBoxClockContainer.Start();
                    track.Start();
                    _RbPlayfield.Clock = rhythmBoxClockContainer.RhythmBoxClock;
                }
            };

            rhythmBoxClockContainer.Children = new Drawable[]
            {
                _RbPlayfield = new Playfield.Playfield(ToApplyMods)
                {
                    Anchor               = Anchor.Centre,
                    Origin               = Anchor.Centre,
                    RelativeSizeAxes     = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size = new Vector2(0.6f, 0.9f),
                    Map  = _map,
                    Y    = 0.02f
                },
                hpbar = new HPBar(ToApplyMods)
                {
                    Anchor           = Anchor.TopLeft,
                    Origin           = Anchor.TopLeft,
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(0.8f, 1f),
                    Colour           = Color4.AliceBlue
                },
                DispayCombo = new TextFlowContainer
                {
                    Anchor               = Anchor.BottomLeft,
                    Origin               = Anchor.BottomLeft,
                    RelativeSizeAxes     = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size       = new Vector2(0.1f),
                    TextAnchor = Anchor.BottomLeft,
                },
                DispayScore = new TextFlowContainer
                {
                    Anchor               = Anchor.TopRight,
                    Origin               = Anchor.TopRight,
                    RelativeSizeAxes     = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size       = new Vector2(0.1f),
                    TextAnchor = Anchor.TopRight,
                    X          = -0.01f
                },
            };

            rhythmBoxClockContainer.IsPaused.BindTo(IsPaused);
            rhythmBoxClockContainer.UserPlaybackRate.BindTo(UserPlaybackRate);

            _RbPlayfield.Clock = rhythmBoxClockContainer.RhythmBoxClock;
            DispayScore.Clock  = rhythmBoxClockContainer.RhythmBoxClock;
            DispayCombo.Clock  = rhythmBoxClockContainer.RhythmBoxClock;
            hpbar.Clock        = rhythmBoxClockContainer.RhythmBoxClock;

            _RbPlayfield.Resuming.BindTo(Resuming);

            DispayCombo.AddText("0x", x => x.Font     = new FontUsage("Roboto", 40));
            DispayScore.AddText("000000", x => x.Font = new FontUsage("Roboto", 40));

            Score.Combo.PrivateComboBindable.ValueChanged += (e) => hpbar.CurrentValue.Value += hpbar.CalcValue(Score.Combo.currentHit);
            _RbPlayfield.HasFinished.ValueChanged         += (e) =>
            {
                if (!e.NewValue)
                {
                    return;
                }

                rhythmBoxClockContainer.Stop();

                var currentTime = track?.CurrentTime;
                track?.Stop();

                _RbPlayfield.HasFinished.UnbindEvents();

                cachedMap.Map = _map;
                cachedMap.LoadTrackFile();
                cachedMap.Seek(currentTime.GetValueOrDefault());

                Scheduler.AddDelayed(() => this.Expire(), 1000);
                LoadComponentAsync(new ResultScreen(), this.Push);
            };

            ReturntoSongSelectionAfterFail.ValueChanged += (e) =>
            {
                cachedMap.Map = _map;
                cachedMap.LoadTrackFile();
                cachedMap.Seek(track.CurrentTime);

                Selection songSelction;
                LoadComponent(songSelction = new Selection());
                Schedule(() => this.Push(songSelction));
            };

            _RbPlayfield.CanStart.ValueChanged += (e) =>
            {
                if (e.NewValue)
                {
                    Load(1000);
                }
            };
        }
Esempio n. 14
0
 public TrackManagerAudioTrack(TrackSong trackSong, ITrackStore trackManager)
 {
     this.trackSong    = trackSong;
     this.trackManager = trackManager;
 }
Esempio n. 15
0
 public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager)
     : base(beatmapSetInfo, trackManager)
 {
     this.trackManager = trackManager;
 }
Esempio n. 16
0
 public WaveformTestBeatmap(AudioManager audioManager)
     : base(new BeatmapInfo(), audioManager)
 {
     trackStore = audioManager.GetTrackStore(getZipReader());
 }
Esempio n. 17
0
 protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore);
Esempio n. 18
0
 private void load(AudioManager audioManager)
 {
     trackStore = audioManager.GetTrackStore(new OnlineStore());
 }
Esempio n. 19
0
 protected virtual TrackManagerAudioTrack CreatePreviewTrack(TrackSong trackSong, ITrackStore trackStore) =>
 new TrackManagerAudioTrack(trackSong, trackStore);
Esempio n. 20
0
 /// <summary>
 /// Creates the <see cref="TrackManagerPreviewTrack"/>.
 /// </summary>
 protected virtual TrackManagerPreviewTrack CreatePreviewTrack(IBeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) =>
 new TrackManagerPreviewTrack(beatmapSetInfo, trackStore);
Esempio n. 21
0
 public TrackManagerPreviewTrack(IBeatmapSetInfo beatmapSetInfo, ITrackStore trackManager)
 {
     this.beatmapSetInfo = beatmapSetInfo;
     this.trackManager   = trackManager;
 }