Ejemplo n.º 1
0
    public void UpdateTSValue(string value)
    {
        float prevValue = currentTS.numerator;
        uint  numerator = 0;
        bool  isValid   = uint.TryParse(value, out numerator);

        isValid &= numerator > 0;

        if (currentTS != null && isValid)
        {
            bool tentativeRecord, lockedRecord;
            ShouldRecordInputField(value, currentTS.numerator.ToString(), out tentativeRecord, out lockedRecord);

            if (!lockedRecord && tentativeRecord)
            {
                editor.commandStack.Pop();
            }

            if (tentativeRecord || lockedRecord)
            {
                TimeSignature newTs   = new TimeSignature(currentTS.tick, numerator, currentTS.denominator);
                var           command = new SongEditModify <TimeSignature>(currentTS, newTs);
                editor.commandStack.Push(command);
                editor.selectedObjectsManager.SelectSongObject(newTs, editor.currentSong.syncTrack);
            }
        }
    }
Ejemplo n.º 2
0
    void GenerateFixUpBPMAnchorCommands()
    {
        if (bpmAnchorFixup.Count > 0)
        {
            return;
        }

        Song song = ChartEditor.Instance.currentSong;
        var  bpms = song.bpms;

        tempAnchorFixupBPMs.Clear();
        tempAnchorFixupSynctrack.Clear();
        foreach (BPM bpm in bpms)
        {
            BPM clone = bpm.CloneAs <BPM>();
            tempAnchorFixupBPMs.Add(clone);
            tempAnchorFixupSynctrack.Add(clone);
        }

        // Fix up any anchors
        for (int i = 0; i < tempAnchorFixupBPMs.Count; ++i)
        {
            if (tempAnchorFixupBPMs[i].anchor != null && i > 0)
            {
                BPM anchorBPM   = tempAnchorFixupBPMs[i];
                BPM bpmToAdjust = tempAnchorFixupBPMs[i - 1];

                double deltaTime = (double)anchorBPM.anchor - Song.LiveTickToTime(bpmToAdjust.tick, song.resolution, tempAnchorFixupBPMs[0], tempAnchorFixupSynctrack);
                uint   newValue  = (uint)Mathf.Round((float)(TickFunctions.DisToBpm(bpmToAdjust.tick, anchorBPM.tick, deltaTime, song.resolution) * 1000.0d));

                if (deltaTime > 0 && newValue > 0)
                {
                    if (bpmToAdjust.value != newValue)
                    {
                        BPM original = bpmToAdjust.CloneAs <BPM>();
                        bpmToAdjust.value = newValue;

                        SongEditModify <BPM> command = new SongEditModify <BPM>(original, bpmToAdjust);
                        command.postExecuteEnabled = false;
                        bpmAnchorFixup.Add(command);
                    }
                }
            }
        }

        bpmAnchorFixupCommandsGenerated = true;
        tempAnchorFixupBPMs.Clear();
        tempAnchorFixupSynctrack.Clear();
    }
Ejemplo n.º 3
0
    public void IncreaseDenom()
    {
        float prevValue = currentTS.denominator;

        // Get the next highest power of 2
        uint pow = GetNextHigherPowOf2(currentTS.denominator);

        if (prevValue != pow)
        {
            TimeSignature newTs   = new TimeSignature(currentTS.tick, currentTS.numerator, pow);
            var           command = new SongEditModify <TimeSignature>(currentTS, newTs);
            editor.commandStack.Push(command);
            var selected = editor.selectedObjectsManager.SelectSongObject(newTs, editor.currentSong.timeSignatures);
            tsDenomValue.text = selected.denominator.ToString();
        }
    }
Ejemplo n.º 4
0
    void SetNewFlags(Starpower sp, Starpower.Flags newFlags)
    {
        if (sp.flags == newFlags)
        {
            return;
        }

        if (editor.toolManager.currentToolId == EditorObjectToolManager.ToolID.Cursor)
        {
            Starpower newSp = new Starpower(sp.tick, sp.length, newFlags);
            SongEditModify <Starpower> command = new SongEditModify <Starpower>(sp, newSp);
            editor.commandStack.Push(command);
        }
        else
        {
            // Updating sp tool parameters and visuals
            starpowerToolController.starpower.flags = newFlags;
            starpowerToolController.controller.SetDirty();
        }
    }
Ejemplo n.º 5
0
    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;
    }
 public SongEditModifyValidated(Note before, Note after) : base(after)
 {
     Debug.Assert(after.song == null, "Must add a new song object!");
     Debug.Assert(before.tick == after.tick, "Song object is being moved rather than modified!");
     Debug.Assert(SongEditModify <SongObject> .FindObjectToModify(before) != null, "Unable to find a song object to modify!");
 }