Ejemplo n.º 1
0
        public static byte[] CreateRB3Pro(CreateProConfig config)
        {
            STFSPackage pk = null;
            bool loadedExisting = false;
            if (config.existingCONFile != null)
            {
                try
                {
                    pk = LoadSTFS(config.existingCONFile);
                }
                catch { }
                if (pk == null)
                {
                    pk = LoadSTFS(Resources.proconfile);
                }
                else
                {
                    loadedExisting = true;
                }
            }
            else
            {
                pk = LoadSTFS(Resources.proconfile);
            }
            bool loadedOK = false;
            if (pk != null)
            {

                //pk.Header.ContentImage = Resources.rockband;
                //pk.Header.PackageImage = Resources.rockband2;
                
                pk.Header.TitleID = config.TitleID;
                //pk.Header.MediaID = 4FC9256F;

                pk.Header.Description = config.description;
                pk.Header.Title_Display = config.displayTitle;

                var folder = pk.GetFolder("songs_upgrades");
                if (loadedExisting)
                {


                    var files = folder.GetSubFiles();

                    bool foundDTA = false;
                    bool foundMID = false;
                    foreach (var f in files)
                    {

                        if (string.Compare(f.Name, "upgrades.dta", StringComparison.OrdinalIgnoreCase) == 0)
                        {

                            string upgradeFile = Encoding.ASCII.GetString(Resources.upgrades);

                            upgradeFile = upgradeFile.Replace("##songshortname##", config.songShortName);
                            upgradeFile = upgradeFile.Replace("##profilename##", config.proMidiFileName);
                            upgradeFile = upgradeFile.Replace("##songid##", config.song_id);
                            upgradeFile = upgradeFile.Replace("##guitardifficulty##", config.guitarDifficulty);
                            upgradeFile = upgradeFile.Replace("##bassdifficulty##", config.bassDifficulty);

                            f.Replace(Encoding.ASCII.GetBytes(upgradeFile));
                            foundDTA = true;
                        }
                        else if (string.Compare(f.Name, config.proMidiFileName, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            f.Replace(config.midFileContents);
                            foundMID = true;
                        }
                    }
                    loadedOK = foundDTA && foundMID;

                    if (!loadedOK)
                    {
                        pk.CloseIO();
                        config.existingCONFile = null;
                        return CreateRB3Pro(config);
                    }
                }
                else
                {
                    foreach (var f in folder.GetSubFiles())
                    {
                        if (f.Name.EndsWith(".mid", StringComparison.OrdinalIgnoreCase) ||
                            f.Name.EndsWith(".midi", StringComparison.OrdinalIgnoreCase))
                        {
                            f.Name = config.proMidiFileName;

                            f.Replace(config.midFileContents);
                        }
                        else if (f.Name.EndsWith(".dta", StringComparison.OrdinalIgnoreCase))
                        {
                            string upgradeFile = Encoding.ASCII.GetString(Resources.upgrades);

                            f.Name = "upgrades.dta";

                            upgradeFile = upgradeFile.Replace("##songshortname##", config.songShortName);
                            upgradeFile = upgradeFile.Replace("##profilename##", config.proMidiFileName);
                            upgradeFile = upgradeFile.Replace("##songid##", config.song_id);
                            upgradeFile = upgradeFile.Replace("##guitardifficulty##", config.guitarDifficulty);
                            upgradeFile = upgradeFile.Replace("##bassdifficulty##", config.bassDifficulty);

                            f.Replace(Encoding.ASCII.GetBytes(upgradeFile));
                        }
                    }
                }
            }


            var bytes = pk.RebuildPackageInMemory(
                new RSAParams(new DJsIO(Resources.KV, true)));

            pk.CloseIO();

            return bytes;
        }