Exemplo n.º 1
0
    public IEnumerator _ExportSong(string filepath)
    {
        LoadingTasksManager tasksManager = editor.services.loadingTasksManager;

        Song song = editor.currentSong;// new Song(editor.currentSong);

        exportOptions.tickOffset = TickFunctions.TimeToDis(0, delayTime, exportOptions.targetResolution, 120);

        float  timer            = Time.realtimeSinceStartup;
        string errorMessageList = string.Empty;

        List <LoadingTask> tasks = new List <LoadingTask>()
        {
            new LoadingTask("Exporting " + exportOptions.format, () =>
            {
                if (exportOptions.format == ExportOptions.Format.Chart)
                {
                    try
                    {
                        new ChartWriter(filepath).Write(song, exportOptions, out errorMessageList);
                        //song.Save(filepath, exportOptions);
                    }
                    catch (System.Exception e)
                    {
                        Logger.LogException(e, "Error when exporting chart");
                        errorMessageList += e.Message;
                    }
                }
                else if (exportOptions.format == ExportOptions.Format.Midi)
                {
                    try
                    {
                        MidWriter.WriteToFile(filepath, song, exportOptions);
                    }
                    catch (System.Exception e)
                    {
                        Logger.LogException(e, "Error when exporting midi");
                        errorMessageList += e.Message;
                    }
                }
            })
        };

        if (generateIniToggle.isOn)
        {
            tasks.Add(new LoadingTask("Generating Song.ini", () =>
            {
                GenerateSongIni(Path.GetDirectoryName(filepath), song);
            }));
        }

        tasksManager.KickTasks(tasks);

        while (tasksManager.isRunningTask)
        {
            yield return(null);
        }

        Debug.Log("Total exporting time: " + (Time.realtimeSinceStartup - timer));

        if (errorMessageList != string.Empty)
        {
            ChartEditor.Instance.errorManager.QueueErrorMessage("Encountered the following errors while exporting: " + Globals.LINE_ENDING + errorMessageList);
        }
    }
Exemplo n.º 2
0
    public IEnumerator _ExportSong(string filepath)
    {
        // Start saving
        Globals.applicationMode = Globals.ApplicationMode.Loading;
        loadingScreen.FadeIn();
        loadingScreen.loadingInformation.text = "Exporting " + exportOptions.format;

        Song song = new Song(editor.currentSong);

        exportOptions.tickOffset = TickFunctions.TimeToDis(0, delayTime, exportOptions.targetResolution, 120);

        float  timer            = Time.realtimeSinceStartup;
        string errorMessageList = string.Empty;
        Thread exportingThread  = new Thread(() =>
        {
            if (exportOptions.format == ExportOptions.Format.Chart)
            {
                try
                {
                    new ChartWriter(filepath).Write(song, exportOptions, out errorMessageList);
                    //song.Save(filepath, exportOptions);
                }
                catch (System.Exception e)
                {
                    Logger.LogException(e, "Error when exporting chart");
                    errorMessageList += e.Message;
                }
            }
            else if (exportOptions.format == ExportOptions.Format.Midi)
            {
                try
                {
                    MidWriter.WriteToFile(filepath, song, exportOptions);
                }
                catch (System.Exception e)
                {
                    Logger.LogException(e, "Error when exporting midi");
                    errorMessageList += e.Message;
                }
            }
        });

        exportingThread.Start();

        while (exportingThread.ThreadState == ThreadState.Running)
        {
            yield return(null);
        }

        if (generateIniToggle.isOn)
        {
            loadingScreen.loadingInformation.text = "Generating Song.ini";
            Thread iniThread = new Thread(() =>
            {
                GenerateSongIni(Path.GetDirectoryName(filepath));
            });

            iniThread.Start();

            while (iniThread.ThreadState == ThreadState.Running)
            {
                yield return(null);
            }
        }

        Debug.Log("Total exporting time: " + (Time.realtimeSinceStartup - timer));

        // Stop loading animation
        loadingScreen.FadeOut();
        loadingScreen.loadingInformation.text = "Complete!";

        if (errorMessageList != string.Empty)
        {
            ChartEditor.Instance.errorManager.QueueErrorMessage("Encountered the following errors while exporting: " + Globals.LINE_ENDING + errorMessageList);
        }
    }
Exemplo n.º 3
0
    public IEnumerator _ExportSong(string filepath)
    {
        LoadingTasksManager tasksManager = editor.services.loadingTasksManager;

        Song  song       = editor.currentSong;// new Song(editor.currentSong);
        float songLength = editor.currentSongLength;

        exportOptions.tickOffset = TickFunctions.TimeToDis(0, delayTime, exportOptions.targetResolution, 120);

        float  timer            = Time.realtimeSinceStartup;
        string errorMessageList = string.Empty;

        List <LoadingTask> tasks = new List <LoadingTask>()
        {
            new LoadingTask("Exporting " + exportOptions.format, () =>
            {
                if (exportOptions.format == ExportOptions.Format.Chart)
                {
                    try
                    {
                        ChartWriter.ErrorReport errorReport;

                        Debug.Log("Exporting CHART file to " + filepath);
                        new ChartWriter(filepath).Write(song, exportOptions, out errorReport);

                        errorMessageList = errorReport.errorList.ToString();
                    }
                    catch (System.Exception e)
                    {
                        Logger.LogException(e, "Error when exporting chart");
                        errorMessageList += e.Message;
                    }
                }
                else if (exportOptions.format == ExportOptions.Format.Midi)
                {
                    try
                    {
                        Debug.Log("Exporting MIDI file to " + filepath);
                        MidWriter.WriteToFile(filepath, song, exportOptions);
                    }
                    catch (System.Exception e)
                    {
                        Logger.LogException(e, "Error when exporting midi");
                        errorMessageList += e.Message;
                    }
                }
            })
        };

        if (generateIniToggle.isOn)
        {
            tasks.Add(new LoadingTask("Generating Song.ini", () =>
            {
                GenerateSongIni(Path.GetDirectoryName(filepath), song, songLength);
            }));
        }

        tasksManager.KickTasks(tasks);

        while (tasksManager.isRunningTask)
        {
            yield return(null);
        }

        Debug.Log("Total exporting time: " + (Time.realtimeSinceStartup - timer));

        if (exportOptions.format == ExportOptions.Format.Midi)
        {
            bool hasErrors;
            SongValidate.ValidationParameters validateParams = new SongValidate.ValidationParameters()
            {
                songLength = editor.currentSongLength, checkMidiIssues = true,
            };
            string validationErrors = SongValidate.GenerateReport(SongValidate.ValidationOptions.CloneHero, editor.currentSong, validateParams, out hasErrors);

            if (hasErrors)
            {
                errorMessageList += '\n';
                errorMessageList += validationErrors;
            }
        }

        if (errorMessageList != string.Empty)
        {
            Disable();
            ChartEditor.Instance.errorManager.QueueErrorMessage("Encountered the following errors while exporting: " + Globals.LINE_ENDING + errorMessageList);
        }
    }