Exemple #1
0
        public GameplayClockContainer(BeatmapMeta beatmap, double gameplayStartTime)
        {
            this.beatmap           = beatmap;
            this.gameplayStartTime = gameplayStartTime;

            RelativeSizeAxes = Axes.Both;

            sourceClock = (IAdjustableClock)beatmap.Song ?? new StopwatchClock();
            (sourceClock as IAdjustableAudioComponent)?.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);

            adjustableClock = new DecoupleableInterpolatingFramedClock {
                IsCoupled = false
            };

            platformOffsetClock = new FramedOffsetClock(adjustableClock)
            {
                Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 22 : 0
            };

            // the final usable gameplay clock with user-set offsets applied.
            userOffsetClock = new FramedOffsetClock(platformOffsetClock);

            // the clock to be exposed via DI to children.
            GameplayClock = new GameplayClock(userOffsetClock);

            GameplayClock.IsPaused.BindTo(IsPaused);
        }
Exemple #2
0
        private void updateSelectedBeatmap(BeatmapMeta beatmap)
        {
            if (beatmap?.Equals(beatmapNoDebounce) == true)
            {
                return;
            }

            beatmapNoDebounce = beatmap;
            performUpdateSelected();
        }
Exemple #3
0
            public Background(BeatmapMeta beatmap = null)
            {
                this.beatmap     = beatmap;
                Depth            = float.MaxValue;
                RelativeSizeAxes = Axes.Both;

                BufferedContainer container = new BufferedContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    Children         = new Drawable[]
                    {
                        sprite = new Sprite
                        {
                            RelativeSizeAxes = Axes.Both,
                            FillMode         = FillMode.Fill,
                            Anchor           = Anchor.Centre,
                            Origin           = Anchor.Centre
                        },
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(1f, 0.8f),
                            Colour           = ColourInfo.GradientVertical(Color4.Black.Opacity(0.5f), Color4.Black.Opacity(0f))
                        }
                    }
                };

                Children = new Drawable[]
                {
                    container,
                    new BufferedContainer
                    {
                        RelativeSizeAxes = Axes.X,
                        Height           = bottom_black_area_height,
                        Origin           = Anchor.BottomCentre,
                        Anchor           = Anchor.BottomCentre,
                        BlurSigma        = new Vector2(10),
                        Child            = container.CreateView().With(d =>
                        {
                            d.RelativeSizeAxes     = Axes.Both;
                            d.SynchronisedDrawQuad = true;
                        })
                    },
                    new Box
                    {
                        RelativeSizeAxes = Axes.X,
                        Height           = bottom_black_area_height,
                        Origin           = Anchor.BottomCentre,
                        Anchor           = Anchor.BottomCentre,
                        Colour           = Color4.Black.Opacity(0.2f)
                    }
                };
            }
        private void itemSelected(BeatmapMeta set)
        {
            if (set.ID == (collection.CurrentBeatmap.Value?.ID ?? -1))
            {
                collection.CurrentBeatmap.Value?.Song?.Seek(0);
                return;
            }

            collection.CurrentBeatmap.Value = collection.Beatmaps.First();
            collection.CurrentBeatmap.Value.Song.Restart();
        }
Exemple #5
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            introBeatmap = new BeatmapMeta
            {
                Background = Texture.FromStream(game.Resources.GetStream(@"Tracks/Intro/bg.png")),
                Song       = new TrackBass(game.Resources.GetStream(@"Tracks/Intro/song.mp3")),
                Metadata   = new BeatmapMetadata
                {
                    Song = new SongMetadata
                    {
                        Author = "Kobaryo",
                        Name   = "Villain Virus ( feat. Camellia )"
                    }
                }
            };

            track = introBeatmap.Song;

            collection.CurrentBeatmap.Value = introBeatmap;

            collection.CurrentBeatmap.ValueChanged += delegate
            {
                track.Stop();
                introBeatmap = collection.CurrentBeatmap.Value;
                restartTrack();
            };

            AddInternal(intro = new RhythmicLogo
            {
                Origin = Anchor.Centre,
                Anchor = Anchor.Centre,
            });

            intro.ScaleTo(1);
            intro.FadeIn();
            intro.PlayIntro();

            Scheduler.AddDelayed(() =>
            {
                audio.AddItem(track);
                track.Seek(206500);
                track.Start();

                Scheduler.AddDelayed(() =>
                {
                    DidLoadMenu = true;
                    this.Push(mainMenu);
                }, delay_step_one);
            }, delay_step_two);
        }
Exemple #6
0
        private void prev()
        {
            queuedDirection = TransformDirection.Prev;

            BeatmapMeta playable = collection.Beatmaps.TakeWhile(i => i.ID != current.ID).LastOrDefault() ?? collection.Beatmaps.LastOrDefault();

            if (playable != null)
            {
                collection.CurrentBeatmap.Value.Song.Reset();
                collection.CurrentBeatmap.Value = playable;
                collection.CurrentBeatmap.Value.Song.Restart();
            }
        }
Exemple #7
0
        private void next(bool instant = false)
        {
            if (!instant)
            {
                queuedDirection = TransformDirection.Next;
            }

            BeatmapMeta playable = collection.Beatmaps.SkipWhile(i => i.ID != current.ID).Skip(1).FirstOrDefault() ?? collection.Beatmaps.FirstOrDefault();

            Console.WriteLine(playable);

            if (playable != null)
            {
                collection.CurrentBeatmap.Value.Song.Reset();
                collection.CurrentBeatmap.Value = playable;
                collection.CurrentBeatmap.Value.Song.Restart();
            }
        }
Exemple #8
0
        private void updateDisplay(BeatmapMeta beatmap, TransformDirection direction)
        {
            pendingBeatmapSwitch?.Cancel();

            pendingBeatmapSwitch = Schedule(delegate
            {
                if (beatmap == null)
                {
                    title.Text  = @"Nothing to play!";
                    artist.Text = @"Nothing to play!";
                }
                else
                {
                    SongMetadata metadata = beatmap.Metadata.Song;
                    title.Text            = new LocalisedString((metadata.NameUnicode, metadata.Name));
                    artist.Text           = new LocalisedString((metadata.AuthorUnicode, metadata.Author));
                }

                LoadComponentAsync(new Background(beatmap)
                {
                    Depth = float.MaxValue
                }, newBackground =>
                {
                    switch (direction)
                    {
                    case TransformDirection.Next:
                        newBackground.Position = new Vector2(400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(-400, 500, Easing.OutCubic);
                        break;

                    case TransformDirection.Prev:
                        newBackground.Position = new Vector2(-400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(400, 500, Easing.OutCubic);
                        break;
                    }

                    background.Expire();
                    background = newBackground;

                    playerContainer.Add(newBackground);
                });
            });
Exemple #9
0
        private void load(Game game, AudioManager Audio)
        {
            API = new BeatmapAPI();

            TestLevel = API.ParseBeatmap(File.ReadAllText("../../../../../Rhythmic.Resources/Beatmap/NULCTRL/level.json"));

            AddStep("aa", null);
            AddStep("Restart", () =>
            {
                Clear();

                foreach (Beatmap.Properties.Level.Object.Object o in TestLevel.Level.Level)
                {
                    Scheduler.AddDelayed(() =>
                    {
                        Add(new DrawableBeatmapObject(o));
                    }, o.Time);
                }
            });
        }
Exemple #10
0
        /// <summary>Allow components in SongSelect to update their loaded beatmap details.
        /// This is a debounced call (unlike directly binding to WorkingBeatmap.ValueChanged).</summary>
        /// <param name="beatmap">The working beatmap.</param>
        protected virtual void UpdateBeatmap(BeatmapMeta beatmap)
        {
            Logger.Log($"working beatmap updated to {beatmap}");

            if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
            {
                backgroundModeBeatmap.Beatmap          = beatmap;
                backgroundModeBeatmap.BlurAmount.Value = BACKGROUND_BLUR;
                backgroundModeBeatmap.FadeColour(Color4.White, 250);
            }

            beatmapInfoWedge.Beatmap = beatmap;

            //BeatmapDetails.Beatmap = beatmap;

            if (beatmap.Song != null)
            {
                beatmap.Song.Looping = true;
            }
        }
Exemple #11
0
        private void beatmapChanged(ValueChangedEvent <BeatmapMeta> beatmap)
        {
            TransformDirection direction = TransformDirection.None;

            if (current != null)
            {
                bool audioEquals = beatmap.NewValue?.Song.Equals(current.Song) ?? false;

                if (audioEquals)
                {
                    direction = TransformDirection.None;
                }
                else if (queuedDirection.HasValue)
                {
                    direction       = queuedDirection.Value;
                    queuedDirection = null;
                }
                else
                {
                    int last = collection.Beatmaps.TakeWhile(b => b.ID != current?.ID).Count();
                    int next = beatmap.NewValue == null ? -1 : collection.Beatmaps.TakeWhile(b => b.ID != beatmap.NewValue?.ID).Count();

                    direction = last > next ? TransformDirection.Prev : TransformDirection.Next;
                }

                current.Song.Completed -= currentTrackCompleted;
            }

            current = beatmap.NewValue;

            if (current != null)
            {
                current.Song.Completed += currentTrackCompleted;
            }

            progressBar.CurrentTime = 0;

            updateDisplay(current, direction);

            queuedDirection = null;
        }
Exemple #12
0
        // Beatmap editing
        public BeatmapMeta CreateNewLevel(BeatmapMeta meta)
        {
            BeatmapMeta Beatmap = new BeatmapMeta
            {
                Level = new LevelMeta
                {
                    Level = new List <Object>(),
                },
                Metadata = new BeatmapMetadata
                {
                    Level = new LevelMetadata(),
                    Song  = new SongMetadata()
                },
                Player = new PlayerMeta()
            };

            Beatmap.Metadata = meta.Metadata;
            Beatmap.Player   = meta.Player;
            Beatmap.SongUrl  = meta.SongUrl;

            return(Beatmap);
        }
Exemple #13
0
        /// <summary>selection has been changed as the result of a user interaction.</summary>
        private void performUpdateSelected()
        {
            BeatmapMeta beatmap = beatmapNoDebounce;

            selectionChangedDebounce?.Cancel();

            if (beatmap == null)
            {
                run();
            }
            else
            {
                selectionChangedDebounce = Scheduler.AddDelayed(run, 200);
            }

            void run()
            {
                Logger.Log($"updating selection with beatmap:{beatmap?.ID.ToString() ?? "null"}");

                // We may be arriving here due to another component changing the bindable Beatmap.
                // In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
                if (!Equals(beatmap, collection.CurrentBeatmap.Value))
                {
                    Logger.Log($"beatmap changed from \"{collection.CurrentBeatmap.Value}\" to \"{beatmap}\"");

                    //We want to make sure we stop the current track before we change to a new Beatmap.
                    collection.CurrentBeatmap.Value.Song.Stop();

                    collection.CurrentBeatmap.Value = beatmap;
                }

                if (this.IsCurrentScreen())
                {
                    ensurePlayingSelected();
                }

                UpdateBeatmap(collection.CurrentBeatmap.Value);
            }
        }
Exemple #14
0
        private void LoadAllBeatmaps()
        {
            string path = Path.Combine(GetFolderPath(SpecialFolder.ApplicationData), "Rhythmic", "Database", "Beatmaps");

            foreach (string file in Directory.EnumerateDirectories(path))
            {
                API.GetBeatmapFromZip(file);
                BeatmapMeta level = API.ParseBeatmap(File.ReadAllText(Path.Combine(file, "level.json")));

                BeatmapMeta beatmap = new BeatmapMeta
                {
                    Level    = level.Level,
                    Metadata = level.Metadata,
                    Player   = level.Player,
                    SongUrl  = level.SongUrl
                };

                FileStream SongStream = File.OpenRead(Path.Combine(file, beatmap.SongUrl));

                beatmap.Song = new TrackBass(SongStream);

                if (beatmap.Metadata?.LogoURL != null)
                {
                    beatmap.Logo = Texture.FromStream(File.OpenRead(Path.Combine(file, beatmap.Metadata.LogoURL)));
                }
                if (beatmap.Metadata?.BackgroundURL != null)
                {
                    beatmap.Background = Texture.FromStream(File.OpenRead(Path.Combine(file, beatmap.Metadata.BackgroundURL)));
                }

                collection.Beatmaps.Add(beatmap);
            }

            for (int i = 0; i < collection.Beatmaps.Count; i++)
            {
                collection.Beatmaps[i].ID = i;
            }
        }
Exemple #15
0
        /// <summary>
        /// Call to make a selection and perform the default action for this SongSelect.
        /// </summary>
        /// <param name="beatmap">An optional beatmap to override the current carousel selection.</param>
        /// <param name="performStartAction">Whether to trigger <see cref="OnStart"/>.</param>
        public void FinaliseSelection(BeatmapMeta beatmap = null, bool performStartAction = true)
        {
            // This is very important as we have not yet bound to screen-level bindables before the carousel load is completed.
            if (!Carousel.BeatmapSetsLoaded)
            {
                return;
            }

            // if we have a pending filter operation, we want to run it now.
            // it could change selection (ie. if the ruleset has been changed).
            Carousel.FlushPendingFilterOperations();

            // avoid attempting to continue before a selection has been obtained.
            // this could happen via a user interaction while the carousel is still in a loading state.
            if (Carousel.SelectedBeatmapSet == null)
            {
                return;
            }

            if (beatmap != null)
            {
                Carousel.SelectBeatmap(beatmap);
            }

            if (selectionChangedDebounce?.Completed == false)
            {
                selectionChangedDebounce.RunTask();
                selectionChangedDebounce.Cancel(); // cancel the already scheduled task.
                selectionChangedDebounce = null;
            }

            if (performStartAction)
            {
                OnStart();
            }
        }
Exemple #16
0
 public BeatmapUsecase(BeatmapMeta beatmap, BufferedContainer background)
 {
     this.beatmap    = beatmap;
     this.background = background;
 }
        public static Database Parse(string filename)
        {
            Log.Information("Loading database file {0}", filename);
            List <BeatmapMeta> beatmaps = new List <BeatmapMeta>();

            if (!File.Exists(filename))
            {
                Log.Error("Database file not found");
                throw new FileNotFoundException("Database file not found");
            }

            Database database = new Database();

            byte[] fileBytes = File.ReadAllBytes(filename);
            using (MemoryStream memoryStr = new MemoryStream(fileBytes))
            {
                using (BinaryReader br = new BinaryReader(memoryStr))
                {
                    database.Version         = br.ReadInt32();
                    database.FolderCount     = br.ReadInt32();
                    database.AccountUnlocked = br.ReadBoolean();
                    database.DateUnlocked    = new DateTime(br.ReadInt64());
                    database.PlayerName      = ReadString(br);

                    int mapCount = br.ReadInt32();

                    for (int i = 0; i < mapCount; i++)
                    {
                        BeatmapMeta bm = new BeatmapMeta
                        {
                            Size = database.Version < 20191106 ? br.ReadInt32() : 0,

                            ArtistName    = ReadString(br),
                            ArtistUnicode = ReadString(br),
                            Title         = ReadString(br),
                            TitleUnicode  = ReadString(br),
                            Creator       = ReadString(br),
                            Difficulty    = ReadString(br),
                            AudioFile     = ReadString(br),
                            MD5           = ReadString(br),
                            MapFile       = ReadString(br),

                            Status = (RankedStatus)br.ReadByte(),

                            HitCircleCount = br.ReadInt16(),
                            SliderCount    = br.ReadInt16(),
                            SpinnerCount   = br.ReadInt16(),

                            LastModification = br.ReadInt64(),

                            ApproachRate      = database.Version < 20140609 ? br.ReadByte() : br.ReadSingle(),
                            CircleSize        = database.Version < 20140609 ? br.ReadByte() : br.ReadSingle(),
                            HPDrain           = database.Version < 20140609 ? br.ReadByte() : br.ReadSingle(),
                            OverallDifficulty = database.Version < 20140609 ? br.ReadByte() : br.ReadSingle(),

                            SliderVelocity = br.ReadDouble(),

                            STDModSR   = database.Version < 20140609 ? null : ReadStarRatings(br),
                            TaikoModSR = database.Version < 20140609 ? null : ReadStarRatings(br),
                            CTBModSR   = database.Version < 20140609 ? null : ReadStarRatings(br),
                            ManiaModSR = database.Version < 20140609 ? null : ReadStarRatings(br),

                            DrainTime = br.ReadInt32(),
                            TotalTime = br.ReadInt32(),

                            AudioPreviewTime = br.ReadInt32(),

                            TimingPoints = ReadTimingPoints(br),

                            BeatmapID    = br.ReadInt32(),
                            BeatmapSetID = br.ReadInt32(),
                            ThreadID     = br.ReadInt32(),

                            STDRank   = (int)br.ReadByte(),
                            TaikoRank = (int)br.ReadByte(),
                            CTBRank   = (int)br.ReadByte(),
                            ManiaRank = (int)br.ReadByte(),

                            LocalOffset   = br.ReadInt16(),
                            StackLeniency = br.ReadSingle(),
                            Gamemode      = (Mode)br.ReadByte(),
                            Source        = ReadString(br),
                            Tags          = ReadString(br),
                            OnlineOffset  = br.ReadInt16(),
                            TitleFont     = ReadString(br),
                            Unplayed      = br.ReadBoolean(),
                            LastPlay      = br.ReadInt64(),
                            osz2          = br.ReadBoolean(),
                            FolderName    = ReadString(br),
                            LastUpdate    = br.ReadInt64(),

                            IgnoreSound    = br.ReadBoolean(),
                            IgnoreSkin     = br.ReadBoolean(),
                            DisableSB      = br.ReadBoolean(),
                            DisableVideo   = br.ReadBoolean(),
                            VisualOverride = br.ReadBoolean()
                        };

                        if (database.Version < 20140609)
                        {
                            br.BaseStream.Position += 2; //skips an unknown short
                        }
                        br.BaseStream.Position += 4;     //skips 2nd last mod time ?

                        bm.ManiaScrollSpeed = br.ReadByte();

                        beatmaps.Add(bm);
                        Log.Debug("Read {0}", bm.Title);
                    }

                    database.UserPermissions = br.ReadInt32();
                }
            }

            database.Beatmaps = beatmaps;
            return(database);
        }
 public CarouselBeatmapSet(BeatmapMeta beatmapSet)
 {
     BeatmapSet = beatmapSet ?? throw new ArgumentNullException(nameof(beatmapSet));
 }
Exemple #19
0
 public string ParseBeatmap(BeatmapMeta meta)
 => JsonConvert.SerializeObject(meta, Formatting.Indented, new JsonSerializerSettings
 {
     NullValueHandling = NullValueHandling.Include
 });
Exemple #20
0
 public BeatmapLogoSprite(BeatmapMeta beatmap)
 => this.beatmap = beatmap ?? throw new ArgumentNullException(nameof(beatmap));
        private void load()
        {
            API = new BeatmapAPI();

            TestLevel = API.CreateNewLevel(new BeatmapMeta
            {
                Metadata = new BeatmapMetadata
                {
                    Level = new LevelMetadata
                    {
                        CreatorID   = 0,
                        CreatorName = "Alten",
                        LevelName   = "NULCTRL"
                    },
                    Song = new SongMetadata
                    {
                        Author = "SilentRoom",
                        Name   = "NULCTRL"
                    }
                },
                Level = new LevelMeta
                {
                    BackgroundColour = new float[] { 20, 20, 20 }
                }
            });

            API.AddObject(new Object
            {
                AutoSizeAxes     = Axes.Both,
                RelativeSizeAxes = Axes.None,
                Size             = new float[] { 1f, 1f },
                Position         = new float[] { 0, -1900 },
                Anchor           = Anchor.Centre,
                Origin           = Anchor.Centre,
                Autokill         = false,
                Colour           = new float[] { 255, 255, 255, 255 },
                Masking          = false,
                MoveKeyframes    = new List <Keyframe <double[]> >
                {
                    new Keyframe <double[]>
                    {
                        EaseType        = Easing.OutExpo,
                        Value           = new double[] { 0, 0 },
                        Time            = 0,
                        TimeUntilFinish = 6000
                    }
                },
                ColourKeyframes          = new List <Keyframe <float[]> >(),
                RotationKeyframes        = new List <Keyframe <double> >(),
                ScaleKeyframes           = new List <Keyframe <double[]> >(),
                BorderColourKeyframes    = new List <Keyframe <float[]> >(),
                BorderThicknessKeyframes = new List <Keyframe <double[]> >(),
                BorderColour             = new float[] { 255, 255, 255, 255 },
                BorderThickness          = 0f,
                Name      = "Test Container",
                Rotation  = 0,
                Shape     = Shape.Container,
                Time      = 0,
                Childrens = new List <Object>()
                {
                    new Object
                    {
                        Origin            = Anchor.Centre,
                        Anchor            = Anchor.Centre,
                        Colour            = new float[] { 255, 255, 255, 255 },
                        Size              = new float[] { 190, 190 },
                        Position          = new float[] { 0, 0 },
                        AutoSizeAxes      = Axes.Both,
                        RelativeSizeAxes  = Axes.None,
                        Autokill          = false,
                        Masking           = false,
                        MoveKeyframes     = new List <Keyframe <double[]> >(),
                        ColourKeyframes   = new List <Keyframe <float[]> >(),
                        RotationKeyframes = new List <Keyframe <double> >(),
                        ScaleKeyframes    = new List <Keyframe <double[]> >(),
                        Name              = "Test Square",
                        Rotation          = 0,
                        Shape             = Shape.Square,
                        Time              = 0,
                    },
                    new Object
                    {
                        AutoSizeAxes             = Axes.None,
                        RelativeSizeAxes         = Axes.None,
                        Size                     = new float[] { 125f, 125f },
                        Position                 = new float[] { 0, 0 },
                        Anchor                   = Anchor.Centre,
                        Origin                   = Anchor.Centre,
                        Autokill                 = false,
                        Colour                   = new float[] { 255, 255, 0, 255 },
                        Masking                  = true,
                        MoveKeyframes            = new List <Keyframe <double[]> >(),
                        ColourKeyframes          = new List <Keyframe <float[]> >(),
                        RotationKeyframes        = new List <Keyframe <double> >(),
                        ScaleKeyframes           = new List <Keyframe <double[]> >(),
                        BorderColourKeyframes    = new List <Keyframe <float[]> >(),
                        BorderThicknessKeyframes = new List <Keyframe <double[]> >(),
                        BorderColour             = new float[] { 255, 255, 255, 255 },
                        BorderThickness          = 0f,
                        Name                     = "Test Circle",
                        Rotation                 = 0,
                        Shape                    = Shape.Circle,
                        Time                     = 0,
                        Childrens                = new List <Object>()
                    },
                    new Object
                    {
                        Origin            = Anchor.Centre,
                        Anchor            = Anchor.Centre,
                        Colour            = new float[] { 255, 0, 255, 150 },
                        Size              = new float[] { 125, 125 },
                        Position          = new float[] { 0, 0 },
                        AutoSizeAxes      = Axes.Both,
                        RelativeSizeAxes  = Axes.None,
                        Autokill          = false,
                        Masking           = false,
                        MoveKeyframes     = new List <Keyframe <double[]> >(),
                        ColourKeyframes   = new List <Keyframe <float[]> >(),
                        RotationKeyframes = new List <Keyframe <double> >(),
                        ScaleKeyframes    = new List <Keyframe <double[]> >(),
                        Name              = "Test Triangle",
                        Rotation          = 0,
                        Shape             = Shape.Triangle,
                        Time              = 0,
                    },
                    new Object
                    {
                        Origin            = Anchor.Centre,
                        Anchor            = Anchor.Centre,
                        Colour            = new float[] { 0, 255, 255, 150 },
                        Size              = new float[] { 70, 70 },
                        Position          = new float[] { 0, 0 },
                        AutoSizeAxes      = Axes.Both,
                        RelativeSizeAxes  = Axes.None,
                        Autokill          = false,
                        Masking           = false,
                        MoveKeyframes     = new List <Keyframe <double[]> >(),
                        ColourKeyframes   = new List <Keyframe <float[]> >(),
                        RotationKeyframes = new List <Keyframe <double> >(),
                        ScaleKeyframes    = new List <Keyframe <double[]> >(),
                        Name              = "Test EquilateralTriangle",
                        Rotation          = 0,
                        Shape             = Shape.EquilateralTriangle,
                        Time              = 0,
                    },
                }
            }, TestLevel);

            foreach (Object obj in TestLevel.Level.Level)
            {
                Scheduler.AddDelayed(() =>
                {
                    Add(new DrawableBeatmapObject(obj));
                }, obj.Time);
            }
        }
Exemple #22
0
        public BeatmapCard(BeatmapMeta beatmap)
        {
            Beatmap      = beatmap;
            Size         = size;
            CornerRadius = 5;
            Masking      = true;

            EdgeEffect = new EdgeEffectParameters
            {
                Type   = EdgeEffectType.Shadow,
                Offset = new Vector2(0f, 2f),
                Radius = 1f,
                Colour = Color4.Black.Opacity(0.25f),
            };

            Children = new Drawable[]
            {
                main = new BufferedContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = Color4.Black
                        },
                        new BeatmapBackgroundSprite(beatmap)
                        {
                            RelativeSizeAxes = Axes.Both,
                            FillMode         = FillMode.Fill,
                            Anchor           = Anchor.Centre,
                            Origin           = Anchor.Centre,
                            Alpha            = 0.6f,
                        },
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = new ColourInfo
                            {
                                TopLeft     = Color4.Black.Opacity(0f),
                                TopRight    = Color4.Black.Opacity(0f),
                                BottomLeft  = Color4.Black.Opacity(0.6f),
                                BottomRight = Color4.Black.Opacity(0.6f)
                            }
                        },
                        new FillFlowContainer
                        {
                            RelativeSizeAxes = Axes.Both,
                            Direction        = FillDirection.Vertical,
                            Anchor           = Anchor.BottomCentre,
                            Origin           = Anchor.BottomCentre,
                            Padding          = new MarginPadding
                            {
                                Bottom = size.Y / 4 + 5,
                                Left   = 5
                            },
                            Children = new Drawable[]
                            {
                                new SpriteText
                                {
                                    Text   = beatmap.Metadata.Song.Author,
                                    Font   = RhythmicFont.GetFont(size: 20, weight: FontWeight.Light),
                                    Anchor = Anchor.BottomLeft,
                                    Origin = Anchor.BottomLeft
                                },
                                new SpriteText
                                {
                                    Text   = beatmap.Metadata.Song.Name,
                                    Font   = RhythmicFont.GetFont(size: 30, weight: FontWeight.Regular),
                                    Anchor = Anchor.BottomLeft,
                                    Origin = Anchor.BottomLeft
                                }
                            }
                        },
                    }
                },
                new BeatmapUsecase(beatmap, main)
                {
                    Origin           = Anchor.BottomLeft,
                    Anchor           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.X,
                    Size             = new Vector2(1f, size.Y / 4)
                }
            };
        }
Exemple #23
0
 public Stream GetTrack(BeatmapMeta meta)
 => game.Resources.GetStream("Tracks/" + meta.Metadata.Level.LevelName + "/" + meta.SongUrl);
Exemple #24
0
 private void playlistOrderChanged(BeatmapMeta beatmap, int index)
 {
     collection.Beatmaps.Remove(beatmap);
     collection.Beatmaps.Insert(index, beatmap);
 }
Exemple #25
0
 public void Edit(BeatmapMeta beatmap = null)
 {
     collection.CurrentBeatmap.Value = beatmap ?? beatmapNoDebounce;
     this.Push(new Editor());
 }
Exemple #26
0
        public EditorClock(BeatmapMeta beatmap, BindableBeatDivisor beatDivisor)
        {
            this.beatDivisor = beatDivisor;

            TrackLength = beatmap.Song.Length;
        }
Exemple #27
0
        protected override void LoadComplete()
        {
            base.LoadComplete();
            dependencies.Cache(this);

            AddRange(new Drawable[]
            {
                screenContainer = new BufferedContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Children         = new Drawable[]
                    {
                        screenStack = new RhythmicScreenStack {
                            RelativeSizeAxes = Axes.Both
                        },
                    }
                },
                rightFloatingOverlayContent = new BufferedContainer {
                    RelativeSizeAxes = Axes.Both
                },
                topMostOverlayContent = new BufferedContainer {
                    RelativeSizeAxes = Axes.Both
                },
            });

            screenStack.ScreenPushed += screenPushed;
            screenStack.ScreenExited += screenExited;

            dependencies.Cache(beatmaps);

            loadComponentSingleFile(Toolbar = new Toolbar(screenContainer)
            {
                OnHome = delegate
                {
                    CloseAllOverlays(false);
                    menuScreen?.MakeCurrent();
                },
            }, d =>
            {
                topMostOverlayContent.Add(d);
                toolbarElements.Add(d);
            });

            loadComponentSingleFile(musicController = new MusicController(screenContainer)
            {
                GetToolbarHeight = () => ToolbarOffset,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, m =>
            {
                rightFloatingOverlayContent.Add(m);
                overlays.Add(m);
            });

            loadComponentSingleFile(notifications = new NotificationOverlay(screenContainer)
            {
                GetToolbarHeight = () => ToolbarOffset,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, n =>
            {
                rightFloatingOverlayContent.Add(n);
                overlays.Add(n);
            });

            notifications.Post(new SimpleNotification
            {
                Text        = "Test Notification",
                Description = "And here’s some text that you can almost barely read!"
            });

            Toolbar.ToggleVisibility();

            dependencies.Cache(menuScreen = new MainMenu(screenContainer));
            screenStack.Push(new Loader());

            dependencies.Cache(musicController);
            dependencies.Cache(notifications);

            OverlayActivationMode.ValueChanged += mode =>
            {
                if (mode.NewValue != OverlayActivation.All)
                {
                    CloseAllOverlays();
                }
            };

            EditorBeatmapManager editorBeatmapManager;

            dependencies.Cache(editorBeatmapManager = new EditorBeatmapManager());

            Add(editorBeatmapManager);

            fileImporters.Add(editorBeatmapManager);

            editorBeatmapManager.PushToEditor += b =>
            {
                ProgressNotification notification = new ProgressNotification {
                    State = ProgressNotificationState.Active
                };

                BeatmapMeta convertedBeatmap = Import(notification, b);

                if (convertedBeatmap != null)
                {
                    beatmaps.CurrentBeatmap.Value = convertedBeatmap;
                    screenStack.Push(new Editor());
                }
            };

            BeatmapMeta Import(ProgressNotification notification, string songPath)
            {
                notification.Progress = 0;
                notification.Text     = "Import is initialising...";

                if (notification.State == ProgressNotificationState.Cancelled)
                {
                    return(null);
                }

                try
                {
                    string text = "Importing " + Path.GetFileNameWithoutExtension(songPath);

                    notification.Text = text;

                    FileStream file = File.OpenRead(songPath);

                    BeatmapMeta beatmap = new BeatmapMeta
                    {
                        Song     = new TrackBass(file),
                        SongUrl  = songPath,
                        Metadata = new BeatmapMetadata
                        {
                            Song  = new SongMetadata(),
                            Level = new LevelMetadata()
                        }
                    };

                    beatmaps.Beatmaps.Add(beatmap);

                    return(beatmap);
                }
                catch (Exception e)
                {
                    e = e.InnerException ?? e;
                    Logger.Error(e, $@"Could not import ({Path.GetFileName(songPath)})");
                }

                return(null);
            }
        }
Exemple #28
0
 public DrawableCarouselBeatmapSet(CarouselBeatmapSet set)
     : base(set)
 {
     beatmapSet = set.BeatmapSet;
 }
        public TestSceneBeatmapParsing()
        {
            API = new BeatmapAPI();

            Children = new Drawable[]
            {
                new RhythmicScrollContainer(Direction.Vertical)
                {
                    RelativeSizeAxes = Axes.Both,
                    Children         = new[]
                    {
                        Container = new FillFlowContainer
                        {
                            LayoutDuration   = 100,
                            LayoutEasing     = Easing.Out,
                            Spacing          = new Vector2(1, 1),
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Padding          = new MarginPadding(5)
                        }
                    }
                }
            };

            #region BeatmapSetup
            TestLevel = new BeatmapMeta
            {
                Metadata = new BeatmapMetadata
                {
                    Song = new SongMetadata
                    {
                        Author = "Silentroom",
                        Name   = "NULCTRL"
                    },
                    Level = new LevelMetadata
                    {
                        CreatorID   = 0,
                        CreatorName = "Alten",
                        LevelName   = "NULCTRL"
                    }
                },
                SongUrl = "song.mp3"
            };

            TestLevel.Player = new PlayerMeta
            {
                Colour   = new float[] { 255, 255, 255, 255 },
                Cooldown = 2,
                Health   = 3,
                Size     = 20
            };

            TestLevel = API.CreateNewLevel(TestLevel);

            TestLevel.Level.BackgroundColour = new float[] { 10, 10, 10, 10 };

            API.AddObject(new Object
            {
                Name          = "Object 2",
                Time          = 2,
                Shape         = Shape.Square,
                Position      = new float[] { 0, 0 },
                Size          = new float[] { 1, 1 },
                Colour        = new float[] { 255, 255, 255, 255 },
                Rotation      = 0,
                Anchor        = Anchor.Centre,
                Origin        = Anchor.Centre,
                Autokill      = false,
                Masking       = false,
                Empty         = false,
                Helper        = false,
                MoveKeyframes = new List <Keyframe <double[]> >
                {
                    new Keyframe <double[]>
                    {
                        Time     = 0,
                        Value    = new double[] { 0, 0 },
                        EaseType = Easing.None
                    },
                    new Keyframe <double[]>
                    {
                        Time     = 1,
                        Value    = new double[] { 0, 20 },
                        EaseType = Easing.InExpo
                    }
                },
                ScaleKeyframes = new List <Keyframe <double[]> >
                {
                    new Keyframe <double[]>
                    {
                        Time     = 0,
                        Value    = new double[] { 0, 0 },
                        EaseType = Easing.None
                    },
                    new Keyframe <double[]>
                    {
                        Time     = 0.2,
                        Value    = new double[] { 1, 1 },
                        EaseType = Easing.OutExpo
                    }
                }
            }, TestLevel);

            #endregion

            string Json = API.ParseBeatmap(TestLevel);

            System.Console.WriteLine(Json);

            Container.Add(new TextFlowContainer
            {
                Text             = Json,
                RelativeSizeAxes = Axes.X,
                AutoSizeAxes     = Axes.Y,
            });

            AddStep("aa", null);

            //TODO: Add more steps
            #region Steps
            AddStep("Create new object", () =>
            {
                API.AddObject(new Object
                {
                    Name          = "Object " + index,
                    Time          = 2,
                    Shape         = Shape.Square,
                    Position      = new float[] { 0, 0 },
                    Size          = new float[] { 1, 1 },
                    Rotation      = 0,
                    Anchor        = Anchor.Centre,
                    Origin        = Anchor.Centre,
                    Autokill      = false,
                    Masking       = false,
                    Empty         = false,
                    Helper        = false,
                    MoveKeyframes = new List <Keyframe <double[]> >
                    {
                        new Keyframe <double[]>
                        {
                            Time     = 0,
                            Value    = new double[] { 0, 0 },
                            EaseType = Easing.None
                        },
                        new Keyframe <double[]>
                        {
                            Time     = 1,
                            Value    = new double[] { 0, 20 },
                            EaseType = Easing.InExpo
                        }
                    },
                    ScaleKeyframes = new List <Keyframe <double[]> >
                    {
                        new Keyframe <double[]>
                        {
                            Time     = 0,
                            Value    = new double[] { 0, 0 },
                            EaseType = Easing.None
                        },
                        new Keyframe <double[]>
                        {
                            Time     = 0.2,
                            Value    = new double[] { 1, 1 },
                            EaseType = Easing.OutExpo
                        }
                    }
                }, TestLevel);

                Container.Clear();

                Json = JsonConvert.SerializeObject(TestLevel, Formatting.Indented);

                Container.Add(new TextFlowContainer
                {
                    Text             = Json,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                });

                index++;
            });
            #endregion
        }
Exemple #30
0
 public void AddObject(Object obj, BeatmapMeta meta)
 => meta.Level.Level.Add(obj);