예제 #1
0
 private void AttemptToSelect()
 {
     if (highlightedIndex >= EventGridOffset)
     {
         int gridOffset = highlightedIndex - EventGridOffset;                                  //Take the difference
         gridOffset = BeatmapEventContainer.ModifiedTypeToEventType(gridOffset);               //And turn from modified to event type
         BeatmapObjectContainer highlighting = events.LoadedContainers.Where(
             (BeatmapObjectContainer x) => x.objectData._time >= atsc.CurrentBeat - 1 / 64f && //Check time, within a small margin
             x.objectData._time <= atsc.CurrentBeat + 1 / 64f &&                               //Check time, within a small margin
             (x.objectData as MapEvent)._type == gridOffset                                    //Check type against what we calculated earlier
             ).FirstOrDefault();
         if (highlighting != null)
         {
             SelectOrDeselect(highlighting);
         }
     }
     else //For the notes grid, check notes first then obstacles.
     {
         BeatmapObjectContainer highlighting = notes.LoadedContainers.Where(
             (BeatmapObjectContainer x) => x.objectData._time >= atsc.CurrentBeat - 1 / 64f && //Check time, within a small margin
             x.objectData._time <= atsc.CurrentBeat + 1 / 64f &&                               //Check time, within a small margin
             (x.objectData as BeatmapNote)._lineIndex == highlightedIndex &&                   //Check index
             (x.objectData as BeatmapNote)._lineLayer == highlightedLayer                      //Check layer
             ).FirstOrDefault();                                                               //Grab first instance (Or null if there is none)
         if (highlighting != null)
         {
             SelectOrDeselect(highlighting);
         }
         else
         {
             highlighting = obstacles.LoadedContainers.Where((BeatmapObjectContainer x) =>
                                                             (x.objectData as BeatmapObstacle)._lineIndex <= highlightedIndex &&                                                  //If it's between the left side
                                                             (x.objectData as BeatmapObstacle)._lineIndex + ((x.objectData as BeatmapObstacle)._width - 1) >= highlightedIndex && //...and the right
                                                             (x.objectData as BeatmapObstacle)._duration + x.objectData._time >= atsc.CurrentBeat &&                              //If it's between the end point in time
                                                             x.objectData._time <= atsc.CurrentBeat &&                                                                            //...and the beginning point in time
                                                             (x.objectData as BeatmapObstacle)._type == wallType                                                                  //And, for good measure, if they match types.
                                                             ).FirstOrDefault();
             if (highlighting != null)
             {
                 SelectOrDeselect(highlighting);
             }
         }
     }
 }
예제 #2
0
 public void ShiftSelection(int leftRight, int upDown)
 {
     foreach (BeatmapObjectContainer con in SelectedObjects)
     {
         if (con is BeatmapNoteContainer note)
         {
             if (note.mapNoteData._lineIndex >= 1000)
             {
                 note.mapNoteData._lineIndex += Mathf.RoundToInt((1f / atsc.gridMeasureSnapping) * 1000 * leftRight);
                 if (note.mapNoteData._lineIndex < 1000)
                 {
                     note.mapNoteData._lineIndex = 1000;
                 }
             }
             else if (note.mapNoteData._lineIndex <= -1000)
             {
                 note.mapNoteData._lineIndex += Mathf.RoundToInt((1f / atsc.gridMeasureSnapping) * 1000 * leftRight);
                 if (note.mapNoteData._lineIndex > -1000)
                 {
                     note.mapNoteData._lineIndex = -1000;
                 }
             }
             else
             {
                 note.mapNoteData._lineIndex += leftRight;
             }
             note.mapNoteData._lineLayer += upDown;
         }
         else if (con is BeatmapObstacleContainer obstacle)
         {
             if (obstacle.obstacleData._lineIndex >= 1000)
             {
                 obstacle.obstacleData._lineIndex += Mathf.RoundToInt((1f / atsc.gridMeasureSnapping) * 1000 * leftRight);
                 if (obstacle.obstacleData._lineIndex < 1000)
                 {
                     obstacle.obstacleData._lineIndex = 1000;
                 }
             }
             else if (obstacle.obstacleData._lineIndex <= -1000)
             {
                 obstacle.obstacleData._lineIndex += Mathf.RoundToInt((1f / atsc.gridMeasureSnapping) * 1000 * leftRight);
                 if (obstacle.obstacleData._lineIndex > -1000)
                 {
                     obstacle.obstacleData._lineIndex = -1000;
                 }
             }
             else
             {
                 obstacle.obstacleData._lineIndex += leftRight;
             }
             obstacle.obstacleData._time += ((1f / atsc.gridMeasureSnapping) * upDown);
         }
         else if (con is BeatmapEventContainer e)
         {
             e.eventData._time += ((1f / atsc.gridMeasureSnapping) * upDown);
             if (eventPlacement.objectContainerCollection.RingPropagationEditing)
             {
                 int pos = -1 + leftRight;
                 if (con.objectData._customData != null && con.objectData._customData["_propID"].IsNumber)
                 {
                     pos = (con.objectData?._customData["_propID"]?.AsInt ?? -1) + leftRight;
                 }
                 if (e.eventData._type != MapEvent.EVENT_TYPE_RING_LIGHTS)
                 {
                     e.UpdateAlpha(0);
                     pos = -1;
                 }
                 else
                 {
                     if (pos < -1)
                     {
                         pos = -1;
                     }
                     if (pos > 14)
                     {
                         pos = 14;
                     }
                 }
                 con.transform.localPosition = new Vector3(pos + 0.5f, 0.5f, con.transform.localPosition.z);
                 if (pos == -1)
                 {
                     con.objectData._customData?.Remove("_propID");
                 }
                 else
                 {
                     con.objectData._customData["_propID"] = pos;
                 }
             }
             else
             {
                 if (e.eventData._customData != null && e.eventData._customData["_propID"] != null)
                 {
                     e.eventData._customData["_propID"] = e.eventData._customData["_propID"].AsInt + leftRight;
                 }
                 int modified = BeatmapEventContainer.EventTypeToModifiedType(e.eventData._type);
                 modified += leftRight;
                 if (modified < 0)
                 {
                     modified = 0;
                 }
                 if (modified > 15)
                 {
                     modified = 15;
                 }
                 e.eventData._type = BeatmapEventContainer.ModifiedTypeToEventType(modified);
                 e.RefreshAppearance();
                 if (e.eventData.IsRotationEvent || e.eventData._type - leftRight == MapEvent.EVENT_TYPE_LATE_ROTATION ||
                     e.eventData._type - leftRight == MapEvent.EVENT_TYPE_EARLY_ROTATION)
                 {
                     tracksManager.RefreshTracks();
                 }
             }
         }
         con.UpdateGridPosition();
         if (eventPlacement.objectContainerCollection.RingPropagationEditing)
         {
             eventPlacement.objectContainerCollection.RingPropagationEditing = eventPlacement.objectContainerCollection.RingPropagationEditing;
         }
     }
     RefreshMap();
 }