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"; } } }
public static void SendMessage(string senderName, string message) { ChirpPanel cp = ChirpPanel.instance; if (cp == null) { return; } cp.AddMessage(new ChirpForecast() { senderName = senderName, text = message }); }
// 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; } } }
public static void SendMessage(string senderName, string msg) { ChirpPanel cp = ChirpPanel.instance; if (cp == null) { return; } if (lastChrip == DateTime.MinValue) { lastChrip = DateTime.Now.AddSeconds(10); } DateTime now = DateTime.Now; // if ((now - lastChrip).TotalSeconds > 5) { cp.AddMessage(new ChirpBox() { senderName = senderName, text = msg }); lastChrip = now; } }
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; }