Пример #1
0
        /// <summary>
        /// Check if font of specified name and locale have been registered.
        /// </summary>
        /// <param name="locale">Locale of font.</param>
        /// <param name="fontName">Name of font, which must be one of the 5 Daggerfall fonts.</param>
        /// <returns>True if font of this name and locale has been registered.</returns>
        public bool HasLocalizedFont(Locale locale, DaggerfallFont.FontName fontName)
        {
            if (locale == null)
            {
                return(false);
            }

            return(localizedFonts.ContainsKey(GetLocaleFontKey(locale, fontName)));
        }
Пример #2
0
        /// <summary>
        /// Gets a registered DaggerfallFont replacement for current locale.
        /// </summary>
        /// <param name="fontName"></param>
        /// <returns></returns>
        public DaggerfallFont GetLocalizedFont(DaggerfallFont.FontName fontName)
        {
            Locale selectedLocale;
            var    op = LocalizationSettings.SelectedLocaleAsync;

            if (op.IsDone)
            {
                selectedLocale = op.Result;
            }
            else
            {
                return(null);
            }

            return(GetLocalizedFont(selectedLocale, fontName));
        }
Пример #3
0
        /// <summary>
        /// Check if font of specified name is available in current locale.
        /// </summary>
        /// <param name="fontName">Name of font, which must be one of the 5 Daggerfall fonts.</param>
        /// <returns>True if font of this name has been registered in current locale.</returns>
        public bool HasLocalizedFont(DaggerfallFont.FontName fontName)
        {
            Locale selectedLocale;
            var    op = LocalizationSettings.SelectedLocaleAsync;

            if (op.IsDone)
            {
                selectedLocale = op.Result;
            }
            else
            {
                return(false);
            }

            return(localizedFonts.ContainsKey(GetLocaleFontKey(selectedLocale, fontName)));
        }
Пример #4
0
        /// <summary>
        /// Gets a registered Daggerfall replacement for specified name and locale.
        /// </summary>
        /// <param name="locale">Locale of font.</param>
        /// <param name="fontName">Name of font, which must be one of the 5 Daggerfall fonts.</param>
        /// <returns>DaggerfallFont object if registered, otherwise null.</returns>
        public DaggerfallFont GetLocalizedFont(Locale locale, DaggerfallFont.FontName fontName)
        {
            if (locale == null)
            {
                return(null);
            }

            DaggerfallFont font;

            if (localizedFonts.TryGetValue(GetLocaleFontKey(locale, fontName), out font))
            {
                return(font);
            }

            return(null);
        }
Пример #5
0
        /// <summary>
        /// Gets a registered DaggerfallFont replacement for current locale.
        /// </summary>
        /// <param name="fontName"></param>
        /// <returns></returns>
        public DaggerfallFont GetLocalizedFont(DaggerfallFont.FontName fontName)
        {
            Locale selectedLocale = null;
            var    op             = LocalizationSettings.SelectedLocaleAsync;

            if (op.IsDone)
            {
                selectedLocale = op.Result;
            }
            else
            {
                op.Completed += (o) => selectedLocale = o.Result;
            }

            return((selectedLocale != null) ? GetLocalizedFont(selectedLocale, fontName) : null);
        }
Пример #6
0
        /// <summary>
        /// Check if font of specified name is available in current locale.
        /// </summary>
        /// <param name="fontName">Name of font, which must be one of the 5 Daggerfall fonts.</param>
        /// <returns>True if font of this name has been registered in current locale.</returns>
        public bool HasLocalizedFont(DaggerfallFont.FontName fontName)
        {
            Locale selectedLocale = null;
            var    op             = LocalizationSettings.SelectedLocaleAsync;

            if (op.IsDone)
            {
                selectedLocale = op.Result;
            }
            else
            {
                op.Completed += (o) => selectedLocale = o.Result;
            }

            return((selectedLocale != null) ? localizedFonts.ContainsKey(GetLocaleFontKey(selectedLocale, fontName)) : false);
        }
Пример #7
0
        /// <summary>
        /// Register a DaggerfallFont replacement to be used for specified locale.
        /// If this font name and locale replacement has already been registered, it will be replaced by this font.
        /// Note: Localized fonts can only be SDF capable. SDF font setting will be forced on by registering any custom font.
        /// </summary>
        /// <param name="locale">Locale of font.</param>
        /// <param name="fontName">Name of font, which must be one of the 5 Daggerfall fonts.</param>
        /// <param name="font">DaggerfallFont object to use for this font name and locale.</param>
        public void RegisterLocalizedFont(Locale locale, DaggerfallFont.FontName fontName, DaggerfallFont font)
        {
            if (locale == null || font == null)
            {
                Debug.LogError("RegisterLocalizedFont() locale and font cannot be null.");
            }

            string key = GetLocaleFontKey(locale, fontName);

            if (localizedFonts.ContainsKey(key))
            {
                localizedFonts.Remove(key);
            }

            localizedFonts.Add(key, font);
            DaggerfallUnity.Settings.SDFFontRendering = true;
        }
Пример #8
0
        /// <summary>
        /// Gets a registered DaggerfallFont replacement for current locale.
        /// </summary>
        /// <param name="fontName"></param>
        /// <returns></returns>
        public DaggerfallFont GetLocalizedFont(DaggerfallFont.FontName fontName)
        {
            Locale selectedLocale = null;
            var    op             = LocalizationSettings.SelectedLocaleAsync;

            op.WaitForCompletion();
            if (op.IsDone)
            {
                selectedLocale = op.Result;
            }
            else
            {
                Debug.LogError("GetLocalizedFont() failed LocalizationSettings.SelectedLocaleAsync operation");
            }

            return((selectedLocale != null) ? GetLocalizedFont(selectedLocale, fontName) : null);
        }
Пример #9
0
        /// <summary>
        /// Check if font of specified name is available in current locale.
        /// </summary>
        /// <param name="fontName">Name of font, which must be one of the 5 Daggerfall fonts.</param>
        /// <returns>True if font of this name has been registered in current locale.</returns>
        public bool HasLocalizedFont(DaggerfallFont.FontName fontName)
        {
            Locale selectedLocale = null;
            var    op             = LocalizationSettings.SelectedLocaleAsync;

            op.WaitForCompletion();
            if (op.IsDone)
            {
                selectedLocale = op.Result;
            }
            else
            {
                Debug.LogError("HasLocalizedFont() failed LocalizationSettings.SelectedLocaleAsync operation");
            }

            return((selectedLocale != null) ? localizedFonts.ContainsKey(GetLocaleFontKey(selectedLocale, fontName)) : false);
        }
Пример #10
0
 private string GetLocaleFontKey(Locale locale, DaggerfallFont.FontName fontName)
 {
     return(string.Format("{0}_{1}", fontName, locale.name));
 }
Пример #11
0
 void ChangeFont(DaggerfallFont.FontName fontName)
 {
     currentFont = DaggerfallUI.Instance.GetFont(fontName);
 }