public void CompleteMoveAction() { SongEditAdd addAction = new SongEditAdd(movingSongObjects); fullCommands.Add(addAction); BatchedSongEditCommand moveAction = new BatchedSongEditCommand(fullCommands); editor.commandStack.Pop(); editor.commandStack.Push(moveAction); editor.selectedObjectsManager.TryFindAndSelectSongObjects(movingSongObjects); Reset(); }
public void CompleteMoveAction() { for (int i = 0; i < movingSongObjects.Count; ++i) { fullMovementCommands.Add(new SongEditAdd(movingSongObjects[i].Clone())); } BatchedSongEditCommand moveCommands = new BatchedSongEditCommand(fullMovementCommands); editor.commandStack.Pop(); editor.commandStack.Push(moveCommands); editor.FindAndSelectSongObjects(movingSongObjects); Reset(); }
public void Delete() { if (selectedObjectsManager.currentSelectedObjects.Count > 0) { SongEditCommand[] commands = new SongEditCommand[] { new SongEditDelete(selectedObjectsManager.currentSelectedObjects), }; BatchedSongEditCommand commandBatch = new BatchedSongEditCommand(commands); commandStack.Push(commandBatch); selectedObjectsManager.currentSelectedObject = null; groupSelect.reset(); } }
public void SetLyric(uint tick) { List <SongEditCommand> commands = new List <SongEditCommand>(); Event searchedLyricEvent = FindEvent(); if (searchedLyricEvent != null) { commands.Add(new SongEditDelete(searchedLyricEvent)); } Event newLyric = new Event(c_lyricPrefix + lyricInputField.text, tick); commands.Add(new SongEditAdd(newLyric)); BatchedSongEditCommand batchedCommands = new BatchedSongEditCommand(commands); ChartEditor.Instance.commandStack.Push(batchedCommands); lyricEvent = newLyric; Redraw(); }
// Paste the clipboard data into the chart, overwriting anything else in the process public void Paste(uint chartLocationToPaste) { //if (System.Windows.Forms.Clipboard.GetDataObject().GetFormats().Length > 0 && // !( // System.Windows.Forms.Clipboard.ContainsText(TextDataFormat.UnicodeText) && // System.Windows.Forms.Clipboard.ContainsText(TextDataFormat.Text) && // System.Windows.Forms.Clipboard.GetText() == "") // ) // Something else is pasted on the clipboard instead of Moonscraper stuff. // return; FileStream fs = null; clipboard = null; try { // Read clipboard data from a file instead of the actual clipboard because the actual clipboard doesn't work for whatever reason fs = new FileStream(CLIPBOARD_FILE_LOCATION, FileMode.Open); BinaryFormatter formatter = new BinaryFormatter(); clipboard = (Clipboard)formatter.Deserialize(fs); } catch (System.Exception e) { Logger.LogException(e, "Failed to read from clipboard file"); clipboard = null; } finally { if (fs != null) { fs.Close(); } else { Debug.LogError("Filestream when reading clipboard data failed to initialise"); } } if (Globals.applicationMode == Globals.ApplicationMode.Editor && clipboard != null && clipboard.data.Length > 0) { List <SongEditCommand> commands = new List <SongEditCommand>(); Rect collisionRect = clipboard.GetCollisionRect(chartLocationToPaste, editor.currentSong); if (clipboard.areaChartPosMin > clipboard.areaChartPosMax) { Debug.LogError("Clipboard minimum (" + clipboard.areaChartPosMin + ") is greater than clipboard the max (" + clipboard.areaChartPosMax + ")"); } uint colliderChartDistance = TickFunctions.TickScaling(clipboard.areaChartPosMax - clipboard.areaChartPosMin, clipboard.resolution, editor.currentSong.resolution); viewModeController.ToggleSongViewMode(!clipboard.data[0].GetType().IsSubclassOf(typeof(ChartObject))); { List <SongObject> newObjectsToDelete = new List <SongObject>(); // Overwrite any objects in the clipboard space if (clipboard.data[0].GetType().IsSubclassOf(typeof(ChartObject))) { foreach (ChartObject chartObject in editor.currentChart.chartObjects) { if (chartObject.tick >= chartLocationToPaste && chartObject.tick <= (chartLocationToPaste + colliderChartDistance) && PrefabGlobals.HorizontalCollisionCheck(PrefabGlobals.GetCollisionRect(chartObject), collisionRect)) { newObjectsToDelete.Add(chartObject); } } } else { // Overwrite synctrack, leave sections alone foreach (SyncTrack syncObject in editor.currentSong.syncTrack) { if (syncObject.tick >= chartLocationToPaste && syncObject.tick <= (chartLocationToPaste + colliderChartDistance) && PrefabGlobals.HorizontalCollisionCheck(PrefabGlobals.GetCollisionRect(syncObject), collisionRect)) { newObjectsToDelete.Add(syncObject); } } } if (newObjectsToDelete.Count > 0) { commands.Add(new SongEditDelete(newObjectsToDelete)); } } { uint maxLength = editor.currentSong.TimeToTick(editor.currentSong.length, editor.currentSong.resolution); List <SongObject> newObjectsToAddIn = new List <SongObject>(); // Paste the new objects in foreach (SongObject clipboardSongObject in clipboard.data) { SongObject objectToAdd = clipboardSongObject.Clone(); objectToAdd.tick = chartLocationToPaste + TickFunctions.TickScaling(clipboardSongObject.tick, clipboard.resolution, editor.currentSong.resolution) - TickFunctions.TickScaling(clipboard.areaChartPosMin, clipboard.resolution, editor.currentSong.resolution); if (objectToAdd.tick >= maxLength) { break; } if (objectToAdd.GetType() == typeof(Note)) { Note note = (Note)objectToAdd; if (clipboard.instrument == Song.Instrument.GHLiveGuitar || clipboard.instrument == Song.Instrument.GHLiveBass) { // Pasting from a ghl track if (!Globals.ghLiveMode) { if (note.ghliveGuitarFret == Note.GHLiveGuitarFret.Open) { note.guitarFret = Note.GuitarFret.Open; } else if (note.ghliveGuitarFret == Note.GHLiveGuitarFret.White3) { continue; } } } else if (Globals.ghLiveMode) { // Pasting onto a ghl track if (note.guitarFret == Note.GuitarFret.Open) { note.ghliveGuitarFret = Note.GHLiveGuitarFret.Open; } } note.length = TickFunctions.TickScaling(note.length, clipboard.resolution, editor.currentSong.resolution); } else if (objectToAdd.GetType() == typeof(Starpower)) { Starpower sp = (Starpower)objectToAdd; sp.length = TickFunctions.TickScaling(sp.length, clipboard.resolution, editor.currentSong.resolution); } newObjectsToAddIn.Add(objectToAdd); } if (newObjectsToAddIn.Count > 0) { commands.Add(new SongEditAdd(newObjectsToAddIn)); } } if (commands.Count > 0) { BatchedSongEditCommand batchedCommands = new BatchedSongEditCommand(commands); editor.commandStack.Push(batchedCommands); } } // 0 objects in clipboard, don't bother pasting }
public void StartMoveAction(IList <SongObject> songObjects, int anchorArrayPos, bool delete = false) { if (Mouse.world2DPosition != null) { initMousePos = (Vector2)Mouse.world2DPosition; } else { initMousePos = Vector2.zero; } Reset(); this.anchorArrayPos = anchorArrayPos; originalSongObjects.Clear(); movingSongObjects.Clear(); originalSongObjects.AddRange(songObjects); initObjectSnappedChartPos = objectSnappedChartPos; int lastNotePos = -1; for (int i = 0; i < songObjects.Count; ++i) { movingSongObjects.Add(songObjects[i].Clone()); initialDeleteCommands.Add(new SongEditDelete(songObjects[i])); fullMovementCommands.Add(new SongEditDelete(songObjects[i])); // Rebuild linked list if ((SongObject.ID)songObjects[i].classID == SongObject.ID.Note) { if (lastNotePos >= 0) { ((Note)movingSongObjects[i]).previous = ((Note)movingSongObjects[lastNotePos]); ((Note)movingSongObjects[lastNotePos]).next = ((Note)movingSongObjects[i]); } lastNotePos = i; } originalSongObjects[i].song = editor.currentSong; movingSongObjects[i].song = editor.currentSong; if (originalSongObjects[i].GetType().IsSubclassOf(typeof(ChartObject))) { ((ChartObject)originalSongObjects[i]).chart = editor.currentChart; ((ChartObject)movingSongObjects[i]).chart = editor.currentChart; } } Mouse.cancel = true; BatchedSongEditCommand batchedCommands = new BatchedSongEditCommand(initialDeleteCommands); editor.commandStack.Push(batchedCommands); notesToEnable.AddRange(movingSongObjects.OfType <Note>()); starpowerToEnable.AddRange(movingSongObjects.OfType <Starpower>()); chartEventsToEnable.AddRange(movingSongObjects.OfType <ChartEvent>()); bpmsToEnable.AddRange(movingSongObjects.OfType <BPM>()); timeSignaturesToEnable.AddRange(movingSongObjects.OfType <TimeSignature>().ToArray()); sectionsToEnable.AddRange(movingSongObjects.OfType <Section>().ToArray()); eventsToEnable.AddRange(movingSongObjects.OfType <Event>().ToArray()); editor.currentSelectedObject = null; }