public FilterContainer(CitizenMessage citizenmsg, int id) { this.cm = citizenmsg; this.filtered = false; this.chirpmessagetext = cm.text; this.index = id; }
/// <summary> /// OnNewMessage runs before the message can be found in the stack. So we try to get /// rid of it here Mostly copied from https://github.com/mabako/reddit-for-city-skylines/ /// </summary> public override void OnUpdate() { // If there's no message to remove, continue on if (_messageRemovalTarget == null) return; if (ChirpPanel.instance == null) return; // This code is roughly based on the work by Juuso "Zuppi" Hietala. // Get the Chirper container, where all of the chirps reside var container = ChirpPanel.instance.transform.Find("Chirps").Find("Clipper").Find("Container").gameObject.transform; for (var i = 0; i < container.childCount; ++i) { // Keep looping until we get the one we want. It should pretty much be the very first one we snag every time, on very rare // occurence the second one if (!container.GetChild(i).GetComponentInChildren<UILabel>().text.Equals(_messageRemovalTarget.GetText())) continue; // Remove the message UITemplateManager.RemoveInstance("ChirpTemplate", container.GetChild(i).GetComponent<UIPanel>()); MessageManager.instance.DeleteMessage(_messageRemovalTarget); // We're done here _messageRemovalTarget = null; break; } }
/// <summary> /// On a new message event we check and see if the message is one we want to keep or delete. Mostly copied from https://github.com/mabako/reddit-for-city-skylines/ /// </summary> public override void OnNewMessage(IChirperMessage message) { // If the message should be filtered, target it for removal var citizenMessage = message as CitizenMessage; if (citizenMessage == null) return; if (!Configuration.ConfigurationSettings.ShowDefaultChirperMessages) _messageRemovalTarget = citizenMessage; }
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); } } }
//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 void OnNewMessage(IChirperMessage message) { bool important = false; if (message != null && theBannerPanel != null) { try { string citizenMessageID = string.Empty; CitizenMessage cm = message as CitizenMessage; if (cm != null) { //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("found citmess MessageID: {0} GetText: {1}", cm.m_messageID, cm.GetText())); citizenMessageID = cm.m_messageID; } if (!string.IsNullOrEmpty(citizenMessageID)) { // TODO: Do stuff if the Chirper message is actually important. // Hope is to mimic SimCity's ticker. // List of LocaleIDs available here: https://github.com/cities-skylines/Assembly-CSharp/wiki/LocaleID important = FilterMessage(cm.m_messageID); } } catch (Exception ex) { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("ChirpBanner.OnNewMessage threw Exception: {0}", ex.Message)); } // use rich styled text // Colossal markup uses sliiiiiightly different tags than unity. // munge our config strings to fit string nameColorTag = MyConfig.ConfigHolder.Config.NameColor; string textColorTag = MyConfig.ConfigHolder.Config.MessageColor; if (nameColorTag.Length == 9) // ie: #001122FF { nameColorTag = nameColorTag.Substring(0, 7); // drop alpha bits } if (textColorTag.Length == 9) // ie: #001122FF { textColorTag = textColorTag.Substring(0, 7); // drop alpha bits } // Check for CurrentConfig.ColorChirps if (MyConfig.ConfigHolder.Config.ColorChirps) { // If chirp is important, and ColorChirps is enabled, make the chirp name and message red. if (important) { //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("Chirp is important: {0}", message.text)); //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("CurrentConfig.NameColor: {0}", CurrentConfig.NameColor)); //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("CurrentConfig.MessageColor: {0}", CurrentConfig.MessageColor)); textColorTag = "#FF0000"; nameColorTag = "#FF0000"; } } string str = String.Format("<color{0}>{1}</color> : <color{2}>{3}</color>", nameColorTag, message.senderName, textColorTag, message.text); // Check for CurrentConfig.FilterChirps if (MyConfig.ConfigHolder.Config.FilterChirps) { // If Chirp is deemed not important as a result of above LocaleIDs, just return, do nothing if (!important) { //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("Chirp is not important: {0}", message.text)); return; } // Otherwise, do something if (important) { //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("Chirp is important: {0}", message.text)); //theBannerPanel.CreateBannerLabel (str, message.senderID); ChirpMoverThread.addTask2Main(() => { theBannerPanel.CreateBannerLabel(str, message.senderID); }); } } else { //theBannerPanel.CreateBannerLabel (str, message.senderID); ChirpMoverThread.addTask2Main(() => { theBannerPanel.CreateBannerLabel(str, message.senderID); }); } //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("textColorTag: {0}", textColorTag)); //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("nameColorTag: {0}", nameColorTag)); //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("chirp! {0}", message.text)); //MyIThreadingExtension.addTask2Main(() => { theBannerPanel.CreateBannerLabel(str, message.senderID); }); //MyIThreadingExtension.addTask2Main(() => { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("chirp! {0}", message.text)); }); } }
public void OnNewMessage(IChirperMessage message) { if (message != null && theBannerPanel != null) { try { string citizenMessageID = string.Empty; CitizenMessage cm = message as CitizenMessage; if (cm != null) { //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("found citmess MessageID: {0} GetText: {1}", cm.m_messageID, cm.GetText())); citizenMessageID = cm.m_messageID; } if (!string.IsNullOrEmpty(citizenMessageID)) { // Integrate with ChirpFilter if (ChirpFilter_FilterModule == null) { GameObject ChirpFilter_GameObject = GameObject.Find("ChirperFilterModule"); if (ChirpFilter_GameObject != null) { ChirpFilter_FilterModule = ChirpFilter_GameObject.GetComponent("ChirpFilter.FilterModule"); } } if (ChirpFilter_FilterModule != null) { bool bIsBlacklisted = false; if (ChirpFilter_FilterModule is IFormattable) { IFormattable ifs = ChirpFilter_FilterModule as IFormattable; string sresult = ifs.ToString(citizenMessageID, null); if (string.IsNullOrEmpty(sresult) || sresult == "false") { bIsBlacklisted = false; } else if (sresult == "true") { bIsBlacklisted = true; } } // see if ChirpFilter wants us to filter (not show) the message if (bIsBlacklisted) { //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("msgid {0} msg {1} blacklisted", citizenMessageID, message.text)); return; } } } } catch (Exception ex) { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("ChirpBanner.OnNewMessage threw Exception: {0}", ex.Message)); } // use rich styled text // Colossal markup uses sliiiiiightly different tags than unity. // munge our config strings to fit string nameColorTag = CurrentConfig.NameColor; string textColorTag = CurrentConfig.MessageColor; if (nameColorTag.Length == 9) // ie: #001122FF { nameColorTag = nameColorTag.Substring(0, 7); // drop alpha bits } if (textColorTag.Length == 9) // ie: #001122FF { textColorTag = textColorTag.Substring(0, 7); // drop alpha bits } //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("chirp! {0}", message.text)); string str = String.Format("<color{0}>{1}</color> : <color{2}>{3}</color>", nameColorTag, message.senderName, textColorTag, message.text); theBannerPanel.CreateBannerLabel(str, message.senderID); } }