Esempio n. 1
0
        public static string WrapNameWithColorTags(string name, Color color)
        {
            string hexColour  = UIMarkupStyle.ColorToHex(color);
            string returnName = "<color" + hexColour + ">" + name + "</color>";

            return(returnName);
        }
Esempio n. 2
0
        private static ColorInfo ParseColor(UIMarkupToken token, Color defaultColor)
        {
            var result = new ColorInfo(Color.white, true);

            if (token.attributeCount == 1)
            {
                string value = token.GetAttribute(0).m_Value.value;
                result.color         = UIMarkupStyle.ParseColor(value, defaultColor);
                result.overrideColor = true;
            }
            return(result);
        }
Esempio n. 3
0
        public static Color ExtractColourFromTags(string text, Color defaultColour)
        {
            Regex  colourExtraction = new Regex("(?:<color)(#[0-9a-fA-F]{3,6})(>.*)");
            string extractedTag     = colourExtraction.Replace(text, "$1");

            if (extractedTag != null && extractedTag != text && extractedTag != "")
            {
                defaultColour = UIMarkupStyle.ParseColor(extractedTag, defaultColour);
            }

            return(defaultColour);
        }
Esempio n. 4
0
        /// <summary>
        /// Extracts data from a HTML page. This will only work on the Steam Workshop
        /// due to certain div IDs. You shouldn't need to call this yourself really, and
        /// should only be used if you really really need to use it.
        /// </summary>
        /// <param name="rawData"></param>
        protected void ExtractData(string rawData)
        {
            if (rawData != null && rawData != "")
            {
                int firstIndex = rawData.IndexOf("<div class=\"headline\"");
                int lastIndex  = rawData.IndexOf("<div class=\"commentsLink changeLog\"");

                if (firstIndex > 0 && lastIndex > 0 && lastIndex > firstIndex)
                {
                    string splitData   = rawData.Substring(firstIndex, lastIndex - firstIndex);
                    Regex  findList    = new Regex("(?:<ul.*?bb_ul.*?>)(.*)(?:<\\/ul>)");
                    Match  matchedList = findList.Match(splitData);

                    if (matchedList.Success && matchedList.Groups.Count > 1)
                    {
                        string listData = matchedList.Groups[1].Value;
                        listData = listData.Replace("<li>", "\n\n");

                        if (m_colouriseTags)
                        {
                            foreach (KeyValuePair <string, Color> tag in m_tagsToColourise)
                            {
                                string hexValue = UIMarkupStyle.ColorToHex(tag.Value);
                                listData = listData.Replace("<" + tag.Key + ">", "|~|color" + hexValue + "!~|");
                                listData = listData.Replace("</" + tag.Key + ">", "|~|/color!~|");
                            }
                        }

                        Regex stripTags = new Regex("<.*?>");
                        listData = stripTags.Replace(listData, "");

                        listData = listData.Replace("|~|", "<");
                        listData = listData.Replace("!~|", ">");
                        listData = listData.Trim('\n');

                        m_rawChanges    = listData;
                        m_changeList    = listData.Split(new string[] { "\n\n" }, StringSplitOptions.None).ToList();
                        m_downloadError = false;
                    }
                }
            }
        }
Esempio n. 5
0
        public void Initialize(ChirpyBanner chBann)
        {
            TheChirpyBanner = chBann;

            // first, set up our panel stuff
            UIView uiv = UIView.GetAView();

            if (uiv == null)
            {
                // log error
                return;
            }

            this.backgroundSprite = "MenuPanel";// or MenuPanel2
            int viewWidth  = (int)uiv.GetScreenResolution().x;
            int viewHeight = (int)uiv.GetScreenResolution().y;

            this.clipChildren        = false;// true; //temp
            this.canFocus            = true;
            this.isInteractive       = true;
            this.autoLayout          = true;
            this.autoLayoutDirection = LayoutDirection.Vertical;
            this.autoLayoutPadding   = new RectOffset(0, 0, 1, 1);
            this.autoLayoutStart     = LayoutStart.TopLeft;

            this.position = new Vector3(0, 0, 0);//test// new Vector3((-viewWidth / 2), (viewHeight / 2));

            //testing tempsizes
            this.width  = 450;
            this.height = 400;

            //this.SendToBack();

            TitleSubPanel = AddUIComponent <UITitleSubPanel>();
            TitleSubPanel.ParentBannerConfig = this;

            HideChirpSubPanel = AddUIComponent <UICheckSubPanel>();
            HideChirpSubPanel.ParentBannerConfig   = this;
            HideChirpSubPanel.Checked              = ChirpyBanner.CurrentConfig.DestroyBuiltinChirper;
            HideChirpSubPanel.Checkbox.eventClick += (component, param) =>
            {
                ChirpyBanner.CurrentConfig.DestroyBuiltinChirper = !ChirpyBanner.CurrentConfig.DestroyBuiltinChirper;

                if (ChirpyBanner.BuiltinChirper != null)
                {
                    ChirpyBanner.BuiltinChirper.ShowBuiltinChirper(!ChirpyBanner.CurrentConfig.DestroyBuiltinChirper);
                }
            };


            ScrollSpeedSlider = AddUIComponent <UISliderSubPanel>();
            ScrollSpeedSlider.ParentBannerConfig        = this;
            ScrollSpeedSlider.Slider.minValue           = 1;
            ScrollSpeedSlider.Slider.maxValue           = 200;
            ScrollSpeedSlider.Slider.stepSize           = 5;
            ScrollSpeedSlider.Slider.value              = ChirpyBanner.CurrentConfig.ScrollSpeed;
            ScrollSpeedSlider.Slider.scrollWheelAmount  = 5;
            ScrollSpeedSlider.Description.text          = "Scrolling Speed";
            ScrollSpeedSlider.Slider.eventValueChanged += (component, param) => { ChirpyBanner.CurrentConfig.ScrollSpeed = (int)param; };

            TextSizeSlider = AddUIComponent <UISliderSubPanel>();
            TextSizeSlider.ParentBannerConfig        = this;
            TextSizeSlider.Slider.minValue           = 5;
            TextSizeSlider.Slider.maxValue           = 50;
            TextSizeSlider.Slider.stepSize           = 1;
            TextSizeSlider.Slider.value              = ChirpyBanner.CurrentConfig.TextSize;
            TextSizeSlider.Slider.scrollWheelAmount  = 1;
            TextSizeSlider.Description.text          = "Text Size";
            TextSizeSlider.Slider.eventValueChanged += (component, param) => { ChirpyBanner.CurrentConfig.TextSize = (int)param; };

            AlphaSlider = AddUIComponent <UISliderSubPanel>();
            AlphaSlider.ParentBannerConfig        = this;
            AlphaSlider.Slider.minValue           = 0f;
            AlphaSlider.Slider.maxValue           = 1f;
            AlphaSlider.Slider.stepSize           = 0.01f;
            AlphaSlider.Slider.value              = ChirpyBanner.CurrentConfig.BackgroundAlpha;
            AlphaSlider.Slider.scrollWheelAmount  = 0.01f;
            AlphaSlider.Description.text          = "Background Transparency";
            AlphaSlider.Slider.eventValueChanged += (component, param) =>
            {
                // don't go below opacity of 0.00999999977648258 or control becomes non-responsive to clicks
                float val = Math.Max(0.02f, Math.Min(0.98f, param));
                ChirpyBanner.CurrentConfig.BackgroundAlpha = val;
                ChirpyBanner.theBannerPanel.opacity        = (1f - val);
            };

            NameColorSubPanel = AddUIComponent <UIColorSubPanel>();
            NameColorSubPanel.ParentBannerConfig       = this;
            NameColorSubPanel.Description.text         = "Chirper Name Color";
            NameColorSubPanel.ColorField.selectedColor = UIMarkupStyle.ParseColor(ChirpyBanner.CurrentConfig.NameColor, Color.cyan);
            NameColorSubPanel.ColorField.eventSelectedColorReleased += (component, param) => { ChirpyBanner.CurrentConfig.NameColor = UIMarkupStyle.ColorToHex(param); };

            MessageColorSubPanel = AddUIComponent <UIColorSubPanel>();
            MessageColorSubPanel.ParentBannerConfig       = this;
            MessageColorSubPanel.Description.text         = "Chirp Message Color";
            MessageColorSubPanel.ColorField.selectedColor = UIMarkupStyle.ParseColor(ChirpyBanner.CurrentConfig.MessageColor, Color.white);
            MessageColorSubPanel.ColorField.eventSelectedColorReleased += (component, param) => { ChirpyBanner.CurrentConfig.MessageColor = UIMarkupStyle.ColorToHex(param); };

            this.eventVisibilityChanged += BannerConfiguration_eventVisibilityChanged;
        }