Merge branch 'master' into skip-button

# Conflicts:
#	osu.Game/Graphics/UserInterface/BackButton.cs
#	osu.Game/Screens/Play/Player.cs
#	osu.Game/osu.Game.csproj
This commit is contained in:
Dean Herbert
2017-02-01 14:05:58 +09:00
38 changed files with 1305 additions and 201 deletions

View File

@ -249,6 +249,8 @@ namespace osu.Game.Screens.Menu
{
sampleClick.Play();
box.FlashColour(Color4.White, 500, EasingTypes.OutExpo);
clickAction?.Invoke();
}

View File

@ -12,6 +12,7 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using OpenTK;
using OpenTK.Graphics;
@ -23,6 +24,8 @@ namespace osu.Game.Screens.Menu
/// </summary>
public partial class OsuLogo : Container
{
public Color4 OsuPink = OsuColour.FromHex(@"e967a1");
private Sprite logo;
private CircularContainer logoContainer;
private Container logoBounceContainer;
@ -62,6 +65,7 @@ namespace osu.Game.Screens.Menu
}
public bool Interactive = true;
private Box flashLayer;
public OsuLogo()
{
@ -104,15 +108,24 @@ namespace osu.Game.Screens.Menu
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = new Color4(233, 103, 161, 255),
Colour = OsuPink,
},
new OsuLogoTriangles
new Triangles
{
TriangleScale = 4,
ColourLight = OsuColour.FromHex(@"ff7db7"),
ColourDark = OsuColour.FromHex(@"de5b95"),
RelativeSizeAxes = Axes.Both,
},
}
},
flashLayer = new Box
{
RelativeSizeAxes = Axes.Both,
BlendingMode = BlendingMode.Additive,
Colour = Color4.White,
Alpha = 0,
},
},
},
logo = new Sprite
@ -189,6 +202,10 @@ namespace osu.Game.Screens.Menu
{
if (!Interactive) return false;
flashLayer.ClearTransformations();
flashLayer.Alpha = 0.4f;
flashLayer.FadeOut(1500, EasingTypes.OutExpo);
Action?.Invoke();
return true;
}
@ -204,31 +221,5 @@ namespace osu.Game.Screens.Menu
{
logoHoverContainer.ScaleTo(1, 500, EasingTypes.OutElastic);
}
class OsuLogoTriangles : Triangles
{
public OsuLogoTriangles()
{
TriangleScale = 4;
Alpha = 1;
}
protected override Triangle CreateTriangle()
{
var triangle = base.CreateTriangle();
triangle.Alpha = 1;
triangle.Colour = getTriangleShade();
return triangle;
}
private Color4 getTriangleShade()
{
float val = RNG.NextSingle();
return Interpolation.ValueAt(val,
new Color4(222, 91, 149, 255),
new Color4(255, 125, 183, 255),
0, 1);
}
}
}
}

View File

@ -16,11 +16,13 @@ using osu.Framework.GameModes;
using osu.Game.Modes.UI;
using osu.Game.Screens.Ranking;
using osu.Game.Configuration;
using osu.Game.Overlays.Pause;
using osu.Framework.Configuration;
using System;
using System.Linq;
using osu.Game.Beatmaps;
using OpenTK.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Screens.Play
{
@ -35,7 +37,23 @@ namespace osu.Game.Screens.Play
public BeatmapInfo BeatmapInfo;
public PlayMode PreferredPlayMode;
private bool isPaused;
public bool IsPaused
{
get
{
return isPaused;
}
}
public int RestartCount;
private double pauseCooldown = 1000;
private double lastPauseActionTime = 0;
private bool canPause => Time.Current >= (lastPauseActionTime + pauseCooldown);
private IAdjustableClock sourceClock;
private Ruleset ruleset;
@ -45,6 +63,10 @@ namespace osu.Game.Screens.Play
private Bindable<int> dimLevel;
private SkipButton skipButton;
private ScoreOverlay scoreOverlay;
private PauseOverlay pauseOverlay;
private PlayerInputManager playerInputManager;
[BackgroundDependencyLoader]
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game, OsuConfigManager config)
{
@ -89,9 +111,20 @@ namespace osu.Game.Screens.Play
ruleset = Ruleset.GetRuleset(usablePlayMode);
var scoreOverlay = ruleset.CreateScoreOverlay();
scoreOverlay = ruleset.CreateScoreOverlay();
scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count));
pauseOverlay = new PauseOverlay
{
Depth = -1,
OnResume = delegate {
Delay(400);
Schedule(Resume);
},
OnRetry = Restart,
OnQuit = Exit
};
hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects);
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
@ -106,7 +139,7 @@ namespace osu.Game.Screens.Play
Children = new Drawable[]
{
new PlayerInputManager(game.Host)
playerInputManager = new PlayerInputManager(game.Host)
{
Clock = new InterpolatingFramedClock(sourceClock),
PassThrough = false,
@ -117,6 +150,7 @@ namespace osu.Game.Screens.Play
}
},
scoreOverlay,
pauseOverlay
};
}
@ -147,6 +181,58 @@ namespace osu.Game.Screens.Play
skipButton.Expire();
}
public void Pause(bool force = false)
{
if (canPause || force)
{
lastPauseActionTime = Time.Current;
playerInputManager.PassThrough = true;
scoreOverlay.KeyCounter.IsCounting = false;
pauseOverlay.Retries = RestartCount;
pauseOverlay.Show();
sourceClock.Stop();
isPaused = true;
}
else
{
isPaused = false;
}
}
public void Resume()
{
lastPauseActionTime = Time.Current;
playerInputManager.PassThrough = false;
scoreOverlay.KeyCounter.IsCounting = true;
pauseOverlay.Hide();
sourceClock.Start();
isPaused = false;
}
public void TogglePaused()
{
isPaused = !IsPaused;
if (IsPaused) Pause(); else Resume();
}
public void Restart()
{
sourceClock.Stop(); // If the clock is running and Restart is called the game will lag until relaunch
var newPlayer = new Player();
newPlayer.Preload(Game, delegate
{
newPlayer.RestartCount = RestartCount + 1;
ValidForResume = false;
if (!Push(newPlayer))
{
// Error(?)
}
});
}
protected override void LoadComplete()
{
base.LoadComplete();
@ -202,9 +288,19 @@ namespace osu.Game.Screens.Play
protected override bool OnExiting(GameMode next)
{
dimLevel.ValueChanged -= dimChanged;
Background?.FadeTo(1f, 200);
return base.OnExiting(next);
if (pauseOverlay.State != Visibility.Visible && !canPause) return true;
if (!IsPaused && sourceClock.IsRunning) // For if the user presses escape quickly when entering the map
{
Pause();
return true;
}
else
{
dimLevel.ValueChanged -= dimChanged;
Background?.FadeTo(1f, 200);
return base.OnExiting(next);
}
}
private void dimChanged(object sender, EventArgs e)

View File

@ -2,6 +2,7 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using osu.Framework;
using osu.Framework.Allocation;
using OpenTK;
@ -14,7 +15,12 @@ using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Framework.Graphics.Colour;
using osu.Game.Beatmaps.Drawables;
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
using osu.Game.Beatmaps.Timing;
using osu.Game.Modes;
namespace osu.Game.Screens.Select
{
@ -24,7 +30,7 @@ namespace osu.Game.Screens.Select
private Container beatmapInfoContainer;
private BaseGame game;
private OsuGameBase game;
public BeatmapInfoWedge()
{
@ -42,7 +48,7 @@ namespace osu.Game.Screens.Select
}
[BackgroundDependencyLoader]
private void load(BaseGame game)
private void load(OsuGameBase game)
{
this.game = game;
}
@ -59,6 +65,28 @@ namespace osu.Game.Screens.Select
BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo;
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
List<InfoLabel> labels = new List<InfoLabel>();
if (beatmap.Beatmap != null)
{
labels.Add(new InfoLabel(new BeatmapStatistic
{
Name = "Length",
Icon = FontAwesome.fa_clock_o,
Content = TimeSpan.FromMilliseconds(beatmap.Beatmap.HitObjects.Last().EndTime - beatmap.Beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"),
}));
labels.Add(new InfoLabel(new BeatmapStatistic
{
Name = "BPM",
Icon = FontAwesome.fa_circle,
Content = getBPMRange(beatmap.Beatmap),
}));
//get statistics fromt he current ruleset.
Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).ForEach(s => labels.Add(new InfoLabel(s)));
}
(beatmapInfoContainer = new BufferedContainer
{
Depth = newDepth,
@ -99,9 +127,9 @@ namespace osu.Game.Screens.Select
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Direction = FlowDirection.VerticalOnly,
Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 40 },
Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 20 },
AutoSizeAxes = Axes.Both,
Children = new[]
Children = new Drawable[]
{
new SpriteText
{
@ -139,11 +167,18 @@ namespace osu.Game.Screens.Select
Shadow = true,
},
}
}
},
new FlowContainer
{
Margin = new MarginPadding { Top = 20 },
Spacing = new Vector2(40,0),
AutoSizeAxes = Axes.Both,
Children = labels
},
}
}
},
}
}).Preload(game, delegate(Drawable d)
}).Preload(game, delegate (Drawable d)
{
FadeIn(250);
@ -153,5 +188,47 @@ namespace osu.Game.Screens.Select
Add(d);
});
}
private string getBPMRange(Beatmap beatmap)
{
double bpmMax = beatmap.BPMMaximum;
double bpmMin = beatmap.BPMMinimum;
if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm";
return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.BPMMode) + "bpm)";
}
public class InfoLabel : Container
{
public InfoLabel(BeatmapStatistic statistic)
{
AutoSizeAxes = Axes.Both;
Children = new[]
{
new TextAwesome
{
Icon = FontAwesome.fa_square,
Colour = new Color4(68, 17, 136, 255),
Rotation = 45
},
new TextAwesome
{
Icon = statistic.Icon,
Colour = new Color4(255, 221, 85, 255),
Scale = new Vector2(0.8f)
},
new SpriteText
{
Margin = new MarginPadding { Left = 13 },
Font = @"Exo2.0-Bold",
Colour = new Color4(255, 221, 85, 255),
Text = statistic.Content,
TextSize = 17,
Origin = Anchor.CentreLeft
},
};
}
}
}
}

View File

@ -186,7 +186,7 @@ namespace osu.Game.Screens.Select
private static float offsetX(float dist, float halfHeight)
{
// The radius of the circle the carousel moves on.
const float CIRCLE_RADIUS = 4;
const float CIRCLE_RADIUS = 3;
double discriminant = Math.Max(0, CIRCLE_RADIUS * CIRCLE_RADIUS - dist * dist);
float x = (CIRCLE_RADIUS - (float)Math.Sqrt(discriminant)) * halfHeight;

View File

@ -310,7 +310,7 @@ namespace osu.Game.Screens.Select
if (b.Metadata == null) b.Metadata = beatmapSet.Metadata;
});
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList();
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList();
var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database);