コード例 #1
0
        private static void OnTopicChange(object sender, TopicChangeEventArgs e)
        {
            string message = CRCStrings.Localize("client_topic_change") + e.NewTopic;

            CRCDisplay.AddInformation(message);
            CRCGame.AddInformation(message);
        }
コード例 #2
0
        private static void OnErrorMessage(object sender, IrcEventArgs e)
        {
            string message;

            switch (e.Data.ReplyCode)
            {
            case ReplyCode.ErrorBannedFromChannel:
                message = CRCStrings.Localize("client_banned");
                CRCDisplay.AddError(message);
                CRCGame.AddError(message);
                break;

            // What's the difference?
            case ReplyCode.ErrorNicknameInUse:
            case ReplyCode.ErrorNicknameCollision:
                message = CRCStrings.Localize("client_nick_collision");
                CRCDisplay.AddError(message);
                CRCGame.AddError(message);
                break;

            // Don't care
            case ReplyCode.ErrorNoMotd:
            case ReplyCode.ErrorNotRegistered:
                break;

            default:
                CRCDisplay.AddError(e.Data.Message);
                CRCGame.AddError(e.Data.Message);
                break;
            }
        }
コード例 #3
0
        private static void OnNickChange(object sender, NickChangeEventArgs e)
        {
            string oldNick = e.OldNickname;
            string newNick = e.NewNickname;

            Users.Remove(oldNick);
            Users.Add(newNick);
            Users.Sort();
            CRCDisplay.UpdateUsers();
            CRCGame.UpdateUsers();
            if (newNick != client.Nickname)
            {
                if (crcNicks.ContainsKey(oldNick))
                {
                    crcNicks[newNick] = crcNicks[oldNick];
                    crcNicks.Remove(oldNick);
                }
                string message = oldNick + CRCStrings.Localize("client_nick_change") + newNick;
                CRCDisplay.AddInformation(message);
                CRCGame.AddInformation(message);
            }
            else
            {
                CRCOptions.Name = newNick;
                string message = CRCStrings.Localize("client_own_nick_change") + newNick;
                CRCDisplay.AddInformation(message);
                CRCGame.AddInformation(message);
            }
        }
コード例 #4
0
        public static void SendDeath(string message)
        {
            string nick = CRCStrings.RandomName(CRCOptions.GameFaction);

            client.SendMessage(SendType.Message, CRCOptions.ChannelProxy(), nick + FAKE_DELIM + CRCOptions.GetFaction() + META_DELIM + message);
            CRCDisplay.OnChannelMessage(nick, message);
            CRCGame.OnChannelMessage(nick, CRCOptions.GameFaction, message);
        }
コード例 #5
0
 private static void OnDisconnected(object sender, EventArgs e)
 {
     if (retry)
     {
         string message = CRCStrings.Localize("client_reconnecting");
         CRCDisplay.AddInformation(message);
         CRCGame.AddInformation(message);
         client.Connect(CRCOptions.Server, 6667);
     }
 }
コード例 #6
0
 private static void OnChannelActiveSynced(object sender, IrcEventArgs e)
 {
     foreach (ChannelUser user in client.GetChannel(e.Data.Channel).Users.Values)
     {
         Users.Add(user.Nick);
     }
     Users.Sort();
     CRCDisplay.UpdateUsers();
     CRCGame.UpdateUsers();
     client.SendMessage(SendType.CtcpRequest, e.Data.Channel, "CLIENTINFO");
 }
コード例 #7
0
        private static void OnQuit(object sender, QuitEventArgs e)
        {
            crcNicks.Remove(e.Who);
            Users.Remove(e.Who);
            Users.Sort();
            CRCDisplay.UpdateUsers();
            CRCGame.UpdateUsers();
            string message = e.Who + CRCStrings.Localize("client_part");

            CRCDisplay.AddInformation(message);
            CRCGame.AddInformation(message);
        }
コード例 #8
0
        private static void OnQueryMessage(object sender, IrcEventArgs e)
        {
            lastQuery = e.Data.Nick;
            // Metadata should not be used in queries, just throw it out
            string fakeNick, faction;
            string message = GetMetadata(e.Data.Message, out fakeNick, out faction);
            string nick    = e.Data.Nick;

            faction = crcNicks.ContainsKey(nick) ? crcNicks[nick] : "actor_stalker";
            CRCDisplay.OnQueryMessage(nick, CRCOptions.Name, message);
            CRCGame.OnQueryMessage(nick, CRCOptions.Name, faction, message);
        }
コード例 #9
0
 private static void OnPart(object sender, PartEventArgs e)
 {
     if (e.Who != CRCOptions.Name)
     {
         crcNicks.Remove(e.Who);
         Users.Remove(e.Who);
         Users.Sort();
         CRCDisplay.UpdateUsers();
         CRCGame.UpdateUsers();
         string message = e.Who + CRCStrings.Localize("client_part");
         CRCDisplay.AddInformation(message);
         CRCGame.AddInformation(message);
     }
     else
     {
         string message = CRCStrings.Localize("client_own_part");
         CRCDisplay.AddInformation(message);
         CRCGame.AddInformation(message);
     }
 }
コード例 #10
0
 private static void OnJoin(object sender, JoinEventArgs e)
 {
     if (e.Who != client.Nickname)
     {
         Users.Add(e.Who);
         Users.Sort();
         CRCDisplay.UpdateUsers();
         CRCGame.UpdateUsers();
         string message = e.Who + CRCStrings.Localize("client_join");
         CRCDisplay.AddInformation(message);
         CRCGame.AddInformation(message);
     }
     else
     {
         CRCOptions.Name = e.Who;
         string message = CRCStrings.Localize("client_connected");
         CRCDisplay.AddInformation(message);
         CRCGame.AddInformation(message);
         CRCDisplay.OnConnected();
     }
 }
コード例 #11
0
        public static async Task <bool> CheckUpdate()
        {
            UpdateChecker updateChecker = new UpdateChecker("TKGP", "Chernobyl-Relay-Chat");
            UpdateType    updateType;

            try
            {
                updateType = await updateChecker.CheckUpdate();
            }
            catch (RateLimitExceededException)
            {
                return(false);
            }
            // If it got past the first one this is probably just a temporary issue
            catch (AggregateException ae)
            {
                ae.Handle(ex =>
                {
                    return(ex is HttpRequestException);
                });
                return(false);
            }
            if (updateType != UpdateType.None)
            {
                string releaseNotes = await updateChecker.RenderReleaseNotes();

                SystemSounds.Asterisk.Play();
                CRCGame.OnUpdate(CRCStrings.Localize("update_notice"));
                using (UpdateForm updateForm = new UpdateForm((updateType == UpdateType.Major || updateType == UpdateType.Minor), releaseNotes))
                {
                    DialogResult dialogResult = updateForm.ShowDialog();
                    if (dialogResult == DialogResult.OK)
                    {
                        updateChecker.DownloadAsset("Chernobyl-Relay-Chat.zip");
                    }
                }
                return(true);
            }
            return(false);
        }
コード例 #12
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string name   = textBoxName.Text.Replace(' ', '_');
            string result = CRCStrings.ValidateNick(name);

            if (result != null)
            {
                MessageBox.Show(result, CRCStrings.Localize("crc_error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string lang = indexToLanguage[comboBoxLanguage.SelectedIndex];

            if (lang != CRCOptions.Language)
            {
                CRCOptions.Language = lang;
                MessageBox.Show(CRCStrings.Localize("options_language_restart"), CRCStrings.Localize("crc_name"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            CRCOptions.Channel        = indexToChannel[comboBoxChannel.SelectedIndex];
            CRCOptions.AutoFaction    = radioButtonFactionAuto.Checked;
            CRCOptions.ManualFaction  = indexToFaction[comboBoxFaction.SelectedIndex];
            CRCOptions.Name           = name;
            CRCOptions.ShowTimestamps = checkBoxTimestamps.Checked;
            CRCOptions.SendDeath      = checkBoxDeathSend.Checked;
            CRCOptions.ReceiveDeath   = checkBoxDeathReceive.Checked;
            CRCOptions.DeathInterval  = (int)numericUpDownDeath.Value;

            CRCOptions.NewsDuration = (int)numericUpDownNewsDuration.Value;
            CRCOptions.ChatKey      = textBoxChatKey.Text;
            CRCOptions.NewsSound    = checkBoxNewsSound.Checked;
            CRCOptions.CloseChat    = checkBoxCloseChat.Checked;

            CRCOptions.Save();
            CRCClient.UpdateSettings();
            CRCGame.UpdateSettings();
            this.Close();
        }
コード例 #13
0
        private static void OnChannelMessage(object sender, IrcEventArgs e)
        {
            string fakeNick, faction;
            string message = GetMetadata(e.Data.Message, out fakeNick, out faction);

            // If some cheeky m8 just sends delimiters, ignore it
            if (message.Length > 0)
            {
                string nick;
                if (fakeNick == null)
                {
                    nick    = e.Data.Nick;
                    faction = crcNicks.ContainsKey(nick) ? crcNicks[nick] : "actor_stalker";
                }
                else if (CRCOptions.ReceiveDeath && (DateTime.Now - lastDeath).TotalSeconds > CRCOptions.DeathInterval)
                {
                    lastDeath = DateTime.Now;
                    nick      = e.Data.Nick; //fakeNick;
                }
                else
                {
                    return;
                }
                if (message.Contains(CRCOptions.Name))
                {
                    SystemSounds.Asterisk.Play();
                    CRCDisplay.OnHighlightMessage(nick, message);
                    CRCGame.OnHighlightMessage(nick, faction, message);
                }
                else
                {
                    CRCDisplay.OnChannelMessage(nick, message);
                    CRCGame.OnChannelMessage(nick, faction, message);
                }
            }
        }
コード例 #14
0
        private static void OnKick(object sender, KickEventArgs e)
        {
            string victim = e.Whom;

            if (victim == CRCOptions.Name)
            {
                Users.Clear();
                string message = CRCStrings.Localize("client_got_kicked") + e.KickReason;
                CRCDisplay.AddError(message);
                CRCGame.AddError(message);
                CRCDisplay.OnGotKicked();
            }
            else
            {
                crcNicks.Remove(e.Who);
                Users.Remove(victim);
                Users.Sort();
                string message = victim + CRCStrings.Localize("client_kicked") + e.KickReason;
                CRCDisplay.AddInformation(message);
                CRCGame.AddInformation(message);
            }
            CRCDisplay.UpdateUsers();
            CRCGame.UpdateUsers();
        }
コード例 #15
0
 public void AddInformation(string message)
 {
     CRCGame.AddInformation(message);
 }
コード例 #16
0
 private void timerGameCheck_Tick(object sender, EventArgs e)
 {
     CRCGame.GameCheck();
 }
コード例 #17
0
 public static void SendQuery(string nick, string message)
 {
     client.SendMessage(SendType.Message, nick, CRCOptions.GetFaction() + META_DELIM + message);
     CRCDisplay.OnQueryMessage(CRCOptions.Name, nick, message);
     CRCGame.OnQueryMessage(CRCOptions.Name, nick, CRCOptions.GetFaction(), message);
 }
コード例 #18
0
 public static void Send(string message)
 {
     client.SendMessage(SendType.Message, CRCOptions.ChannelProxy(), message);
     CRCDisplay.OnOwnChannelMessage(CRCOptions.Name, message);
     CRCGame.OnChannelMessage(CRCOptions.Name, CRCOptions.GetFaction(), message);
 }
コード例 #19
0
 private void timerGameUpdate_Tick(object sender, EventArgs e)
 {
     CRCGame.GameUpdate();
 }
コード例 #20
0
 public void AddError(string message)
 {
     CRCGame.AddError(message);
 }