mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 13:22:57 +08:00
Split out common implementation and private classes in MatchSettingsOverlay
This commit is contained in:
parent
27e64bdb34
commit
8201fa8e34
@ -109,14 +109,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddUntilStep("error not displayed", () => !settings.ErrorText.IsPresent);
|
||||
}
|
||||
|
||||
private class TestRoomSettings : MatchSettingsOverlay
|
||||
private class TestRoomSettings : TimeshiftMatchSettingsOverlay
|
||||
{
|
||||
public TriangleButton ApplyButton => Settings.ApplyButton;
|
||||
public TriangleButton ApplyButton => ((MatchSettings)Settings).ApplyButton;
|
||||
|
||||
public OsuTextBox NameField => Settings.NameField;
|
||||
public OsuDropdown<TimeSpan> DurationField => Settings.DurationField;
|
||||
public OsuTextBox NameField => ((MatchSettings)Settings).NameField;
|
||||
public OsuDropdown<TimeSpan> DurationField => ((MatchSettings)Settings).DurationField;
|
||||
|
||||
public OsuSpriteText ErrorText => Settings.ErrorText;
|
||||
public OsuSpriteText ErrorText => ((MatchSettings)Settings).ErrorText;
|
||||
}
|
||||
|
||||
private class TestRoomManager : IRoomManager
|
||||
|
@ -120,7 +120,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
AddStep("create room", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(match.ChildrenOfType<MatchSettingsOverlay.CreateRoomButton>().Single());
|
||||
InputManager.MoveMouseTo(match.ChildrenOfType<TimeshiftMatchSettingsOverlay.CreateRoomButton>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
|
@ -21,20 +21,108 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public class MatchSettingsOverlay : FocusedOverlayContainer
|
||||
public abstract class MatchSettingsOverlay : FocusedOverlayContainer
|
||||
{
|
||||
private const float transition_duration = 350;
|
||||
private const float field_padding = 45;
|
||||
protected const float TRANSITION_DURATION = 350;
|
||||
protected const float FIELD_PADDING = 45;
|
||||
|
||||
public Action EditPlaylist;
|
||||
|
||||
protected MatchSettings Settings { get; private set; }
|
||||
protected MultiplayerComposite Settings { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Masking = true;
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
Settings.MoveToY(0, TRANSITION_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
Settings.MoveToY(-1, TRANSITION_DURATION, Easing.InSine);
|
||||
}
|
||||
|
||||
protected class SettingsTextBox : OsuTextBox
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
BackgroundUnfocused = Color4.Black;
|
||||
BackgroundFocused = Color4.Black;
|
||||
}
|
||||
}
|
||||
|
||||
protected class SettingsNumberTextBox : SettingsTextBox
|
||||
{
|
||||
protected override bool CanAddCharacter(char character) => char.IsNumber(character);
|
||||
}
|
||||
|
||||
protected class SettingsPasswordTextBox : OsuPasswordTextBox
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
BackgroundUnfocused = Color4.Black;
|
||||
BackgroundFocused = Color4.Black;
|
||||
}
|
||||
}
|
||||
|
||||
protected class SectionContainer : FillFlowContainer<Section>
|
||||
{
|
||||
public SectionContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Width = 0.5f;
|
||||
Direction = FillDirection.Vertical;
|
||||
Spacing = new Vector2(FIELD_PADDING);
|
||||
}
|
||||
}
|
||||
|
||||
protected class Section : Container
|
||||
{
|
||||
private readonly Container content;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
public Section(string title)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12),
|
||||
Text = title.ToUpper(),
|
||||
},
|
||||
content = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TimeshiftMatchSettingsOverlay : MatchSettingsOverlay
|
||||
{
|
||||
public Action EditPlaylist;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Child = Settings = new MatchSettings
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -43,16 +131,6 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
};
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
Settings.MoveToY(0, transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
Settings.MoveToY(-1, transition_duration, Easing.InSine);
|
||||
}
|
||||
|
||||
protected class MatchSettings : MultiplayerComposite
|
||||
{
|
||||
private const float disabled_alpha = 0.2f;
|
||||
@ -126,7 +204,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
new SectionContainer
|
||||
{
|
||||
Padding = new MarginPadding { Right = field_padding / 2 },
|
||||
Padding = new MarginPadding { Right = FIELD_PADDING / 2 },
|
||||
Children = new[]
|
||||
{
|
||||
new Section("Room name")
|
||||
@ -216,7 +294,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Padding = new MarginPadding { Left = field_padding / 2 },
|
||||
Padding = new MarginPadding { Left = FIELD_PADDING / 2 },
|
||||
Children = new[]
|
||||
{
|
||||
new Section("Playlist")
|
||||
@ -379,77 +457,6 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
}
|
||||
}
|
||||
|
||||
private class SettingsTextBox : OsuTextBox
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
BackgroundUnfocused = Color4.Black;
|
||||
BackgroundFocused = Color4.Black;
|
||||
}
|
||||
}
|
||||
|
||||
private class SettingsNumberTextBox : SettingsTextBox
|
||||
{
|
||||
protected override bool CanAddCharacter(char character) => char.IsNumber(character);
|
||||
}
|
||||
|
||||
private class SettingsPasswordTextBox : OsuPasswordTextBox
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
BackgroundUnfocused = Color4.Black;
|
||||
BackgroundFocused = Color4.Black;
|
||||
}
|
||||
}
|
||||
|
||||
private class SectionContainer : FillFlowContainer<Section>
|
||||
{
|
||||
public SectionContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Width = 0.5f;
|
||||
Direction = FillDirection.Vertical;
|
||||
Spacing = new Vector2(field_padding);
|
||||
}
|
||||
}
|
||||
|
||||
private class Section : Container
|
||||
{
|
||||
private readonly Container content;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
public Section(string title)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12),
|
||||
Text = title.ToUpper(),
|
||||
},
|
||||
content = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class CreateRoomButton : TriangleButton
|
||||
{
|
||||
public CreateRoomButton()
|
||||
|
@ -19,22 +19,14 @@ using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Multi.Match.Components;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Match
|
||||
{
|
||||
public class RealtimeMatchSettingsOverlay : FocusedOverlayContainer
|
||||
public class RealtimeMatchSettingsOverlay : MatchSettingsOverlay
|
||||
{
|
||||
private const float transition_duration = 350;
|
||||
private const float field_padding = 45;
|
||||
|
||||
protected MatchSettings Settings { get; private set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Masking = true;
|
||||
|
||||
Child = Settings = new MatchSettings
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -43,16 +35,6 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Match
|
||||
};
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
Settings.MoveToY(0, transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
Settings.MoveToY(-1, transition_duration, Easing.InSine);
|
||||
}
|
||||
|
||||
protected class MatchSettings : MultiplayerComposite
|
||||
{
|
||||
private const float disabled_alpha = 0.2f;
|
||||
@ -143,7 +125,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Match
|
||||
{
|
||||
new SectionContainer
|
||||
{
|
||||
Padding = new MarginPadding { Right = field_padding / 2 },
|
||||
Padding = new MarginPadding { Right = FIELD_PADDING / 2 },
|
||||
Children = new[]
|
||||
{
|
||||
new Section("Room name")
|
||||
@ -192,7 +174,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Match
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Padding = new MarginPadding { Left = field_padding / 2 },
|
||||
Padding = new MarginPadding { Left = FIELD_PADDING / 2 },
|
||||
Children = new[]
|
||||
{
|
||||
new Section("Max participants")
|
||||
@ -347,77 +329,6 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Match
|
||||
}
|
||||
}
|
||||
|
||||
private class SettingsTextBox : OsuTextBox
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
BackgroundUnfocused = Color4.Black;
|
||||
BackgroundFocused = Color4.Black;
|
||||
}
|
||||
}
|
||||
|
||||
private class SettingsNumberTextBox : SettingsTextBox
|
||||
{
|
||||
protected override bool CanAddCharacter(char character) => char.IsNumber(character);
|
||||
}
|
||||
|
||||
private class SettingsPasswordTextBox : OsuPasswordTextBox
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
BackgroundUnfocused = Color4.Black;
|
||||
BackgroundFocused = Color4.Black;
|
||||
}
|
||||
}
|
||||
|
||||
private class SectionContainer : FillFlowContainer<Section>
|
||||
{
|
||||
public SectionContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Width = 0.5f;
|
||||
Direction = FillDirection.Vertical;
|
||||
Spacing = new Vector2(field_padding);
|
||||
}
|
||||
}
|
||||
|
||||
private class Section : Container
|
||||
{
|
||||
private readonly Container content;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
public Section(string title)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12),
|
||||
Text = title.ToUpper(),
|
||||
},
|
||||
content = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class CreateOrUpdateButton : TriangleButton
|
||||
{
|
||||
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
||||
|
@ -18,6 +18,7 @@ using osu.Game.Screens.Multi.Ranking;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Users;
|
||||
using Footer = osu.Game.Screens.Multi.Match.Components.Footer;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Timeshift
|
||||
{
|
||||
@ -175,7 +176,7 @@ namespace osu.Game.Screens.Multi.Timeshift
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
new Match.Components.Footer
|
||||
new Footer
|
||||
{
|
||||
OnStart = onStart,
|
||||
SelectedItem = { BindTarget = SelectedItem }
|
||||
@ -188,7 +189,7 @@ namespace osu.Game.Screens.Multi.Timeshift
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
}
|
||||
},
|
||||
settingsOverlay = new MatchSettingsOverlay
|
||||
settingsOverlay = new TimeshiftMatchSettingsOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
EditPlaylist = () => this.Push(new MatchSongSelect()),
|
||||
|
Loading…
Reference in New Issue
Block a user