private void option_DoClose(object sender, EventArgs e) { Close(); pSprite s = sender as pSprite; pButton b = s != null ? s.Tag as pButton : sender as pButton; if (b != null) { b.SpriteCollection.ForEach(sp => sp.FadeOut(600)); } }
internal void AddOption(string text, Color textColour, EventHandler onClick, bool closePopup) { Color modColour = new Color(200, 200, 200, 255); pButton pbut = new pButton((options.Count + 1) + ". " + text, new Vector2(90, currentVerticalSpace), new Vector2(460, 40), 0.92f, textColour, onClick); ((pText)pbut.SpriteCollection[3]).TextShadow = true; for (int i = 0; i < 4; i++) { pSprite p = pbut.SpriteCollection[i]; if (i < 3 && closePopup) { p.OnClick += option_OnClick; p.Tag = pbut; } if (i == 0) { options.Add(p); } p.FadeInFromZero(140); SpriteCollection.Add(p); } /*pText option = * new pText((options.Count + 1) + ". " + text, 34, new Vector2(320, currentVerticalSpace), new Vector2(460, 150), 0.92F, true, * modColour, false); * option.TextColour = textColour; * option.OriginType = OriginTypes.Centre; * option.TextAlignment = Alignment.Centre; * option.BackgroundColour = Color.Black; * option.HoverEffect = new Transformation(modColour, Color.White, 0, 100); * option.BorderColour = Color.Gray; * option.BorderWidth = 3; * option.IsClickable = true; * option.CatchUniversal = true; * if (closePopup) * option.OnClick += option_OnClick; * if (onClick != null) * option.OnClick += onClick; * SpriteCollection.Add(option); * option.FadeInFromZero(180); * options.Add(option); */ currentVerticalSpace += 50; }
internal void AddOption(string text, Color textColour, EventHandler onClick, bool closePopup = true, bool halfWidth = false, bool leftHalf = true) { pButton pbut = new pButton((options.Count + 1) + ". " + text, new Vector2(GameBase.WindowManager.WidthScaled / 2 - 230 + (leftHalf ? 0 : 240), currentVerticalSpace) + ButtonOffset, new Vector2(halfWidth ? 220 : 460, 40), 0.92f, textColour, onClick, GameModeSpecific); ((pText)pbut.SpriteCollection[3]).TextShadow = true; for (int i = 0; i < 4; i++) { pSprite p = pbut.SpriteCollection[i]; if (i < 3 && closePopup) { p.OnClick += option_DoClose; p.Tag = pbut; } if (IsDisplayed) { p.FadeInFromZero(140); } else { int start = options.Count * 60; p.Alpha = 0; p.Transformations.Add(new Transformation(p.InitialPosition + new Vector2(AddOdd ? -40 : 40, 0), p.InitialPosition, start, start + 800, EasingTypes.OutBounce)); p.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, start, start + 800, EasingTypes.Out)); p.Position = p.Position + new Vector2(AddOdd ? -40 : 40, 0); } spriteManager.Add(p); } options.Add(pbut.SpriteCollection[0]); AddOdd = !AddOdd; currentVerticalSpace += 50; }