Exemple #1
0
 public void ReplaceFile(string qbFilename, QbFile withQbFile)
 {
     replaceFile(qbFilename, withQbFile.Length, false, delegate(Stream stream)
     {
         withQbFile.Write(stream);
     });
 }
Exemple #2
0
        /// <summary>
        /// Add the non debug item to the user defined list if it's not already there
        /// </summary>
        /// <param name="qbKey"></param>
        /// <param name="qbFilename"></param>
        /// <param name="qbfile"></param>
        /// <returns>True if crc already exists with different text.</returns>
        public string AddNonDebugQbKey(QbKey qbKey, string qbFilename, QbFile qbfile)
        {
            //check that it's not already in the real debug file
            if (qbKey.HasText)
            {
                string t = string.Empty;
                if (qbfile != null)
                {
                    t = qbfile.LookupDebugName(qbKey.Crc, false);
                }

                //it's in the debug file
                if (t.Length != 0)
                {
                    if (t != qbKey.Text)
                    {
                        return(t);
                    }
                }
                else
                {
                    //check that it's not in the user debug file
                    if (GetNonDebugQbKey(qbKey.Crc, qbFilename) == null)
                    {
                        if (_qbKeys == null)
                        {
                            _qbKeys = new List <NonDebugQbKey>();
                        }
                        _qbKeys.Add(new NonDebugQbKey(qbKey, qbFilename));
                    }
                }
            }
            return(string.Empty);
        }
Exemple #3
0
        /// <summary>
        /// Rename the filename, this does not set the fileid for all the qb types
        /// </summary>
        /// <param name="qbFilename">Source full filename.</param>
        /// <param name="newFullQbFilename">Full QB filename</param>
        /// <param name="fileType">.qb or .sqb=QB, .mqb=mid, .img=img .dbg=dbg  etc</param>
        /// <param name="extension">.qb.ngc for Wii for example</param>
        public void RenameFile(string qbFilename, string newQbFilename, QbKey itemType)
        {
            PakHeaderItem phi = _pakHeaders[qbFilename.ToLower()];

            phi.SetFilename(newQbFilename, itemType, _pakFormat.FileExtension, phi);

            using (BinaryEndianWriter bw = new BinaryEndianWriter(File.OpenWrite(_pakFormat.FullPakFilename)))
            {
                bw.BaseStream.Seek(phi.HeaderStart, SeekOrigin.Begin);
                writeHeaderItem(bw, phi);
            }

            //update the filename in the collection
            Dictionary <string, PakHeaderItem> p = new Dictionary <string, PakHeaderItem>(_pakHeaders.Count);

            foreach (PakHeaderItem ph in _pakHeaders.Values)
            {
                p.Add(ph.Filename.ToLower(), ph);
            }

            _pakHeaders = p;

            if (phi.PakFileType == PakItemType.Qb || phi.PakFileType == PakItemType.Sqb || phi.PakFileType == PakItemType.Midi)
            {
                try
                {
                    QbFile qbf = ReadQbFile(newQbFilename);
                    qbf.SetNewFileId();
                    ReplaceFile(newQbFilename, qbf);
                }
                catch
                {
                }
            }
        }
        public override void Construct(BinaryEndianReader br, QbItemType type)
        {
            //System.Diagnostics.Debug.WriteLine(string.Format("{0} - 0x{1}", type.ToString(), (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0')));

            base.Construct(br, type);

            QbItemBase qib;
            QbItemType headerType;
            uint       headerValue;

            for (int i = 0; i < base.ItemCount; i++)
            {
                if (base.StreamPos(br) != base.Pointers[i]) //pointer test
                {
                    throw new ApplicationException(QbFile.FormatBadPointerExceptionMessage(this, base.StreamPos(br), base.Pointers[i]));
                }

                headerValue = br.ReadUInt32(this.Root.PakFormat.EndianType);
                headerType  = this.Root.PakFormat.GetQbItemType(headerValue);

                switch (headerType)
                {
                case QbItemType.StructHeader:
                    qib = new QbItemStruct(this.Root);
                    break;

                default:
                    throw new ApplicationException(string.Format("Location 0x{0}: Not a struct header type 0x{1}", (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0'), headerValue.ToString("X").PadLeft(8, '0')));
                }
                qib.Construct(br, headerType);
                AddItem(qib);
            }

            base.ConstructEnd(br);
        }
Exemple #5
0
        public void NewFile(string newQbFilename, QbKey itemType, bool filenameInHeader, uint magic, byte[] unknownData)
        {
            createBlankFile(newQbFilename, itemType, filenameInHeader);
            QbFile blank = new QbFile(newQbFilename, _pakFormat, magic, unknownData);

            this.ReplaceFile(newQbFilename, blank);
        }
Exemple #6
0
 public QbItemBase(QbFile root)
 {
     _qbFormatSet = false;
     _root = root;
     _lengthCheckStart = 0;
     _items = new List<QbItemBase>();
 }
Exemple #7
0
 public QbItemBase(QbFile root)
 {
     _qbFormatSet      = false;
     _root             = root;
     _lengthCheckStart = 0;
     _items            = new List <QbItemBase>();
 }
Exemple #8
0
        public QbItemType GetInternalType(QbItemType type, QbFile qbFile)
        {
            QbItemType qt = type;

            if (qbFile.PakFormat.StructItemChildrenType == StructItemChildrenType.ArrayItems)
            {
                if (type == QbItemType.StructItemArray)
                {
                    qt = QbItemType.ArrayArray;
                }
                else if (type == QbItemType.StructItemFloat)
                {
                    qt = QbItemType.ArrayFloat;
                }
                else if (type == QbItemType.StructItemFloatsX2)
                {
                    qt = QbItemType.ArrayFloatsX2;
                }
                else if (type == QbItemType.StructItemFloatsX3)
                {
                    qt = QbItemType.ArrayFloatsX3;
                }
                else if (type == QbItemType.StructItemInteger)
                {
                    qt = QbItemType.ArrayInteger;
                }
                else if (type == QbItemType.StructItemQbKey)
                {
                    qt = QbItemType.ArrayQbKey;
                }
                else if (type == QbItemType.StructItemQbKeyString)
                {
                    qt = QbItemType.ArrayQbKeyString;
                }
                else if (type == QbItemType.StructItemStringPointer)
                {
                    qt = QbItemType.ArrayStringPointer;
                }
                else if (type == QbItemType.StructItemQbKeyStringQs)
                {
                    qt = QbItemType.ArrayQbKeyStringQs;
                }
                else if (type == QbItemType.StructItemString)
                {
                    qt = QbItemType.ArrayString;
                }
                else if (type == QbItemType.ArrayStringW)
                {
                    qt = QbItemType.ArrayStringW;
                }
                else if (type == QbItemType.StructItemStruct)
                {
                    qt = QbItemType.ArrayStruct;
                }
            }

            return(qt);
        }
Exemple #9
0
        public QbItemScript(QbFile root)
            : base(root)
        {
            _strings = null;

            if (QbFile.AllowedScriptStringChars == null || QbFile.AllowedScriptStringChars.Length == 0)
                _allowedStringChars = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890\/?!""£$%^&*()-+{}[]'#@~?><,. =®©_";
            else
                _allowedStringChars = QbFile.AllowedScriptStringChars;
        }
Exemple #10
0
        public QbItemScript(QbFile root) : base(root)
        {
            _strings = null;

            if (QbFile.AllowedScriptStringChars == null || QbFile.AllowedScriptStringChars.Length == 0)
            {
                _allowedStringChars = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890\/?!""£$%^&*()-+{}[]'#@~?><,. =®©_";
            }
            else
            {
                _allowedStringChars = QbFile.AllowedScriptStringChars;
            }
        }
Exemple #11
0
        private ApplicationException testLengthCheck(object sender, BinaryEndianWriter bw)
        {
            uint len = this.Length;

            if (this.StreamPos(bw.BaseStream) - _lengthCheckStart != len)
            {
                return(new ApplicationException(QbFile.FormatWriteLengthExceptionMessage(sender, _lengthCheckStart, this.StreamPos(bw.BaseStream), len)));
            }
            else
            {
                return(null);
            }
        }
Exemple #12
0
        /// <summary>
        /// Call after derived class has read its data in Construct()
        /// </summary>
        /// <param name="br"></param>
        public virtual void ConstructEnd(BinaryEndianReader br)
        {
            #region switch
            switch (_qbFormat)
            {
            case QbFormat.SectionValue:
                //Simple section type:
                //  ItemId, FileId, Value, Reserved
                _reserved = br.ReadUInt32(this.Root.PakFormat.EndianType);
                _length  += (1 * 4);
                break;

            case QbFormat.StructItemPointer:
                if (_nextItemPointer != 0 && this.StreamPos(br) != _nextItemPointer)     //pointer test
                {
                    throw new ApplicationException(QbFile.FormatBadPointerExceptionMessage(this, this.StreamPos(br), _nextItemPointer));
                }
                break;

            case QbFormat.StructItemValue:
                //Simple struct type:
                //  ItemId, Value (4 byte), NextItemPointer
                _nextItemPointer = br.ReadUInt32(this.Root.PakFormat.EndianType);
                _length         += (1 * 4);

                if (_nextItemPointer != 0 && this.StreamPos(br) != _nextItemPointer)     //pointer test
                {
                    throw new ApplicationException(QbFile.FormatBadPointerExceptionMessage(this, this.StreamPos(br), _nextItemPointer));
                }
                break;

            case QbFormat.ArrayPointer:
                //Complex array type:
                //  ItemCount, Pointer, Pointers -  (if length is 1 then pointer points to first item and Pointers are abscent)
                for (int i = 0; i < _items.Count; i++)     //_items.Count is 0 for strings (it checks it's own)
                {
                    if (_pointers[i] != _items[i].Position)
                    {
                        throw new ApplicationException(QbFile.FormatBadPointerExceptionMessage(this, _items[i].Position, _pointers[i]));
                    }
                }
                break;

            default:
                break;
            }
            #endregion

            setChildMode();
            //_itemCount = (uint)this.CalcItemCount();
        }
Exemple #13
0
        internal FileManager(Project project, IPluginFileCopy fileCopyPlugin, string gameLocation)
        {
            _pakFormat = null;
            _pakEditor = null;
            _dbgEditor = null;

            _songListQbFile = null;
            _guitarProgressionQbFile = null;

            _project = project;
            _files = new Dictionary<string, GameFile>();
            _fileCopy = fileCopyPlugin;
            _gameLocation = gameLocation;
            _backgroundAudioDatWad = null;
        }
Exemple #14
0
        internal QbItemBase SearchItems(QbFile qbFile, List <QbItemBase> qibs, bool recursive, Predicate <QbItemBase> match)
        {
            QbItemBase ret = null;

            foreach (QbItemBase qib in qibs)
            {
                if (match(qib))
                {
                    return(qib);
                }
                if (recursive && qib.Items.Count != 0)
                {
                    ret = SearchItems(qbFile, qib.Items, recursive, match);
                    if (ret != null)
                    {
                        return(ret);
                    }
                }
            }
            return(ret);
        }
Exemple #15
0
        public override void Construct(BinaryEndianReader br, QbItemType type)
        {
            //System.Diagnostics.Debug.WriteLine(string.Format("{0} - 0x{1}", type.ToString(), (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0')));

            base.Construct(br, type);

            QbItemBase qib;
            QbItemType floatsType;
            uint       floatsValue;
            bool       is3d;

            for (int i = 0; i < base.ItemCount; i++)
            {
                if (base.StreamPos(br) != base.Pointers[i]) //pointer test
                {
                    throw new ApplicationException(QbFile.FormatBadPointerExceptionMessage(this, base.StreamPos(br), base.Pointers[i]));
                }

                floatsValue = br.ReadUInt32(this.Root.PakFormat.EndianType);
                floatsType  = this.Root.PakFormat.GetQbItemType(floatsValue);

                is3d = (type == QbItemType.SectionFloatsX3 || type == QbItemType.StructItemFloatsX3 || type == QbItemType.ArrayFloatsX3);

                switch (floatsType)
                {
                case QbItemType.Floats:
                    qib = new QbItemFloats(this.Root, is3d);
                    break;

                default:
                    throw new ApplicationException(string.Format("Location 0x{0}: Not a float type 0x{1}", (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0'), floatsValue.ToString("X").PadLeft(8, '0')));
                }
                qib.Construct(br, floatsType);
                AddItem(qib);

                base.ConstructEnd(br);
            }
        }
Exemple #16
0
        public void FreeStore(QbFile storeDataQb)
        {
            if (_project.GameInfo.Game == Game.GH3_Wii || _project.GameInfo.Game == Game.GHA_Wii)
            {
                //set all prices to 0
                QbKey price = QbKey.Create("price");
                storeDataQb.FindItem(true, delegate(QbItemBase qib)
                    {
                        if (qib.ItemQbKey != null && qib.ItemQbKey.Crc == price.Crc)
                            ((QbItemInteger)qib).Values[0] = 0;
                        return false; //loop until end of qb
                    });

                storeDataQb.AlignPointers();
                storeDataQb.IsValid();
            }
        }
Exemple #17
0
        /// <summary>
        /// Clones Tier1 to the battle tiers.
        /// </summary>
        /// <param name="guitarProgressionQb"></param>
        public void EditTiers(QbFile guitarProgressionQb, QbFile storeQb, QbFile songlistQb, QbFile coopQb, bool removeBossBattles, int setTierCount, int bonusSongCount, int[] songCounts, bool unlockTiers)
        {
            bool isGh3 = _project.GameInfo.Game == Game.GH3_Wii;
            int minTierSongCount = int.MaxValue; //so we can work out the encore unlock values

            QbKey qkUnlockSong = _project.GameInfo.Game == Game.GH3_Wii ? QbKey.Create("thrufireandflames") : QbKey.Create("kingsandqueens");
            QbKey qkCreditsSong = QbKey.Create("kingsandqueenscredits");
            bool unlockSongExists = false;
            bool creditsSongExists = false;

            QbKey qkDevil = _project.GameInfo.Game == Game.GH3_Wii ? QbKey.Create("bossdevil") : QbKey.Create(""); //don't do it for Aerosmith
            QbKey[] bossSongs = new QbKey[] { QbKey.Create("bosstom"), QbKey.Create("bossslash"), QbKey.Create("bossdevil"), QbKey.Create("bossjoe") };

            string tierSongsComplete = "career_tier{0}_songscomplete";
            QbFile qb = guitarProgressionQb; //short ref

            QbKey tname = QbKey.Create("name");
            QbKey tcomp = QbKey.Create(string.Format(tierSongsComplete, "1"));

            QbItemStruct[] progs = new QbItemStruct[4];
            string[][] masks = new string[4][];

            List<QbKey> careerSongs = getAllCareerSongs(guitarProgressionQb);
            List<QbKey> bonusSongs = getAllBonusSongs(storeQb);
            int usedSong = 0;

            if (removeBossBattles)
            {
                foreach (QbKey qk in bossSongs)
                    careerSongs.Remove(qk);
            }

            if (songCounts != null)
            {
                //find TTFAF or KQ and remove, it will be added as the last song of the career
                for (int c = careerSongs.Count - 1; c >= 0; c--)
                {
                    QbKey qk = careerSongs[c];
                    if (qk.Crc == qkUnlockSong.Crc || qk.Crc == qkCreditsSong.Crc) //TTFAF or KQ (no credits)
                    {
                        careerSongs.Remove(qk);
                        if (qk.Crc == qkUnlockSong.Crc)
                            unlockSongExists = true;
                        else
                            creditsSongExists = true;
                    }
                }

                for (int c = bonusSongs.Count - 1; c >= 0; c--)
                {
                    QbKey qk = bonusSongs[c];
                    if (qk.Crc == qkUnlockSong.Crc || qk.Crc == qkCreditsSong.Crc) //TTFAF or KQ (no credits)
                    {
                        removeBonusSong(storeQb, qk);
                        bonusSongs.Remove(qk);
                        if (qk.Crc == qkUnlockSong.Crc)
                            unlockSongExists = true;
                        else
                            creditsSongExists = true;
                    }
                }
            }
            else if (removeBossBattles && isGh3) //add TTFAF to the end of the career tiers
            {
                for (int c = bonusSongs.Count - 1; c >= 0; c--)
                {
                    QbKey qk = bonusSongs[c];
                    if (qk.Crc == qkUnlockSong.Crc) //TTFAF
                    {
                        removeBonusSong(storeQb, qk);
                        bonusSongs.Remove(qk);
                        unlockSongExists = true;
                        break;
                    }
                }
            }

            //remove the boss items and set to encore
            QbItemStruct careerSongsSec = qb.FindItem(QbKey.Create("GH3_Career_Songs"), false) as QbItemStruct;
            QbItemInteger qbNumTiers = careerSongsSec.FindItem(QbKey.Create("num_tiers"), false) as QbItemInteger;
            int currTierCount = (int)qbNumTiers.Values[0];

            if (setTierCount != 0 && currTierCount != setTierCount)
            {
                setCareerTiers(careerSongsSec, currTierCount, setTierCount, unlockTiers);
                qbNumTiers.Values[0] = (uint)setTierCount;
            }

            if (setTierCount == 0)
                setTierCount = currTierCount; //no change

            #region career editing

            if (careerSongsSec != null)
            {
                QbKey qkEncore = QbKey.Create("encorep1");
                QbKey qkAeroEncore = QbKey.Create("aerosmith_encore_p1");
                QbKey qkBoss = QbKey.Create("boss");
                QbKey qkLevel = QbKey.Create("level");
                QbKey qkSongs = QbKey.Create("songs");
                QbKey qkUnlocked = QbKey.Create("defaultunlocked");
                QbKey qkNumTiers = QbKey.Create("num_tiers");

                int tierCount = 0;
                int tierNo = 0;

                //remove Through the fire and flames. It can only be unlocked with the cheat or by beating the devil
                //this.RemoveBonusSongQbItems(QbKey.Create("thrufireandflames"), storeQb);

                foreach (QbItemBase qib in careerSongsSec.Items)
                {
                    bool hasEncore = false;
                    bool hasBoss = false;
                    List<QbKey> sngs = null;

                    if (qib is QbItemInteger && qib.ItemQbKey != null && qib.ItemQbKey.Crc == qkNumTiers.Crc)
                        tierCount = (int)((QbItemInteger)qib).Values[0];

                    if (qib is QbItemStruct)
                    {
                        tierNo++; //assume they QB hold them in order

                        foreach (QbItemBase qib2 in qib.Items)
                        {
                            bool devilRemoved = false;
                            QbKey qiQk = null;
                            if (qib2.QbItemType == QbItemType.StructItemArray) //find songs to be removed
                            {
                                qiQk = qib2.ItemQbKey;
                                if (qiQk.Crc == qkSongs.Crc)
                                {
                                    if (removeBossBattles) //remove the battles if required
                                    {
                                        sngs = new List<QbKey>(((QbItemQbKey)qib2.Items[0]).Values);
                                        for (int si = sngs.Count - 1; si >= 0; si--)
                                        {
                                            foreach (QbKey k in bossSongs)
                                            {
                                                if (sngs[si].Crc == k.Crc)
                                                {
                                                    devilRemoved = k == qkDevil; //is it the devil?
                                                    removeSongFromSonglist(songlistQb, k);
                                                    sngs.RemoveAt(si--); //remove the boss song from the list
                                                }
                                            }
                                        }
                                    }

                                    //are we to modify the career tier song counts
                                    if (songCounts != null)
                                    {
                                        //set the career tier songs
                                        int tierSongs = songCounts[Math.Min(songCounts.Length - 1, tierNo - 1)];
                                        sngs.Clear();

                                        for (int i = 0; i < tierSongs; i++)
                                        {
                                            //last song of the career, use TTFAF or KQ (no credits)
                                            if (tierNo == tierCount && i == tierSongs - 1 && unlockSongExists)
                                            {
                                                careerSongs.Insert(usedSong, qkUnlockSong);
                                            }
                                            else if (usedSong >= careerSongs.Count)
                                            {
                                                //move song from bonus to career tier
                                                removeBonusSong(storeQb, bonusSongs[0]);
                                                careerSongs.Add(bonusSongs[0]);
                                                bonusSongs.RemoveAt(0);
                                            }

                                            sngs.Add(careerSongs[usedSong++]);
                                        }

                                    }
                                    else if (isGh3 && removeBossBattles && devilRemoved) //if tier songs are not to be edited then add ttfaf to the last tier (replace devil battle)
                                    {
                                        sngs.Add(qkUnlockSong);
                                    }

                                    if (sngs.Count < minTierSongCount)
                                        minTierSongCount = sngs.Count;

                                    ((QbItemQbKey)qib2.Items[0]).Values = sngs.ToArray();
                                }
                            }
                            else if (qib2.QbItemType == QbItemType.StructItemQbKey) //set the encore flag on all tiers, remove the boss
                            {
                                qiQk = ((QbItemQbKey)qib2).Values[0];
                                if (qiQk.Crc == qkEncore.Crc)
                                    hasEncore = true;
                                else if (qiQk.Crc == qkBoss.Crc || qiQk.Crc == qkAeroEncore.Crc)
                                {
                                    if (hasEncore) //just remove the boss or Aerosmith item
                                        qib.RemoveItem(qib2);
                                    else
                                        ((QbItemQbKey)qib2).Values[0] = QbKey.Create("encorep1");
                                    hasBoss = true;
                                    break;
                                }
                                else if (qiQk.Crc == qkLevel.Crc && !hasBoss && !hasEncore)
                                {
                                    QbItemQbKey enc = new QbItemQbKey(qib2.Root);
                                    enc.Create(QbItemType.StructItemQbKey);
                                    enc.Values = new QbKey[] { QbKey.Create("encorep1") };
                                    //insert new item
                                    qib.InsertItem(enc, qib2, true);
                                    break;
                                }
                            }
                            else if (qib2.QbItemType == QbItemType.StructItemInteger)
                            {
                                if (qib2.ItemQbKey != null && qib2.ItemQbKey.Crc == qkUnlocked.Crc && sngs != null && ((QbItemInteger)qib2).Values[0] < (uint)sngs.Count - 1)
                                    ((QbItemInteger)qib2).Values[0] = (uint)sngs.Count - 1;
                            }

                        }
                    }
                }

                if (songCounts == null)
                    usedSong = careerSongs.Count; //songs not touched

                //move the remaining Career Songs to the bonus section - ttfaf will not be the last song
                while (usedSong < careerSongs.Count)
                {
                    bonusSongs.Insert(0, careerSongs[careerSongs.Count - 1]);
                    this.AddBonusSongQbItems(careerSongs[careerSongs.Count - 1], storeQb, true);
                    careerSongs.RemoveAt(careerSongs.Count - 1);
                }

                while (bonusSongs.Count != 0 && bonusSongs.Count > bonusSongCount)
                {
                    this.BonusSongRemoveFromGame(storeQb, songlistQb, bonusSongs[bonusSongs.Count - 1]); //remove from set list also
                    //removeBonusSong(storeQb, bonusSongs[bonusSongs.Count - 1]);
                    bonusSongs.RemoveAt(bonusSongs.Count - 1);
                }

                //set the last bonus song to the creditsSongExists song
                if (!isGh3 && creditsSongExists)
                {
                    if (bonusSongs.Count != 0 && bonusSongs.Count == bonusSongCount) //remove last song
                    {
                        this.BonusSongRemoveFromGame(storeQb, songlistQb, bonusSongs[bonusSongs.Count - 1]); //remove from set list also
                        //removeBonusSong(storeQb, bonusSongs[bonusSongs.Count - 1]);
                        bonusSongs.RemoveAt(bonusSongs.Count - 1);
                    }
                    bonusSongs.Add(qkCreditsSong);
                    this.AddBonusSongQbItems(qkCreditsSong, storeQb, false);
                }

                //System.Diagnostics.Debug.WriteLine("\r\nCAREER\r\n");
                //foreach (QbKey q1 in careerSongs)
                //    System.Diagnostics.Debug.WriteLine(q1.Text);
                //System.Diagnostics.Debug.WriteLine("\r\nBONUS\r\n");
                //foreach (QbKey q1 in bonusSongs)
                //    System.Diagnostics.Debug.WriteLine(q1.Text);

                //set the songs to unlock section
                unlockXSongsToProgress(guitarProgressionQb,
                    Math.Max(1, (int)(minTierSongCount * 0.65)),
                    Math.Max(1, (int)(minTierSongCount * 0.75)),
                    Math.Max(1, (int)(minTierSongCount * 0.85)),
                    Math.Max(1, (int)(minTierSongCount * 0.95)),
                    Math.Max(1, bonusSongs.Count));
            }

            #endregion

            //modify the progression rules.
            QbItemArray careerProgSec = qb.FindItem(QbKey.Create("GH3_Career_Progression"), false) as QbItemArray;
            if (careerProgSec != null)
            {
                //use this temp
                progs[0] = findTierProgStruct(QbKey.Create("career_tier1_intro_songscomplete"), careerProgSec);
                if (progs[0] != null)
                    careerProgSec.Items[0].RemoveItem(progs[0]);

                progs[0] = findTierProgStruct(QbKey.Create("career_tier1_songscomplete"), careerProgSec);
                masks[0] = new string[] { "career_tier{0}_songscomplete", "career_tier{0}_complete" };
                progs[1] = findTierProgStruct(QbKey.Create("career_tier1_encoreunlock"), careerProgSec);
                masks[1] = new string[] { "career_tier{0}_encoreunlock", "career_tier{0}_songscomplete" };
                progs[2] = findTierProgStruct(QbKey.Create("career_tier1_encorecomplete"), careerProgSec);
                masks[2] = new string[] { "career_tier{0}_encorecomplete", "career_tier{0}_encoreunlock" };
                progs[3] = findTierProgStruct(QbKey.Create("career_tier1_complete"), careerProgSec);
                masks[3] = new string[] { "career_tier{0}_complete", "career_tier{0}_songscomplete", "career_tier{0}_encorecomplete" };
                progs[0] = (QbItemStruct)progs[0].Clone(); //we need to clone this before modifying it or the modified version will be saved.
                addDependencyToTier1SongsComplete(progs[0]);

                QbItemStruct copy = null;
                QbItemStruct last = progs[3]; //insert new items after this one
                QbItemBase rem = null;

                if (setTierCount == 1)
                    insertFinishGame(progs[3]);

                //set all prog items that trigger when completing the last tier
                QbKey qkCurr = QbKey.Create(string.Format("career_tier{0}_complete", currTierCount.ToString()));
                QbKey qkLast = QbKey.Create(string.Format("career_tier{0}_complete", setTierCount.ToString()));
                QbKey qkAtom = QbKey.Create("atom");
                careerProgSec.FindItem(true, delegate(QbItemBase qib)
                    {
                        if (qib.ItemQbKey != null && qib.ItemQbKey.Crc == qkAtom.Crc && ((QbItemQbKey)qib).Values[0].Crc == qkCurr.Crc)
                            ((QbItemQbKey)qib).Values[0] = qkLast.Clone(); //set to new last value
                        return false;
                    });

                //copy tier 1 to all tiers
                for (int t = 2; t <= Math.Max(setTierCount, currTierCount); t++)
                {
                    //remove the boss items
                    rem = findTierProgStruct(QbKey.Create(string.Format("career_tier{0}_bosscomplete", t.ToString())), careerProgSec);
                    if (rem != null)
                        careerProgSec.Items[0].RemoveItem(rem);
                    rem = findTierProgStruct(QbKey.Create(string.Format("career_tier{0}_bossunlock", t.ToString())), careerProgSec);
                    if (rem != null)
                        careerProgSec.Items[0].RemoveItem(rem);

                    rem = findTierProgStruct(QbKey.Create(string.Format("career_tier{0}_intro_songscomplete", t.ToString())), careerProgSec);
                    if (rem != null)
                        careerProgSec.Items[0].RemoveItem(rem);

                    for (int p = 0; p < progs.Length; p++)
                    {
                        //replace all 1s for our new number
                        copy = copyTierProg(progs[p], t, masks[p]);

                        //remove the existing item if present
                        rem = findTierProgStruct(((QbItemQbKey)copy.Items[0]).Values[0], careerProgSec);
                        careerProgSec.Items[0].RemoveItem(rem);

                        if (t <= setTierCount)
                        {
                            if (t == setTierCount && p == progs.Length - 1)
                                insertFinishGame(copy);
                            careerProgSec.Items[0].InsertItem(copy, last, false);
                        }
                        qb.AlignPointers();
                        qb.IsValid();

                        last = copy;
                    }
                }
            }

            QbItemStruct[] src = new QbItemStruct[] { (QbItemStruct)qb.FindItem(QbKey.Create("GH3_General_Songs"), false),
                                                      (QbItemStruct)qb.FindItem(QbKey.Create("GH3_GeneralP2_Songs"), false),
                                                      (QbItemStruct)qb.FindItem(QbKey.Create("GH3_GeneralP2_Songs_Coop"), false) };
            for (int i = 0; i < src.Length; i++)
            {
                if (src[i] != null)
                {
                    QbItemStruct dst = copyCareerTiers(careerSongsSec, src[i]);
                    qb.InsertItem(dst, src[i], true);
                    qb.RemoveItem(src[i]);
                    qb.AlignPointers();
                    qb.IsValid();
                }
            }

            if (coopQb != null)
            {
                copyCareerTiersToCoop(coopQb, guitarProgressionQb);
            }
        }
Exemple #18
0
 /// <summary>
 /// Add song to bonus list and shop
 /// </summary>
 /// <param name="songQk"></param>
 public void BonusSongAddToGame(QbFile qbStore, QbFile qbSongList, QbKey qkSong, bool insertAdd)
 {
     //is this song (this) in the bonus tiers already?
     bool found = getAllBonusSongs(qbStore).Contains(qkSong);
     addSongToSonglist(qbSongList, qkSong);
     this.AddBonusSongQbItems(qkSong, qbStore, insertAdd);
 }
Exemple #19
0
 public static QbItemBase CreateQbItemType(QbFile qbFile, QbItemType type)
 {
     return(createQbItemType(qbFile, type, (QbFormat)(-1), false));
 }
Exemple #20
0
 public QbItemInteger(QbFile root)
     : base(root)
 {
 }
 public QbItemStructArray(QbFile root) : base(root)
 {
 }
Exemple #22
0
        public QbItemUnknown(int length, QbFile root) : base(root)
        {
            //System.Diagnostics.Debug.WriteLine(string.Format("{0} - 0x{1}", type.ToString(), (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0')));

            _length = length;
        }
Exemple #23
0
 public QbItemFloatsArray(QbFile root) : base(root)
 {
 }
Exemple #24
0
        public static void SetGenericItems(QbItemBase item, List <GenericQbItem> gItems)
        {
            MemberInfo[] ms = item.GetType().FindMembers(MemberTypes.Property,
                                                         /*BindingFlags.DeclaredOnly |*/ BindingFlags.Instance | BindingFlags.Public,
                                                         Type.FilterName, "*");

            int                  i = 0;
            GenericQbItem        gi;
            List <GenericQbItem> list = null;

            if (gItems.Count == 0)
            {
                //test if this is an array item
                GenericQbItem gqi = QbFile.CreateGenericArrayItem(item);

                //null if not an array type
                if (gqi != null)
                {
                    //use this item to identify the array to set to 0 items
                    MemberInfo m = Array.Find(ms, delegate(MemberInfo mi)
                    {
                        return(mi.Name == gqi.SourceProperty);
                    });
                    if (m != null)
                    {
                        Type t = ((PropertyInfo)m).GetValue(item, null).GetType();
                        if (t == typeof(QbKey[]))
                        {
                            ((PropertyInfo)m).SetValue(item, new QbKey[0], null);
                        }
                        else if (t == typeof(float[]))
                        {
                            ((PropertyInfo)m).SetValue(item, new float[0], null);
                        }
                        else if (t == typeof(uint[]))
                        {
                            ((PropertyInfo)m).SetValue(item, new uint[0], null);
                        }
                        else if (t == typeof(int[]))
                        {
                            ((PropertyInfo)m).SetValue(item, new int[0], null);
                        }
                        else if (t == typeof(string[]))
                        {
                            ((PropertyInfo)m).SetValue(item, new string[0], null);
                        }
                    }
                }
            }


            while (i < gItems.Count)
            {
                gi = gItems[i++];

                if (gi.ReadOnly)
                {
                    continue;
                }

                //list = null;

                list = new List <GenericQbItem>();
                list.Add(gi);
                while (i < gItems.Count && gi.SourceProperty == gItems[i].SourceProperty)
                {
                    list.Add(gItems[i++]);
                }

                MemberInfo m = Array.Find(ms, delegate(MemberInfo mi)
                {
                    return(mi.Name == gi.SourceProperty);
                });

                if (m != null)
                {
                    Type t = ((PropertyInfo)m).GetValue(item, null).GetType();
                    if (t == typeof(QbKey[]))
                    {
                        QbKey[] qb = new QbKey[list.Count];
                        QbKey   q;
                        string  qS;

                        for (int c = 0; c < list.Count; c++)
                        {
                            q  = list[c].ToQbKey();
                            qS = item.Root.LookupDebugName(q.Crc);
                            if (qS.Length != 0)
                            {
                                q = QbKey.Create(q.Crc, qS);
                            }
                            qb[c] = q;
                        }
                        ((PropertyInfo)m).SetValue(item, qb, null);
                    }
                    else if (t == typeof(float[]))
                    {
                        float[] f = new float[list.Count];
                        for (int c = 0; c < list.Count; c++)
                        {
                            f[c] = list[c].ToSingle();
                        }
                        ((PropertyInfo)m).SetValue(item, f, null);
                    }
                    else if (t == typeof(uint[]))
                    {
                        uint[] ui = new uint[list.Count];
                        for (int c = 0; c < list.Count; c++)
                        {
                            ui[c] = list[c].ToUInt32();
                        }
                        ((PropertyInfo)m).SetValue(item, ui, null);
                    }
                    else if (t == typeof(int[]))
                    {
                        int[] si = new int[list.Count];
                        for (int c = 0; c < list.Count; c++)
                        {
                            si[c] = list[c].ToInt32();
                        }
                        ((PropertyInfo)m).SetValue(item, si, null);
                    }
                    else if (t == typeof(string[]))
                    {
                        string[] s = new string[list.Count];
                        for (int c = 0; c < list.Count; c++)
                        {
                            s[c] = list[c].ToString();
                        }
                        ((PropertyInfo)m).SetValue(item, s, null);
                    }
                    else if (t == typeof(QbKey))
                    {
                        QbKey  q  = gi.ToQbKey();
                        string qS = item.Root.LookupDebugName(q.Crc);
                        if (qS.Length != 0)
                        {
                            q = QbKey.Create(q.Crc, qS);
                        }
                        ((PropertyInfo)m).SetValue(item, q, null);
                    }
                    else if (t == typeof(float))
                    {
                        ((PropertyInfo)m).SetValue(item, gi.ToSingle(), null);
                    }
                    else if (t == typeof(uint))
                    {
                        ((PropertyInfo)m).SetValue(item, gi.ToUInt32(), null);
                    }
                    else if (t == typeof(int))
                    {
                        ((PropertyInfo)m).SetValue(item, gi.ToInt32(), null);
                    }
                    else if (t == typeof(string))
                    {
                        ((PropertyInfo)m).SetValue(item, gi.ToString(), null);
                    }
                    else if (t == typeof(byte[]))
                    {
                        ((PropertyInfo)m).SetValue(item, gi.ToByteArray(), null);
                    }
                    else
                    {
                        throw new ApplicationException(string.Format("DataType {0} not supported.", t.Name));
                    }
                }
            }
        }
Exemple #25
0
        private static QbItemBase createQbItemType(QbFile qbFile, QbItemType type, QbFormat qbFormat, bool hasQbFormat)
        {
            QbItemBase qib = null;

            if (qbFile.PakFormat.GetQbItemValue(type, qbFile) == 0xFFFFFFFF)
            {
                throw new ApplicationException(string.Format("'{0}' data value not known for {1}", type.ToString(), qbFile.PakFormat.FriendlyName));
            }

            switch (type)
            {
            //case QbItemType.Unknown:
            //    break;

            case QbItemType.SectionString:
            case QbItemType.SectionStringW:
            case QbItemType.ArrayString:
            case QbItemType.ArrayStringW:
            case QbItemType.StructItemString:
            case QbItemType.StructItemStringW:
                qib = new QbItemString(qbFile);
                break;

            case QbItemType.SectionArray:
            case QbItemType.ArrayArray:
            case QbItemType.StructItemArray:
                qib = new QbItemArray(qbFile);
                break;

            case QbItemType.SectionStruct:
            case QbItemType.StructItemStruct:
            case QbItemType.StructHeader:
                qib = new QbItemStruct(qbFile);
                break;

            case QbItemType.SectionScript:
                qib = new QbItemScript(qbFile);
                break;

            case QbItemType.SectionFloat:
            case QbItemType.ArrayFloat:
            case QbItemType.StructItemFloat:
                qib = new QbItemFloat(qbFile);
                break;

            case QbItemType.SectionFloatsX2:
            case QbItemType.SectionFloatsX3:
            case QbItemType.ArrayFloatsX2:
            case QbItemType.ArrayFloatsX3:
            case QbItemType.StructItemFloatsX2:
            case QbItemType.StructItemFloatsX3:
                qib = new QbItemFloatsArray(qbFile);
                break;

            case QbItemType.SectionInteger:
            case QbItemType.SectionStringPointer:
            case QbItemType.ArrayInteger:
            case QbItemType.ArrayStringPointer:     //GH:GH
            case QbItemType.StructItemStringPointer:
            case QbItemType.StructItemInteger:
                qib = new QbItemInteger(qbFile);
                break;

            case QbItemType.SectionQbKey:
            case QbItemType.SectionQbKeyString:
            case QbItemType.SectionQbKeyStringQs:     //GH:GH
            case QbItemType.ArrayQbKey:
            case QbItemType.ArrayQbKeyString:
            case QbItemType.ArrayQbKeyStringQs:     //GH:GH
            case QbItemType.StructItemQbKey:
            case QbItemType.StructItemQbKeyString:
            case QbItemType.StructItemQbKeyStringQs:
                qib = new QbItemQbKey(qbFile);
                break;

            case QbItemType.Floats:
                qib = new QbItemFloats(qbFile);
                break;

            case QbItemType.ArrayStruct:
                qib = new QbItemStructArray(qbFile);
                break;

            default:
                throw new ApplicationException(string.Format("'{0}' is not recognised by CreateQbItemType.", type.ToString()));
            }
            if (qib != null)
            {
                qib.Create(type);
            }

            return(qib);
        }
Exemple #26
0
 public static QbItemBase CreateQbItemType(QbFile qbFile, QbItemType type, QbFormat qbFormat)
 {
     return(createQbItemType(qbFile, type, qbFormat, true));
 }
Exemple #27
0
 public void RemoveIntroVids(QbFile bootupMenuFlowQb)
 {
     if (_project.GameInfo.Game == Game.GH3_Wii || _project.GameInfo.Game == Game.GHA_Wii)
     {
         //remove the intro videos
         QbItemScript qbs = bootupMenuFlowQb.FindItem(QbKey.Create("bootup_sequence"), false) as QbItemScript;
         if (qbs.ScriptData.Length == 474) //make sure it hasn't already been edited
         {
             byte[] scr = new byte[68 + 130];
             Array.Copy(qbs.ScriptData, scr, 68);
             Array.Copy(qbs.ScriptData, qbs.ScriptData.Length - 130, scr, 68, 130);
             qbs.ScriptData = scr;
             bootupMenuFlowQb.AlignPointers();
             bootupMenuFlowQb.IsValid();
         }
     }
 }
 public QbItemFloats(QbFile root, bool isX3) : base(root)
 {
     this.Values = new float[isX3 ? 3 : 2];
 }
Exemple #29
0
 public QbItemString(QbFile root)
     : base(root)
 {
 }
 public QbItemFloats(QbFile root) : this(root, false)
 {
 }
Exemple #31
0
        /// <summary>
        /// Add a new file in to the PAK, currently just inserts it at the start.
        /// </summary>
        /// <param name="newFullQbFilename">Full QB filename</param>
        /// <param name="fileType">.qb or .sqb=QB, .mqb=mid, .img=img .dbg=dbg  etc</param>
        /// <param name="extension">.qb.ngc for Wii for example</param>
        public void AddFile(QbFile newQbFile, string newQbFilename, QbKey itemType, bool filenameInHeader)
        {
            createBlankFile(newQbFilename, itemType, filenameInHeader);

            this.ReplaceFile(newQbFilename, newQbFile);
        }
        public override void Construct(BinaryEndianReader br, QbItemType type)
        {
            //System.Diagnostics.Debug.WriteLine(string.Format("{0} - 0x{1}", type.ToString(), (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0')));

            base.Construct(br, type);

            uint pointer;

            if (type != QbItemType.StructHeader)
            {
                _headerValue = br.ReadUInt32(base.Root.PakFormat.EndianType);
            }
            else
            {
                _headerValue = base.Root.PakFormat.GetQbItemValue(type, this.Root);
            }

            _headerType = base.Root.PakFormat.GetQbItemType(_headerValue);

            QbItemBase qib = null;
            QbItemType structType;
            uint       structValue;

            if (_headerType == QbItemType.StructHeader)
            {
                pointer = br.ReadUInt32(base.Root.PakFormat.EndianType); //Should be the current stream position after reading

                _iniNextItemPointer = pointer;

                if (pointer != 0 && base.StreamPos(br) != pointer) //pointer test
                {
                    throw new ApplicationException(QbFile.FormatBadPointerExceptionMessage(this, base.StreamPos(br), pointer));
                }

                while (pointer != 0)
                {
                    structValue = br.ReadUInt32(this.Root.PakFormat.EndianType);
                    structType  = this.Root.PakFormat.GetQbItemType(structValue);

                    switch (structType)
                    {
                    case QbItemType.StructItemStruct:
                        this.Root.PakFormat.StructItemChildrenType = StructItemChildrenType.StructItems;
                        qib = new QbItemStruct(this.Root);
                        break;

                    case QbItemType.StructItemStringPointer:
                    case QbItemType.StructItemInteger:
                        this.Root.PakFormat.StructItemChildrenType = StructItemChildrenType.StructItems;
                        qib = new QbItemInteger(this.Root);
                        break;

                    case QbItemType.StructItemQbKeyString:
                    case QbItemType.StructItemQbKeyStringQs:
                    case QbItemType.StructItemQbKey:
                        this.Root.PakFormat.StructItemChildrenType = StructItemChildrenType.StructItems;
                        qib = new QbItemQbKey(this.Root);
                        break;

                    case QbItemType.StructItemString:
                    case QbItemType.StructItemStringW:
                        this.Root.PakFormat.StructItemChildrenType = StructItemChildrenType.StructItems;
                        qib = new QbItemString(this.Root);
                        break;

                    case QbItemType.StructItemFloat:
                        this.Root.PakFormat.StructItemChildrenType = StructItemChildrenType.StructItems;
                        qib = new QbItemFloat(this.Root);
                        break;

                    case QbItemType.StructItemFloatsX2:
                    case QbItemType.StructItemFloatsX3:
                        this.Root.PakFormat.StructItemChildrenType = StructItemChildrenType.StructItems;
                        qib = new QbItemFloatsArray(this.Root);
                        break;

                    case QbItemType.StructItemArray:
                        this.Root.PakFormat.StructItemChildrenType = StructItemChildrenType.StructItems;
                        qib = new QbItemArray(this.Root);
                        break;

                    //Convert array types to structitems to fit in with this parser (if QbFile.HasStructItems is false then internal type will be swapped back to array)
                    case QbItemType.ArrayStruct:
                        structType = QbItemType.StructItemStruct;
                        qib        = new QbItemArray(this.Root);
                        break;

                    case QbItemType.ArrayInteger:
                        structType = QbItemType.StructItemInteger;
                        qib        = new QbItemInteger(this.Root);
                        break;

                    case QbItemType.ArrayQbKeyString:
                        structType = QbItemType.StructItemQbKeyString;
                        qib        = new QbItemQbKey(this.Root);
                        break;

                    case QbItemType.ArrayStringPointer:
                        structType = QbItemType.StructItemStringPointer;
                        qib        = new QbItemInteger(this.Root);
                        break;

                    case QbItemType.ArrayQbKeyStringQs:
                        structType = QbItemType.StructItemQbKeyStringQs;
                        qib        = new QbItemQbKey(this.Root);
                        break;

                    case QbItemType.ArrayQbKey:
                        structType = QbItemType.StructItemQbKey;
                        qib        = new QbItemQbKey(this.Root);
                        break;

                    case QbItemType.ArrayString:
                        structType = QbItemType.StructItemString;
                        qib        = new QbItemString(this.Root);
                        break;

                    case QbItemType.ArrayStringW:
                        structType = QbItemType.StructItemStringW;
                        qib        = new QbItemString(this.Root);
                        break;

                    case QbItemType.ArrayFloat:
                        structType = QbItemType.StructItemFloat;
                        qib        = new QbItemFloat(this.Root);
                        break;

                    case QbItemType.ArrayFloatsX2:
                        structType = QbItemType.StructItemFloatsX2;
                        qib        = new QbItemFloatsArray(this.Root);
                        break;

                    case QbItemType.ArrayFloatsX3:
                        structType = QbItemType.StructItemFloatsX3;
                        qib        = new QbItemFloatsArray(this.Root);
                        break;

                    case QbItemType.ArrayArray:
                        structType = QbItemType.StructItemArray;
                        qib        = new QbItemArray(this.Root);
                        break;

                    default:
                        qib = null;
                        break;
                    }

                    if (qib != null)
                    {
                        if (this.Root.PakFormat.StructItemChildrenType == StructItemChildrenType.NotSet) //will have been set to structItem if qib is not null)
                        {
                            this.Root.PakFormat.StructItemChildrenType = StructItemChildrenType.ArrayItems;
                        }

                        qib.Construct(br, structType);
                        AddItem(qib);
                        pointer = qib.NextItemPointer;
                    }
                    else
                    {
                        throw new ApplicationException(string.Format("Location 0x{0}: Unknown item type 0x{1} in struct ", (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0'), structValue.ToString("X").PadLeft(8, '0')));
                    }
                }
            }
            else
            {
                throw new ApplicationException(string.Format("Location 0x{0}: Struct without header type", (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0')));
            }

            base.ConstructEnd(br);
        }
 public QbItemString(QbFile root) : base(root)
 {
 }
Exemple #34
0
 private void searchItems(QbFile qbFile, List<QbItemBase> qibs, testSearchItem callback)
 {
     foreach (QbItemBase qib in qibs)
     {
         callback(qbFile, qib);
         if (qib.Items.Count != 0)
             searchItems(qbFile, qib.Items, callback);
     }
 }
Exemple #35
0
 public QbItemStruct(QbFile root)
     : base(root)
 {
 }
Exemple #36
0
        private void testQbFile(string filename)
        {
            QbFile qbf;
            QbFile qbTest;
            QbItemString qbs;

            qbf = new QbFile(filename, _pakFormat);
            searchItems(qbf, qbf.Items, delegate(QbFile qbFile, QbItemBase item)
            {
                if ((qbs = (item as QbItemString)) != null)
                {
                    for (int i = 0; i < qbs.Strings.Length; i++)
                        qbs.Strings[i] = "nanook";
                }
            });

            if (File.Exists(filename))
                File.Delete(filename);
            qbf.AlignPointers();
            qbf.Write(filename);

            qbTest = new QbFile(filename, _pakFormat);
            File.Delete(filename);
        }
Exemple #37
0
        private void unlockXSongsToProgress(QbFile guitarProgressionQb, int easy, int medium, int hard, int expert, int bonus)
        {
            Dictionary<uint, int> vals = new Dictionary<uint, int>(4);
            vals.Add(QbKey.Create("easy").Crc, easy);
            vals.Add(QbKey.Create("medium").Crc, medium);
            vals.Add(QbKey.Create("hard").Crc, hard);
            vals.Add(QbKey.Create("expert").Crc, expert);

            if (bonus != 0)
                vals.Add(QbKey.Create("bonus").Crc, bonus);

            //set the tiers to be complete after 1 song complete
            QbKey qk = QbKey.Create("GH3_Career_NumSongToProgress");
            QbItemStruct nsp = guitarProgressionQb.FindItem(false, delegate(QbItemBase qib)
            {
                return (qib.QbItemType == QbItemType.SectionStruct && qib.ItemQbKey.Crc == qk.Crc);
            }) as QbItemStruct;
            if (nsp != null)
            {
                foreach (QbItemBase qib in nsp.Items)
                {
                    if (qib.QbItemType == QbItemType.StructItemInteger && qib.ItemQbKey != null && vals.ContainsKey(qib.ItemQbKey.Crc))
                        ((QbItemInteger)qib).Values[0] = (uint)vals[qib.ItemQbKey.Crc]; //set to 1 item
                }
            }
        }
Exemple #38
0
        private void clearInterfaceQb()
        {
            lstQbItems.Items.Clear();
            clearEditor();
            tlblQbFileInfo.Text = string.Empty;
            btnSavePak.Enabled = false;
            tabQb.Text = "QB File";

            _qbFile = null;

            tabs.SelectedTab = tabPak;
        }
Exemple #39
0
        /// <summary>
        /// Remove song from bonus list and shop
        /// </summary>
        public void BonusSongRemoveFromGame(QbFile qbStore, QbFile qbSongList, QbKey qkSong)
        {
            //is this song (this) in the bonus tiers?
            bool found = getAllBonusSongs(qbStore).Contains(qkSong);

            removeSongFromSonglist(qbSongList, qkSong);

            this.RemoveBonusSongQbItems(qkSong, qbStore);
        }
Exemple #40
0
        public void ResetBonusInfoText(QbFile storeDataQb, string infoText)
        {
            if (_project.GameInfo.Game == Game.GH3_Wii || _project.GameInfo.Game == Game.GHA_Wii)
            {
                QbItemArray qa = storeDataQb.FindItem(QbKey.Create("Bonus_Songs_Info"), false) as QbItemArray;

                if (qa != null)
                {
                    //set all prices to 0
                    QbKey info = QbKey.Create("text");
                    qa.FindItem(true, delegate(QbItemBase qib)
                    {
                        if (qib.ItemQbKey != null && qib.ItemQbKey.Crc == info.Crc)
                            ((QbItemString)qib).Strings[0] = infoText;
                        return false; //loop until end of qb
                    });

                    storeDataQb.AlignPointers();
                    storeDataQb.IsValid();
                }
            }
        }
Exemple #41
0
        /// <summary>
        /// Add song to bonus list and shop
        /// </summary>
        /// <param name="songQk"></param>
        public void AddBonusSongQbItems(QbKey songQk, QbFile qbStore, bool insertAdd)
        {
            QbKey qkCreditsSong = _project.GameInfo.Game == Game.GH3_Wii ? QbKey.Create("thrufireandflames") : QbKey.Create("kingsandqueenscredits");

            //find bonus song list
            QbItemArray bonusSongs = qbStore.FindItem(QbKey.Create("songs"), true) as QbItemArray;

            //find bonus song price list
            QbItemStruct songData = qbStore.FindItem(QbKey.Create("store_song_data"), true) as QbItemStruct;

            //find bonus song info
            QbItemArray bonusInfo = qbStore.FindItem(QbKey.Create("Bonus_Songs_Info"), true) as QbItemArray;

            //add bonus song to list
            if (bonusSongs != null)
            {
                List<QbKey> songs = new List<QbKey>((bonusSongs.Items[0] as QbItemQbKey).Values);
                if (!songs.Contains(songQk))
                {
                    if (insertAdd)
                        songs.Insert(0, songQk.Clone());
                    else
                    {
                        //insert second from the end (before TTFAF / kingandqueenscredits)
                        if (songs.Count == 0 || songs[songs.Count - 1].Crc != qkCreditsSong.Crc)
                            songs.Add(songQk.Clone()); //clone qbkey
                        else
                            songs.Insert(songs.Count - 1, songQk.Clone()); //clone qbkey
                    }
                    (bonusSongs.Items[0] as QbItemQbKey).Values = songs.ToArray();
                }
            }

            if (songData != null)
            {
                //add bonus song price
                if (null == songData.FindItem(false, delegate(QbItemBase qib)
                    {
                        return (qib.ItemQbKey.Crc == songQk.Crc);
                    }))
                {
                    QbItemStruct songDataItem = new QbItemStruct(qbStore);
                    songDataItem.Create(QbItemType.StructItemStruct);
                    songDataItem.ItemQbKey = songQk.Clone();
                    QbItemInteger songDataItemPrice = new QbItemInteger(qbStore);
                    songDataItemPrice.Create(QbItemType.StructItemInteger);
                    songDataItemPrice.ItemQbKey = QbKey.Create("price");
                    songDataItemPrice.Values = new uint[] { 0 };
                    songDataItem.AddItem(songDataItemPrice);
                    if (!insertAdd || songData.Items.Count == 0)
                        songData.AddItem(songDataItem);
                    else
                        songData.InsertItem(songDataItem, songData.Items[0], true);
                }
            }

            if (bonusInfo != null)
            {
                //add bonus info
                QbKey itemQk = QbKey.Create("item");
                QbItemStructArray infoArray = (bonusInfo.Items[0] as QbItemStructArray);
                if (null == infoArray.FindItem(false, delegate(QbItemBase qib)
                    {
                        QbItemQbKey iqk = (QbItemQbKey)(qib.Items[0]);
                        return iqk.ItemQbKey.Crc == itemQk.Crc && iqk.Values[0] == songQk.Crc;
                    }))
                {
                    QbItemStruct infoStruct = new QbItemStruct(qbStore);
                    infoStruct.Create(QbItemType.StructHeader);
                    if (!insertAdd || infoArray.Items.Count == 0)
                        infoArray.AddItem(infoStruct);
                    else
                        infoArray.InsertItem(infoStruct, infoArray.Items[0], true);
                    qbStore.AlignPointers();
                    qbStore.IsValid();
                    QbItemQbKey infoItem = new QbItemQbKey(qbStore);
                    infoItem.Create(QbItemType.StructItemQbKey);
                    infoItem.ItemQbKey = itemQk; //"item"
                    infoItem.Values = new QbKey[] { songQk.Clone() };
                    infoStruct.AddItem(infoItem);
                    qbStore.AlignPointers();
                    qbStore.IsValid();
                    QbItemString infoText = new QbItemString(qbStore);
                    infoText.Create(QbItemType.StructItemString);
                    infoText.ItemQbKey = QbKey.Create("text");
                    infoText.Strings = new string[] { "Bonus song added with TheGHOST" };
                    infoStruct.AddItem(infoText);
                    qbStore.AlignPointers();
                    qbStore.IsValid();
                    QbItemQbKey infoCover = new QbItemQbKey(qbStore);
                    infoCover.Create(QbItemType.StructItemQbKey);
                    infoCover.ItemQbKey = QbKey.Create("album_cover");
                    infoCover.Values = new QbKey[] { QbKey.Create("store_song_default") };
                    infoStruct.AddItem(infoCover);
                    qbStore.AlignPointers();
                    qbStore.IsValid();
                }
            }
        }
Exemple #42
0
 public void SetCheats(QbFile menuCheatsQb)
 {
     if (_project.GameInfo.Game == Game.GH3_Wii || _project.GameInfo.Game == Game.GHA_Wii)
     {
         //edit the cheats
         uint t = 0x00010000;
         uint f = 0x00011000;
         bool b = true;
         menuCheatsQb.FindItem(true, delegate(QbItemBase qib)
         {
             if (qib.QbItemType == QbItemType.StructItemArray && qib.ItemQbKey == QbKey.Create("unlock_pattern"))
             {
                 uint[] ui = new uint[1];
                 if (b)
                 {
                     ui[0] = t;
                     t >>= 4;
                 }
                 else
                 {
                     ui[0] = f;
                     f >>= 4;
                 }
                 b = !b;
                 ((QbItemInteger)qib.Items[0]).Values = ui;
             }
             return false;
         });
         menuCheatsQb.AlignPointers();
         menuCheatsQb.IsValid();
     }
 }
Exemple #43
0
        /// <summary>
        /// Remove song to bonus list and shop
        /// </summary>
        /// <param name="songQk"></param>
        public void RemoveBonusSongQbItems(QbKey songQk, QbFile qbStore)
        {
            QbItemBase item;

            //find bonus song list
            QbItemArray bonusSongs = qbStore.FindItem(QbKey.Create("songs"), true) as QbItemArray;

            //find bonus song price list
            QbItemStruct songData = qbStore.FindItem(QbKey.Create("store_song_data"), true) as QbItemStruct;

            //find bonus song info
            QbItemArray bonusInfo = qbStore.FindItem(QbKey.Create("Bonus_Songs_Info"), true) as QbItemArray;

            //remove bonus song from list
            if (bonusSongs != null)
            {
                List<QbKey> songs = new List<QbKey>((bonusSongs.Items[0] as QbItemQbKey).Values);
                songs.Remove(songQk);
                (bonusSongs.Items[0] as QbItemQbKey).Values = songs.ToArray();
            }

            //remove bonus song price
            if (songData != null)
            {
                item = songData.FindItem(false, delegate(QbItemBase qib)
                    {
                        return (qib.ItemQbKey.Crc == songQk.Crc);
                    });
                if (item != null)
                    songData.RemoveItem(item);
            }

            //remove bonus info
            if (bonusInfo != null && bonusInfo.Items.Count > 0)
            {
                QbKey itemQk = QbKey.Create("item");
                QbItemStructArray infoArray = (bonusInfo.Items[0] as QbItemStructArray);
                item = infoArray.FindItem(false, delegate(QbItemBase qib)
                    {
                        QbItemQbKey iqk = (QbItemQbKey)(qib.Items[0]);
                        return iqk.ItemQbKey.Crc == itemQk.Crc && iqk.Values[0] == songQk.Crc;
                    });
                if (item != null)
                    infoArray.RemoveItem(item);
            }

            qbStore.AlignPointers();
            qbStore.IsValid();
        }
Exemple #44
0
        public void UnlockSetlists(QbFile guitarProgressionQb, QbFile guitarCoOpQb, bool unlockAllTiers, bool completeTier1Song)
        {
            if (_project.GameInfo.Game == Game.GH3_Wii || _project.GameInfo.Game == Game.GHA_Wii)
            {
                List<QbFile> setlists = new List<QbFile>();
                if (guitarProgressionQb != null)
                    setlists.Add(guitarProgressionQb);
                if (guitarCoOpQb != null)
                    setlists.Add(guitarCoOpQb);

                foreach (QbFile qbf in setlists)
                {

                    QbKey qk;
                    if (completeTier1Song)
                        unlockXSongsToProgress(qbf, 1, 1, 1, 1, 0);

                    if (unlockAllTiers)
                    {
                        //display the songs in the tiers
                        List<QbItemStruct> tiers = new List<QbItemStruct>();
                        int t;
                        int i = 1;
                        do
                        {
                            t = tiers.Count;
                            qk = QbKey.Create(string.Format("tier{0}", (i++).ToString()));
                            qbf.FindItem(true, delegate(QbItemBase qib)
                                {
                                    if (qib.QbItemType == QbItemType.StructItemStruct && qk.Crc == qib.ItemQbKey.Crc)
                                        tiers.Add((QbItemStruct)qib);
                                    return false; //find for all setlists
                                });
                        } while (t != tiers.Count);

                        //we do not have ALL tiers for all careers
                        QbItemInteger defaultUnlocked;
                        QbItemArray songs;
                        QbKey duQk = QbKey.Create("defaultunlocked");
                        QbKey sQk = QbKey.Create("songs");
                        foreach (QbItemStruct tier in tiers)
                        {
                            //if no defaultUnlocked item then create one, set it to 20 (won't have mote than 100 songs in a tier
                            defaultUnlocked = tier.FindItem(duQk, false) as QbItemInteger;
                            songs = tier.FindItem(sQk, false) as QbItemArray;

                            if (defaultUnlocked == null)
                            {
                                defaultUnlocked = new QbItemInteger(tier.Root);
                                defaultUnlocked.Create(QbItemType.StructItemInteger);
                                defaultUnlocked.ItemQbKey = duQk.Clone();
                                tier.AddItem(defaultUnlocked);
                            }
                            defaultUnlocked.Values = new uint[] { (uint)((QbItemQbKey)songs.Items[0]).Values.Length };
                        }
                    }
                    qbf.AlignPointers();
                    qbf.IsValid();
                }
            }
        }
Exemple #45
0
        public void ResetBonusArt(QbFile storeDataQb)
        {
            if (_project.GameInfo.Game == Game.GH3_Wii || _project.GameInfo.Game == Game.GHA_Wii)
            {
                QbItemArray qa = storeDataQb.FindItem(QbKey.Create("Bonus_Songs_Info"), false) as QbItemArray;

                if (qa != null)
                {
                    //set all prices to 0
                    QbKey cover = QbKey.Create("album_cover");
                    qa.FindItem(true, delegate(QbItemBase qib)
                    {
                        if (qib.ItemQbKey != null && qib.ItemQbKey.Crc == cover.Crc)
                            ((QbItemQbKey)qib).Values[0] = QbKey.Create("store_song_default");
                        return false; //loop until end of qb
                    });

                    storeDataQb.AlignPointers();
                    storeDataQb.IsValid();
                }
            }
        }
Exemple #46
0
 public QbItemUnknown(byte[] unknownData, uint position, QbFile root) : base(root)
 {
     _unknownData  = unknownData;
     base.Position = position;
 }
Exemple #47
0
 public QbItemQbKey(QbFile root)
     : base(root)
 {
 }
Exemple #48
0
        //#if DEBUG
        //        /// <summary>
        //        /// Edits tiers using the files in Partition folder
        //        /// </summary>
        //        /// <param name="removeBossBattles"></param>
        //        /// <param name="bonusSongs"></param>
        //        /// <param name="songCounts"></param>
        //        public void CoopCopyTest(PakEditor pak)
        //        {
        //            QbKey[] nonCareerSongs = new QbKey[0];
        //            string progQb = @"scripts\guitar\guitar_progression.qb.ngc";
        //            string coopQb = @"scripts\guitar\guitar_coop.qb.ngc";
        //            string storeDataQb = @"scripts\guitar\store_data.qb.ngc";
        //            string songlistQb = @"scripts\guitar\songlist.qb.ngc";
        //            if (_project.GameInfo.Game == Game.GH3_Wii)
        //            {
        //                progQb = progQb.Substring(1);  //remove first char
        //                coopQb = coopQb.Substring(1);  //remove first char
        //                storeDataQb = storeDataQb.Substring(1);  //remove first char
        //                songlistQb = songlistQb.Substring(1);  //remove first char
        //            }
        //            if (_project.GameInfo.Game == Game.GH3_Wii || _project.GameInfo.Game == Game.GHA_Wii)
        //            {
        //                //add song to song list
        //                QbFile qbProg = pak.ReadQbFile(progQb);
        //                QbFile qbCoop = _project.GameInfo.Game == Game.GH3_Wii ? pak.ReadQbFile(coopQb) : null;
        //                QbFile qbStore = pak.ReadQbFile(storeDataQb);
        //                QbFile qbSonglist = pak.ReadQbFile(songlistQb);
        //                copyCareerTiersToCoop(qbCoop, qbProg);
        //                pak.ReplaceFile(coopQb, qbCoop);
        //            }
        //        }
        //#endif
        private void copyCareerTiersToCoop(QbFile coopQb, QbFile guitarProgressionQb)
        {
            int coopMoviesCount = 6;

            QbKey qkEncore = QbKey.Create("encorep1");
            QbKey qkEncore2 = QbKey.Create("encorep2");
            QbKey qkLevel = QbKey.Create("level");
            QbKey qkLevel2 = QbKey.Create("level2");
            QbKey qkNumTiers = QbKey.Create("num_tiers");
            QbKey qkCompMovie = QbKey.Create("completion_movie");
            QbKey qkSetList = QbKey.Create("setlist_icon");
            QbKey qkNumSongs = QbKey.Create("numsongstoprogress");
            QbKey qkCoopNumSongs = QbKey.Create("GH3_COOPCareer_NumSongToProgress");
            QbKey qkAtom = QbKey.Create("atom");
            QbKey qkTier = QbKey.Create("tier");

            QbItemStruct careerSongsSec = guitarProgressionQb.FindItem(QbKey.Create("GH3_Career_Songs"), false) as QbItemStruct;
            QbItemInteger qbNumTiers = careerSongsSec.FindItem(qkNumTiers, false) as QbItemInteger;
            int currTierCount = (int)qbNumTiers.Values[0];

            QbItemStruct coopSongsSec = coopQb.FindItem(QbKey.Create("GH3_CoopCareer_Songs"), false) as QbItemStruct;
            QbItemInteger qbCoopNumTiers = coopSongsSec.FindItem(qkNumTiers, false) as QbItemInteger;
            int currCoopTierCount = (int)qbCoopNumTiers.Values[0];
            qbCoopNumTiers.Values[0] = (uint)currTierCount; //set new value

            //copy file ids

            #region copy setlist

            for (int i = 1; i <= currCoopTierCount; i++)
            {
                QbItemStruct srcTier = coopSongsSec.FindItem(QbKey.Create(string.Format("tier{0}", i.ToString())), false) as QbItemStruct;
                if (srcTier == null)
                    continue;

                coopSongsSec.RemoveItem(srcTier);
            }

            for (int i = 1; i <= currTierCount; i++)
            {
                QbItemStruct srcTier = careerSongsSec.FindItem(QbKey.Create(string.Format("tier{0}", i.ToString())), false) as QbItemStruct;
                if (srcTier == null)
                    continue;

                srcTier = (QbItemStruct)srcTier.Clone();

                foreach (QbItemBase qib in srcTier.Items)
                {
                    if (qib.QbItemType == QbItemType.StructItemQbKey)
                    {
                        if (((QbItemQbKey)qib).Values[0].Crc == qkEncore.Crc)
                            ((QbItemQbKey)qib).Values[0] = qkEncore2.Clone();
                    }
                    else if (qib.QbItemType == QbItemType.StructItemString && qib.ItemQbKey != null && qib.ItemQbKey.Crc == qkCompMovie.Crc)
                    {
                        int m = i + 1;
                        if (m < currTierCount)
                            ((QbItemString)qib).Strings[0] = string.Format("coop_{0}", (m < coopMoviesCount ? m : (m % coopMoviesCount == 0 ? coopMoviesCount : m % coopMoviesCount)).ToString().PadLeft(2,'0'));
                        else
                            ((QbItemString)qib).Strings[0] = "singleplayer_end"; //on 2nd last tier

                    }
                }

                if (i == currTierCount) //last tier
                {
                    QbItemBase tmp = srcTier.FindItem(qkCompMovie, false);
                    if (tmp != null)
                        srcTier.RemoveItem(tmp); //no movie in last coop tier

                    tmp = srcTier.FindItem(qkSetList, false);
                    if (tmp != null)
                        srcTier.RemoveItem(tmp);

                    tmp = new QbItemQbKey(guitarProgressionQb);
                    tmp.Create(QbItemType.StructItemQbKey);
                    tmp.ItemQbKey = qkLevel2.Clone();
                    ((QbItemQbKey)tmp).Values = new QbKey[] { QbKey.Create("load_z_hell") };
                    srcTier.AddItem(tmp);

                    tmp = new QbItemQbKey(guitarProgressionQb);
                    tmp.Create(QbItemType.StructItemQbKey);
                    //tmp.ItemQbKey = null
                    ((QbItemQbKey)tmp).Values = new QbKey[] { QbKey.Create("nocash") };
                    srcTier.AddItem(tmp);

                }

                coopSongsSec.AddItem(srcTier);

                coopQb.AlignPointers();
                coopQb.IsValid();
            }

            #endregion

            #region copy songs to progress values

            QbItemStruct careerSongs = guitarProgressionQb.FindItem(QbKey.Create("GH3_Career_NumSongToProgress"), false) as QbItemStruct;
            QbItemStruct coopSongs = coopQb.FindItem(QbKey.Create("GH3_COOPCareer_NumSongToProgress"), false) as QbItemStruct;

            foreach (QbItemBase qib in careerSongs.Items)
            {
                QbItemInteger qbVal = coopSongs.FindItem(qib.ItemQbKey, false) as QbItemInteger;
                if (qbVal != null)
                    qbVal.Values[0] = ((QbItemInteger)qib).Values[0];
            }

            #endregion

            #region copy progression

            QbItemArray careerSongsProg = guitarProgressionQb.FindItem(QbKey.Create("GH3_Career_Progression"), false) as QbItemArray;
            QbItemArray coopSongsProg = coopQb.FindItem(QbKey.Create("GH3_CoopCareer_Progression"), false) as QbItemArray;

            string[] masks = new string[4];

            masks[0] = "career_tier{0}_songscomplete";
            masks[1] = "career_tier{0}_encoreunlock";
            masks[2] = "career_tier{0}_encorecomplete";
            masks[3] = "career_tier{0}_complete";

            //remove existing progression entries
            for (int i = 1; i <= currCoopTierCount; i++)
            {
                for (int c = 0; c < masks.Length; c++)
                {
                    QbItemBase qib = findTierProgStruct(QbKey.Create(string.Format(masks[c], i.ToString())), coopSongsProg);
                    if (qib != null)
                        coopSongsProg.Items[0].RemoveItem(qib);
                }
            }

            //point all checks for the setlist being complete to the last tier, do while less items in list
            QbKey qkEndOrig = QbKey.Create(string.Format(masks[3], currCoopTierCount - 1)); //-1 if original coop tier list
            QbKey qkEndTG = QbKey.Create(string.Format(masks[3], currCoopTierCount)); //TheGHOST has alreay edited this ISO
            QbKey qkEndNew = QbKey.Create(string.Format(masks[3], currTierCount)); //New value
            coopSongsProg.Items[0].FindItem(true, delegate(QbItemBase qb)
                {
                    if (qb.ItemQbKey != null && qb.ItemQbKey.Crc == qkAtom.Crc)
                    {
                        QbItemQbKey qbk = (QbItemQbKey)qb;
                        if (qbk.Values[0].Crc == qkEndOrig.Crc || qbk.Values[0].Crc == qkEndTG.Crc)
                            qbk.Values[0] = qkEndNew;
                    }
                    return false;
                });

            QbItemBase qibUnlock = findTierProgStruct(QbKey.Create("career_unlock_unlockedsongs"), coopSongsProg);

            //edit to set end unlock info.  We hack this to just point to the last tier (so we can allow GH3 to have 1 toer if required)
            qibUnlock.FindItem(true, delegate(QbItemBase qb)
                {
                    if (qb.ItemQbKey != null && qb.ItemQbKey.Crc == qkTier.Crc)
                        ((QbItemInteger)qb).Values[0] = (uint)currTierCount; //point to the last tier
                    return false;
                });

            //insert new entries
            for (int i = 1; i <= currTierCount; i++)
            {
                for (int c = 0; c < masks.Length; c++)
                {
                    QbItemBase qib = findTierProgStruct(QbKey.Create(string.Format(masks[c], i.ToString())), careerSongsProg);
                    if (qib == null)
                        continue;

                    qib = qib.Clone();

                    qib.FindItem(true, delegate(QbItemBase qb)
                        {
                            if (qb.ItemQbKey != null && qb.ItemQbKey.Crc == qkNumSongs.Crc)
                                ((QbItemQbKey)qb).Values[0] = qkCoopNumSongs.Clone();
                            return false;
                        });

                    coopSongsProg.Items[0].InsertItem(qib, qibUnlock, true);

                }
            }

            #endregion

            coopQb.AlignPointers();
            coopQb.IsValid();
        }
Exemple #49
0
 public uint GetQbItemValue(QbItemType type, QbFile qbFile)
 {
     return(_types[(int)this.GetInternalType(type, qbFile), (int)PakFormatType]);
 }
Exemple #50
0
        public void AddBonusSongsFromNonCareer(QbFile storeDataQb, QbFile songListQb, QbFile guitarProgressionQb)
        {
            List<QbKey> nc = _nonCareerSongs;

            if (nc.Count == 0)
                nc = _specialSongs;

            List<QbKey> c = getAllCareerSongs(guitarProgressionQb);

            foreach (QbKey qk in nc)
            {
                if (c.Contains(qk))
                    continue;

                //add the existing song to the shop
                this.BonusSongAddToGame(storeDataQb, songListQb, qk.Clone(), false);

                //force item to leaderboard
                QbItemStruct qis = songListQb.FindItem(qk, true) as QbItemStruct;
                if (qis != null)
                {
                    QbItemInteger qii = qis.FindItem(QbKey.Create("leaderboard"), false) as QbItemInteger;
                    if (qii != null)
                        qii.Values[0] = 1; //mark as leaderboard
                }

            }
        }
Exemple #51
0
 public QbItemFloat(QbFile root) : base(root)
 {
 }
Exemple #52
0
        private List<QbKey> getAllBonusSongs(QbFile storeData)
        {
            QbItemStruct bonusSongsSec = storeData.FindItem(QbKey.Create("GH3_Bonus_Songs"), false) as QbItemStruct;

            List<QbKey> songs = new List<QbKey>();

            if (bonusSongsSec != null)
            {
                QbKey qkSongs = QbKey.Create("songs");
                bonusSongsSec.FindItem(true, delegate(QbItemBase qib)
                    {
                        if (qib.ItemQbKey != null && qib.ItemQbKey.Crc == qkSongs.Crc)
                            songs.AddRange(((QbItemQbKey)qib.Items[0]).Values);
                        return false;
                    });
            }
            return songs;
        }
Exemple #53
0
 public QbItemFloatsArray(QbFile root)
     : base(root)
 {
 }
Exemple #54
0
        private List<QbKey> getAllCareerSongs(QbFile guitarProgression)
        {
            QbItemStruct careerSongsSec = guitarProgression.FindItem(QbKey.Create("GH3_Career_Songs"), false) as QbItemStruct;

            List<QbKey> songs = new List<QbKey>();

            if (careerSongsSec != null)
            {
                QbKey qkSongs = QbKey.Create("songs");
                careerSongsSec.FindItem(true, delegate(QbItemBase qib)
                    {
                        if (qib.ItemQbKey != null && qib.ItemQbKey.Crc == qkSongs.Crc)
                            songs.AddRange(((QbItemQbKey)qib.Items[0]).Values);
                        return false;
                    });
            }
            return songs;
        }
        public override void Construct(BinaryEndianReader br, QbItemType type)
        {
            //System.Diagnostics.Debug.WriteLine(string.Format("{0} - 0x{1}", type.ToString(), (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0')));

            _isUnicode = ((type == QbItemType.SectionStringW || type == QbItemType.ArrayStringW || type == QbItemType.StructItemStringW) &&
                          (base.Root.PakFormat.PakFormatType == PakFormatType.PC || base.Root.PakFormat.PakFormatType == PakFormatType.XBox));

            byte[] bytes;

            base.Construct(br, type);

            this.Strings = new string[base.ItemCount];

            _charWidth = !_isUnicode ? 1 : 2;

            if (base.ItemCount != 0)
            {
                //use pointers to read quickly
                if (base.ItemCount > 1)
                {
                    for (int i = 0; i < base.ItemCount - 1; i++)
                    {
                        if (base.StreamPos(br) != base.Pointers[i]) //pointer test
                        {
                            throw new ApplicationException(QbFile.FormatBadPointerExceptionMessage(this, base.StreamPos(br), base.Pointers[i]));
                        }

                        bytes = br.ReadBytes((int)((base.Pointers[i + 1] - _charWidth) - base.StreamPos(br)));

                        _strings[i] = bytesToString(bytes); //handles unicode

                        if (!_isUnicode ? (br.ReadByte() != 0) : (br.ReadByte() != 0 || br.ReadByte() != 0))
                        {
                            throw new ApplicationException(string.Format("Null byte expected reading string array at 0x{0}", (base.StreamPos(br) - _charWidth).ToString("X").PadLeft(8, '0')));
                        }
                    }

                    if (base.StreamPos(br) != base.Pointers[base.ItemCount - 1]) //pointer test
                    {
                        throw new ApplicationException(QbFile.FormatBadPointerExceptionMessage(this, base.StreamPos(br), base.Pointers[base.ItemCount - 1]));
                    }
                }


                //use the slow method read the last string
                StringBuilder sb = new StringBuilder();
                //if we have come from an array we must align our position to %4
                int byteAmount = (int)(4 - (base.StreamPos(br) % 4));

                do
                {
                    bytes = br.ReadBytes(byteAmount);
                    sb.Append(bytesToString(bytes));
                    byteAmount = 4;
                }while (!_isUnicode ? (bytes[bytes.Length - 1] != '\0') : (bytes[bytes.Length - 1] != '\0' || bytes[bytes.Length - 2] != '\0'));


                //get text and remove any trailing null bytes
                _strings[base.ItemCount - 1] = sb.ToString().TrimEnd(new char[] { '\0' });
            }
            base.ConstructEnd(br);
        }
Exemple #56
0
        private bool removeBonusSong(QbFile storeQb, QbKey songId)
        {
            //find bonus song list
            QbItemArray bonusSongs = storeQb.FindItem(true, delegate(QbItemBase qib)
            {
                return (qib.QbItemType == QbItemType.StructItemArray && qib.ItemQbKey == QbKey.Create("songs"));
            }) as QbItemArray;

            //remove bonus song from list
            List<QbKey> songs = new List<QbKey>((bonusSongs.Items[0] as QbItemQbKey).Values);

            if (songs.Exists(delegate(QbKey qk)
                {
                    return qk.Crc == songId.Crc;
                }))
            {
                this.RemoveBonusSongQbItems(songId, storeQb);
                return true;
            }
            else
                return false;
        }
Exemple #57
0
 public QbItemInteger(QbFile root) : base(root)
 {
 }
Exemple #58
0
        private void removeSongFromSonglist(QbFile qbSongList, QbKey qkSong)
        {
            QbItemArray songsList = qbSongList.FindItem(QbKey.Create("gh3_songlist"), false) as QbItemArray;
            if (songsList != null)
            {
                List<QbKey> songlistQk = new List<QbKey>(((QbItemQbKey)songsList.Items[0]).Values);

                if (songlistQk.Contains(qkSong))
                    songlistQk.Remove(qkSong);

                //update gh3_songlist
                ((QbItemQbKey)songsList.Items[0]).Values = songlistQk.ToArray();

                qbSongList.AlignPointers();
                qbSongList.IsValid();
            }
        }
Exemple #59
0
        private static void addSongToSonglist(QbFile qbSongList, QbKey qkSong)
        {
            QbItemStruct songs = qbSongList.FindItem(QbKey.Create("permanent_songlist_props"), false) as QbItemStruct;
            QbItemArray songsList = qbSongList.FindItem(QbKey.Create("gh3_songlist"), false) as QbItemArray;
            if (songsList != null)
            {
                List<QbKey> songlistQk = new List<QbKey>(((QbItemQbKey)songsList.Items[0]).Values);

                if (!songlistQk.Contains(qkSong))
                {
                    songs.AddItem((QbItemBase)SongQb.CreateSong(songs.Root, qkSong.Text));
                    songlistQk.Add(qkSong);
                }

                //update gh3_songlist
                ((QbItemQbKey)songsList.Items[0]).Values = songlistQk.ToArray();

                qbSongList.AlignPointers();
                qbSongList.IsValid();
            }
        }
Exemple #60
0
 public QbItemQbKey(QbFile root) : base(root)
 {
 }