Create() public method

public Create ( QbItemType type ) : void
type QbItemType
return void
示例#1
0
        /// <summary>
        /// Deep clones this item and all children.  Positions and lengths are not cloned.  When inserted in to another item they should be calculated.
        /// </summary>
        /// <returns></returns>
        public override QbItemBase Clone()
        {
            QbItemInteger qi = new QbItemInteger(this.Root);
            qi.Create(this.QbItemType);

            if (this.ItemQbKey != null)
                qi.ItemQbKey = this.ItemQbKey.Clone();

            uint[] ii = new uint[this.Values.Length];
            for (int i = 0; i < ii.Length; i++)
                ii[i] = this.Values[i];

            qi.Values = ii;
            qi.ItemCount = this.ItemCount;

            return qi;
        }
示例#2
0
        public override QbItemBase Clone()
        {
            QbItemInteger qi = new QbItemInteger(this.Root);

            qi.Create(this.QbItemType);

            if (this.ItemQbKey != null)
            {
                qi.ItemQbKey = this.ItemQbKey.Clone();
            }

            int[] ii = new int[this.Values.Length];
            for (int i = 0; i < ii.Length; i++)
            {
                ii[i] = Values[i];
            }

            qi.Values    = ii;
            qi.ItemCount = this.ItemCount;

            return(qi);
        }
示例#3
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();
                }
            }
        }
示例#4
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();
                }
            }
        }
示例#5
0
文件: SongQb.cs 项目: Nanook/TheGHOST
        public static QbItemStruct CreateSong(QbFile root, string songname)
        {
            QbItemStruct song = new QbItemStruct(root);
            song.Create(QbItemType.StructItemStruct);
            song.ItemQbKey = QbKey.Create(songname);

            QbItemQbKey checksum = new QbItemQbKey(root);
            checksum.Create(QbItemType.StructItemQbKey);
            checksum.ItemQbKey = QbKey.Create("checksum");
            checksum.Values = new QbKey[] { QbKey.Create(songname) };
            song.AddItem(checksum);

            QbItemString name = new QbItemString(root);
            name.Create(QbItemType.StructItemString);
            name.ItemQbKey = QbKey.Create("name");
            name.Strings = new string[] { songname };
            song.AddItem(name);

            QbItemString title = new QbItemString(root);
            title.Create(QbItemType.StructItemString);
            title.ItemQbKey = QbKey.Create("title");
            title.Strings = new string[] { songname };
            song.AddItem(title);

            QbItemString artist = new QbItemString(root);
            artist.Create(QbItemType.StructItemString);
            artist.ItemQbKey = QbKey.Create("artist");
            artist.Strings = new string[] { songname };
            song.AddItem(artist);

            QbItemString year = new QbItemString(root);
            year.Create(QbItemType.StructItemString);
            year.ItemQbKey = QbKey.Create("year");
            year.Strings = new string[] { string.Empty };
            song.AddItem(year);

            QbItemQbKey artistText = new QbItemQbKey(root);
            artistText.Create(QbItemType.StructItemQbKeyString);
            artistText.ItemQbKey = QbKey.Create("artist_text");
            artistText.Values = new QbKey[] { QbKey.Create("artist_text_by") };
            song.AddItem(artistText);

            QbItemInteger originalArtist = new QbItemInteger(root);
            originalArtist.Create(QbItemType.StructItemInteger);
            originalArtist.ItemQbKey = QbKey.Create("original_artist");
            originalArtist.Values = new uint[] { 1 };
            song.AddItem(originalArtist);

            QbItemQbKey version = new QbItemQbKey(root);
            version.Create(QbItemType.StructItemQbKey);
            version.ItemQbKey = QbKey.Create("version");
            version.Values = new QbKey[] { QbKey.Create("gh3") };
            song.AddItem(version);

            QbItemInteger leaderboard = new QbItemInteger(root);
            leaderboard.Create(QbItemType.StructItemInteger);
            leaderboard.ItemQbKey = QbKey.Create("leaderboard");
            leaderboard.Values = new uint[] { 1 };
            song.AddItem(leaderboard);

            QbItemInteger gemOffset = new QbItemInteger(root);
            gemOffset.Create(QbItemType.StructItemInteger);
            gemOffset.ItemQbKey = QbKey.Create("gem_offset");
            gemOffset.Values = new uint[] { 0 };
            song.AddItem(gemOffset);

            QbItemInteger inputOffset = new QbItemInteger(root);
            inputOffset.Create(QbItemType.StructItemInteger);
            inputOffset.ItemQbKey = QbKey.Create("input_offset");
            inputOffset.Values = new uint[] { 0 };
            song.AddItem(inputOffset);

            QbItemQbKey singer = new QbItemQbKey(root);
            singer.Create(QbItemType.StructItemQbKey);
            singer.ItemQbKey = QbKey.Create("singer");
            singer.Values = new QbKey[] { QbKey.Create("male") };
            song.AddItem(singer);

            QbItemQbKey keyboard = new QbItemQbKey(root);
            keyboard.Create(QbItemType.StructItemQbKey);
            keyboard.ItemQbKey = QbKey.Create("keyboard");
            keyboard.Values = new QbKey[] { QbKey.Create("false") };
            song.AddItem(keyboard);

            QbItemFloat bandPlaybackVolume = new QbItemFloat(root);
            bandPlaybackVolume.Create(QbItemType.StructItemFloat);
            bandPlaybackVolume.ItemQbKey = QbKey.Create("band_playback_volume");
            bandPlaybackVolume.Values = new float[] { 0F };
            song.AddItem(bandPlaybackVolume);

            QbItemFloat guitarPlaybackVolume = new QbItemFloat(root);
            guitarPlaybackVolume.Create(QbItemType.StructItemFloat);
            guitarPlaybackVolume.ItemQbKey = QbKey.Create("guitar_playback_volume");
            guitarPlaybackVolume.Values = new float[] { 0F };
            song.AddItem(guitarPlaybackVolume);

            QbItemString countOff = new QbItemString(root);
            countOff.Create(QbItemType.StructItemString);
            countOff.ItemQbKey = QbKey.Create("countoff");
            countOff.Strings = new string[] { "sticks_normal" };
            song.AddItem(countOff);

            QbItemInteger rhythmTrack = new QbItemInteger(root);
            rhythmTrack.Create(QbItemType.StructItemInteger);
            rhythmTrack.ItemQbKey = QbKey.Create("rhythm_track");
            rhythmTrack.Values = new uint[] { 0 };
            song.AddItem(rhythmTrack);

            return song;
        }
示例#6
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();
        }
示例#7
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();
        }
示例#8
0
        private void replaceQbItems(QbItemArray a, int[] items, bool split, int splitBy)
        {
            a.Items.Clear();

            //no items to add
            if (items.Length == 0)
            {
                QbItemFloats f = new QbItemFloats(a.Root);
                f.Create(QbItemType.Floats);
                a.AddItem(f);
                a.Root.AlignPointers();
            }
            else
            {
                if (!split)
                {
                    //add array to parent as one large array
                    QbItemInteger qi = new QbItemInteger(a.Root);
                    qi.Create(QbItemType.ArrayInteger);
                    qi.Values = convertIntArrayToUIntArray(items);
                    a.AddItem(qi);
                    a.Root.AlignPointers();
                }
                else
                {
                    //split array down in to blocks of <splitBy>
                    QbItemInteger qi;
                    QbItemArray aa = new QbItemArray(a.Root);
                    aa.Create(QbItemType.ArrayArray);
                    uint[] uints;
                    a.AddItem(aa);
                    a.Root.AlignPointers();

                    for (int i = 0; i < items.Length; i += splitBy)
                    {
                        qi = new QbItemInteger(a.Root);
                        qi.Create(QbItemType.ArrayInteger);
                        uints = new uint[splitBy];
                        for (int j = 0; j < splitBy; j++)
                            uints[j] = (uint)items[i + j];
                        qi.Values = uints;
                        aa.AddItem(qi);
                        a.Root.AlignPointers();
                    }

                }
            }
        }