Exemplo n.º 1
0
        // Custom method to delete a single message - uses ChirpMessages.
        private void DeleteMessage(ChirpMessage message)
        {
            // Get container for chirps
            Transform container = chirpPane.transform.FindChild("Chirps").FindChild("Clipper").FindChild("Container").gameObject.transform;

            for (int i = 0; i < container.childCount; ++i)
            {
                if (container.GetChild(i).GetComponentInChildren <UILabel>().text.Equals(message.GetText()))
                {
                    DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Deleted Message:" + message.text);
                    // Remove both visual and internal message.
                    UITemplateManager.RemoveInstance("ChirpTemplate", container.GetChild(i).GetComponent <UIPanel>());

                    // Find the original message, remove it from manager.
                    IChirperMessage delMessage;
                    messageMap.TryGetValue(message, out delMessage);
                    messageManager.DeleteMessage(delMessage);


                    if (!userOpened)
                    {
                        chirpPane.Collapse();
                    }
                    return;
                }
            }
        }
Exemplo n.º 2
0
        private void RemoveHashtags()
        {
            Transform container = chirpPane.transform.FindChild("Chirps").FindChild("Clipper").FindChild("Container").gameObject.transform;

            foreach (ChirpMessage message in hashTaggedMessages)
            {
                // Set showHide time low to stop overlap.
                chirpPane.m_ShowHideTime = 0.05f;

                // Delete old message.
                DeleteMessage(message);

                // Construct new message without hashtags.
                string       newMessageText = ChirpFilter.DeHashTagMessage(message);
                ChirpMessage newMessage     = new ChirpMessage(message.senderName, newMessageText, message.senderID);

                chirpPane.StartCoroutine(AddMessageCo(newMessage));

                // Set showHide time to normal.
                chirpPane.m_ShowHideTime = showHideTime;

                // Clean up ...
                bool filtered;

                if (messageFilterMap.TryGetValue(message, out filtered))
                {
                    messageFilterMap.Remove(message);
                    messageFilterMap.Add(newMessage, filtered);
                }

                IChirperMessage managerMessage;

                if (messageMap.TryGetValue(message, out managerMessage))
                {
                    messageMap.Remove(message);
                    messageMap.Add(newMessage, managerMessage);
                }

                hashTaggedMessages.Remove(message);
            }
        }
Exemplo n.º 3
0
        // In development - not used!
        private void ReplaceMessage(ChirpMessage delMessage, ChirpMessage replaceMessage)
        {
            // Get container for chirps
            Transform container = chirpPane.transform.FindChild("Chirps").FindChild("Clipper").FindChild("Container").gameObject.transform;

            for (int i = 0; i < container.childCount; ++i)
            {
                if (container.GetChild(i).GetComponentInChildren <UILabel>().text.Equals(delMessage.GetText()))
                {
                    DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Replaced Message:" + delMessage.text);
                    // Remove both visual and internal message.
                    UITemplateManager.RemoveInstance("ChirpTemplate", container.GetChild(i).GetComponent <UIPanel>());
                    chirpPane.AddMessage(replaceMessage, true);

                    // Find the original message, replace it in manager.
                    MessageBase[] messages = (MessageBase[])typeof(MessageManager).GetField("m_recentMessages", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(MessageManager.instance);

                    for (int j = 0; j < messages.Length; ++j)
                    {
                        if (messages[i].text.Equals(delMessage))
                        {
                            DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] New Message:" + delMessage.text);
                            messages[i] = replaceMessage;
                        }
                    }

                    //DEBUGGING
                    MessageBase[] finalMessages = (MessageBase[])typeof(MessageManager).GetField("m_recentMessages", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(MessageManager.instance);
                    foreach (MessageBase message in finalMessages)
                    {
                        DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Final Message:" + message.text);
                    }
                    return;
                }
            }
        }
Exemplo n.º 4
0
        //Thread: Main
        public override void OnNewMessage(IChirperMessage message)
        {
            // To make mute collapsing work better.
            userOpened = chirpPane.isShowing;
            newMsgIn   = true;

            DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Message received");
            if (!isMuted)
            {
                // Cast message and check whether it should be filtered.
                CitizenMessage cm            = message as CitizenMessage;
                ChirpMessage   storedMessage = new ChirpMessage(message.senderName, message.text, message.senderID);

                bool filter = ChirpFilter.FilterMessage(cm.m_messageID);

                if (cm != null)
                {
                    // Check if message is garbage


                    // Check if we should make noise
                    chirpPane.m_NotificationSound = ((isFiltered && filter) ? null : SuperChirperLoader.MessageSound);

                    // TODO: Change to ChirpMessage in dictionary, to make compatible with hashtag removal.
                    messageFilterMap.Add(storedMessage, filter);
                }
                else
                {
                    // Default to unfiltered messages.
                    messageFilterMap.Add(storedMessage, false);
                }

                hashTaggedMessages.Add(storedMessage);
                messageMap.Add(storedMessage, message);
            }
        }
        public override void OnLevelLoaded(LoadMode mode)
        {
            chirpPane      = GameObject.Find("ChirperPanel").GetComponent <ChirpPanel>();
            messageManager = GameObject.Find("MessageManager").GetComponent <MessageManager>();

            // For development
            DestroyPanel();

            if (chirpPane == null)
            {
                return;
            }

            messageSound = chirpPane.m_NotificationSound;

            #region "ChirpFilters Mod"
            // We check if ChirpFilters mod is installed - if it is we don't worry about handling our own filters.
            GameObject chirperFilter = GameObject.Find("ChirperFilterModule");
            if (chirperFilter != null)
            {
                DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] ChirpFilters located.");
                SuperChirper.HasFilters = true;
            }
            else if (chirperFilter == null)
            {
                DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] ChirpFilters NOT located.");
                SuperChirper.HasFilters = false;
            }
            #endregion

            #region "NewGame"
            // Give intro message (only shows up on new level)
            ChirpMessage introMessage = new ChirpMessage("SuperChirpy", "Welcome to Super Chirpy! Press Alt+C to toggle Chirpy, press Clear to delete all chirps, and options to access other features.", 12345);
            // Get rid of default message
            chirpPane.ClearMessages();
            chirpPane.AddMessage(introMessage);
            #endregion

            GameObject clearButtonObject   = new GameObject("SuperChirperClearButton", typeof(UIButton));
            GameObject optionsButtonObject = new GameObject("SuperChirperOptionsButton", typeof(UIButton));
            optionsPanelObject = new GameObject("SuperChirperOptionsPanel", typeof(ChirperConfigPanel));

            // Make the Objects a child of the uiView.
            clearButtonObject.transform.parent   = chirpPane.transform;
            optionsButtonObject.transform.parent = chirpPane.transform;

            // Get the button component.
            UIButton           clearButton   = clearButtonObject.GetComponent <UIButton>();
            UIButton           optionsButton = optionsButtonObject.GetComponent <UIButton>();
            ChirperConfigPanel optionsPanel  = optionsPanelObject.GetComponent <ChirperConfigPanel>();

            if (optionsPanel == null)
            {
                DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] No ConfigPanel component found.");
            }

            UIView.GetAView().AttachUIComponent(optionsPanelObject);

            // Set the text to show on the button.
            clearButton.text   = "Clear";
            optionsButton.text = "Options";

            // Set the button dimensions.
            clearButton.width    = 50;
            clearButton.height   = 20;
            optionsButton.width  = 60;
            optionsButton.height = 20;

            // Style the buttons to make them look like a menu button.
            clearButton.normalBgSprite    = "ButtonMenu";
            clearButton.disabledBgSprite  = "ButtonMenuDisabled";
            clearButton.hoveredBgSprite   = "ButtonMenuHovered";
            clearButton.focusedBgSprite   = "ButtonMenuFocused";
            clearButton.pressedBgSprite   = "ButtonMenuPressed";
            clearButton.textColor         = new Color32(255, 255, 255, 255);
            clearButton.disabledTextColor = new Color32(7, 7, 7, 255);
            clearButton.hoveredTextColor  = new Color32(7, 132, 255, 255);
            clearButton.focusedTextColor  = new Color32(255, 255, 255, 255);
            clearButton.pressedTextColor  = new Color32(30, 30, 44, 255);

            optionsButton.normalBgSprite    = "ButtonMenu";
            optionsButton.disabledBgSprite  = "ButtonMenuDisabled";
            optionsButton.hoveredBgSprite   = "ButtonMenuHovered";
            optionsButton.focusedBgSprite   = "ButtonMenuFocused";
            optionsButton.pressedBgSprite   = "ButtonMenuPressed";
            optionsButton.textColor         = new Color32(255, 255, 255, 255);
            optionsButton.disabledTextColor = new Color32(7, 7, 7, 255);
            optionsButton.hoveredTextColor  = new Color32(7, 132, 255, 255);
            optionsButton.focusedTextColor  = new Color32(255, 255, 255, 255);
            optionsButton.pressedTextColor  = new Color32(30, 30, 44, 255);

            // Enable sounds.
            clearButton.playAudioEvents   = true;
            optionsButton.playAudioEvents = true;

            // Place the button.
            clearButton.transformPosition   = new Vector3(-1.22f, 1.0f);
            optionsButton.transformPosition = new Vector3(-1.37f, 1.0f);

            // Respond to button click.
            clearButton.eventClick   += ClearButtonClick;
            optionsButton.eventClick += OptionsButtonClick;

            SuperChirperMod.ClearButtonInstance = clearButton;

            SuperChirperMod.OptionsButtonInstance = optionsButton;


            SuperChirperMod.OptionsPanelInstance = optionsPanel;
        }
Exemplo n.º 6
0
        // Coroutine for adding delayed messages.
        IEnumerator AddMessageCo(ChirpMessage message, float waitTime = 0.01f)
        {
            yield return(new WaitForSeconds(waitTime));

            chirpPane.AddMessage(message);
        }