public ChannelGUI(IRCLinkWindow linkWindow, string handle, IRCConfig config) { this.linkWindow = linkWindow; this.handle = handle; this.config = config; // prevent highlighting in "(Debug)" or "(Notice)" channels highlightName = handle.StartsWith("#"); }
public IRCChatWindow(IRCLinkWindow linkWindow, string version, IRCConfig config) : base("chat", config, new Rect(Screen.width / 6, Screen.height / 6, Screen.width * 2 / 3, Screen.height * 2 / 3)) { this.linkWindow = linkWindow; this.config = config; hidden = true; title = "IRC - " + version + " - " + (config.twitch ? "Twitch" : config.host + ":" + config.port); onResized += windowResized; onVisibleToggled += (e) => windowVisibleToggled(e.visible); }
KSPIRC() { instance = this; GameObject.DontDestroyOnLoad(this); version = this.GetType().Assembly.GetName().Version.ToString(); config = new IRCConfig(); configWindow = new IRCConfigWindow(version, config); configWindow.configChangedEvent += configChanged; linkWindow = new IRCLinkWindow(config); linkWindow.hidden = true; chatWindow = new IRCChatWindow(linkWindow, version, config); chatWindow.channelClosedEvent += channelClosed; chatWindow.onUserCommandEntered += (e) => handleUserCommand(e.command); chatWindow.onShowConfigHandler += showConfig; chatWindow.hidden = IRC_WINDOW_HIDDEN; initCommandHandlers(); initUserCommandHandlers(); client = new IRCClient(); client.onCommandReceived += (e) => handleServerCommand(e.command); client.onCommandSent += (e) => logSendCommand(e.command); client.onConnect += () => chatWindow.addToChannel(NOTICE_CHANNEL_HANDLE, "*", "Connecting to server " + config.host + ":" + config.port + "..."); client.onConnected += () => chatWindow.addToChannel(NOTICE_CHANNEL_HANDLE, "*", "Server connection established."); client.onSSLConnected += () => chatWindow.addToChannel(NOTICE_CHANNEL_HANDLE, "*", "SSL Server connection established."); client.onDisconnected += () => chatWindow.addToChannel(NOTICE_CHANNEL_HANDLE, "*", "Disconnected from server."); client.onConnectionFailed += () => chatWindow.addToChannel(NOTICE_CHANNEL_HANDLE, "*", "Connection failed to server."); client.onConnectionAttemptsExceeded += () => chatWindow.addToChannel(NOTICE_CHANNEL_HANDLE, "*", "Connection attempts exceeded. Change config before retrying."); client.onSSLCertificateError += () => chatWindow.addToChannel(NOTICE_CHANNEL_HANDLE, "*", "SSL Certificate error - use this server at your own risk."); if ((config.host != null) && (config.port > 0) && (config.nick != "")) { Debug.Log("Connecting to: " + config.host + ":" + config.port); configWindow.hidden = true; client.connect(config); } else { configWindow.hidden = false; chatWindow.addToChannel("IRC Plugin", "*", "IRC plugin not configured, not connecting to IRC server."); chatWindow.addToChannel("IRC Plugin", "*", "Edit config and confirm updates to connect."); } if (ToolbarManager.ToolbarAvailable) { windowButton = ToolbarManager.Instance.add("irc", "irc"); windowButton.TexturePath = "KSPIRC/button-regular"; windowButton.ToolTip = "IRC"; windowButton.Visibility = new GameScenesVisibility(GameScenes.CREDITS, GameScenes.EDITOR, GameScenes.FLIGHT, GameScenes.LOADING, GameScenes.LOADINGBUFFER, GameScenes.MAINMENU, GameScenes.PSYSTEM, GameScenes.SPACECENTER, GameScenes.TRACKSTATION); windowButton.OnClick += (e) => toggleChatWindow(); } else { ApplicationLauncher.AppScenes scenes = ApplicationLauncher.AppScenes.ALWAYS; Texture toolbarButtonTexture = (Texture)GameDatabase.Instance.GetTexture("KSPIRC/button-regular", false); appLauncherButton = ApplicationLauncher.Instance.AddModApplication(onAppLaunchToggleOn, onAppLaunchToggleOff, null, null, null, null, scenes, toolbarButtonTexture); } }