コード例 #1
0
ファイル: SelectionHandler.cs プロジェクト: tangalbert919/osu
        /// <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)
        {
            ChangeHandler?.BeginChange();

            foreach (var h in SelectedHitObjects)
            {
                h.SamplesBindable.RemoveAll(s => s.Name == sampleName);
            }

            ChangeHandler?.EndChange();
        }
コード例 #2
0
ファイル: SelectionHandler.cs プロジェクト: tangalbert919/osu
        private void deleteSelected()
        {
            ChangeHandler?.BeginChange();

            foreach (var h in selectedBlueprints.ToList())
            {
                EditorBeatmap?.Remove(h.HitObject);
            }

            ChangeHandler?.EndChange();
        }
コード例 #3
0
        public void SetRimState(bool state)
        {
            var hits = SelectedHitObjects.OfType <Hit>();

            ChangeHandler.BeginChange();

            foreach (var h in hits)
            {
                h.Type = state ? HitType.Rim : HitType.Centre;
            }

            ChangeHandler.EndChange();
        }
コード例 #4
0
        public void SetStrongState(bool state)
        {
            var hits = SelectedHitObjects.OfType <Hit>();

            ChangeHandler.BeginChange();

            foreach (var h in hits)
            {
                h.IsStrong = state;
            }

            ChangeHandler.EndChange();
        }
コード例 #5
0
        public void SetStrongState(bool state)
        {
            var hits = SelectedHitObjects.OfType <Hit>();

            ChangeHandler.BeginChange();

            foreach (var h in hits)
            {
                if (h.IsStrong != state)
                {
                    h.IsStrong = state;
                    EditorBeatmap.UpdateHitObject(h);
                }
            }

            ChangeHandler.EndChange();
        }
コード例 #6
0
ファイル: SelectionHandler.cs プロジェクト: tangalbert919/osu
        /// <summary>
        /// Set the new combo state of all selected <see cref="HitObject"/>s.
        /// </summary>
        /// <param name="state">Whether to set or unset.</param>
        /// <exception cref="InvalidOperationException">Throws if any selected object doesn't implement <see cref="IHasComboInformation"/></exception>
        public void SetNewCombo(bool state)
        {
            ChangeHandler?.BeginChange();

            foreach (var h in SelectedHitObjects)
            {
                var comboInfo = h as IHasComboInformation;

                if (comboInfo == null)
                {
                    throw new InvalidOperationException($"Tried to change combo state of a {h.GetType()}, which doesn't implement {nameof(IHasComboInformation)}");
                }

                comboInfo.NewCombo = state;
                EditorBeatmap?.UpdateHitObject(h);
            }

            ChangeHandler?.EndChange();
        }
コード例 #7
0
ファイル: SelectionHandler.cs プロジェクト: tangalbert919/osu
        /// <summary>
        /// Adds a hit sample to all selected <see cref="HitObject"/>s.
        /// </summary>
        /// <param name="sampleName">The name of the hit sample.</param>
        public void AddHitSample(string sampleName)
        {
            ChangeHandler?.BeginChange();

            foreach (var h in SelectedHitObjects)
            {
                // Make sure there isn't already an existing sample
                if (h.Samples.Any(s => s.Name == sampleName))
                {
                    continue;
                }

                h.Samples.Add(new HitSampleInfo {
                    Name = sampleName
                });
            }

            ChangeHandler?.EndChange();
        }
コード例 #8
0
ファイル: SelectionHandler.cs プロジェクト: ef1500/osu
        /// <summary>
        /// Set the new combo state of all selected <see cref="HitObject"/>s.
        /// </summary>
        /// <param name="state">Whether to set or unset.</param>
        /// <exception cref="InvalidOperationException">Throws if any selected object doesn't implement <see cref="IHasComboInformation"/></exception>
        public void SetNewCombo(bool state)
        {
            ChangeHandler?.BeginChange();

            foreach (var h in SelectedHitObjects)
            {
                var comboInfo = h as IHasComboInformation;

                if (comboInfo == null || comboInfo.NewCombo == state)
                {
                    continue;
                }

                comboInfo.NewCombo = state;
                EditorBeatmap?.UpdateHitObject(h);
            }

            ChangeHandler?.EndChange();
        }
コード例 #9
0
ファイル: SelectionHandler.cs プロジェクト: neoayi/osu
 private void deleteSelected()
 {
     ChangeHandler?.BeginChange();
     EditorBeatmap?.RemoveRange(selectedBlueprints.Select(b => b.HitObject));
     ChangeHandler?.EndChange();
 }
コード例 #10
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) }
                });
            }
        }