// Update is called once per frame
    protected override void Update()
    {
        note.chart = editor.currentChart;
        base.Update();

        // Get previous and next note
        int pos = SongObjectHelper.FindClosestPosition(note.tick, editor.currentChart.notes);

        //Debug.Log(pos);
        if (pos == SongObjectHelper.NOTFOUND)
        {
            note.previous = null;
            note.next     = null;
        }
        else
        {
            if (note.IsOpenNote())
            {
                UpdateOpenPrevAndNext(pos);
            }
            else
            {
                UpdatePrevAndNext(pos);
            }
        }

        UpdateFretType();
    }
    void HighlightCurrentSection(SongObjectSelectedManipFn manipFn, Globals.ViewMode viewMode, int sectionOffset = 0)
    {
        // Get the previous and next section
        uint currentPos      = editor.currentTickPos;
        var  sections        = editor.currentSong.sections;
        int  maxSectionIndex = 0;

        while (maxSectionIndex < sections.Count && !(sections[maxSectionIndex].tick > currentPos))
        {
            ++maxSectionIndex;
        }

        maxSectionIndex += sectionOffset;

        uint rangeMin = (maxSectionIndex - 1) >= 0 ? sections[maxSectionIndex - 1].tick : 0;
        uint rangeMax = maxSectionIndex < sections.Count ? sections[maxSectionIndex].tick : uint.MaxValue;

        if (rangeMax > 0)
        {
            --rangeMax;
        }

        if (viewMode == Globals.ViewMode.Chart)
        {
            manipFn(SongObjectHelper.GetRangeCopy(editor.currentChart.chartObjects.ToArray(), rangeMin, rangeMax));
        }
        else
        {
            manipFn(SongObjectHelper.GetRangeCopy(editor.currentSong.syncTrack.ToArray(), rangeMin, rangeMax));
            manipFn(SongObjectHelper.GetRangeCopy(editor.currentSong.eventsAndSections.ToArray(), rangeMin, rangeMax));
        }
    }
Exemple #3
0
 void AddToSelection(IEnumerable <ChartObject> chartObjects)
 {
     // Insertion sort
     foreach (ChartObject chartObject in chartObjects)
     {
         if (!data.Contains(chartObject))
         {
             int pos = SongObjectHelper.FindClosestPosition(chartObject, data.ToArray());
             if (pos != SongObjectHelper.NOTFOUND)
             {
                 if (data[pos] > chartObject)
                 {
                     data.Insert(pos, chartObject);
                 }
                 else
                 {
                     data.Insert(pos + 1, chartObject);
                 }
             }
             else
             {
                 data.Add(chartObject);
             }
         }
     }
 }
Exemple #4
0
    protected override void Controls()
    {
        if (!GameSettings.keysModeEnabled)
        {
            if (Toolpane.currentTool == Toolpane.Tools.Timesignature && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0))
            {
                RecordAddActionHistory(ts, editor.currentSong.timeSignatures);

                AddObject();
            }
        }
        else if (ShortcutInput.GetInputDown(Shortcut.AddSongObject))
        {
            SongObject[] searchArray = editor.currentSong.syncTrack;
            int          pos         = SongObjectHelper.FindObjectPosition(ts, searchArray);
            if (pos == SongObjectHelper.NOTFOUND)
            {
                editor.actionHistory.Insert(new ActionHistory.Add(ts));
                AddObject();
            }
            else if (searchArray[pos].tick != 0)
            {
                editor.actionHistory.Insert(new ActionHistory.Delete(searchArray[pos]));
                searchArray[pos].Delete();
                editor.currentSelectedObject = null;
            }
        }
    }
Exemple #5
0
 protected override void Controls()
 {
     if (!Globals.gameSettings.keysModeEnabled)
     {
         if (Input.GetMouseButtonDown(0))
         {
             Section sectionSearched = sectionSearch(section.tick);
             if (sectionSearched == null)
             {
                 AddObject();
             }
             else
             {
                 editor.selectedObjectsManager.currentSelectedObject = sectionSearched;
             }
         }
     }
     else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.AddSongObject))
     {
         var searchArray = editor.currentSong.sections;
         int pos         = SongObjectHelper.FindObjectPosition(section, searchArray);
         if (pos == SongObjectHelper.NOTFOUND)
         {
             AddObject();
         }
         else
         {
             editor.commandStack.Push(new SongEditDelete(searchArray[pos]));
             editor.selectedObjectsManager.currentSelectedObject = null;
         }
     }
 }
Exemple #6
0
 protected override void Controls()
 {
     if (!GameSettings.keysModeEnabled)
     {
         if (Toolpane.currentTool == Toolpane.Tools.SongEvent && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0))
         {
             int pos = SongObjectHelper.FindObjectPosition(songEvent, editor.currentSong.events);
             if (pos == SongObjectHelper.NOTFOUND)
             {
                 AddObject();
             }
             // Link to the event already in
             else
             {
                 editor.currentSelectedObject = editor.currentSong.events[pos];
             }
         }
     }
     else if (ShortcutInput.GetInputDown(Shortcut.AddSongObject))
     {
         var searchArray = editor.currentSong.events;
         int pos         = SongObjectHelper.FindObjectPosition(songEvent, searchArray);
         if (pos == SongObjectHelper.NOTFOUND)
         {
             AddObject();
         }
         else
         {
             editor.commandStack.Push(new SongEditDelete(searchArray[pos]));
             editor.currentSelectedObject = null;
         }
     }
 }
    public void AddAndInvokeSubActions(SongObject songObject, IList <BaseAction> subActions)
    {
        Note note = songObject as Note;
        Note next = null;

        if (note != null)
        {
            var chartObjects = ChartEditor.Instance.currentChart.chartObjects;
            int arrayPos     = SongObjectHelper.FindObjectPosition(note, chartObjects);
            if (arrayPos != SongObjectHelper.NOTFOUND)
            {
                Note foundNote = chartObjects[arrayPos] as Note;
                if (foundNote != null)
                {
                    next = foundNote.nextSeperateNote;
                }
            }
        }

        AddAndInvokeSubAction(new DeleteAction(songObject), subActions);

        if (next != null)
        {
            GeneratePostDeleteSubActions(next, subActions);
        }
    }
    public void AddToSelectedObjects(IEnumerable <SongObject> songObjects)
    {
        var selectedObjectsList = new List <SongObject>(currentSelectedObjects);

        foreach (SongObject songObject in songObjects)
        {
            if (!selectedObjectsList.Contains(songObject))
            {
                int pos = SongObjectHelper.FindClosestPosition(songObject, selectedObjectsList);
                if (pos != SongObjectHelper.NOTFOUND)
                {
                    if (selectedObjectsList[pos] > songObject)
                    {
                        selectedObjectsList.Insert(pos, songObject);
                    }
                    else
                    {
                        selectedObjectsList.Insert(pos + 1, songObject);
                    }
                }
                else
                {
                    selectedObjectsList.Add(songObject);
                }
            }
        }

        currentSelectedObjects = selectedObjectsList;
    }
    // Should be called once the physics system has settled down
    void Init()
    {
        ChartEditor editor = ChartEditor.Instance;

        Debug.Assert(!hitWindowFeeder.enabled);
        hitWindowFeeder.enabled = true;

        if (botEnabled)
        {
            // We want the bot to automatically hit any sustains that are currently active in the view, but for which the notes are already past the strikeline
            Song  song        = editor.currentSong;
            float currentTime = editor.currentVisibleTime;
            uint  currentTick = song.TimeToTick(currentTime, song.resolution);
            int   index       = SongObjectHelper.FindClosestPositionRoundedDown(currentTick, editor.currentChart.notes);
            if (index != SongObjectHelper.NOTFOUND)
            {
                Note        note         = editor.currentChart.notes[index];
                List <Note> sustainNotes = new List <Note>();
                NoteFunctions.GetPreviousOfSustains(sustainNotes, note, GameSettings.extendedSustainsEnabled);

                foreach (Note chordNote in note.chord)
                {
                    sustainNotes.Add(chordNote);
                }
                foreach (Note sustainNote in sustainNotes)
                {
                    if (sustainNote.controller != null)
                    {
                        hitWindowFeeder.TryAddNote(sustainNote.controller);
                    }
                }
            }
        }
    }
Exemple #10
0
    void CollectStarpowerInViewRange(IList <Starpower> starpowers)
    {
        collectedStarpowerInRange.Clear();
        int index, length;

        SongObjectHelper.GetRange(starpowers, editor.minPos, editor.maxPos, out index, out length);
        for (int i = index; i < index + length; ++i)
        {
            collectedStarpowerInRange.Add(starpowers[i]);
        }

        int arrayPos = SongObjectHelper.FindClosestPosition(editor.minPos, editor.currentChart.starPower);

        if (arrayPos != SongObjectHelper.NOTFOUND)
        {
            // Find the back-most position
            while (arrayPos > 0 && editor.currentChart.starPower[arrayPos].tick >= editor.minPos)
            {
                --arrayPos;
            }
            // Render previous sp sustain in case of overlap into current position
            if (arrayPos >= 0 && editor.currentChart.starPower[arrayPos].tick + editor.currentChart.starPower[arrayPos].length > editor.minPos &&
                (editor.currentChart.starPower[arrayPos].tick + editor.currentChart.starPower[arrayPos].length) < editor.maxPos)
            {
                collectedStarpowerInRange.Add(editor.currentChart.starPower[arrayPos]);
            }
        }
    }
Exemple #11
0
    public void EnableChartEvents(IList <ChartEvent> events)
    {
        int index, length;

        SongObjectHelper.GetRange(events, editor.minPos, editor.maxPos, out index, out length);
        chartEventPool.Activate(events, index, length);
    }
 protected override void Controls()
 {
     if (!GameSettings.keysModeEnabled)
     {
         if (Input.GetMouseButtonDown(0))
         {
             int pos = SongObjectHelper.FindObjectPosition(chartEvent, editor.currentChart.events);
             if (pos == SongObjectHelper.NOTFOUND)
             {
                 AddObject();
             }
             // Link to the event already in
             else
             {
                 editor.selectedObjectsManager.currentSelectedObject = editor.currentChart.events[pos];
             }
         }
     }
     else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.AddSongObject))
     {
         var searchArray = editor.currentChart.events;
         int pos         = SongObjectHelper.FindObjectPosition(chartEvent, searchArray);
         if (pos == SongObjectHelper.NOTFOUND)
         {
             AddObject();
         }
         else
         {
             editor.commandStack.Push(new SongEditDelete(searchArray[pos]));
             editor.selectedObjectsManager.currentSelectedObject = null;
         }
     }
 }
 protected override void Controls()
 {
     if (!GameSettings.keysModeEnabled)
     {
         if (Toolpane.currentTool == Toolpane.Tools.Section && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0))
         {
             Section sectionSearched = sectionSearch(section.tick);
             if (sectionSearched == null)
             {
                 AddObject();
             }
             else
             {
                 editor.currentSelectedObject = sectionSearched;
             }
         }
     }
     else if (ShortcutInput.GetInputDown(Shortcut.AddSongObject))
     {
         var searchArray = editor.currentSong.sections;
         int pos         = SongObjectHelper.FindObjectPosition(section, searchArray);
         if (pos == SongObjectHelper.NOTFOUND)
         {
             AddObject();
         }
         else
         {
             editor.commandStack.Push(new SongEditDelete(searchArray[pos]));
             editor.currentSelectedObject = null;
         }
     }
 }
Exemple #14
0
    static void TryDeleteSongObject <T>(T songObject, IList <T> arrayToSearch) where T : SongObject
    {
        int arrayPos = SongObjectHelper.FindObjectPosition(songObject, arrayToSearch);

        if (arrayPos != SongObjectHelper.NOTFOUND)
        {
            T foundSongObject = arrayToSearch[arrayPos];

            Note next = null;
            if ((SongObject.ID)foundSongObject.classID == SongObject.ID.Note)
            {
                next = (foundSongObject as Note).nextSeperateNote;
            }

            foundSongObject.Delete(false);

            if (next != null)
            {
                foreach (Note chordNote in next.chord)
                {
                    if (chordNote.controller)
                    {
                        chordNote.controller.SetDirty();
                    }
                }
            }
        }
        else
        {
            Debug.LogError("Delete SongObject command cannot find a song object to delete!");
        }
    }
Exemple #15
0
    void UpdateBeatLines4()
    {
        int measurePoolPos = 0, beatPoolPos = 0, quarterPoolPos = 0;

        Song song           = editor.currentSong;
        uint startRange     = song.WorldPositionToSnappedTick(editor.camYMin.position.y, 8);
        uint endRange       = editor.maxPos;
        var  timeSignatures = editor.currentSong.timeSignatures;
        int  startIndex     = SongObjectHelper.FindClosestPositionRoundedDown(startRange, timeSignatures);

        for (int tsIndex = startIndex; tsIndex < timeSignatures.Count && timeSignatures[tsIndex].tick <= endRange; ++tsIndex)
        {
            TimeSignature ts = timeSignatures[tsIndex];

            uint nextTSTick = tsIndex + 1 < timeSignatures.Count ? timeSignatures[tsIndex + 1].tick : endRange;

            TimeSignature.MeasureInfo measureInfo = ts.GetMeasureInfo();

            measurePoolPos += RenderBeatLines(ts, measureInfo.measureLine, measureLinePool, measurePoolPos, startRange, endRange, nextTSTick);
            beatPoolPos    += RenderBeatLines(ts, measureInfo.beatLine, beatLinePool, beatPoolPos, startRange, endRange, nextTSTick);
            quarterPoolPos += RenderBeatLines(ts, measureInfo.quarterBeatLine, quarterBeatLinePool, quarterPoolPos, startRange, endRange, nextTSTick);
        }

        DisableBeatLines(measurePoolPos, measureLinePool);
        DisableBeatLines(beatPoolPos, beatLinePool);
        DisableBeatLines(quarterPoolPos, quarterBeatLinePool);
    }
    void FillNotesKeyboardControlsBurstMode(LaneInfo laneInfo)
    {
        int  keysPressed = 0;
        int  laneCount   = laneInfo.laneCount;
        bool isTyping    = Services.IsTyping;

        if (isTyping)
        {
            return;
        }

        for (int i = 0; i < laneCount + 1; ++i)
        {
            int index = i;

            bool isOpenInput = index >= laneCount;
            if (isOpenInput && keysPressed > 0)           // Prevents open notes while holding other keys
            {
                continue;
            }

            int inputOnKeyboard = index + 1;
            if (Input.GetKey(NumToStringLUT[inputOnKeyboard]) && !inputBlock[index])
            {
                ++keysPressed;
                int notePos = index;

                if (isOpenInput)
                {
                    notePos = allPlaceableNotes.IndexOf(openNote);
                }

                LeftyFlipReflectionCheck(ref notePos, laneCount);

                allPlaceableNotes[notePos].ExplicitUpdate();
                int pos = SongObjectHelper.FindObjectPosition(allPlaceableNotes[notePos].note, editor.currentChart.notes);

                if (currentPlacementMode == KeysPlacementMode.None)
                {
                    currentPlacementMode = pos == SongObjectHelper.NOTFOUND ? KeysPlacementMode.Adding : KeysPlacementMode.Deleting;
                }

                if (currentPlacementMode == KeysPlacementMode.Adding && pos == SongObjectHelper.NOTFOUND)
                {
                    Debug.Log("Adding note");
                    currentlyAddingNotes.Add(allPlaceableNotes[notePos].note.Clone());
                }
                else if (Input.GetKeyDown(NumToStringLUT[inputOnKeyboard]) && currentPlacementMode == KeysPlacementMode.Deleting)
                {
                    Debug.Log("Removed " + editor.currentChart.notes[pos].rawNote + " note at position " + editor.currentChart.notes[pos].tick + " using keyboard controls");
                    currentlyAddingNotes.Add(editor.currentChart.notes[pos]);
                    inputBlock[index] = true;
                }
            }
            else if (!Input.GetKey(NumToStringLUT[(index + 1)]))
            {
                inputBlock[index] = false;
            }
        }
    }
    protected new void LateUpdate()
    {
        base.LateUpdate();

        // Re-do the controller's position setting
        var events = editor.currentSong.events;

        int offset = 0;
        int index, length;

        SongObjectHelper.GetRange(events, songEvent.tick, songEvent.tick, out index, out length);

        // Determine the offset for the object
        for (int i = index; i < index + length; ++i)
        {
            if (events[i].GetType() != songEvent.GetType())
            {
                continue;
            }

            offset += EventController.OFFSET_SPACING;
        }

        transform.position = new Vector3(SongObjectController.CHART_CENTER_POS + EventController.position + offset, songEvent.worldYPosition, 0);
    }
    public static void PerformPreChartInsertCorrections(Note note, Chart chart, IList <BaseAction> subActions, bool extendedSustainsEnabled)
    {
        int index, length;

        SongObjectHelper.GetRange(chart.chartObjects, note.tick, note.tick, out index, out length);

        // Account for when adding an exact note as what's already in
        if (length > 0)
        {
            for (int i = index + length - 1; i >= index; --i)
            {
                Note overwriteNote = chart.chartObjects[i] as Note;
                if (overwriteNote == null)
                {
                    continue;
                }

                bool sameFret = note.guitarFret == overwriteNote.guitarFret;
                bool isOverwritableOpenNote = (note.IsOpenNote() || overwriteNote.IsOpenNote()) && !Globals.drumMode;
                if (isOverwritableOpenNote || sameFret)
                {
                    SongEditCommand.AddAndInvokeSubAction(new DeleteAction(overwriteNote), subActions);
                }
            }
        }
    }
Exemple #19
0
    public void EnableSongEvents(IList <MoonscraperChartEditor.Song.Event> events)
    {
        int index, length;

        SongObjectHelper.GetRange(events, editor.minPos, editor.maxPos, out index, out length);
        songEventPool.Activate(events, index, length);
    }
Exemple #20
0
    static void AddBPM(BPM bpm, IList <BaseAction> subActions)
    {
        ChartEditor editor = ChartEditor.Instance;
        Song        song   = editor.currentSong;

        TryRecordOverwrite(bpm, editor.currentSong.syncTrack, subActions);

        AddAndInvokeSubAction(new AddAction(bpm), subActions);
        if (bpm.anchor != null)
        {
            int arrayPos = SongObjectHelper.FindObjectPosition(bpm, song.syncTrack);
            if (arrayPos != SongObjectHelper.NOTFOUND)
            {
                BPM justAdded = song.syncTrack[arrayPos] as BPM;
                if (justAdded == null)
                {
                    UnityEngine.Debug.LogError("Object just added was not a bpm");
                }
                else
                {
                    float anchorValue = justAdded.song.LiveTickToTime(justAdded.tick, justAdded.song.resolution);
                    BPM   newBpm      = new BPM(bpm.tick, bpm.value, anchorValue);

                    AddAndInvokeSubAction(new DeleteAction(justAdded), subActions);
                    AddAndInvokeSubAction(new AddAction(newBpm), subActions);
                }
            }
            else
            {
                UnityEngine.Debug.LogError("Unable to find bpm that was just added");
            }
        }
    }
Exemple #21
0
    static void AddNote(Note note, IList <BaseAction> subActions, bool extendedSustainsEnabled)
    {
        ChartEditor editor = ChartEditor.Instance;
        Chart       chart  = editor.currentChart;
        Song        song   = editor.currentSong;

        NoteFunctions.PerformPreChartInsertCorrections(note, chart, subActions, extendedSustainsEnabled);
        AddAndInvokeSubAction(new AddAction(note), subActions);

        int arrayPos = SongObjectHelper.FindObjectPosition(note, chart.chartObjects);

        if (arrayPos != SongObjectHelper.NOTFOUND)
        {
            Note justAdded = chart.chartObjects[arrayPos] as Note;
            if (justAdded == null)
            {
                UnityEngine.Debug.LogError("Object just added was not a note");
            }
            else
            {
                NoteFunctions.PerformPostChartInsertCorrections(justAdded, subActions, extendedSustainsEnabled);
            }
        }
        else
        {
            UnityEngine.Debug.LogError("Unable to find note that was just added");
        }
    }
Exemple #22
0
    public static float GetOffset(ChartEditor editor, ChartEvent chartEvent)
    {
        var events = editor.currentChart.events;

        int offset = 0;
        int index, length;

        SongObjectHelper.GetRange(events, chartEvent.tick, chartEvent.tick, out index, out length);

        // Determine the offset for the object
        for (int i = index; i < index + length; ++i)
        {
            if (events[i].GetType() != chartEvent.GetType())
            {
                continue;
            }

            if (events[i] < chartEvent)
            {
                offset += OFFSET_SPACING;
            }
        }

        return(offset);
    }
Exemple #23
0
    public void EnableSections(IList <Section> sections)
    {
        int index, length;

        SongObjectHelper.GetRange(sections, editor.minPos, editor.maxPos, out index, out length);
        sectionPool.Activate(sections, index, length);
    }
    protected new void LateUpdate()
    {
        // Re-do the controller's position setting
        base.LateUpdate();

        var events = editor.currentChart.events;

        float offset = ChartEventController.BASE_OFFSET;
        int   index, length;

        SongObjectHelper.GetRange(events, chartEvent.tick, chartEvent.tick, out index, out length);

        // Determine the offset for the object
        for (int i = index; i < index + length; ++i)
        {
            if (events[i].GetType() != chartEvent.GetType())
            {
                continue;
            }

            offset += ChartEventController.OFFSET_SPACING;
        }

        transform.position = new Vector3(SongObjectController.CHART_CENTER_POS + ChartEventController.position, chartEvent.worldYPosition, offset);
    }
Exemple #25
0
    void KeyboardControlsBurstMode(LaneInfo laneInfo)
    {
        int  keysPressed = 0;
        int  laneCount   = laneInfo.laneCount;
        bool isTyping    = Services.IsTyping;

        if (isTyping)
        {
            return;
        }

        for (int i = 0; i < laneCount + 1; ++i)
        {
            int index = i;
            if (index + 1 >= laneCount && keysPressed > 0)           // Prevents open notes while holding other keys
            {
                continue;
            }

            int inputOnKeyboard = index + 1;
            if (Input.GetKey(inputOnKeyboard.ToString()) && !inputBlock[index])
            {
                ++keysPressed;
                int notePos = index;

                if (Input.GetKey(GetOpenNoteInputKey(laneCount)))
                {
                    notePos = allPlaceableNotes.IndexOf(openNote);
                }

                LeftyFlipReflectionCheck(ref notePos, laneCount);

                allPlaceableNotes[notePos].ExplicitUpdate();
                int pos = SongObjectHelper.FindObjectPosition(allPlaceableNotes[notePos].note, editor.currentChart.notes);

                if (pos == SongObjectHelper.NOTFOUND)
                {
                    Debug.Log("Not found");
                    keysBurstAddHistory.AddRange(PlaceNote.AddObjectToCurrentChart((Note)allPlaceableNotes[notePos].note.Clone(), editor));
                }
                else if (Input.GetKeyDown(inputOnKeyboard.ToString()))
                {
                    editor.actionHistory.Insert(new ActionHistory.Delete(editor.currentChart.notes[pos]));
                    Debug.Log("Removed " + editor.currentChart.notes[pos].rawNote + " note at position " + editor.currentChart.notes[pos].tick + " using keyboard controls");
                    editor.currentChart.notes[pos].Delete();
                    inputBlock[index] = true;
                }
            }
            else if (!Input.GetKey((index + 1).ToString()))
            {
                inputBlock[index] = false;
            }
        }

        if (keysPressed == 0)
        {
            BurstRecordingInsertCheck(keysBurstAddHistory);
        }
    }
Exemple #26
0
    // Calculate the beat lines directly from the time signature positions themselves
    void UpdateBeatLines3()
    {
        int measurePoolPos = 0, beatPoolPos = 0, quarterPoolPos = 0;

        Song song                       = editor.currentSong;
        uint startRange                 = song.WorldPositionToSnappedTick(editor.camYMin.position.y, 8);
        uint endRange                   = editor.maxPos;
        var  timeSignatures             = editor.currentSong.timeSignatures;
        uint standardMeasureLengthTicks = (uint)(Song.RESOLUTIONS_PER_MEASURE * song.resolution);

        int startIndex = SongObjectHelper.FindClosestPositionRoundedDown(startRange, timeSignatures);

        for (int tsIndex = startIndex; tsIndex < timeSignatures.Count && timeSignatures[tsIndex].tick <= endRange; ++tsIndex)
        {
            TimeSignature ts            = timeSignatures[tsIndex];
            uint          nextTick      = ts.tick;
            uint          nextTSTick    = tsIndex + 1 < timeSignatures.Count ? timeSignatures[tsIndex + 1].tick : endRange;
            float         beatDeltaTick = standardMeasureLengthTicks / ts.beatsPerMeasure;

            uint startDeltaFromTSTick = startRange > ts.tick ? (startRange - ts.tick) : 0;
            int  quarterLineIndex     = (int)Mathf.Round((float)(startDeltaFromTSTick) / beatDeltaTick); // Jump to the next reasonable line index rather than looping until we get there
            if (quarterLineIndex > 0)
            {
                --quarterLineIndex;
            }

            while (nextTick < nextTSTick && nextTick <= endRange)
            {
                uint currentTick   = nextTick;
                bool tickIsMeasure = quarterLineIndex % ts.quarterNotesPerMeasure == 0;

                if (currentTick >= startRange && currentTick < nextTSTick && currentTick <= endRange)
                {
                    if (tickIsMeasure)
                    {
                        SetBeatLinePosition(currentTick, measureLinePool, ref measurePoolPos);
                    }
                    else
                    {
                        SetBeatLinePosition(currentTick, beatLinePool, ref beatPoolPos);
                    }
                }

                nextTick = ts.tick + (uint)Mathf.Round(beatDeltaTick * (++quarterLineIndex));

                uint tickDelta   = nextTick - currentTick;
                uint newPosition = currentTick + tickDelta / 2;

                if (newPosition >= startRange && newPosition < nextTSTick && newPosition <= endRange)
                {
                    SetBeatLinePosition(newPosition, quarterBeatLinePool, ref quarterPoolPos);
                }
            }
        }

        DisableBeatLines(measurePoolPos, measureLinePool);
        DisableBeatLines(beatPoolPos, beatLinePool);
        DisableBeatLines(quarterPoolPos, quarterBeatLinePool);
    }
    public T SelectSongObject <T>(T songObject, IList <T> arrToSearch) where T : SongObject
    {
        int insertionIndex = SongObjectHelper.FindObjectPosition(songObject, arrToSearch);

        Debug.Assert(insertionIndex != SongObjectHelper.NOTFOUND, "Failed to find songObject to highlight");
        currentSelectedObject = arrToSearch[insertionIndex];
        return(currentSelectedObject as T);
    }
Exemple #28
0
    public void EnableBPM(IList <BPM> bpms)
    {
        int index, length;

        SongObjectHelper.GetRange(bpms, editor.minPos, editor.maxPos, out index, out length);

        bpmPool.Activate(bpms, index, length);
    }
Exemple #29
0
    public void EnableTS(IList <TimeSignature> timeSignatures)
    {
        int index, length;

        SongObjectHelper.GetRange(timeSignatures, editor.minPos, editor.maxPos, out index, out length);

        tsPool.Activate(timeSignatures, index, length);
    }
    protected override void AddObject()
    {
        editor.commandStack.Push(new SongEditAdd(new Starpower(starpower)));

        int insertionIndex = SongObjectHelper.FindObjectPosition(starpower, editor.currentChart.starPower);

        Debug.Assert(insertionIndex != SongObjectHelper.NOTFOUND, "Song event failed to be inserted?");
        lastPlacedSP = editor.currentChart.starPower[insertionIndex];
    }