Example #1
0
        /// <summary>
        ///     Adds a HitObject sprite to the container.
        /// </summary>
        public void AddHitObjectSprite(HitObjectInfo h)
        {
            DrawableEditorHitObject hitObject;

            var skin  = SkinManager.Skin.Keys[Ruleset.WorkingMap.Mode];
            var index = skin.ColorObjectsBySnapDistance ? HitObjectManager.GetBeatSnap(h, h.GetTimingPoint(Ruleset.WorkingMap.TimingPoints)) : 0;

            if (h.IsLongNote)
            {
                if (ConfigManager.EditorViewLayers.Value)
                {
                    hitObject = new DrawableEditorHitObjectLong(this, h,
                                                                skin.EditorLayerNoteHitObjects[h.Lane - 1],
                                                                skin.EditorLayerNoteHoldBodies[h.Lane - 1],
                                                                skin.EditorLayerNoteHoldEnds[h.Lane - 1]);
                }
                else
                {
                    hitObject = new DrawableEditorHitObjectLong(this, h,
                                                                skin.NoteHoldHitObjects[h.Lane - 1][index],
                                                                skin.NoteHoldBodies[h.Lane - 1].First(),
                                                                skin.NoteHoldEnds[h.Lane - 1]);
                }
            }
            else
            {
                if (ConfigManager.EditorViewLayers.Value)
                {
                    hitObject = new DrawableEditorHitObject(this, h, skin.EditorLayerNoteHitObjects[h.Lane - 1]);
                }
                else
                {
                    hitObject = new DrawableEditorHitObject(this, h, skin.NoteHitObjects[h.Lane - 1][index]);
                }
            }

            hitObject.Alignment = Alignment.TopLeft;
            hitObject.X         = ScreenRectangle.X + LaneSize * (h.Lane - 1) + DividerLineWidth;
            hitObject.Width     = LaneSize - DividerLineWidth;

            // Make sure the width of the long note is updated if this object is indeed an LN.
            if (hitObject is DrawableEditorHitObjectLong longNote)
            {
                longNote.Body.Width = hitObject.Width;
                longNote.Tail.Width = hitObject.Width;
            }

            hitObject.AppearAsActive();

            // Check if the layer is hidden that the user is adding the object to and display the object
            // as that appropriate colour.
            if (((EditorScreenView)Ruleset.Screen.View).LayerCompositor.ScrollContainer.AvailableItems[hitObject.Info.EditorLayer].Hidden)
            {
                hitObject.AppearAsHiddenInLayer();
            }

            lock (HitObjects)
                HitObjects.Add(hitObject);
        }
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public void Perform()
        {
            var skin = SkinManager.Skin.Keys[WorkingMap.Mode];

            foreach (var h in HitObjects)
            {
                h.Info.Lane = WorkingMap.GetKeyCount() - h.Info.Lane + 1;
                h.X         = Container.ScreenRectangle.X + Container.LaneSize * (h.Info.Lane - 1) + Container.DividerLineWidth;

                var index = skin.ColorObjectsBySnapDistance ? HitObjectManager.GetBeatSnap(h.Info, h.Info.GetTimingPoint(WorkingMap.TimingPoints)) : 0;

                if (h.Info.IsLongNote)
                {
                    var ln = (DrawableEditorHitObjectLong)h;

                    if (ConfigManager.EditorViewLayers.Value)
                    {
                        h.Image       = skin.EditorLayerNoteHitObjects[h.Info.Lane - 1];
                        ln.Body.Image = skin.EditorLayerNoteHoldBodies[h.Info.Lane - 1];
                        ln.Tail.Image = skin.EditorLayerNoteHoldEnds[h.Info.Lane - 1];
                    }
                    else
                    {
                        h.Image       = skin.NoteHoldHitObjects[h.Info.Lane - 1][index];
                        ln.Body.Image = skin.NoteHoldBodies[h.Info.Lane - 1].First();
                        ln.Tail.Image = skin.NoteHoldEnds[h.Info.Lane - 1];
                    }

                    ln.ResizeLongNote();
                }
                else
                {
                    if (ConfigManager.EditorViewLayers.Value)
                    {
                        h.Image = skin.EditorLayerNoteHitObjects[h.Info.Lane - 1];
                    }
                    else
                    {
                        h.Image = skin.NoteHitObjects[h.Info.Lane - 1][index];
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnEditorUseLayerHitObjects(object sender, BindableValueChangedEventArgs <bool> e)
        {
            lock (HitObjects)
            {
                var skin = SkinManager.Skin.Keys[Ruleset.Screen.WorkingMap.Mode];

                HitObjects.ForEach(h =>
                {
                    var index = skin.ColorObjectsBySnapDistance ?
                                HitObjectManager.GetBeatSnap(h.Info, h.Info.GetTimingPoint(Ruleset.Screen.WorkingMap.TimingPoints)) : 0;

                    if (h.Info.IsLongNote)
                    {
                        var ln = (DrawableEditorHitObjectLong)h;

                        if (ConfigManager.EditorViewLayers.Value)
                        {
                            h.Image = skin.EditorLayerNoteHitObjects[h.Info.Lane - 1];
                            ln.ChangeTextures(skin.EditorLayerNoteHoldBodies[h.Info.Lane - 1], skin.EditorLayerNoteHoldEnds[h.Info.Lane - 1]);
                        }
                        else
                        {
                            h.Image = skin.NoteHoldHitObjects[h.Info.Lane - 1][index];
                            ln.ChangeTextures(skin.NoteHoldBodies[h.Info.Lane - 1].First(), skin.NoteHoldEnds[h.Info.Lane - 1]);
                        }
                    }
                    else
                    {
                        if (ConfigManager.EditorViewLayers.Value)
                        {
                            h.Image = skin.EditorLayerNoteHitObjects[h.Info.Lane - 1];
                        }
                        else
                        {
                            h.Image = skin.NoteHitObjects[h.Info.Lane - 1][index];
                        }
                    }

                    // Resize and reposition the object to support skins that are of different sizes.
                    h.SetHeight();
                    h.SetPositionY();
                    h.Resize();

                    // Reset back to an active state temporarily because any objects that don't
                    // fit the following cases are considered active still.
                    h.AppearAsActive();

                    // Get the layer the object is in
                    var view  = (EditorScreenView)Ruleset.Screen.View;
                    var layer = view.LayerCompositor.ScrollContainer.AvailableItems[h.Info.EditorLayer];

                    if (Ruleset.SelectedHitObjects.Contains(h))
                    {
                        h.AppearAsSelected();
                    }
                    else if (Ruleset.PendingLongNoteReleases.Contains(h.Info))
                    {
                        var ln = h as DrawableEditorHitObjectLong;
                        ln?.AppearAsInactive();
                    }
                    else if (layer.Hidden)
                    {
                        h.AppearAsHiddenInLayer();
                    }
                });
            }
        }