/// <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); }
/// <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); }
/// <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); }
public StringIDSetResolver(StringIDLayout idLayout) { IDLayout = idLayout; }
public StringIDNamespaceResolver(StringIDLayout idLayout) { IDLayout = idLayout; }
/// <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))); }
/// <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))); }
/// <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))); }
/// <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) { }
/// <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))); }
/// <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) { }
/// <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? }