示例#1
0
        //writeAudioToPreset copies the audio from the selected directory to the preset folder
        public void writeAudioToPreset()
        {
            //We copy the files to the Original folder
            foreach (var customMusicFile in Directory.GetFiles(currentDirectory, "*.*", SearchOption.TopDirectoryOnly).Where(s => s.EndsWith(".ogg") || s.EndsWith(".wav") || s.EndsWith(".mp3")))
            {
                string thisCustomMusicFilename = System.IO.Path.GetFileName(customMusicFile);

                if (!File.Exists(presetsPath + presetName + "\\Original\\" + thisCustomMusicFilename))
                {
                    File.Copy(customMusicFile, presetsPath + presetName + "\\Original\\" + thisCustomMusicFilename, true);
                }
            }

            PresetData[] dataArray = new PresetData[214];
            dataArray = readPresetXML();

            //We copy the files from the Original folder, and name them to the games's filenames then copy them to the Named folder
            for (int i = 0; i < dataArray.Length - 1; i++)
            {
                if (dataArray[i].customFile != "Default")
                {
                    convertToOGG(presetsPath + presetName + "\\Original\\", presetsPath + presetName + "\\Named\\", System.IO.Path.GetFileNameWithoutExtension(dataArray[i].customFile), System.IO.Path.GetFileNameWithoutExtension(dataArray[i].musicFile));
                }
            }
        }
示例#2
0
        //readPresetXML is responsible for reading the-- you get the point.
        public PresetData[] readPresetXML()
        {
            //We create an object dataArray as an array of PresetData (size of the number of game tracks) to store data for each track
            PresetData[] dataArray = new PresetData[Constants.GameTracks];

            //We try to load the preset.xml file, and catch an exception
            XmlDocument presetXMLFile = new XmlDocument();

            try
            {
                presetXMLFile.Load(presetsPath + presetName + "\\preset.xml");
            }

            catch (Exception ex)
            {
                MessageBox.Show("An unhandled exception occurred when loading the preset.xml! The exception is: " + ex + ". Please report this bug to me via reddit or Skype!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            int i = 0;

            //We try to loop through the ChildNodes of the root of the presetXMLFile, and catch an exception
            try
            {
                //For each <MUsic File> Node that is a child of the Root node in presetXMLFile
                foreach (XmlNode musicFileNode in presetXMLFile.DocumentElement.ChildNodes)
                {
                    dataArray[i].musicFile  = musicFileNode.Attributes["Value"]?.InnerText; //Add the text of the Value attribute to the musicFile member of dataArray at index i (e.g. abc_123.ogg)
                    dataArray[i].customFile = musicFileNode["CustomFile"].InnerText;        //Add the text of the CustomFile attribute to the customFile member of dataArray at index i (the name of the file we're replacing musicFile with)
                    i++;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("An unhandled exception occurred when reading the preset.xml for values! The exception is: " + ex + ". Please report this bug to me via reddit or Skype!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(dataArray);
        }
示例#3
0
        //tagForThisPreset tags all gameTracksList items with their corresponding customTracksList value's index
        public void tagForThisPreset(string presetName)
        {
            resetTags();

            PresetData[] dataArray = new PresetData[Constants.GameTracks];
            dataArray = readPresetXML();

            try
            {
                for (int i = 0; i < dataArray.Length - 1; i++)
                {
                    ListViewItem thisGameItem = (ListViewItem)gameTracksList.Items[i];

                    //If it's default, we don't have a custom file assigned
                    if (dataArray[i].customFile == "Default")
                    {
                        thisGameItem.Tag = null;
                    }

                    else
                    {
                        foreach (ListViewItem thisCustomItem in customTracksList.Items)
                        {
                            //If the custom game track's content equals the custom file at index i in dataArray
                            if (thisCustomItem.Content.ToString() == IDs.GameTracks.GetTrackFilename((dataArray[i].customFile)))
                            {
                                thisGameItem.Tag = customTracksList.Items.IndexOf(thisCustomItem);  //Set the tag of the game track to the index of the custom track
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("An unhandled exception occurred when reading the preset.xml for tags! The exception is: " + ex + ". Please report this bug to me via reddit or Skype!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }