コード例 #1
0
 private static void SendReply(List <string> args, ICRCSendable output)
 {
     if (!CRCClient.SendReply(args[0]))
     {
         output.AddError("You can't reply if you haven't been sent any messages yet.");
     }
 }
コード例 #2
0
        private static void ChangeNick(List <string> args, ICRCSendable output)
        {
            string nick   = args[0].Replace(' ', '_');
            string result = CRCStrings.ValidateNick(nick);

            if (result != null)
            {
                output.AddError(result);
            }
            else
            {
                CRCClient.ChangeNick(nick);
            }
        }
コード例 #3
0
        private void ClientDisplay_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (WindowState == FormWindowState.Normal)
            {
                CRCOptions.DisplayLocation = Location;
                CRCOptions.DisplaySize     = Size;
            }
            else
            {
                CRCOptions.DisplayLocation = RestoreBounds.Location;
                CRCOptions.DisplaySize     = RestoreBounds.Size;
            }

            CRCClient.Stop();
        }
コード例 #4
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            string trimmed = textBoxInput.Text.Trim();

            if (trimmed.Length > 0)
            {
                if (trimmed[0] == '/')
                {
                    CRCCommands.ProcessCommand(trimmed, this);
                }
                else if (trimmed.Length > 0)
                {
                    CRCClient.Send(trimmed);
                }
                textBoxInput.Clear();
            }
        }
コード例 #5
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();
        }
コード例 #6
0
ファイル: CRCGame.cs プロジェクト: TKGP/Chernobyl-Relay-Chat
        public static void GameUpdate()
        {
            if (disable || processID == -1)
            {
                return;
            }

            // Wipe game output when first discovered
            if (!firstClear)
            {
                try
                {
                    File.WriteAllText(gamePath + CRCOptions.OutPath, "", encoding);
                    firstClear = true;
                }
                catch (IOException)
                {
                    return;
                }
                catch (Exception ex) when(ex is SecurityException || ex is UnauthorizedAccessException)
                {
                    Disable();
                    return;
                }
            }

            // Get messages from game
            try
            {
                string[] lines = File.ReadAllLines(gamePath + CRCOptions.OutPath, encoding);
                File.WriteAllText(gamePath + CRCOptions.OutPath, "", encoding);
                foreach (string line in lines)
                {
                    Match  typeMatch = outputRx.Match(line);
                    string type      = typeMatch.Groups[1].Value;
                    if (type == "Handshake")
                    {
                        if (Convert.ToInt16(typeMatch.Groups[2].Value) < SCRIPT_VERSION)
                        {
                            AddError(CRCStrings.Localize("game_script_version_error"));
                            CRCDisplay.AddError(CRCStrings.Localize("game_script_version_error"));
                        }
                        UpdateSettings();
                        UpdateUsers();
                    }
                    else if (type == "Message")
                    {
                        Match  messageMatch = messageRx.Match(typeMatch.Groups[2].Value);
                        string faction      = messageMatch.Groups[1].Value;
                        string message      = messageMatch.Groups[2].Value;
                        if (message[0] == '/')
                        {
                            CRCCommands.ProcessCommand(message, wrapper);
                        }
                        else
                        {
                            CRCOptions.GameFaction = CRCStrings.ValidateFaction(faction);
                            CRCClient.UpdateSettings();
                            if (CRCOptions.GameFaction == "actor_zombied")
                            {
                                CRCClient.Send(CRCZombie.Generate());
                            }
                            else
                            {
                                CRCClient.Send(message);
                            }
                        }
                    }
                    else if (type == "Death" && CRCOptions.SendDeath)
                    {
                        Match  deathMatch = deathRx.Match(typeMatch.Groups[2].Value);
                        string faction    = deathMatch.Groups[1].Value;
                        string level      = deathMatch.Groups[2].Value;
                        string xrClass    = deathMatch.Groups[3].Value;
                        string section    = deathMatch.Groups[4].Value;
                        CRCOptions.GameFaction = CRCStrings.ValidateFaction(faction);
                        CRCClient.UpdateSettings();
                        if (CRCOptions.GameFaction != "actor_zombied")
                        {
                            string message = CRCStrings.DeathMessage(CRCOptions.Name, level, xrClass, section);
                            CRCClient.SendDeath(message);
                        }
                    }
                }
            }
            catch (IOException) { }
            catch (Exception ex) when(ex is SecurityException || ex is UnauthorizedAccessException)
            {
                Disable();
                return;
            }

            // Send messages to game
            lock (sendQueue)
            {
                try
                {
                    File.AppendAllText(gamePath + CRCOptions.InPath, sendQueue.ToString(), encoding);
                    sendQueue.Clear();
                }
                catch (IOException) { }
                catch (Exception ex) when(ex is SecurityException || ex is UnauthorizedAccessException)
                {
                    Disable();
                    return;
                }
            }
        }
コード例 #7
0
ファイル: CRCGame.cs プロジェクト: TKGP/Chernobyl-Relay-Chat
 public CRCGame(ClientDisplay clientDisplay, CRCClient crcClient)
 {
     display = clientDisplay;
     client  = crcClient;
 }
コード例 #8
0
 private static void SendQuery(List <string> args, ICRCSendable output)
 {
     CRCClient.SendQuery(args[0], args[1]);
 }