Пример #1
0
        /// <summary>
        /// Loads all of the locale symbols defined in an XML document.
        /// </summary>
        /// <param name="layoutDocument">The XML document to load locale symbols from.</param>
        /// <returns>The symbols that were loaded.</returns>
        public static LocaleSymbolCollection LoadLocaleSymbols(XDocument symbolDocument)
        {
            // Make sure there is a root <symbols> tag
            XContainer container = symbolDocument.Element("symbols");
            if (container == null)
                throw new ArgumentException("Invalid symbols document");

            // Symbol tags have the format:
            // <symbol code="0x(the byte array)" display="(Friendly Name)" />
            LocaleSymbolCollection result = new LocaleSymbolCollection();
            foreach (XElement symbol in container.Elements("symbol"))
            {
                string code = XMLUtil.GetStringAttribute(symbol, "code");
                string display = XMLUtil.GetStringAttribute(symbol, "display");

                // Convert code to int
                code = code.Replace("0x", "");
                byte[] codeBytes = FunctionHelpers.HexStringToBytes(code);
                string codeString = Encoding.UTF8.GetString(codeBytes);
                char codeChar = codeString[0];

                result.AddSymbol(codeChar, display);
            }
            return result;
        }
        /// <summary>
        /// Adds a collection of symbols to this symbol collection.
        /// </summary>
        /// <param name="symbols">The symbols to add.</param>
        public void AddSymbols(LocaleSymbolCollection symbols)
        {
            foreach (var symbol in symbols._charReplacements)
                _charReplacements[symbol.Key] = symbol.Value;

            foreach (var str in symbols._stringReplacements)
                _stringReplacements[str.Key] = str.Value;
        }
Пример #3
0
 public ThirdGenLanguage(StructureValueCollection values, FileSegmenter segmenter, FileSegmentGroup localeArea, BuildInformation buildInfo)
 {
     _pointerLayout = buildInfo.GetLayout("locale index table entry");
     _encryptionKey = buildInfo.LocaleKey;
     _symbols = buildInfo.LocaleSymbols;
     _localeArea = localeArea;
     _sizeAlign = (_encryptionKey != null) ? AES.BlockSize : 1;
     Load(values, segmenter, localeArea);
 }
Пример #4
0
        /// <summary>
        ///     Adds a collection of symbols to this symbol collection.
        /// </summary>
        /// <param name="symbols">The symbols to add.</param>
        public void AddSymbols(LocaleSymbolCollection symbols)
        {
            foreach (var symbol in symbols._charReplacements)
            {
                _charReplacements[symbol.Key] = symbol.Value;
            }

            foreach (var str in symbols._stringReplacements)
            {
                _stringReplacements[str.Key] = str.Value;
            }
        }
Пример #5
0
        public LocaleEditor(GameLanguage language, ICacheFile cache, IStreamManager streamManager, Trie stringIdTrie,
			LocaleSymbolCollection symbols)
        {
            InitializeComponent();

            _currentLanguage = language;
            _cache = cache;
            _streamManager = streamManager;
            _symbols = symbols;
            StringIDTrie = stringIdTrie;

            // Thread the loading routine
            var thrd = new Thread(LoadAll);
            thrd.SetApartmentState(ApartmentState.STA);
            thrd.Start();
        }