private void MuteButtonClick(UIComponent component, UIMouseEventParameter eventParam)
        {
            if (eventParam.buttons == UIMouseButton.Left && ChirpPanel.instance != null)
            {
                if (SuperChirper.IsMuted)
                {
                    // Unmute the chirper, let it make noise.
                    SuperChirper.IsMuted          = false;
                    chirpPane.m_NotificationSound = SuperChirperLoader.MessageSound;

                    // Inform user that chirpy has been unmuted
                    chirpPane.AddMessage(new ChirpMessage("SuperChirper", "Chirpy now unmuted.", 12345), true);

                    // Adjust button.
                    SuperChirperMod.MuteButtonInstance.text = "Mute";
                }
                else if (!SuperChirper.IsMuted)
                {
                    // Set chirper to muted, update sounds.
                    SuperChirper.IsMuted          = true;
                    chirpPane.m_NotificationSound = null;
                    chirpPane.ClearMessages();

                    // Adjust button.
                    SuperChirperMod.MuteButtonInstance.text = "Unmute";
                }
            }
        }
 private void ClearButtonClick(UIComponent component, UIMouseEventParameter eventParam)
 {
     if (eventParam.buttons == UIMouseButton.Left && ChirpPanel.instance != null)
     {
         // Clear all messages in Chirpy and hide the window
         chirpPane.ClearMessages();
         chirpPane.Collapse();
     }
 }
Пример #3
0
        //Thread: Main
        public override void OnUpdate()
        {
            if (isMuted)
            {
                // Collapse and clear only when a new message is received. (Otherwise can not open once muted.)
                if (newMsgIn)
                {
                    chirpPane.ClearMessages();
                    messageFilterMap.Clear();

                    // Check if user had window open before.
                    if (!userOpened)
                    {
                        chirpPane.Collapse();
                    }
                    newMsgIn = false;
                }
            }
            else if (!isMuted)
            {
                // Room for further implementation in the future. (Potentially filtering etc.)

                if (isFiltered && !hasFilters)
                {
                    FilterMessages();
                }

                // Remove hashtags
                if (!isHashTagged)
                {
                    RemoveHashtags();
                }
            }

            // Detect keypress - Alt+C
            if (Event.current.alt && Input.GetKeyDown(KeyCode.C))
            {
                DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Chirpy toggled.");

                // Toggle chirpy
                chirpPane.gameObject.SetActive(!chirpPane.gameObject.activeSelf);

                if (!chirpPane.gameObject.activeSelf)
                {
                    SuperChirperMod.OptionsPanelInstance.Hide();
                }

                newMsgIn = true;

                /*
                 * TODO:
                 * Stop messages not clearing when we reactivate after muting
                 * Fix message manager so that dehashtag messages are stored correctly
                 */
            }
        }
Пример #4
0
 private void ClearButtonClick(UIComponent component, UIMouseEventParameter eventParam)
 {
     if (eventParam.buttons == UIMouseButton.Left && ChirpPanel.instance != null)
     {
         // Clear all messages in Chirpy
         if (_chirpPanel != null)
         {
             _chirpPanel.ClearMessages();
         }
     }
 }
Пример #5
0
 public void OnNewMessage(IChirperMessage msg)
 {
     if (!chiperChecked)
     {
         cpanel.ClearMessages();
         chiperChecked = true;
         if (chirpContainer == null)
         {
             chirperDestroyed = true;
         }
     }
     if (!chirperDestroyed)
     {
         CitizenMessage cm = msg as CitizenMessage;
         if (cm != null)
         {
             FilterContainer fc = new FilterContainer(cm, chirpContainer.transform.childCount);
             filter(fc);
             recentMessages.Add(fc);
         }
     }
 }
        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;
        }