Ejemplo n.º 1
0
            internal PlainChannelMessageRenderer(ChannelGUI gui, string sender, string text)
                : base(sender, text)
            {
                // use full markup for clickies
                textClickifiedText = StripControlChars(text);

                this.highlighted = gui.highlightName && (sender != "*") && this.sourceText.ToLower().Contains(gui.config.nick.ToLower());
            }
Ejemplo n.º 2
0
            internal RichTextLabelChannelMessageRenderer(ChannelGUI gui, string sender, string text)
                : base(sender, text)
            {
                ToRichText(sender, out senderRichText, out senderClickifiedText);
                ToRichText(text, out textRichText, out textClickifiedText);

                this.highlighted = gui.highlightName && (sender != "*") && this.sourceText.ToLower().Contains(gui.config.nick.ToLower());
            }
Ejemplo n.º 3
0
 private void initStyles(ChannelGUI gui)
 {
     if (!this.stylesInitialized)
     {
         this.senderWidth       = gui.senderStyle.CalcSize(new GUIContent(sender)).x;
         this.stylesInitialized = true;
     }
 }
Ejemplo n.º 4
0
            private void handleClick(ChannelGUI gui, string text, int index)
            {
                string word = GetWordAt(text, index);

                if (word.StartsWith("http:") || word.StartsWith("https:"))
                {
                    gui.linkWindow.load(word);
                }
            }
Ejemplo n.º 5
0
 private void closeChannel(string handle)
 {
     if (channelClosedEvent != null)
     {
         channelClosedEvent(new ChannelEvent(handle));
     }
     channelGUIs.Remove(handle);
     handles.Remove(handle);
     currentChannelGUI = channelGUIs.Values.FirstOrDefault();
 }
Ejemplo n.º 6
0
 internal ChannelMessageRenderer get(ChannelGUI gui, string sender, string text)
 {
     if (gui.config.forceSimpleRender)
     {
         return(new PlainChannelMessageRenderer(gui, sender, text));
     }
     else
     {
         return(new RichTextLabelChannelMessageRenderer(gui, sender, text));
     }
 }
Ejemplo n.º 7
0
        private ChannelGUI getChannelGUI(string handle)
        {
            ChannelGUI channelGUI;

            if (!channelGUIs.ContainsKey(handle))
            {
                channelGUI        = new ChannelGUI(linkWindow, handle, config);
                channelGUI.hidden = true;
                channelGUI.onUserCommandEntered += (e) => userCommandEntered(e.command);
                channelGUIs.Add(handle, channelGUI);
                handles.Add(handle);
                handles.Sort(StringComparer.CurrentCultureIgnoreCase);
            }
            else
            {
                channelGUI = channelGUIs[handle];
            }
            return(channelGUI);
        }
Ejemplo n.º 8
0
            internal override void Render(ChannelGUI gui, float spaceWidth, float maxNameWidth)
            {
                initStyles(gui);


                GUIStyle style = (highlighted ? gui.textHighlightedStyle : gui.textStyle);

                GUILayout.BeginHorizontal();
                GUILayout.Label(sender, gui.senderStyle, GUILayout.Width(maxNameWidth), GUILayout.MaxWidth(maxNameWidth));
                if (GUILayout.Button(sourceText, style))
                {
                    int textIndex = style.GetCursorStringIndex(textRect, new GUIContent(textClickifiedText), Event.current.mousePosition);
                    handleClick(gui, textClickifiedText, textIndex);
                }
                if (Event.current.type == EventType.Repaint)
                {
                    textRect = GUILayoutUtility.GetLastRect();
                }
                GUILayout.EndHorizontal();
            }
Ejemplo n.º 9
0
        public void addToChannel(string handle, string sender, string text, IRCCommand cmd = null)
        {
            TextInputState textInputState = GetInputState();
            ChannelGUI     channelGUI     = getChannelGUI(handle);

            channelGUI.addToBuffer(sender, text, cmd);

            // show this channel if no channel is visible yet
            if (currentChannelGUI == null)
            {
                currentChannelGUI        = channelGUI;
                currentChannelGUI.hidden = false;
            }

            RestoreInputFocus(textInputState);

            if (config.tts)
            {
                speak(handle, sender, text, cmd);
            }
        }
Ejemplo n.º 10
0
            private void initStyles(ChannelGUI gui)
            {
                if (!this.stylesInitialized)
                {
                    this.senderTextStyle = new GUIStyle(gui.senderStyle);
                    this.senderTextStyle.normal.textColor = Color.white;
                    this.senderTextStyle.richText         = true;

                    this.textStyle = new GUIStyle(gui.textStyle);
                    this.textStyle.normal.textColor = Color.white;
                    this.textStyle.richText         = true;

                    this.textHighlightedStyle = new GUIStyle(gui.textHighlightedStyle);
                    this.textHighlightedStyle.normal.textColor = Color.white;
                    this.textHighlightedStyle.richText         = true;

                    this.senderWidth = senderTextStyle.CalcSize(new GUIContent(senderRichText)).x;

                    this.stylesInitialized = true;
                }
            }
Ejemplo n.º 11
0
        private void drawButtons()
        {
            GUILayout.BeginHorizontal();
            for (int ix = 0; ix < handles.Count; ix++)
            {
                string handle = handles[ix];

                ChannelGUI channelGUI = getChannelGUI(handle);
                GUIStyle   buttonStyle;
                if (channelGUI.Equals(currentChannelGUI))
                {
                    buttonStyle = buttonActiveStyle;
                }
                else if (channelGUI.channelHighlightedPrivateMessage)
                {
                    buttonStyle = buttonHighlightedNicknameStyle;
                }
                else if (channelGUI.channelHighlightedMessage)
                {
                    buttonStyle = buttonHighlightedStyle;
                }
                else
                {
                    buttonStyle = GUI.skin.button;
                }

                if (GUILayout.Button(handle, buttonStyle))
                {
                    currentChannelGUI        = channelGUI;
                    currentChannelGUI.hidden = false;
                    foreach (ChannelGUI gui in channelGUIs.Values.Where(gui => !gui.Equals(currentChannelGUI)))
                    {
                        gui.hidden = true;
                    }
                }
            }

            GUILayout.FlexibleSpace();

            if ((currentChannelGUI != null) && (channelGUIs.Count > 1))
            {
                if (currentChannelGUI.handle.StartsWith("#"))
                {
                    if (GUILayout.Button(namesHidden ? "<" : ">"))
                    {
                        namesHidden = !namesHidden;
                    }
                }
                if (GUILayout.Button("X"))
                {
                    closeChannel(currentChannelGUI.handle);
                }
            }

            if (GUILayout.Button("Config"))
            {
                if (onShowConfigHandler != null)
                {
                    onShowConfigHandler(new ShowConfigEvent());
                }
            }
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 12
0
 internal override float SenderWidth(ChannelGUI gui)
 {
     initStyles(gui);
     return(senderWidth);
 }
Ejemplo n.º 13
0
 abstract internal void Render(ChannelGUI gui, float spaceWidth, float maxNameWidth);
Ejemplo n.º 14
0
 abstract internal float SenderWidth(ChannelGUI gui);