Skip to content

Commit

Permalink
Merge pull request #30109 from bdach/editor/setup-screen-better-backg…
Browse files Browse the repository at this point in the history
…round-selector

Move setup screen background preview to appropriate form control
  • Loading branch information
peppy authored Oct 4, 2024
2 parents 2914a5b + 7cd724f commit 24227b4
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 41 deletions.
20 changes: 18 additions & 2 deletions osu.Game/Graphics/UserInterfaceV2/FormFileSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public Bindable<FileInfo?> Current
/// </summary>
public LocalisableString PlaceholderText { get; init; }

public Container PreviewContainer { get; private set; } = null!;

private Box background = null!;

private FormFieldCaption caption = null!;
Expand All @@ -89,7 +91,7 @@ public FormFileSelector(params string[] handledExtensions)
private void load()
{
RelativeSizeAxes = Axes.X;
Height = 50;
AutoSizeAxes = Axes.Y;

Masking = true;
CornerRadius = 5;
Expand All @@ -101,9 +103,23 @@ private void load()
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background5,
},
PreviewContainer = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding
{
Horizontal = 1.5f,
Top = 1.5f,
Bottom = 50
},
},
new Container
{
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
Height = 50,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Padding = new MarginPadding(9),
Children = new Drawable[]
{
Expand Down
11 changes: 9 additions & 2 deletions osu.Game/Screens/Edit/Setup/ResourcesSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ public partial class ResourcesSection : SetupSection
[Resolved]
private Editor? editor { get; set; }

[Resolved]
private SetupScreenHeaderBackground headerBackground { get; set; } = null!;
private SetupScreenHeaderBackground headerBackground = null!;

[BackgroundDependencyLoader]
private void load()
{
headerBackground = new SetupScreenHeaderBackground
{
RelativeSizeAxes = Axes.X,
Height = 110,
};

Children = new Drawable[]
{
backgroundChooser = new FormFileSelector(".jpg", ".jpeg", ".png")
Expand All @@ -55,6 +60,8 @@ private void load()
},
};

backgroundChooser.PreviewContainer.Add(headerBackground);

if (!string.IsNullOrEmpty(working.Value.Metadata.BackgroundFile))
backgroundChooser.Current.Value = new FileInfo(working.Value.Metadata.BackgroundFile);

Expand Down
50 changes: 14 additions & 36 deletions osu.Game/Screens/Edit/Setup/SetupScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ public SetupScreen()
{
}

[Cached]
private SetupScreenHeaderBackground background = new SetupScreenHeaderBackground { RelativeSizeAxes = Axes.Both, };

private OsuScrollContainer scroll = null!;
private FillFlowContainer flow = null!;

Expand All @@ -42,43 +39,24 @@ private void load(EditorBeatmap beatmap, OverlayColourProvider colourProvider)
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background3,
},
new GridContainer
scroll = new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
RowDimensions =
[
new Dimension(GridSizeMode.Absolute, 110),
new Dimension()
],
Content = new[]
Padding = new MarginPadding(15),
Child = flow = new FillFlowContainer
{
new Drawable[]
{
background,
},
new Drawable[]
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Full,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Spacing = new Vector2(25),
ChildrenEnumerable = ruleset.CreateEditorSetupSections().Select(section => section.With(s =>
{
scroll = new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(15),
Child = flow = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Full,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Spacing = new Vector2(25),
ChildrenEnumerable = ruleset.CreateEditorSetupSections().Select(section => section.With(s =>
{
s.Width = 450;
s.Anchor = Anchor.TopCentre;
s.Origin = Anchor.TopCentre;
})),
}
}
}
s.Width = 450;
s.Anchor = Anchor.TopCentre;
s.Origin = Anchor.TopCentre;
})),
}
}
};
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Screens/Edit/Setup/SetupScreenHeaderBackground.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public SetupScreenHeaderBackground()
InternalChild = content = new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true
Masking = true,
CornerRadius = 3.5f,
};
}

Expand Down

0 comments on commit 24227b4

Please sign in to comment.