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);
     }
 }
Beispiel #2
0
 public static int SessionID()
 {
     if (sessionID == -1)
     {
         sessionID = KPlayerPrefs.GetInt("SESSION_ID", -1);
     }
     return(sessionID);
 }
Beispiel #3
0
 public static int GameID()
 {
     if (gameID == -1)
     {
         gameID = KPlayerPrefs.GetInt("GAME_ID", -1);
     }
     return(gameID);
 }
Beispiel #4
0
 private void RestoreLegacyMetricsSetting()
 {
     if (KPlayerPrefs.GetInt("ENABLE_METRICS", 1) == 0)
     {
         KPlayerPrefs.DeleteKey("ENABLE_METRICS");
         KPlayerPrefs.Save();
         KPrivacyPrefs.instance.disableDataCollection = true;
         KPrivacyPrefs.Save();
     }
 }
 private void ShowLanguageConfirmation()
 {
     if (SteamManager.Initialized)
     {
         string steamUILanguage = SteamUtils.GetSteamUILanguage();
         if (!(steamUILanguage != "schinese") && KPlayerPrefs.GetInt("LanguageConfirmationVersion") < LANGUAGE_CONFIRMATION_VERSION)
         {
             KPlayerPrefs.SetInt("LanguageConfirmationVersion", LANGUAGE_CONFIRMATION_VERSION);
             Translations();
         }
     }
 }
Beispiel #6
0
 protected override void OnSpawn()
 {
     base.OnSpawn();
     if (!RuntimeManager.IsInitialized)
     {
         base.enabled = false;
     }
     else if (KPlayerPrefs.HasKey(AudioOptionsScreen.AlwaysPlayMusicKey))
     {
         alwaysPlayMusic = ((KPlayerPrefs.GetInt(AudioOptionsScreen.AlwaysPlayMusicKey) == 1) ? true : false);
     }
 }
Beispiel #7
0
    protected override void OnActivate()
    {
        closeButton.onClick       += OnClickClose;
        nextMessageButton.onClick += OnClickNextMessage;
        MultiToggle multiToggle = dontShowAgainButton;

        multiToggle.onClick = (System.Action)Delegate.Combine(multiToggle.onClick, new System.Action(OnClickDontShowAgain));
        bool flag = KPlayerPrefs.GetInt("HideTutorial_CheckState", 0) == 1;

        dontShowAgainButton.ChangeState((!flag) ? 1 : 0);
        Subscribe(Messenger.Instance.gameObject, -599791736, OnMessagesChanged);
        OnMessagesChanged(null);
    }
Beispiel #8
0
 private void OnApplicationFocus(bool hasFocus)
 {
     if (AudioMixer.instance != null && !((Object)AudioMixerSnapshots.Get() == (Object)null))
     {
         if (!hasFocus && KPlayerPrefs.GetInt(AudioOptionsScreen.MuteOnFocusLost) == 1)
         {
             AudioMixer.instance.Start(AudioMixerSnapshots.Get().GameNotFocusedSnapshot);
         }
         else
         {
             AudioMixer.instance.Stop(AudioMixerSnapshots.Get().GameNotFocusedSnapshot, STOP_MODE.ALLOWFADEOUT);
         }
     }
 }
Beispiel #9
0
 private static PublishedFileId_t GetInstalledFileID(out System.DateTime lastModified)
 {
     InstalledLanguageData.Get(out PublishedFileId_t item, out lastModified);
     if (item == PublishedFileId_t.Invalid)
     {
         PublishedFileId_t invalid = PublishedFileId_t.Invalid;
         item = new PublishedFileId_t((uint)KPlayerPrefs.GetInt("InstalledLanguage", (int)invalid.m_PublishedFileId));
     }
     if (item != PublishedFileId_t.Invalid && (UnityEngine.Object)SteamUGCService.Instance != (UnityEngine.Object)null && !SteamUGCService.Instance.IsSubscribed(item))
     {
         Debug.LogWarning("It doesn't look like we are subscribed..." + item);
         item = PublishedFileId_t.Invalid;
         return(item);
     }
     return(item);
 }
 private void ToggleAlwaysPlayAutomation()
 {
     KPlayerPrefs.SetInt(AlwaysPlayAutomation, (KPlayerPrefs.GetInt(AlwaysPlayAutomation) != 1) ? 1 : 0);
     alwaysPlayAutomationButton.GetComponent <HierarchyReferences>().GetReference("CheckMark").gameObject.SetActive((KPlayerPrefs.GetInt(AlwaysPlayAutomation) == 1) ? true : false);
 }
Beispiel #11
0
    private void TriggerAudio(int new_value)
    {
        LogicCircuitNetwork networkForCell = Game.Instance.logicCircuitManager.GetNetworkForCell(cell);
        SpeedControlScreen  instance       = SpeedControlScreen.Instance;

        if (networkForCell != null && new_value != value && (UnityEngine.Object)instance != (UnityEngine.Object)null && !instance.IsPaused && (!KPlayerPrefs.HasKey(AudioOptionsScreen.AlwaysPlayAutomation) || KPlayerPrefs.GetInt(AudioOptionsScreen.AlwaysPlayAutomation) == 1 || !(OverlayScreen.Instance.GetMode() != OverlayModes.Logic.ID)))
        {
            string name = "Logic_Building_Toggle";
            if (CameraController.Instance.IsAudibleSound(Grid.CellToPosCCC(cell, Grid.SceneLayer.BuildingFront)))
            {
                EventInstance instance2 = KFMOD.BeginOneShot(GlobalAssets.GetSound(name, false), Grid.CellToPos(cell));
                instance2.setParameterValue("wireCount", (float)(networkForCell.Wires.Count % 24));
                instance2.setParameterValue("enabled", (float)new_value);
                KFMOD.EndOneShot(instance2);
            }
        }
    }
Beispiel #12
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);
            }
        }
    }
Beispiel #13
0
 private ulong GetCurrentLanguage()
 {
     return((ulong)KPlayerPrefs.GetInt("InstalledLanguage"));
 }
Beispiel #14
0
    public static void SetResolutionFromPrefs()
    {
        int  num  = Screen.currentResolution.width;
        int  num2 = Screen.currentResolution.height;
        int  num3 = Screen.currentResolution.refreshRate;
        bool flag = Screen.fullScreen;

        DebugUtil.LogArgs($"Starting up with a resolution of {num}x{num2} @{num3}hz (fullscreen: {flag})");
        if (KPlayerPrefs.HasKey(ResolutionWidthKey) && KPlayerPrefs.HasKey(ResolutionHeightKey))
        {
            int  @int  = KPlayerPrefs.GetInt(ResolutionWidthKey);
            int  int2  = KPlayerPrefs.GetInt(ResolutionHeightKey);
            int  int3  = KPlayerPrefs.GetInt(RefreshRateKey, Screen.currentResolution.refreshRate);
            bool flag2 = (KPlayerPrefs.GetInt(FullScreenKey, Screen.fullScreen ? 1 : 0) == 1) ? true : false;
            DebugUtil.LogArgs($"Found player prefs resolution {@int}x{int2} @{int3}hz (fullscreen: {flag2})");
            if (int2 <= 1 || @int <= 1)
            {
                DebugUtil.LogArgs("Saved resolution was invalid, ignoring...");
            }
            else
            {
                num  = @int;
                num2 = int2;
                num3 = int3;
                flag = flag2;
            }
        }
        if (num <= 1 || num2 <= 1)
        {
            DebugUtil.LogWarningArgs("Detected a degenerate resolution, attempting to fix...");
            Resolution[] array = Screen.resolutions;
            for (int i = 0; i < array.Length; i++)
            {
                Resolution resolution = array[i];
                if (resolution.width == 1920)
                {
                    num  = resolution.width;
                    num2 = resolution.height;
                    num3 = 0;
                }
            }
            if (num <= 1 || num2 <= 1)
            {
                Resolution[] array2 = Screen.resolutions;
                for (int j = 0; j < array2.Length; j++)
                {
                    Resolution resolution2 = array2[j];
                    if (resolution2.width == 1280)
                    {
                        num  = resolution2.width;
                        num2 = resolution2.height;
                        num3 = 0;
                    }
                }
            }
            if (num <= 1 || num2 <= 1)
            {
                Resolution[] array3 = Screen.resolutions;
                for (int k = 0; k < array3.Length; k++)
                {
                    Resolution resolution3 = array3[k];
                    if (resolution3.width > 1 && resolution3.height > 1 && resolution3.refreshRate > 0)
                    {
                        num  = resolution3.width;
                        num2 = resolution3.height;
                        num3 = 0;
                    }
                }
            }
            if (num <= 1 || num2 <= 1)
            {
                string       text   = "Could not find a suitable resolution for this screen! Reported available resolutions are:";
                Resolution[] array4 = Screen.resolutions;
                for (int l = 0; l < array4.Length; l++)
                {
                    Resolution resolution4 = array4[l];
                    text += $"\n{resolution4.width}x{resolution4.height} @ {resolution4.refreshRate}hz";
                }
                Debug.LogError(text);
                num  = 1280;
                num2 = 720;
                flag = false;
                num3 = 0;
            }
        }
        DebugUtil.LogArgs($"Applying resolution {num}x{num2} @{num3}hz (fullscreen: {flag})");
        Screen.SetResolution(num, num2, flag, num3);
    }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        closeButton.onClick += delegate
        {
            OnClose(base.gameObject);
        };
        doneButton.onClick += delegate
        {
            OnClose(base.gameObject);
        };
        sliderPool = new UIPool <SliderContainer>(sliderPrefab);
        Dictionary <string, AudioMixer.UserVolumeBus> userVolumeSettings = AudioMixer.instance.userVolumeSettings;

        foreach (KeyValuePair <string, AudioMixer.UserVolumeBus> item in userVolumeSettings)
        {
            SliderContainer newSlider = sliderPool.GetFreeElement(sliderGroup, true);
            sliderBusMap.Add(newSlider.slider, item.Key);
            newSlider.slider.value   = item.Value.busLevel;
            newSlider.nameLabel.text = item.Value.labelString;
            newSlider.UpdateSliderLabel(item.Value.busLevel);
            newSlider.slider.ClearReleaseHandleEvent();
            newSlider.slider.onValueChanged.AddListener(delegate
            {
                OnReleaseHandle(newSlider.slider);
            });
            if (item.Key == "Master")
            {
                newSlider.transform.SetSiblingIndex(2);
                newSlider.slider.onValueChanged.AddListener(CheckMasterValue);
                CheckMasterValue(item.Value.busLevel);
            }
        }
        HierarchyReferences component  = alwaysPlayMusicButton.GetComponent <HierarchyReferences>();
        GameObject          gameObject = component.GetReference("Button").gameObject;

        gameObject.GetComponent <ToolTip>().SetSimpleTooltip(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.MUSIC_EVERY_CYCLE_TOOLTIP);
        component.GetReference("CheckMark").gameObject.SetActive(MusicManager.instance.alwaysPlayMusic);
        gameObject.GetComponent <KButton>().onClick += delegate
        {
            ToggleAlwaysPlayMusic();
        };
        LocText reference = component.GetReference <LocText>("Label");

        reference.SetText(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.MUSIC_EVERY_CYCLE);
        if (!KPlayerPrefs.HasKey(AlwaysPlayAutomation))
        {
            KPlayerPrefs.SetInt(AlwaysPlayAutomation, 1);
        }
        HierarchyReferences component2  = alwaysPlayAutomationButton.GetComponent <HierarchyReferences>();
        GameObject          gameObject2 = component2.GetReference("Button").gameObject;

        gameObject2.GetComponent <ToolTip>().SetSimpleTooltip(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.AUTOMATION_SOUNDS_ALWAYS_TOOLTIP);
        gameObject2.GetComponent <KButton>().onClick += delegate
        {
            ToggleAlwaysPlayAutomation();
        };
        LocText reference2 = component2.GetReference <LocText>("Label");

        reference2.SetText(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.AUTOMATION_SOUNDS_ALWAYS);
        component2.GetReference("CheckMark").gameObject.SetActive((KPlayerPrefs.GetInt(AlwaysPlayAutomation) == 1) ? true : false);
        if (!KPlayerPrefs.HasKey(MuteOnFocusLost))
        {
            KPlayerPrefs.SetInt(MuteOnFocusLost, 0);
        }
        HierarchyReferences component3  = muteOnFocusLostToggle.GetComponent <HierarchyReferences>();
        GameObject          gameObject3 = component3.GetReference("Button").gameObject;

        gameObject3.GetComponent <ToolTip>().SetSimpleTooltip(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.MUTE_ON_FOCUS_LOST_TOOLTIP);
        gameObject3.GetComponent <KButton>().onClick += delegate
        {
            ToggleMuteOnFocusLost();
        };
        LocText reference3 = component3.GetReference <LocText>("Label");

        reference3.SetText(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.MUTE_ON_FOCUS_LOST);
        component3.GetReference("CheckMark").gameObject.SetActive((KPlayerPrefs.GetInt(MuteOnFocusLost) == 1) ? true : false);
    }
 private void ToggleMuteOnFocusLost()
 {
     KPlayerPrefs.SetInt(MuteOnFocusLost, (KPlayerPrefs.GetInt(MuteOnFocusLost) != 1) ? 1 : 0);
     muteOnFocusLostToggle.GetComponent <HierarchyReferences>().GetReference("CheckMark").gameObject.SetActive((KPlayerPrefs.GetInt(MuteOnFocusLost) == 1) ? true : false);
 }
Beispiel #17
0
    public static bool UseHotkeyBuildMenu()
    {
        int @int = KPlayerPrefs.GetInt("ENABLE_HOTKEY_BUILD_MENU");

        return(@int != 0);
    }
    protected override void OnPrefabInit()
    {
        instance = this;
        if (KPlayerPrefs.HasKey("TemperatureUnit"))
        {
            GameUtil.temperatureUnit = (GameUtil.TemperatureUnit)KPlayerPrefs.GetInt("TemperatureUnit");
        }
        if (KPlayerPrefs.HasKey("MassUnit"))
        {
            GameUtil.massUnit = (GameUtil.MassUnit)KPlayerPrefs.GetInt("MassUnit");
        }
        RecipeManager.DestroyInstance();
        RecipeManager.Get();
        AnimMaterial = AnimMaterialAsset;
        Prefabs      = new List <KPrefabID>(from x in PrefabAssets
                                            where (UnityEngine.Object)x != (UnityEngine.Object) null
                                            select x);
        PrefabsByTag.Clear();
        PrefabsByAdditionalTags.Clear();
        CountableTags.Clear();
        Sprites = new Dictionary <HashedString, Sprite>();
        foreach (Sprite spriteAsset in SpriteAssets)
        {
            if (!((UnityEngine.Object)spriteAsset == (UnityEngine.Object)null))
            {
                HashedString key = new HashedString(spriteAsset.name);
                Sprites.Add(key, spriteAsset);
            }
        }
        TintedSprites = (from x in TintedSpriteAssets
                         where x != null && (UnityEngine.Object)x.sprite != (UnityEngine.Object) null
                         select x).ToList();
        Materials = (from x in MaterialAssets
                     where (UnityEngine.Object)x != (UnityEngine.Object) null
                     select x).ToList();
        Textures = (from x in TextureAssets
                    where (UnityEngine.Object)x != (UnityEngine.Object) null
                    select x).ToList();
        TextureAtlases = (from x in TextureAtlasAssets
                          where (UnityEngine.Object)x != (UnityEngine.Object) null
                          select x).ToList();
        BlockTileDecorInfos = (from x in BlockTileDecorInfoAssets
                               where (UnityEngine.Object)x != (UnityEngine.Object) null
                               select x).ToList();
        Anims = (from x in AnimAssets
                 where (UnityEngine.Object)x != (UnityEngine.Object) null
                 select x).ToList();
        Anims.AddRange(ModLoadedKAnims);
        UIPrefabs = UIPrefabAssets;
        DebugFont = DebugFontAsset;
        AsyncLoadManager <IGlobalAsyncLoader> .Run();

        GameAudioSheets.Get().Initialize();
        SubstanceListHookup();
        BuildingDefs = new List <BuildingDef>();
        foreach (KPrefabID prefabAsset in PrefabAssets)
        {
            if (!((UnityEngine.Object)prefabAsset == (UnityEngine.Object)null))
            {
                AddPrefab(prefabAsset);
            }
        }
        AnimTable.Clear();
        foreach (KAnimFile anim in Anims)
        {
            if ((UnityEngine.Object)anim != (UnityEngine.Object)null)
            {
                HashedString key2 = anim.name;
                AnimTable[key2] = anim;
            }
        }
        CreatePrefabs();
    }