Skip to content

Commit

Permalink
Merge branch 'master' into fix-model-import
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jul 20, 2018
2 parents fc6deb6 + f226e10 commit 77da100
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 23 deletions.
13 changes: 9 additions & 4 deletions osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ public GameplayCursor()

private int downCount;

private const float pressed_scale = 1.2f;
private const float released_scale = 1f;

private float targetScale => downCount > 0 ? pressed_scale : released_scale;

public bool OnPressed(OsuAction action)
{
switch (action)
{
case OsuAction.LeftButton:
case OsuAction.RightButton:
downCount++;
ActiveCursor.ScaleTo(1).ScaleTo(1.2f, 100, Easing.OutQuad);
ActiveCursor.ScaleTo(released_scale).ScaleTo(targetScale, 100, Easing.OutQuad);
break;
}

Expand All @@ -60,7 +65,7 @@ public bool OnReleased(OsuAction action)
case OsuAction.LeftButton:
case OsuAction.RightButton:
if (--downCount == 0)
ActiveCursor.ScaleTo(1, 200, Easing.OutQuad);
ActiveCursor.ScaleTo(targetScale, 200, Easing.OutQuad);
break;
}

Expand All @@ -72,13 +77,13 @@ public bool OnReleased(OsuAction action)
protected override void PopIn()
{
fadeContainer.FadeTo(1, 300, Easing.OutQuint);
ActiveCursor.ScaleTo(1, 400, Easing.OutQuint);
ActiveCursor.ScaleTo(targetScale, 400, Easing.OutQuint);
}

protected override void PopOut()
{
fadeContainer.FadeTo(0.05f, 450, Easing.OutQuint);
ActiveCursor.ScaleTo(0.8f, 450, Easing.OutQuint);
ActiveCursor.ScaleTo(targetScale * 0.8f, 450, Easing.OutQuint);
}

public class OsuCursor : Container
Expand Down
1 change: 0 additions & 1 deletion osu.Game.Tests/Visual/TestCaseKeyCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public TestCaseKeyCounter()
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
IsCounting = true,
Children = new KeyCounter[]
{
new KeyCounterKeyboard(Key.Z),
Expand Down
13 changes: 13 additions & 0 deletions osu.Game/Rulesets/UI/RulesetContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ protected RulesetContainer(Ruleset ruleset)
Ruleset = ruleset;
playfield = new Lazy<Playfield>(CreatePlayfield);

IsPaused.ValueChanged += paused =>
{
if (HasReplayLoaded)
return;
KeyBindingInputManager.UseParentInput = !paused;
};

Cursor = CreateCursor();
}

Expand Down Expand Up @@ -120,6 +128,11 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl

public Replay Replay { get; private set; }

/// <summary>
/// Whether the game is paused. Used to block user input.
/// </summary>
public readonly BindableBool IsPaused = new BindableBool();

/// <summary>
/// Sets a replay to be used, overriding local input.
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion osu.Game/Screens/Play/HUDOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)

protected virtual KeyCounterCollection CreateKeyCounter() => new KeyCounterCollection
{
IsCounting = true,
FadeTime = 50,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Screens/Play/KeyCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class KeyCounter : Container
private Container textLayer;
private SpriteText countSpriteText;

public bool IsCounting { get; set; }
public bool IsCounting { get; set; } = true;
private int countPresses;
public int CountPresses
{
Expand Down
3 changes: 1 addition & 2 deletions osu.Game/Screens/Play/KeyCounterCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ private void load(OsuConfigManager config)
configVisibility.BindValueChanged(_ => updateVisibility(), true);
}

//further: change default values here and in KeyCounter if needed, instead of passing them in every constructor
private bool isCounting;
private bool isCounting = true;
public bool IsCounting
{
get { return isCounting; }
Expand Down
12 changes: 4 additions & 8 deletions osu.Game/Screens/Play/PauseContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
Expand All @@ -18,7 +19,7 @@ namespace osu.Game.Screens.Play
/// </summary>
public class PauseContainer : Container
{
public bool IsPaused { get; private set; }
public readonly BindableBool IsPaused = new BindableBool();

public Func<bool> CheckCanPause;

Expand All @@ -39,9 +40,6 @@ public class PauseContainer : Container
public Action OnRetry;
public Action OnQuit;

public Action OnResume;
public Action OnPause;

private readonly FramedClock framedClock;
private readonly DecoupleableInterpolatingFramedClock decoupledClock;

Expand Down Expand Up @@ -84,9 +82,8 @@ public void Pause(bool force = false) => Schedule(() => // Scheduled to ensure a
// stop the seekable clock (stops the audio eventually)
decoupledClock.Stop();
IsPaused = true;
IsPaused.Value = true;
OnPause?.Invoke();
pauseOverlay.Show();
lastPauseActionTime = Time.Current;
Expand All @@ -96,7 +93,7 @@ public void Resume()
{
if (!IsPaused) return;

IsPaused = false;
IsPaused.Value = false;
IsResuming = false;
lastPauseActionTime = Time.Current;

Expand All @@ -105,7 +102,6 @@ public void Resume()
decoupledClock.Seek(decoupledClock.CurrentTime);
decoupledClock.Start();

OnResume?.Invoke();
pauseOverlay.Hide();
}

Expand Down
9 changes: 3 additions & 6 deletions osu.Game/Screens/Play/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,10 @@ private void load(AudioManager audio, APIAccess api, OsuConfigManager config)
{
pauseContainer = new PauseContainer(offsetClock, adjustableClock)
{
Retries = RestartCount,
OnRetry = Restart,
OnQuit = Exit,
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
OnPause = () =>
{
pauseContainer.Retries = RestartCount;
hudOverlay.KeyCounter.IsCounting = !pauseContainer.IsPaused;
},
OnResume = () => hudOverlay.KeyCounter.IsCounting = true,
Children = new[]
{
storyboardContainer = new Container
Expand Down Expand Up @@ -227,6 +222,8 @@ private void load(AudioManager audio, APIAccess api, OsuConfigManager config)
hudOverlay.HoldToQuit.Action = Exit;
hudOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded);

RulesetContainer.IsPaused.BindTo(pauseContainer.IsPaused);

if (ShowStoryboard)
initializeStoryboard(false);

Expand Down

0 comments on commit 77da100

Please sign in to comment.