public static void CallQueuedCommand(string user, [Group(1)] bool now, [Group(2)] string name) { name = (name?.Trim()) ?? ""; var response = TwitchGame.Instance.CheckIfCall(false, now, user, name, out bool callChanged); if (response != TwitchGame.CallResponse.Success) { TwitchGame.Instance.SendCallResponse(user, name, response, callChanged); return; } if (callChanged) { IRCConnection.SendMessageFormat("@{0}, your call has been changed to {1}.", user, string.IsNullOrEmpty(name) ? "the next queued command" : name); } TwitchGame.Instance.CommandQueue.Remove(TwitchGame.Instance.callSend); TwitchGame.ModuleCameras?.SetNotes(); IRCConnection.SendMessageFormat("{0} {1}: {2}", TwitchGame.Instance.callWaiting && string.IsNullOrEmpty(user) ? "Call waiting, calling" : now ? "Bypassing the required number of calls, calling" : TwitchGame.Instance.callsNeeded > 1 ? "Required calls reached, calling" : "Calling", TwitchGame.Instance.callSend.Message.UserNickName, TwitchGame.Instance.callSend.Message.Text); DeleteCallInformation(true); IRCConnection.ReceiveMessage(TwitchGame.Instance.callSend.Message); }
private void OnGUI() { if (!TwitchPlaySettings.data.TwitchPlaysDebugEnabled) { return; } GUILayout.BeginArea(new Rect(50, Screen.height - 75, (Screen.width - 50) * 0.2f, 25)); GUILayout.BeginHorizontal(); _inputCommand = GUILayout.TextField(_inputCommand, GUILayout.MinWidth(50)); if ((GUILayout.Button("Send") || Event.current.keyCode == KeyCode.Return) && !string.IsNullOrEmpty(_inputCommand)) { if (_inputCommand.Equals(DebugSequence)) { TwitchPlaySettings.data.TwitchPlaysDebugEnabled = !TwitchPlaySettings.data.TwitchPlaysDebugEnabled; TwitchPlaySettings.WriteDataToFile(); _inputCommand = ""; GUILayout.EndHorizontal(); GUILayout.EndArea(); return; } IRCConnection.SetDebugUsername(); IRCConnection.SendMessage(_inputCommand); IRCConnection.ReceiveMessage(IRCConnection.Instance.UserNickName, IRCConnection.Instance.CurrentColor, _inputCommand); _inputCommand = ""; } GUILayout.EndHorizontal(); GUILayout.EndArea(); }
private void SetupChatSimulator() { chatSimulator.SetActive(TwitchPlaySettings.data.TwitchPlaysDebugEnabled); var num = MouseControls.SCREEN_BOUNDARY_PERCENT * Screen.height + 5; chatSimulator.transform.position = new Vector3(num, num, 0); var messageInput = chatSimulator.Traverse <InputField>("MessageInput"); var sendButton = chatSimulator.Traverse <Button>("SendButton"); messageInput.onEndEdit.AddListener(_ => { if (Input.GetKey(KeyCode.Return)) { sendButton.onClick.Invoke(); messageInput.ActivateInputField(); } }); sendButton.onClick.AddListener(() => { var message = messageInput.text; if (string.IsNullOrEmpty(message)) { return; } if (message.Equals(DebugSequence)) { TwitchPlaySettings.data.TwitchPlaysDebugEnabled = !TwitchPlaySettings.data.TwitchPlaysDebugEnabled; TwitchPlaySettings.WriteDataToFile(); chatSimulator.SetActive(TwitchPlaySettings.data.TwitchPlaysDebugEnabled); } else { IRCConnection.SetDebugUsername(); IRCConnection.SendMessage(message); IRCConnection.ReceiveMessage(IRCConnection.Instance.UserNickName, IRCConnection.Instance.CurrentColor, message); } messageInput.text = ""; }); }
public static void CallAllQueuedCommands(string user, bool isWhisper) { if (TwitchGame.Instance.CommandQueue.Count == 0) { IRCConnection.SendMessage($"{user}, the queue is empty.", user, !isWhisper); return; } // Take a copy of the list in case executing one of the commands modifies the command queue var allCommands = TwitchGame.Instance.CommandQueue.ToList(); TwitchGame.Instance.CommandQueue.Clear(); TwitchGame.ModuleCameras?.SetNotes(); foreach (var call in allCommands) { IRCConnection.SendMessageFormat("Calling {0}: {1}", call.Message.UserNickName, call.Message.Text); IRCConnection.ReceiveMessage(call.Message); } }
public static void CallQueuedCommand(string user, bool isWhisper, [Group(1)] bool now, [Group(2)] string name) { name = name?.Trim(); if (TwitchGame.Instance.CallingPlayers.Contains(user)) { IRCConnection.SendMessageFormat("@{0}, you already called!", user); return; } var _callsNeeded = TwitchGame.Instance.callsNeeded; var _callsTotal = TwitchGame.Instance.CallingPlayers.Count; // Only call if there are enough calls. if (!(_callsTotal + 1 >= _callsNeeded) && !now) { TwitchGame.Instance.CallingPlayers.Add(user); CallCountCommand(); return; } CommandQueueItem call = null; if (string.IsNullOrEmpty(name)) { // Call the first unnamed item in the queue. call = TwitchGame.Instance.CommandQueue.Find(item => item.Name == null); if (call == null) { IRCConnection.SendMessage($"@{user}, no unnamed commands in the queue.", user, !isWhisper); return; } } else if (name.StartsWith("!")) { name += ' '; // Call an unnamed item in the queue for a specific module. call = TwitchGame.Instance.CommandQueue.Find(item => item.Message.Text.StartsWith(name) && item.Name == null); if (call == null) { // If a named command exists, and no unnamed commands exist, then show the name of that command (but don't call it). call = TwitchGame.Instance.CommandQueue.Find(item => item.Message.Text.StartsWith(name)); if (call != null) { IRCConnection.SendMessage($"@{user}, module {name} is queued with the name “{call.Name}”, please use “!call {call.Name}” to call it.", user, !isWhisper); } else { IRCConnection.SendMessage($"@{user}, no commands for module {name} in the queue.", user, !isWhisper); } return; } } else { // Call a named item in the queue. call = TwitchGame.Instance.CommandQueue.FirstOrDefault(item => name.EqualsIgnoreCase(item.Name)); if (call == null) { IRCConnection.SendMessage($"@{user}, no commands named “{name}” in the queue.", user, !isWhisper); return; } } TwitchGame.Instance.CallingPlayers.Clear(); TwitchGame.Instance.CommandQueue.Remove(call); TwitchGame.ModuleCameras?.SetNotes(); IRCConnection.SendMessageFormat("{0} {1}: {2}", now ? "Bypassing the required number of calls, calling" : TwitchGame.Instance.callsNeeded > 1 ? "Required calls reached, calling" : "Calling", call.Message.UserNickName, call.Message.Text); IRCConnection.ReceiveMessage(call.Message); }