Exemple #1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="count">The initial number of entries in the tlk file.</param>
        public Tlk(int count)
        {
            name = string.Empty;
            header = new TlkHeader();
            resRefs = new RawResRef[count];
            strings = new string[count];

            header.fileType = tlkFile;
            header.fileVersion = tlkVersion;
            header.stringCount = count;
            header.stringOffset = 0;

            for (int i = 0; i < count; i++)
            {
                resRefs[i] = new RawResRef();
                resRefs[i].flags = (int) ResRefFlags.None;
                resRefs[i].offsetToString = 0;
                resRefs[i].pitchVariance = 0;
                resRefs[i].soundLength = 0;
                resRefs[i].soundResRef = string.Empty;
                resRefs[i].stringSize = 0;
                resRefs[i].volumeVariance = 0;

                strings[i] = string.Empty;
            }
        }
Exemple #2
0
        /// <summary>
        /// Pads the tlk to have at least the specified number of entries.  If the tlk file
        /// has less entries than what is given, blank entries are inserted to pad.
        /// </summary>
        /// <param name="length">The new number of entries</param>
        public void Pad(int length)
        {
            // If the tlk file is larger than the pad count then do nothing.
            if (header.stringCount >= length) return;

            // Add blank entries to the tlk file to pad.
            RawResRef[] padded = new RawResRef[length];
            resRefs.CopyTo(padded, 0);
            for (int i = resRefs.Length; i < padded.Length; i++)
            {
                padded[i].flags = 0;
                padded[i].offsetToString = 0;
                padded[i].pitchVariance = 0;
                padded[i].stringSize = 0;
                padded[i].volumeVariance = 0;
                padded[i].soundLength = 0.0f;
                padded[i].soundResRef = string.Empty;
            }

            string[] paddedStrings = new string[length];
            paddedStrings.CopyTo(strings, 0);
            for (int i = strings.Length; i < paddedStrings.Length; i++)
                paddedStrings[i] = string.Empty;

            // Save the new RawResRef array and update the number of entries in
            // the header.
            header.stringCount = length;
            resRefs = padded;
            strings = paddedStrings;
        }