Example #1
0
        public GameLanguageHandle GetEngineLanguage(int langIndex)
        {
            Contract.Requires <ArgumentOutOfRangeException>(LanguageRegistry.IsValidLanguageIndex(langIndex));
            Contract.Assert(mEngineLanguageTable != null, kErrorMessageNotInitialized);

            return(mEngineLanguageTable[langIndex]);
        }
Example #2
0
		internal GameLanguageHandle(Engine.EngineBuildHandle buildHandle, int langIndex, int gameIndex)
		{
			Contract.Requires(LanguageRegistry.IsValidLanguageIndex(langIndex));
			Contract.Requires(IsValidGameIndex(gameIndex));

			InitializeHandle(out mHandle, buildHandle, langIndex, gameIndex);
		}
Example #3
0
        public bool IsEngineLanguageOptional(int langIndex)
        {
            if (!LanguageRegistry.IsValidLanguageIndex(langIndex))
            {
                throw new ArgumentOutOfRangeException(nameof(langIndex), langIndex, "Out of bounds");
            }
            Contract.Assert(mEngineLanguageTable != null, kErrorMessageNotInitialized);

            return(mOptionalEngineLanguageFlags[langIndex]);
        }
Example #4
0
        void ReadEngineLanguageTable <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            const string kElementNameEntry       = "E";
            const string kAttributeNameGameIndex = "id";
            const string kAttributeNameLangIndex = "lang";
            const string kAttributeNameOptional  = "optional";

            // number of languages for this build of the engine
            int lang_count = 0;

            foreach (var e in s.ElementsByName(kElementNameEntry))
            {
                using (s.EnterCursorBookmark(e))
                {
                    int  game_index  = TypeExtensions.kNone;
                    int  lang_index  = TypeExtensions.kNone;
                    bool is_optional = false;

                    s.ReadAttribute(kAttributeNameGameIndex, ref game_index, NumeralBase.Decimal);
                    LanguageRegistry.SerializeLanguageId(s, kAttributeNameLangIndex, ref lang_index);
                    s.ReadAttributeOpt(kAttributeNameOptional, ref is_optional);

                    if (IsInvalidGameIndexFromStream(game_index) || lang_index.IsNone())
                    {
                        s.ThrowReadException(new System.IO.InvalidDataException("Invalid table entry data"));
                    }

                    mEngineLanguageTable[lang_index] = new GameLanguageHandle(mBuildHandle, lang_index, game_index);
                    if (is_optional)
                    {
                        mOptionalEngineLanguageFlags[lang_index] = true;
                        mOptionalGameLanguageFlags[game_index]   = true;
                    }

                    lang_count++;
                }
            }

            if (lang_count == 0)
            {
                s.ThrowReadException(new System.IO.InvalidDataException("Table has no entries"));
            }

            if (!InitializeGameLanguageTableFromEngineTable(lang_count))
            {
                s.ThrowReadException(new System.IO.InvalidDataException("Invalid game index data"));
            }
        }
Example #5
0
		//internal uint Handle { get { return mHandle; } }

		static void InitializeHandle(out uint handle,
			Engine.EngineBuildHandle buildHandle, int langIndex, int gameIndex)
		{
			uint is_supported = gameIndex.IsNotNone() ? 1U : 0U;

			var encoder = new Bitwise.HandleBitEncoder();
			encoder.EncodeNoneable32(gameIndex, Constants.kGameIndexBitField);
			encoder.Encode32(is_supported, Constants.kIsSupportedBitField);
			LanguageRegistry.BitEncodeLanguageIndex(ref encoder, langIndex);
			encoder.Encode32(buildHandle.Handle, Constants.kBuildBitField);

			Contract.Assert(encoder.UsedBitCount == GameLanguageHandle.BitCount);

			handle = encoder.GetHandle32();
		}
Example #6
0
		public static bool IsValidGameIndex(int index) { return LanguageRegistry.IsValidLanguageIndex(index); }
Example #7
0
        public int LanguageIndexToGameIndex(int langIndex)
        {
            Contract.Requires <ArgumentOutOfRangeException>(LanguageRegistry.IsValidLanguageIndex(langIndex));

            return(GetEngineLanguage(langIndex).GameIndex);
        }