protected virtual UndoRedoJumpInfo GetUndoRedoJumpInfo() { SongObject lowestTickSo = null; UndoRedoJumpInfo info = new UndoRedoJumpInfo(); foreach (SongObject songObject in songObjects) { if (lowestTickSo == null || songObject.tick < lowestTickSo.tick) { lowestTickSo = songObject; } } if (lowestTickSo != null) { info.jumpToPos = lowestTickSo.tick; info.viewMode = lowestTickSo.GetType().IsSubclassOf(typeof(ChartObject)) ? Globals.ViewMode.Chart : Globals.ViewMode.Song; } else { info.jumpToPos = null; } return(info); }
protected override UndoRedoJumpInfo GetUndoRedoJumpInfo() { SongObject lowestTickSo = null; SongObject highestTickSo = null; UndoRedoJumpInfo info = new UndoRedoJumpInfo(); foreach (SongEditCommand command in commands) { if (command.subActions.Count > 0) { foreach (BaseAction action in command.subActions) { SongObject so = action.songObject; if (lowestTickSo == null || so.tick < lowestTickSo.tick) { lowestTickSo = so; } if (highestTickSo == null || so.tick > highestTickSo.tick) { highestTickSo = so; } } } else { foreach (SongObject so in command.GetSongObjects()) { if (lowestTickSo == null || so.tick < lowestTickSo.tick) { lowestTickSo = so; } if (highestTickSo == null || so.tick > highestTickSo.tick) { highestTickSo = so; } } } } if (lowestTickSo != null) { info.jumpToPos = lowestTickSo.tick; info.viewMode = lowestTickSo.GetType().IsSubclassOf(typeof(ChartObject)) ? Globals.ViewMode.Chart : Globals.ViewMode.Song; info.min = lowestTickSo.tick; } else { info.jumpToPos = null; } if (highestTickSo != null) { info.max = highestTickSo.tick; } return(info); }
void PostExecuteUpdate(bool isInvoke) { if (!postExecuteEnabled) { return; } ChartEditor editor = ChartEditor.Instance; UndoRedoJumpInfo jumpInfo = GetUndoRedoJumpInfo(); if (!bpmAnchorFixupCommandsGenerated) { GenerateFixUpBPMAnchorCommands(); } if (!cannotBeForcedFixupCommandsGenerated) { GenerateForcedFlagFixupCommands(jumpInfo); } if (isInvoke) { foreach (ICommand command in bpmAnchorFixup) { command.Invoke(); } foreach (ICommand command in forcedFlagFixup) { command.Invoke(); } } editor.currentChart.UpdateCache(); editor.currentSong.UpdateCache(); if (editor.toolManager.currentToolId != EditorObjectToolManager.ToolID.Note) { editor.selectedObjectsManager.currentSelectedObject = null; } ChartEditor.isDirty = true; if (jumpInfo.IsValid) { editor.FillUndoRedoSnapInfo(jumpInfo.jumpToPos.Value, jumpInfo.viewMode); } editor.selectedObjectsManager.TryFindAndSelectSongObjects(selectedSongObjects); selectedSongObjects.Clear(); }
void GenerateForcedFlagFixupCommands(UndoRedoJumpInfo jumpInfo) { Chart chart = ChartEditor.Instance.currentChart; if (chart.chartObjects.Count <= 0) { return; } int index, length; SongObjectHelper.GetRange(chart.chartObjects, jumpInfo.min.GetValueOrDefault(0), jumpInfo.max.GetValueOrDefault(0), out index, out length); Note lastCheckedNote = null; for (int i = index; i < index + length; ++i) { if (chart.chartObjects[i].classID == (int)SongObject.ID.Note) { Note note = chart.chartObjects[i] as Note; if ((note.flags & Note.Flags.Forced) != 0 && note.cannotBeForced) { foreach (Note chordNote in note.chord) { Note modifiedNote = new Note(chordNote); modifiedNote.flags &= ~Note.Flags.Forced; SongEditModify <Note> command = new SongEditModify <Note>(chordNote, modifiedNote); command.postExecuteEnabled = false; forcedFlagFixup.Add(command); } } lastCheckedNote = note; } } // Do last final check for next note that may not have been included in the range if (lastCheckedNote != null) { Note note = lastCheckedNote.nextSeperateNote; if (note != null && (note.flags & Note.Flags.Forced) != 0 && note.cannotBeForced) { foreach (Note chordNote in note.chord) { Note modifiedNote = new Note(chordNote); modifiedNote.flags &= ~Note.Flags.Forced; SongEditModify <Note> command = new SongEditModify <Note>(chordNote, modifiedNote); command.postExecuteEnabled = false; forcedFlagFixup.Add(command); } } } // Get the note to start on, then we will traverse the linked list /* * Note currentNote = null; * for (int i = 0; i < chart.chartObjects.Count; ++i) * { * Note note = chart.chartObjects[i] as Note; * if (note != null) * { * Note prev = note.previousSeperateNote; * if (prev != null) * { * currentNote = prev; * } * else * { * currentNote = note; * } * } * } * * while (currentNote != null) * { * if ((currentNote.flags & Note.Flags.Forced) != 0 && currentNote.cannotBeForced) * { * foreach (Note chordNote in currentNote.chord) * { * Note modifiedNote = new Note(chordNote); * modifiedNote.flags &= ~Note.Flags.Forced; * * SongEditModify<Note> command = new SongEditModify<Note>(chordNote, modifiedNote); * command.postExecuteEnabled = false; * forcedFlagFixup.Add(command); * } * } * * currentNote = currentNote.nextSeperateNote; * }*/ cannotBeForcedFixupCommandsGenerated = true; }