예제 #1
0
        private void AddFolder(string folder)
        {
            string xPath;

            if (folderTree.SelectedNode != folderTree.Nodes[0])
            {
                xPath = ((CFolderEntry)folderTree.SelectedNode.Tag).Path + "/" + folder;
            }
            else
            {
                xPath = folder;
            }

            var folderexists = xsession.GetFolder(xPath);

            if (folder != "gen" && folderexists != null)
            {
                MessageBox.Show(
                    "There is already a folder with the name '" + folder +
                    "'\nYou can't have multiple folders with the same name,\ntry deleting the existing folder first",
                    Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                dupFolder = true;
                return;
            }

            if (!xsession.AddFolder(xPath))
            {
                return;
            }
            folderTree.SelectedNode.Nodes.Add(GetFoldNode(xsession.GetFolder(xPath)));
            folderTree.SelectedNode.ExpandAll();
            folderTree.SelectedNode = folderTree.FindNodeByText(folder);
        }
예제 #2
0
        private void addFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Renamer y = new Renamer("", true);

            if (y.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string xPath = "";

            if (advTree1.SelectedNode != advTree1.Nodes[0])
            {
                xPath = ((CFolderEntry)advTree1.SelectedNode.Tag).Path + "/" + y.FileName;
            }
            else
            {
                xPath = y.FileName;
            }
            if (!xsession.AddFolder(xPath))
            {
                return;
            }
            advTree1.SelectedNode.Nodes.Add(GetFoldNode(xsession.GetFolder(xPath)));
        }
예제 #3
0
        private bool PackageCheckFiles(CreateSTFS xsession)
        {
            var fnamedta = tempfolder + "songs.dta";

            if (File.Exists(fnamedta))
            {
                xsession.AddFolder("songs");
                xsession.AddFolder("songs/" + basesongname);
                xsession.AddFolder("songs/" + basesongname + "/gen");
                if (!xsession.AddFile(fnamedta, "songs/songs.dta"))
                {
                    Log("ERROR: Could not add " + fnamedta + " to CON");
                    return(false);
                }
            }
            else
            {
                Log("FAIL: " + fnamedta + " is not present");
                return(false);
            }
            var files = Directory.GetFiles(tempfolder, "*.mid");

            if (files.Count() != 0)
            {
                if (!xsession.AddFile(files[0], "songs/" + basesongname + "/" + basesongname + ".mid"))
                {
                    Log("ERROR: Could not add MIDI file to CON");
                    return(false);
                }
            }
            files = Directory.GetFiles(tempfolder, "*.mogg");
            if (files.Count() != 0)
            {
                if (!xsession.AddFile(files[0], "songs/" + basesongname + "/" + basesongname + ".mogg"))
                {
                    Log("ERROR: Could not add mogg file to CON");
                    return(false);
                }
            }
            files = Directory.GetFiles(tempfolder, "*.milo_xbox");
            if (files.Count() != 0)
            {
                if (!xsession.AddFile(files[0], "songs/" + basesongname + "/gen/" + basesongname + ".milo_xbox"))
                {
                    Log("ERROR: Could not add milo file to CON");
                    return(false);
                }
            }
            files = Directory.GetFiles(tempfolder, "*.png_xbox");
            if (files.Count() != 0)
            {
                if (!xsession.AddFile(files[0], "songs/" + basesongname + "/gen/" + basesongname + "_keep.png_xbox"))
                {
                    Log("ERROR: Could not add album art to CON");
                    return(false);
                }
            }
            files = Directory.GetFiles(tempfolder, "*.bin");
            if (!files.Any())
            {
                return(true);
            }
            if (xsession.AddFile(files[0], "songs/" + basesongname + "/gen/" + basesongname + "_weights.bin"))
            {
                return(true);
            }
            Log("ERROR: Could not add weights file to CON");
            return(false);
        }
예제 #4
0
        private bool addFiles()
        {
            if (backgroundWorker1.CancellationPending)
            {
                return(false);
            }

            var name = "song";

            if (chkFTV.Checked)
            {
                name = "ftv";
            }

            var filesAdded = 0;

            if (songsFolder.Substring(songsFolder.Length - 1, 1) != "\\")
            {
                songsFolder = songsFolder + "\\";
            }

            if (Directory.Exists(songsFolder))
            {
                var songsInput    = Directory.GetFiles(songsFolder);
                var enoughFolders = Directory.GetDirectories(songsFolder);
                if (enoughFolders.Any()) //only add if there's at least one folder in there
                {
                    packfiles.AddFolder("songs");

                    foreach (var sFile in songsInput.Where(sFile => sFile.Substring(sFile.Length - 4, 4) != ".dta"))
                    {
                        packfiles.AddFile(sFile, "songs/" + Path.GetFileName(sFile));
                    }

                    //create song folders and add contents to each
                    var subFolders    = Directory.GetDirectories(songsFolder);
                    var sFolderLength = songsFolder;

                    //if songs.dta doesn't exist, create one. if exists, leave it, will be appended
                    if (!(File.Exists(songsFolder + "songs.dta")))
                    {
                        var tempDta = new StreamWriter(songsFolder + "songs.dta", false, Encoding.Default);
                        tempDta.Dispose();
                    }

                    foreach (var songName in from folder in subFolders select folder.Substring(sFolderLength.Length, folder.Length - sFolderLength.Length) into songName select songName.Replace("\\", "") into songName where Directory.Exists(songsFolder + songName) let ending = songName.Substring(songName.Length - 3, 3) where ending != "(1)" && ending != "(2)" && ending != "(3)" && ending != "(4)" && ending != "(5)" select songName)
                    {
                        if (backgroundWorker1.CancellationPending)
                        {
                            return(false);
                        }

                        filesAdded++;
                        Log("Adding files for song " + filesAdded);
                        //add all items at the songfolder level (mostly .mid and .mogg files)
                        packfiles.AddFolder("songs/" + songName);

                        //if songs.dta is there, add to main songs.dta and then delete
                        if (File.Exists(songsFolder + songName + "\\songs.dta"))
                        {
                            var dtaIn  = new StreamReader(songsFolder + songName + "\\songs.dta", Encoding.Default);
                            var dtaOut = new StreamWriter(songsFolder + "songs.dta", true, Encoding.Default);

                            while (dtaIn.Peek() >= 0)
                            {
                                var line = dtaIn.ReadLine();

                                if (string.IsNullOrWhiteSpace(line))
                                {
                                    continue;
                                }
                                line = Tools.FixBadChars(line);

                                if (chkID.Checked)
                                {
                                    //replace short id with custom generated id
                                    if (line == "(")
                                    {
                                        dtaOut.WriteLine(line);
                                        dtaIn.ReadLine();

                                        var month = "0" + nextFriday.Month;
                                        month = month.Substring(month.Length - 2, 2);
                                        var day = "0" + nextFriday.Day;
                                        day = day.Substring(day.Length - 2, 2);

                                        line = "      '" + month + day +
                                               nextFriday.Year.ToString(CultureInfo.InvariantCulture)
                                               .Substring(2, 2) + name + filesAdded + "'";
                                    }
                                    else if (!string.IsNullOrWhiteSpace(line) && (line.Substring(0, 1) == "(" && !line.Contains(")")))
                                    {
                                        line = "(" + nextFriday.Month + nextFriday.Day +
                                               nextFriday.Year.ToString(CultureInfo.InvariantCulture)
                                               .Substring(2, 2) + name + filesAdded;
                                    }
                                }

                                if (chkRename.Checked)
                                {
                                    var replace = defaultTool.Checked ? "RECORDING" : "PREVIEW";
                                    //replace artist names to group all together
                                    if (line.ToLowerInvariant().Contains("(artist"))
                                    {
                                        line = "   (artist \"VIDEO " + replace + "\")";
                                    }
                                    if (line.ToLowerInvariant().Contains("'artist'"))
                                    {
                                        dtaOut.WriteLine(line);
                                        dtaIn.ReadLine();
                                        line = "      \"VIDEO " + replace + "\"";
                                    }
                                }

                                if (chkID.Checked)
                                {
                                    //replace song id with custom generated id
                                    if (line.Contains("song_id"))
                                    {
                                        line = "   ('song_id' " + nextFriday.Month + nextFriday.Day +
                                               nextFriday.Year.ToString(CultureInfo.InvariantCulture)
                                               .Substring(2, 2) + name + filesAdded + ")";
                                    }
                                }

                                //add mute level setting so all instruments are heard even when missed
                                if ((line.Contains("'drum_freestyle'") || line.Contains("(drum_freestyle")) && chkVolume.Checked)
                                {
                                    if (line.Contains("'drum_freestyle'"))
                                    {
                                        dtaOut.WriteLine(line);
                                        line = dtaIn.ReadLine();
                                        dtaOut.WriteLine(line);
                                        line = dtaIn.ReadLine();
                                        dtaOut.WriteLine(line);
                                        line = dtaIn.ReadLine();
                                        dtaOut.WriteLine(line);
                                        line = dtaIn.ReadLine();
                                        dtaOut.WriteLine(line);
                                        line = dtaIn.ReadLine();
                                        dtaOut.WriteLine(line);
                                    }
                                    else if (line.Contains("(drum_freestyle"))
                                    {
                                        dtaOut.WriteLine(line);
                                        line = dtaIn.ReadLine();
                                        dtaOut.WriteLine(line);
                                        line = dtaIn.ReadLine();
                                        dtaOut.WriteLine(line);
                                    }
                                    dtaOut.WriteLine("      (mute_volume 0.0)");
                                    dtaOut.WriteLine("      (mute_volume_vocals 0.0)");
                                    line = dtaIn.ReadLine();
                                }

                                if (line != null && !line.Trim().StartsWith(";;", StringComparison.Ordinal))
                                {
                                    dtaOut.WriteLine(line);
                                }
                            }
                            dtaIn.Dispose();
                            dtaOut.WriteLine(""); //separate entries
                            dtaOut.Dispose();

                            //delete original dta files
                            Tools.DeleteFile(songsFolder + songName + "\\songs.dta");
                        }

                        //add mid, mogg and other files found at the songname folder level
                        var songContents = Directory.GetFiles(songsFolder + songName);
                        if (songContents.Count() != 0)
                        {
                            foreach (var contents in songContents)
                            {
                                if (backgroundWorker1.CancellationPending)
                                {
                                    return(false);
                                }
                                packfiles.AddFile(contents, "songs/" + songName + "/" + Path.GetFileName(contents));
                            }
                        }

                        //all all items at the gen level (mostly png_xbox and milo_xbox files)
                        packfiles.AddFolder("songs/" + songName + "/gen");
                        var subContents = Directory.GetFiles(songsFolder + songName + "\\gen");
                        if (!subContents.Any())
                        {
                            continue;
                        }
                        foreach (var contents in subContents)
                        {
                            if (backgroundWorker1.CancellationPending)
                            {
                                return(false);
                            }
                            packfiles.AddFile(contents, "songs/" + songName + "/gen/" + Path.GetFileName(contents));
                        }
                    }
                    //C16 modification. if multiple songs.dta files are found, combine them
                    var c16Dta = Directory.GetFiles(songsFolder, "*.dta");
                    if (c16Dta.Count() > 1)
                    {
                        //prompt user that multiple dtas were found, and to choose whether to combine them (C16) or not
                        var dialogResult =
                            MessageBox.Show("Found multiple songs.dta files in the 'songs' folder\nDo you want me to merge (YES) or discard (NO) the duplicates?\nUnless you're C16 or you know what you're doing, I suggest you discard the duplicates (NO)",
                                            "C16 Modification Activate!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        switch (dialogResult)
                        {
                        case DialogResult.No:
                            foreach (var c16 in c16Dta.Where(c16 => c16.Substring(c16.Length - 9, 9) != "songs.dta"))
                            {
                                Tools.DeleteFile(c16);
                            }
                            break;

                        case DialogResult.Yes:
                        {
                            //create temporary dta file
                            File.Create(songsFolder + "temp_songs.dta").Dispose();

                            //process the duplicate dtas
                            foreach (var c16 in c16Dta)
                            {
                                //read first dta file
                                var dtaIn   = new StreamReader(c16, Encoding.Default);
                                var dtaPack = dtaIn.ReadToEnd();
                                dtaIn.Dispose();

                                //write to temp dta
                                var dtaOut = new StreamWriter(songsFolder + "temp_songs.dta", true, Encoding.Default);
                                dtaOut.Write(dtaPack);
                                dtaOut.Dispose();

                                //delete that dta file
                                Tools.DeleteFile(c16);
                            }

                            //now rename that to songs.dta and just allow existing code to add it to the package
                            Tools.MoveFile(songsFolder + "temp_songs.dta", songsFolder + "songs.dta");
                        }
                        break;
                        }
                    }

                    if (File.Exists(songsFolder + "songs.dta"))
                    {
                        packfiles.AddFile(songsFolder + "songs.dta", "songs/songs.dta");
                    }
                }
            }

            Log("Successfully added files for " + filesAdded + (filesAdded > 1 ? " songs" : " song"));
            if (filesAdded < inputFiles.Count())
            {
                Log("It looks like there were some duplicate songs");
                Log("I skipped: " + (inputFiles.Count() - filesAdded) + (inputFiles.Count() - filesAdded > 1? " songs" : " song"));
            }

            Tools.DeleteFolder(tempFolder + "temp\\", true);
            return(true);
        }