public override void Evaluate(int SpreadMax) { //calc input spreadcount int inputSpreadCount = SpreadMax; //create or delete button groups int diff = inputSpreadCount - FControllerGroups.Count; if (diff > 0) { for (int i = 0; i < diff; i++) { FControllerGroups.Add(new RadioButtonGroup()); } } else if (diff < 0) { for (int i = 0; i < -diff; i++) { FControllerGroups.RemoveAt(FControllerGroups.Count - 1 - i); } } //update parameters int slice; if (AnyParameterPinChanged()) { for (slice = 0; slice < inputSpreadCount; slice++) { RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice]; group.UpdateTransform(FTransformIn[slice], FCountIn[slice], FSizeIn[slice], FColorIn[slice], FOverColorIn[slice], FActiveColorIn[slice]); } } //update mouse and colors bool valueSet = false; if (AnyMouseUpdatePinChanged()) { var mouseCount = FMouseIn.SliceCount; FLastMouseLeft.SliceCount = mouseCount; for (int mouseSlice = 0; mouseSlice < mouseCount; mouseSlice++) { var mouse = FMouseIn[0]; for (slice = 0; slice < inputSpreadCount; slice++) { RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice]; group.IsMultiTouch = mouseCount > 1; valueSet = group.UpdateMouse(mouse.Position, mouse.IsLeft && !FLastMouseLeft[mouseSlice], mouse.IsLeft); } valueSet = FLastMouseLeft[mouseSlice] && mouse.IsLeft; FLastMouseLeft[mouseSlice] = mouse.IsLeft; } } if (FValueIn.IsChanged || FSetValueIn.IsChanged) { for (slice = 0; slice < inputSpreadCount; slice++) { RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice]; if (FSetValueIn[slice]) { //update value group.UpdateValue(FValueIn[slice]); valueSet = true; } else if (FFirstframe) { //load from config pin on first frame group.UpdateValue(FInternalValueConfig[slice]); } } } //get spread counts int outcount = 0; FSpreadCountsOut.SliceCount = inputSpreadCount; for (slice = 0; slice < inputSpreadCount; slice++) { RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice]; outcount += group.FControllers.Length; FSpreadCountsOut[slice] = group.FControllers.Length; } //write output to pins FValueOut.SliceCount = inputSpreadCount; if (outcount != FInternalValueConfig.SliceCount) { FInternalValueConfig.SliceCount = outcount; } FTransformOut.SliceCount = outcount; FColorOut.SliceCount = outcount; FHitOut.SliceCount = outcount; FActiveOut.SliceCount = outcount; FMouseOverOut.SliceCount = outcount; slice = 0; for (int i = 0; i < inputSpreadCount; i++) { RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[i]; int pcount = group.FControllers.Length; FValueOut[i] = group.SelectedSlice; if (valueSet) { FInternalValueConfig[i] = group.SelectedSlice; } for (int j = 0; j < pcount; j++) { RadioButton b = (RadioButton)group.FControllers[j]; FTransformOut[slice] = b.Transform; FColorOut[slice] = b.CurrentCol; FMouseOverOut[slice] = b.GetAndResetMouseOver(); FHitOut[slice] = b.Hit; FActiveOut[slice] = b.Active; slice++; } } //end of frame FFirstframe = false; }
public override void Evaluate(int SpreadMax) { //calc input spreadcount int inputSpreadCount = SpreadMax; //create or delete button groups int diff = inputSpreadCount - FControllerGroups.Count; if (diff > 0) { for (int i = 0; i < diff; i++) { FControllerGroups.Add(new RadioButtonGroup()); } } else if (diff < 0) { for (int i = 0; i < -diff; i++) { FControllerGroups.RemoveAt(FControllerGroups.Count - 1 - i); } } //update parameters int slice; if (FCountXIn.PinIsChanged || FCountYIn.PinIsChanged || FSizeXIn.PinIsChanged || FSizeYIn.PinIsChanged || FTransformIn.PinIsChanged || FColorIn.PinIsChanged || FOverColorIn.PinIsChanged || FActiveColorIn.PinIsChanged) { for (slice = 0; slice < inputSpreadCount; slice++) { RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice]; Matrix4x4 trans; Vector2D count, size; RGBAColor col, over, active; FTransformIn.GetMatrix(slice, out trans); FCountXIn.GetValue(slice, out count.x); FCountYIn.GetValue(slice, out count.y); FSizeXIn.GetValue(slice, out size.x); FSizeYIn.GetValue(slice, out size.y); FColorIn.GetColor(slice, out col); FOverColorIn.GetColor(slice, out over); FActiveColorIn.GetColor(slice, out active); group.UpdateTransform(trans, count, size, col, over, active); } } //update mouse and colors bool valueSet = false; if (FMouseXIn.PinIsChanged || FMouseYIn.PinIsChanged || FLeftButtonIn.PinIsChanged || FColorIn.PinIsChanged || FOverColorIn.PinIsChanged || FActiveColorIn.PinIsChanged || FCountXIn.PinIsChanged || FCountYIn.PinIsChanged || FLastMouseLeft || FSetValueIn.PinIsChanged) { Vector2D mouse; double mouseLeft; FMouseXIn.GetValue(0, out mouse.x); FMouseYIn.GetValue(0, out mouse.y); FLeftButtonIn.GetValue(0, out mouseLeft); for (slice = 0; slice < inputSpreadCount; slice++) { RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice]; valueSet = group.UpdateMouse(mouse, (mouseLeft >= 0.5) && !FLastMouseLeft, mouseLeft >= 0.5); } valueSet = FLastMouseLeft && mouseLeft < 0.5; FLastMouseLeft = mouseLeft >= 0.5; } if (FValueIn.PinIsChanged || FSetValueIn.PinIsChanged) { for (slice = 0; slice < inputSpreadCount; slice++) { RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice]; double val; FSetValueIn.GetValue(slice, out val); if (val >= 0.5) { //update value FValueIn.GetValue(slice, out val); group.UpdateValue((int)Math.Round(val)); valueSet = true; } else if (FFirstframe) { //load from config pin on first frame FInternalValueConfig.GetValue(slice, out val); group.UpdateValue((int)Math.Round(val)); } } } //get spread counts int outcount = 0; FSpreadCountsOut.SliceCount = inputSpreadCount; for (slice = 0; slice < inputSpreadCount; slice++) { RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice]; outcount += group.FControllers.Length; FSpreadCountsOut.SetValue(slice, group.FControllers.Length); } //write output to pins FValueOut.SliceCount = inputSpreadCount; if (outcount != FInternalValueConfig.SliceCount) { FInternalValueConfig.SliceCount = outcount; } FTransformOut.SliceCount = outcount; FColorOut.SliceCount = outcount; FHitOut.SliceCount = outcount; FActiveOut.SliceCount = outcount; FMouseOverOut.SliceCount = outcount; slice = 0; for (int i = 0; i < inputSpreadCount; i++) { RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[i]; int pcount = group.FControllers.Length; FValueOut.SetValue(i, group.SelectedSlice); if (valueSet) { FInternalValueConfig.SetValue(i, group.SelectedSlice); } for (int j = 0; j < pcount; j++) { RadioButton b = (RadioButton)group.FControllers[j]; FTransformOut.SetMatrix(slice, b.Transform); FColorOut.SetColor(slice, b.CurrentCol); FMouseOverOut.SetValue(slice, b.MouseOver ? 1 : 0); FHitOut.SetValue(slice, b.Hit ? 1 : 0); FActiveOut.SetValue(slice, b.Active ? 1 : 0); slice++; } } //end of frame FFirstframe = false; }