public override void Start() { chirpPane = GameObject.Find("ChirperPanel").GetComponent <ChirpPanel>(); if (chirpPane == null) { return; } // Set visuals for panel this.backgroundSprite = "ChirperBubble"; this.color = new Color32(122, 132, 138, 255); this.width = 300; this.height = 200; this.transformPosition = new Vector3(-1.0f, 0.9f); // Allow automated layout this.autoLayoutDirection = LayoutDirection.Vertical; this.autoLayoutStart = LayoutStart.TopLeft; this.autoLayoutPadding = new RectOffset(10, 10, 0, 10); this.autoLayout = true; // Add drag handle for panel UIDragHandle dragHandle = this.AddUIComponent <UIDragHandle>(); // Add title to drag handle UILabel titleLabel = dragHandle.AddUIComponent <UILabel>(); titleLabel.text = "Options"; titleLabel.textScale = 1.5f; titleLabel.textColor = new Color32(36, 202, 255, 255); titleLabel.textAlignment = UIHorizontalAlignment.Center; UIButton muteButton = AddNewButton("Mute"); UIButton filterButton = AddNewButton("Filters: OFF"); UIButton hashTagsButton = AddNewButton("HashTags: ON"); // Defaults to ON if ChirpFilter is active. /* * if (SuperChirper.HasFilters) * filterButton.text = "Filters: ON"; */ muteButton.eventClick += MuteButtonClick; filterButton.eventClick += FilterButtonClick; hashTagsButton.eventClick += HashTagsButtonClick; SuperChirperMod.MuteButtonInstance = muteButton; SuperChirperMod.FilterButtonInstance = filterButton; SuperChirperMod.HashTagsButtonInstance = hashTagsButton; // Default to hidden this.Hide(); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] ConfigPanel built."); }
public static void SendMessage(string senderName, string message) { ChirpPanel cp = ChirpPanel.instance; if (cp == null) { return; } cp.AddMessage(new ChirpForecast() { senderName = senderName, text = message }); }
public void OnCreated(IChirper chirper) { chirperDestroyed = false; messageManager = GameObject.Find("MessageManager").GetComponent <MessageManager>(); GameObject filterModule = new GameObject("ChirperFilterModule"); module = filterModule.AddComponent <ChirpFilter.FilterModule>(); cpanel = GameObject.Find("ChirperPanel").GetComponent <ChirpPanel>(); chirpContainer = cpanel.transform.FindChild("Chirps").FindChild("Clipper").FindChild("Container").gameObject; soundStore = cpanel.m_NotificationSound; chiperChecked = false; recentMessages = new List <FilterContainer>(); }
/// <summary> /// On creation, startup the IRC client to hook onto the twitch chat /// </summary> public override void OnCreated(IChirper c) { //c.DestroyBuiltinChirper(); Configuration.ReloadConfigFile(); if (IrcClient == null) IrcClient = new IrcClient(Logger); // The noise will drive people bonkers ChirpPanel cp = ChirpPanel.instance; if (cp != null) cp.m_NotificationSound = null; CustomCitizens = GetCustomCitizens(); //bool enterPressed = Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter); // If they're using the default username, make them aware of the options tab GetChirperManager.AddMessage("chirpertestclient", "Welcome to Twitch Chirper Chat! Click the Options button or press Alt+C to access options!", MessagePriority.Critical); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, String.Format("User Name: {0} - Channel: {1} - Connecting to Irc...", Configuration.ConfigurationSettings.UserName, Configuration.ConfigurationSettings.IrcChannel)); try { if (_apiManager != null) _apiManager.Dispose(); } // ReSharper disable once EmptyGeneralCatchClause catch {} _apiManager = new ApiManager(Logger, Configuration.ConfigurationSettings.IrcChannel); _apiManager.NewFollowers += _apiManager_NewFollowers; _apiManager.StartWatching(); // Hook up the Irc client events and execute a connection IrcClient.ChatMessageReceived += _ircClient_ChatMessageReceived; IrcClient.Disconnected += _ircClient_Disconnected; IrcClient.Connected += _ircClient_Connected; IrcClient.NewSubscriber += _ircClient_NewSubscriber; IrcClient.Connect(Configuration.ConfigurationSettings.UserName, Configuration.ConfigurationSettings.OAuthKey, Configuration.ConfigurationSettings.IrcChannel); }
/// <summary> /// Clean up the leftovers /// </summary> public override void OnReleased() { try { // Make sure we reset the notification sound back to normal, or we might really screw something up ChirpPanel cp = ChirpPanel.instance; if (cp != null) cp.m_NotificationSound = null; // Make sure the Irc client is really gone so it releases the Irc port if (IrcClient != null) IrcClient.Dispose(); IrcClient = null; } catch (Exception ex) { Logger.AddEntry(ex); } }
//Thread: Main public override void OnCreated(IChirper chirper) { try { chirpPane = GameObject.Find("ChirperPanel").GetComponent <ChirpPanel>(); messageManager = GameObject.Find("MessageManager").GetComponent <MessageManager>(); thisChirper = chirper; messageFilterMap = new Dictionary <ChirpMessage, bool>(); hashTaggedMessages = new List <ChirpMessage>(); messageMap = new Dictionary <ChirpMessage, IChirperMessage>(); showHideTime = chirpPane.m_ShowHideTime; DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Initialised modification."); } catch { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Initialisation failed."); } }
void Init() { try { DebugLogger.Message("Start Deploying Assemblys"); m_TempDir = Environment.ExpandEnvironmentVariables(@"%TEMP%\ModChitter\"); if (Directory.Exists(m_TempDir)) { Directory.Delete(m_TempDir, true); } Directory.CreateDirectory(m_TempDir); File.WriteAllBytes(m_TempDir + "Chitter.exe", Properties.Resources.Chitter); File.WriteAllBytes(m_TempDir + "Hammock.ClientProfile.dll", Properties.Resources.Hammock_ClientProfile); File.WriteAllBytes(m_TempDir + "Newtonsoft.Json.dll", Properties.Resources.Newtonsoft_Json); File.WriteAllBytes(m_TempDir + "TweetSharp.dll", Properties.Resources.TweetSharp); DebugLogger.Log(MessageType.Message, "Start Chirper Outbound"); m_Chirpy = Singleton <ChirpPanel> .instance; DebugLogger.Log(MessageType.Message, "Start Pipe Server"); m_ServerStream = new NamedPipeServerStream("chirper", PipeDirection.In); m_StreamReader = new Thread(StreamReader); m_StreamReader.Start(); DebugLogger.Message("Try Start Chitter Application at:\n\t\"" + m_TempDir + "Chitter.exe" + "\""); m_Chitter = Process.Start(m_TempDir + "Chitter.exe"); } catch (Exception ex) { DebugLogger.Log(MessageType.Error, ex.Message); } }
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; }
/// <summary> /// Initialize the options menu and Option + Clear buttons /// </summary> /// <param name="mode"></param> public override void OnLevelLoaded(LoadMode mode) { // For development DestroyPanel(); _optionsPanelObject = new GameObject("TwitchChirperChatOptionsPanel", typeof(ConfigurationPanel)); try { _chirpPanel = GameObject.Find("ChirperPanel").GetComponent <ChirpPanel>(); } catch { } if (_chirpPanel != null) { //messageSound = chirpPane.m_NotificationSound; GameObject clearButtonObject = new GameObject("SuperChirperClearButton", typeof(UIButton)); GameObject optionsButtonObject = new GameObject("SuperChirperOptionsButton", typeof(UIButton)); clearButtonObject.transform.parent = _chirpPanel.transform; optionsButtonObject.transform.parent = _chirpPanel.transform; UIButton clearButton = clearButtonObject.GetComponent <UIButton>(); UIButton optionsButton = optionsButtonObject.GetComponent <UIButton>(); // 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 = 65; 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.42f, 0.9999f); optionsButton.transformPosition = new Vector3(-1.60f, 0.9999f); // Respond to button click. clearButton.eventClick += ClearButtonClick; optionsButton.eventClick += OptionsButtonClick; ClearButtonInstance = clearButton; OptionsButtonInstance = optionsButton; } UIView.GetAView().AttachUIComponent(_optionsPanelObject); var optionsPanel = _optionsPanelObject.GetComponent <ConfigurationPanel>(); OptionsPanelInstance = optionsPanel; }