示例#1
0
    public void ExportCHPackage()
    {
        string saveDirectory;

        if (FileExplorer.OpenFolderPanel(out saveDirectory))
        {
            Song  song       = editor.currentSong;
            float songLength = editor.currentSongLength;

            saveDirectory = saveDirectory.Replace('\\', '/');
            saveDirectory = Path.Combine(saveDirectory, FileExplorer.StripIllegalChars(song.name));

            // Check if files exist at the current directory and ask user before overwriting.
            if (Directory.Exists(saveDirectory))
            {
                NativeWindow            window    = ChartEditor.Instance.windowHandleManager.nativeWindow;
                NativeMessageBox.Result overwrite = NativeMessageBox.Show("Exported files exist. Overwrite?", "Warning", NativeMessageBox.Type.YesNo, window);

                if (overwrite != NativeMessageBox.Result.Yes)
                {
                    return;
                }
            }

            StartCoroutine(ExportCHPackage(saveDirectory, song, songLength, exportOptions));
        }
    }
    IEnumerator AutosaveCheck()
    {
        yield return(null);

        if (System.IO.File.Exists(autosaveLocation))
        {
#if !UNITY_EDITOR
            string autosaveText    = "An autosave was detected indicating that the program did not correctly shut down during the last session. \nWould you like to reload the autosave?";
            string autosaveCaption = "Warning";

            NativeMessageBox.Result result = NativeMessageBox.Show(autosaveText, autosaveCaption, NativeMessageBox.Type.YesNo, editor.windowHandleManager.nativeWindow);

            if (result == NativeMessageBox.Result.Yes)
            {
                yield return(StartCoroutine(editor._Load(autosaveLocation, false)));

                ChartEditor.isDirty = true;
            }
#endif
        }
    }
示例#3
0
    bool EditCheck()
    {
        // Check for unsaved changes
        if (isDirty)
        {
            NativeMessageBox.Result result = NativeMessageBox.Show("Do you want to save unsaved changes?", "Warning", NativeMessageBox.Type.YesNoCancel, windowHandleManager.nativeWindow);

            if (result == NativeMessageBox.Result.Yes)
            {
                if (!_Save())
                {
                    return(false);
                }
            }
            else if (result == NativeMessageBox.Result.Cancel)
            {
                return(false);
            }
        }

        return(true);
    }
示例#4
0
    bool EditCheck()
    {
        // Check for unsaved changes
        if (isDirty)
        {
            if (quitting)
            {
                UnityEngine.Application.CancelQuit();
            }
#if !UNITY_EDITOR
            NativeMessageBox.Result result = NativeMessageBox.Show("Want to save unsaved changes?", "Warning", NativeMessageBox.Type.YesNoCancel);
            if (quitting)
            {
                UnityEngine.Application.CancelQuit();
            }

            if (result == NativeMessageBox.Result.Yes)
            {
                if (!_Save())
                {
                    quitting = false;
                    return(false);
                }
            }
            else if (result == NativeMessageBox.Result.Cancel)
            {
                quitting = false;
                return(false);
            }
#endif

            if (quitting)
            {
                UnityEngine.Application.Quit();
            }
        }

        return(true);
    }
    public static Song ReadMidi(string path, ref CallbackState callBackState)
    {
        Song   song      = new Song();
        string directory = System.IO.Path.GetDirectoryName(path);

        foreach (Song.AudioInstrument audio in EnumX <Song.AudioInstrument> .Values)
        {
            string filename = string.Empty;

            string[] locationOverrides = null;
            if (c_audioStreamLocationOverrideDict.TryGetValue(audio, out locationOverrides))
            {
                foreach (string overrideFilename in locationOverrides)
                {
                    string testFilepath = directory + "\\" + overrideFilename.ToLower() + ".ogg";

                    if (System.IO.File.Exists(testFilepath))
                    {
                        filename = overrideFilename;
                        break;
                    }
                }
            }
            else
            {
                filename = audio.ToString();
            }

            string audioFilepath = directory + "\\" + filename.ToLower() + ".ogg";
            Debug.Log(audioFilepath);
            song.SetAudioLocation(audio, audioFilepath);
        }

        MidiFile midi;

        try
        {
            midi = new MidiFile(path);
        }
        catch (SystemException e)
        {
            throw new SystemException("Bad or corrupted midi file- " + e.Message);
        }

        song.resolution = (short)midi.DeltaTicksPerQuarterNote;

        // Read all bpm data in first. This will also allow song.TimeToTick to function properly.
        ReadSync(midi.Events[0], song);

        for (int i = 1; i < midi.Tracks; ++i)
        {
            var trackName = midi.Events[i][0] as TextEvent;
            if (trackName == null)
            {
                continue;
            }
            Debug.Log("Found midi track " + trackName.Text);

            string trackNameKey = trackName.Text.ToUpper();
            if (trackNameKey == MidIOHelper.EVENTS_TRACK)
            {
                ReadSongGlobalEvents(midi.Events[i], song);
            }
            else if (!c_trackExcludesMap.ContainsKey(trackNameKey))
            {
                bool importTrackAsVocalsEvents = trackNameKey == MidIOHelper.VOCALS_TRACK;

#if !UNITY_EDITOR
                if (importTrackAsVocalsEvents)
                {
                    callBackState = CallbackState.WaitingForExternalInformation;
                    NativeMessageBox.Result result = NativeMessageBox.Show("A vocals track was found in the file. Would you like to import the text events as global lyrics events?", "Vocals Track Found", NativeMessageBox.Type.YesNo, null);
                    callBackState             = CallbackState.None;
                    importTrackAsVocalsEvents = result == NativeMessageBox.Result.Yes;
                }
#endif
                if (importTrackAsVocalsEvents)
                {
                    Debug.Log("Loading lyrics from Vocals track");
                    ReadTextEventsIntoGlobalEventsAsLyrics(midi.Events[i], song);
                }
                else
                {
                    Song.Instrument instrument;
                    if (!c_trackNameToInstrumentMap.TryGetValue(trackNameKey, out instrument))
                    {
                        instrument = Song.Instrument.Unrecognised;
                    }

                    Debug.LogFormat("Loading midi track {0}", instrument);
                    ReadNotes(midi.Events[i], song, instrument);
                }
            }
        }

        return(song);
    }