Beispiel #1
0
    private void SetONIStaticSessionVariables()
    {
        ThreadedHttps <KleiMetrics> .Instance.SetStaticSessionVariable("Branch", "release");

        ThreadedHttps <KleiMetrics> .Instance.SetStaticSessionVariable("Build", 365655u);

        if (KPlayerPrefs.HasKey(UnitConfigurationScreen.MassUnitKey))
        {
            ThreadedHttps <KleiMetrics> .Instance.SetStaticSessionVariable(UnitConfigurationScreen.MassUnitKey, KPlayerPrefs.GetInt(UnitConfigurationScreen.MassUnitKey).ToString());
        }
        if (KPlayerPrefs.HasKey(UnitConfigurationScreen.TemperatureUnitKey))
        {
            ThreadedHttps <KleiMetrics> .Instance.SetStaticSessionVariable(UnitConfigurationScreen.TemperatureUnitKey, KPlayerPrefs.GetInt(UnitConfigurationScreen.TemperatureUnitKey).ToString());
        }
        if (SteamManager.Initialized)
        {
            PublishedFileId_t installed;
            string            installedLanguageCode = LanguageOptionsScreen.GetInstalledLanguageCode(out installed);
            if (installed != PublishedFileId_t.Invalid)
            {
                ThreadedHttps <KleiMetrics> .Instance.SetStaticSessionVariable(LanguagePackKey, installed.m_PublishedFileId);
            }
            if (!string.IsNullOrEmpty(installedLanguageCode))
            {
                ThreadedHttps <KleiMetrics> .Instance.SetStaticSessionVariable(LanguageCodeKey, installedLanguageCode);
            }
        }
    }
    public static void Initialize(bool dontCheckSteam = false)
    {
        DebugUtil.LogArgs("Localization.Initialize!");
        bool flag = false;

        switch (GetSelectedLanguageType())
        {
        case SelectedLanguageType.Preinstalled:
        {
            string selectedPreinstalledLanguageCode = GetSelectedPreinstalledLanguageCode();
            if (!string.IsNullOrEmpty(selectedPreinstalledLanguageCode))
            {
                DebugUtil.LogArgs("Localization Initialize... Preinstalled localization");
                DebugUtil.LogArgs(" -> ", selectedPreinstalledLanguageCode);
                LoadPreinstalledTranslation(selectedPreinstalledLanguageCode);
            }
            else
            {
                flag = true;
            }
            break;
        }

        case SelectedLanguageType.UGC:
            if (!dontCheckSteam && SteamManager.Initialized && LanguageOptionsScreen.HasInstalledLanguage())
            {
                DebugUtil.LogArgs("Localization Initialize... SteamUGCService");
                PublishedFileId_t item = PublishedFileId_t.Invalid;
                LanguageOptionsScreen.LoadTranslation(ref item);
                if (item != PublishedFileId_t.Invalid)
                {
                    DebugUtil.LogArgs(" -> Loaded steamworks file id: ", item.ToString());
                }
                else
                {
                    DebugUtil.LogArgs(" -> Failed to load steamworks file id: ", item.ToString());
                }
            }
            else
            {
                flag = true;
            }
            break;

        case SelectedLanguageType.None:
            sFontAsset = GetFont(GetDefaultLocale().FontName);
            break;
        }
        if (flag)
        {
            ClearLanguage();
        }
    }
Beispiel #3
0
    private void RebuildUGCButtons()
    {
        ListPool <SteamUGCService.Mod, ScenariosMenu> .PooledList pooledList = ListPool <SteamUGCService.Mod, ScenariosMenu> .Allocate();

        bool flag = pooledList.Count > 0;

        noScenariosText.gameObject.SetActive(!flag);
        contentRoot.gameObject.SetActive(flag);
        bool flag2 = true;

        if (pooledList.Count != 0)
        {
            for (int i = 0; i < pooledList.Count; i++)
            {
                GameObject gameObject = Util.KInstantiateUI(ugcButtonPrefab, ugcContainer, false);
                gameObject.name = pooledList[i].title + "_button";
                gameObject.gameObject.SetActive(true);
                HierarchyReferences component      = gameObject.GetComponent <HierarchyReferences>();
                TMP_FontAsset       fontForLangage = LanguageOptionsScreen.GetFontForLangage(pooledList[i].fileId);
                LocText             reference      = component.GetReference <LocText>("Title");
                reference.SetText(pooledList[i].title);
                reference.font = fontForLangage;
                Texture2D previewImage = pooledList[i].previewImage;
                if ((UnityEngine.Object)previewImage != (UnityEngine.Object)null)
                {
                    Image reference2 = component.GetReference <Image>("Image");
                    reference2.sprite = Sprite.Create(previewImage, new Rect(Vector2.zero, new Vector2((float)previewImage.width, (float)previewImage.height)), Vector2.one * 0.5f);
                }
                KButton           component2 = gameObject.GetComponent <KButton>();
                int               index      = i;
                PublishedFileId_t item       = pooledList[index].fileId;
                component2.onClick += delegate
                {
                    ShowDetails(item);
                };
                component2.onDoubleClick += delegate
                {
                    LoadScenario(item);
                };
                buttons.Add(gameObject);
                if (item == activeItem)
                {
                    flag2 = false;
                }
            }
        }
        if (flag2)
        {
            HideDetails();
        }
        pooledList.Recycle();
    }
    public static void ClearLanguage()
    {
        DebugUtil.LogArgs(" -> Clearing selected language! Either it didn't load correct or returning to english by menu.");
        sFontAsset = null;
        sLocale    = null;
        KPlayerPrefs.SetString(SELECTED_LANGUAGE_TYPE_KEY, 0.ToString());
        KPlayerPrefs.SetString(SELECTED_LANGUAGE_CODE_KEY, string.Empty);
        SwapToLocalizedFont(GetDefaultLocale().FontName);
        string defaultLocalizationFilePath = GetDefaultLocalizationFilePath();

        if (File.Exists(defaultLocalizationFilePath))
        {
            string[] lines = File.ReadAllLines(defaultLocalizationFilePath, Encoding.UTF8);
            LoadTranslation(lines, true);
        }
        LanguageOptionsScreen.CleanUpCurrentModLanguage();
    }
    private void Translations()
    {
        LanguageOptionsScreen languageOptionsScreen = Util.KInstantiateUI <LanguageOptionsScreen>(ScreenPrefabs.Instance.languageOptionsScreen.gameObject, base.transform.parent.gameObject, false);

        languageOptionsScreen.SetBackgroundActive(true);
    }
 public static void VerifyTranslationModSubscription(GameObject context)
 {
     if (GetSelectedLanguageType() == SelectedLanguageType.UGC && SteamManager.Initialized && !LanguageOptionsScreen.HasInstalledLanguage())
     {
         PublishedFileId_t invalid           = PublishedFileId_t.Invalid;
         PublishedFileId_t publishedFileId_t = new PublishedFileId_t((uint)KPlayerPrefs.GetInt("InstalledLanguage", (int)invalid.m_PublishedFileId));
         Label             label             = default(Label);
         label.distribution_platform = Label.DistributionPlatform.Steam;
         label.id = publishedFileId_t.ToString();
         Label  rhs = label;
         string arg = UI.FRONTEND.TRANSLATIONS_SCREEN.UNKNOWN;
         foreach (Mod mod in Global.Instance.modManager.mods)
         {
             if (mod.label.Match(rhs))
             {
                 arg = mod.title;
                 break;
             }
         }
         ClearLanguage();
         GameObject gameObject = KScreenManager.AddChild(context, ScreenPrefabs.Instance.ConfirmDialogScreen.gameObject);
         KScreen    component  = gameObject.GetComponent <KScreen>();
         component.Activate();
         ConfirmDialogScreen component2          = component.GetComponent <ConfirmDialogScreen>();
         ConfirmDialogScreen confirmDialogScreen = component2;
         string        title_text   = UI.CONFIRMDIALOG.DIALOG_HEADER;
         string        text         = string.Format(UI.FRONTEND.TRANSLATIONS_SCREEN.MISSING_LANGUAGE_PACK, arg);
         string        confirm_text = UI.FRONTEND.TRANSLATIONS_SCREEN.RESTART;
         System.Action on_confirm   = App.instance.Restart;
         confirmDialogScreen.PopupConfirmDialog(text, on_confirm, null, null, null, title_text, confirm_text, null, null, true);
     }
 }