private void UpdateBaseColor() { baseColor = Color.white; if (!vanishIfMouseDistant) { return; } Rect r = OverRect.ContractedBy(-12f); if (r.Contains(Event.current.mousePosition)) { return; } float distanceFromRect = GenUI.DistFromRect(r, Event.current.mousePosition); baseColor = new Color(1f, 1f, 1f, (float)(1.0 - distanceFromRect / 200.0)); if (distanceFromRect <= 200.0) { return; } Close(false); Cancel(); }
public override void DoWindowContents(Rect rect) { if (!rect.Contains(Event.current.mousePosition)) { var num = GenUI.DistFromRect(rect, Event.current.mousePosition); if (num > 75f) { Close(false); return; } } _intSlider.Draw(new Rect(5, 10, _width - 50, _height - 50)); }
public static bool CheckShouldClose(Rect r) { if (r.Contains(Event.current.mousePosition)) { windowTransparency = new Color(1, 1, 1, 1); return(false); } var num = GenUI.DistFromRect(r, Event.current.mousePosition); windowTransparency = new Color(1f, 1f, 1f, 1f - (num / mouseDistTillClose)); return(num > mouseDistTillClose); }
public override void DoWindowContents(Rect rect) { Rect r = new Rect(0f, 0f, WIDTH, HEIGHT).ContractedBy(-5f); if (!r.Contains(Event.current.mousePosition)) { float num = GenUI.DistFromRect(r, Event.current.mousePosition); if (num > 95f) { this.Close(false); return; } } GUI.DrawTexture(rect, Main.BlackTexture); Color rgb = this.CompGlower.Props.glowColor.ToColor; HSL hsl = new HSL(); Color.RGBToHSV(rgb, out hsl.h, out hsl.s, out hsl.l); HSL originalHsl = new HSL(hsl); Color originalRGB = rgb; rgb.r = Widgets.HorizontalSlider(new Rect(5, 15, 125f, 20f), rgb.r, 0, 1, false, null, "AdjustableColoredLights.R".Translate(), ((int)(rgb.r * 255)).ToString()); rgb.g = Widgets.HorizontalSlider(new Rect(5, 45, 125f, 20f), rgb.g, 0, 1, false, null, "AdjustableColoredLights.G".Translate(), ((int)(rgb.g * 255)).ToString()); rgb.b = Widgets.HorizontalSlider(new Rect(5, 75, 125f, 20f), rgb.b, 0, 1, false, null, "AdjustableColoredLights.B".Translate(), ((int)(rgb.b * 255)).ToString()); hsl.h = Widgets.HorizontalSlider(new Rect(5, 105, 125f, 20f), hsl.h, 0, 1, false, null, "AdjustableColoredLights.H".Translate(), ((int)(hsl.h * 255)).ToString()); hsl.s = Widgets.HorizontalSlider(new Rect(5, 135, 125f, 20f), hsl.s, 0, 1, false, null, "AdjustableColoredLights.S".Translate(), ((int)(hsl.s * 255)).ToString()); hsl.l = Widgets.HorizontalSlider(new Rect(5, 165, 125f, 20f), hsl.l, 0, 1, false, null, "AdjustableColoredLights.L".Translate(), ((int)(hsl.l * 255)).ToString()); if (hsl != originalHsl) { rgb = Color.HSVToRGB(hsl.h, hsl.s, hsl.l); } if (rgb.r < 0.02f && rgb.g < 0.02f && rgb.b < 0.02f) { rgb = new Color(0.02f, 0.02f, 0.02f); } if (rgb != originalRGB) { this.CompGlower.Props.glowColor = new ColorInt( (int)(rgb.r * 255), (int)(rgb.g * 255), (int)(rgb.b * 255), (int)(rgb.a * 255)); this.CompGlower.parent?.Map?.glowGrid.MarkGlowGridDirty(this.CompGlower.parent.Position); } }
protected virtual void UpdateBaseColor() { if (!Selected && !HasActiveParent) { baseColor = Color.white; Rect r = new Rect(0f, 0f, backgroundTexture.width, backgroundTexture.height).ContractedBy(-5f); if (!r.Contains(Event.current.mousePosition)) { float num = GenUI.DistFromRect(r, Event.current.mousePosition); baseColor = new Color(1f, 1f, 1f, 1f - num / 95f); if (num > 95f) { Close(doCloseSound: false); Cancel(); } } } }
public override void DoWindowContents(Rect rect) { if (!rect.Contains(Event.current.mousePosition)) { var num = GenUI.DistFromRect(rect, Event.current.mousePosition); if (num > 75f) { Close(false); return; } } _callback((int)Widgets.HorizontalSlider( new Rect(5, 10, 165f, 25f), _current(), _floor, _ceiling, false, "" + _current() + "/" + _ceiling, _label)); }