//this sets data to use as a reference for relative mode private void SetFixedValues() { fixedValues = new List <LightProps>(); for (int i = 0; i < selection.Count; i++) { Thing t = selection[i]; LightProps lp = new LightProps(); int firstArg = 3; if (t.DynamicLightType == 1502 || t.DynamicLightType == 1503) { firstArg = 0; } lp.PrimaryRadius = t.Args[firstArg]; //either both of them or none are used if (showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, t.DynamicLightType) != -1) { lp.SecondaryRadius = t.Args[4]; lp.Interval = t.AngleDoom; } fixedValues.Add(lp); } }
//initialise pannel public bool Setup(string editingModeName) { this.editingModeName = editingModeName; SetupSelection(); int selCount = selection.Count; if (selCount == 0) { General.Interface.DisplayStatus(StatusType.Warning, "No lights found in selection!"); return(false); } lightProps = new LightProps(); //initialise InitializeComponent(); SetupSliders(selection[0]); UpdateLightPropsFromThing(selection[0]); SetControlsMode(); colorPickerControl1.Initialize(GetThingColor(selection[0])); colorPickerControl1.OnColorChanged += OnColorPickerControl1OnColorChanged; colorPickerControl1.OnOkPressed += colorPickerControl1_OnOkPressed; colorPickerControl1.OnCancelPressed += colorPickerControl1_OnCancelPressed; cbRelativeMode.Checked = RELATIVE_MODE; cbRelativeMode.CheckStateChanged += cbRelativeMode_CheckStateChanged; this.AcceptButton = colorPickerControl1.OkButton; this.CancelButton = colorPickerControl1.CancelButton; this.Text = "Editing " + selCount + " light" + (selCount > 1 ? "s" : ""); //undo MakeUndo(this.Text); return(true); }
//this sets values from lightProps to things in selection private void UpdateSelection(bool colorChanged) { for (int i = 0; i < selection.Count; i++) { Thing t = selection[i]; //update color if (colorChanged) //need this check to allow relative mode to work properly { if (t.DynamicLightType == 1503) //Vavoom Light Color { t.Args[1] = lightProps.Red; t.Args[2] = lightProps.Green; t.Args[3] = lightProps.Blue; } else if (t.DynamicLightType != 1502) //vavoom light has no color settings { t.Args[0] = lightProps.Red; t.Args[1] = lightProps.Green; t.Args[2] = lightProps.Blue; } } int firstArg = 3; if (t.DynamicLightType == 1502 || t.DynamicLightType == 1503) { firstArg = 0; } //update radius and intensity if (RELATIVE_MODE) { LightProps fixedVal = fixedValues[i]; t.Args[firstArg] = fixedVal.PrimaryRadius + lightProps.PrimaryRadius; if (t.Args[firstArg] < 0) { t.Args[firstArg] = 0; } if (showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, t.DynamicLightType) != -1) { t.Args[4] = fixedVal.SecondaryRadius + lightProps.SecondaryRadius; if (t.Args[4] < 0) { t.Args[4] = 0; } t.Rotate(General.ClampAngle(fixedVal.Interval + lightProps.Interval)); } } else { if (lightProps.PrimaryRadius != -1) { t.Args[firstArg] = lightProps.PrimaryRadius; } if (showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, t.DynamicLightType) != -1) { t.Args[4] = lightProps.SecondaryRadius; t.Rotate(General.ClampAngle(lightProps.Interval)); } } } //update VisualThings if (editingModeName == "BaseVisualMode") { foreach (VisualThing t in visualSelection) { t.UpdateLight(); } } else if (editingModeName == "ThingsMode") { // Hacky way to call ThingsMode.UpdateHelperObjects() without referenceing BuilderModes.dll General.Editing.Mode.OnRedoEnd(); General.Interface.RedrawDisplay(); } }