Merge pull request #65 from peppy/general-fixes

General fixes
This commit is contained in:
Dean Herbert
2016-10-13 14:46:40 +09:00
committed by GitHub
31 changed files with 394 additions and 1415 deletions

View File

@ -23,7 +23,7 @@ namespace osu.Desktop.Tests
public override string Description => @"Showing hitobjects and what not."; public override string Description => @"Showing hitobjects and what not.";
FramedOffsetClock localClock; FramedClock localClock;
protected override IFrameBasedClock Clock => localClock; protected override IFrameBasedClock Clock => localClock;
@ -32,9 +32,7 @@ namespace osu.Desktop.Tests
base.Reset(); base.Reset();
//ensure we are at offset 0 //ensure we are at offset 0
if (localClock == null) localClock = new FramedClock();
localClock = new FramedOffsetClock(base.Clock);
localClock.Offset = -base.Clock.CurrentTime;
List<HitObject> objects = new List<HitObject>(); List<HitObject> objects = new List<HitObject>();

View File

@ -1,159 +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 OpenTK.Input;
using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Graphics.Transformations;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Graphics.Sprites;
namespace osu.Desktop.Tests
{
class TestCaseScoreCounter : TestCase
{
public override string Name => @"ScoreCounter";
public override string Description => @"Tests multiple counters";
public override void Reset()
{
base.Reset();
ScoreCounter uc = new ScoreCounter
{
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
TextSize = 40,
RollingDuration = 1000,
RollingEasing = EasingTypes.Out,
Count = 0,
Position = new Vector2(20, 20),
LeadingZeroes = 7,
};
Add(uc);
StandardComboCounter sc = new StandardComboCounter
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 20),
IsRollingProportional = true,
RollingDuration = 20,
PopOutDuration = 250,
Count = 0,
TextSize = 40,
};
Add(sc);
CatchComboCounter cc = new CatchComboCounter
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
IsRollingProportional = true,
RollingDuration = 20,
PopOutDuration = 250,
Count = 0,
TextSize = 40,
};
Add(cc);
AlternativeComboCounter ac = new AlternativeComboCounter
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 80),
IsRollingProportional = true,
RollingDuration = 20,
ScaleFactor = 2,
Count = 0,
TextSize = 40,
};
Add(ac);
AccuracyCounter pc = new AccuracyCounter
{
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
RollingDuration = 1000,
RollingEasing = EasingTypes.Out,
Count = 100.0f,
Position = new Vector2(20, 60),
};
Add(pc);
SpriteText text = new SpriteText
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 190),
Text = @"- unset -",
};
Add(text);
StarCounter tc = new StarCounter
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 160),
};
Add(tc);
AddButton(@"Reset all", delegate
{
uc.Count = 0;
sc.Count = 0;
ac.Count = 0;
cc.Count = 0;
pc.SetCount(0, 0);
tc.Count = 0;
text.Text = tc.Count.ToString("0.00");
});
AddButton(@"Hit! :D", delegate
{
uc.Count += 300 + (ulong)(300.0 * (sc.Count > 0 ? sc.Count - 1 : 0) / 25.0);
sc.Count++;
ac.Count++;
cc.CatchFruit(new Color4(
Math.Max(0.5f, RNG.NextSingle()),
Math.Max(0.5f, RNG.NextSingle()),
Math.Max(0.5f, RNG.NextSingle()),
1)
);
pc.Numerator++;
pc.Denominator++;
});
AddButton(@"miss...", delegate
{
sc.Count = 0;
ac.Count = 0;
cc.Count = 0;
pc.Denominator++;
});
AddButton(@"Alter stars", delegate
{
tc.Count = RNG.NextSingle() * (tc.MaxStars + 1);
text.Text = tc.Count.ToString("0.00");
});
AddButton(@"Stop counters", delegate
{
uc.StopRolling();
sc.StopRolling();
cc.StopRolling();
ac.StopRolling();
pc.StopRolling();
tc.StopRolling();
});
}
}
}

View File

@ -140,7 +140,6 @@
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Tests\TestCaseChatDisplay.cs" /> <Compile Include="Tests\TestCaseChatDisplay.cs" />
<Compile Include="Tests\TestCaseGamefield.cs" /> <Compile Include="Tests\TestCaseGamefield.cs" />
<Compile Include="Tests\TestCaseScoreCounter.cs" />
<Compile Include="Tests\TestCaseKeyCounter.cs" /> <Compile Include="Tests\TestCaseKeyCounter.cs" />
<Compile Include="Tests\TestCaseMenuButtonSystem.cs" /> <Compile Include="Tests\TestCaseMenuButtonSystem.cs" />
<Compile Include="Tests\TestCaseTextAwesome.cs" /> <Compile Include="Tests\TestCaseTextAwesome.cs" />

View File

@ -0,0 +1,43 @@
//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.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Game.Beatmaps.Objects.Catch;
using osu.Game.Beatmaps.Objects.Osu;
namespace osu.Game.Beatmaps.Objects.Catch
{
class CatchConverter : HitObjectConverter<CatchBaseHit>
{
public override List<CatchBaseHit> Convert(List<HitObject> input)
{
List<CatchBaseHit> output = new List<CatchBaseHit>();
foreach (HitObject i in input)
{
CatchBaseHit h = i as CatchBaseHit;
if (h == null)
{
OsuBaseHit o = i as OsuBaseHit;
if (o == null) throw new Exception(@"Can't convert!");
h = new Fruit
{
StartTime = o.StartTime,
Position = o.Position.X,
};
}
output.Add(h);
}
return output;
}
}
}

View File

@ -0,0 +1,42 @@
//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.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using OpenTK;
namespace osu.Game.Beatmaps.Objects.Catch.Drawable
{
class DrawableFruit : Sprite
{
private CatchBaseHit h;
public DrawableFruit(CatchBaseHit h)
{
this.h = h;
Origin = Anchor.Centre;
Scale = new Vector2(0.1f);
RelativePositionAxes = Axes.Y;
Position = new Vector2(h.Position, -0.1f);
}
public override void Load(BaseGame game)
{
base.Load(game);
Texture = game.Textures.Get(@"Menu/logo");
Transforms.Add(new TransformPosition(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) });
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
Expire(true);
}
}
}

View File

@ -0,0 +1,13 @@
//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;
namespace osu.Game.Beatmaps.Objects
{
public abstract class HitObjectConverter<T>
where T : HitObject
{
public abstract List<T> Convert(List<HitObject> input);
}
}

View File

@ -0,0 +1,33 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using OpenTK;
namespace osu.Game.Beatmaps.Objects.Mania.Drawable
{
public class DrawableNote : Sprite
{
private readonly ManiaBaseHit note;
public DrawableNote(ManiaBaseHit note)
{
this.note = note;
Origin = Anchor.Centre;
Scale = new Vector2(0.1f);
}
public override void Load(BaseGame game)
{
base.Load(game);
Texture = game.Textures.Get(@"Menu/logo");
Transforms.Add(new TransformPositionY(Clock) { StartTime = note.StartTime - 200, EndTime = note.StartTime, StartValue = -0.1f, EndValue = 0.9f });
Transforms.Add(new TransformAlpha(Clock) { StartTime = note.StartTime + note.Duration + 200, EndTime = note.StartTime + note.Duration + 400, StartValue = 1, EndValue = 0 });
Expire(true);
}
}
}

View File

@ -0,0 +1,46 @@
//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 osu.Game.Beatmaps.Objects.Osu;
namespace osu.Game.Beatmaps.Objects.Mania
{
class ManiaConverter : HitObjectConverter<ManiaBaseHit>
{
private readonly int columns;
public ManiaConverter(int columns)
{
this.columns = columns;
}
public override List<ManiaBaseHit> Convert(List<HitObject> input)
{
List<ManiaBaseHit> output = new List<ManiaBaseHit>();
foreach (HitObject i in input)
{
ManiaBaseHit h = i as ManiaBaseHit;
if (h == null)
{
OsuBaseHit o = i as OsuBaseHit;
if (o == null) throw new Exception(@"Can't convert!");
h = new Note
{
StartTime = o.StartTime,
Column = (int)Math.Round(o.Position.X / 512 * columns)
};
}
output.Add(h);
}
return output;
}
}
}

View File

@ -0,0 +1,42 @@
//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.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using OpenTK;
namespace osu.Game.Beatmaps.Objects.Osu.Drawable
{
class DrawableCircle : Sprite
{
private OsuBaseHit h;
public DrawableCircle(OsuBaseHit h)
{
this.h = h;
Origin = Anchor.Centre;
Scale = new Vector2(0.1f);
Alpha = 0;
Position = h.Position;
}
public override void Load(BaseGame game)
{
base.Load(game);
Texture = game.Textures.Get(@"Menu/logo");
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 0, EndValue = 1 });
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
Expire(true);
}
}
}

View File

@ -0,0 +1,21 @@
//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;
namespace osu.Game.Beatmaps.Objects.Osu
{
class OsuConverter : HitObjectConverter<OsuBaseHit>
{
public override List<OsuBaseHit> Convert(List<HitObject> input)
{
List<OsuBaseHit> output = new List<OsuBaseHit>();
foreach (HitObject h in input)
output.Add(h as OsuBaseHit);
return output;
}
}
}

View File

@ -0,0 +1,37 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using OpenTK;
namespace osu.Game.Beatmaps.Objects.Taiko.Drawable
{
class DrawableTaikoHit : Sprite
{
private TaikoBaseHit h;
public DrawableTaikoHit(TaikoBaseHit h)
{
this.h = h;
Origin = Anchor.Centre;
Scale = new Vector2(0.2f);
RelativePositionAxes = Axes.Both;
Position = new Vector2(1.1f, 0.5f);
}
public override void Load(BaseGame game)
{
base.Load(game);
Texture = game.Textures.Get(@"Menu/logo");
Transforms.Add(new TransformPositionX(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 1.1f, EndValue = 0.1f });
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
Expire(true);
}
}
}

View File

@ -3,7 +3,7 @@
namespace osu.Game.Beatmaps.Objects.Taiko namespace osu.Game.Beatmaps.Objects.Taiko
{ {
class TaikoBaseHit : HitObject public class TaikoBaseHit : HitObject
{ {
public float Scale = 1; public float Scale = 1;

View File

@ -0,0 +1,38 @@
//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 osu.Game.Beatmaps.Objects.Osu;
namespace osu.Game.Beatmaps.Objects.Taiko
{
class TaikoConverter : HitObjectConverter<TaikoBaseHit>
{
public override List<TaikoBaseHit> Convert(List<HitObject> input)
{
List<TaikoBaseHit> output = new List<TaikoBaseHit>();
foreach (HitObject i in input)
{
TaikoBaseHit h = i as TaikoBaseHit;
if (h == null)
{
OsuBaseHit o = i as OsuBaseHit;
if (o == null) throw new Exception(@"Can't convert!");
h = new TaikoBaseHit
{
StartTime = o.StartTime,
};
}
output.Add(h);
}
return output;
}
}
}

View File

@ -1,82 +1,20 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.Beatmaps.Objects.Catch; using osu.Game.Beatmaps.Objects.Catch;
using OpenTK; using osu.Game.Beatmaps.Objects.Catch.Drawable;
using osu.Framework;
namespace osu.Game.GameModes.Play.Catch namespace osu.Game.GameModes.Play.Catch
{ {
public class CatchHitRenderer : HitRenderer public class CatchHitRenderer : HitRenderer<CatchBaseHit>
{ {
List<CatchBaseHit> objects; protected override Playfield CreatePlayfield() => new CatchPlayfield();
private CatchPlayfield playfield;
public override List<HitObject> Objects protected override List<CatchBaseHit> Convert(List<HitObject> objects) => new CatchConverter().Convert(objects);
{
set protected override Drawable GetVisualRepresentation(CatchBaseHit h) => new DrawableFruit(h);
{
//osu! mode requires all objects to be of CatchBaseHit type.
objects = value.ConvertAll(convertForCatch);
}
}
private CatchBaseHit convertForCatch(HitObject input)
{
CatchBaseHit h = input as CatchBaseHit;
if (h == null)
{
OsuBaseHit o = input as OsuBaseHit;
if (o == null) throw new Exception(@"Can't convert!");
h = new Fruit()
{
StartTime = o.StartTime,
Position = o.Position.X
};
}
return h;
}
public override void Load(BaseGame game)
{
base.Load(game);
if (playfield == null)
Add(playfield = new CatchPlayfield());
else
playfield.Clear();
if (objects == null) return;
foreach (CatchBaseHit h in objects)
{
//render stuff!
Sprite s = new Sprite
{
Texture = game.Textures.Get(@"Menu/logo"),
Origin = Anchor.Centre,
Scale = new Vector2(0.1f),
RelativePositionAxes = Axes.Y,
Position = new Vector2(h.Position, -0.1f)
};
s.Transforms.Add(new TransformPosition(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) });
s.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
s.Expire(true);
playfield.Add(s);
}
}
} }
} }

View File

@ -3,35 +3,53 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Batches;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Drawables;
using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework; using osu.Framework;
namespace osu.Game.GameModes.Play namespace osu.Game.GameModes.Play
{ {
public abstract class HitRenderer : Container public abstract class HitRenderer<T> : Container
{ {
public abstract List<HitObject> Objects { set; } private List<T> objects;
public HitRenderer() public List<HitObject> Objects
{ {
RelativeSizeAxes = Axes.Both; set
{
objects = Convert(value);
if (IsLoaded)
loadObjects();
} }
}
private Playfield playfield;
protected abstract Playfield CreatePlayfield();
protected abstract List<T> Convert(List<HitObject> objects);
public override void Load(BaseGame game) public override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
Add(new Box() RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{ {
RelativeSizeAxes = Axes.Both, playfield = CreatePlayfield()
Alpha = 0.8f, };
Colour = new Color4(5, 5, 5, 255),
}); loadObjects();
} }
private void loadObjects()
{
if (objects == null) return;
foreach (T h in objects)
playfield.Add(GetVisualRepresentation(h));
}
protected abstract Drawable GetVisualRepresentation(T h);
} }
} }

View File

@ -1,88 +1,39 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.Beatmaps.Objects.Mania; using osu.Game.Beatmaps.Objects.Mania;
using OpenTK; using OpenTK;
using osu.Framework; using osu.Game.Beatmaps.Objects.Mania.Drawable;
using System.Collections.Generic;
namespace osu.Game.GameModes.Play.Mania namespace osu.Game.GameModes.Play.Mania
{ {
public class ManiaHitRenderer : HitRenderer public class ManiaHitRenderer : HitRenderer<ManiaBaseHit>
{ {
private readonly int columns; private readonly int columns;
List<ManiaBaseHit> objects;
private ManiaPlayfield playfield;
public ManiaHitRenderer(int columns = 5) public ManiaHitRenderer(int columns = 5)
{ {
this.columns = columns; this.columns = columns;
} }
public override List<HitObject> Objects protected override List<ManiaBaseHit> Convert(List<HitObject> objects)
{ {
set ManiaConverter converter = new ManiaConverter(columns);
{ return converter.Convert(objects);
//osu! mode requires all objects to be of ManiaBaseHit type.
objects = value.ConvertAll(convertForMania);
}
} }
private ManiaBaseHit convertForMania(HitObject input) protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns);
{
ManiaBaseHit h = input as ManiaBaseHit;
if (h == null) protected override Drawable GetVisualRepresentation(ManiaBaseHit h)
{ {
OsuBaseHit o = input as OsuBaseHit; return new DrawableNote(h)
if (o == null) throw new Exception(@"Can't convert!");
h = new Note()
{ {
StartTime = o.StartTime, Position = new Vector2((float)(h.Column + 0.5) / columns, -0.1f),
Column = (int)Math.Round(o.Position.X / 512 * columns) RelativePositionAxes = Axes.Both
}; };
} }
return h;
}
public override void Load(BaseGame game)
{
base.Load(game);
if (playfield == null)
Add(playfield = new ManiaPlayfield(columns));
else
playfield.Clear();
if (objects == null) return;
foreach (ManiaBaseHit h in objects)
{
//render stuff!
Sprite s = new Sprite
{
Texture = game.Textures.Get(@"Menu/logo"),
Origin = Anchor.Centre,
Scale = new Vector2(0.1f),
RelativePositionAxes = Axes.Both,
Position = new Vector2((float)(h.Column + 0.5) / columns, -0.1f)
};
s.Transforms.Add(new TransformPositionY(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = -0.1f, EndValue = 0.9f });
s.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
s.Expire(true);
playfield.Add(s);
}
}
} }
} }

View File

@ -2,62 +2,19 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu; using osu.Game.Beatmaps.Objects.Osu;
using OpenTK; using osu.Game.Beatmaps.Objects.Osu.Drawable;
using System.Diagnostics;
using osu.Framework;
namespace osu.Game.GameModes.Play.Osu namespace osu.Game.GameModes.Play.Osu
{ {
public class OsuHitRenderer : HitRenderer public class OsuHitRenderer : HitRenderer<OsuBaseHit>
{ {
List<OsuBaseHit> objects; protected override Playfield CreatePlayfield() => new OsuPlayfield();
private OsuPlayfield playfield;
public override List<HitObject> Objects protected override List<OsuBaseHit> Convert(List<HitObject> objects) => new OsuConverter().Convert(objects);
{
set
{
Debug.Assert(objects == null);
//osu! mode requires all objects to be of OsuBaseHit type. protected override Drawable GetVisualRepresentation(OsuBaseHit h) => new DrawableCircle(h);
objects = value.ConvertAll(o => (OsuBaseHit)o);
}
}
public override void Load(BaseGame game)
{
base.Load(game);
if (playfield == null)
Add(playfield = new OsuPlayfield());
else
playfield.Clear();
if (objects == null) return;
foreach (OsuBaseHit h in objects)
{
//render stuff!
Sprite s = new Sprite
{
Texture = game.Textures.Get(@"Menu/logo"),
Origin = Anchor.Centre,
Scale = new Vector2(0.1f),
Alpha = 0,
Position = h.Position
};
s.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 0, EndValue = 1 });
s.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
s.Expire(true);
playfield.Add(s);
}
}
} }
} }

View File

@ -1,81 +1,20 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.Beatmaps.Objects.Taiko; using osu.Game.Beatmaps.Objects.Taiko;
using OpenTK; using osu.Game.Beatmaps.Objects.Taiko.Drawable;
using osu.Framework;
namespace osu.Game.GameModes.Play.Taiko namespace osu.Game.GameModes.Play.Taiko
{ {
public class TaikoHitRenderer : HitRenderer public class TaikoHitRenderer : HitRenderer<TaikoBaseHit>
{ {
List<TaikoBaseHit> objects; protected override List<TaikoBaseHit> Convert(List<HitObject> objects) => new TaikoConverter().Convert(objects);
private TaikoPlayfield playfield;
public override List<HitObject> Objects protected override Playfield CreatePlayfield() => new TaikoPlayfield();
{
set protected override Drawable GetVisualRepresentation(TaikoBaseHit h) => new DrawableTaikoHit(h);
{
//osu! mode requires all objects to be of TaikoBaseHit type.
objects = value.ConvertAll(convertForTaiko);
}
}
private TaikoBaseHit convertForTaiko(HitObject input)
{
TaikoBaseHit h = input as TaikoBaseHit;
if (h == null)
{
OsuBaseHit o = input as OsuBaseHit;
if (o == null) throw new Exception(@"Can't convert!");
h = new TaikoBaseHit()
{
StartTime = o.StartTime
};
}
return h;
}
public override void Load(BaseGame game)
{
base.Load(game);
if (playfield == null)
Add(playfield = new TaikoPlayfield());
else
playfield.Clear();
if (objects == null) return;
foreach (TaikoBaseHit h in objects)
{
//render stuff!
Sprite s = new Sprite
{
Texture = game.Textures.Get(@"Menu/logo"),
Origin = Anchor.Centre,
Scale = new Vector2(0.2f),
RelativePositionAxes = Axes.Both,
Position = new Vector2(1.1f, 0.5f)
};
s.Transforms.Add(new TransformPositionX(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 1.1f, EndValue = 0.1f });
s.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
s.Expire(true);
playfield.Add(s);
}
}
} }
} }

View File

@ -1,102 +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 osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// Used as an accuracy counter. Represented visually as a percentage, internally as a fraction.
/// </summary>
public class AccuracyCounter : NumericRollingCounter<float>
{
protected override Type transformType => typeof(TransformAccuracy);
private long numerator = 0;
public long Numerator
{
get
{
return numerator;
}
set
{
numerator = value;
updateCount();
}
}
private ulong denominator = 0;
public ulong Denominator
{
get
{
return denominator;
}
set
{
denominator = value;
updateCount();
}
}
public void SetCount(long num, ulong den)
{
numerator = num;
denominator = den;
updateCount();
}
private void updateCount()
{
Count = Denominator == 0 ? 100.0f : (Numerator * 100.0f) / Denominator;
}
public override void ResetCount()
{
numerator = 0;
denominator = 0;
updateCount();
StopRolling();
}
protected override string formatCount(float count)
{
return count.ToString("0.00") + "%";
}
protected class TransformAccuracy : Transform<float>
{
public override float CurrentValue
{
get
{
double time = Time;
if (time < StartTime) return StartValue;
if (time >= EndTime) return EndValue;
return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
}
}
public override void Apply(Drawable d)
{
base.Apply(d);
(d as AccuracyCounter).VisibleCount = CurrentValue;
}
public TransformAccuracy(IClock clock)
: base(clock)
{
}
}
}
}

View File

@ -1,91 +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 OpenTK;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Graphics.Transformations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// Allows tint and vertical scaling animation. Used in osu!taiko and osu!mania.
/// </summary>
public class AlternativeComboCounter : ULongCounter // btw, I'm terribly bad with names... OUENDAN!
{
public Color4 OriginalColour;
public Color4 TintColour = Color4.OrangeRed;
public int TintDuration = 250;
public float ScaleFactor = 2;
public EasingTypes TintEasing = EasingTypes.None;
public bool CanAnimateWhenBackwards = false;
public AlternativeComboCounter() : base()
{
IsRollingContinuous = false;
}
public override void Load(BaseGame game)
{
base.Load(game);
countSpriteText.Hide();
OriginalColour = Colour;
}
public override void ResetCount()
{
SetCountWithoutRolling(0);
}
protected override void transformCount(ulong currentValue, ulong newValue)
{
// Animate rollover only when going backwards
if (newValue > currentValue)
{
updateTransforms(typeof(TransformULongCounter));
removeTransforms(typeof(TransformULongCounter));
VisibleCount = newValue;
}
else
transformCount(new TransformULongCounter(Clock), currentValue, newValue);
}
protected override ulong getProportionalDuration(ulong currentValue, ulong newValue)
{
ulong difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue;
return difference * RollingDuration;
}
protected virtual void transformAnimate()
{
countSpriteText.FadeColour(TintColour, 0);
countSpriteText.ScaleTo(new Vector2(1, ScaleFactor));
countSpriteText.FadeColour(OriginalColour, TintDuration, TintEasing);
countSpriteText.ScaleTo(new Vector2(1, 1), TintDuration, TintEasing);
}
protected override void transformVisibleCount(ulong currentValue, ulong newValue)
{
if (countSpriteText != null)
{
countSpriteText.Text = newValue.ToString("#,0");
if (newValue == 0)
{
countSpriteText.FadeOut(TintDuration);
return;
}
countSpriteText.Show();
if (newValue > currentValue || CanAnimateWhenBackwards)
{
transformAnimate();
}
}
}
}
}

View File

@ -1,60 +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 OpenTK.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// Similar to Standard, but without the 'x' and has tinted pop-ups. Used in osu!catch.
/// </summary>
public class CatchComboCounter : StandardComboCounter
{
public CatchComboCounter() : base()
{
CanPopOutWhenBackwards = true;
}
protected override string formatCount(ulong count)
{
return count.ToString("#,0");
}
protected override void transformCount(ulong currentValue, ulong newValue)
{
// Animate rollover only when going backwards
if (newValue > currentValue)
{
updateTransforms(typeof(TransformULongCounter));
removeTransforms(typeof(TransformULongCounter));
VisibleCount = newValue;
}
else
{
// Backwards pop-up animation has no tint colour
popOutSpriteText.Colour = countSpriteText.Colour;
transformCount(new TransformULongCounter(Clock), currentValue, newValue);
}
}
/// <summary>
/// Increaces counter and tints pop-out before animation.
/// </summary>
/// <param name="colour">Last grabbed fruit colour.</param>
public void CatchFruit(Color4 colour)
{
popOutSpriteText.Colour = colour;
Count++;
}
public override void ResetCount()
{
base.ResetCount();
}
}
}

View File

@ -1,65 +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 osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// Skeleton for a numeric counter with a simple roll-up animation.
/// </summary>
/// <typeparam name="T">Type of the actual counter.</typeparam>
public abstract class NumericRollingCounter<T> : RollingCounter<T>
{
protected SpriteText countSpriteText;
protected float textSize = 20.0f;
public float TextSize
{
get { return textSize; }
set
{
textSize = value;
updateTextSize();
}
}
public override void Load(BaseGame game)
{
base.Load(game);
Children = new Drawable[]
{
countSpriteText = new SpriteText
{
Text = formatCount(Count),
TextSize = this.TextSize,
Anchor = this.Anchor,
Origin = this.Origin,
},
};
}
protected override void transformVisibleCount(T currentValue, T newValue)
{
if (countSpriteText != null)
{
countSpriteText.Text = formatCount(newValue);
}
}
protected virtual void updateTextSize()
{
if (countSpriteText != null)
countSpriteText.TextSize = TextSize;
}
}
}

View File

@ -1,241 +0,0 @@
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transformations;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// Skeleton for a counter which value rolls-up in a lapse of time.
/// </summary>
/// <remarks>
/// This class only abstracts the basics to roll-up a value in a lapse of time by using Transforms.
/// In order to show a value, you must implement a way to display it, i.e., as a numeric counter or a bar.
/// </remarks>
/// <typeparam name="T">Type of the actual counter.</typeparam>
public abstract class RollingCounter<T> : Container
{
/// <summary>
/// Type of the Transform to use.
/// </summary>
/// <remarks>
/// Must be a subclass of Transform<T>
/// </remarks>
protected virtual Type transformType => typeof(Transform<T>);
protected ulong RollingTotalDuration = 0;
/// <summary>
/// If true, each time the Count is updated, it will roll over from the current visible value.
/// Else, it will roll up from the current count value.
/// </summary>
public bool IsRollingContinuous = true;
/// <summary>
/// If true, the roll-up duration will be proportional to the counter.
/// </summary>
public bool IsRollingProportional = false;
/// <summary>
/// If IsRollingProportional = false, duration in milliseconds for the counter roll-up animation for each
/// element; else duration in milliseconds for the counter roll-up animation in total.
/// </summary>
public ulong RollingDuration = 0;
/// <summary>
/// Easing for the counter rollover animation.
/// </summary>
public EasingTypes RollingEasing = EasingTypes.None;
protected T prevVisibleCount;
protected T visibleCount;
/// <summary>
/// Value shown at the current moment.
/// </summary>
public virtual T VisibleCount
{
get
{
return visibleCount;
}
protected set
{
prevVisibleCount = visibleCount;
if (visibleCount.Equals(value))
return;
visibleCount = value;
transformVisibleCount(prevVisibleCount, value);
}
}
protected T prevCount;
protected T count;
/// <summary>
/// Actual value of counter.
/// </summary>
public virtual T Count
{
get
{
return count;
}
set
{
prevCount = count;
count = value;
if (Clock != null)
{
RollingTotalDuration =
IsRollingProportional
? getProportionalDuration(VisibleCount, value)
: RollingDuration;
transformCount(IsRollingContinuous ? VisibleCount : prevCount, value);
}
}
}
protected RollingCounter()
{
Debug.Assert(
transformType.IsSubclassOf(typeof(Transform<T>)) || transformType == typeof(Transform<T>),
@"transformType should be a subclass of Transform<T>."
);
}
public override void Load(BaseGame game)
{
base.Load(game);
removeTransforms(transformType);
if (Count == null)
ResetCount();
VisibleCount = Count;
}
/// <summary>
/// Sets count value, bypassing rollover animation.
/// </summary>
/// <param name="count">New count value.</param>
public virtual void SetCountWithoutRolling(T count)
{
Count = count;
StopRolling();
}
/// <summary>
/// Stops rollover animation, forcing the visible count to be the actual count.
/// </summary>
public virtual void StopRolling()
{
removeTransforms(transformType);
VisibleCount = Count;
}
/// <summary>
/// Resets count to default value.
/// </summary>
public abstract void ResetCount();
/// <summary>
/// Calculates the duration of the roll-up animation by using the difference between the current visible value
/// and the new final value.
/// </summary>
/// <remarks>
/// To be used in conjunction with IsRollingProportional = true.
/// Unless a derived class needs to have a proportional rolling, it is not necessary to override this function.
/// </remarks>
/// <param name="currentValue">Current visible value.</param>
/// <param name="newValue">New final value.</param>
/// <returns>Calculated rollover duration in milliseconds.</returns>
protected virtual ulong getProportionalDuration(T currentValue, T newValue)
{
return RollingDuration;
}
/// <summary>
/// Used to format counts.
/// </summary>
/// <param name="count">Count to format.</param>
/// <returns>Count formatted as a string.</returns>
protected virtual string formatCount(T count)
{
return count.ToString();
}
protected void updateTransforms(Type type)
{
foreach (ITransform t in Transforms.AliveItems)
if (t.GetType() == type)
t.Apply(this);
}
protected void removeTransforms(Type type)
{
Transforms.RemoveAll(t => t.GetType() == type);
}
/// <summary>
/// Called when the count is updated to add a transformer that changes the value of the visible count (i.e.
/// implement the rollover animation).
/// </summary>
/// <param name="currentValue">Count value before modification.</param>
/// <param name="newValue">Expected count value after modification-</param>
/// <remarks>
/// Unless you need to set a custom animation according to the current or new value of the count, the
/// recommended approach is to call transformCount(CustomTransformer(Clock), currentValue, newValue), where
/// CustomTransformer is of type transformerType.
/// By using this approach, there is no need to check if the Clock is not null; this validation is done before
/// adding the transformer.
/// </remarks>
/// <seealso cref="transformType"/>
protected virtual void transformCount(T currentValue, T newValue)
{
object[] parameters = { Clock };
transformCount((Transform<T>)Activator.CreateInstance(transformType, parameters), currentValue, newValue);
}
/// <summary>
/// Intended to be used by transformCount().
/// </summary>
/// <see cref="transformCount"/>
protected void transformCount(Transform<T> transform, T currentValue, T newValue)
{
Type type = transform.GetType();
updateTransforms(type);
removeTransforms(type);
if (Clock == null)
return;
if (RollingDuration == 0)
{
VisibleCount = Count;
return;
}
transform.StartTime = Time;
transform.EndTime = Time + RollingTotalDuration;
transform.StartValue = currentValue;
transform.EndValue = newValue;
transform.Easing = RollingEasing;
Transforms.Add(transform);
}
/// <summary>
/// This procedure is called each time the visible count value is updated.
/// Override to create custom animations.
/// </summary>
/// <param name="currentValue">Visible count value before modification.</param>
/// <param name="newValue">Expected visible count value after modification-</param>
protected abstract void transformVisibleCount(T currentValue, T newValue);
}
}

View File

@ -1,32 +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 osu.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
public class ScoreCounter : ULongCounter
{
/// <summary>
/// How many leading zeroes the counter will have.
/// </summary>
public uint LeadingZeroes = 0;
public override void Load(BaseGame game)
{
base.Load(game);
countSpriteText.FixedWidth = true;
}
protected override string formatCount(ulong count)
{
return count.ToString("D" + LeadingZeroes);
}
}
}

View File

@ -1,110 +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 osu.Framework;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// Uses the 'x' symbol and has a pop-out effect while rolling over. Used in osu! standard.
/// </summary>
public class StandardComboCounter : ULongCounter
{
public SpriteText popOutSpriteText;
public ulong PopOutDuration = 0;
public float PopOutBigScale = 2.0f;
public float PopOutSmallScale = 1.2f;
public EasingTypes PopOutEasing = EasingTypes.None;
public bool CanPopOutWhenBackwards = false;
public float PopOutInitialAlpha = 0.75f;
public StandardComboCounter() : base()
{
IsRollingContinuous = false;
}
public override void Load(BaseGame game)
{
base.Load(game);
countSpriteText.Alpha = 0;
Add(popOutSpriteText = new SpriteText
{
Text = formatCount(Count),
Origin = this.Origin,
Anchor = this.Anchor,
TextSize = this.TextSize,
Alpha = 0,
});
}
protected override void updateTextSize()
{
base.updateTextSize();
if (popOutSpriteText != null)
popOutSpriteText.TextSize = this.TextSize;
}
protected override void transformCount(ulong currentValue, ulong newValue)
{
// Animate rollover only when going backwards
if (newValue > currentValue)
{
updateTransforms(typeof(TransformULongCounter));
removeTransforms(typeof(TransformULongCounter));
VisibleCount = newValue;
}
else
transformCount(new TransformULongCounter(Clock), currentValue, newValue);
}
protected override ulong getProportionalDuration(ulong currentValue, ulong newValue)
{
ulong difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue;
return difference * RollingDuration;
}
protected override string formatCount(ulong count)
{
return count.ToString("#,0") + "x";
}
protected virtual void transformPopOut()
{
countSpriteText.ScaleTo(PopOutSmallScale);
countSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
popOutSpriteText.ScaleTo(PopOutBigScale);
popOutSpriteText.FadeTo(PopOutInitialAlpha);
popOutSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
popOutSpriteText.FadeOut(PopOutDuration, PopOutEasing);
}
protected override void transformVisibleCount(ulong currentValue, ulong newValue)
{
if (countSpriteText != null && popOutSpriteText != null)
{
countSpriteText.Text = popOutSpriteText.Text = formatCount(newValue);
if (newValue == 0)
{
countSpriteText.FadeOut(PopOutDuration);
}
else
{
countSpriteText.Show();
if (newValue > currentValue || CanPopOutWhenBackwards)
transformPopOut();
}
}
}
}
}

View File

@ -1,205 +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 OpenTK;
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transformations;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// Shows a float count as stars. Used as star difficulty display.
/// </summary>
public class StarCounter : RollingCounter<float>
{
protected override Type transformType => typeof(TransformStarCounter);
protected Container starContainer;
protected List<TextAwesome> stars = new List<TextAwesome>();
public ulong StarAnimationDuration = 500;
public EasingTypes StarAnimationEasing = EasingTypes.OutElasticHalf;
public ulong FadeDuration = 100;
public float MinStarSize = 0.3f;
public float MinStarAlpha = 0.5f;
public int MaxStars = 10;
public int StarSize = 20;
public int StarSpacing = 4;
public StarCounter() : base()
{
IsRollingProportional = true;
RollingDuration = 150;
}
protected override ulong getProportionalDuration(float currentValue, float newValue)
{
return (ulong)(Math.Abs(currentValue - newValue) * RollingDuration);
}
public override void ResetCount()
{
Count = 0;
StopRolling();
}
public override void Load(BaseGame game)
{
base.Load(game);
Children = new Drawable[]
{
starContainer = new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Width = MaxStars * StarSize + Math.Max(MaxStars - 1, 0) * StarSpacing,
Height = StarSize,
}
};
for (int i = 0; i < MaxStars; i++)
{
TextAwesome star = new TextAwesome
{
Icon = FontAwesome.star,
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre,
TextSize = StarSize,
Scale = new Vector2(MinStarSize),
Alpha = (i == 0) ? 1.0f : MinStarAlpha,
Position = new Vector2((StarSize + StarSpacing) * i + (StarSize + StarSpacing) / 2, 0),
};
//todo: user Container<T> once we have it.
stars.Add(star);
starContainer.Add(star);
}
ResetCount();
}
protected override void transformCount(float currentValue, float newValue)
{
transformStar((int)Math.Floor(currentValue), currentValue, currentValue < newValue);
transformCount(new TransformStarCounter(Clock), currentValue, newValue);
}
protected void updateTransformStar(int i)
{
foreach (ITransform t in stars[i].Transforms.AliveItems)
if (t.GetType() == typeof(TransformAlpha) || t.GetType() == typeof(TransformScaleVector))
t.Apply(stars[i]);
stars[i].Transforms.RemoveAll(t =>
t.GetType() == typeof(TransformScaleVector) || t.GetType() == typeof(TransformAlpha)
);
}
protected void transformStarScale(int i, TransformScaleVector transform, bool isIncrement, double startTime)
{
transform.StartTime = startTime;
transform.EndTime = transform.StartTime + StarAnimationDuration;
transform.StartValue = stars[i].Scale;
transform.EndValue = new Vector2(
Interpolation.ValueAt(
Math.Min(Math.Max(i, Count), i + 1),
MinStarSize,
1.0f,
i,
i + 1
)
);
transform.Easing = StarAnimationEasing;
stars[i].Transforms.Add(transform);
}
protected void transformStarAlpha(int i, TransformAlpha transform, bool isIncrement, double startTime)
{
transform.StartTime = startTime;
//if (!isIncrement)
//transform.StartTime += StarAnimationDuration - FadeDuration;
transform.EndTime = transform.StartTime + FadeDuration;
transform.StartValue = stars[i].Alpha;
transform.EndValue = i < Count ? 1.0f : MinStarAlpha;
stars[i].Transforms.Add(transform);
}
protected void transformStar(int i, float value, bool isIncrement)
{
if (i >= MaxStars)
return;
if (Clock == null)
return;
// Calculate time where animation should had started
double startTime = Time;
// If incrementing, animation should had started when VisibleCount crossed start of star (i)
if (isIncrement)
startTime -= i == (int)Math.Floor(prevCount) ?
getProportionalDuration(prevCount, value) : getProportionalDuration(i, value);
// If decrementing, animation should had started when VisibleCount crossed end of star (i + 1)
else
startTime -= i == (int)Math.Floor(prevCount) ?
getProportionalDuration(prevCount, value) : getProportionalDuration(i + 1, value);
updateTransformStar(i);
transformStarScale(i, new TransformScaleVector(Clock), isIncrement, startTime);
transformStarAlpha(i, new TransformAlpha(Clock), isIncrement, startTime);
}
protected override void transformVisibleCount(float currentValue, float newValue)
{
// Detect increment that passes over an integer value
if (Math.Ceiling(currentValue) <= Math.Floor(newValue))
for (int i = (int)Math.Ceiling(currentValue); i <= Math.Floor(newValue); i++)
transformStar(i, newValue, true);
// Detect decrement that passes over an integer value
if (Math.Floor(currentValue) >= Math.Ceiling(newValue))
for (int i = (int)Math.Floor(newValue); i < Math.Floor(currentValue); i++)
transformStar(i, newValue, false);
}
protected class TransformStarCounter : Transform<float>
{
public override float CurrentValue
{
get
{
double time = Time;
if (time < StartTime) return StartValue;
if (time >= EndTime) return EndValue;
return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
}
}
public override void Apply(Drawable d)
{
base.Apply(d);
(d as StarCounter).VisibleCount = CurrentValue;
}
public TransformStarCounter(IClock clock)
: base(clock)
{
}
}
}
}

View File

@ -1,59 +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 osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// A simple rolling counter that accepts unsigned long values.
/// </summary>
public class ULongCounter : NumericRollingCounter<ulong>
{
protected override Type transformType => typeof(TransformULongCounter);
public override void ResetCount()
{
SetCountWithoutRolling(0);
}
protected override string formatCount(ulong count)
{
return count.ToString("#,0");
}
protected class TransformULongCounter : Transform<ulong>
{
public override ulong CurrentValue
{
get
{
double time = Time;
if (time < StartTime) return StartValue;
if (time >= EndTime) return EndValue;
return (ulong)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
}
}
public override void Apply(Drawable d)
{
base.Apply(d);
(d as ULongCounter).VisibleCount = CurrentValue;
}
public TransformULongCounter(IClock clock)
: base(clock)
{
}
}
}
}

View File

@ -219,7 +219,10 @@ namespace osu.Game.Online.API
{ {
//NotificationManager.ShowMessage($@"We just went {newState}!", newState == APIState.Online ? Color4.YellowGreen : Color4.OrangeRed, 5000); //NotificationManager.ShowMessage($@"We just went {newState}!", newState == APIState.Online ? Color4.YellowGreen : Color4.OrangeRed, 5000);
log.Add($@"We just went {newState}!"); log.Add($@"We just went {newState}!");
Scheduler.Add(delegate
{
OnStateChange?.Invoke(oldState, newState); OnStateChange?.Invoke(oldState, newState);
});
} }
} }
} }

View File

@ -56,7 +56,7 @@ namespace osu.Game.Online.Chat.Display
} }
} }
}, },
new Container new AutoSizeContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Padding = new MarginPadding { Left = padding + 10 }, Padding = new MarginPadding { Left = padding + 10 },

View File

@ -63,18 +63,27 @@
<Compile Include="Beatmaps\Beatmap.cs" /> <Compile Include="Beatmaps\Beatmap.cs" />
<Compile Include="Beatmaps\BeatmapSet.cs" /> <Compile Include="Beatmaps\BeatmapSet.cs" />
<Compile Include="Beatmaps\BeatmapMetadata.cs" /> <Compile Include="Beatmaps\BeatmapMetadata.cs" />
<Compile Include="Beatmaps\Objects\Catch\CatchConverter.cs" />
<Compile Include="Beatmaps\Objects\Catch\Drawable\DrawableFruit.cs" />
<Compile Include="Beatmaps\Objects\HitObject.cs" /> <Compile Include="Beatmaps\Objects\HitObject.cs" />
<Compile Include="Beatmaps\Objects\Catch\CatchBaseHit.cs" /> <Compile Include="Beatmaps\Objects\Catch\CatchBaseHit.cs" />
<Compile Include="Beatmaps\Objects\Catch\Droplet.cs" /> <Compile Include="Beatmaps\Objects\Catch\Droplet.cs" />
<Compile Include="Beatmaps\Objects\Catch\Fruit.cs" /> <Compile Include="Beatmaps\Objects\Catch\Fruit.cs" />
<Compile Include="Beatmaps\Objects\HitObjectConverter.cs" />
<Compile Include="Beatmaps\Objects\Mania\Drawable\DrawableNote.cs" />
<Compile Include="Beatmaps\Objects\Mania\HoldNote.cs" /> <Compile Include="Beatmaps\Objects\Mania\HoldNote.cs" />
<Compile Include="Beatmaps\Objects\Mania\ManiaBaseHit.cs" /> <Compile Include="Beatmaps\Objects\Mania\ManiaBaseHit.cs" />
<Compile Include="Beatmaps\Objects\Mania\ManiaConverter.cs" />
<Compile Include="Beatmaps\Objects\Mania\Note.cs" /> <Compile Include="Beatmaps\Objects\Mania\Note.cs" />
<Compile Include="Beatmaps\Objects\Osu\Circle.cs" /> <Compile Include="Beatmaps\Objects\Osu\Circle.cs" />
<Compile Include="Beatmaps\Objects\Osu\Drawable\DrawableCircle.cs" />
<Compile Include="Beatmaps\Objects\Osu\OsuBaseHit.cs" /> <Compile Include="Beatmaps\Objects\Osu\OsuBaseHit.cs" />
<Compile Include="Beatmaps\Objects\Osu\OsuConverter.cs" />
<Compile Include="Beatmaps\Objects\Osu\Slider.cs" /> <Compile Include="Beatmaps\Objects\Osu\Slider.cs" />
<Compile Include="Beatmaps\Objects\Osu\Spinner.cs" /> <Compile Include="Beatmaps\Objects\Osu\Spinner.cs" />
<Compile Include="Beatmaps\Objects\Taiko\Drawable\DrawableTaikoHit.cs" />
<Compile Include="Beatmaps\Objects\Taiko\TaikoBaseHit.cs" /> <Compile Include="Beatmaps\Objects\Taiko\TaikoBaseHit.cs" />
<Compile Include="Beatmaps\Objects\Taiko\TaikoConverter.cs" />
<Compile Include="Beatmaps\Samples\HitSampleInfo.cs" /> <Compile Include="Beatmaps\Samples\HitSampleInfo.cs" />
<Compile Include="Beatmaps\Samples\SampleBank.cs" /> <Compile Include="Beatmaps\Samples\SampleBank.cs" />
<Compile Include="Beatmaps\Samples\SampleInfo.cs" /> <Compile Include="Beatmaps\Samples\SampleInfo.cs" />
@ -127,19 +136,10 @@
<Compile Include="Graphics\Cursor\OsuCursorContainer.cs" /> <Compile Include="Graphics\Cursor\OsuCursorContainer.cs" />
<Compile Include="Graphics\Processing\RatioAdjust.cs" /> <Compile Include="Graphics\Processing\RatioAdjust.cs" />
<Compile Include="Graphics\TextAwesome.cs" /> <Compile Include="Graphics\TextAwesome.cs" />
<Compile Include="Graphics\UserInterface\AlternativeComboCounter.cs" />
<Compile Include="Graphics\UserInterface\RollingCounter.cs" />
<Compile Include="Graphics\UserInterface\KeyCounter.cs" /> <Compile Include="Graphics\UserInterface\KeyCounter.cs" />
<Compile Include="Graphics\UserInterface\KeyCounterKeyboard.cs" /> <Compile Include="Graphics\UserInterface\KeyCounterKeyboard.cs" />
<Compile Include="Graphics\UserInterface\KeyCounterCollection.cs" /> <Compile Include="Graphics\UserInterface\KeyCounterCollection.cs" />
<Compile Include="Graphics\UserInterface\KeyCounterMouse.cs" /> <Compile Include="Graphics\UserInterface\KeyCounterMouse.cs" />
<Compile Include="Graphics\UserInterface\AccuracyCounter.cs" />
<Compile Include="Graphics\UserInterface\NumericRollingCounter.cs" />
<Compile Include="Graphics\UserInterface\ScoreCounter.cs" />
<Compile Include="Graphics\UserInterface\CatchComboCounter.cs" />
<Compile Include="Graphics\UserInterface\StandardComboCounter.cs" />
<Compile Include="Graphics\UserInterface\StarCounter.cs" />
<Compile Include="Graphics\UserInterface\ULongCounter.cs" />
<Compile Include="Online\API\APIAccess.cs" /> <Compile Include="Online\API\APIAccess.cs" />
<Compile Include="Online\API\APIRequest.cs" /> <Compile Include="Online\API\APIRequest.cs" />
<Compile Include="Online\API\OAuth.cs" /> <Compile Include="Online\API\OAuth.cs" />
@ -188,12 +188,7 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup />
<ItemGroup> <ItemGroup />
<Folder Include="Database\" />
<Folder Include="Beatmaps\Formats\" />
<Folder Include="Beatmaps\IO\" />
<Folder Include="Beatmaps\Events\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

10
osu.sln
View File

@ -24,45 +24,35 @@ EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Deploy|Any CPU = Deploy|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Deploy|Any CPU = Deploy|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.Build.0 = Release|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.Build.0 = Release|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.Build.0 = Debug|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.ActiveCfg = Release|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.Build.0 = Release|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.Build.0 = Release|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Debug|Any CPU.Build.0 = Debug|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Release|Any CPU.ActiveCfg = Release|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Release|Any CPU.Build.0 = Release|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Release|Any CPU.Build.0 = Release|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.Build.0 = Debug|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.ActiveCfg = Release|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.Build.0 = Release|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.Build.0 = Release|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Debug|Any CPU.Build.0 = Debug|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Release|Any CPU.ActiveCfg = Release|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Release|Any CPU.Build.0 = Release|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Release|Any CPU.Build.0 = Release|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Debug|Any CPU.Build.0 = Debug|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Release|Any CPU.ActiveCfg = Release|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Release|Any CPU.Build.0 = Release|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Release|Any CPU.Build.0 = Release|Any CPU
{54377672-20B1-40AF-8087-5CF73BF3953A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{54377672-20B1-40AF-8087-5CF73BF3953A}.Debug|Any CPU.Build.0 = Debug|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54377672-20B1-40AF-8087-5CF73BF3953A}.Deploy|Any CPU.ActiveCfg = Release|Any CPU
{54377672-20B1-40AF-8087-5CF73BF3953A}.Deploy|Any CPU.Build.0 = Release|Any CPU
{54377672-20B1-40AF-8087-5CF73BF3953A}.Release|Any CPU.ActiveCfg = Release|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54377672-20B1-40AF-8087-5CF73BF3953A}.Release|Any CPU.Build.0 = Release|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection