-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 #26076 from peppy/gameplay-offset-adjust
Add control to allow changing offset from gameplay
- Loading branch information
Showing
5 changed files
with
204 additions
and
23 deletions.
There are no files selected for viewing
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
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
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,107 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT 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.Shapes; | ||
using osu.Framework.Threading; | ||
using osu.Game.Graphics; | ||
using osu.Game.Graphics.Containers; | ||
using osu.Game.Overlays; | ||
using osu.Game.Screens.Play.PlayerSettings; | ||
using osuTK; | ||
using osuTK.Graphics; | ||
|
||
namespace osu.Game.Screens.Play | ||
{ | ||
/// <summary> | ||
/// This provides the ability to change the offset while in gameplay. | ||
/// Eventually this should be replaced with all settings from PlayerLoader being accessible from the game. | ||
/// </summary> | ||
internal partial class GameplayOffsetControl : VisibilityContainer | ||
{ | ||
protected override bool StartHidden => true; | ||
|
||
public override bool PropagateNonPositionalInputSubTree => true; | ||
|
||
// Disable interaction for now to avoid any funny business with slider bar dragging. | ||
public override bool PropagatePositionalInputSubTree => false; | ||
|
||
private BeatmapOffsetControl offsetControl = null!; | ||
|
||
private OsuTextFlowContainer text = null!; | ||
|
||
private ScheduledDelegate? hideOp; | ||
|
||
public GameplayOffsetControl() | ||
{ | ||
AutoSizeAxes = Axes.Y; | ||
Width = SettingsToolboxGroup.CONTAINER_WIDTH; | ||
|
||
Masking = true; | ||
CornerRadius = 5; | ||
|
||
// Allow BeatmapOffsetControl to handle keyboard input. | ||
AlwaysPresent = true; | ||
|
||
Anchor = Anchor.CentreRight; | ||
Origin = Anchor.CentreRight; | ||
|
||
X = 100; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(OverlayColourProvider? colourProvider) | ||
{ | ||
InternalChildren = new Drawable[] | ||
{ | ||
new Box | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Alpha = 0.8f, | ||
Colour = colourProvider?.Background4 ?? Color4.Black, | ||
}, | ||
new FillFlowContainer | ||
{ | ||
RelativeSizeAxes = Axes.X, | ||
AutoSizeAxes = Axes.Y, | ||
Padding = new MarginPadding(10), | ||
Spacing = new Vector2(5), | ||
Direction = FillDirection.Vertical, | ||
Children = new Drawable[] | ||
{ | ||
offsetControl = new BeatmapOffsetControl(), | ||
text = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(weight: FontWeight.SemiBold)) | ||
{ | ||
RelativeSizeAxes = Axes.X, | ||
AutoSizeAxes = Axes.Y, | ||
TextAnchor = Anchor.TopCentre, | ||
} | ||
} | ||
}, | ||
}; | ||
|
||
offsetControl.Current.BindValueChanged(val => | ||
{ | ||
text.Text = BeatmapOffsetControl.GetOffsetExplanatoryText(val.NewValue); | ||
Show(); | ||
|
||
hideOp?.Cancel(); | ||
hideOp = Scheduler.AddDelayed(Hide, 500); | ||
}); | ||
} | ||
|
||
protected override void PopIn() | ||
{ | ||
this.FadeIn(500, Easing.OutQuint) | ||
.MoveToX(0, 500, Easing.OutQuint); | ||
} | ||
|
||
protected override void PopOut() | ||
{ | ||
this.FadeOut(500, Easing.InQuint) | ||
.MoveToX(100, 500, Easing.InQuint); | ||
} | ||
} | ||
} |
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
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