Esempio n. 1
0
    void Save(string filename, ExportOptions exportOptions)
    {
        if (currentSong != null && !isSaving)
        {
            Debug.Log("Saving to file- " + System.IO.Path.GetFullPath(filename));

            _saveTask      = SaveCurrentSongAsync(filename, exportOptions);
            lastLoadedFile = System.IO.Path.GetFullPath(filename);

            if (isSaving)
            {
                events.saveEvent.Fire();
            }

            isDirty = false;

            if (Globals.gameSettings.autoValidateSongOnSave)
            {
                bool hasErrors;
                SongValidate.ValidationParameters validateParams = new SongValidate.ValidationParameters()
                {
                    songLength = currentSongLength, checkMidiIssues = false,
                };
                SongValidate.GenerateReport(Globals.gameSettings.songValidatorModes, currentSong, validateParams, out hasErrors);

                if (hasErrors)
                {
                    EnableMenu(uiServices.gameObject.GetComponentInChildren <ValidationMenu>(true));
                }
            }
        }
    }
Esempio n. 2
0
    public void ValidateSong()
    {
        bool hasErrors;

        SongValidate.ValidationParameters validateParams = new SongValidate.ValidationParameters()
        {
            songLength      = editor.currentSongLength,
            checkMidiIssues = true,
        };
        errorText.text = SongValidate.GenerateReport(currentOptions, editor.currentSong, validateParams, out hasErrors);
    }
Esempio 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);
        }
    }