コード例 #1
0
        public TimelineHitObjectDisplay(EditorBeatmap beatmap)
        {
            RelativeSizeAxes = Axes.Both;

            this.beatmap = beatmap;
        }
コード例 #2
0
        public void TestRangeSelect()
        {
            var addedObjects = new[]
            {
                new HitCircle {
                    StartTime = 500
                },
                new HitCircle {
                    StartTime = 1000, Position = new Vector2(100)
                },
                new HitCircle {
                    StartTime = 1500, Position = new Vector2(200)
                },
                new HitCircle {
                    StartTime = 2000, Position = new Vector2(300)
                },
                new HitCircle {
                    StartTime = 2500, Position = new Vector2(400)
                },
            };

            AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));

            moveMouseToObject(() => addedObjects[1]);
            AddStep("click second", () => InputManager.Click(MouseButton.Left));

            AddAssert("hitobject selected", () => EditorBeatmap.SelectedHitObjects.Single() == addedObjects[1]);

            AddStep("hold shift", () => InputManager.PressKey(Key.ShiftLeft));

            moveMouseToObject(() => addedObjects[3]);
            AddStep("click fourth", () => InputManager.Click(MouseButton.Left));
            assertSelectionIs(addedObjects.Skip(1).Take(3));

            moveMouseToObject(() => addedObjects[0]);
            AddStep("click first", () => InputManager.Click(MouseButton.Left));
            assertSelectionIs(addedObjects.Take(2));

            AddStep("clear selection", () => EditorBeatmap.SelectedHitObjects.Clear());
            AddStep("release shift", () => InputManager.ReleaseKey(Key.ShiftLeft));

            moveMouseToObject(() => addedObjects[0]);
            AddStep("click first", () => InputManager.Click(MouseButton.Left));
            assertSelectionIs(addedObjects.Take(1));

            AddStep("hold ctrl", () => InputManager.PressKey(Key.ControlLeft));
            moveMouseToObject(() => addedObjects[2]);
            AddStep("click third", () => InputManager.Click(MouseButton.Left));
            assertSelectionIs(new[] { addedObjects[0], addedObjects[2] });

            AddStep("hold shift", () => InputManager.PressKey(Key.ShiftLeft));
            moveMouseToObject(() => addedObjects[4]);
            AddStep("click fifth", () => InputManager.Click(MouseButton.Left));
            assertSelectionIs(addedObjects.Except(new[] { addedObjects[1] }));

            moveMouseToObject(() => addedObjects[0]);
            AddStep("click first", () => InputManager.Click(MouseButton.Left));
            assertSelectionIs(addedObjects);

            AddStep("clear selection", () => EditorBeatmap.SelectedHitObjects.Clear());
            moveMouseToObject(() => addedObjects[0]);
            AddStep("click first", () => InputManager.Click(MouseButton.Left));
            assertSelectionIs(addedObjects.Take(1));

            moveMouseToObject(() => addedObjects[1]);
            AddStep("click first", () => InputManager.Click(MouseButton.Left));
            assertSelectionIs(addedObjects.Take(2));

            moveMouseToObject(() => addedObjects[2]);
            AddStep("click first", () => InputManager.Click(MouseButton.Left));
            assertSelectionIs(addedObjects.Take(3));

            AddStep("release keys", () =>
            {
                InputManager.ReleaseKey(Key.ControlLeft);
                InputManager.ReleaseKey(Key.ShiftLeft);
            });
        }
コード例 #3
0
        private void load(KaraokeRulesetConfigManager config, IBindable <IReadOnlyList <Mod> > mods, IBindable <WorkingBeatmap> beatmap, KaraokeSessionStatics session, EditorBeatmap editorBeatmap)
        {
            if (editorBeatmap != null)
            {
                session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.Edit);
                return;
            }

            this.beatmap = beatmap.Value.Beatmap;

            var disableMicrophoneDeviceByMod = mods.Value.OfType <IApplicableToMicrophone>().Any(x => !x.MicrophoneEnabled);

            if (disableMicrophoneDeviceByMod)
            {
                session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.AutoPlay);
                return;
            }

            var beatmapSaitenable = beatmap.Value.Beatmap.IsScorable();

            if (!beatmapSaitenable)
            {
                session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.NotSaitening);
                return;
            }

            try
            {
                var selectedDevice = config.Get <string>(KaraokeRulesetSetting.MicrophoneDevice);
                var microphoneList = new MicrophoneManager().MicrophoneDeviceNames.ToList();

                // Find index by selection id
                var deviceIndex = microphoneList.IndexOf(selectedDevice);
                AddHandler(new OsuTKMicrophoneHandler(deviceIndex));

                session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.Saitening);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Microphone initialize error.");
                // todo : set real error by exception
                session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.WindowsMicrophonePermissionDeclined);
            }
        }
コード例 #4
0
 private void addArbitraryChange(EditorBeatmap beatmap)
 {
     beatmap.Add(new HitCircle {
         StartTime = 2760
     });
 }
コード例 #5
0
 public TestSceneSetupScreen()
 {
     editorBeatmap = new EditorBeatmap(new OsuBeatmap());
 }
コード例 #6
0
 private void deleteSelected()
 {
     EditorBeatmap.RemoveRange(selectedBlueprints.Select(b => b.HitObject));
 }
コード例 #7
0
        public TestSceneOsuDistanceSnapGrid()
        {
            editorBeatmap = new EditorBeatmap <OsuHitObject>(new OsuBeatmap());

            createGrid();
        }
コード例 #8
0
        public override void SetUpSteps()
        {
            base.SetUpSteps();

            AddStep("get beatmap", () => editorBeatmap = Editor.ChildrenOfType <EditorBeatmap>().Single());
        }
コード例 #9
0
ファイル: MarkerPart.cs プロジェクト: Azyyyyyy/osu
 protected override void LoadBeatmap(EditorBeatmap beatmap)
 {
     // block base call so we don't clear our marker (can be reused on beatmap change).
 }
コード例 #10
0
 public TestSceneTimingScreen()
 {
     editorBeatmap = new EditorBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
 }
コード例 #11
0
ファイル: SelectionHandler.cs プロジェクト: neoayi/osu
 private void deleteSelected()
 {
     ChangeHandler?.BeginChange();
     EditorBeatmap?.RemoveRange(selectedBlueprints.Select(b => b.HitObject));
     ChangeHandler?.EndChange();
 }
コード例 #12
0
 private Lyric[] getLyrics(EditorBeatmap editorBeatmap)
 => editorBeatmap.HitObjects.OfType <Lyric>().ToArray();
コード例 #13
0
 public EditorGeneratorContext(Effect effect, string projectPath, string mapsetPath, EditorBeatmap beatmap, IEnumerable <EditorBeatmap> beatmaps, MultiFileWatcher watcher)
 {
     this.projectPath = projectPath;
     this.mapsetPath  = mapsetPath;
     this.effect      = effect;
     this.beatmap     = beatmap;
     this.beatmaps    = beatmaps;
     this.watcher     = watcher;
 }
コード例 #14
0
 public TestSceneHitObjectComposerDistanceSnapping()
 {
     editorBeatmap = new EditorBeatmap(new OsuBeatmap(), BeatDivisor);
 }
コード例 #15
0
        private void load(KaraokeRulesetConfigManager config, IBindable <IReadOnlyList <Mod> > mods, IBindable <WorkingBeatmap> beatmap, EditorBeatmap editorBeatmap)
        {
            if (editorBeatmap != null)
            {
                return;
            }

            this.beatmap = beatmap.Value.Beatmap;

            var disableMicrophoneDeviceByMod = mods.Value.OfType <IApplicableToMicrophone>().Any(x => !x.MicrophoneEnabled);

            if (disableMicrophoneDeviceByMod)
            {
                return;
            }

            var beatmapSaitenable = beatmap.Value.Beatmap.IsScorable();

            if (!beatmapSaitenable)
            {
                return;
            }

            var selectedDevice = config.GetBindable <string>(KaraokeRulesetSetting.MicrophoneDevice).Value;
            var microphoneList = new MicrophoneManager().MicrophoneDeviceNames.ToList();

            // Find index by selection id
            var deviceIndex = microphoneList.IndexOf(selectedDevice);

            AddHandler(new OsuTKMicrophoneHandler(deviceIndex));
        }
コード例 #16
0
 public TestSceneOsuDistanceSnapGrid()
 {
     editorBeatmap = new EditorBeatmap(new OsuBeatmap());
 }
コード例 #17
0
 public void EndPlacement(HitObject hitObject)
 {
     EditorBeatmap.Add(hitObject);
     showGridFor(Enumerable.Empty <HitObject>());
 }
コード例 #18
0
        public void TestCreateNewDifficulty([Values] bool sameRuleset)
        {
            string firstDifficultyName  = Guid.NewGuid().ToString();
            string secondDifficultyName = Guid.NewGuid().ToString();

            AddStep("set unique difficulty name", () => EditorBeatmap.BeatmapInfo.DifficultyName = firstDifficultyName);
            AddStep("add timing point", () => EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint {
                BeatLength = 1000
            }));
            AddStep("add hitobjects", () => EditorBeatmap.AddRange(new[]
            {
                new HitCircle
                {
                    Position  = new Vector2(0),
                    StartTime = 0
                },
                new HitCircle
                {
                    Position  = OsuPlayfield.BASE_SIZE,
                    StartTime = 1000
                }
            }));

            AddStep("save beatmap", () => Editor.Save());
            AddAssert("new beatmap persisted", () =>
            {
                var beatmap = beatmapManager.QueryBeatmap(b => b.DifficultyName == firstDifficultyName);
                var set     = beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID);

                return(beatmap != null &&
                       beatmap.DifficultyName == firstDifficultyName &&
                       set != null &&
                       set.PerformRead(s => s.Beatmaps.Single().ID == beatmap.ID));
            });
            AddAssert("can save again", () => Editor.Save());

            AddStep("create new difficulty", () => Editor.CreateNewDifficulty(sameRuleset ? new OsuRuleset().RulesetInfo : new CatchRuleset().RulesetInfo));

            if (sameRuleset)
            {
                AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
                AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog.PerformOkAction());
            }

            AddUntilStep("wait for created", () =>
            {
                string difficultyName = Editor.ChildrenOfType <EditorBeatmap>().SingleOrDefault()?.BeatmapInfo.DifficultyName;
                return(difficultyName != null && difficultyName != firstDifficultyName);
            });

            AddAssert("created difficulty has timing point", () =>
            {
                var timingPoint = EditorBeatmap.ControlPointInfo.TimingPoints.Single();
                return(timingPoint.Time == 0 && timingPoint.BeatLength == 1000);
            });
            AddAssert("created difficulty has no objects", () => EditorBeatmap.HitObjects.Count == 0);

            AddStep("set unique difficulty name", () => EditorBeatmap.BeatmapInfo.DifficultyName = secondDifficultyName);
            AddStep("save beatmap", () => Editor.Save());
            AddAssert("new beatmap persisted", () =>
            {
                var beatmap = beatmapManager.QueryBeatmap(b => b.DifficultyName == secondDifficultyName);
                var set     = beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID);

                return(beatmap != null &&
                       beatmap.DifficultyName == secondDifficultyName &&
                       set != null &&
                       set.PerformRead(s => s.Beatmaps.Count == 2 && s.Beatmaps.Any(b => b.DifficultyName == secondDifficultyName)));
            });
        }
コード例 #19
0
 /// <summary>
 /// Removes a hit sample from all selected <see cref="HitObject"/>s.
 /// </summary>
 /// <param name="sampleName">The name of the hit sample.</param>
 public void RemoveHitSample(string sampleName)
 {
     EditorBeatmap.PerformOnSelection(h => h.SamplesBindable.RemoveAll(s => s.Name == sampleName));
 }
コード例 #20
0
        public void TestCopyDifficulty()
        {
            string originalDifficultyName = Guid.NewGuid().ToString();
            string copyDifficultyName     = $"{originalDifficultyName} (copy)";

            AddStep("set unique difficulty name", () => EditorBeatmap.BeatmapInfo.DifficultyName = originalDifficultyName);
            AddStep("add timing point", () => EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint {
                BeatLength = 1000
            }));
            AddStep("add hitobjects", () => EditorBeatmap.AddRange(new[]
            {
                new HitCircle
                {
                    Position  = new Vector2(0),
                    StartTime = 0
                },
                new HitCircle
                {
                    Position  = OsuPlayfield.BASE_SIZE,
                    StartTime = 1000
                }
            }));
            AddStep("set approach rate", () => EditorBeatmap.Difficulty.ApproachRate = 4);
            AddStep("set combo colours", () =>
            {
                var beatmapSkin = EditorBeatmap.BeatmapSkin.AsNonNull();
                beatmapSkin.ComboColours.Clear();
                beatmapSkin.ComboColours.AddRange(new[]
                {
                    new Colour4(255, 0, 0, 255),
                    new Colour4(0, 0, 255, 255)
                });
            });
            AddStep("set status & online ID", () =>
            {
                EditorBeatmap.BeatmapInfo.OnlineID = 123456;
                EditorBeatmap.BeatmapInfo.Status   = BeatmapOnlineStatus.WIP;
            });

            AddStep("save beatmap", () => Editor.Save());
            AddAssert("new beatmap persisted", () =>
            {
                var beatmap = beatmapManager.QueryBeatmap(b => b.DifficultyName == originalDifficultyName);
                var set     = beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID);

                return(beatmap != null &&
                       beatmap.DifficultyName == originalDifficultyName &&
                       set != null &&
                       set.PerformRead(s => s.Beatmaps.Single().ID == beatmap.ID));
            });
            AddAssert("can save again", () => Editor.Save());

            AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));

            AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
            AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog.Buttons.ElementAt(1).TriggerClick());

            AddUntilStep("wait for created", () =>
            {
                string difficultyName = Editor.ChildrenOfType <EditorBeatmap>().SingleOrDefault()?.BeatmapInfo.DifficultyName;
                return(difficultyName != null && difficultyName != originalDifficultyName);
            });

            AddAssert("created difficulty has copy suffix in name", () => EditorBeatmap.BeatmapInfo.DifficultyName == copyDifficultyName);
            AddAssert("created difficulty has timing point", () =>
            {
                var timingPoint = EditorBeatmap.ControlPointInfo.TimingPoints.Single();
                return(timingPoint.Time == 0 && timingPoint.BeatLength == 1000);
            });
            AddAssert("created difficulty has objects", () => EditorBeatmap.HitObjects.Count == 2);
            AddAssert("approach rate correctly copied", () => EditorBeatmap.Difficulty.ApproachRate == 4);
            AddAssert("combo colours correctly copied", () => EditorBeatmap.BeatmapSkin.AsNonNull().ComboColours.Count == 2);

            AddAssert("status not copied", () => EditorBeatmap.BeatmapInfo.Status == BeatmapOnlineStatus.None);
            AddAssert("online ID not copied", () => EditorBeatmap.BeatmapInfo.OnlineID == -1);

            AddStep("save beatmap", () => Editor.Save());

            BeatmapInfo           refetchedBeatmap    = null;
            Live <BeatmapSetInfo> refetchedBeatmapSet = null;

            AddStep("refetch from database", () =>
            {
                refetchedBeatmap    = beatmapManager.QueryBeatmap(b => b.DifficultyName == copyDifficultyName);
                refetchedBeatmapSet = beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID);
            });

            AddAssert("new beatmap persisted", () =>
            {
                return(refetchedBeatmap != null &&
                       refetchedBeatmap.DifficultyName == copyDifficultyName &&
                       refetchedBeatmapSet != null &&
                       refetchedBeatmapSet.PerformRead(s =>
                                                       s.Beatmaps.Count == 2 &&
                                                       s.Beatmaps.Any(b => b.DifficultyName == originalDifficultyName) &&
                                                       s.Beatmaps.Any(b => b.DifficultyName == copyDifficultyName)));
            });
            AddAssert("old beatmap file not deleted", () => refetchedBeatmapSet.AsNonNull().PerformRead(s => s.Files.Count == 2));
        }
コード例 #21
0
 public TestSceneEditorSummaryTimeline()
 {
     editorBeatmap = new EditorBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
 }
コード例 #22
0
 public TestSceneTimingScreen()
 {
     editorBeatmap = new EditorBeatmap(new OsuBeatmap());
 }
コード例 #23
0
 public void Delete(HitObject hitObject) => EditorBeatmap.Remove(hitObject);
コード例 #24
0
        protected override IEnumerable <MenuItem> GetContextMenuItemsForSelection(IEnumerable <SelectionBlueprint> selection)
        {
            if (selection.All(s => s.HitObject is Hit))
            {
                var hits = selection.Select(s => s.HitObject).OfType <Hit>();

                yield return(new TernaryStateMenuItem("Rim", action: state =>
                {
                    ChangeHandler.BeginChange();

                    foreach (var h in hits)
                    {
                        switch (state)
                        {
                        case TernaryState.True:
                            h.Type = HitType.Rim;
                            break;

                        case TernaryState.False:
                            h.Type = HitType.Centre;
                            break;
                        }
                    }

                    ChangeHandler.EndChange();
                })
                {
                    State = { Value = getTernaryState(hits, h => h.Type == HitType.Rim) }
                });
            }

            if (selection.All(s => s.HitObject is TaikoHitObject))
            {
                var hits = selection.Select(s => s.HitObject).OfType <TaikoHitObject>();

                yield return(new TernaryStateMenuItem("Strong", action: state =>
                {
                    ChangeHandler.BeginChange();

                    foreach (var h in hits)
                    {
                        switch (state)
                        {
                        case TernaryState.True:
                            h.IsStrong = true;
                            break;

                        case TernaryState.False:
                            h.IsStrong = false;
                            break;
                        }

                        EditorBeatmap?.UpdateHitObject(h);
                    }

                    ChangeHandler.EndChange();
                })
                {
                    State = { Value = getTernaryState(hits, h => h.IsStrong) }
                });
            }
        }