void mTriggerOutControlPoint_ControlPointRemoved(BasicControlPoint cp, IControlPoint other) { TriggerControl otherctrl = other.TagObject as TriggerControl; if (otherctrl != null) { bool onfalse = (cp.GetName() == "Effect.False") ? true : false; TriggerEffect toremove = null; if (onfalse == false) { foreach (TriggerEffect effect in Trigger.TriggerEffects.Effects) { if ((effect.Type == TriggerSystemMain.mTriggerDefinitions.GetDeactivateEffectName()) || (effect.Type == TriggerSystemMain.mTriggerDefinitions.GetActivateEffectName())) { TriggerValue val = ParentTriggerNamespace.GetValues()[effect.Parameter[0].ID]; if (val.Value == otherctrl.Trigger.ID.ToString()) { toremove = effect; } } } } if (onfalse == true) { foreach (TriggerEffect effect in Trigger.TriggerEffectsFalse.Effects) { if ((effect.Type == TriggerSystemMain.mTriggerDefinitions.GetDeactivateEffectName()) || (effect.Type == TriggerSystemMain.mTriggerDefinitions.GetActivateEffectName())) { TriggerValue val = ParentTriggerNamespace.GetValues()[effect.Parameter[0].ID]; if (val.Value == otherctrl.Trigger.ID.ToString()) { toremove = effect; } } } } if (toremove != null) { ParentTriggerNamespace.DeleteEffect(Trigger, toremove, onfalse); } } TemplateControl templateControl = other.TagObject as TemplateControl; if (templateControl != null) { string name = other.ToString(); BasicControlPoint othercp = other as BasicControlPoint; TriggersTemplateInputActionBinder targetBinder = templateControl.mInputActionCPs[othercp]; TriggerBindInfo toremove = null; string linkName = cp.Name; int linkID = this.Trigger.ID; foreach (TriggerBindInfo b in targetBinder.TargetIDs) { if ((b.LinkName == linkName) && (b.ID == linkID)) { toremove = b; } } if (toremove != null) { targetBinder.TargetIDs.Remove(toremove); } else { CoreGlobals.getErrorManager().LogErrorToNetwork("mTriggerOutControlPoint_ControlPointRemoved: error deleting template link"); } } }
public void LoadExistingConnections() { List <TriggerEffect> effectList = mThisTrigger.TriggerEffects.Effects; List <TriggerEffect> hitlist = new List <TriggerEffect>(); foreach (TriggerEffect e in effectList) { if (e.Type == TriggerSystemMain.mTriggerDefinitions.GetActivateEffectName()) { //Hide it... and load it as a line //mTriggerOutControlPoint. int targetTrigger = System.Convert.ToInt32(ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value); TriggerControl targetC = mTriggerHost.GetTriggerControl(targetTrigger); //mEffectTrueControlPoint.GetTargets().Add(targetC.GetActivationPoint()); if (targetC == null) { CoreGlobals.getErrorManager().OnSimpleWarning("Error Remapping link to trigger " + targetTrigger.ToString()); hitlist.Add(e); } else { mEffectTrueControlPoint.GetTargets().Add(targetC.GetActivationPoint()); } continue; } if (e.Type == TriggerSystemMain.mTriggerDefinitions.GetDeactivateEffectName()) { int targetTrigger = System.Convert.ToInt32(ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value); TriggerControl targetC = mTriggerHost.GetTriggerControl(targetTrigger); //mEffectTrueControlPoint.GetTargets().Add(targetC.GetDeactivationPoint()); if (targetC == null) { CoreGlobals.getErrorManager().OnSimpleWarning("Error Remapping link to trigger " + targetTrigger.ToString()); hitlist.Add(e); } else { mEffectTrueControlPoint.GetTargets().Add(targetC.GetDeactivationPoint()); } continue; } } foreach (TriggerEffect e in hitlist) { effectList.Remove(e); } hitlist.Clear(); List <TriggerEffect> effectsOnFalse = mThisTrigger.TriggerEffectsFalse.Effects; foreach (TriggerEffect e in effectsOnFalse) { if (e.Type == TriggerSystemMain.mTriggerDefinitions.GetActivateEffectName()) { //Hide it... and load it as a line //mTriggerOutControlPoint. int targetTrigger = System.Convert.ToInt32(ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value); TriggerControl targetC = mTriggerHost.GetTriggerControl(targetTrigger); if (targetC == null) { CoreGlobals.getErrorManager().OnSimpleWarning("Error Remapping link to trigger " + targetTrigger.ToString()); hitlist.Add(e); } else { mEffectFalseControlPoint.GetTargets().Add(targetC.GetActivationPoint()); } continue; } if (e.Type == TriggerSystemMain.mTriggerDefinitions.GetDeactivateEffectName()) { int targetTrigger = System.Convert.ToInt32(ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value); TriggerControl targetC = mTriggerHost.GetTriggerControl(targetTrigger); //mEffectFalseControlPoint.GetTargets().Add(targetC.GetDeactivationPoint()); if (targetC == null) { CoreGlobals.getErrorManager().OnSimpleWarning("Error Remapping link to trigger " + targetTrigger.ToString()); hitlist.Add(e); } else { mEffectFalseControlPoint.GetTargets().Add(targetC.GetDeactivationPoint()); } continue; } } foreach (TriggerEffect e in hitlist) { effectsOnFalse.Remove(e); } }
void mTriggerOutControlPoint_ControlPointConnected(BasicControlPoint cp, IControlPoint other) { //set target value: TriggerControl t = other.TagObject as TriggerControl; if (t != null) { string effectName = ""; if (other.GetName() == "Activate") { effectName = TriggerSystemMain.mTriggerDefinitions.GetActivateEffectName(); } if (other.GetName() == "Deactivate") { effectName = TriggerSystemMain.mTriggerDefinitions.GetDeactivateEffectName(); } TriggerEffect effect; Dictionary <int, TriggerValue> values; TriggerSystemMain.mTriggerDefinitions.GetTriggerEffect(effectName, out effect, out values); Dictionary <int, TriggerValue> .Enumerator it = values.GetEnumerator(); while (it.MoveNext()) { it.Current.Value.Value = t.Trigger.ID.ToString(); break; } int newID; bool onfalse = (cp.GetName() == "Effect.False")?true:false; ParentTriggerNamespace.InsertEffect(Trigger.ID, effect, values, onfalse, out newID); return;//Finished } //else.. template object TemplateControl templateControl = other.TagObject as TemplateControl; if (templateControl != null) { string name = other.ToString(); foreach (TriggersTemplateInputActionBinder binder in templateControl.TriggerTemplateMapping.TriggerInputs) { if (binder.Name == name) { foreach (TriggerBindInfo b in binder.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(this.Trigger.ID, cp.ToString()); binder.TargetIDs.Add(bindInfo); return; } } } }
/// <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); } } }