Ejemplo n.º 1
0
        private MySelectableListItem addVisualAction(Action act)
        {
            RichTextBox cb = new RichTextBox(); // Callback should change it, but it won't change the already added MySelectableListItem
            TriggerDefinitionPartProperties def = new TriggerDefinitionPartProperties();

            def.g = cb;
            Trigger.regenerateTextboxForTriggerDefinitionParts(def, act.getDefinitionParts, (RichTextBox qcb) => { cb = qcb; });
            MySelectableListItem item = new MySelectableListItem(new Object[] { cb, act, def }, cb);

            lstAct.Add(item);
            return(item);
        }
Ejemplo n.º 2
0
        private MySelectableListItem InsertTriggerIntoTheVisualList(Trigger trig)
        {
            Brush brush = new SolidColorBrush(Colors.Red);
            TriggerDefinitionPartProperties def = new TriggerDefinitionPartProperties();
            FrameworkElement g = trig.getTrigerListItem(def);

            def.g = (RichTextBox)g;
            MySelectableListItem item = new MySelectableListItem(new object[] { g, trig, def }, g);

            lstTriggers.Add(item);
            return(item);
        }
Ejemplo n.º 3
0
        private void lstCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            grd.Children.Clear();
            MyComboItem sel = lstCombo.SelectedItem as MyComboItem;
            RichTextBox rc  = new RichTextBox();

            grd.Children.Add(rc);
            content = sel.getConstructable().construct();
            TriggerDefinitionPartProperties def = new TriggerDefinitionPartProperties(() => KeepDefault);

            def.HideCheckBox = true;
            def.g            = rc;
            Trigger.regenerateTextboxForTriggerDefinitionParts(def, content.getDefinitionParts, (RichTextBox rb) => { rc = rb; });
        }
Ejemplo n.º 4
0
        public WndModify(Trigger trig, StarcraftEPDTriggers.src.data.TriggerCollection colection, Action <Trigger> saveCallback)
        {
            InitializeComponent();
            setup();
            _originalTrigger = trig;
            _colection       = colection;
            _saveCallback    = saveCallback;
            myTrigga         = new Trigger();
            TriggerDefinitionPartProperties def = new TriggerDefinitionPartProperties();

            myTrigga.reparseFromString(_originalTrigger.ToSaveString(false), null, def);
            updateValuesFromTrigger();
            ShowDialog();
            setup();
        }
Ejemplo n.º 5
0
        private void lstAct_SelectionChanged(MySelectableListItem lastSelected, MySelectableListItem newSelected)
        {
            TabControl_SelectionChanged(null, null);
            bool isSel = newSelected != null;

            btnActCopy.IsEnabled     = isSel;
            btnActDel.IsEnabled      = isSel;
            btnActMoveDown.IsEnabled = isSel;
            btnActMoveUp.IsEnabled   = isSel;

            if (lstAct.isLastItemSelected())
            {
                btnActMoveDown.IsEnabled = false;
            }
            if (lstAct.isFirstItemSelected())
            {
                btnActMoveUp.IsEnabled = false;
            }

            if (lastSelected != newSelected)   // Ignore the crap of this shit
            {
                if (lastSelected != null)
                {
                    FrameworkElement ls = ((object[])lastSelected.CustomData)[0] as FrameworkElement;
                    TriggerDefinitionPartProperties props = ((object[])lastSelected.CustomData)[2] as TriggerDefinitionPartProperties;
                    props.FireSelectionChange(false);
                    if (ls is RichTextBox)
                    {
                        ((RichTextBox)ls).Background = Brushes.White;
                        ((RichTextBox)ls).Foreground = Brushes.Black;
                        ls.InvalidateVisual();
                    }
                }
                if (newSelected != null)
                {
                    FrameworkElement ls = ((object[])newSelected.CustomData)[0] as FrameworkElement;
                    TriggerDefinitionPartProperties props = ((object[])newSelected.CustomData)[2] as TriggerDefinitionPartProperties;
                    props.FireSelectionChange(true);
                    if (ls is RichTextBox)
                    {
                        ((RichTextBox)ls).Background = selected;
                        ((RichTextBox)ls).Foreground = Brushes.White;
                        ls.InvalidateVisual();
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            // First validate settings
            // At least 1 player is selected
            Affecteds.Clear();
            for (int i = 0; i < playersChecks.Length; i++)
            {
                if ((bool)playersChecks[i].IsChecked)
                {
                    Affecteds.Add(PlayerDef.AllPlayers[i]);
                }
            }
            if (Affecteds.Count == 0)
            {
                tabs.SelectedIndex = 0;
                MessageBox.Show("Trigger must affect at least 1 player.");
                return;
            }

            // At least 1 condition exists
            List <Condition> conds = getFromSelLst <Condition>(lstCond.GetAllItems());

            if (conds.Count == 0)
            {
                tabs.SelectedIndex = 1;
                MessageBox.Show("At least 1 condition must exist.");
                return;
            }
            if (conds.Count > 16)
            {
                tabs.SelectedIndex = 1;
                MessageBox.Show("There can only be at most 16 conditions.");
                return;
            }
            myTrigga.Conditions.Clear();
            foreach (Condition cond in conds)
            {
                myTrigga.Conditions.Add(cond);
            }


            // At least 1 action exists
            List <Action> actions = getFromSelLst <Action>(lstAct.GetAllItems());

            if (actions.Count == 0)
            {
                tabs.SelectedIndex = 2;
                MessageBox.Show("At least 1 action must exist.");
                return;
            }
            if (actions.Count > 64)
            {
                tabs.SelectedIndex = 1;
                MessageBox.Show("There can only be at most 64 actions.");
                return;
            }
            myTrigga.Actions.Clear();
            foreach (Action action in actions)
            {
                myTrigga.Actions.Add(action);
            }
            TriggerDefinitionPartProperties def = new TriggerDefinitionPartProperties();

            _originalTrigger.reparseFromString(myTrigga.ToSaveString(false), _colection, def);
            _saveCallback(_originalTrigger);
            Close();
        }