Exemplo n.º 1
0
        //Remove the binding target
        void output_ControlPointRemoved(BasicControlPoint cp, IControlPoint other)
        {
            if (other.Virtual == true)
            {
                return;
            }
            TriggersTemplateOutputActionBinder outputBinder = mOutputActionCPs[cp];
            TriggerBindInfo toremove = null;

            foreach (TriggerBindInfo b in outputBinder.TargetIDs)
            {
                if (b != null && other != null)
                {
                    if (b.LinkName == other.ToString())
                    {
                        toremove = b;
                    }
                }
                else
                {
                    CoreGlobals.getErrorManager().LogErrorToNetwork("(b.LinkName == other.ToString())");
                }
            }
            if (toremove != null)
            {
                outputBinder.TargetIDs.Remove(toremove);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add a new binding target
        /// </summary>
        /// <param name="cp">This(starting) control point</param>
        /// <param name="other">Target control point</param>
        void output_ControlPointConnected(BasicControlPoint cp, IControlPoint other)
        {
            if (other.Virtual == true)
            {
                return;
            }
            //set target value:
            TriggerControl t = other.TagObject as TriggerControl;

            TriggersTemplateOutputActionBinder outputbinder = mOutputActionCPs[cp];

            if (t != null)
            {
                string name = cp.ToString();
                if (mOutputActionCPs.ContainsKey(cp))
                {
                    TriggerBindInfo bindInfo = new TriggerBindInfo();
                    bindInfo.SetTarget(t.Trigger.ID, other.ToString());
                    outputbinder.TargetIDs.Add(bindInfo);

                    return;
                }
            }

            TemplateControl templateControl = other.TagObject as TemplateControl;

            if (templateControl != null)
            {
                string name = other.ToString();
                foreach (TriggersTemplateInputActionBinder inputBinder in templateControl.TriggerTemplateMapping.TriggerInputs)
                {
                    if (inputBinder.Name == name)
                    {
                        foreach (TriggerBindInfo b in inputBinder.TargetIDs)
                        {
                            if (b.ID == templateControl.TriggerTemplateMapping.ID && b.LinkName == other.ToString())
                            {
                                CoreGlobals.getErrorManager().OnSimpleWarning("can't bind. template is already bound to trigger.  this is a bug");
                                return;
                            }
                        }

                        TriggerBindInfo bindInfo = new TriggerBindInfo();
                        bindInfo.SetTarget(templateControl.TriggerTemplateMapping.ID, other.ToString());
                        outputbinder.TargetIDs.Add(bindInfo);

                        return;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// This connects the ui elements based off of the data that was loaded.
        /// Templates hold the connection data when a connection to a template is made in the ActionBinder classes
        /// Templates always load the connections to the right(output), and load connections to the left if trigger control is left of them
        /// </summary>
        public void LoadExistingConnections()
        {
            Dictionary <BasicControlPoint, TriggersTemplateInputActionBinder> .Enumerator it = mInputActionCPs.GetEnumerator();
            while (it.MoveNext())
            {
                TriggersTemplateInputActionBinder binder = it.Current.Value;
                BasicControlPoint thisCp = it.Current.Key;
                foreach (TriggerBindInfo targetinfo in binder.TargetIDs)
                {
                    if (targetinfo.HasTarget())
                    {
                        if (targetinfo.LinkName == "Effect.False" || targetinfo.LinkName == "Effect.True")
                        {
                            TriggerControl targetC = mTriggerHost.GetTriggerControl(targetinfo.ID);
                            if (targetC != null)
                            {
                                if (targetinfo.LinkName == "Effect.True")
                                {
                                    targetC.GetEffectTruePoint().GetTargets().Add(thisCp);
                                }
                                else
                                {
                                    targetC.GetEffectFalsePoint().GetTargets().Add(thisCp);
                                }
                            }
                        }
                    }
                }
            }

            Dictionary <BasicControlPoint, TriggersTemplateOutputActionBinder> .Enumerator it2 = mOutputActionCPs.GetEnumerator();
            while (it2.MoveNext())
            {
                TriggersTemplateOutputActionBinder binder = it2.Current.Value;
                BasicControlPoint thisCp = it2.Current.Key;

                List <TriggerBindInfo> toRemove = new List <TriggerBindInfo>();

                foreach (TriggerBindInfo targetinfo in binder.TargetIDs)
                {
                    if (targetinfo.HasTarget())
                    {
                        //bound to trigger
                        if (targetinfo.LinkName == "Activate" || targetinfo.LinkName == "Deactivate")
                        {
                            TriggerControl triggerTarget = mTriggerHost.GetTriggerControl(targetinfo.ID);
                            if (triggerTarget != null)
                            {
                                if (targetinfo.LinkName == "Activate")
                                {
                                    thisCp.GetTargets().Add(triggerTarget.GetActivationPoint());
                                }
                                else if (targetinfo.LinkName == "Deactivate")
                                {
                                    thisCp.GetTargets().Add(triggerTarget.GetDeactivationPoint());
                                }
                            }
                        }
                        else //it is a template
                        {
                            TemplateControl c = mTriggerHost.GetTemplatetControl(targetinfo.ID);
                            if (c != null)
                            {
                                BasicControlPoint cpTarget = c.GetInputControlPoint(targetinfo.LinkName);
                                thisCp.GetTargets().Add(cpTarget);
                            }
                            else
                            {
                                string groupName = this.ParentTriggerNamespace.GetGroupName(TriggerTemplateMapping.GroupID);
                                string errormsg  = "Error connecting template " + this.TriggerTemplateMapping.Name + "(" + this.TriggerTemplateMapping.ID + ")"
                                                   + "." + thisCp.Name
                                                   + "  to missing template input: " + targetinfo.LinkName + ", " + targetinfo.ID + "     in group: " + groupName
                                                   + "   Bad Link removed (most likely harmless residue from an old deleted template that this was connected to)";
                                toRemove.Add(targetinfo);
                                this.BackColor            = Color.Red;
                                this.TriggerNameText.Text = Path.GetFileNameWithoutExtension(TriggerTemplateMapping.Name) + "(" + this.TriggerTemplateMapping.ID + ")";

                                CoreGlobals.getErrorManager().OnSimpleWarning(errormsg);
                                CoreGlobals.ShowMessage(errormsg);
                                CoreGlobals.getErrorManager().LogErrorToNetwork(errormsg);
                            }
                        }
                    }
                }

                foreach (TriggerBindInfo badBind in toRemove)
                {
                    binder.TargetIDs.Remove(badBind);
                }
            }
        }