mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge remote-tracking branch 'upstream/master' into ekrctb-fix-volme-meter
This commit is contained in:
@ -6,16 +6,16 @@ using System.Linq;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Input;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Overlays.Dialog
|
||||
{
|
||||
@ -23,6 +23,9 @@ namespace osu.Game.Overlays.Dialog
|
||||
{
|
||||
public static readonly float ENTER_DURATION = 500;
|
||||
public static readonly float EXIT_DURATION = 200;
|
||||
|
||||
protected override bool BlockPassThroughMouse => false;
|
||||
|
||||
private readonly Vector2 ringSize = new Vector2(100f);
|
||||
private readonly Vector2 ringMinifiedSize = new Vector2(20f);
|
||||
private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f);
|
||||
@ -34,26 +37,28 @@ namespace osu.Game.Overlays.Dialog
|
||||
private readonly SpriteText header;
|
||||
private readonly TextFlowContainer body;
|
||||
|
||||
private bool actionInvoked;
|
||||
|
||||
public FontAwesome Icon
|
||||
{
|
||||
get { return icon.Icon; }
|
||||
set { icon.Icon = value; }
|
||||
get => icon.Icon;
|
||||
set => icon.Icon = value;
|
||||
}
|
||||
|
||||
public string HeaderText
|
||||
{
|
||||
get { return header.Text; }
|
||||
set { header.Text = value; }
|
||||
get => header.Text;
|
||||
set => header.Text = value;
|
||||
}
|
||||
|
||||
public string BodyText
|
||||
{
|
||||
set { body.Text = value; }
|
||||
set => body.Text = value;
|
||||
}
|
||||
|
||||
public IEnumerable<PopupDialogButton> Buttons
|
||||
{
|
||||
get { return buttonsContainer.Children; }
|
||||
get => buttonsContainer.Children;
|
||||
set
|
||||
{
|
||||
buttonsContainer.ChildrenEnumerable = value;
|
||||
@ -62,71 +67,17 @@ namespace osu.Game.Overlays.Dialog
|
||||
var action = b.Action;
|
||||
b.Action = () =>
|
||||
{
|
||||
Hide();
|
||||
if (actionInvoked) return;
|
||||
|
||||
actionInvoked = true;
|
||||
action?.Invoke();
|
||||
|
||||
Hide();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void pressButtonAtIndex(int index)
|
||||
{
|
||||
if (index < Buttons.Count())
|
||||
Buttons.Skip(index).First().TriggerOnClick();
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Repeat) return false;
|
||||
|
||||
if (args.Key == Key.Enter || args.Key == Key.KeypadEnter)
|
||||
{
|
||||
Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.TriggerOnClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
// press button at number if 1-9 on number row or keypad are pressed
|
||||
var k = args.Key;
|
||||
if (k >= Key.Number1 && k <= Key.Number9)
|
||||
{
|
||||
pressButtonAtIndex(k - Key.Number1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (k >= Key.Keypad1 && k <= Key.Keypad9)
|
||||
{
|
||||
pressButtonAtIndex(k - Key.Keypad1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
base.PopIn();
|
||||
|
||||
// Reset various animations but only if the dialog animation fully completed
|
||||
if (content.Alpha == 0)
|
||||
{
|
||||
buttonsContainer.TransformSpacingTo(buttonsEnterSpacing);
|
||||
buttonsContainer.MoveToY(buttonsEnterSpacing.Y);
|
||||
ring.ResizeTo(ringMinifiedSize);
|
||||
}
|
||||
|
||||
content.FadeIn(ENTER_DURATION, Easing.OutQuint);
|
||||
ring.ResizeTo(ringSize, ENTER_DURATION, Easing.OutQuint);
|
||||
buttonsContainer.TransformSpacingTo(Vector2.Zero, ENTER_DURATION, Easing.OutQuint);
|
||||
buttonsContainer.MoveToY(0, ENTER_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
base.PopOut();
|
||||
|
||||
content.FadeOut(EXIT_DURATION, Easing.InSine);
|
||||
}
|
||||
|
||||
public PopupDialog()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
@ -136,9 +87,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Width = 0.4f,
|
||||
Alpha = 0f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -243,5 +191,69 @@ namespace osu.Game.Overlays.Dialog
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Repeat) return false;
|
||||
|
||||
if (args.Key == Key.Enter || args.Key == Key.KeypadEnter)
|
||||
{
|
||||
Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.TriggerOnClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
// press button at number if 1-9 on number row or keypad are pressed
|
||||
var k = args.Key;
|
||||
if (k >= Key.Number1 && k <= Key.Number9)
|
||||
{
|
||||
pressButtonAtIndex(k - Key.Number1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (k >= Key.Keypad1 && k <= Key.Keypad9)
|
||||
{
|
||||
pressButtonAtIndex(k - Key.Keypad1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
base.PopIn();
|
||||
|
||||
actionInvoked = false;
|
||||
|
||||
// Reset various animations but only if the dialog animation fully completed
|
||||
if (content.Alpha == 0)
|
||||
{
|
||||
buttonsContainer.TransformSpacingTo(buttonsEnterSpacing);
|
||||
buttonsContainer.MoveToY(buttonsEnterSpacing.Y);
|
||||
ring.ResizeTo(ringMinifiedSize);
|
||||
}
|
||||
|
||||
content.FadeIn(ENTER_DURATION, Easing.OutQuint);
|
||||
ring.ResizeTo(ringSize, ENTER_DURATION, Easing.OutQuint);
|
||||
buttonsContainer.TransformSpacingTo(Vector2.Zero, ENTER_DURATION, Easing.OutQuint);
|
||||
buttonsContainer.MoveToY(0, ENTER_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
if (!actionInvoked)
|
||||
// In the case a user did not choose an action before a hide was triggered, press the last button.
|
||||
// This is presumed to always be a sane default "cancel" action.
|
||||
buttonsContainer.Last().TriggerOnClick();
|
||||
|
||||
base.PopOut();
|
||||
content.FadeOut(EXIT_DURATION, Easing.InSine);
|
||||
}
|
||||
|
||||
private void pressButtonAtIndex(int index)
|
||||
{
|
||||
if (index < Buttons.Count())
|
||||
Buttons.Skip(index).First().TriggerOnClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
@ -16,6 +13,20 @@ namespace osu.Game.Overlays
|
||||
private readonly Container dialogContainer;
|
||||
private PopupDialog currentDialog;
|
||||
|
||||
public DialogOverlay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Child = dialogContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
|
||||
Width = 0.4f;
|
||||
Anchor = Anchor.BottomCentre;
|
||||
Origin = Anchor.BottomCentre;
|
||||
}
|
||||
|
||||
public void Push(PopupDialog dialog)
|
||||
{
|
||||
if (dialog == currentDialog) return;
|
||||
@ -30,6 +41,10 @@ namespace osu.Game.Overlays
|
||||
State = Visibility.Visible;
|
||||
}
|
||||
|
||||
protected override bool PlaySamplesOnStateChange => false;
|
||||
|
||||
protected override bool BlockPassThroughKeyboard => true;
|
||||
|
||||
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
|
||||
{
|
||||
if (v != Visibility.Hidden) return;
|
||||
@ -50,32 +65,14 @@ namespace osu.Game.Overlays
|
||||
protected override void PopOut()
|
||||
{
|
||||
base.PopOut();
|
||||
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
|
||||
}
|
||||
|
||||
public DialogOverlay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
if (currentDialog?.State == Visibility.Visible)
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black.Opacity(0.5f),
|
||||
},
|
||||
},
|
||||
},
|
||||
dialogContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
};
|
||||
currentDialog.Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,15 +35,13 @@ namespace osu.Game.Overlays.Direct
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame game, RulesetStore rulesets, OsuColour colours)
|
||||
private void load(RulesetStore rulesets, OsuColour colours, Bindable<RulesetInfo> ruleset)
|
||||
{
|
||||
DisplayStyleControl.Dropdown.AccentColour = colours.BlueDark;
|
||||
|
||||
Ruleset.Value = game?.Ruleset.Value ?? rulesets.GetRuleset(0);
|
||||
Ruleset.Value = ruleset ?? rulesets.GetRuleset(0);
|
||||
foreach (var r in rulesets.AvailableRulesets)
|
||||
{
|
||||
modeButtons.Add(new RulesetToggleButton(Ruleset, r));
|
||||
}
|
||||
}
|
||||
|
||||
private class RulesetToggleButton : OsuClickableContainer
|
||||
|
@ -202,9 +202,6 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Escape:
|
||||
finalise();
|
||||
return true;
|
||||
case Key.Delete:
|
||||
{
|
||||
if (state.Keyboard.ShiftPressed)
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>();
|
||||
|
||||
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
public readonly IBindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private void rulesetChanged(RulesetInfo newRuleset)
|
||||
{
|
||||
@ -51,8 +51,8 @@ namespace osu.Game.Overlays.Mods
|
||||
refreshSelectedMods();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuColour colours, OsuGame osu, RulesetStore rulesets, AudioManager audio)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, IBindable<RulesetInfo> ruleset, AudioManager audio)
|
||||
{
|
||||
SelectedMods.ValueChanged += selectedModsChanged;
|
||||
|
||||
@ -60,13 +60,8 @@ namespace osu.Game.Overlays.Mods
|
||||
HighMultiplierColour = colours.Green;
|
||||
UnrankedLabel.Colour = colours.Blue;
|
||||
|
||||
if (osu != null)
|
||||
Ruleset.BindTo(osu.Ruleset);
|
||||
else
|
||||
Ruleset.Value = rulesets.AvailableRulesets.First();
|
||||
|
||||
Ruleset.ValueChanged += rulesetChanged;
|
||||
Ruleset.TriggerChange();
|
||||
Ruleset.BindTo(ruleset);
|
||||
Ruleset.BindValueChanged(rulesetChanged, true);
|
||||
|
||||
sampleOn = audio.Sample.Get(@"UI/check-on");
|
||||
sampleOff = audio.Sample.Get(@"UI/check-off");
|
||||
|
20
osu.Game/Overlays/Profile/Components/DrawableJoinDate.cs
Normal file
20
osu.Game/Overlays/Profile/Components/DrawableJoinDate.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Components
|
||||
{
|
||||
public class DrawableJoinDate : DrawableDate
|
||||
{
|
||||
public DrawableJoinDate(DateTimeOffset date)
|
||||
: base(date)
|
||||
{
|
||||
}
|
||||
|
||||
protected override string Format() => Text = Date.ToUniversalTime().Year < 2008 ? "Here since the beginning" : $"{Date:MMMM yyyy}";
|
||||
|
||||
public override string TooltipText => $"{Date:MMMM d, yyyy}";
|
||||
}
|
||||
}
|
50
osu.Game/Overlays/Profile/Components/GradeBadge.cs
Normal file
50
osu.Game/Overlays/Profile/Components/GradeBadge.cs
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Components
|
||||
{
|
||||
public class GradeBadge : Container
|
||||
{
|
||||
private const float width = 50;
|
||||
private readonly string grade;
|
||||
private readonly Sprite badge;
|
||||
private readonly SpriteText numberText;
|
||||
|
||||
public int DisplayCount
|
||||
{
|
||||
set => numberText.Text = value.ToString(@"#,0");
|
||||
}
|
||||
|
||||
public GradeBadge(string grade)
|
||||
{
|
||||
this.grade = grade;
|
||||
Width = width;
|
||||
Height = 41;
|
||||
Add(badge = new Sprite
|
||||
{
|
||||
Width = width,
|
||||
Height = 26
|
||||
});
|
||||
Add(numberText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold"
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
badge.Texture = textures.Get($"Grades/{grade}");
|
||||
}
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Profile.Components;
|
||||
using osu.Game.Overlays.Profile.Header;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -375,12 +376,12 @@ namespace osu.Game.Overlays.Profile
|
||||
|
||||
if (user.JoinDate.ToUniversalTime().Year < 2008)
|
||||
{
|
||||
infoTextLeft.AddText("Here since the beginning", boldItalic);
|
||||
infoTextLeft.AddText(new DrawableJoinDate(user.JoinDate), lightText);
|
||||
}
|
||||
else
|
||||
{
|
||||
infoTextLeft.AddText("Joined ", lightText);
|
||||
infoTextLeft.AddText(new DrawableDate(user.JoinDate), boldItalic);
|
||||
infoTextLeft.AddText(new DrawableJoinDate(user.JoinDate), boldItalic);
|
||||
}
|
||||
|
||||
infoTextLeft.NewLine();
|
||||
@ -470,43 +471,5 @@ namespace osu.Game.Overlays.Profile
|
||||
|
||||
infoTextRight.NewLine();
|
||||
}
|
||||
|
||||
private class GradeBadge : Container
|
||||
{
|
||||
private const float width = 50;
|
||||
private readonly string grade;
|
||||
private readonly Sprite badge;
|
||||
private readonly SpriteText numberText;
|
||||
|
||||
public int DisplayCount
|
||||
{
|
||||
set { numberText.Text = value.ToString(@"#,0"); }
|
||||
}
|
||||
|
||||
public GradeBadge(string grade)
|
||||
{
|
||||
this.grade = grade;
|
||||
Width = width;
|
||||
Height = 41;
|
||||
Add(badge = new Sprite
|
||||
{
|
||||
Width = width,
|
||||
Height = 26
|
||||
});
|
||||
Add(numberText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold"
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
badge.Texture = textures.Get($"Grades/{grade}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,11 +141,11 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportFirst:
|
||||
message = $"{userLinkTemplate()} has become an osu! supporter - thanks for your generosity!";
|
||||
message = $"{userLinkTemplate()} has become an osu!supporter - thanks for your generosity!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportGift:
|
||||
message = $"{userLinkTemplate()} has received the gift of osu! supporter!";
|
||||
message = $"{userLinkTemplate()} has received the gift of osu!supporter!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.UsernameChange:
|
||||
|
@ -56,7 +56,13 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
|
||||
reloadSkins();
|
||||
|
||||
skinDropdown.Bindable = config.GetBindable<int>(OsuSetting.Skin);
|
||||
var skinBindable = config.GetBindable<int>(OsuSetting.Skin);
|
||||
|
||||
// Todo: This should not be necessary when OsuConfigManager is databased
|
||||
if (skinDropdown.Items.All(s => s.Value != skinBindable.Value))
|
||||
skinBindable.Value = 0;
|
||||
|
||||
skinDropdown.Bindable = skinBindable;
|
||||
}
|
||||
|
||||
private void reloadSkins() => skinDropdown.Items = skins.GetAllUsableSkins().Select(s => new KeyValuePair<string, int>(s.ToString(), s.ID));
|
||||
|
@ -67,8 +67,8 @@ namespace osu.Game.Overlays.Toolbar
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(RulesetStore rulesets, OsuGame game)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets, Bindable<RulesetInfo> parentRuleset)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
foreach (var r in rulesets.AvailableRulesets)
|
||||
@ -82,11 +82,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
ruleset.ValueChanged += rulesetChanged;
|
||||
ruleset.DisabledChanged += disabledChanged;
|
||||
|
||||
if (game != null)
|
||||
ruleset.BindTo(game.Ruleset);
|
||||
else
|
||||
ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault();
|
||||
ruleset.BindTo(parentRuleset);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
|
Reference in New Issue
Block a user