Exemplo n.º 1
0
        public async void AddWeatherInfoMenu()
        {
            forecast.spacing = 0.01f;
            if (PluginConfig.Instance.showCityName)
            {
                var Header = BeatSaberUI.CreateText((RectTransform)forecast.transform, PluginConfig.Instance.WeatherFinder.cityName, Vector2.zero);
                Header.color     = Color.cyan;
                Header.fontSize  = 12f;
                Header.alignment = TMPro.TextAlignmentOptions.Center;
                ContentSizeFitter fitter = Header.gameObject.AddComponent <ContentSizeFitter>();
                fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
                fitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
            }
            WeatherDataRoot weatherInfo = await WeatherFinder.GetWeatherData();

            for (int i = 0; i < weatherInfo.weather.Length; i++)
            {
                WeatherData data        = weatherInfo.weather[i];
                GameObject  forecastObj = new GameObject("ForecastObject");
                forecastObj.transform.SetParent(forecast.transform);
                HorizontalLayoutGroup horiz = forecastObj.AddComponent <HorizontalLayoutGroup>();
                horiz.childAlignment = TextAnchor.MiddleCenter;
                var text = BeatSaberUI.CreateText((RectTransform)forecastObj.transform, data.main + "    -    " + data.description, Vector2.zero);
                text.fontSize  = 0.2f;
                text.alignment = TMPro.TextAlignmentOptions.Center;
                forecastObj.transform.localPosition = Vector3.zero;
            }
        }
Exemplo n.º 2
0
        public async void SetRefs()
        {
            hasFullSetRefs = true;
            Plugin.Log.Info("SetRefs " + CurrentScene.name);
            WeatherDataRoot weatherInfo = await WeatherFinder.GetWeatherData();

            MeshRenderer[] mrs = Resources.FindObjectsOfTypeAll <MeshRenderer>();
            //Plugin.Log.Info("SetRefs 1");
            if (CurrentScene.name == Plugin.menu)
            {
                BundleLoader.WeatherPrefab.SetActive(PluginConfig.Instance.enabledInMenu);
            }
            if (CurrentScene.name == Plugin.game)
            {
                BundleLoader.WeatherPrefab.SetActive(PluginConfig.Instance.enabledInGameplay);
            }
            BundleLoader.effects.Clear();
            for (int x = 0; x < weatherInfo.weather.Length; x++)
            {
                WeatherData data = weatherInfo.weather[x];
                EffectModel.EnableEffect(data.main, true);
            }
            for (int i = 0; i < gameObject.transform.childCount; i++)
            {
                //Plugin.Log.Info(i.ToString());
                Transform Child = gameObject.transform.GetChild(i);
                Child.gameObject.SetActive(true);

                EffectDiscriptor efd       = Child.gameObject.GetComponent <EffectDiscriptor>();
                string           NameToUse = EffectModel.GetNameWithoutSceneName(efd.EffectName);
                Child.gameObject.GetComponentsInChildren <AudioSource>().ToList().ForEach((AudioSource s) => { s.volume = PluginConfig.Instance.audioSFXVolume; });
                efd.gameObject.SetActive(true);
                efd.transform.GetChild(0).gameObject.SetActive(true);
                Effect eff = new Effect(efd, Child.gameObject, PluginConfig.Instance.enabledEffects.Any((string str) => { return(str == efd.EffectName); }));

                if (MiscConfig.hasObject(NameToUse))
                {
                    //Plugin.Log.Info("Misc Config has Object! " + NameToUse);
                    MiscConfigObject Object = MiscConfig.ReadObject(NameToUse);
                    eff.showInMenu = Object.showInMenu;
                    eff.showInGame = Object.showInGame;
                }
                else
                {
                    MiscConfig.Add(new MiscConfigObject(NameToUse, eff.showInMenu, eff.showInGame));
                    MiscConfig.Write();
                }
                eff.SetActiveRefs();
                BundleLoader.effects.Add(eff);
                //Plugin.Log.Info("Replacing " + mrs.Length.ToString    ());
                for (int x = 0; x < mrs.Length; x++)
                {
                    MeshRenderer mr = mrs[x];
                    if (mr.material.name.Contains("Note") || mr.gameObject.name.Contains("building") || mr.gameObject.name.Contains("speaker"))
                    {
                        eff.TrySetNoteMateral(mr);
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
Exemplo n.º 3
0
 async public static void LoadWeatherFinder()
 {
     WeatherDataRoot weatherData = await WeatherFinder.GetWeatherData();
 }