-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #195 from andy840119/rabbit/singer-tooltip
Implement singer tooltip.
- Loading branch information
Showing
4 changed files
with
211 additions
and
37 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
osu.Game.Rulesets.Karaoke.Tests/Graphics/TestSceneSingerToolTip.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using NUnit.Framework; | ||
using osu.Game.Rulesets.Karaoke.Graphics.Cursor; | ||
using osu.Game.Tests.Visual; | ||
using osu.Framework.Graphics; | ||
using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; | ||
using System; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.Graphics | ||
{ | ||
[TestFixture] | ||
public class TestSceneSingerToolTip : OsuTestScene | ||
{ | ||
private SingerToolTip toolTip; | ||
|
||
[SetUp] | ||
public void SetUp() => Schedule(() => | ||
{ | ||
Child = toolTip = new SingerToolTip | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre | ||
}; | ||
toolTip.Show(); | ||
}); | ||
|
||
[Test] | ||
public void TestDisplayToolTip() | ||
{ | ||
setTooltip("Test normal singer", singer => | ||
{ | ||
singer.Name = "Normal singer"; | ||
}); | ||
|
||
setTooltip("Test singer with description", singer => | ||
{ | ||
singer.Name = "Singer with description"; | ||
singer.Description = "International superstar vocaloid Hatsune Miku."; | ||
}); | ||
|
||
setTooltip("Test singer with large description", singer => | ||
{ | ||
singer.Name = "Singer with large description"; | ||
singer.Description = "International superstar vocaloid Hatsune Miku on Sept 9 assumed her new position as Coronavirus Countermeasure Supporter in the Office for Novel Coronavirus Disease Control of the Japanese government’s Cabinet Secretariat."; | ||
}); | ||
|
||
setTooltip("Test singer with english name", singer => | ||
{ | ||
singer.Name = "Singer with English name"; | ||
singer.EnglishName = "Hatsune Miku"; | ||
}); | ||
|
||
setTooltip("Test singer with romaji name", singer => | ||
{ | ||
singer.Name = "Singer with Romaji name"; | ||
singer.EnglishName = "Hatsune Miku"; | ||
}); | ||
} | ||
|
||
private void setTooltip(string testName, Action<Singer> callBack) | ||
{ | ||
AddStep(testName, () => | ||
{ | ||
var singer = new Singer(1); | ||
callBack?.Invoke(singer); | ||
toolTip.SetContent(singer); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
osu.Game.Rulesets.Karaoke/Graphics/Cursor/BackgroundToolTip.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Cursor; | ||
using osu.Framework.Graphics.Shapes; | ||
using osu.Game.Graphics; | ||
using osuTK; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Graphics.Cursor | ||
{ | ||
public abstract class BackgroundToolTip : VisibilityContainer, ITooltip | ||
{ | ||
private readonly Box background; | ||
private readonly Container content; | ||
|
||
protected override Container<Drawable> Content => content; | ||
|
||
public BackgroundToolTip() | ||
{ | ||
AutoSizeAxes = Axes.Both; | ||
Masking = true; | ||
CornerRadius = 5; | ||
|
||
InternalChildren = new Drawable[] | ||
{ | ||
background = new Box | ||
{ | ||
RelativeSizeAxes = Axes.Both | ||
}, | ||
content = new Container | ||
{ | ||
AutoSizeAxes = Axes.Both, | ||
AutoSizeDuration = 200, | ||
AutoSizeEasing = Easing.OutQuint, | ||
Padding = new MarginPadding(10) | ||
} | ||
}; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(OsuColour colours) | ||
{ | ||
background.Colour = colours.Gray3; | ||
} | ||
|
||
public abstract bool SetContent(object content); | ||
|
||
public void Move(Vector2 pos) => Position = pos; | ||
|
||
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint); | ||
|
||
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters