AlignPointers() public method

public AlignPointers ( ) : void
return void
Example #1
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();
         }
     }
 }
Example #2
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();
                }
            }
        }
Example #3
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();
            }
        }
Example #4
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();
        }
Example #5
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();
            }
        }
Example #6
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();
                }
            }
        }
Example #7
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();
            }
        }
Example #8
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();
        }
Example #9
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();
     }
 }
Example #10
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();
                }
            }
        }
Example #11
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);
        }
Example #12
0
        private void calculateMarkers(int[] frets, QbItemArray arr, QbFile text)
        {
            int minNote = this.Notes.MinNoteOffsetSynced + _startPaddingMs + _fretPadding;
            int maxNote = this.Notes.MaxNoteOffsetSynced + _startPaddingMs + _fretPadding;

            int pos = minNote;

            int sectionSecs = 20000;
            int sections = (maxNote - minNote) / sectionSecs; //every x seconds

            for (int c = text.Items.Count - 1; c > 0; c--)
                text.RemoveItem(text.Items[c]);

            QbItemStructArray sa = new QbItemStructArray(arr.Root);
            sa.Create(QbItemType.ArrayStruct);

            arr.Items.Clear();
            arr.AddItem(sa);

            QbItemStruct s;
            QbItemInteger i;
            QbItemQbKey q;
            string sectionTitle;
            QbKey qbKey;
            QbItemString txt;

            for (int c = 0; c < sections; c++)
            {
                if (pos + 3000 > this.Length)
                    break; //don't create a section less than 3 seconds long

                sectionTitle = string.Format("Section {0}", (c + 1).ToString());
                qbKey = QbKey.Create(string.Format("{0}_markers_text_{1}", this.SongQb.Id, QbKey.Create(sectionTitle).Crc.ToString("x").ToLower()));

                txt = new QbItemString(text);
                txt.Create(QbItemType.SectionString);
                txt.ItemQbKey = qbKey;
                txt.Strings = new string[] { sectionTitle };
                text.AddItem(txt);

                s = new QbItemStruct(arr.Root);
                s.Create(QbItemType.StructHeader);
                sa.AddItem(s);

                i = new QbItemInteger(arr.Root);
                i.Create(QbItemType.StructItemInteger);
                i.ItemQbKey = QbKey.Create("time");
                i.Values = new uint[] { findNearestFret((uint)pos, frets) };
                s.AddItem(i);

                pos += sectionSecs;

                q = new QbItemQbKey(arr.Root);
                q.Create(QbItemType.StructItemQbKeyString);
                q.ItemQbKey = QbKey.Create("marker");
                q.Values = new QbKey[] { qbKey };
                s.AddItem(q);
            }

            text.AlignPointers();
            arr.Root.AlignPointers();
        }
Example #13
0
        private void setMarkers(int[] frets, QbItemArray arr, QbFile text, NotesMarker[] markers)
        {
            int minNote = this.Notes.MinNoteOffsetSynced + _startPaddingMs + _fretPadding;
            QbItemStruct s;
            QbItemInteger i;
            QbItemQbKey q;
            QbKey qbKey;
            QbItemString txt;

            for (int c = text.Items.Count - 1; c > 0; c--)
                text.RemoveItem(text.Items[c]);

            if (arr.Items[0] is QbItemFloats)
            {
                QbItemStructArray newArr = new QbItemStructArray(arr.Root);
                newArr.Create(QbItemType.ArrayStruct);
                arr.AddItem(newArr);
                arr.RemoveItem(arr.Items[0]);
            }

            QbItemStructArray sa = (QbItemStructArray)arr.Items[0];
            sa.Items.Clear();

            NotesMarker marker;

            List<NotesMarker> mrk = new List<NotesMarker>(markers);

            if (mrk.Count > 0 && mrk[0].Offset > minNote)  //some charts don't have sections at the start so you can't practice the start notes :-(
            {
                if (mrk[0].Offset > minNote + 5000) // if > 5secs then add new
                    mrk.Insert(0, new NotesMarker("Start", minNote));
                else //else move first marker back to start
                    mrk[0].Offset = minNote;
            }

            for (int c = 0; c < mrk.Count; c++)
            {
                marker = mrk[c];
                if (c < mrk.Count - 1 && mrk[c + 1].Offset < minNote)
                    continue; //don't add sections at the start that would have no notes (crashes song??)

                qbKey = QbKey.Create(string.Format("{0}_markers_text_{1}", this.SongQb.Id, QbKey.Create(marker.Title).Crc.ToString("x").ToLower()));

                txt = new QbItemString(text);
                txt.Create(QbItemType.SectionString);
                txt.ItemQbKey = qbKey;
                txt.Strings = new string[] { marker.Title };
                text.AddItem(txt);

                s = new QbItemStruct(arr.Root);
                s.Create(QbItemType.StructHeader);
                sa.AddItem(s);

                i = new QbItemInteger(arr.Root);
                i.Create(QbItemType.StructItemInteger);
                i.ItemQbKey = QbKey.Create("time");
                i.Values = new uint[] { findNearestFret((uint)marker.Offset, frets) };
                s.AddItem(i);

                q = new QbItemQbKey(arr.Root);
                q.Create(QbItemType.StructItemQbKeyString);
                q.ItemQbKey = QbKey.Create("marker");
                q.Values = new QbKey[] { qbKey };
                s.AddItem(q);
            }
            text.AlignPointers();
            arr.Root.AlignPointers();
        }