public static BeatMapData ConvertBSDataToEditorData(BeatSaberJSONClass fromBeatSaber)
        {
            BeatMapData bmd = new BeatMapData();

            bmd.beatsPerMinute = fromBeatSaber.info.beatsPerMinute;
            bmd.mapArtist      = fromBeatSaber.info.authorName;
            bmd.songArtist     = fromBeatSaber.info.songSubName;
            bmd.songName       = fromBeatSaber.info.songName;
            bmd.songOffset     = fromBeatSaber.info.difficultyLevels[0].offset / 100;
            List <NoteDetails> notes = new List <NoteDetails>();

            foreach (BSNote bsNote in fromBeatSaber.level._notes)
            {
                NoteDetails note = new NoteDetails();
                if (bsNote._type == 0)
                {
                    note.color = Note.NoteColor.LEFT;
                }
                else
                {
                    note.color = Note.NoteColor.RIGHT;
                }
                note.slashDirection = BSNote.GetSlashDirection(bsNote._cutDirection);
                note.gridPosition   = new Vector2(bsNote._lineIndex, bsNote._lineLayer);
                note.timeToSpawn    = bsNote._time;
                notes.Add(note);
            }
            bmd.notes = notes.ToArray();
            return(bmd);
        }
Esempio n. 2
0
 public void LoadSelectedMap()
 {
     SetCurrentState(EditorState.PlaybackLoad);
     Debug.LogWarning("Loading selected map");
     string[] location = flatMenu.GetSelectedMapFullPath();
     json        = LoadFromDisk(location[0], location[1], location[2]);
     beatMapData = BeatSaberJSONClass.ConvertBSDataToEditorData(json);
     // Load from disk continues from update method when audio is loaded //
 }
Esempio n. 3
0
        public static void AddNoteChange(NoteDetails change)
        {
            int noteIndex = BeatMapData.GetNoteWithSamePosition(change, notes);

            if (noteIndex > -1)
            {
                changes.Add(notes[noteIndex]);
            }
        }
Esempio n. 4
0
 private void StartNewMap(int songOffset, float bpm, string fullPathToAudio,
                          string songArtist, string mapArtist, string songName, BeatSaveDifficulty difficulty,
                          string songFileName)
 {
     Debug.LogWarning("Selectednewsong - " + songFileName);
     SetCurrentState(EditorState.StartNewMapLoad);
     BeatMap.currentDifficulty = difficulty;
     beatMapData = BeatMapData.GenerateBMDInfo(mapArtist, songArtist, songName
                                               , songOffset, bpm, difficulty, songFileName);
     song           = Utilities.StartAudioInitialize(fullPathToAudio);
     audioIsLoading = true;
 }
Esempio n. 5
0
 public static BeatMapData CopyBMDNotNotes(BeatMapData target, BeatMapData source)
 {
     target.beatsPerMinute = source.beatsPerMinute;
     target.difficulty     = source.difficulty;
     target.mapArtist      = source.mapArtist;
     target.mapName        = source.mapName;
     target.songArtist     = source.songArtist;
     target.songName       = source.songName;
     target.songOffset     = source.songOffset;
     target.songFileName   = source.songFileName;
     return(target);
 }
Esempio n. 6
0
        public static BeatMapData GenerateBMDInfo(string mapArtist, string songArtist, string songName,
                                                  int songOffset, float bpm, BeatSaveDifficulty difficulty, string songFileName)
        {
            BeatMapData data = new BeatMapData();

            data.mapArtist      = mapArtist;
            data.songArtist     = songArtist;
            data.songFileName   = songFileName;
            data.songName       = songName;
            data.songOffset     = songOffset;
            data.beatsPerMinute = bpm;
            data.difficulty     = difficulty;
            return(data);
        }
        public static BeatSaberJSONClass ConvertUnityDataToBSData(BeatMapData data)
        {
            BeatSaberJSONClass bsaberJSON = new BeatSaberJSONClass();

            bsaberJSON.info = new InfoJSON();
            bsaberJSON.info.beatsPerMinute = (int)data.beatsPerMinute;
            bsaberJSON.info.authorName     = data.mapArtist;
            bsaberJSON.info.songSubName    = data.songArtist;
            bsaberJSON.info.songName       = data.songName;
            // TODO merge with existing info if any //
            bsaberJSON.info.difficultyLevels    = new DifficultyLevel[1];
            bsaberJSON.info.difficultyLevels[0] = DifficultyLevel.Generate(data.difficulty,
                                                                           data.songFileName, (int)data.songOffset);
            List <BSNote> notes = new List <BSNote>();

            for (int count = 0; count < data.notes.Length; count++)
            {
                if (!data.notes[count].inverted)
                {
                    BSNote bSNote = new BSNote();
                    if (data.notes[count].color == Note.NoteColor.LEFT)
                    {
                        bSNote._type = 0;
                    }
                    else
                    {
                        bSNote._type = 1;
                    }
                    bSNote._cutDirection = BSNote.GetBSaberCutDirection(data.notes[count].slashDirection);
                    bSNote._lineIndex    = (int)data.notes[count].gridPosition.x;
                    bSNote._lineLayer    = (int)data.notes[count].gridPosition.y;
                    bSNote._time         = data.notes[count].timeToSpawn;
                    notes.Add(bSNote);
                }
            }
            BeatMap.Log("Notes exported with count " + notes.Count);
            LevelJSON level = new LevelJSON();

            level._beatsPerMinute = (int)data.beatsPerMinute;
            level._version        = "1.0";
            level._beatsPerBar    = 16;
            level._noteJumpSpeed  = 10;
            level._shufflePeriod  = .5f;
            level._notes          = notes.ToArray();
            bsaberJSON.level      = level;
            return(bsaberJSON);
        }
Esempio n. 8
0
        public void SaveCurrentMapToDisk()
        {
            BeatMapData dataToSave = new BeatMapData();

            if (beatMapData == null)
            {
                BeatMap.Log("Current map data not available to save");
                return;
            }
            if (state != EditorState.Editing && state != EditorState.Recording &&
                state != EditorState.PlaybackPaused)
            {
                BeatMap.Log("Call to save when not in proper state - " + state);
                return;
            }
            else
            {
                Debug.LogWarning("data song file name - " + beatMapData.songFileName);
                dataToSave = BeatMapData.CopyBMDNotNotes(dataToSave, beatMapData);
                float              throwAwayFirstBeats = (dataToSave.beatsPerMinute / 16.5f);
                NoteDetails[]      notes    = GetAllNotes(true);
                List <NoteDetails> filtered = new List <NoteDetails>();
                for (int count = 0; count < notes.Length; count++)
                {
                    if (notes[count].timeToSpawn < throwAwayFirstBeats)
                    {
                    }
                    else
                    {
                        Debug.LogWarning("Accepting note " + notes[count].timeToSpawn + "-" +
                                         notes[count].inverted);
                        filtered.Add(notes[count]);
                    }
                }
                Debug.LogWarning("Notes - " + notes.Length + " filtered - " + filtered.Count);
                dataToSave.notes = filtered.ToArray();
            }
            Log("Call to save with # of notes " + dataToSave.notes.Length);
            Utilities.SaveToDisk(dataToSave);
        }
Esempio n. 9
0
        public void Initialize(BeatMapData data, NoteMode noteMode, EditorState requestedState)
        {
            if (BeatMap.state != EditorState.Started)
            {
                Debug.Log("Trying to initialize when not in started state - " + state);
                return;
            }
            Debug.LogWarning("Audio loaded, Initializing with note mode " + currentNoteMode);

            waitingNotes       = new List <NoteDetails>();
            activeNotes        = new List <Note>();
            completedNotes     = new List <NoteDetails>();
            beatManager        = new Utilities.BeatManager(data.beatsPerMinute, song);
            audioSource.clip   = song;
            beatsToReachPlayer = timeToReachPlayer * beatManager.beatsPerSecond; // Convert from seconds to beats
            Debug.Log("Time to reach player Seconds-Beats -- " + timeToReachPlayer + "-" + beatsToReachPlayer);
            Debug.Log("BPM - " + data.beatsPerMinute + " BPS - " + beatManager.beatsPerSecond);
            Debug.Log("Total beats - " + beatManager.GetTotalBeats);
            lastBeatBarPlacedAtBeat = beatManager.GetCurrentWholeBeat;
            beatMapData             = data;
            waitingNotes            = new List <NoteDetails>();
            activeNotes             = new List <Note>();
            completedNotes          = new List <NoteDetails>();
            if (data.notes == null)
            {
                beatMapData.notes = new NoteDetails[0];
            }
            Log("Loading notes, size - " + data.notes.Length);
            for (int count = 0; count < data.notes.Length; count++)
            {
                data.notes[count].inverted    = false;
                data.notes[count].timeToSpawn = RoundToRelativeBeat(data.notes[count].timeToSpawn, noteMode);
                waitingNotes.Add(data.notes[count]);
            }
            // When in creative mode, we keep the inverted objects in memory //
            if (requestedState == EditorState.Recording || requestedState == EditorState.Editing)
            {
                Debug.Log("Creating inverted array, waitingnotes size - " + waitingNotes.Count + " - " +
                          "total beats - " + beatManager.GetTotalBeats);
                NoteDetails[] invertedArray = BeatMapData.InvertNoteArray(waitingNotes.ToArray(), beatManager.GetTotalBeats, currentNoteMode);
                for (int count = 0; count < invertedArray.Length; count++)
                {
                    invertedArray[count].inverted = true;
                    waitingNotes.Add(invertedArray[count]);
                }
                Log("Inverted array size - " + invertedArray.Length);
            }
            if (requestedState == EditorState.Editing || requestedState == EditorState.PlaybackPaused)
            {
                // If we have an inverted map on top of the regular map, disable note displah for performance //
                miniMap.showNotes = true;
            }
            else if (requestedState == EditorState.Playback || requestedState == EditorState.Recording)
            {
                miniMap.showNotes = false;
            }
            SetRunning(false);
            SetCurrentState(requestedState);
            miniMap.Initialize(beatManager.GetTotalBeats, beatsToReachPlayer);
            initialized = true;
        }