Do not expose HoldToQuit.HoldToQuitButton

This commit is contained in:
Roman Kapustin 2018-05-03 23:29:58 +03:00
parent 3b84ce7c9f
commit f8630115d6
3 changed files with 13 additions and 8 deletions

View File

@ -22,15 +22,15 @@ namespace osu.Game.Tests.Visual
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,
});
holdToQuit.Button.ExitAction = () => exitAction = true;
holdToQuit.ExitAction = () => exitAction = true;
var text = holdToQuit.Children.OfType<SpriteText>().Single();
AddStep("Trigger text fade in/out", () =>
{
exitAction = false;
holdToQuit.Button.TriggerOnMouseDown();
holdToQuit.Button.TriggerOnMouseUp();
holdToQuit.TriggerOnMouseDown();
holdToQuit.TriggerOnMouseUp();
});
AddUntilStep(() => text.IsPresent && !exitAction, "Text visible");
@ -39,10 +39,10 @@ namespace osu.Game.Tests.Visual
AddStep("Trigger exit action", () =>
{
exitAction = false;
holdToQuit.Button.TriggerOnMouseDown();
holdToQuit.TriggerOnMouseDown();
});
AddUntilStep(() => exitAction, $"{nameof(holdToQuit.Button.ExitAction)} was triggered");
AddUntilStep(() => exitAction, $"{nameof(holdToQuit.ExitAction)} was triggered");
}
}
}

View File

@ -16,7 +16,12 @@ namespace osu.Game.Screens.Play.HUD
{
public class HoldToQuit : FillFlowContainer
{
public readonly HoldToQuitButton Button;
private readonly HoldToQuitButton button;
public Action ExitAction
{
get => button.ExitAction;
set => button.ExitAction = value;
}
public HoldToQuit()
{
@ -32,7 +37,7 @@ namespace osu.Game.Screens.Play.HUD
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft
},
Button = new HoldToQuitButton(text)
button = new HoldToQuitButton(text)
};
AutoSizeAxes = Axes.Both;
}

View File

@ -216,7 +216,7 @@ namespace osu.Game.Screens.Play
}
};
hudOverlay.HoldToQuit.Button.ExitAction = Exit;
hudOverlay.HoldToQuit.ExitAction = Exit;
if (ShowStoryboard)
initializeStoryboard(false);