Skip to content

Commit 459577c

Browse files
authored
Merge pull request #31474 from peppy/scroll-container-double-precision
Update game `ScrollContainer` usage in line with framework changes
2 parents 75d1fab + 92cc45d commit 459577c

26 files changed

+66
-54
lines changed

osu.Android.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
1111
</PropertyGroup>
1212
<ItemGroup>
13-
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.1224.0" />
13+
<PackageReference Include="ppy.osu.Framework.Android" Version="2025.114.1" />
1414
</ItemGroup>
1515
<PropertyGroup>
1616
<!-- Fody does not handle Android build well, and warns when unchanged.

osu.Game.Tests/Visual/UserInterface/TestSceneSectionsContainer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void step(int scrollIndex)
138138
AddUntilStep("section top is visible", () =>
139139
{
140140
var scrollContainer = container.ChildrenOfType<UserTrackingScrollContainer>().Single();
141-
float sectionPosition = scrollContainer.GetChildPosInContent(container.Children[scrollIndex]);
141+
double sectionPosition = scrollContainer.GetChildPosInContent(container.Children[scrollIndex]);
142142
return scrollContainer.Current < sectionPosition;
143143
});
144144
}

osu.Game/Graphics/Containers/OsuScrollContainer.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ public OsuScrollContainer(Direction scrollDirection = Direction.Vertical)
5959
/// <param name="extraScroll">An added amount to scroll beyond the requirement to bring the target into view.</param>
6060
public void ScrollIntoView(Drawable d, bool animated = true, float extraScroll = 0)
6161
{
62-
float childPos0 = GetChildPosInContent(d);
63-
float childPos1 = GetChildPosInContent(d, d.DrawSize);
62+
double childPos0 = GetChildPosInContent(d);
63+
double childPos1 = GetChildPosInContent(d, d.DrawSize);
6464

65-
float minPos = Math.Min(childPos0, childPos1);
66-
float maxPos = Math.Max(childPos0, childPos1);
65+
double minPos = Math.Min(childPos0, childPos1);
66+
double maxPos = Math.Max(childPos0, childPos1);
6767

6868
if (minPos < Current || (minPos > Current && d.DrawSize[ScrollDim] > DisplayableContent))
6969
ScrollTo(minPos - extraScroll, animated);

osu.Game/Graphics/Containers/SectionsContainer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public void ScrollTo(Drawable target)
208208
private float getScrollTargetForDrawable(Drawable target)
209209
{
210210
// implementation similar to ScrollIntoView but a bit more nuanced.
211-
return scrollContainer.GetChildPosInContent(target) - scrollContainer.DisplayableContent * scroll_y_centre;
211+
return (float)(scrollContainer.GetChildPosInContent(target) - scrollContainer.DisplayableContent * scroll_y_centre);
212212
}
213213

214214
public void ScrollToTop() => scrollContainer.ScrollTo(0);
@@ -259,7 +259,7 @@ protected override void UpdateAfterChildren()
259259
updateSectionsMargin();
260260
}
261261

262-
float currentScroll = scrollContainer.Current;
262+
float currentScroll = (float)scrollContainer.Current;
263263

264264
if (currentScroll != lastKnownScroll)
265265
{

osu.Game/Graphics/Containers/UserTrackingScrollContainer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public UserTrackingScrollContainer(Direction direction)
3535
{
3636
}
3737

38-
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default)
38+
protected override void OnUserScroll(double value, bool animated = true, double? distanceDecay = default)
3939
{
4040
UserScrolling = true;
4141
base.OnUserScroll(value, animated, distanceDecay);
@@ -53,7 +53,7 @@ protected override void ScrollFromMouseEvent(MouseEvent e)
5353
base.ScrollFromMouseEvent(e);
5454
}
5555

56-
public new void ScrollTo(float value, bool animated = true, double? distanceDecay = null)
56+
public new void ScrollTo(double value, bool animated = true, double? distanceDecay = null)
5757
{
5858
UserScrolling = false;
5959
base.ScrollTo(value, animated, distanceDecay);
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
22
// See the LICENCE file in the repository root for full licence text.
33

4+
using osu.Framework.Input;
5+
46
namespace osu.Game.Graphics.UserInterface
57
{
68
public partial class OsuNumberBox : OsuTextBox
79
{
8-
protected override bool AllowIme => false;
9-
1010
public OsuNumberBox()
1111
{
12+
InputProperties = new TextInputProperties(TextInputType.Number, false);
13+
1214
SelectAllOnFocus = true;
1315
}
14-
15-
protected override bool CanAddCharacter(char character) => char.IsAsciiDigit(character);
1616
}
1717
}

osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace osu.Game.Graphics.UserInterface
2020
{
21-
public partial class OsuPasswordTextBox : OsuTextBox, ISuppressKeyEventLogging
21+
public partial class OsuPasswordTextBox : OsuTextBox
2222
{
2323
protected override Drawable GetDrawableCharacter(char c) => new FallingDownContainer
2424
{
@@ -28,19 +28,15 @@ public partial class OsuPasswordTextBox : OsuTextBox, ISuppressKeyEventLogging
2828

2929
protected override bool AllowUniqueCharacterSamples => false;
3030

31-
protected override bool AllowClipboardExport => false;
32-
33-
protected override bool AllowWordNavigation => false;
34-
35-
protected override bool AllowIme => false;
36-
3731
private readonly CapsWarning warning;
3832

3933
[Resolved]
4034
private GameHost host { get; set; } = null!;
4135

4236
public OsuPasswordTextBox()
4337
{
38+
InputProperties = new TextInputProperties(TextInputType.Password, false);
39+
4440
Add(warning = new CapsWarning
4541
{
4642
Size = new Vector2(20),

osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// See the LICENCE file in the repository root for full licence text.
33

44
using System.Globalization;
5+
using osu.Framework.Input;
56

67
namespace osu.Game.Graphics.UserInterfaceV2
78
{
@@ -19,6 +20,11 @@ internal partial class InnerNumberBox : InnerTextBox
1920
{
2021
public bool AllowDecimals { get; init; }
2122

23+
public InnerNumberBox()
24+
{
25+
InputProperties = new TextInputProperties(TextInputType.Number, false);
26+
}
27+
2228
protected override bool CanAddCharacter(char character)
2329
=> char.IsAsciiDigit(character) || (AllowDecimals && CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(character));
2430
}

osu.Game/Online/Leaderboards/Leaderboard.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ protected override void UpdateAfterChildren()
375375
{
376376
base.UpdateAfterChildren();
377377

378-
float fadeBottom = scrollContainer.Current + scrollContainer.DrawHeight;
379-
float fadeTop = scrollContainer.Current + LeaderboardScore.HEIGHT;
378+
float fadeBottom = (float)(scrollContainer.Current + scrollContainer.DrawHeight);
379+
float fadeTop = (float)(scrollContainer.Current + LeaderboardScore.HEIGHT);
380380

381381
if (!scrollContainer.IsScrolledToEnd())
382382
fadeBottom -= LeaderboardScore.HEIGHT;

osu.Game/Overlays/Chat/ChannelScrollContainer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ protected override void UpdateAfterChildren()
4141

4242
#region Scroll handling
4343

44-
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = null)
44+
protected override void OnUserScroll(double value, bool animated = true, double? distanceDecay = null)
4545
{
4646
base.OnUserScroll(value, animated, distanceDecay);
4747
updateTrackState();
4848
}
4949

50-
public new void ScrollTo(float value, bool animated = true, double? distanceDecay = null)
50+
public new void ScrollTo(double value, bool animated = true, double? distanceDecay = null)
5151
{
5252
base.ScrollTo(value, animated, distanceDecay);
5353
updateTrackState();

osu.Game/Overlays/Chat/DrawableChannel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private void processMessageHighlighting() => SchedulerAfterChildren.AddOnce(() =
117117
if (chatLine == null)
118118
return;
119119

120-
float center = scroll.GetChildPosInContent(chatLine, chatLine.DrawSize / 2) - scroll.DisplayableContent / 2;
120+
double center = scroll.GetChildPosInContent(chatLine, chatLine.DrawSize / 2) - scroll.DisplayableContent / 2;
121121
scroll.ScrollTo(Math.Clamp(center, 0, scroll.ScrollableExtent));
122122
chatLine.Highlight();
123123

osu.Game/Overlays/Login/LoginForm.cs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using osu.Framework.Graphics;
88
using osu.Framework.Graphics.Containers;
99
using osu.Framework.Graphics.UserInterface;
10+
using osu.Framework.Input;
1011
using osu.Framework.Input.Events;
1112
using osu.Game.Configuration;
1213
using osu.Game.Graphics;
@@ -63,6 +64,7 @@ private void load(OsuConfigManager config, AccountCreationOverlay accountCreatio
6364
},
6465
username = new OsuTextBox
6566
{
67+
InputProperties = new TextInputProperties(TextInputType.Username, false),
6668
PlaceholderText = UsersStrings.LoginUsername.ToLower(),
6769
RelativeSizeAxes = Axes.X,
6870
Text = api.ProvidedUsername,

osu.Game/Overlays/Mods/ModSelectOverlay.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -710,13 +710,13 @@ protected override void Update()
710710

711711
// the bounds below represent the horizontal range of scroll items to be considered fully visible/active, in the scroll's internal coordinate space.
712712
// note that clamping is applied to the left scroll bound to ensure scrolling past extents does not change the set of active columns.
713-
float leftVisibleBound = Math.Clamp(Current, 0, ScrollableExtent);
714-
float rightVisibleBound = leftVisibleBound + DrawWidth;
713+
double leftVisibleBound = Math.Clamp(Current, 0, ScrollableExtent);
714+
double rightVisibleBound = leftVisibleBound + DrawWidth;
715715

716716
// if a movement is occurring at this time, the bounds below represent the full range of columns that the scroll movement will encompass.
717717
// this will be used to ensure that columns do not change state from active to inactive back and forth until they are fully scrolled past.
718-
float leftMovementBound = Math.Min(Current, Target);
719-
float rightMovementBound = Math.Max(Current, Target) + DrawWidth;
718+
double leftMovementBound = Math.Min(Current, Target);
719+
double rightMovementBound = Math.Max(Current, Target) + DrawWidth;
720720

721721
foreach (var column in Child)
722722
{

osu.Game/Overlays/NewsOverlay.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected override void UpdateAfterChildren()
136136
{
137137
base.UpdateAfterChildren();
138138
sidebarContainer.Height = DrawHeight;
139-
sidebarContainer.Y = Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
139+
sidebarContainer.Y = (float)Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
140140
}
141141

142142
private void loadListing(int? year = null)

osu.Game/Overlays/OnlineOverlay.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected override void UpdateAfterChildren()
8888
base.UpdateAfterChildren();
8989

9090
// don't block header by applying padding equal to the visible header height
91-
loadingContainer.Padding = new MarginPadding { Top = Math.Max(0, Header.Height - ScrollFlow.Current) };
91+
loadingContainer.Padding = new MarginPadding { Top = (float)Math.Max(0, Header.Height - ScrollFlow.Current) };
9292
}
9393
}
9494
}

osu.Game/Overlays/OverlayScrollContainer.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public partial class OverlayScrollContainer : UserTrackingScrollContainer
3535

3636
public ScrollBackButton Button { get; private set; }
3737

38-
private readonly Bindable<float?> lastScrollTarget = new Bindable<float?>();
38+
private readonly Bindable<double?> lastScrollTarget = new Bindable<double?>();
3939

4040
[BackgroundDependencyLoader]
4141
private void load()
@@ -63,7 +63,7 @@ protected override void UpdateAfterChildren()
6363
Button.State = Target > button_scroll_position || lastScrollTarget.Value != null ? Visibility.Visible : Visibility.Hidden;
6464
}
6565

66-
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default)
66+
protected override void OnUserScroll(double value, bool animated = true, double? distanceDecay = default)
6767
{
6868
base.OnUserScroll(value, animated, distanceDecay);
6969

@@ -112,7 +112,7 @@ public Visibility State
112112
private readonly Box background;
113113
private readonly SpriteIcon spriteIcon;
114114

115-
public Bindable<float?> LastScrollTarget = new Bindable<float?>();
115+
public Bindable<double?> LastScrollTarget = new Bindable<double?>();
116116

117117
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
118118

osu.Game/Overlays/Settings/SettingsNumberBox.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using osu.Framework.Graphics;
66
using osu.Framework.Graphics.Containers;
77
using osu.Framework.Graphics.UserInterface;
8+
using osu.Framework.Input;
89

910
namespace osu.Game.Overlays.Settings
1011
{
@@ -66,7 +67,10 @@ public NumberControl()
6667

6768
private partial class OutlinedNumberBox : OutlinedTextBox
6869
{
69-
protected override bool AllowIme => false;
70+
public OutlinedNumberBox()
71+
{
72+
InputProperties = new TextInputProperties(TextInputType.Number, false);
73+
}
7074

7175
protected override bool CanAddCharacter(char character) => char.IsAsciiDigit(character);
7276

osu.Game/Overlays/WikiOverlay.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected override void UpdateAfterChildren()
100100
if (articlePage != null)
101101
{
102102
articlePage.SidebarContainer.Height = DrawHeight;
103-
articlePage.SidebarContainer.Y = Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
103+
articlePage.SidebarContainer.Y = (float)Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
104104
}
105105
}
106106

osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public bool AlwaysShowControlPoints
5555
/// <summary>
5656
/// The timeline's scroll position in the last frame.
5757
/// </summary>
58-
private float lastScrollPosition;
58+
private double lastScrollPosition;
5959

6060
/// <summary>
6161
/// The track time in the last frame.
@@ -322,7 +322,7 @@ private void endUserDrag()
322322
/// </summary>
323323
public double VisibleRange => editorClock.TrackLength / Zoom;
324324

325-
public double TimeAtPosition(float x)
325+
public double TimeAtPosition(double x)
326326
{
327327
return x / Content.DrawWidth * editorClock.TrackLength;
328328
}

osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private void setZoomTarget(float newZoom, float? focusPoint = null)
182182
}
183183

184184
private void transformZoomTo(float newZoom, float focusPoint, double duration = 0, Easing easing = Easing.None)
185-
=> this.TransformTo(this.PopulateTransform(new TransformZoom(focusPoint, zoomedContent.DrawWidth, Current), newZoom, duration, easing));
185+
=> this.TransformTo(this.PopulateTransform(new TransformZoom(focusPoint, zoomedContent.DrawWidth, (float)Current), newZoom, duration, easing));
186186

187187
/// <summary>
188188
/// Invoked when <see cref="Zoom"/> has changed.

osu.Game/Screens/Edit/Setup/MetadataSection.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using osu.Framework.Allocation;
66
using osu.Framework.Graphics.UserInterface;
7+
using osu.Framework.Input;
78
using osu.Framework.Localisation;
89
using osu.Game.Beatmaps;
910
using osu.Game.Graphics.UserInterfaceV2;
@@ -136,7 +137,10 @@ private partial class FormRomanisedTextBox : FormTextBox
136137

137138
private partial class RomanisedTextBox : InnerTextBox
138139
{
139-
protected override bool AllowIme => false;
140+
public RomanisedTextBox()
141+
{
142+
InputProperties = new TextInputProperties(TextInputType.Text, false);
143+
}
140144

141145
protected override bool CanAddCharacter(char character)
142146
=> MetadataUtils.IsRomanised(character);

osu.Game/Screens/Play/HUD/GameplayLeaderboard.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ protected override void Update()
114114

115115
if (requiresScroll && TrackedScore != null)
116116
{
117-
float scrollTarget = scroll.GetChildPosInContent(TrackedScore) + TrackedScore.DrawHeight / 2 - scroll.DrawHeight / 2;
117+
double scrollTarget = scroll.GetChildPosInContent(TrackedScore) + TrackedScore.DrawHeight / 2 - scroll.DrawHeight / 2;
118118

119119
scroll.ScrollTo(scrollTarget);
120120
}
121121

122122
const float panel_height = GameplayLeaderboardScore.PANEL_HEIGHT;
123123

124-
float fadeBottom = scroll.Current + scroll.DrawHeight;
125-
float fadeTop = scroll.Current + panel_height;
124+
float fadeBottom = (float)(scroll.Current + scroll.DrawHeight);
125+
float fadeTop = (float)(scroll.Current + panel_height);
126126

127127
if (scroll.IsScrolledToStart()) fadeTop -= panel_height;
128128
if (!scroll.IsScrolledToEnd()) fadeBottom -= panel_height;

osu.Game/Screens/Ranking/ScorePanelList.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private IEnumerable<ScorePanelTrackingContainer> applySorting(IEnumerable<Drawab
334334

335335
private partial class Scroll : OsuScrollContainer
336336
{
337-
public new float Target => base.Target;
337+
public new double Target => base.Target;
338338

339339
public Scroll()
340340
: base(Direction.Horizontal)
@@ -344,7 +344,7 @@ public Scroll()
344344
/// <summary>
345345
/// The target that will be scrolled to instantaneously next frame.
346346
/// </summary>
347-
public float? InstantScrollTarget;
347+
public double? InstantScrollTarget;
348348

349349
protected override void UpdateAfterChildren()
350350
{

0 commit comments

Comments
 (0)