1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 23:22:55 +08:00

Use depth to arrange buttons.

This commit is contained in:
Huo Yaoyuan 2017-03-14 20:18:14 +08:00
parent 618e8e822b
commit 35a60a8f7d
6 changed files with 20 additions and 30 deletions

View File

@ -1,10 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Screens.Edit;
namespace osu.Game.Screens.Select
@ -12,13 +9,5 @@ namespace osu.Game.Screens.Select
internal class EditSongSelect : SongSelect
{
protected override void OnSelected(WorkingBeatmap beatmap) => Push(new Editor(beatmap));
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2);
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, PromptDelete, Key.Number4);
}
}
}

View File

@ -36,13 +36,18 @@ namespace osu.Game.Screens.Select
public OsuLogo StartButton;
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null)
/// <param name="depth">
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
/// </param>
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
{
var button = new FooterButton
{
Text = text,
Height = play_song_select_button_height,
Width = play_song_select_button_width,
Depth = depth,
SelectedColour = colour,
DeselectedColour = colour.Opacity(0.5f),
Hotkey = hotkey,

View File

@ -1,23 +1,12 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
namespace osu.Game.Screens.Select
{
internal class MatchSongSelect : SongSelect
{
protected override void OnSelected(WorkingBeatmap beatmap) => Exit();
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2);
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, PromptDelete, Key.Number4);
}
}
}

View File

@ -86,7 +86,11 @@ namespace osu.Game.Screens.Select.Options
};
}
public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null)
/// <param name="depth">
/// <para>Lower depth to be put on the left, and higher to be put on the right.</para>
/// <para>Notice this is different to <see cref="Footer"/>!</para>
/// </param>
public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
{
buttonsContainer.Add(new BeatmapOptionsButton
{
@ -94,6 +98,7 @@ namespace osu.Game.Screens.Select.Options
SecondLineText = secongLine,
Icon = icon,
ButtonColour = colour,
Depth = depth,
Action = () =>
{
Hide();

View File

@ -29,14 +29,11 @@ namespace osu.Game.Screens.Select
Margin = new MarginPadding { Bottom = 50 }
});
Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1);
Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2);
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue);
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1);
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2);
BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, null, Key.Number3);
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, PromptDelete, Key.Number4);
}
protected override void OnBeatmapChanged(WorkingBeatmap beatmap)

View File

@ -146,6 +146,11 @@ namespace osu.Game.Screens.Select
},
};
Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2);
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue);
if (osu != null)
playMode.BindTo(osu.PlayMode);
playMode.ValueChanged += playMode_ValueChanged;
@ -404,7 +409,7 @@ namespace osu.Game.Screens.Select
}
}
protected void PromptDelete()
private void promptDelete()
{
if (Beatmap != null)
dialogOverlay?.Push(new BeatmapDeleteDialog(Beatmap));
@ -414,7 +419,7 @@ namespace osu.Game.Screens.Select
{
if (!args.Repeat && args.Key == Key.Delete && state.Keyboard.ShiftPressed)
{
PromptDelete();
promptDelete();
return true;
}