1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 23:42:55 +08:00

Applied suggested changes

This commit is contained in:
EVAST9919 2017-05-30 12:23:53 +03:00
parent 963d6e9e8f
commit e737ded382
10 changed files with 53 additions and 54 deletions

View File

@ -46,7 +46,7 @@ namespace osu.Desktop.VisualTests.Tests
}));
}
private class ExampleContainer : SettingsDropdownContainer
private class ExampleContainer : ReplaySettingsGroup
{
protected override string Title => @"example";
}

View File

@ -12,7 +12,7 @@ using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterface
{
public class SimpleButton : ClickableContainer
public class IconButton : ClickableContainer
{
private readonly TextAwesome icon;
private readonly Box hover;
@ -33,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface
set { icon.Scale = value; }
}
public SimpleButton()
public IconButton()
{
AutoSizeAxes = Axes.Both;

View File

@ -39,8 +39,8 @@ namespace osu.Game.Overlays
private Drawable currentBackground;
private DragBar progressBar;
private SimpleButton playButton;
private SimpleButton playlistButton;
private IconButton playButton;
private IconButton playlistButton;
private SpriteText title, artist;
@ -144,7 +144,7 @@ namespace osu.Game.Overlays
Anchor = Anchor.BottomCentre,
Children = new Drawable[]
{
new FillFlowContainer<SimpleButton>
new FillFlowContainer<IconButton>
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
@ -153,26 +153,26 @@ namespace osu.Game.Overlays
Anchor = Anchor.Centre,
Children = new[]
{
new SimpleButton
new IconButton
{
Action = prev,
Icon = FontAwesome.fa_step_backward,
},
playButton = new SimpleButton
playButton = new IconButton
{
Scale = new Vector2(1.4f),
IconScale = new Vector2(1.4f),
Action = play,
Icon = FontAwesome.fa_play_circle_o,
},
new SimpleButton
new IconButton
{
Action = next,
Icon = FontAwesome.fa_step_forward,
},
}
},
playlistButton = new SimpleButton
playlistButton = new IconButton
{
Origin = Anchor.Centre,
Anchor = Anchor.CentreRight,

View File

@ -33,6 +33,8 @@ namespace osu.Game.Screens.Play
public readonly ReplaySettingsOverlay ReplaySettingsOverlay;
private Bindable<bool> showHud;
private bool replaySettingsIsVisible;
private bool replayLoaded;
private static bool hasShownNotificationOnce;
@ -97,8 +99,10 @@ namespace osu.Game.Screens.Play
{
hitRenderer.InputManager.Add(KeyCounter.GetReceptor());
replayLoaded = hitRenderer.HasReplayLoaded;
// in the case a replay isn't loaded, we want some elements to only appear briefly.
if (!hitRenderer.HasReplayLoaded)
if (!replayLoaded)
{
ReplaySettingsOverlay.Hide();
ReplaySettingsOverlay.AlwaysPresent = false;
@ -122,6 +126,18 @@ namespace osu.Game.Screens.Play
}
}
switch (args.Key)
{
case Key.H:
if (replayLoaded)
{
ReplaySettingsOverlay.FadeTo(replaySettingsIsVisible ? 1 : 0, duration);
replaySettingsIsVisible = !replaySettingsIsVisible;
return true;
}
else return false;
}
return base.OnKeyDown(state, args);
}
}

View File

@ -10,7 +10,7 @@ using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Play.ReplaySettings
{
public class CollectionSettings : SettingsDropdownContainer
public class CollectionSettings : ReplaySettingsGroup
{
protected override string Title => @"collections";

View File

@ -8,7 +8,7 @@ using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Play.ReplaySettings
{
public class DiscussionSettings : SettingsDropdownContainer
public class DiscussionSettings : ReplaySettingsGroup
{
protected override string Title => @"discussions";
@ -19,7 +19,7 @@ namespace osu.Game.Screens.Play.ReplaySettings
{
new ReplaySettingsCheckbox
{
LabelText = "Show floating coments",
LabelText = "Show floating comments",
Bindable = config.GetBindable<bool>(OsuSetting.FloatingComments)
},
new FocusedTextBox

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics;
namespace osu.Game.Screens.Play.ReplaySettings
{
public class PlaybackSettings : SettingsDropdownContainer
public class PlaybackSettings : ReplaySettingsGroup
{
protected override string Title => @"playback";

View File

@ -7,14 +7,16 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterface
namespace osu.Game.Screens.Play.ReplaySettings
{
public abstract class SettingsDropdownContainer : Container
public abstract class ReplaySettingsGroup : Container
{
/// <summary>
/// The title of this container, which will be written in header.
/// The title to be displayed in the header of this group.
/// </summary>
protected abstract string Title { get; }
@ -24,14 +26,13 @@ namespace osu.Game.Graphics.UserInterface
private const int header_height = 30;
private const int corner_radius = 5;
private FillFlowContainer content;
private SimpleButton button;
private bool buttonIsActive;
private readonly FillFlowContainer content;
private readonly IconButton button;
private bool expanded;
private Color4 buttonActiveColour;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
public ReplaySettingsGroup()
{
AutoSizeAxes = Axes.Y;
Width = container_width;
@ -53,7 +54,6 @@ namespace osu.Game.Graphics.UserInterface
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new Container
@ -63,7 +63,6 @@ namespace osu.Game.Graphics.UserInterface
Anchor = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Height = header_height,
Children = new Drawable[]
{
new OsuSpriteText
@ -75,14 +74,13 @@ namespace osu.Game.Graphics.UserInterface
Font = @"Exo2.0-Bold",
Margin = new MarginPadding { Left = 10 },
},
button = new SimpleButton
button = new IconButton
{
Origin = Anchor.Centre,
Anchor = Anchor.CentreRight,
Position = new Vector2(-15,0),
Icon = FontAwesome.fa_bars,
Scale = new Vector2(0.75f),
Colour = buttonActiveColour = colours.Yellow,
Action = triggerContentVisibility,
},
}
@ -105,19 +103,25 @@ namespace osu.Game.Graphics.UserInterface
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
button.Colour = buttonActiveColour = colours.Yellow;
}
protected override Container<Drawable> Content => content;
private void triggerContentVisibility()
{
content.ClearTransforms();
content.AutoSizeAxes = buttonIsActive ? Axes.Y : Axes.None;
content.AutoSizeAxes = expanded ? Axes.Y : Axes.None;
if (!buttonIsActive)
if (!expanded)
content.ResizeHeightTo(0, transition_duration, EasingTypes.OutQuint);
button.FadeColour(buttonIsActive ? buttonActiveColour : Color4.White, 200, EasingTypes.OutQuint);
button.FadeColour(expanded ? buttonActiveColour : Color4.White, 200, EasingTypes.OutQuint);
buttonIsActive = !buttonIsActive;
expanded = !expanded;
}
}
}

View File

@ -2,19 +2,13 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using OpenTK.Input;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
namespace osu.Game.Screens.Play.ReplaySettings
{
public class ReplaySettingsOverlay : FillFlowContainer
{
private const int fade_duration = 100;
private bool isVisible;
public ReplaySettingsOverlay()
{
AlwaysPresent = true;
@ -26,20 +20,5 @@ namespace osu.Game.Screens.Play.ReplaySettings
Add(new DiscussionSettings());
Add(new PlaybackSettings());
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat) return false;
switch (args.Key)
{
case Key.H:
FadeTo(isVisible ? 1 : 0, fade_duration);
isVisible = !isVisible;
return true;
}
return base.OnKeyDown(state, args);
}
}
}

View File

@ -74,7 +74,7 @@
<Compile Include="Audio\SampleInfoList.cs" />
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
<Compile Include="Graphics\UserInterface\SimpleButton.cs" />
<Compile Include="Graphics\UserInterface\IconButton.cs" />
<Compile Include="Online\API\Requests\PostMessageRequest.cs" />
<Compile Include="Online\Chat\ErrorMessage.cs" />
<Compile Include="Overlays\Chat\ChatTabControl.cs" />
@ -243,7 +243,7 @@
<Compile Include="Screens\Play\HotkeyRetryOverlay.cs" />
<Compile Include="Screens\Play\ReplaySettings\CollectionSettings.cs" />
<Compile Include="Screens\Play\ReplaySettings\DiscussionSettings.cs" />
<Compile Include="Graphics\UserInterface\SettingsDropdownContainer.cs" />
<Compile Include="Screens\Play\ReplaySettings\ReplaySettingsGroup.cs" />
<Compile Include="Screens\Play\ReplaySettings\ReplaySettingsOverlay.cs" />
<Compile Include="Screens\Play\ReplaySettings\ReplaySettingsSliderBar.cs" />
<Compile Include="Screens\Play\ReplaySettings\PlaybackSettings.cs" />