コード例 #1
0
        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("#");
        }
コード例 #2
0
ファイル: AbstractWindow.cs プロジェクト: timmersuk/ksp_irc
        protected AbstractWindow(string configName, IRCConfig config, Rect defaultRect)
        {
            this.configName = configName;
            this.config     = config;

            if (!config.GetWindowRect(configName, ref rect))
            {
                rect = defaultRect;
            }
        }
コード例 #3
0
ファイル: IRCChatWindow.cs プロジェクト: timmersuk/ksp_irc
        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);
        }
コード例 #4
0
ファイル: IRCConfigWindow.cs プロジェクト: timmersuk/ksp_irc
        public IRCConfigWindow(string version, IRCConfig config)
            : base("config", config, new Rect(Screen.width / 6, Screen.height / 6, 300, 200))
        {
            this.config               = config;
            this.wipTwitch            = config.twitch;
            this.wipHost              = (config.host == null ? "" : config.host);
            this.wipPort              = Convert.ToString(config.port);
            this.wipSecure            = config.secure;
            this.wipNick              = (config.nick == null ? "" : config.nick);
            this.wipUser              = (config.user == null ? "" : config.user);
            this.wipServerPassword    = (config.serverPassword == null ? "" : config.serverPassword);
            this.wipForceSimpleRender = config.forceSimpleRender;
            this.wipChannels          = config.channels;
            this.wipTTS               = config.tts;
            this.wipTTSVolume         = config.ttsVolume;
            this.wipDebug             = config.debug;


            title = "IRC Config - " + version;
        }
コード例 #5
0
 public ConfigChangedEvent(IRCConfig config)
 {
     this.config = config;
 }
コード例 #6
0
 public IRCLinkWindow(IRCConfig config)
     : base("link", config, new Rect(Screen.width / 4, Screen.height / 4, Screen.width / 4, Screen.height / 4))
 {
     hidden = true;
     title  = "KSPIRC Link Viewer";
 }
コード例 #7
0
ファイル: KSPIRC.cs プロジェクト: timmersuk/ksp_irc
        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);
            }
        }
コード例 #8
0
ファイル: IRCClient.cs プロジェクト: timmersuk/ksp_irc
 public void connect(IRCConfig config)
 {
     this.connectionAttempts = 0;
     this.config             = config;
     connect();
 }