Example #1
0
 public ChatRuleDisplayInfo(ChatRule rule)
 {
     Operator      = rule.Operator;
     Pattern       = rule.Value;
     CaseSensitive = rule.CaseSensitive;
     IgnoreColors  = rule.IgnoreColors;
     SearchTeam    = rule.SearchTeamMessages;
 }
 void Start()
 {
     InputFieldCache = GetComponent <InputField>();
     ChatRuleCache   = GameObject.Find("Chat Rules").GetComponent <ChatRule>();
     if (Utils.IsValid(ChatRuleCache) && Utils.IsValid(InputFieldCache))
     {
         InputFieldCache.onEndEdit.AddListener(ChatRuleCache.SendChatMessage);
     }
 }
Example #3
0
        private void OnAddChatRuleClicked()
        {
            var rule = new ChatRule();

            if (!ShowChatRuleEditDialog(rule))
            {
                return;
            }

            _app.Config.ChatRules.Add(rule);
            _chatRulesListView.Items.Add(new ChatRuleDisplayInfo(rule));
        }
Example #4
0
    void Start()
    {
        Dbg.LogCheckAssigned(BtnMissionStart, this);
        Dbg.LogCheckAssigned(BtnReturnToTitle, this);
        ConnectRuleCache = FindObjectOfType <ConnectRule>();
        ChatRuleCache    = FindObjectOfType <ChatRule>();

        if (Utils.IsValid(ConnectRuleCache))
        {
            if (Utils.IsValid(BtnMissionStart))
            {
                BtnMissionStart.onClick.AddListener(OnMissionStartBtnClicked);
            }

            if (Utils.IsValid(BtnReturnToTitle))
            {
                BtnReturnToTitle.onClick.AddListener(OnReturnToTitleBtnClicked);
            }
        }
    }
Example #5
0
 public ChatRuleDisplayInfo(ChatRule rule)
 {
     Operator = rule.Operator;
     Pattern = rule.Value;
     CaseSensitive = rule.CaseSensitive;
     IgnoreColors = rule.IgnoreColors;
 }
Example #6
0
        private bool ShowChatRuleEditDialog(ChatRule chatRule)
        {
            var ruleNamesDic = new List<Tuple<string, string>>();
            ruleNamesDic.Add(new Tuple<string, string>("Contains", "Contains"));
            ruleNamesDic.Add(new Tuple<string, string>("Starts With", "StartsWith"));
            ruleNamesDic.Add(new Tuple<string, string>("Ends With", "EndsWith"));

            var operatorComboBox = new ComboBox();
            operatorComboBox.Width = 150;
            foreach(var ruleName in ruleNamesDic)
            {
                operatorComboBox.Items.Add(ruleName.Item1);
            }
            operatorComboBox.SelectedIndex = ruleNamesDic.FindIndex(r => r.Item2.ToLower() == chatRule.Operator.ToLower());

            var valueEditBox = new TextBox();
            valueEditBox.Width = 200;
            valueEditBox.Text = chatRule.Value;

            var caseCheckBox = new CheckBox();
            caseCheckBox.VerticalAlignment = VerticalAlignment.Center;
            caseCheckBox.Content = " The operator must respect case sensitivity";
            caseCheckBox.IsChecked = chatRule.CaseSensitive;

            var colorsCheckBox = new CheckBox();
            colorsCheckBox.VerticalAlignment = VerticalAlignment.Center;
            colorsCheckBox.Content = " Ignore the Quake 3 color codes (e.g. ^1 for red)";
            colorsCheckBox.IsChecked = chatRule.IgnoreColors;

            var panelList = new List<Tuple<FrameworkElement, FrameworkElement>>();
            panelList.Add(App.CreateTuple("Operator", operatorComboBox));
            panelList.Add(App.CreateTuple("Pattern", valueEditBox));
            panelList.Add(App.CreateTuple("Case Sensitive?", caseCheckBox));
            panelList.Add(App.CreateTuple("Ignore Colors?", colorsCheckBox));
            var rulePanel = WpfHelper.CreateDualColumnPanel(panelList, 100, 5);
            rulePanel.HorizontalAlignment = HorizontalAlignment.Center;
            rulePanel.VerticalAlignment = VerticalAlignment.Center;

            var ruleGroupBox = new GroupBox();
            ruleGroupBox.HorizontalAlignment = HorizontalAlignment.Center;
            ruleGroupBox.VerticalAlignment = VerticalAlignment.Center;
            ruleGroupBox.Margin = new Thickness(5);
            ruleGroupBox.Header = "Rule";
            ruleGroupBox.Content = rulePanel;

            var okButton = new Button();
            okButton.Content = "OK";
            okButton.Width = 75;
            okButton.Height = 25;
            okButton.Margin = new Thickness(5);
            okButton.HorizontalAlignment = HorizontalAlignment.Right;

            var cancelButton = new Button();
            cancelButton.Content = "Cancel";
            cancelButton.Width = 75;
            cancelButton.Height = 25;
            cancelButton.Margin = new Thickness(5);
            cancelButton.HorizontalAlignment = HorizontalAlignment.Right;

            var rootPanel = new DockPanel();
            rootPanel.HorizontalAlignment = HorizontalAlignment.Center;
            rootPanel.VerticalAlignment = VerticalAlignment.Center;
            rootPanel.Children.Add(ruleGroupBox);
            rootPanel.Children.Add(cancelButton);
            rootPanel.Children.Add(okButton);

            DockPanel.SetDock(ruleGroupBox, Dock.Top);
            DockPanel.SetDock(cancelButton, Dock.Right);
            DockPanel.SetDock(okButton, Dock.Right);

            var window = new Window();
            okButton.Click += (obj, args) => { window.DialogResult = true; window.Close(); };
            cancelButton.Click += (obj, args) => { window.DialogResult = false; window.Close(); };

            var appWindow = _app.MainWindow;
            window.WindowStyle = WindowStyle.ToolWindow;
            window.AllowsTransparency = false;
            window.Background = new SolidColorBrush(System.Windows.SystemColors.ControlColor);
            window.ShowInTaskbar = false;
            window.Title = "Chat Rule Editor";
            window.Content = rootPanel;
            window.Width = 420;
            window.Height = 280;
            window.Left = appWindow.Left + (appWindow.Width - window.Width) / 2;
            window.Top = appWindow.Top + (appWindow.Height - window.Height) / 2;
            window.ShowDialog();

            var result = window.DialogResult ?? false;
            if(!result)
            {
                return false;
            }

            chatRule.CaseSensitive = caseCheckBox.IsChecked ?? false;
            chatRule.IgnoreColors = colorsCheckBox.IsChecked ?? false;
            chatRule.Operator = ruleNamesDic.Find(r => r.Item1 == operatorComboBox.Text).Item2; ;
            chatRule.Value = valueEditBox.Text;

            return true;
        }
Example #7
0
        private void OnAddChatRuleClicked()
        {
            var rule = new ChatRule();
            if(!ShowChatRuleEditDialog(rule))
            {
                return;
            }

            _app.Config.ChatRules.Add(rule);
            _chatRulesListView.Items.Add(new ChatRuleDisplayInfo(rule));
        }
Example #8
0
        private bool ShowChatRuleEditDialog(ChatRule chatRule)
        {
            var ruleNamesDic = new List <Tuple <string, string> >();

            ruleNamesDic.Add(new Tuple <string, string>("Contains", "Contains"));
            ruleNamesDic.Add(new Tuple <string, string>("Starts With", "StartsWith"));
            ruleNamesDic.Add(new Tuple <string, string>("Ends With", "EndsWith"));

            var operatorComboBox = new ComboBox();

            operatorComboBox.Width = 150;
            foreach (var ruleName in ruleNamesDic)
            {
                operatorComboBox.Items.Add(ruleName.Item1);
            }
            operatorComboBox.SelectedIndex = ruleNamesDic.FindIndex(r => r.Item2.ToLower() == chatRule.Operator.ToLower());

            var valueEditBox = new TextBox();

            valueEditBox.Width = 200;
            valueEditBox.Text  = chatRule.Value;

            var caseCheckBox = new CheckBox();

            caseCheckBox.VerticalAlignment = VerticalAlignment.Center;
            caseCheckBox.Content           = " The operator must respect case sensitivity";
            caseCheckBox.IsChecked         = chatRule.CaseSensitive;

            var colorsCheckBox = new CheckBox();

            colorsCheckBox.VerticalAlignment = VerticalAlignment.Center;
            colorsCheckBox.Content           = " Ignore the Quake 3 color codes (e.g. ^1 for red)";
            colorsCheckBox.IsChecked         = chatRule.IgnoreColors;

            var teamMessagesCheckBox = new CheckBox();

            teamMessagesCheckBox.VerticalAlignment = VerticalAlignment.Center;
            teamMessagesCheckBox.Content           = " Search team chat too?";
            teamMessagesCheckBox.IsChecked         = chatRule.SearchTeamMessages;

            var panelList = new List <Tuple <FrameworkElement, FrameworkElement> >();

            panelList.Add(App.CreateTuple("Operator", operatorComboBox));
            panelList.Add(App.CreateTuple("Pattern", valueEditBox));
            panelList.Add(App.CreateTuple("Case Sensitive?", caseCheckBox));
            panelList.Add(App.CreateTuple("Ignore Colors?", colorsCheckBox));
            panelList.Add(App.CreateTuple("Team Chat?", teamMessagesCheckBox));
            var rulePanel = WpfHelper.CreateDualColumnPanel(panelList, 100, 5);

            rulePanel.HorizontalAlignment = HorizontalAlignment.Center;
            rulePanel.VerticalAlignment   = VerticalAlignment.Center;

            var ruleGroupBox = new GroupBox();

            ruleGroupBox.HorizontalAlignment = HorizontalAlignment.Center;
            ruleGroupBox.VerticalAlignment   = VerticalAlignment.Center;
            ruleGroupBox.Margin  = new Thickness(5);
            ruleGroupBox.Header  = "Rule";
            ruleGroupBox.Content = rulePanel;

            var okButton = new Button();

            okButton.Content             = "OK";
            okButton.Width               = 75;
            okButton.Height              = 25;
            okButton.Margin              = new Thickness(5);
            okButton.HorizontalAlignment = HorizontalAlignment.Right;

            var cancelButton = new Button();

            cancelButton.Content             = "Cancel";
            cancelButton.Width               = 75;
            cancelButton.Height              = 25;
            cancelButton.Margin              = new Thickness(5);
            cancelButton.HorizontalAlignment = HorizontalAlignment.Right;

            var rootPanel = new DockPanel();

            rootPanel.HorizontalAlignment = HorizontalAlignment.Center;
            rootPanel.VerticalAlignment   = VerticalAlignment.Center;
            rootPanel.Children.Add(ruleGroupBox);
            rootPanel.Children.Add(cancelButton);
            rootPanel.Children.Add(okButton);

            DockPanel.SetDock(ruleGroupBox, Dock.Top);
            DockPanel.SetDock(cancelButton, Dock.Right);
            DockPanel.SetDock(okButton, Dock.Right);

            var window = new Window();

            okButton.Click     += (obj, args) => { window.DialogResult = true; window.Close(); };
            cancelButton.Click += (obj, args) => { window.DialogResult = false; window.Close(); };

            var appWindow = _app.MainWindow;

            window.Owner              = _app.MainWindow;
            window.WindowStyle        = WindowStyle.ToolWindow;
            window.AllowsTransparency = false;
            window.Background         = new SolidColorBrush(System.Windows.SystemColors.ControlColor);
            window.ShowInTaskbar      = false;
            window.Title              = "Chat Rule Editor";
            window.Content            = rootPanel;
            window.Width              = 420;
            window.Height             = 280;
            window.Left = appWindow.Left + (appWindow.Width - window.Width) / 2;
            window.Top  = appWindow.Top + (appWindow.Height - window.Height) / 2;
            window.ShowDialog();

            var result = window.DialogResult ?? false;

            if (!result)
            {
                return(false);
            }

            chatRule.CaseSensitive      = caseCheckBox.IsChecked ?? false;
            chatRule.IgnoreColors       = colorsCheckBox.IsChecked ?? false;
            chatRule.SearchTeamMessages = teamMessagesCheckBox.IsChecked ?? false;
            chatRule.Operator           = ruleNamesDic.Find(r => r.Item1 == operatorComboBox.Text).Item2;;
            chatRule.Value = valueEditBox.Text;

            return(true);
        }