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);
     }
 }
 public void StartUserVolumesSnapshot()
 {
     Start(AudioMixerSnapshots.Get().UserVolumeSettingsSnapshot);
     if (activeSnapshots.TryGetValue(AudioMixerSnapshots.Get().UserVolumeSettingsSnapshot, out EventInstance value))
     {
         value.getDescription(out EventDescription description);
         description.getUserProperty("buses", out USER_PROPERTY property);
         string   text  = property.stringValue();
         char     c     = '-';
         string[] array = text.Split(c);
         for (int i = 0; i < array.Length; i++)
         {
             float  busLevel = 1f;
             string key      = "Volume_" + array[i];
             if (KPlayerPrefs.HasKey(key))
             {
                 busLevel = KPlayerPrefs.GetFloat(key);
             }
             UserVolumeBus userVolumeBus = new UserVolumeBus();
             userVolumeBus.busLevel    = busLevel;
             userVolumeBus.labelString = Strings.Get("STRINGS.UI.FRONTEND.AUDIO_OPTIONS_SCREEN.AUDIO_BUS_" + array[i].ToUpper());
             userVolumeSettings.Add(array[i], userVolumeBus);
             SetUserVolume(array[i], userVolumeBus.busLevel);
         }
     }
 }
Example #3
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);
            }
        }
    }
Example #4
0
        /// <summary>
        /// Applied before these methods run.
        /// </summary>
        internal static bool Prefix()
        {
            var options = FastTrackOptions.Instance;

            return(!options.DisableSound && KPlayerPrefs.GetFloat(SoundUpdater.VOLUME_MUSIC,
                                                                  1.0f) > 0.0f && KPlayerPrefs.GetFloat(SoundUpdater.VOLUME_MASTER, 1.0f) > 0.0f);
        }
 public void SetUserVolume(string bus, float value)
 {
     if (!userVolumeSettings.ContainsKey(bus))
     {
         Debug.LogError("The provided bus doesn't exist. Check yo'self fool!");
     }
     else
     {
         if (value > 1f)
         {
             value = 1f;
         }
         else if (value < 0f)
         {
             value = 0f;
         }
         userVolumeSettings[bus].busLevel = value;
         KPlayerPrefs.SetFloat("Volume_" + bus, value);
         if (activeSnapshots.TryGetValue(AudioMixerSnapshots.Get().UserVolumeSettingsSnapshot, out EventInstance value2))
         {
             value2.setParameterValue("userVolume_" + bus, userVolumeSettings[bus].busLevel);
         }
         else
         {
             Log("Tried to set [" + bus + "] to [" + value + "] but UserVolumeSettingsSnapshot is not active.");
         }
         if (bus == "Music")
         {
             SetSnapshotParameter(AudioMixerSnapshots.Get().DynamicMusicPlayingSnapshot, "userVolume_Music", value, true);
         }
     }
 }
Example #6
0
 public KPlayerPrefs()
 {
     strings   = new Dictionary <string, string>();
     ints      = new Dictionary <string, int>();
     floats    = new Dictionary <string, float>();
     _instance = this;
 }
Example #7
0
 public static int SessionID()
 {
     if (sessionID == -1)
     {
         sessionID = KPlayerPrefs.GetInt("SESSION_ID", -1);
     }
     return(sessionID);
 }
Example #8
0
 private static void SaveResolutionToPrefs(Settings settings)
 {
     Debug.LogFormat("Screen resolution updated, saving values to prefs: {0}x{1} @ {2}, fullscreen: {3}", settings.resolution.width, settings.resolution.height, settings.resolution.refreshRate, settings.fullscreen);
     KPlayerPrefs.SetInt(ResolutionWidthKey, settings.resolution.width);
     KPlayerPrefs.SetInt(ResolutionHeightKey, settings.resolution.height);
     KPlayerPrefs.SetInt(RefreshRateKey, settings.resolution.refreshRate);
     KPlayerPrefs.SetInt(FullScreenKey, settings.fullscreen ? 1 : 0);
 }
Example #9
0
 public static int GameID()
 {
     if (gameID == -1)
     {
         gameID = KPlayerPrefs.GetInt("GAME_ID", -1);
     }
     return(gameID);
 }
    public static string GetSelectedPreinstalledLanguageCode()
    {
        SelectedLanguageType selectedLanguageType = GetSelectedLanguageType();

        if (selectedLanguageType == SelectedLanguageType.Preinstalled)
        {
            return(KPlayerPrefs.GetString(SELECTED_LANGUAGE_CODE_KEY));
        }
        return(string.Empty);
    }
Example #11
0
 private void RestoreLegacyMetricsSetting()
 {
     if (KPlayerPrefs.GetInt("ENABLE_METRICS", 1) == 0)
     {
         KPlayerPrefs.DeleteKey("ENABLE_METRICS");
         KPlayerPrefs.Save();
         KPrivacyPrefs.instance.disableDataCollection = true;
         KPrivacyPrefs.Save();
     }
 }
Example #12
0
 private void UpdateUIScale(float value)
 {
     KCanvasScaler[] canvasScalers = CanvasScalers;
     foreach (KCanvasScaler kCanvasScaler in canvasScalers)
     {
         float userScale = value / 100f;
         kCanvasScaler.SetUserScale(userScale);
         KPlayerPrefs.SetFloat(KCanvasScaler.UIScalePrefKey, value);
     }
     UpdateSliderLabel();
 }
Example #13
0
 private void RebuildScreen()
 {
     foreach (GameObject button in buttons)
     {
         UnityEngine.Object.Destroy(button);
     }
     buttons.Clear();
     uninstallButton.isInteractable = (KPlayerPrefs.GetString(Localization.SELECTED_LANGUAGE_TYPE_KEY, 0.ToString()) != 0.ToString());
     RebuildPreinstalledButtons();
     RebuildUGCButtons();
 }
 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();
         }
     }
 }
Example #15
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);
     }
 }
Example #16
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);
    }
Example #17
0
    public static void CleanUpCurrentModLanguage()
    {
        PublishedFileId_t invalid = PublishedFileId_t.Invalid;

        KPlayerPrefs.SetInt("InstalledLanguage", (int)invalid.m_PublishedFileId);
        InstalledLanguageData.Delete();
        string modLocalizationFilePath = Localization.GetModLocalizationFilePath();

        if (File.Exists(modLocalizationFilePath))
        {
            File.Delete(modLocalizationFilePath);
        }
    }
Example #18
0
 public static string GetInstallTimeStamp()
 {
     if (installTimeStamp == null)
     {
         installTimeStamp = KPlayerPrefs.GetString("INSTALL_TIMESTAMP", null);
         if (installTimeStamp == null || installTimeStamp == string.Empty)
         {
             installTimeStamp = DateTime.UtcNow.Ticks.ToString();
             KPlayerPrefs.SetString("INSTALL_TIMESTAMP", installTimeStamp);
         }
     }
     return(installTimeStamp);
 }
Example #19
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);
         }
     }
 }
 private void CheckPlayerPrefsCorruption()
 {
     if (KPlayerPrefs.HasCorruptedFlag())
     {
         KPlayerPrefs.ResetCorruptedFlag();
         ConfirmDialogScreen confirmDialogScreen  = Util.KInstantiateUI <ConfirmDialogScreen>(ScreenPrefabs.Instance.ConfirmDialogScreen.gameObject, base.gameObject, true);
         ConfirmDialogScreen confirmDialogScreen2 = confirmDialogScreen;
         string        text       = UI.FRONTEND.SUPPORTWARNINGS.PLAYER_PREFS_CORRUPTED;
         System.Action on_confirm = null;
         System.Action on_cancel  = null;
         Sprite        sadDupe    = GlobalResources.Instance().sadDupe;
         confirmDialogScreen2.PopupConfirmDialog(text, on_confirm, on_cancel, null, null, null, null, null, sadDupe, true);
     }
 }
    protected override void OnPrefabInit()
    {
        base.OnPrefabInit();
        if (KPlayerPrefs.HasKey(UIScalePrefKey))
        {
            SetUserScale(KPlayerPrefs.GetFloat(UIScalePrefKey) / 100f);
        }
        else
        {
            SetUserScale(1f);
        }
        ScreenResize instance = ScreenResize.Instance;

        instance.OnResize = (System.Action)Delegate.Combine(instance.OnResize, new System.Action(OnResize));
    }
 public static void LoadPreinstalledTranslation(string code)
 {
     if (!string.IsNullOrEmpty(code) && code != DEFAULT_LANGUAGE_CODE)
     {
         string preinstalledLocalizationFilePath = GetPreinstalledLocalizationFilePath(code);
         if (LoadLocalTranslationFile(SelectedLanguageType.Preinstalled, preinstalledLocalizationFilePath))
         {
             KPlayerPrefs.SetString(SELECTED_LANGUAGE_CODE_KEY, code);
         }
     }
     else
     {
         ClearLanguage();
     }
 }
Example #23
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);
 }
Example #24
0
    private void PlayImpactSound(Vector3 pos)
    {
        if (impactSound == null)
        {
            impactSound = "Meteor_Large_Impact";
        }
        loopingSounds.StopSound(flyingSound);
        string sound = GlobalAssets.GetSound(impactSound, false);

        if (CameraController.Instance.IsAudibleSound(pos, sound))
        {
            EventInstance instance = KFMOD.BeginOneShot(sound, pos);
            instance.setParameterValue("userVolume_SFX", KPlayerPrefs.GetFloat("Volume_SFX"));
            KFMOD.EndOneShot(instance);
        }
    }
Example #25
0
 public void PlayDynamicMusic()
 {
     if (DynamicMusicIsActive())
     {
         Log("Trying to play DynamicMusic when it is already playing.");
     }
     else
     {
         string nextDynamicSong = GetNextDynamicSong();
         if (!(nextDynamicSong == "NONE"))
         {
             PlaySong(nextDynamicSong, false);
             if (activeSongs.TryGetValue(nextDynamicSong, out SongInfo value))
             {
                 activeDynamicSong = value;
                 AudioMixer.instance.Start(AudioMixerSnapshots.Get().DynamicMusicPlayingSnapshot);
                 if ((UnityEngine.Object)SpeedControlScreen.Instance != (UnityEngine.Object)null && SpeedControlScreen.Instance.IsPaused)
                 {
                     SetDynamicMusicPaused();
                 }
                 if ((UnityEngine.Object)OverlayScreen.Instance != (UnityEngine.Object)null && OverlayScreen.Instance.mode != OverlayModes.None.ID)
                 {
                     SetDynamicMusicOverlayActive();
                 }
                 SetDynamicMusicPlayHook();
                 string key = "Volume_Music";
                 if (KPlayerPrefs.HasKey(key))
                 {
                     float @float = KPlayerPrefs.GetFloat(key);
                     AudioMixer.instance.SetSnapshotParameter(AudioMixerSnapshots.Get().DynamicMusicPlayingSnapshot, "userVolume_Music", @float, true);
                 }
                 AudioMixer.instance.SetSnapshotParameter(AudioMixerSnapshots.Get().DynamicMusicPlayingSnapshot, "intensity", value.sfxAttenuationPercentage / 100f, true);
             }
             else
             {
                 Log("DynamicMusic song " + nextDynamicSong + " did not start.");
                 string text = string.Empty;
                 foreach (KeyValuePair <string, SongInfo> activeSong in activeSongs)
                 {
                     text = text + activeSong.Key + ", ";
                     Debug.Log(text);
                 }
                 DebugUtil.DevAssert(false, "Song failed to play: " + nextDynamicSong);
             }
         }
     }
 }
    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();
    }
    public static bool LoadLocalTranslationFile(SelectedLanguageType source, string path)
    {
        if (!File.Exists(path))
        {
            return(false);
        }
        string[] lines = File.ReadAllLines(path, Encoding.UTF8);
        bool     flag  = LoadTranslationFromLines(lines);

        if (flag)
        {
            KPlayerPrefs.SetString(SELECTED_LANGUAGE_TYPE_KEY, source.ToString());
        }
        else
        {
            ClearLanguage();
        }
        return(flag);
    }
        public void ShowExplosion(Comet comet)
        {
            var    position = comet.transform.GetPosition();
            string sound    = GlobalAssets.GetSound(comet.impactSound);

            if (CameraController.Instance.IsAudibleSound(position, sound))
            {
                EventInstance instance = KFMOD.BeginOneShot(sound, position);
                instance.setParameterByName("userVolume_SFX", KPlayerPrefs.GetFloat("Volume_SFX"));
                KFMOD.EndOneShot(instance);
            }
            var fx_position = position;

            fx_position.z = Grid.GetLayerZ(Grid.SceneLayer.FXFront2);
            var cell = Grid.PosToCell(fx_position);

            if (SafeCell(cell))
            {
                Game.Instance.SpawnFX(comet.explosionEffectHash, fx_position, 0f);
            }
        }
    private void OnAudioDeviceChanged(int idx)
    {
        RuntimeManager.LowlevelSystem.setDriver(idx);
        int num = 0;

        while (true)
        {
            if (num >= audioDevices.Count)
            {
                return;
            }
            KFMOD.AudioDevice audioDevice = audioDevices[num];
            if (idx == audioDevice.fmod_id)
            {
                break;
            }
            num++;
        }
        KFMOD.currentDevice = audioDevices[num];
        KPlayerPrefs.SetString("AudioDeviceGuid", KFMOD.currentDevice.guid.ToString());
    }
Example #30
0
        private bool LoadTranslations()
        {
            string path = FileSystem.Normalize(label.install_path);

            if (!System.IO.Directory.Exists(path))
            {
                return(false);
            }
            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            HashSetPool <Localization.Locale, Mod> .PooledHashSet pooledHashSet = HashSetPool <Localization.Locale, Mod> .Allocate();

            FileInfo[] files = directoryInfo.GetFiles();
            foreach (FileInfo fileInfo in files)
            {
                if (!(fileInfo.Extension.ToLower() != ".po"))
                {
                    string[] lines = File.ReadAllLines(fileInfo.FullName, Encoding.UTF8);
                    pooledHashSet.Add(Localization.GetLocale(lines));
                    Dictionary <string, string> translated_strings = Localization.ExtractTranslatedStrings(lines, false);
                    Localization.OverloadStrings(translated_strings);
                }
            }
            if (pooledHashSet.Count == 0)
            {
                return(false);
            }
            Localization.Locale new_locale = pooledHashSet.First();
            if (!pooledHashSet.All((Localization.Locale locale) => locale == new_locale))
            {
                return(false);
            }
            Localization.SetLocale(new_locale);
            Localization.SwapToLocalizedFont(new_locale.FontName);
            KPlayerPrefs.SetString(Localization.SELECTED_LANGUAGE_TYPE_KEY, 2.ToString());
            KPlayerPrefs.SetString(Localization.SELECTED_LANGUAGE_CODE_KEY, new_locale.Code);
            return(true);
        }