コード例 #1
0
        /// <summary>
        ///     Constructs a new StringID from a length, a set, and an index.
        /// </summary>
        /// <param name="length">The length of the string.</param>
        /// <param name="nspace">The namespace the stringID belongs to.</param>
        /// <param name="index">The index of the stringID within the set.</param>
        /// <param name="layout">The layout of the stringID.</param>
        public StringID(int length, int nspace, int index, StringIDLayout layout)
        {
            var shiftedLength    = (int)((length & CreateMask(layout.LengthSize)) << layout.LengthStart);
            var shiftedNamespace = (int)((nspace & CreateMask(layout.NamespaceSize)) << layout.NamespaceStart);
            var shiftedIndex     = (int)((index & CreateMask(layout.IndexSize)) << layout.IndexStart);

            _value = (uint)(shiftedLength | shiftedNamespace | shiftedIndex);
        }
コード例 #2
0
        /// <summary>
        ///     Constructs a new StringID from a length, a set, and an index.
        /// </summary>
        /// <param name="length">The length of the string.</param>
        /// <param name="set">The set the stringID belongs to.</param>
        /// <param name="index">The index of the stringID within the set.</param>
        /// <param name="layout">The layout of the stringID.</param>
        public StringID(int length, int set, int index, StringIDLayout layout)
        {
            var shiftedLength = (int)((length & CreateMask(layout.LengthSize)) << layout.LengthStart);
            var shiftedSet    = (int)((set & CreateMask(layout.SetSize)) << layout.SetStart);
            var shiftedIndex  = (int)((index & CreateMask(layout.IndexSize)) << layout.IndexStart);

            _value = (uint)(shiftedLength | shiftedSet | shiftedIndex);
        }
コード例 #3
0
        /// <summary>
        ///     Loads stringID set definitions from an XML document.
        /// </summary>
        /// <param name="document">The XML document to load set definitions from.</param>
        /// <returns>The StringIDSetResolver that was created.</returns>
        public static StringIDNamespaceResolver LoadStringIDNamespaces(XDocument document)
        {
            // Make sure there is a root <stringIDs> tag
            XElement container = document.Element("stringIDs");

            if (container == null)
            {
                throw new ArgumentException("Invalid stringID definition document");
            }

            StringIDLayout idLayout = ProcessIDLayoutInfo(container);

            // Process <set> elements
            var resolver = new StringIDNamespaceResolver(idLayout);

            foreach (XElement element in container.Elements("namespace"))
            {
                ProcessSetElement(element, resolver);
            }

            return(resolver);
        }
コード例 #4
0
 public StringIDSetResolver(StringIDLayout idLayout)
 {
     IDLayout = idLayout;
 }
コード例 #5
0
 public StringIDNamespaceResolver(StringIDLayout idLayout)
 {
     IDLayout = idLayout;
 }
コード例 #6
0
 /// <summary>
 ///     Gets the index of the string within the set.
 /// </summary>
 /// <param name="layout">The stringID layout to use to parse the index.</param>
 /// <returns>The index portion of the stringID.</returns>
 public int GetIndex(StringIDLayout layout)
 {
     return((int)((Value >> layout.IndexStart) & CreateMask(layout.IndexSize)));
 }
コード例 #7
0
 /// <summary>
 ///     Gets the set that the stringID belongs to.
 /// </summary>
 /// <param name="layout">The stringID layout to use to parse the set.</param>
 /// <returns>The set portion of the stringID.</returns>
 public int GetNamespace(StringIDLayout layout)
 {
     return((int)((Value >> layout.NamespaceStart) & CreateMask(layout.NamespaceSize)));
 }
コード例 #8
0
 /// <summary>
 ///     Gets the length portion of the stringID. Can be 0 for some games.
 /// </summary>
 /// <param name="layout">The stringID layout to use to parse the length.</param>
 /// <returns>The length portion of the stringID.</returns>
 public int GetLength(StringIDLayout layout)
 {
     return((int)((Value >> layout.LengthStart) & CreateMask(layout.LengthSize)));
 }
コード例 #9
0
 /// <summary>
 ///     Constructs a new StringID from a set and an index.
 /// </summary>
 /// <param name="nspace">The namespace the stringID belongs to.</param>
 /// <param name="index">The index of the stringID within the set.</param>
 /// <param name="layout">The layout of the stringID.</param>
 public StringID(int nspace, int index, StringIDLayout layout)
     : this(0, nspace, index, layout)
 {
 }
コード例 #10
0
 /// <summary>
 ///     Gets the set that the stringID belongs to.
 /// </summary>
 /// <param name="layout">The stringID layout to use to parse the set.</param>
 /// <returns>The set portion of the stringID.</returns>
 public int GetSet(StringIDLayout layout)
 {
     return((int)((Value >> layout.SetStart) & CreateMask(layout.SetSize)));
 }
コード例 #11
0
 /// <summary>
 ///     Constructs a new StringID from a set and an index.
 /// </summary>
 /// <param name="set">The set the stringID belongs to.</param>
 /// <param name="index">The index of the stringID within the set.</param>
 /// <param name="layout">The layout of the stringID.</param>
 public StringID(int set, int index, StringIDLayout layout)
     : this(0, set, index, layout)
 {
 }
コード例 #12
0
 /// <summary>
 ///     Constructs a new LengthBasedStringIDResolver.
 /// </summary>
 /// <param name="strings">The IndexedStringTable to reference to get string lengths.</param>
 public LengthBasedStringIDResolver(IndexedStringTable strings)
 {
     _strings = strings;
     IDLayout = new StringIDLayout(24, 0, 8);             // TODO: is it necessary to make this a build option?
 }