/// <sumary> /// Instantiate the new Chart and load the editor scene /// </sumary> public void StartEditor(bool isEdit = false) { if (Serializer.Initialized) { if (Serializer.ChartData == null) { Chart chart = new Chart(); Beats defaultBeats = new Beats(); defaultBeats.Easy = new Dictionary <float, List <Note> >(); defaultBeats.Normal = new Dictionary <float, List <Note> >(); defaultBeats.Hard = new Dictionary <float, List <Note> >(); defaultBeats.Expert = new Dictionary <float, List <Note> >(); defaultBeats.Master = new Dictionary <float, List <Note> >(); defaultBeats.Custom = new Dictionary <float, List <Note> >(); Effects defaultEffects = new Effects(); defaultEffects.Easy = new List <float>(); defaultEffects.Normal = new List <float>(); defaultEffects.Hard = new List <float>(); defaultEffects.Expert = new List <float>(); defaultEffects.Master = new List <float>(); defaultEffects.Custom = new List <float>(); Jumps defaultJumps = new Jumps(); defaultJumps.Easy = new List <float>(); defaultJumps.Normal = new List <float>(); defaultJumps.Hard = new List <float>(); defaultJumps.Expert = new List <float>(); defaultJumps.Master = new List <float>(); defaultJumps.Custom = new List <float>(); Crouchs defaultCrouchs = new Crouchs(); defaultCrouchs.Easy = new List <float>(); defaultCrouchs.Normal = new List <float>(); defaultCrouchs.Hard = new List <float>(); defaultCrouchs.Expert = new List <float>(); defaultCrouchs.Master = new List <float>(); defaultCrouchs.Custom = new List <float>(); Slides defaultSlides = new Slides(); defaultSlides.Easy = new List <Slide>(); defaultSlides.Normal = new List <Slide>(); defaultSlides.Hard = new List <Slide>(); defaultSlides.Expert = new List <Slide>(); defaultSlides.Master = new List <Slide>(); defaultSlides.Custom = new List <Slide>(); Lights defaultLights = new Lights(); defaultLights.Easy = new List <float>(); defaultLights.Normal = new List <float>(); defaultLights.Hard = new List <float>(); defaultLights.Expert = new List <float>(); defaultLights.Master = new List <float>(); defaultLights.Custom = new List <float>(); /// For testing /*var list = new List<Note>(); * list.Add(new Note(new Vector3(-0.5756355f, 0.2400601f, 0), 1)); * defaultBeats.Easy.Add(0, list); * list = new List<Note>(); * list.Add(new Note(new Vector3(-0.7826607f, 0.3006552f, 20f), 2002)); * defaultBeats.Easy.Add(2000, list); * list = new List<Note>(); * list.Add(new Note(new Vector3(0.1514833f, 0.3359979f, 40f), 4001)); * defaultBeats.Easy.Add(4000, list); */ chart.Track = defaultBeats; chart.Effects = defaultEffects; chart.Jumps = defaultJumps; chart.Crouchs = defaultCrouchs; chart.Slides = defaultSlides; chart.Bookmarks = new Bookmarks(); chart.Name = nameField.text; chart.Author = authorField.text; chart.AudioName = trackField.text; chart.AudioData = null; //audioData; chart.AudioFrecuency = loadedClip.frequency; chart.AudioChannels = loadedClip.channels; chart.BPM = 120; chart.FilePath = null; chart.Artwork = artWorkField; chart.ArtworkBytes = loadedArtwork; chart.IsAdminOnly = Serializer.IsAdmin(); chart.Beatmapper = mapperField.text; chart.CustomDifficultyName = "Custom"; chart.CustomDifficultySpeed = 1; chart.Tags = new List <string>(); chart.Lights = defaultLights; Serializer.ChartData = chart; } if (artworkEdited) { Serializer.ChartData.Artwork = artWorkField; Serializer.ChartData.ArtworkBytes = loadedArtwork; } if (audioEdited) { // Serializer.ChartData.AudioData = audioData; Serializer.ChartData.AudioFrecuency = loadedClip.frequency; Serializer.ChartData.AudioChannels = loadedClip.channels; } if (isEdit) { Serializer.ChartData.Name = editNameField.text; Serializer.ChartData.Author = editAuthorField.text; Serializer.ChartData.AudioName = editTrackField.text; Serializer.ChartData.Beatmapper = editMapperField.text; } // Complete editor process // Serializer.SerializeToFile(); Miku_LoaderHelper.LauchPreloader(); } }
public static Chart Convert(string path, int distancex = 50, int distancey = 35, int offsety = 10, int dynamic = 20, int repeat = 200) { path = path.Substring(0, path.LastIndexOf(@"\")); Chart synthSong = new Chart(); if (File.Exists(path + @"\info.dat")) { //load song info string infoStr = ""; using (StreamReader streamReader = new StreamReader(path + @"\info.dat")) { infoStr = streamReader.ReadToEnd(); } //deserialize song info Info info = JsonConvert.DeserializeObject <Info>(infoStr); synthSong.Name = (info._songName != "") ? info._songName : "N/A"; synthSong.Author = (info._songAuthorName != "") ? info._songAuthorName : "N/A"; synthSong.BPM = info._beatsPerMinute; synthSong.Offset = (info._songTimeOffset < 0) ? info._songTimeOffset : synthSong.Offset = 0; synthSong.Beatmapper = (info._levelAuthorName != "") ? info._levelAuthorName : "N/A"; synthSong.BeatConverted = true; synthSong.Artwork = "Default Artwork"; synthSong.ArtworkBytes = null; synthSong.AudioName = ""; synthSong.AudioData = null; synthSong.AudioFrecuency = 0; synthSong.AudioChannels = 2; synthSong.EditorVersion = "1.8"; synthSong.IsAdminOnly = false; for (int i = 0; i < info._difficultyBeatmapSets[0]._difficultyBeatmaps.Count && i < 5; i++) { if (File.Exists(path + @"\" + info._difficultyBeatmapSets[0]._difficultyBeatmaps[i]._beatmapFilename)) { //load song difficulty string beatSongStr = ""; using (StreamReader streamReader = new StreamReader(path + @"\" + info._difficultyBeatmapSets[0]._difficultyBeatmaps[i]._beatmapFilename)) { beatSongStr = streamReader.ReadToEnd(); } //deserialize song difficulty BeatSong beatSong = JsonConvert.DeserializeObject <BeatSong>(beatSongStr); //convert notes Dictionary <float, List <Note> > track = new Dictionary <float, List <Note> >(); for (int j = 0; j < beatSong._notes.Count; j++) { int time = (int)Math.Round(beatSong._notes[j]._time * 60000f / info._beatsPerMinute); float y_offset = 0; float _offset = 0; switch (beatSong._notes[j]._cutDirection) { case 0: y_offset += dynamic * 0.01f; break; //up case 1: y_offset -= dynamic * 0.01f; break; //down case 2: _offset += dynamic * 0.01f; break; //left case 3: _offset -= dynamic * 0.01f; break; //right case 4: y_offset += (dynamic / sqrttwo) * 0.01f; _offset += (dynamic / sqrttwo) * 0.01f; break; //up_left case 5: y_offset += (dynamic / sqrttwo) * 0.01f; _offset -= (dynamic / sqrttwo) * 0.01f; break; //up_right case 6: y_offset -= (dynamic / sqrttwo) * 0.01f; _offset += (dynamic / sqrttwo) * 0.01f; break; //down_left case 7: y_offset -= (dynamic / sqrttwo) * 0.01f; _offset -= (dynamic / sqrttwo) * 0.01f; break; //down_right } Vector3 pos = new Vector3(_offset + (distancex / 150f) * (beatSong._notes[j]._lineIndex - 1.5f), y_offset + (distancey / 100f) * (beatSong._notes[j]._lineLayer - 1f) + offsety * 0.01f, (time) * 0.02f); Note.NoteType type; if (beatSong._notes[j]._type == 0) { type = Note.NoteType.LeftHanded; } else if (beatSong._notes[j]._type == 1) { type = Note.NoteType.RightHanded; } else//bombs { continue; } string id = i.ToString() + "," + j.ToString(); Note note = new Note(pos, id, -1, type); if (!track.ContainsKey(time)) { List <Note> notes = new List <Note>(); notes.Add(note); track.Add(time, notes); } else { track[time].Add(note); } } //convert obstacles List <Crouch> crouches = new List <Crouch>(); List <Slide> slides = new List <Slide>(); for (int j = 0; j < beatSong._obstacles.Count; j++) { int time = (int)Math.Round(beatSong._obstacles[j]._time * 60000f / info._beatsPerMinute); int duration = (int)Math.Round(beatSong._obstacles[j]._duration * 60000f / info._beatsPerMinute); for (int n = time; n < time + duration; n += repeat) { if (beatSong._obstacles[j]._type == 1) { Crouch crouch = new Crouch(); crouch.time = n; crouch.position = new float[] { 0, 0, n * 18.75f }; crouches.Add(crouch); } else { Slide slide = new Slide(); slide.time = n; slide.position = new float[] { 0, 0, n * 18.75f }; if (beatSong._obstacles[j]._width == 1) { if (beatSong._obstacles[j]._lineIndex == 0)//one on the left { slide.slideType = (Note.NoteType) 4; } else if (beatSong._obstacles[j]._lineIndex == 3)//one on the right { slide.slideType = (Note.NoteType) 2; } else//one middle right or middle left { slide.slideType = (Note.NoteType) 3; } slides.Add(slide); } else if (beatSong._obstacles[j]._width == 2) { if (beatSong._obstacles[j]._lineIndex == 0)//two on the left { slide.slideType = (Note.NoteType) 1; } else if (beatSong._obstacles[j]._lineIndex == 1)//two in the middle { slide.slideType = (Note.NoteType) 3; } else if (beatSong._obstacles[j]._lineIndex == 2)//two on the right { slide.slideType = (Note.NoteType) 0; } slides.Add(slide); } else { Crouch crouch = new Crouch(); crouch.time = n; crouch.position = new float[] { 0, 0, n * 18.75f }; crouches.Add(crouch); } } } } Beats defaultBeats = new Beats(); defaultBeats.Easy = new Dictionary <float, List <Note> >(); defaultBeats.Normal = new Dictionary <float, List <Note> >(); defaultBeats.Hard = new Dictionary <float, List <Note> >(); defaultBeats.Expert = new Dictionary <float, List <Note> >(); defaultBeats.Master = new Dictionary <float, List <Note> >(); defaultBeats.Custom = new Dictionary <float, List <Note> >(); synthSong.Track = defaultBeats; Crouchs defaultCrouchs = new Crouchs(); defaultCrouchs.Easy = new List <Crouch>(); defaultCrouchs.Normal = new List <Crouch>(); defaultCrouchs.Hard = new List <Crouch>(); defaultCrouchs.Expert = new List <Crouch>(); defaultCrouchs.Master = new List <Crouch>(); defaultCrouchs.Custom = new List <Crouch>(); synthSong.Crouchs = defaultCrouchs; Slides defaultSlides = new Slides(); defaultSlides.Easy = new List <Slide>(); defaultSlides.Normal = new List <Slide>(); defaultSlides.Hard = new List <Slide>(); defaultSlides.Expert = new List <Slide>(); defaultSlides.Master = new List <Slide>(); defaultSlides.Custom = new List <Slide>(); synthSong.Slides = defaultSlides; if (info._difficultyBeatmapSets[0]._difficultyBeatmaps[i]._difficulty.Equals("Expert")) { synthSong.Track.Expert = track; synthSong.Crouchs.Expert = crouches; synthSong.Slides.Expert = slides; } else if (info._difficultyBeatmapSets[0]._difficultyBeatmaps[i]._difficulty.Equals("Hard")) { synthSong.Track.Hard = track; synthSong.Crouchs.Hard = crouches; synthSong.Slides.Hard = slides; } else if (info._difficultyBeatmapSets[0]._difficultyBeatmaps[i]._difficulty.Equals("Normal")) { synthSong.Track.Normal = track; synthSong.Crouchs.Normal = crouches; synthSong.Slides.Normal = slides; } else if (info._difficultyBeatmapSets[0]._difficultyBeatmaps[i]._difficulty.Equals("Easy")) { synthSong.Track.Easy = track; synthSong.Crouchs.Easy = crouches; synthSong.Slides.Easy = slides; } else { synthSong.Track.Master = track; synthSong.Crouchs.Master = crouches; synthSong.Slides.Master = slides; } } } string[] filePaths = Directory.GetFiles(path); foreach (string filePath in filePaths) { if (filePath.Contains(".egg"))//replace the .egg file ending with .ogg { string tmp = filePath.Substring(0, filePath.IndexOf(".egg")) + ".ogg"; if (!File.Exists(tmp)) { File.Copy(filePath, tmp); } } } } return(synthSong); }
private void LoadAudioChart(string absoluteUri, bool isJSON = false) { if (Serializer.Initialized) { // bool fileLoadSuccess = Serializer.LoadFronFile(absoluteUri, isJSON, absoluteUri.Contains(".dat")); bool fileLoadSuccess = isJSON ? Serializer.LoadFronFile(absoluteUri, isJSON, absoluteUri.Contains(".dat")) : Serializer.LoadFronFile(absoluteUri); if (fileLoadSuccess) { editPanelAnimator.Play("Panel In"); editModePanelAnimator.Play("Panel Out"); editNameField.text = Serializer.ChartData.Name; editAuthorField.text = Serializer.ChartData.Author; editTrackField.text = (Serializer.ChartData.AudioData != null) ? string.Empty : Serializer.ChartData.AudioName; editMapperField.text = Serializer.ChartData.Beatmapper; if (!isJSON) { Serializer.ChartData.FilePath = absoluteUri; } // For the artwork texture if (Serializer.ChartData.ArtworkBytes == null) { Serializer.ChartData.Artwork = "Default Artwork"; Serializer.ChartData.ArtworkBytes = defaultArtworkData; } SetSpriteToImage(editArtworkField, Serializer.ChartData.ArtworkBytes); // If not has effect data if (Serializer.ChartData.Effects == null) { Effects defaultEffects = new Effects(); defaultEffects.Easy = new List <float>(); defaultEffects.Normal = new List <float>(); defaultEffects.Hard = new List <float>(); defaultEffects.Expert = new List <float>(); defaultEffects.Master = new List <float>(); defaultEffects.Custom = new List <float>(); Serializer.ChartData.Effects = defaultEffects; } if (Serializer.ChartData.Jumps == null) { Jumps defaultJumps = new Jumps(); defaultJumps.Easy = new List <float>(); defaultJumps.Normal = new List <float>(); defaultJumps.Hard = new List <float>(); defaultJumps.Expert = new List <float>(); defaultJumps.Master = new List <float>(); defaultJumps.Custom = new List <float>(); Serializer.ChartData.Jumps = defaultJumps; } if (Serializer.ChartData.Crouchs == null) { Crouchs defaultCrouchs = new Crouchs(); defaultCrouchs.Easy = new List <float>(); defaultCrouchs.Normal = new List <float>(); defaultCrouchs.Hard = new List <float>(); defaultCrouchs.Expert = new List <float>(); defaultCrouchs.Master = new List <float>(); defaultCrouchs.Custom = new List <float>(); Serializer.ChartData.Crouchs = defaultCrouchs; } if (Serializer.ChartData.Slides == null) { Slides defaultSlides = new Slides(); defaultSlides.Easy = new List <Slide>(); defaultSlides.Normal = new List <Slide>(); defaultSlides.Hard = new List <Slide>(); defaultSlides.Expert = new List <Slide>(); defaultSlides.Master = new List <Slide>(); defaultSlides.Custom = new List <Slide>(); Serializer.ChartData.Slides = defaultSlides; } if (Serializer.ChartData.Lights == null) { Lights defaultLights = new Lights(); defaultLights.Easy = new List <float>(); defaultLights.Normal = new List <float>(); defaultLights.Hard = new List <float>(); defaultLights.Expert = new List <float>(); defaultLights.Master = new List <float>(); defaultLights.Custom = new List <float>(); Serializer.ChartData.Lights = defaultLights; } if (Serializer.ChartData.Bookmarks == null) { Serializer.ChartData.Bookmarks = new Bookmarks(); } InitFormsSelection(true); } } }