コード例 #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);
            }
        }
    }
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
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);
     }
 }
コード例 #4
0
    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));
    }
コード例 #5
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);
             }
         }
     }
 }
コード例 #6
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);
            }
        }
    }
    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);
    }
コード例 #8
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();
    }
コード例 #9
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);
    }