public override void releaseLeftClick(int x, int y) { if (activeSlider != null) { activeSlider = null; } base.releaseLeftClick(x, y); }
public virtual Rectangle Reposition(Rectangle start_rect) { buildingPaintMenu.sliderHandles.Clear(); rectangle.X = start_rect.X; rectangle.Y = start_rect.Y; rectangle.Width = start_rect.Width; rectangle.Height = 0; lightnessSlider = null; hueSlider = null; saturationSlider = null; colorDrawPosition = new Vector2(start_rect.X + start_rect.Width - 64, start_rect.Y); hueSlider = new BuildingColorSlider(buildingPaintMenu, 106, new Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width - 100, 12), 0, 360, delegate { if (regionIndex == 0) { buildingPaintMenu.colorTarget.Color1Default.Value = false; } else if (regionIndex == 1) { buildingPaintMenu.colorTarget.Color2Default.Value = false; } else { buildingPaintMenu.colorTarget.Color3Default.Value = false; } ApplyColors(); }); BuildingColorSlider buildingColorSlider = hueSlider; buildingColorSlider.getDrawColor = (Func <float, Color>)Delegate.Combine(buildingColorSlider.getDrawColor, (Func <float, Color>)((float val) => GetColorForValues(val, 100f))); if (regionIndex == 0) { hueSlider.SetValue(buildingPaintMenu.colorTarget.Color1Hue, skip_value_set: true); } else if (regionIndex == 1) { hueSlider.SetValue(buildingPaintMenu.colorTarget.Color2Hue, skip_value_set: true); } else { hueSlider.SetValue(buildingPaintMenu.colorTarget.Color3Hue, skip_value_set: true); } rectangle.Height += 24; saturationSlider = new BuildingColorSlider(buildingPaintMenu, 107, new Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width - 100, 12), 0, 75, delegate { if (regionIndex == 0) { buildingPaintMenu.colorTarget.Color1Default.Value = false; } else if (regionIndex == 1) { buildingPaintMenu.colorTarget.Color2Default.Value = false; } else { buildingPaintMenu.colorTarget.Color3Default.Value = false; } ApplyColors(); }); BuildingColorSlider buildingColorSlider2 = saturationSlider; buildingColorSlider2.getDrawColor = (Func <float, Color>)Delegate.Combine(buildingColorSlider2.getDrawColor, (Func <float, Color>)((float val) => GetColorForValues(hueSlider.GetValue(), val))); if (regionIndex == 0) { saturationSlider.SetValue(buildingPaintMenu.colorTarget.Color1Saturation, skip_value_set: true); } else if (regionIndex == 1) { saturationSlider.SetValue(buildingPaintMenu.colorTarget.Color2Saturation, skip_value_set: true); } else { saturationSlider.SetValue(buildingPaintMenu.colorTarget.Color3Saturation, skip_value_set: true); } rectangle.Height += 24; lightnessSlider = new BuildingColorSlider(buildingPaintMenu, 108, new Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width - 100, 12), minimumBrightness, maximumBrightness, delegate { if (regionIndex == 0) { buildingPaintMenu.colorTarget.Color1Default.Value = false; } else if (regionIndex == 1) { buildingPaintMenu.colorTarget.Color2Default.Value = false; } else { buildingPaintMenu.colorTarget.Color3Default.Value = false; } ApplyColors(); }); BuildingColorSlider buildingColorSlider3 = lightnessSlider; buildingColorSlider3.getDrawColor = (Func <float, Color>)Delegate.Combine(buildingColorSlider3.getDrawColor, (Func <float, Color>)((float val) => GetColorForValues(hueSlider.GetValue(), saturationSlider.GetValue(), val))); if (regionIndex == 0) { lightnessSlider.SetValue(buildingPaintMenu.colorTarget.Color1Lightness, skip_value_set: true); } else if (regionIndex == 1) { lightnessSlider.SetValue(buildingPaintMenu.colorTarget.Color2Lightness, skip_value_set: true); } else { lightnessSlider.SetValue(buildingPaintMenu.colorTarget.Color3Lightness, skip_value_set: true); } rectangle.Height += 24; if ((regionIndex == 0 && buildingPaintMenu.colorTarget.Color1Default.Value) || (regionIndex == 1 && buildingPaintMenu.colorTarget.Color2Default.Value) || (regionIndex == 2 && buildingPaintMenu.colorTarget.Color3Default.Value)) { hueSlider.SetValue(hueSlider.min, skip_value_set: true); saturationSlider.SetValue(saturationSlider.max, skip_value_set: true); lightnessSlider.SetValue((lightnessSlider.min + lightnessSlider.max) / 2, skip_value_set: true); } buildingPaintMenu.sliderHandles.Add(hueSlider.handle); buildingPaintMenu.sliderHandles.Add(saturationSlider.handle); buildingPaintMenu.sliderHandles.Add(lightnessSlider.handle); hueSlider.handle.upNeighborID = 104; hueSlider.handle.downNeighborID = 107; saturationSlider.handle.downNeighborID = 108; saturationSlider.handle.upNeighborID = 106; lightnessSlider.handle.upNeighborID = 107; rectangle.Height += 32; start_rect.Y += rectangle.Height; return(start_rect); }