public TriggerValue SetNullMode() { ParentTriggerNamespace.SwitchVarToConstant(mVariable, ref mValue); mValue.IsNull = true; mBinder.UpdateValue(mValue); return(mValue); }
public TriggerValue SetVarMode() { ParentTriggerNamespace.SwitchConstantToVar(mVariable, ref mValue); mValue.IsNull = false; mBinder.UpdateValue(mValue); //UpdateControl(); return(mValue); }
public void Delete() { ParentTriggerNamespace.DeleteTrigger(this.Trigger); this.Parent.Controls.Remove(this); List <IControlPoint> cps = this.GetControlPoints(); foreach (IControlPoint cp in cps) { cp.MarkForDelete = true; } this.mTriggerHost.Update(); }
public TriggerValue SetVarMode(int newValueID) { //ParentTriggerNamespace.SwitchConstantToVar(mVariable, ref mValue); //newValueID //mVariable.ID = newValueID; //mValue = ParentTriggerNamespace.GetValues()[newValueID]; //ParentTriggerNamespace.AssignValueToVar(mVariable, mValue); mValue = ParentTriggerNamespace.AssignValueToVar(mVariable, newValueID); mValue.IsNull = false; mBinder.UpdateValue(mValue); //UpdateControl(); return(mValue); }
//...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); }
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); }
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."); } }
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."); } }
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"); } } }
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; } } } }
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); } }
public void PostCopy(Dictionary <int, int> triggerMapping) { //fixup trigger ids List <TriggerEffect> effectList = mThisTrigger.TriggerEffects.Effects; List <TriggerEffect> hitlist = new List <TriggerEffect>(); foreach (TriggerEffect e in effectList) { if (e.Type == TriggerSystemMain.mTriggerDefinitions.GetActivateEffectName()) { int targetTrigger = System.Convert.ToInt32(ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value); if (triggerMapping.ContainsKey(targetTrigger)) { ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value = triggerMapping[targetTrigger].ToString(); } else { hitlist.Add(e); } continue; } if (e.Type == TriggerSystemMain.mTriggerDefinitions.GetDeactivateEffectName()) { int targetTrigger = System.Convert.ToInt32(ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value); if (triggerMapping.ContainsKey(targetTrigger)) { ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value = triggerMapping[targetTrigger].ToString(); } else { hitlist.Add(e); } 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()) { int targetTrigger = System.Convert.ToInt32(ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value); if (triggerMapping.ContainsKey(targetTrigger)) { ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value = triggerMapping[targetTrigger].ToString(); } else { hitlist.Add(e); } continue; } if (e.Type == TriggerSystemMain.mTriggerDefinitions.GetDeactivateEffectName()) { int targetTrigger = System.Convert.ToInt32(ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value); if (triggerMapping.ContainsKey(targetTrigger)) { ParentTriggerNamespace.GetValues()[e.Parameter[0].ID].Value = triggerMapping[targetTrigger].ToString(); } else { hitlist.Add(e); } continue; } } foreach (TriggerEffect e in hitlist) { effectList.Remove(e); } hitlist.Clear(); this.LoadExistingConnections(); }
//Loads ui. Creates values for the mappings if they do not exist private void LoadMappingUI(TriggerTemplateMapping mapping) { TriggerNameText.Text = Path.GetFileNameWithoutExtension(mapping.Name); foreach (TriggersTemplateInputVariable v in mapping.InputMappings) { TriggerParameterControl c = new TriggerParameterControl(); TriggerValue val = new TriggerValue(); if (mbDemoMode || (ParentTriggerNamespace.GetValues().ContainsKey(v.ID) == false) || (v.ID == -1)) { val.Name = v.Name; val.Type = v.Type; int newID = -1; ParentTriggerNamespace.InsertValue(val, out newID); v.ID = newID; //this line set optional parmas to default off for newly placed templates if (v.Optional == true) { val.IsNull = true; } } else { val = ParentTriggerNamespace.GetValues()[v.ID]; } c.Init(null, v, val, ParentTriggerNamespace); VarInHardPointsBar.AddControl(c); } foreach (TriggersTemplateOutputVariable v in mapping.OutputMappings) { TriggerParameterControl c = new TriggerParameterControl(); TriggerValue val = new TriggerValue(); if (ParentTriggerNamespace.GetValues().ContainsKey(v.ID) == false) { val.Name = v.Name; val.Type = v.Type; int newID = -1; ParentTriggerNamespace.InsertValue(val, out newID); v.ID = newID; } else { val = ParentTriggerNamespace.GetValues()[v.ID]; } c.Init(null, v, val, ParentTriggerNamespace); VarOutHardPointsBar.AddControl(c); } foreach (TriggersTemplateInputActionBinder b in mapping.TriggerInputs) { BasicControlPoint cp = new BasicControlPoint(mHost); INHardPointsBar.AddControl(cp); cp.TargetKey = "none";//"Trigger.Link.Back"; cp.TypeKey = "Trigger.Link.Forward"; cp.BackColor = b.GetColor(); cp.SetToolTipText(b.Name); cp.Name = b.Name; cp.SetDirection(new Point(-250, 0)); cp.Tag = this; cp.TagObject = this; cp.RenderText = cp.Name; cp.ControlPointDescription = this.mTriggerTemplateMapping.Name + "." + b.Name; mControlPoints.Add(cp); mInputActionCPs[cp] = b; } //flowLayoutPanel1.Controls.Add(MakeLabel("OutputTriggers:")); foreach (TriggersTemplateOutputActionBinder b in mapping.TriggerOutputs) { BasicControlPoint cp = new BasicControlPoint(mHost); OutHardPointsBar.AddControl(cp); cp.TargetKey = "Trigger.Link.Forward"; cp.TypeKey = "none";//"Trigger.Link.Back"; cp.BackColor = b.GetColor(); cp.SetToolTipText(b.Name); cp.Name = b.Name; cp.SetDirection(new Point(250, 0)); cp.Tag = this; cp.TagObject = this; cp.RenderText = b.Name; cp.ControlPointConnected += new BasicControlPoint.ControlPointEvent(output_ControlPointConnected); cp.ControlPointRemoved += new BasicControlPoint.ControlPointEvent(output_ControlPointRemoved); cp.ControlPointDescription = this.mTriggerTemplateMapping.Name + "." + b.Name; mControlPoints.Add(cp); mOutputActionCPs[cp] = b; } }