Exemple #1
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                BSMLParser.instance.Parse(BSMLUtilities.GetResourceContent(Assembly.GetExecutingAssembly(), "EnhancedSearchAndFilters.UI.Views.SearchResultsNavigationView.bsml"), this.gameObject, this);
                name = "SearchResultsNavigationController";

                _loadingSpinner = UIUtilities.CreateLoadingSpinner(this.rectTransform);

                var handler = _lastSearchButton.gameObject.AddComponent <EnterExitEventHandler>();
                handler.PointerEntered += () => _lastSearchButton.SetButtonText(RedoSearchButtonHighlightedText);
                handler.PointerExited  += () => _lastSearchButton.SetButtonText(RedoSearchButtonDefaultText);

                _lastSearchText.color = new Color(1f, 1f, 1f, 0.3f);

                _songPreviewPlayer = Resources.FindObjectsOfTypeAll <SongPreviewPlayer>().First();
            }
            else
            {
                _resultsText.text     = PluginConfig.SearchKeyboard == SearchKeyboardType.RightScreen ? RightScreenKeyboardPlaceholderResultsText : DetachedKeyboardPlaceholderResultsText;
                _resultsText.fontSize = 6f;
            }

            AdjustElements();

            _loadingSpinner.SetActive(false);
            _resultsText.gameObject.SetActive(PluginConfig.SearchKeyboard != SearchKeyboardType.Compact);
            _forceButton.gameObject.SetActive(false);
            _lastSearchButton.gameObject.SetActive(false);
            _lastSearchText.gameObject.SetActive(false);
            _resetKeyboardPosButton.gameObject.SetActive(PluginConfig.SearchKeyboard == SearchKeyboardType.Floating);
            SetHeaderActive(PluginConfig.SearchKeyboard != SearchKeyboardType.Compact);
        }
        public static Texture2D ReadImageFromAssembly(Assembly assembly, string name)
        {
            if (assembly == null)
            {
                return(null);
            }
            using var resourceStream = assembly.GetManifestResourceStream(name);
            if (resourceStream == null)
            {
                Logger.log.Warn($"Assembly {assembly.GetName().Name} does not have embedded resource {name}");
                return(null);
            }
            var data = new byte[resourceStream.Length];
            int read = 0;

            while (read < data.Length)
            {
                read += resourceStream.Read(data, read, data.Length - read);
            }
            return(BSMLUtils.LoadTextureRaw(data));
        }
 public static BSMLParserParams ParseBSML(string resource, GameObject parent, object host = null)
 {
     return(BSMLParser.instance.Parse(BSMLUtilities.GetResourceContent(Assembly.GetExecutingAssembly(), resource), parent, host));
 }