Exemple #1
0
    public void PreviewToggle()
    {
        _previewing = !_previewing;

        // Disable UI
        foreach (GameObject go in disableDuringPreview)
        {
            go.SetActive(!_previewing);
        }

        // Set chart view mode
        Globals.viewMode = Globals.ViewMode.Chart;

        if (_previewing)
        {
            // Record the current position
            initialPosition = editor.visibleStrikeline.position.y;

            // Move to the start of the chart
            editor.movement.SetTime(-3);

            // Play
            editor.Play();
        }
        else
        {
            // Stop
            editor.Stop();

            // Restore to initial position
            editor.movement.SetTime(TickFunctions.WorldYPositionToTime(initialPosition));
        }
    }
    void Update()
    {
        if (Input.GetMouseButtonDown(2))
        {
            middleClickDownScreenPos = Input.mousePosition;
        }
        else if (!Input.GetMouseButton(2) && middleClickDownScreenPos.HasValue)
        {
            middleClickDownScreenPos = null;
            Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
        }

        if (Input.GetMouseButtonUp(0) && editor.currentState == ChartEditor.State.Editor)
        {
            cancel = false;
        }

        if (Services.IsInDropDown)
        {
            cancel = true;
        }

        // Update timer text
        if (timePosition)
        {
            bool audioLoaded = false;
            foreach (var stream in editor.currentSongAudio.bassAudioStreams)
            {
                if (AudioManager.StreamIsValid(stream))
                {
                    audioLoaded = true;
                }
            }

            if (!audioLoaded)//editor.currentSong.songAudioLoaded)
            {
                timePosition.color = Color.red;
                timePosition.text  = "No audio";
            }
            else
            {
                timePosition.color = Color.white;
                timePosition.text  = Utility.timeConvertion(TickFunctions.WorldYPositionToTime(strikeLine.position.y));
            }
        }

        if (MSChartEditorInput.GetGroupInputDown(arrowKeyShortcutGroup))
        {
            arrowMoveTimer = 0;
        }
        else if (MSChartEditorInput.GetGroupInput(arrowKeyShortcutGroup))
        {
            arrowMoveTimer += Time.deltaTime;
        }
        else
        {
            arrowMoveTimer = 0;
        }
    }
Exemple #3
0
    public void StartGameplay()
    {
        if (currentState == State.Playing ||
            movement.transform.position.y < movement.initPos.y ||
            Globals.ghLiveMode)
        {
            return;
        }

        float strikelineYPos = visibleStrikeline.position.y;
        float?stopResetTime  = null;

        songObjectPoolManager.noteVisibilityRangeYPosOverride = strikelineYPos;

        if (GameSettings.resetAfterGameplay)
        {
            stopResetTime = currentVisibleTime;
        }

        // Set position x seconds beforehand
        float startTime = TickFunctions.WorldYPositionToTime(strikelineYPos) - GameSettings.gameplayStartDelayTime - (0.01f * GameSettings.hyperspeed); // Offset to prevent errors where it removes a note that is on the strikeline

        movement.SetTime(startTime);

        GameSettings.bot = false;

        // Hide everything behind the strikeline
        foreach (Note note in currentChart.notes)
        {
            if (note.controller)
            {
                if (note.worldYPosition < strikelineYPos)
                {
                    note.controller.HideFullNote();
                }
                else
                {
                    break;
                }
            }
        }

        foreach (HitAnimation hitAnim in indicators.animations)
        {
            hitAnim.StopAnim();
        }

        SystemManagerState playingState = new PlayingState(startTime, stopResetTime);

        PopulatePersistentSystemsForNewState(State.Playing, playingState);
        ChangeState(State.Playing, playingState);
    }
Exemple #4
0
    public void PlayingMovement()
    {
        float   speed          = GameSettings.hyperspeed;
        Vector3 pos            = transform.position;
        float   deltaTime      = Time.deltaTime;
        float   positionOffset = initPos.y;

        {
            float timeBeforeMovement = TickFunctions.WorldYPositionToTime(pos.y - positionOffset);
            float timeAfterMovement  = timeBeforeMovement + deltaTime * GameSettings.gameSpeed;

            // Make sure we're staying in sync with the audio
            {
                SongAudioManager songAudioManager = editor.currentSongAudio;

                AudioStream stream = null;

                for (int i = 0; i < EnumX <Song.AudioInstrument> .Count; ++i)
                {
                    Song.AudioInstrument audio = (Song.AudioInstrument)i;
                    if (AudioManager.StreamIsValid(songAudioManager.GetAudioStream(audio)))
                    {
                        stream = songAudioManager.GetAudioStream(audio);
                        break;
                    }
                }

                if (AudioManager.StreamIsValid(stream) && stream.IsPlaying())
                {
                    float audioTimePosition = stream.CurrentPositionInSeconds() - editor.services.totalSongAudioOffset;
                    float desyncAmount      = audioTimePosition - timeAfterMovement;

                    if (Mathf.Abs(desyncAmount) > DESYNCLENIENCE)
                    {
                        timeAfterMovement += desyncAmount;
                    }
                }
            }

            float maxChangeInTimeAllowed = Application.targetFrameRate > 0 ? 2.0f / Application.targetFrameRate : 1.0f / 120.0f;

            float totalChangeInTime = timeAfterMovement - timeBeforeMovement;

            float newTimePosition = TickFunctions.TimeToWorldYPosition(timeBeforeMovement + totalChangeInTime);
            pos.y = newTimePosition + positionOffset;
        }

        selfTransform.position = pos;
        explicitChartPos       = null;

        lastUpdatedRealTime = Time.time;
    }
    public override void OnSelectableMouseDrag()
    {
        // Move object
        if (bpm.tick != 0)
        {
            base.OnSelectableMouseDrag();
        }

        if (draggingInitialBpm != null && MSE.Input.KeyboardDevice.ctrlKeyBeingPressed && Input.GetMouseButton(1))
        {
            BPM previousBpm = SongObjectHelper.GetPreviousNonInclusive(bpm.song.bpms, bpm.tick);
            if (previousBpm != null && previousBpm.anchor == null)
            {
                float desiredWorldPos;
                if (editor.services.mouseMonitorSystem.world2DPosition != null && ((Vector2)editor.services.mouseMonitorSystem.world2DPosition).y < editor.mouseYMaxLimit.position.y)
                {
                    desiredWorldPos = ((Vector2)editor.services.mouseMonitorSystem.world2DPosition).y;
                }
                else
                {
                    desiredWorldPos = editor.mouseYMaxLimit.position.y;
                }

                float desiredTime = TickFunctions.WorldYPositionToTime(desiredWorldPos);
                if (desiredTime < previousBpm.time)
                {
                    desiredTime = previousBpm.time;
                }

                BPM nextBpm = SongObjectHelper.GetNextNonInclusive(bpm.song.bpms, bpm.tick);
                if (nextBpm != null && nextBpm.anchor != null && desiredTime >= nextBpm.time)
                {
                    desiredTime = nextBpm.time - 0.01f;
                }

                double disToBpm    = TickFunctions.DisToBpm(previousBpm.tick, bpm.tick, desiredTime - previousBpm.time, bpm.song.resolution);
                uint   newBpmValue = (uint)Mathf.Ceil((float)disToBpm * 1000.0f);
                if (newBpmValue > 0)
                {
                    if (hasPushed)
                    {
                        editor.commandStack.Pop();
                    }

                    editor.commandStack.Push(new SongEditModify <BPM>(previousBpm, new BPM(previousBpm.tick, newBpmValue, previousBpm.anchor)));
                    hasPushed = true;
                }
            }
        }
    }
    void Update()
    {
        if (Input.GetMouseButtonUp(0) && Globals.applicationMode == Globals.ApplicationMode.Editor)
        {
            cancel = false;
        }

        if (Services.IsInDropDown)
        {
            cancel = true;
        }

        // Update timer text
        if (timePosition)
        {
            bool audioLoaded = false;
            foreach (var stream in editor.currentSong.bassAudioStreams)
            {
                if (AudioManager.StreamIsValid(stream))
                {
                    audioLoaded = true;
                }
            }

            if (!audioLoaded)//editor.currentSong.songAudioLoaded)
            {
                timePosition.color = Color.red;
                timePosition.text  = "No audio";
            }
            else
            {
                timePosition.color = Color.white;
                timePosition.text  = Utility.timeConvertion(TickFunctions.WorldYPositionToTime(strikeLine.position.y));
            }
        }

        if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.PageUp) || Input.GetKeyDown(KeyCode.PageDown))
        {
            arrowMoveTimer = 0;
        }
        else if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.PageUp) || Input.GetKey(KeyCode.PageDown))
        {
            arrowMoveTimer += Time.deltaTime;
        }
        else
        {
            arrowMoveTimer = 0;
        }
    }
Exemple #7
0
    public override void OnSelectableMouseDrag()
    {
        // Move object
        if (bpm.tick != 0)
        {
            base.OnSelectableMouseDrag();
        }

        if (draggingInitialBpm != null && ShortcutInput.modifierInput && Input.GetMouseButton(1))
        {
            BPM previousBpm = SongObjectHelper.GetPreviousNonInclusive(bpm.song.bpms, bpm.tick);
            if (previousBpm != null && previousBpm.anchor == null)
            {
                float desiredWorldPos;
                if (Mouse.world2DPosition != null && ((Vector2)Mouse.world2DPosition).y < editor.mouseYMaxLimit.position.y)
                {
                    desiredWorldPos = ((Vector2)Mouse.world2DPosition).y;
                }
                else
                {
                    desiredWorldPos = editor.mouseYMaxLimit.position.y;
                }

                float desiredTime = TickFunctions.WorldYPositionToTime(desiredWorldPos);
                if (desiredTime < previousBpm.time)
                {
                    desiredTime = previousBpm.time;
                }

                BPM nextBpm = SongObjectHelper.GetNextNonInclusive(bpm.song.bpms, bpm.tick);
                if (nextBpm != null && nextBpm.anchor != null && desiredTime >= nextBpm.time)
                {
                    desiredTime = nextBpm.time - 0.01f;
                }

                uint newBpmValue = (uint)(Mathf.Ceil((float)TickFunctions.DisToBpm(previousBpm.tick, bpm.tick, desiredTime - previousBpm.time, bpm.song.resolution)) * 1000);
                if (newBpmValue > 0)
                {
                    previousBpm.value = newBpmValue;
                }

                editor.songObjectPoolManager.SetAllPoolsDirty();
                ChartEditor.isDirty = true;
                editor.currentSong.UpdateCache();
                editor.FixUpBPMAnchors();
            }
        }
    }
Exemple #8
0
    void UpdateWaveformPointsFullData()
    {
        if (currentSample.data.Length <= 0 || currentSample == null)
        {
            return;
        }

        float     sampleRate = currentSample.length / currentSample.data.Length; // currentClip.samples / currentClip.length;
        float     scaling    = 1;
        const int iteration  = 1;                                                // 20;
        int       channels   = 1;                                                // currentSample.channels;
        float     fullOffset = -editor.currentSong.offset;

        // Determine what points of data to draw
        int startPos = timeToArrayPos(TickFunctions.WorldYPositionToTime(editor.camYMin.position.y) - fullOffset, iteration, channels, currentSample.length);
        int endPos   = timeToArrayPos(TickFunctions.WorldYPositionToTime(editor.camYMax.position.y) - fullOffset, iteration, channels, currentSample.length);

        Vector3[] points = new Vector3[endPos - startPos];
#if false
        if (currentSample.clip > 0)
        {
            scaling = (MAX_SCALE / currentSample.clip);
        }
#endif

        // Turn data into world-position points to feed the line renderer
        Vector3 point             = Vector3.zero;
        float[] currentSampleData = currentSample.data;
        float   hs = GameSettings.hyperspeed / GameSettings.gameSpeed;

        for (int i = startPos; i < endPos; ++i)
        {
            point.x = currentSampleData[i] * scaling;

            // Manual inlining of Song.TimeToWorldYPosition
            float time = i * sampleRate + fullOffset;
            point.y = time * hs;

            points[i - startPos] = point;
        }

        lineRen.numPositions = points.Length;
        lineRen.SetPositions(points);
    }
Exemple #9
0
    public void StartGameplay()
    {
        if (Globals.applicationMode == Globals.ApplicationMode.Playing ||
            movement.transform.position.y < movement.initPos.y ||
            Globals.ghLiveMode)
        {
            return;
        }

        if (GameSettings.resetAfterGameplay)
        {
            stopResetPos = movement.transform.position;
        }

        float strikelineYPos = visibleStrikeline.position.y - (0.01f * GameSettings.hyperspeed);     // Offset to prevent errors where it removes a note that is on the strikeline

        startGameplayPos = strikelineYPos;

        // Hide everything behind the strikeline
        foreach (Note note in currentChart.notes)
        {
            if (note.controller)
            {
                if (note.worldYPosition < strikelineYPos)
                {
                    note.controller.HideFullNote();
                }
                else
                {
                    break;
                }
            }
        }

        // Set position x seconds beforehand
        float time = TickFunctions.WorldYPositionToTime(strikelineYPos);

        movement.SetTime(time - GameSettings.gameplayStartDelayTime);

        GameSettings.bot = false;
        Play();
    }
Exemple #10
0
 public uint WorldYPositionToTick(float worldYPos, float resolution)
 {
     return(TimeToTick(TickFunctions.WorldYPositionToTime(worldYPos), resolution));
 }