Exemplo n.º 1
0
        void f_FunctionNameRightClick(object sender, EventArgs e)
        {
            mOptionsMenu = new ContextMenu();
            FunctorEditor fe   = sender as FunctorEditor;
            TriggerEffect comp = fe.Tag as TriggerEffect;

            if (comp == null)
            {
                return;
            }

            MenuItem commentOutItem = new MenuItem("Comment Out");

            commentOutItem.Checked = comp.CommentOut;
            commentOutItem.Click  += new EventHandler(commentOutItem_Click);
            commentOutItem.Tag     = fe;
            mOptionsMenu.MenuItems.Add(commentOutItem);


            if (comp.NeedsUpgrade == true)
            {
                MenuItem upgradeItem = new MenuItem("+Upgrade Version");
                upgradeItem.Click += new EventHandler(upgradeItem_Click);
                upgradeItem.Tag    = fe;
                mOptionsMenu.MenuItems.Add(upgradeItem);
            }

            mOptionsMenu.Show(fe, new Point(0, 0));
        }
Exemplo n.º 2
0
        override public void HandleDrop(DragEventArgs e, SuperListDragButton otherButton, SuperListDragButton thisButton)
        {
            FunctorEditor ctrlMove   = otherButton.Tag as FunctorEditor;
            FunctorEditor ctrlTarget = thisButton.Tag as FunctorEditor;

            if (e.Effect == DragDropEffects.Move)
            {
                if (ctrlMove.LogicalHost == ctrlTarget.LogicalHost && ctrlMove.Parent == ctrlTarget.Parent)
                {
                    this.OnReOrderRequest(otherButton, thisButton);
                }
                else if (ctrlMove.LogicalHost.GetType() == ctrlTarget.LogicalHost.GetType())
                {
                    SuperList senderParent = otherButton.GetParentList();
                    senderParent.OnTransferRequest(this, otherButton);
                    //return DragDropEffects.Move;
                }
                else
                {
                    MessageBox.Show("asdf");
                }
            }
            else if (e.Effect == DragDropEffects.Copy)
            {
                if (ctrlMove.LogicalHost.GetType() == ctrlTarget.LogicalHost.GetType())
                {
                    SuperList senderParent = otherButton.GetParentList();
                    senderParent.OnCopyRequest(this, otherButton);
                    //return DragDropEffects.Move;
                }
            }
        }
Exemplo n.º 3
0
        protected string UpdateHelpText(FunctorEditor f, TriggerComponentDefinition def)
        {
            string newHelpText;

            try
            {
                //List<object> paramsString = new List<object>();
                //paramsString.Add("REPORT_THIS_ERROR_PLZ!");  //don't use index 0
                //foreach (Control c in f.GetComponents())
                //{
                //   TriggerParameterControl param = c as TriggerParameterControl;
                //   if (param != null)
                //   {
                //      paramsString.Add(param.TextValue);
                //   }
                //}
                List <object>            paramsString = new List <object>();
                Dictionary <int, string> paramNames   = new Dictionary <int, string>();

                foreach (Control c in f.GetComponents())
                {
                    TriggerParameterControl param = c as TriggerParameterControl;
                    if (param != null)
                    {
                        paramNames[param.GetVariable().SigID] = param.TextValue;
                    }
                }

                for (int i = 0; i < TriggerSystemDefinitions.cMaxParameters; i++)
                {
                    if (paramNames.ContainsKey(i) == false)
                    {
                        paramsString.Add("##ERRORPARAM=" + i.ToString());
                    }
                    else
                    {
                        paramsString.Add(paramNames[i]);
                    }
                }



                newHelpText = string.Format(def.HelpText, paramsString.ToArray());
            }
            catch (System.Exception ex)
            {
                newHelpText = "Please Report Help text error";
                ex.ToString();
            }
            return(newHelpText);
        }
Exemplo n.º 4
0
        void upgradeItem_Click(object sender, EventArgs e)
        {
            MenuItem         mi   = sender as MenuItem;
            FunctorEditor    fe   = mi.Tag as FunctorEditor;
            TriggerCondition comp = fe.Tag as TriggerCondition;

            if (comp == null)
            {
                return;
            }

            comp.CommentOut = true;
            //UpdateComponentVisuals(comp, fe);

            TriggerCondition condition;
            Dictionary <int, TriggerValue> values;

            TriggerSystemMain.mTriggerDefinitions.GetTriggerCondition(comp.Type, out condition, out values);
            int newID;

            mParentTriggerNamespace.InsertCondition(this.Trigger.ID, condition, values, out newID, comp);

            //copy over old values
            Dictionary <int, int> oldIDsBySigID = new Dictionary <int, int>();

            for (int i = 0; i < comp.Parameter.Count; i++)
            {
                oldIDsBySigID[comp.Parameter[i].SigID] = comp.Parameter[i].ID;
            }
            List <TriggerVariable> oldParams = comp.Parameter;

            for (int i = 0; i < condition.Parameter.Count; i++)
            {
                int oldVarID;
                if (oldIDsBySigID.TryGetValue(condition.Parameter[i].SigID, out oldVarID))
                {
                    condition.Parameter[i].ID = oldVarID;

                    values[oldVarID] = mParentTriggerNamespace.GetValues()[oldVarID];
                }
            }


            condition.Invert       = comp.Invert;
            condition.JustUpgraded = true;
            //Control c = BuildUIFromCondition(condition, values);
            //this.AddRow(c);

            ReloadUI();
        }
Exemplo n.º 5
0
        void commentOutItem_Click(object sender, EventArgs e)
        {
            MenuItem         mi   = sender as MenuItem;
            FunctorEditor    fe   = mi.Tag as FunctorEditor;
            TriggerCondition comp = fe.Tag as TriggerCondition;

            if (comp == null)
            {
                return;
            }

            comp.CommentOut = !comp.CommentOut;
            UpdateComponentVisuals(comp, fe);
        }
Exemplo n.º 6
0
 void UpdateComponentVisuals(TriggerEffect effect, FunctorEditor fe)
 {
     if (effect.CommentOut == true)
     {
         if (mLastBackColor != Color.DarkGray)
         {
             mLastBackColor = fe.BackColor;
         }
         fe.BackColor = Color.DarkGray;
     }
     else if (mLastBackColor != Color.Empty)
     {
         fe.BackColor = Color.Empty;// mLastBackColor;
     }
 }
Exemplo n.º 7
0
        override public DragDropEffects ValidateDragTarget(Control toMove, Control target, DragEventArgs e)
        {
            FunctorEditor ctrlMove   = toMove.Tag as FunctorEditor;
            FunctorEditor ctrlTarget = target.Tag as FunctorEditor;

            SuperList targetList = target as SuperList;

            //to empty list
            if (targetList != null)
            {
                SuperListDragButton button = toMove as SuperListDragButton;
                if (targetList.GetType() == button.GetParentList().GetType())
                {
                    if ((e.KeyState & 8) == 8 && (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
                    {
                        return(DragDropEffects.Copy);
                    }
                    else
                    {
                        return(DragDropEffects.Move);
                    }
                }
            }
            if (ctrlMove == null || ctrlTarget == null)
            {
                return(DragDropEffects.None);
            }

            if ((e.KeyState & 8) == 8 && (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
            {
                return(DragDropEffects.Copy);
            }
            else if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move)
            {
                if (ctrlMove.LogicalHost == ctrlTarget.LogicalHost)
                {
                    return(DragDropEffects.Move);
                }
                else if (ctrlMove.LogicalHost.GetType() == ctrlTarget.LogicalHost.GetType())
                {
                    return(DragDropEffects.Move);
                }
            }

            return(DragDropEffects.None);
        }
Exemplo n.º 8
0
        void UpdateComponentVisuals(TriggerCondition condition, FunctorEditor fe)
        {
            fe.FunctionName = ((condition.Invert == true) ? "! " : "") + condition.Type;

            if (condition.CommentOut == true)
            {
                if (mLastBackColor != Color.DarkGray)
                {
                    mLastBackColor = fe.BackColor;
                }
                fe.BackColor = Color.DarkGray;
            }
            else if (mLastBackColor != Color.Empty)
            {
                fe.BackColor = Color.Empty;//mLastBackColor;
            }
        }
Exemplo n.º 9
0
        override protected void OnReordered()
        {
            List <TriggerEffect> effects = new List <TriggerEffect>();

            foreach (Control c in mControls)
            {
                FunctorEditor f = c as FunctorEditor;
                if (f != null)
                {
                    TriggerEffect effect = f.Tag as TriggerEffect;
                    if (effect != null)
                    {
                        effects.Add(effect);
                    }
                }
            }
            ParentTriggerNamespace.ReOrderEffects(Trigger, effects, EffectsOnFalse);
        }
Exemplo n.º 10
0
        //...ugh, this will be a tree in the future...
        override protected void OnReordered()
        {
            List <TriggerCondition> conditions = new List <TriggerCondition>();

            foreach (Control c in mControls)
            {
                FunctorEditor f = c as FunctorEditor;
                if (f != null)
                {
                    TriggerCondition cond = f.Tag as TriggerCondition;
                    if (cond != null)
                    {
                        conditions.Add(cond);
                    }
                }
            }
            ParentTriggerNamespace.ReOrderConditions(Trigger, conditions);
        }
Exemplo n.º 11
0
        void f_HotSelect(object sender, EventArgs e)
        {
            //if (mComponentHelp != null)
            //{
            //   if (mComponentHelp.Active)
            //   {
            //      mComponentHelp.Active = false;
            //      mComponentHelp.Dispose();//.Hide(this.Parent.Parent);
            //   }
            //   mComponentHelp = new ToolTip();
            //}

            FunctorEditor f = sender as FunctorEditor;

            ToolTip t = mToolTipGroup.GetToolTip(sender.GetHashCode()); //mComponentHelp;

            t.IsBalloon = true;
            Point p = f.PointToScreen(new Point(0, 0));

            p = this.PointToClient(p);
            TriggerComponent           comp = f.Tag as TriggerComponent;
            TriggerComponentDefinition def;

            if (comp == null)
            {
                return;
            }
            if (TriggerSystemMain.mTriggerDefinitions.TryGetDefinition(comp.DBID, comp.Version, out def) == false)
            {
                return;
            }

            string message = UpdateHelpText(f, def);

            if (message == "")
            {
                message = f.FunctionName;
            }
            t.Show(message, f, 50, -40, 5000);

            //t.Show(message, f, f.Width, -45, 5000);
            //t.Show(message, this, 140, p.Y - 2, 3000);
        }
Exemplo n.º 12
0
        public override void OnDelete(SuperListDragButton button)
        {
            bool          deleteWorked = false;
            FunctorEditor f            = button.Tag as FunctorEditor;

            if (f != null)
            {
                TriggerCondition cond = f.Tag as TriggerCondition;
                if (f != null)
                {
                    if (ParentTriggerNamespace.DeleteCondition(Trigger, cond, true))
                    {
                        base.OnDelete(button);
                        deleteWorked = true;
                    }
                }
            }
            if (deleteWorked == false)
            {
                CoreGlobals.getErrorManager().OnSimpleWarning("Error deleting condition.");
            }
        }
Exemplo n.º 13
0
        public override void OnDelete(SuperListDragButton button)
        {
            bool          deleteWorked = false;
            FunctorEditor f            = button.Tag as FunctorEditor;

            if (f != null)
            {
                TriggerEffect effect = f.Tag as TriggerEffect;
                if (f != null)
                {
                    if (ParentTriggerNamespace.DeleteEffect(Trigger, effect, EffectsOnFalse, true))
                    {
                        base.OnDelete(button);
                        deleteWorked = true;
                    }
                }
            }
            if (deleteWorked == false)
            {
                CoreGlobals.getErrorManager().OnSimpleWarning("Error deleting effect.");
            }
        }
Exemplo n.º 14
0
        public override void OnCopyRequest(SuperList otherlist, SuperListDragButton toMove)
        {
            //base.OnCopyRequest(otherlist, toMove);
            Control       c = toMove.Tag as Control;
            FunctorEditor f = c as FunctorEditor;

            if (f == null)
            {
                return;
            }
            TriggerCondition comp = f.Tag as TriggerCondition;

            if (comp == null)
            {
                return;
            }
            //comp.CopyTo

            TriggerControl trigCont = otherlist.Parent.Parent as TriggerControl;

            TriggerClipboard temp = new TriggerClipboard();

            //temp.CopyValues(this.mParentTriggerNamespace.GetValueList());
            temp.mValues = this.ParentTriggerNamespace.GetValues();

            int newID;
            TriggerCondition e = temp.GetCondition(comp, this.mParentTriggerNamespace);

            ConditionsList ef = otherlist as ConditionsList;

            //mParentTriggerNamespace.InsertCondition(trigCont.Trigger.ID, e, temp.mValues, out newID);
            mParentTriggerNamespace.InsertCondition(trigCont.Trigger.ID, e, this.ParentTriggerNamespace.GetValues(), out newID);


            ef.AddExistingConditionToUI(e, this.mParentTriggerNamespace.GetValues());

            mParentTriggerNamespace.ProcessVarMapping();
        }
Exemplo n.º 15
0
        void f_FunctionNameClicked(object sender, EventArgs e)
        {
            FunctorEditor fe = sender as FunctorEditor;

            if (fe == null)
            {
                return;
            }
            TriggerComponent comp = fe.Tag as TriggerComponent;

            if (comp == null)
            {
                return;
            }

            TriggerComponentWorksheet worksheet = new TriggerComponentWorksheet();

            if (worksheet.Setup(mParentTriggerNamespace, comp))
            {
                PopupEditor p = new PopupEditor();
                p.ShowPopup(this, worksheet);
            }
        }
Exemplo n.º 16
0
        void upgradeItem_Click(object sender, EventArgs e)
        {
            MenuItem      mi   = sender as MenuItem;
            FunctorEditor fe   = mi.Tag as FunctorEditor;
            TriggerEffect comp = fe.Tag as TriggerEffect;

            if (comp == null)
            {
                return;
            }

            comp.CommentOut = true;
            //UpdateComponentVisuals(comp, fe);

            TriggerEffect effect;
            Dictionary <int, TriggerValue> values;

            TriggerSystemMain.mTriggerDefinitions.GetTriggerEffect(comp.Type, out effect, out values);
            int newID;

            mParentTriggerNamespace.InsertEffect(this.Trigger.ID, effect, values, this.EffectsOnFalse, out newID, comp);

            //copy over old values
            Dictionary <int, int> oldIDsBySigID = new Dictionary <int, int>();

            for (int i = 0; i < comp.Parameter.Count; i++)
            {
                oldIDsBySigID[comp.Parameter[i].SigID] = comp.Parameter[i].ID;
            }
            List <TriggerVariable> oldParams = comp.Parameter;

            for (int i = 0; i < effect.Parameter.Count; i++)
            {
                int oldVarID;
                if (oldIDsBySigID.TryGetValue(effect.Parameter[i].SigID, out oldVarID))
                {
                    effect.Parameter[i].ID = oldVarID;

                    values[oldVarID] = mParentTriggerNamespace.GetValues()[oldVarID];
                }
            }

            // Halwes - 12/10/2007 - This is a specific update for ModifyProtoData trigger effect revision 3 or older.
            if ((effect.Type == "ModifyProtoData") && (comp.Version <= 3))
            {
                foreach (TriggerVariable var in effect.Parameter)
                {
                    if (var.GetName() == "DataType")
                    {
                        if (values[var.GetID()].Value == "0")
                        {
                            values[var.GetID()].Value = "Enable";
                        }
                        else if (values[var.GetID()].Value == "1")
                        {
                            values[var.GetID()].Value = "Hitpoints";
                        }
                        else if (values[var.GetID()].Value == "2")
                        {
                            values[var.GetID()].Value = "Shieldpoints";
                        }
                        else if (values[var.GetID()].Value == "3")
                        {
                            values[var.GetID()].Value = "AmmoMax";
                        }
                        else if (values[var.GetID()].Value == "4")
                        {
                            values[var.GetID()].Value = "LOS";
                        }
                        else if (values[var.GetID()].Value == "5")
                        {
                            values[var.GetID()].Value = "MaximumVelocity";
                        }
                        else if (values[var.GetID()].Value == "6")
                        {
                            values[var.GetID()].Value = "MaximumRange";
                        }
                        else if (values[var.GetID()].Value == "7")
                        {
                            values[var.GetID()].Value = "ResearchPoints";
                        }
                        else if (values[var.GetID()].Value == "8")
                        {
                            values[var.GetID()].Value = "ResourceTrickleRate";
                        }
                        else if (values[var.GetID()].Value == "9")
                        {
                            values[var.GetID()].Value = "MaximumResourceTrickleRate";
                        }
                        else if (values[var.GetID()].Value == "10")
                        {
                            values[var.GetID()].Value = "RateAmount";
                        }
                        else if (values[var.GetID()].Value == "11")
                        {
                            values[var.GetID()].Value = "RateMultiplier";
                        }
                        else if (values[var.GetID()].Value == "12")
                        {
                            values[var.GetID()].Value = "Resource";
                        }
                        else if (values[var.GetID()].Value == "13")
                        {
                            values[var.GetID()].Value = "Projectile";
                        }
                        else if (values[var.GetID()].Value == "14")
                        {
                            values[var.GetID()].Value = "Damage";
                        }
                        else if (values[var.GetID()].Value == "15")
                        {
                            values[var.GetID()].Value = "AttackRate";
                        }
                        else if (values[var.GetID()].Value == "16")
                        {
                            values[var.GetID()].Value = "MinRange";
                        }
                        else if (values[var.GetID()].Value == "17")
                        {
                            values[var.GetID()].Value = "AOERadius";
                        }
                        else if (values[var.GetID()].Value == "18")
                        {
                            values[var.GetID()].Value = "AOEPrimaryTargetFactor";
                        }
                        else if (values[var.GetID()].Value == "19")
                        {
                            values[var.GetID()].Value = "AOEDistanceFactor";
                        }
                        else if (values[var.GetID()].Value == "20")
                        {
                            values[var.GetID()].Value = "AOEDamageFactor";
                        }
                        else if (values[var.GetID()].Value == "21")
                        {
                            values[var.GetID()].Value = "Accuracy";
                        }
                        else if (values[var.GetID()].Value == "22")
                        {
                            values[var.GetID()].Value = "MovingAccuracy";
                        }
                        else if (values[var.GetID()].Value == "23")
                        {
                            values[var.GetID()].Value = "MaxDeviation";
                        }
                        else if (values[var.GetID()].Value == "24")
                        {
                            values[var.GetID()].Value = "MovingMaxDeviation";
                        }
                        else if (values[var.GetID()].Value == "25")
                        {
                            values[var.GetID()].Value = "DataAccuracyDistanceFactor";
                        }
                        else if (values[var.GetID()].Value == "26")
                        {
                            values[var.GetID()].Value = "AccuracyDeviationFactor";
                        }
                        else if (values[var.GetID()].Value == "27")
                        {
                            values[var.GetID()].Value = "MaxVelocityLead";
                        }
                        else if (values[var.GetID()].Value == "28")
                        {
                            values[var.GetID()].Value = "WorkRate";
                        }
                        else if (values[var.GetID()].Value == "29")
                        {
                            values[var.GetID()].Value = "BuildPoints";
                        }
                        else if (values[var.GetID()].Value == "30")
                        {
                            values[var.GetID()].Value = "Cost";
                        }
                        else if (values[var.GetID()].Value == "31")
                        {
                            values[var.GetID()].Value = "AutoCloak";
                        }
                        else if (values[var.GetID()].Value == "32")
                        {
                            values[var.GetID()].Value = "MoveWhileCloaked";
                        }
                        else if (values[var.GetID()].Value == "33")
                        {
                            values[var.GetID()].Value = "ActionEnable";
                        }
                        else if (values[var.GetID()].Value == "34")
                        {
                            values[var.GetID()].Value = "CommandEnable";
                        }
                        else if (values[var.GetID()].Value == "35")
                        {
                            values[var.GetID()].Value = "BountyResource";
                        }
                        else if (values[var.GetID()].Value == "36")
                        {
                            values[var.GetID()].Value = "TributeCost";
                        }
                        else if (values[var.GetID()].Value == "37")
                        {
                            values[var.GetID()].Value = "ShieldRegenRate";
                        }
                        else if (values[var.GetID()].Value == "38")
                        {
                            values[var.GetID()].Value = "ShieldRegenDelay";
                        }
                        else if (values[var.GetID()].Value == "39")
                        {
                            values[var.GetID()].Value = "DamageModifier";
                        }
                        else if (values[var.GetID()].Value == "40")
                        {
                            values[var.GetID()].Value = "PopCap";
                        }
                        else if (values[var.GetID()].Value == "41")
                        {
                            values[var.GetID()].Value = "PopMax";
                        }
                        else if (values[var.GetID()].Value == "42")
                        {
                            values[var.GetID()].Value = "UnitTrainLimit";
                        }
                        else if (values[var.GetID()].Value == "43")
                        {
                            values[var.GetID()].Value = "SquadTrainLimit";
                        }
                        else if (values[var.GetID()].Value == "44")
                        {
                            values[var.GetID()].Value = "SquadTrainLimit";
                        }
                        else if (values[var.GetID()].Value == "45")
                        {
                            values[var.GetID()].Value = "RepairCost";
                        }
                        else if (values[var.GetID()].Value == "46")
                        {
                            values[var.GetID()].Value = "RepairTime";
                        }
                        else if (values[var.GetID()].Value == "47")
                        {
                            values[var.GetID()].Value = "PowerRechargeTime";
                        }
                        else if (values[var.GetID()].Value == "48")
                        {
                            values[var.GetID()].Value = "PowerUseLimit";
                        }
                    }
                    else if (var.GetName() == "AmountRelation")
                    {
                        if (values[var.GetID()].Value == "0")
                        {
                            values[var.GetID()].Value = "Absolute";
                        }
                        else if (values[var.GetID()].Value == "1")
                        {
                            values[var.GetID()].Value = "BasePercent";
                        }
                        else if (values[var.GetID()].Value == "2")
                        {
                            values[var.GetID()].Value = "Percent";
                        }
                        else if (values[var.GetID()].Value == "3")
                        {
                            values[var.GetID()].Value = "Assign";
                        }
                        else if (values[var.GetID()].Value == "4")
                        {
                            values[var.GetID()].Value = "BasePercentAssign";
                        }
                    }
                }
            }

            effect.JustUpgraded = true;
            //Control c = BuildUIFromEffect(effect, values);
            //this.AddRow(c);

            ReloadUI();
        }
Exemplo n.º 17
0
        //
        public Control BuildUIFromCondition(TriggerCondition condition, Dictionary <int, TriggerValue> values)
        {
            FunctorEditor f = new FunctorEditor();

            f.LayoutStyle = FunctorEditor.eLayoutStyle.VerticleList;

            f.Dock = DockStyle.Fill;

            f.Tag = condition;

            //f.FunctionName = condition.Type;
            UpdateComponentVisuals(condition, f);

            f.LogicalHost = this;

            f.FunctionNameClicked    += new EventHandler(f_FunctionNameClicked);
            f.FunctionNameRightClick += new EventHandler(f_FunctionNameRightClick);
            f.FunctionNameHover      += new EventHandler(f_HotSelect);

            List <Control> inputList  = new List <Control>();
            List <Control> outputList = new List <Control>();
            bool           bErrors    = false;

            bool bWatchForChange = TriggerSystemMain.mTriggerDefinitions.IsDynamicComponent(condition.Type);

            foreach (TriggerVariable v in condition.Parameter)
            {
                try
                {
                    if (v is TriggersInputVariable)
                    {
                        inputList.Add(BuildUIFromConditionVariable(condition, v, values[v.ID], bWatchForChange));
                    }
                    else if (v is TriggersOutputVariable)
                    {
                        outputList.Add(BuildUIFromConditionVariable(condition, v, values[v.ID], bWatchForChange));
                    }
                }
                catch (System.Exception ex)
                {
                    bErrors = true;
                    CoreGlobals.getErrorManager().SendToErrorWarningViewer("Missing value: " + v.ID);
                }
            }

            f.SetupParameters(inputList, outputList);


            //Debug info
            if (condition.HasErrors == true || bErrors)
            {
                f.SetErrorText();
            }
            else if (condition.HasWarnings == true)
            {
                f.SetWarningText();
            }
            else if (condition.JustUpgraded == true)
            {
                f.SetUpdatedText();
            }

            UpdateComponentVisuals(condition, f);

            return(f);
        }