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

Merge remote-tracking branch 'refs/remotes/upstream/master' into carousel-fixes

This commit is contained in:
Dean Herbert 2016-11-26 17:08:40 +09:00
commit ebab9d66bf
20 changed files with 252 additions and 148 deletions

@ -1 +1 @@
Subproject commit 09c18c415d280448c44cb73f2c4e60e0092b974c
Subproject commit 60e210c1aa62a114fb08e50797f8f839da326cc3

View File

@ -12,6 +12,7 @@ using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.Objects.Drawables;
using osu.Framework.Graphics.Containers;
using osu.Game.Modes;
namespace osu.Desktop.VisualTests.Tests
{
@ -50,7 +51,7 @@ namespace osu.Desktop.VisualTests.Tests
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Depth = -i,
State = ArmedState.Armed,
State = ArmedState.Hit,
};
approachContainer.Add(d.ApproachCircle.CreateProxy());

View File

@ -1,31 +1,32 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Desktop.VisualTests.Platform;
using osu.Framework.GameModes.Testing;
using osu.Game.Database;
using osu.Game.Modes;
using osu.Game.Screens.Select;
namespace osu.Desktop.VisualTests.Tests
{
class TestCasePlaySongSelect : TestCase
{
private BeatmapDatabase db;
private TestStorage storage;
public override string Name => @"Song Select";
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Desktop.VisualTests.Platform;
using osu.Framework.GameModes.Testing;
using osu.Game.Database;
using osu.Game.Modes;
using osu.Game.Screens.Select;
namespace osu.Desktop.VisualTests.Tests
{
class TestCasePlaySongSelect : TestCase
{
private BeatmapDatabase db, oldDb;
private TestStorage storage;
public override string Name => @"Song Select";
public override string Description => @"with fake data";
public override void Reset()
{
public override void Reset()
{
base.Reset();
oldDb = Dependencies.Get<BeatmapDatabase>();
if (db == null)
{
storage = new TestStorage(@"TestCasePlaySongSelect");
db = new BeatmapDatabase(storage);
Dependencies.Cache(db, true);
var sets = new List<BeatmapSetInfo>();
@ -34,8 +35,13 @@ namespace osu.Desktop.VisualTests.Tests
db.Import(sets);
}
Add(new PlaySongSelect(db));
Add(new PlaySongSelect());
}
protected override void Dispose(bool isDisposing)
{
Dependencies.Cache(oldDb, true);
base.Dispose(isDisposing);
}
private BeatmapSetInfo createTestBeatmapSet(int i)
@ -89,6 +95,6 @@ namespace osu.Desktop.VisualTests.Tests
},
}),
};
}
}
}
}
}
}

View File

@ -2,6 +2,7 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.ComponentModel;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Modes.Objects.Drawables;
@ -10,7 +11,7 @@ using OpenTK;
namespace osu.Game.Modes.Osu.Objects.Drawables
{
public class DrawableHitCircle : DrawableHitObject
public class DrawableHitCircle : DrawableOsuHitObject
{
private OsuHitObject osuObject;
@ -39,7 +40,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
circle = new CirclePiece
{
Colour = osuObject.Colour,
Hit = Hit,
Hit = () =>
{
((PositionalJudgementInfo)Judgement).PositionOffset = Vector2.Zero; //todo: set to correct value
UpdateJudgement(true);
return true;
},
},
number = new NumberPiece(),
ring = new RingPiece(),
@ -66,6 +72,38 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
UpdateState(State);
}
double hit50 = 150;
double hit100 = 80;
double hit300 = 30;
protected override void CheckJudgement(bool userTriggered)
{
if (!userTriggered)
{
if (Judgement.TimeOffset > hit50)
Judgement.Result = HitResult.Miss;
return;
}
double hitOffset = Math.Abs(Judgement.TimeOffset);
if (hitOffset < hit50)
{
Judgement.Result = HitResult.Hit;
OsuJudgementInfo osuInfo = Judgement as OsuJudgementInfo;
if (hitOffset < hit300)
osuInfo.Score = OsuScoreResult.Hit300;
else if (hitOffset < hit100)
osuInfo.Score = OsuScoreResult.Hit100;
else if (hitOffset < hit50)
osuInfo.Score = OsuScoreResult.Hit50;
}
else
Judgement.Result = HitResult.Miss;
}
protected override void UpdateState(ArmedState state)
{
if (!IsLoaded) return;
@ -73,7 +111,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
Flush(true); //move to DrawableHitObject
ApproachCircle.Flush(true);
double t = HitTime ?? osuObject.StartTime;
double t = osuObject.EndTime + Judgement.TimeOffset;
Alpha = 0;
@ -103,14 +141,27 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
switch (state)
{
case ArmedState.Disarmed:
Delay(osuObject.Duration + 200);
FadeOut(200);
case ArmedState.Idle:
Delay(osuObject.Duration + 500);
FadeOut(500);
explosion?.Expire();
explosion = null;
break;
case ArmedState.Armed:
case ArmedState.Miss:
ring.FadeOut();
circle.FadeOut();
number.FadeOut();
glow.FadeOut();
explosion?.Expire();
explosion = null;
Schedule(() => Add(explosion = new HitExplosion((OsuJudgementInfo)Judgement)));
FadeOut(800);
break;
case ArmedState.Hit:
const double flash_in = 30;
flash.FadeTo(0.8f, flash_in);
@ -119,7 +170,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
explode.FadeIn(flash_in);
Schedule(() => Add(explosion = new HitExplosion(Judgement.Hit300)));
Schedule(() => Add(explosion = new HitExplosion((OsuJudgementInfo)Judgement)));
Delay(flash_in, true);

View File

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Drawables;
namespace osu.Game.Modes.Osu.Objects.Drawables
{
public class DrawableOsuHitObject : DrawableHitObject
{
public DrawableOsuHitObject(OsuHitObject hitObject)
: base(hitObject)
{
}
public override JudgementInfo CreateJudgementInfo() => new OsuJudgementInfo();
protected override void UpdateState(ArmedState state)
{
throw new NotImplementedException();
}
}
public class OsuJudgementInfo : PositionalJudgementInfo
{
public OsuScoreResult Score;
public ComboResult Combo;
}
public enum ComboResult
{
[Description(@"")]
None,
[Description(@"Good")]
Good,
[Description(@"Amazing")]
Perfect
}
public enum OsuScoreResult
{
[Description(@"Miss")]
Miss,
[Description(@"50")]
Hit50,
[Description(@"100")]
Hit100,
[Description(@"300")]
Hit300,
[Description(@"500")]
Hit500
}
}

View File

@ -5,7 +5,7 @@ using OpenTK;
namespace osu.Game.Modes.Osu.Objects.Drawables
{
class DrawableSlider : DrawableHitObject
class DrawableSlider : DrawableOsuHitObject
{
public DrawableSlider(Slider h) : base(h)
{
@ -18,7 +18,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
Add(new CirclePiece
{
Colour = h.Colour,
Hit = Hit,
Position = h.Curve.PositionAt(i) - h.Position //non-relative?
});
}

View File

@ -3,6 +3,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Game.Modes.Objects.Drawables;
using OpenTK;
namespace osu.Game.Modes.Osu.Objects.Drawables
@ -12,7 +13,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
private SpriteText line1;
private SpriteText line2;
public HitExplosion(Judgement judgement, ComboJudgement comboJudgement = ComboJudgement.None)
public HitExplosion(OsuJudgementInfo judgement)
{
AutoSizeAxes = Axes.Both;
Anchor = Anchor.Centre;
@ -27,13 +28,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = judgement.GetDescription(),
Text = judgement.Score.GetDescription(),
Font = @"Venera",
TextSize = 20,
},
line2 = new SpriteText
{
Text = comboJudgement.GetDescription(),
Text = judgement.Combo.GetDescription(),
Font = @"Venera",
TextSize = 14,
}

View File

@ -49,8 +49,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
Hit?.Invoke();
return true;
return Hit?.Invoke() ?? false;
}
}
}

View File

@ -41,6 +41,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" />
<Compile Include="Objects\Drawables\Pieces\ApproachCircle.cs" />
<Compile Include="Objects\Drawables\Pieces\CirclePiece.cs" />
<Compile Include="Objects\Drawables\DrawableSlider.cs" />

View File

@ -6,16 +6,17 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Threading;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Audio;
using osu.Framework.Allocation;
namespace osu.Game.Graphics.UserInterface.Volume
{
internal class VolumeControl : OverlayContainer
{
public BindableDouble VolumeGlobal { get; set; }
public BindableDouble VolumeSample { get; set; }
public BindableDouble VolumeTrack { get; set; }
private BindableDouble volumeGlobal = new BindableDouble();
private BindableDouble volumeSample = new BindableDouble();
private BindableDouble volumeTrack = new BindableDouble();
private VolumeMeter volumeMeterMaster;
@ -54,20 +55,20 @@ namespace osu.Game.Graphics.UserInterface.Volume
{
base.LoadComplete();
VolumeGlobal.ValueChanged += volumeChanged;
VolumeSample.ValueChanged += volumeChanged;
VolumeTrack.ValueChanged += volumeChanged;
volumeGlobal.ValueChanged += volumeChanged;
volumeSample.ValueChanged += volumeChanged;
volumeTrack.ValueChanged += volumeChanged;
volumeMeterMaster.Bindable = VolumeGlobal;
volumeMeterEffect.Bindable = VolumeSample;
volumeMeterMusic.Bindable = VolumeTrack;
volumeMeterMaster.Bindable.Weld(volumeGlobal);
volumeMeterEffect.Bindable.Weld(volumeSample);
volumeMeterMusic.Bindable.Weld(volumeTrack);
}
protected override void Dispose(bool isDisposing)
{
VolumeGlobal.ValueChanged -= volumeChanged;
VolumeSample.ValueChanged -= volumeChanged;
VolumeTrack.ValueChanged -= volumeChanged;
volumeGlobal.ValueChanged -= volumeChanged;
volumeSample.ValueChanged -= volumeChanged;
volumeTrack.ValueChanged -= volumeChanged;
base.Dispose(isDisposing);
}
@ -82,6 +83,14 @@ namespace osu.Game.Graphics.UserInterface.Volume
volumeMeterMaster.TriggerWheel(state);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
volumeGlobal.Weld(audio.Volume);
volumeSample.Weld(audio.VolumeSample);
volumeTrack.Weld(audio.VolumeTrack);
}
ScheduledDelegate popOutDelegate;
private VolumeMeter volumeMeterEffect;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
internal class VolumeMeter : Container
{
private Box meterFill;
public BindableDouble Bindable;
public BindableDouble Bindable { get; private set; } = new BindableDouble();
public VolumeMeter(string meterName)
{

View File

@ -1,51 +0,0 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Game.Modes.Objects;
using OpenTK;
namespace osu.Game.Modes
{
public class HitJudgementResolver
{
public JudgementResult CheckJudgement(HitObject h) => new JudgementResult { Combo = ComboJudgement.None, Judgement = Judgement.Hit300 };
}
public struct JudgementResult
{
public ComboJudgement Combo;
public Judgement Judgement;
public float TimeOffset;
public Vector2 PositionOffset;
}
public enum ComboJudgement
{
[Description(@"")]
None,
[Description(@"Good")]
Good,
[Description(@"Amazing")]
Perfect
}
public enum Judgement
{
[Description(@"Miss")]
Miss,
[Description(@"50")]
Hit50,
[Description(@"100")]
Hit100,
[Description(@"300")]
Hit300,
[Description(@"500")]
Hit500
}
}

View File

@ -2,22 +2,26 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.ComponentModel;
using System.Diagnostics;
using osu.Framework;
using osu.Framework.Graphics.Containers;
using OpenTK;
using Container = osu.Framework.Graphics.Containers.Container;
namespace osu.Game.Modes.Objects.Drawables
{
public abstract class DrawableHitObject : Container, IStateful<ArmedState>
{
//todo: move to a more central implementation. this logic should not be at a drawable level.
public Action<DrawableHitObject> OnHit;
public Action<DrawableHitObject> OnMiss;
public Func<DrawableHitObject, bool> AllowHit;
public Action<DrawableHitObject, JudgementInfo> OnHit;
public Action<DrawableHitObject, JudgementInfo> OnMiss;
public Container<DrawableHitObject> ChildObjects;
public JudgementResult Result;
protected JudgementInfo Judgement;
public abstract JudgementInfo CreateJudgementInfo();
public HitObject HitObject;
@ -41,36 +45,55 @@ namespace osu.Game.Modes.Objects.Drawables
}
}
protected double? HitTime;
protected virtual bool Hit()
protected override void LoadComplete()
{
if (State != ArmedState.Disarmed)
base.LoadComplete();
Judgement = CreateJudgementInfo();
}
/// <summary>
/// Process a hit of this hitobject. Carries out judgement.
/// </summary>
/// <param name="judgement">Preliminary judgement information provided by the hit source.</param>
/// <returns>Whether a hit was processed.</returns>
protected bool UpdateJudgement(bool userTriggered)
{
if (Judgement.Result != null)
return false;
if (AllowHit?.Invoke(this) == false)
Judgement.TimeOffset = Time.Current - HitObject.EndTime;
CheckJudgement(userTriggered);
if (Judgement.Result == null)
return false;
HitTime = Time.Current;
switch (Judgement.Result)
{
default:
State = ArmedState.Hit;
OnHit?.Invoke(this, Judgement);
break;
case HitResult.Miss:
State = ArmedState.Miss;
OnMiss?.Invoke(this, Judgement);
break;
}
State = ArmedState.Armed;
return true;
}
private bool counted;
protected virtual void CheckJudgement(bool userTriggered)
{
}
protected override void Update()
{
base.Update();
if (Time.Current >= HitObject.EndTime && !counted)
{
counted = true;
if (state == ArmedState.Armed)
OnHit?.Invoke(this);
else
OnMiss?.Invoke(this);
}
UpdateJudgement(false);
}
protected abstract void UpdateState(ArmedState state);
@ -78,7 +101,27 @@ namespace osu.Game.Modes.Objects.Drawables
public enum ArmedState
{
Disarmed,
Armed
Idle,
Hit,
Miss
}
public class PositionalJudgementInfo : JudgementInfo
{
public Vector2 PositionOffset;
}
public class JudgementInfo
{
public HitResult? Result;
public double TimeOffset;
}
public enum HitResult
{
[Description(@"Miss")]
Miss,
[Description(@"Hit")]
Hit,
}
}

View File

@ -22,8 +22,6 @@ namespace osu.Game.Modes
public abstract HitObjectParser CreateHitObjectParser();
public virtual HitJudgementResolver CreateHitJudgement() => new HitJudgementResolver();
public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
protected abstract PlayMode PlayMode { get; }

View File

@ -75,12 +75,12 @@ namespace osu.Game.Modes.UI
}
}
private void onMiss(DrawableHitObject obj)
private void onMiss(DrawableHitObject obj, JudgementInfo judgement)
{
OnMiss?.Invoke(obj.HitObject);
}
private void onHit(DrawableHitObject obj)
private void onHit(DrawableHitObject obj, JudgementInfo judgement)
{
OnHit?.Invoke(obj.HitObject);
}

View File

@ -97,12 +97,7 @@ namespace osu.Game
{
RelativeSizeAxes = Axes.Both,
},
volume = new VolumeControl
{
VolumeGlobal = Audio.Volume,
VolumeSample = Audio.VolumeSample,
VolumeTrack = Audio.VolumeTrack
},
volume = new VolumeControl(),
overlayContent = new Container{ RelativeSizeAxes = Axes.Both },
new GlobalHotkeys //exists because UserInputManager is at a level below us.
{

View File

@ -45,7 +45,7 @@ namespace osu.Game
Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host));
//this completely overrides the framework default. will need to change once we make a proper FontStore.
Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f });
Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }, true);
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont"));

View File

@ -90,7 +90,7 @@ namespace osu.Game.Screens.Play
hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); };
if (Autoplay)
hitRenderer.Schedule(() => hitRenderer.DrawableObjects.ForEach(h => h.State = ArmedState.Armed));
hitRenderer.Schedule(() => hitRenderer.DrawableObjects.ForEach(h => h.State = ArmedState.Hit));
Children = new Drawable[]
{

View File

@ -73,11 +73,8 @@ namespace osu.Game.Screens.Select
}
}
/// <param name="database">Optionally provide a database to use instead of the OsuGame one.</param>
public PlaySongSelect(BeatmapDatabase database = null)
public PlaySongSelect()
{
this.database = database;
const float carouselWidth = 640;
const float bottomToolHeight = 50;
Children = new Drawable[]

View File

@ -64,7 +64,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
<Compile Include="Modes\HitJudgementResolver.cs" />
<Compile Include="Modes\Objects\HitObjectParser.cs" />
<Compile Include="Overlays\DragBar.cs" />
<Compile Include="Overlays\MusicController.cs" />