1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 10:22:55 +08:00

Don't use virtual methods in ctor, always create closeButton.

This commit is contained in:
naoey 2017-08-24 09:48:53 +05:30
parent 7ad4c046db
commit 2cace0e1ab

View File

@ -45,7 +45,7 @@ namespace osu.Game.Overlays.Chat
Margin = new MarginPadding(10), Margin = new MarginPadding(10),
}); });
AddTabItem(selectorTab = new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" })); base.AddTabItem(selectorTab = new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" }));
ChannelSelectorActive.BindTo(selectorTab.Active); ChannelSelectorActive.BindTo(selectorTab.Active);
} }
@ -129,7 +129,7 @@ namespace osu.Game.Overlays.Chat
{ {
this.ResizeTo(new Vector2(Width, 1.1f), transition_length, Easing.OutQuint); this.ResizeTo(new Vector2(Width, 1.1f), transition_length, Easing.OutQuint);
closeButton?.MoveToX(-5f, 0.5f, Easing.OutElastic); closeButton.MoveToX(-5f, 0.5f, Easing.OutElastic);
box.FadeColour(backgroundActive, transition_length, Easing.OutQuint); box.FadeColour(backgroundActive, transition_length, Easing.OutQuint);
highlightBox.FadeIn(transition_length, Easing.OutQuint); highlightBox.FadeIn(transition_length, Easing.OutQuint);
@ -141,7 +141,7 @@ namespace osu.Game.Overlays.Chat
{ {
this.ResizeTo(new Vector2(Width, 1), transition_length, Easing.OutQuint); this.ResizeTo(new Vector2(Width, 1), transition_length, Easing.OutQuint);
closeButton?.MoveToX(5f, 0.5f, Easing.InElastic); closeButton.MoveToX(5f, 0.5f, Easing.InElastic);
box.FadeColour(backgroundInactive, transition_length, Easing.OutQuint); box.FadeColour(backgroundInactive, transition_length, Easing.OutQuint);
highlightBox.FadeOut(transition_length, Easing.OutQuint); highlightBox.FadeOut(transition_length, Easing.OutQuint);
@ -151,7 +151,8 @@ namespace osu.Game.Overlays.Chat
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
closeButton?.FadeIn(1f, Easing.InBounce); if (IsRemovable)
closeButton.FadeIn(1f, Easing.InBounce);
if (!Active) if (!Active)
box.FadeColour(backgroundHover, transition_length, Easing.OutQuint); box.FadeColour(backgroundHover, transition_length, Easing.OutQuint);
@ -160,7 +161,9 @@ namespace osu.Game.Overlays.Chat
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
closeButton?.FadeOut(1f, Easing.OutBounce); if (closeButton.IsPresent)
closeButton.FadeOut(1f, Easing.OutBounce);
updateState(); updateState();
} }
@ -250,13 +253,7 @@ namespace osu.Game.Overlays.Chat
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
TextSize = 18, TextSize = 18,
}, },
}, closeButton = new Button
},
};
if (IsRemovable)
{
Add(closeButton = new Button
{ {
Alpha = 0, Alpha = 0,
Width = 20, Width = 20,
@ -266,9 +263,11 @@ namespace osu.Game.Overlays.Chat
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Text = @"x", Text = @"x",
BackgroundColour = Color4.Transparent, BackgroundColour = Color4.Transparent,
Action = () => OnRequestClose?.Invoke(), Action = delegate { if (IsRemovable) OnRequestClose?.Invoke(); },
}); },
} },
},
};
} }
public class ChannelSelectorTabItem : ChannelTabItem public class ChannelSelectorTabItem : ChannelTabItem