Ejemplo n.º 1
0
        private void AddLanguageList(UIHelper group)
        {
            var dropDown = (group.self as UIComponent).AddUIComponent <LanguageDropDown>();

            dropDown.AddItem(string.Empty, CommonLocalize.ResourceManager.GetString("Mod_LocaleGame", CommonLocalize.Culture));

            foreach (var locale in GetSupportLanguages())
            {
                var localizeString = $"Mod_Locale_{locale}";
                var localeText     = CommonLocalize.ResourceManager.GetString(localizeString, CommonLocalize.Culture);
                if (SingletonMod <TypeMod> .Instance.Culture.Name.ToLower() != locale)
                {
                    localeText += $" ({CommonLocalize.ResourceManager.GetString(localizeString, new CultureInfo(locale))})";
                }

                dropDown.AddItem(locale, localeText);
            }

            dropDown.SelectedObject             = Locale.value;
            dropDown.eventSelectedIndexChanged += IndexChanged;

            void IndexChanged(UIComponent component, int value)
            {
                var locale = dropDown.SelectedObject;

                Locale.value = locale;
                LocaleManager.ForceReload();
            }
        }
Ejemplo n.º 2
0
        private static void AddLanguageList(UIHelper group)
        {
            var locales  = GetSupportLanguages().ToArray();
            var dropDown = (group.self as UIComponent).AddUIComponent <LanguageDropDown>();

            dropDown.AddItem(string.Empty, Localize.Mod_LocaleGame);

            foreach (var locale in locales)
            {
                var localizeString = $"Mod_Locale_{locale}";
                var localeText     = Localize.ResourceManager.GetString(localizeString, Localize.Culture);
                if (Localize.Culture.Name.ToLower() != locale)
                {
                    localeText += $" ({Localize.ResourceManager.GetString(localizeString, new CultureInfo(locale))})";
                }

                dropDown.AddItem(locale, localeText);
            }

            dropDown.SelectedObject = Locale.value;

            dropDown.eventSelectedIndexChanged += IndexChanged;

            void IndexChanged(UIComponent component, int value)
            {
                var locale = dropDown.SelectedObject;

                Locale.value = locale;
                Mod.Instance.LocaleChanged();
                LocaleManager.ForceReload();
            }
        }
 public static void loadLocale(string localeId, bool force)
 {
     if (force)
     {
         LocaleManager.ForceReload();
     }
     loadLocaleIntern(localeId, true);
 }
Ejemplo n.º 4
0
 public override void Group9SettingsUI(UIHelperExtension group9)
 {
     group9.AddDropdownLocalized("KCM_MOD_LANG", KCLocaleUtils.instance.getLanguageIndex(), KCLocaleUtils.currentLanguageId.value, delegate(int idx)
     {
         KCLocaleUtils.currentLanguageId.value = idx;
         LocaleManager.ForceReload();
     });
     group9.AddLabel(Locale.Get("KCM_LANG_NOTICE"));
 }
Ejemplo n.º 5
0
        private static void AddLanguageList(UIHelper group)
        {
            var locales  = GetSupportLanguages().ToArray();
            var dropDown = (group.self as UIComponent).AddUIComponent <LanguageDropDown>();

            dropDown.atlas                = TextureUtil.InGameAtlas;
            dropDown.size                 = new Vector2(400, 38);
            dropDown.listBackground       = "OptionsDropboxListbox";
            dropDown.itemHeight           = 24;
            dropDown.itemHover            = "ListItemHover";
            dropDown.itemHighlight        = "ListItemHighlight";
            dropDown.normalBgSprite       = "OptionsDropbox";
            dropDown.hoveredBgSprite      = "OptionsDropboxHovered";
            dropDown.focusedBgSprite      = "OptionsDropboxFocused";
            dropDown.autoListWidth        = true;
            dropDown.listHeight           = 700;
            dropDown.listPosition         = PopupListPosition.Below;
            dropDown.clampListToScreen    = false;
            dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            dropDown.popupColor           = Color.white;
            dropDown.popupTextColor       = new Color32(170, 170, 170, 255);
            dropDown.textScale            = 1.25f;
            dropDown.textFieldPadding     = new RectOffset(14, 40, 7, 0);
            dropDown.popupColor           = Color.white;
            dropDown.popupTextColor       = new Color32(170, 170, 170, 255);
            dropDown.verticalAlignment    = UIVerticalAlignment.Middle;
            dropDown.horizontalAlignment  = UIHorizontalAlignment.Left;
            dropDown.itemPadding          = new RectOffset(14, 14, 0, 0);
            dropDown.triggerButton        = dropDown;

            dropDown.AddItem(string.Empty, Localize.Mod_LocaleGame);

            foreach (var locale in locales)
            {
                var localizeString = $"Mod_Locale_{locale}";
                var localeText     = Localize.ResourceManager.GetString(localizeString, Localize.Culture);
                if (Localize.Culture.Name.ToLower() != locale)
                {
                    localeText += $" ({Localize.ResourceManager.GetString(localizeString, new CultureInfo(locale))})";
                }

                dropDown.AddItem(locale, localeText);
            }

            dropDown.SelectedObject = Locale.value;

            dropDown.eventSelectedIndexChanged += IndexChanged;

            void IndexChanged(UIComponent component, int value)
            {
                var locale = dropDown.SelectedObject;

                Locale.value = locale;
                LocaleManager.ForceReload();
            }
        }
        public override void OnCreated(ILoading loading)
        {
            // Add post locale change event handlers
            LocaleManager.eventLocaleChanged += OnLocaleChanged;

            Log("Added locale change event handlers.");

            // Reload the current locale once to effect changes
            LocaleManager.ForceReload();
        }
        public static void UnloadLocalization()
        {
            // Remove post locale change event handlers
            LocaleManager.eventLocaleChanged -= OnLocaleChanged;

            DebugUtils.Log("Removed locale change event handlers.");

            // Reload the current locale once to effect changes
            LocaleManager.ForceReload();
        }
        public override void OnReleased()
        {
            // Remove post locale change event handlers
            LocaleManager.eventLocaleChanged -= OnLocaleChanged;

            Log("Removed locale change event handlers.");

            // Reload the current locale once to effect changes
            LocaleManager.ForceReload();
        }
        public static void UnloadLocalization()
        {
            // Remove post locale change event handlers
            LocaleManager.eventLocaleChanged -= OnLocaleChanged;

            Log.Info($"[{nameof(LocalizationManager)}.{nameof(UnloadLocalization)}] Removed locale change event handlers");

            // Reload the current locale once to effect changes
            LocaleManager.ForceReload();
        }
 public static void loadLocale(string localeId, bool force, string prefix = "TLM_", string packagePrefix = "Klyte.TransportLinesManager")
 {
     if (force)
     {
         LocaleManager.ForceReload();
     }
     else
     {
         loadLocaleIntern(localeId, true, prefix, packagePrefix);
     }
 }
Ejemplo n.º 11
0
 private void loadLocale(string localeId, bool force, string prefix = null, string packagePrefix = null)
 {
     if (force)
     {
         LocaleManager.ForceReload();
     }
     else
     {
         loadLocaleIntern(localeId, true, prefix ?? this.prefix, packagePrefix ?? this.packagePrefix);
     }
 }
        public static void LoadLocalization()
        {
            if (_loaded)
            {
                return;
            }

            // Add post locale change event handlers
            LocaleManager.eventLocaleChanged += OnLocaleChanged;

            DebugUtils.Log("Added locale change event handlers.");

            // Reload the current locale once to effect changes
            LocaleManager.ForceReload();

            _loaded = true;
        }
Ejemplo n.º 13
0
        public static void LoadLocalization()
        {
            if (_loaded)
            {
                return;
            }

            // Add post locale change event handlers
            LocaleManager.eventLocaleChanged += OnLocaleChanged;

            Log.Info($"[{nameof(LocalizationManager)}.{nameof(LoadLocalization)}] Added locale change event handlers");

            // Reload the current locale once to effect changes
            LocaleManager.ForceReload();

            _loaded = true;
        }