From 00cfc5100409ab3917e5c3e65b5ef637a4a64e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Fri, 7 Oct 2016 02:05:02 -0500 Subject: [PATCH 01/45] Rolling counters (initial) --- .../Tests/TestCaseScoreCounter.cs | 193 ++++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + .../Graphics/UserInterface/AccuracyCounter.cs | 102 ++++++++ .../UserInterface/AlternativeComboCounter.cs | 86 +++++++ .../UserInterface/CatchComboCounter.cs | 56 ++++ .../Graphics/UserInterface/RollingCounter.cs | 239 ++++++++++++++++++ .../Graphics/UserInterface/ScoreCounter.cs | 21 ++ .../UserInterface/StandardComboCounter.cs | 110 ++++++++ .../Graphics/UserInterface/ULongCounter.cs | 59 +++++ osu.Game/osu.Game.csproj | 7 + 10 files changed, 874 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs create mode 100644 osu.Game/Graphics/UserInterface/AccuracyCounter.cs create mode 100644 osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs create mode 100644 osu.Game/Graphics/UserInterface/CatchComboCounter.cs create mode 100644 osu.Game/Graphics/UserInterface/RollingCounter.cs create mode 100644 osu.Game/Graphics/UserInterface/ScoreCounter.cs create mode 100644 osu.Game/Graphics/UserInterface/StandardComboCounter.cs create mode 100644 osu.Game/Graphics/UserInterface/ULongCounter.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs new file mode 100644 index 0000000000..c97fd369ea --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -0,0 +1,193 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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; + +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(); + + Random rnd = new Random(); + + 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); + + Button resetButton = new Button + { + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + Text = @"Reset all", + Width = 100, + Height = 20, + Position = new Vector2(0, 0), + }; + resetButton.Action += delegate + { + uc.Count = 0; + sc.Count = 0; + ac.Count = 0; + cc.Count = 0; + pc.SetCount(0, 0); + }; + Add(resetButton); + + Button hitButton = new Button + { + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + Text = @"Hit! :D", + Width = 100, + Height = 20, + Position = new Vector2(0, 20), + }; + hitButton.Action += 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++; + }; + Add(hitButton); + + Button missButton = new Button + { + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + Text = @"miss...", + Width = 100, + Height = 20, + Position = new Vector2(0, 40), + }; + missButton.Action += delegate + { + sc.Count = 0; + ac.Count = 0; + cc.Count = 0; + pc.Denominator++; + }; + Add(missButton); + + Button forceResetButton = new Button + { + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + Text = @"Force reset", + Width = 100, + Height = 20, + Position = new Vector2(0, 60), + }; + forceResetButton.Action += delegate + { + uc.ResetCount(); + sc.ResetCount(); + ac.ResetCount(); + pc.ResetCount(); + cc.ResetCount(); + }; + Add(forceResetButton); + + Button stopButton = new Button + { + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + Text = @"STOP!", + Width = 100, + Height = 20, + Position = new Vector2(0, 80), + }; + stopButton.Action += delegate + { + uc.StopRolling(); + sc.StopRolling(); + cc.StopRolling(); + ac.StopRolling(); + pc.StopRolling(); + }; + Add(stopButton); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index b731d53b4b..fdbd878a87 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -152,6 +152,7 @@ + diff --git a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs new file mode 100644 index 0000000000..da04d9d7f7 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs @@ -0,0 +1,102 @@ +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 +{ + /// + /// Used as an accuracy counter. Represented visually as a percentage, internally as a fraction. + /// + public class AccuracyCounter : RollingCounter + { + 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 override void transformCount(float currentValue, float newValue) + { + transformCount(new TransformAccuracy(Clock), currentValue, newValue); + } + + protected class TransformAccuracy : Transform + { + 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) + { + } + } + } +} diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs new file mode 100644 index 0000000000..edcad7f13c --- /dev/null +++ b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs @@ -0,0 +1,86 @@ +using OpenTK; +using OpenTK.Graphics; +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 +{ + /// + /// Allows tint and vertical scaling animation. Used by osu!taiko and osu!mania. + /// + public class AlternativeComboCounter : ULongCounter // btw, I'm terribly bad with names... OUENDAN! + { + public Color4 OriginalColour; + public Color4 TintColour = Color4.OrangeRed; + public int TintDuration = 500; + public float ScaleFactor = 1; + public EasingTypes TintEasing = EasingTypes.None; + public bool CanAnimateWhenBackwards = false; + + public AlternativeComboCounter() + { + IsRollingContinuous = false; + } + + public override void Load() + { + base.Load(); + 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(TranformULongCounter)); + removeTransforms(typeof(TranformULongCounter)); + VisibleCount = newValue; + } + else + transformCount(new TranformULongCounter(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.Colour = TintColour; + 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(); + } + } + } + } +} diff --git a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs new file mode 100644 index 0000000000..07ac925bcd --- /dev/null +++ b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs @@ -0,0 +1,56 @@ +using OpenTK.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.Graphics.UserInterface +{ + /// + /// Similar to Standard, but without the 'x' and has colour shadows. Used by osu!catch. + /// + public class CatchComboCounter : StandardComboCounter + { + public CatchComboCounter() + { + 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(TranformULongCounter)); + removeTransforms(typeof(TranformULongCounter)); + VisibleCount = newValue; + } + else + { + popOutSpriteText.Colour = countSpriteText.Colour; + transformCount(new TranformULongCounter(Clock), currentValue, newValue); + } + } + + /// + /// Tints pop-out before animation. Intended to use the last grabbed fruit colour. + /// + /// + public void CatchFruit(Color4 colour) + { + popOutSpriteText.Colour = colour; + Count++; + } + + public override void ResetCount() + { + base.ResetCount(); + } + } +} diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs new file mode 100644 index 0000000000..0e714e07c6 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -0,0 +1,239 @@ +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +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 +{ + /// + /// Skeleton for a counter with a simple rollover animation. + /// + /// Type of the actual counter. + public abstract class RollingCounter : Container + { + protected SpriteText countSpriteText; + protected ulong RollingTotalDuration = 0; + + protected float textSize = 20.0f; + public float TextSize + { + get { return textSize; } + set + { + textSize = value; + updateTextSize(); + } + } + + /// + /// If true, each time the Count is updated, it will roll over from the current visible value. + /// Else, it will roll over from the current count value. + /// + public bool IsRollingContinuous = true; + + /// + /// If true, the rollover duration will be proportional to the counter. + /// + public bool IsRollingProportional = false; + + /// + /// If IsRollingProportional = false, duration in milliseconds for the counter rollover animation for each element. + /// If IsRollingProportional = true, duration in milliseconds for the counter rollover animation in total. + /// + public ulong RollingDuration = 0; + + /// + /// Easing for the counter rollover animation. + /// + public EasingTypes RollingEasing = EasingTypes.None; + + protected T visibleCount; + + /// + /// Value shown at the current moment. + /// + public virtual T VisibleCount + { + get + { + return visibleCount; + } + protected set + { + if (visibleCount.Equals(value)) + return; + transformVisibleCount(visibleCount, value); + visibleCount = value; + } + } + + protected T count; + + /// + /// Actual value of counter. + /// + public virtual T Count + { + get + { + return count; + } + set + { + if (Clock != null) + { + RollingTotalDuration = IsRollingProportional ? GetProportionalDuration(VisibleCount, value) : RollingDuration; + transformCount(IsRollingContinuous ? VisibleCount : count, value); + } + count = value; + } + } + + public override void Load() + { + base.Load(); + removeTransforms(typeof(Transform)); + if (Count == null) + ResetCount(); + VisibleCount = Count; + Children = new Drawable[] + { + countSpriteText = new SpriteText + { + Text = formatCount(Count), + TextSize = this.TextSize, + Anchor = this.Anchor, + Origin = this.Origin, + }, + }; + } + + /// + /// Calculates the duration of the rollover animation by using the difference between the current visible value and the new final value. + /// + /// + /// Intended to be used in conjunction with IsRolloverProportional = true. + /// If you're sure your superclass won't never need to be proportional, then it is not necessary to override this function. + /// + /// Current visible value. + /// New final value. + /// Calculated rollover duration in milliseconds. + protected virtual ulong GetProportionalDuration(T currentValue, T newValue) + { + return RollingDuration; + } + + /// + /// Used to format counts. + /// + /// Count to format. + /// Count formatted as a string. + protected virtual string formatCount(T count) + { + return count.ToString(); + } + + /// + /// Sets count value, bypassing rollover animation. + /// + /// New count value. + public virtual void SetCountWithoutRolling(T count) + { + Count = count; + StopRolling(); + } + + /// + /// Stops rollover animation, forcing the visible count to be the actual count. + /// + public virtual void StopRolling() + { + removeTransforms(typeof(Transform)); + VisibleCount = Count; + } + + /// + /// Resets count to default value. + /// + public abstract void ResetCount(); + + protected void updateTransforms(Type type) + { + foreach (ITransform t in Transforms.AliveItems) + if (t.GetType().IsAssignableFrom(type)) + t.Apply(this); + } + + protected void removeTransforms(Type type) + { + Transforms.RemoveAll(t => t.GetType().IsSubclassOf(type)); + } + + /// + /// Called when the count is updated to add a transformer that changes the value of the visible count (i.e. implement the rollover animation). + /// + /// Count value before modification. + /// Expected count value after modification- + /// + /// 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 a custom Transformer related to the + /// type T of the RolloverCounter. + /// By using this approach, there is no need to check if the Clock is not null; this validation is done before adding the transformer. + /// + protected abstract void transformCount(T currentValue, T newValue); + + /// + /// Intended to be used by transformCount(). + /// + /// + protected void transformCount(Transform 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); + } + + /// + /// This procedure is called each time the visible count value is updated. + /// Override to create custom animations. + /// + /// Visible count value before modification. + /// Expected visible count value after modification- + protected virtual void transformVisibleCount(T currentValue, T newValue) + { + if (countSpriteText != null) + { + countSpriteText.Text = formatCount(newValue); + } + } + + protected virtual void updateTextSize() + { + if (countSpriteText != null) + countSpriteText.TextSize = TextSize; + } + } +} diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs new file mode 100644 index 0000000000..08892f3d38 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -0,0 +1,21 @@ +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 + { + /// + /// How many leading zeroes the counter will have. + /// + public uint LeadingZeroes = 0; + + protected override string formatCount(ulong count) + { + return count.ToString("D" + LeadingZeroes); + } + } +} diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs new file mode 100644 index 0000000000..15404fd2e5 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs @@ -0,0 +1,110 @@ +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 +{ + /// + /// Uses the 'x' symbol and has a pop-out effect while rolling over. Used by osu! standard. + /// + 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 = 1.0f; + + public StandardComboCounter() + { + IsRollingContinuous = false; + } + + public override void Load() + { + base.Load(); + countSpriteText.Alpha = 0; + Add(popOutSpriteText = new SpriteText + { + Text = formatCount(Count), + Origin = this.Origin, + Anchor = this.Anchor, + TextSize = this.TextSize, + Alpha = 0, + }); + } + + public override void ResetCount() + { + SetCountWithoutRolling(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(TranformULongCounter)); + removeTransforms(typeof(TranformULongCounter)); + VisibleCount = newValue; + } + else + transformCount(new TranformULongCounter(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(); + } + } + } + } +} diff --git a/osu.Game/Graphics/UserInterface/ULongCounter.cs b/osu.Game/Graphics/UserInterface/ULongCounter.cs new file mode 100644 index 0000000000..01ab357518 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/ULongCounter.cs @@ -0,0 +1,59 @@ +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 +{ + /// + /// A simple rollover counter that accepts unsigned long values. + /// + public class ULongCounter : RollingCounter + { + protected override void transformCount(ulong currentValue, ulong newValue) + { + transformCount(new TranformULongCounter(Clock), currentValue, newValue); + } + + public override void ResetCount() + { + SetCountWithoutRolling(0); + } + + protected override string formatCount(ulong count) + { + return count.ToString("#,0"); + } + + protected class TranformULongCounter : Transform + { + 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 TranformULongCounter(IClock clock) + : base(clock) + { + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 8ef0f07fa7..ae45d04592 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -101,10 +101,17 @@ + + + + + + + From 35325fab95261673e447ccf21bd0ba45dc910a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Fri, 7 Oct 2016 02:24:46 -0500 Subject: [PATCH 02/45] Licence added --- osu.Game/Graphics/UserInterface/AccuracyCounter.cs | 5 ++++- osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs | 5 ++++- osu.Game/Graphics/UserInterface/CatchComboCounter.cs | 5 ++++- osu.Game/Graphics/UserInterface/RollingCounter.cs | 5 ++++- osu.Game/Graphics/UserInterface/ScoreCounter.cs | 5 ++++- osu.Game/Graphics/UserInterface/StandardComboCounter.cs | 5 ++++- osu.Game/Graphics/UserInterface/ULongCounter.cs | 5 ++++- 7 files changed, 28 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs index da04d9d7f7..2ca6d602c7 100644 --- a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs +++ b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs @@ -1,4 +1,7 @@ -using osu.Framework.Graphics; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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; diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs index edcad7f13c..3bd63ad641 100644 --- a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs @@ -1,4 +1,7 @@ -using OpenTK; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics.Transformations; using System; diff --git a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs index 07ac925bcd..d68c163fa6 100644 --- a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs @@ -1,4 +1,7 @@ -using OpenTK.Graphics; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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; diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 0e714e07c6..4e7e3ad6f3 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -1,4 +1,7 @@ -using osu.Framework.Graphics; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index 08892f3d38..a23e7b5803 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -1,4 +1,7 @@ -using System; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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; diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs index 15404fd2e5..437c4f011f 100644 --- a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs @@ -1,4 +1,7 @@ -using osu.Framework.Graphics.Sprites; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using System; using System.Collections.Generic; diff --git a/osu.Game/Graphics/UserInterface/ULongCounter.cs b/osu.Game/Graphics/UserInterface/ULongCounter.cs index 01ab357518..c01c4208c0 100644 --- a/osu.Game/Graphics/UserInterface/ULongCounter.cs +++ b/osu.Game/Graphics/UserInterface/ULongCounter.cs @@ -1,4 +1,7 @@ -using osu.Framework.Graphics; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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; From 965e542eaf295a86ad2f2ead62cfc764f8fab683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Fri, 7 Oct 2016 16:14:35 -0500 Subject: [PATCH 03/45] Line wrapping --- .../UserInterface/AlternativeComboCounter.cs | 6 ++-- .../UserInterface/CatchComboCounter.cs | 3 +- .../Graphics/UserInterface/RollingCounter.cs | 34 +++++++++++-------- .../UserInterface/StandardComboCounter.cs | 7 +--- .../Graphics/UserInterface/ULongCounter.cs | 2 +- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs index 3bd63ad641..5afe23fce7 100644 --- a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs @@ -13,14 +13,14 @@ using System.Threading.Tasks; namespace osu.Game.Graphics.UserInterface { /// - /// Allows tint and vertical scaling animation. Used by osu!taiko and osu!mania. + /// Allows tint and vertical scaling animation. Used in osu!taiko and osu!mania. /// public class AlternativeComboCounter : ULongCounter // btw, I'm terribly bad with names... OUENDAN! { public Color4 OriginalColour; public Color4 TintColour = Color4.OrangeRed; public int TintDuration = 500; - public float ScaleFactor = 1; + public float ScaleFactor = 2; public EasingTypes TintEasing = EasingTypes.None; public bool CanAnimateWhenBackwards = false; @@ -72,7 +72,7 @@ namespace osu.Game.Graphics.UserInterface { if (countSpriteText != null) { - countSpriteText.Text = newValue.ToString(@"#,0"); + countSpriteText.Text = newValue.ToString("#,0"); if (newValue == 0) { countSpriteText.FadeOut(TintDuration); diff --git a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs index d68c163fa6..6f6d586cb8 100644 --- a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; namespace osu.Game.Graphics.UserInterface { /// - /// Similar to Standard, but without the 'x' and has colour shadows. Used by osu!catch. + /// Similar to Standard, but without the 'x' and has tinted pop-ups. Used in osu!catch. /// public class CatchComboCounter : StandardComboCounter { @@ -36,6 +36,7 @@ namespace osu.Game.Graphics.UserInterface } else { + // Backwards pop-up animation has no tint colour popOutSpriteText.Colour = countSpriteText.Colour; transformCount(new TranformULongCounter(Clock), currentValue, newValue); } diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 4e7e3ad6f3..780c747e96 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -14,7 +14,7 @@ using System.Threading.Tasks; namespace osu.Game.Graphics.UserInterface { /// - /// Skeleton for a counter with a simple rollover animation. + /// Skeleton for a counter with a simple roll-up animation. /// /// Type of the actual counter. public abstract class RollingCounter : Container @@ -35,18 +35,18 @@ namespace osu.Game.Graphics.UserInterface /// /// If true, each time the Count is updated, it will roll over from the current visible value. - /// Else, it will roll over from the current count value. + /// Else, it will roll up from the current count value. /// public bool IsRollingContinuous = true; /// - /// If true, the rollover duration will be proportional to the counter. + /// If true, the roll-up duration will be proportional to the counter. /// public bool IsRollingProportional = false; /// - /// If IsRollingProportional = false, duration in milliseconds for the counter rollover animation for each element. - /// If IsRollingProportional = true, duration in milliseconds for the counter rollover animation in total. + /// If IsRollingProportional = false, duration in milliseconds for the counter roll-up animation for each element. + /// If IsRollingProportional = true, duration in milliseconds for the counter roll-up animation in total. /// public ulong RollingDuration = 0; @@ -90,7 +90,10 @@ namespace osu.Game.Graphics.UserInterface { if (Clock != null) { - RollingTotalDuration = IsRollingProportional ? GetProportionalDuration(VisibleCount, value) : RollingDuration; + RollingTotalDuration = + IsRollingProportional + ? GetProportionalDuration(VisibleCount, value) + : RollingDuration; transformCount(IsRollingContinuous ? VisibleCount : count, value); } count = value; @@ -117,11 +120,12 @@ namespace osu.Game.Graphics.UserInterface } /// - /// Calculates the duration of the rollover animation by using the difference between the current visible value and the new final value. + /// Calculates the duration of the roll-up animation by using the difference between the current visible value + /// and the new final value. /// /// - /// Intended to be used in conjunction with IsRolloverProportional = true. - /// If you're sure your superclass won't never need to be proportional, then it is not necessary to override this function. + /// Intended 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. /// /// Current visible value. /// New final value. @@ -178,15 +182,17 @@ namespace osu.Game.Graphics.UserInterface } /// - /// Called when the count is updated to add a transformer that changes the value of the visible count (i.e. implement the rollover animation). + /// Called when the count is updated to add a transformer that changes the value of the visible count (i.e. + /// implement the rollover animation). /// /// Count value before modification. /// Expected count value after modification- /// - /// 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 a custom Transformer related to the - /// type T of the RolloverCounter. - /// By using this approach, there is no need to check if the Clock is not null; this validation is done before adding the transformer. + /// 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 a custom Transformer related to the type T of the RolloverCounter. + /// By using this approach, there is no need to check if the Clock is not null; this validation is done before + /// adding the transformer. /// protected abstract void transformCount(T currentValue, T newValue); diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs index 437c4f011f..e0555c952e 100644 --- a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace osu.Game.Graphics.UserInterface { /// - /// Uses the 'x' symbol and has a pop-out effect while rolling over. Used by osu! standard. + /// Uses the 'x' symbol and has a pop-out effect while rolling over. Used in osu! standard. /// public class StandardComboCounter : ULongCounter { @@ -44,11 +44,6 @@ namespace osu.Game.Graphics.UserInterface }); } - public override void ResetCount() - { - SetCountWithoutRolling(0); - } - protected override void updateTextSize() { base.updateTextSize(); diff --git a/osu.Game/Graphics/UserInterface/ULongCounter.cs b/osu.Game/Graphics/UserInterface/ULongCounter.cs index c01c4208c0..434607be4c 100644 --- a/osu.Game/Graphics/UserInterface/ULongCounter.cs +++ b/osu.Game/Graphics/UserInterface/ULongCounter.cs @@ -14,7 +14,7 @@ using System.Threading.Tasks; namespace osu.Game.Graphics.UserInterface { /// - /// A simple rollover counter that accepts unsigned long values. + /// A simple rolling counter that accepts unsigned long values. /// public class ULongCounter : RollingCounter { From 7277cf5af14013073a27cf12e81f4340d94a7d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Fri, 7 Oct 2016 16:59:52 -0500 Subject: [PATCH 04/45] Reflection to simplify transforms + some refactoring --- .../Graphics/UserInterface/AccuracyCounter.cs | 7 +- .../UserInterface/AlternativeComboCounter.cs | 10 +-- .../UserInterface/CatchComboCounter.cs | 8 +- .../Graphics/UserInterface/RollingCounter.cs | 87 +++++++++++-------- .../UserInterface/StandardComboCounter.cs | 10 +-- .../Graphics/UserInterface/ULongCounter.cs | 9 +- 6 files changed, 72 insertions(+), 59 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs index 2ca6d602c7..d00eda80b2 100644 --- a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs +++ b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs @@ -18,6 +18,8 @@ namespace osu.Game.Graphics.UserInterface /// public class AccuracyCounter : RollingCounter { + protected override Type transformType => typeof(TransformAccuracy); + private long numerator = 0; public long Numerator { @@ -71,11 +73,6 @@ namespace osu.Game.Graphics.UserInterface return count.ToString("0.00") + "%"; } - protected override void transformCount(float currentValue, float newValue) - { - transformCount(new TransformAccuracy(Clock), currentValue, newValue); - } - protected class TransformAccuracy : Transform { public override float CurrentValue diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs index 5afe23fce7..c361f96644 100644 --- a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs @@ -24,7 +24,7 @@ namespace osu.Game.Graphics.UserInterface public EasingTypes TintEasing = EasingTypes.None; public bool CanAnimateWhenBackwards = false; - public AlternativeComboCounter() + public AlternativeComboCounter() : base() { IsRollingContinuous = false; } @@ -46,15 +46,15 @@ namespace osu.Game.Graphics.UserInterface // Animate rollover only when going backwards if (newValue > currentValue) { - updateTransforms(typeof(TranformULongCounter)); - removeTransforms(typeof(TranformULongCounter)); + updateTransforms(typeof(TransformULongCounter)); + removeTransforms(typeof(TransformULongCounter)); VisibleCount = newValue; } else - transformCount(new TranformULongCounter(Clock), currentValue, newValue); + transformCount(new TransformULongCounter(Clock), currentValue, newValue); } - protected override ulong GetProportionalDuration(ulong currentValue, ulong newValue) + protected override ulong getProportionalDuration(ulong currentValue, ulong newValue) { ulong difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue; return difference * RollingDuration; diff --git a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs index 6f6d586cb8..fae46de9bf 100644 --- a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs @@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface /// public class CatchComboCounter : StandardComboCounter { - public CatchComboCounter() + public CatchComboCounter() : base() { CanPopOutWhenBackwards = true; } @@ -30,15 +30,15 @@ namespace osu.Game.Graphics.UserInterface // Animate rollover only when going backwards if (newValue > currentValue) { - updateTransforms(typeof(TranformULongCounter)); - removeTransforms(typeof(TranformULongCounter)); + updateTransforms(typeof(TransformULongCounter)); + removeTransforms(typeof(TransformULongCounter)); VisibleCount = newValue; } else { // Backwards pop-up animation has no tint colour popOutSpriteText.Colour = countSpriteText.Colour; - transformCount(new TranformULongCounter(Clock), currentValue, newValue); + transformCount(new TransformULongCounter(Clock), currentValue, newValue); } } diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 780c747e96..fa8fb64efa 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -19,6 +20,14 @@ namespace osu.Game.Graphics.UserInterface /// Type of the actual counter. public abstract class RollingCounter : Container { + /// + /// Type of the Transform to use. + /// + /// + /// Must be a subclass of Transform + /// + protected virtual Type transformType => typeof(Transform); + protected SpriteText countSpriteText; protected ulong RollingTotalDuration = 0; @@ -92,7 +101,7 @@ namespace osu.Game.Graphics.UserInterface { RollingTotalDuration = IsRollingProportional - ? GetProportionalDuration(VisibleCount, value) + ? getProportionalDuration(VisibleCount, value) : RollingDuration; transformCount(IsRollingContinuous ? VisibleCount : count, value); } @@ -100,10 +109,15 @@ namespace osu.Game.Graphics.UserInterface } } + protected RollingCounter() + { + Debug.Assert(transformType.IsSubclassOf(typeof(Transform)), @"transformType should be a subclass of Transform."); + } + public override void Load() { base.Load(); - removeTransforms(typeof(Transform)); + removeTransforms(transformType); if (Count == null) ResetCount(); VisibleCount = Count; @@ -119,32 +133,6 @@ namespace osu.Game.Graphics.UserInterface }; } - /// - /// Calculates the duration of the roll-up animation by using the difference between the current visible value - /// and the new final value. - /// - /// - /// Intended 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. - /// - /// Current visible value. - /// New final value. - /// Calculated rollover duration in milliseconds. - protected virtual ulong GetProportionalDuration(T currentValue, T newValue) - { - return RollingDuration; - } - - /// - /// Used to format counts. - /// - /// Count to format. - /// Count formatted as a string. - protected virtual string formatCount(T count) - { - return count.ToString(); - } - /// /// Sets count value, bypassing rollover animation. /// @@ -160,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface /// public virtual void StopRolling() { - removeTransforms(typeof(Transform)); + removeTransforms(transformType); VisibleCount = Count; } @@ -169,16 +157,42 @@ namespace osu.Game.Graphics.UserInterface /// public abstract void ResetCount(); + /// + /// Calculates the duration of the roll-up animation by using the difference between the current visible value + /// and the new final value. + /// + /// + /// 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. + /// + /// Current visible value. + /// New final value. + /// Calculated rollover duration in milliseconds. + protected virtual ulong getProportionalDuration(T currentValue, T newValue) + { + return RollingDuration; + } + + /// + /// Used to format counts. + /// + /// Count to format. + /// Count formatted as a string. + protected virtual string formatCount(T count) + { + return count.ToString(); + } + protected void updateTransforms(Type type) { foreach (ITransform t in Transforms.AliveItems) - if (t.GetType().IsAssignableFrom(type)) + if (t.GetType() == type) t.Apply(this); } protected void removeTransforms(Type type) { - Transforms.RemoveAll(t => t.GetType().IsSubclassOf(type)); + Transforms.RemoveAll(t => t.GetType() == type); } /// @@ -190,11 +204,16 @@ namespace osu.Game.Graphics.UserInterface /// /// 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 a custom Transformer related to the type T of the RolloverCounter. + /// 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. /// - protected abstract void transformCount(T currentValue, T newValue); + /// + protected virtual void transformCount(T currentValue, T newValue) + { + object[] parameters = { Clock }; + transformCount((Transform)Activator.CreateInstance(transformType, parameters), currentValue, newValue); + } /// /// Intended to be used by transformCount(). @@ -239,7 +258,7 @@ namespace osu.Game.Graphics.UserInterface } } - protected virtual void updateTextSize() + protected void updateTextSize() { if (countSpriteText != null) countSpriteText.TextSize = TextSize; diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs index e0555c952e..7b8587ac94 100644 --- a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs @@ -25,7 +25,7 @@ namespace osu.Game.Graphics.UserInterface public bool CanPopOutWhenBackwards = false; public float PopOutInitialAlpha = 1.0f; - public StandardComboCounter() + public StandardComboCounter() : base() { IsRollingContinuous = false; } @@ -57,15 +57,15 @@ namespace osu.Game.Graphics.UserInterface // Animate rollover only when going backwards if (newValue > currentValue) { - updateTransforms(typeof(TranformULongCounter)); - removeTransforms(typeof(TranformULongCounter)); + updateTransforms(typeof(TransformULongCounter)); + removeTransforms(typeof(TransformULongCounter)); VisibleCount = newValue; } else - transformCount(new TranformULongCounter(Clock), currentValue, newValue); + transformCount(new TransformULongCounter(Clock), currentValue, newValue); } - protected override ulong GetProportionalDuration(ulong currentValue, ulong newValue) + protected override ulong getProportionalDuration(ulong currentValue, ulong newValue) { ulong difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue; return difference * RollingDuration; diff --git a/osu.Game/Graphics/UserInterface/ULongCounter.cs b/osu.Game/Graphics/UserInterface/ULongCounter.cs index 434607be4c..ef61cf7879 100644 --- a/osu.Game/Graphics/UserInterface/ULongCounter.cs +++ b/osu.Game/Graphics/UserInterface/ULongCounter.cs @@ -18,10 +18,7 @@ namespace osu.Game.Graphics.UserInterface /// public class ULongCounter : RollingCounter { - protected override void transformCount(ulong currentValue, ulong newValue) - { - transformCount(new TranformULongCounter(Clock), currentValue, newValue); - } + protected override Type transformType => typeof(TransformULongCounter); public override void ResetCount() { @@ -33,7 +30,7 @@ namespace osu.Game.Graphics.UserInterface return count.ToString("#,0"); } - protected class TranformULongCounter : Transform + protected class TransformULongCounter : Transform { public override ulong CurrentValue { @@ -53,7 +50,7 @@ namespace osu.Game.Graphics.UserInterface (d as ULongCounter).VisibleCount = CurrentValue; } - public TranformULongCounter(IClock clock) + public TransformULongCounter(IClock clock) : base(clock) { } From a3b4a34a1addd5782ec1a7c27d6d646dd466b3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Fri, 7 Oct 2016 17:15:36 -0500 Subject: [PATCH 05/45] TestCase buttons + minor fixes --- .../Tests/TestCaseScoreCounter.cs | 77 ++----------------- .../UserInterface/CatchComboCounter.cs | 4 +- .../Graphics/UserInterface/RollingCounter.cs | 2 +- 3 files changed, 11 insertions(+), 72 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index c97fd369ea..eedb0bf5b5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -24,8 +24,6 @@ namespace osu.Desktop.Tests { base.Reset(); - Random rnd = new Random(); - ScoreCounter uc = new ScoreCounter { Origin = Anchor.TopRight, @@ -89,35 +87,16 @@ namespace osu.Desktop.Tests }; Add(pc); - Button resetButton = new Button - { - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - Text = @"Reset all", - Width = 100, - Height = 20, - Position = new Vector2(0, 0), - }; - resetButton.Action += delegate + AddButton(@"Reset all", delegate { uc.Count = 0; sc.Count = 0; ac.Count = 0; cc.Count = 0; pc.SetCount(0, 0); - }; - Add(resetButton); + }); - Button hitButton = new Button - { - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - Text = @"Hit! :D", - Width = 100, - Height = 20, - Position = new Vector2(0, 20), - }; - hitButton.Action += delegate + AddButton(@"Hit! :D", delegate { uc.Count += 300 + (ulong)(300.0 * (sc.Count > 0 ? sc.Count - 1 : 0) / 25.0); sc.Count++; @@ -130,64 +109,24 @@ namespace osu.Desktop.Tests ); pc.Numerator++; pc.Denominator++; - }; - Add(hitButton); + }); - Button missButton = new Button - { - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - Text = @"miss...", - Width = 100, - Height = 20, - Position = new Vector2(0, 40), - }; - missButton.Action += delegate + AddButton(@"miss...", delegate { sc.Count = 0; ac.Count = 0; cc.Count = 0; pc.Denominator++; - }; - Add(missButton); + }); - Button forceResetButton = new Button - { - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - Text = @"Force reset", - Width = 100, - Height = 20, - Position = new Vector2(0, 60), - }; - forceResetButton.Action += delegate - { - uc.ResetCount(); - sc.ResetCount(); - ac.ResetCount(); - pc.ResetCount(); - cc.ResetCount(); - }; - Add(forceResetButton); - - Button stopButton = new Button - { - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - Text = @"STOP!", - Width = 100, - Height = 20, - Position = new Vector2(0, 80), - }; - stopButton.Action += delegate + AddButton(@"Stop counters", delegate { uc.StopRolling(); sc.StopRolling(); cc.StopRolling(); ac.StopRolling(); pc.StopRolling(); - }; - Add(stopButton); + }); } } } diff --git a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs index fae46de9bf..9fb8caa07a 100644 --- a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs @@ -43,9 +43,9 @@ namespace osu.Game.Graphics.UserInterface } /// - /// Tints pop-out before animation. Intended to use the last grabbed fruit colour. + /// Increaces counter and tints pop-out before animation. /// - /// + /// Last grabbed fruit colour. public void CatchFruit(Color4 colour) { popOutSpriteText.Colour = colour; diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index fa8fb64efa..44a160c83e 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -258,7 +258,7 @@ namespace osu.Game.Graphics.UserInterface } } - protected void updateTextSize() + protected virtual void updateTextSize() { if (countSpriteText != null) countSpriteText.TextSize = TextSize; From 3067c890ce278e68625d67c87ebc761abe3a5d2a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 22:51:10 +0900 Subject: [PATCH 06/45] General improvements to chat querying and logic organisation. --- .../Tests/TestCaseChatDisplay.cs | 101 ++++++++++-------- osu.Game/Online/Chat/Channel.cs | 27 +++++ .../Online/Chat/Display/ChannelDisplay.cs | 78 ++++++++++++++ osu.Game/Online/Chat/Display/ChatLine.cs | 27 ++--- osu.Game/Online/Chat/Message.cs | 4 +- osu.Game/osu.Game.csproj | 1 + 6 files changed, 173 insertions(+), 65 deletions(-) create mode 100644 osu.Game/Online/Chat/Display/ChannelDisplay.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 353ad4f9f1..98265877a3 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -5,7 +5,6 @@ using OpenTK; using osu.Framework.GameModes.Testing; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Transformations; using osu.Framework.Threading; using osu.Game; using osu.Game.Online.API; @@ -15,7 +14,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using osu.Framework.Graphics.Sprites; -using osu.Game.Online.Chat.Display.osu.Online.Social; +using osu.Game.Online.Chat.Display; namespace osu.Desktop.Tests { @@ -26,41 +25,22 @@ namespace osu.Desktop.Tests public override string Name => @"Chat"; public override string Description => @"Testing API polling"; - private List channels = new List(); - private FlowContainer flow; + FlowContainer flow; private Scheduler scheduler = new Scheduler(); private APIAccess api => ((OsuGameBase)Game).API; - private long? lastMessageId; + private ChannelDisplay channelDisplay; public override void Reset() { base.Reset(); - lastMessageId = null; - if (api.State != APIAccess.APIState.Online) api.OnStateChange += delegate { initializeChannels(); }; else initializeChannels(); - - Add(new ScrollContainer() - { - Size = new Vector2(1, 0.5f), - Children = new Drawable[] - { - flow = new FlowContainer - { - Direction = FlowDirection.VerticalOnly, - RelativeSizeAxes = Axes.X, - LayoutDuration = 100, - LayoutEasing = EasingTypes.Out, - Padding = new Vector2(1, 1) - } - } - }); } protected override void Update() @@ -69,60 +49,87 @@ namespace osu.Desktop.Tests base.Update(); } + private long? lastMessageId; + + List careChannels; + private void initializeChannels() { + careChannels = new List(); + if (api.State != APIAccess.APIState.Online) return; + Add(flow = new FlowContainer + { + RelativeSizeAxes = Axes.Both, + Direction = FlowDirection.VerticalOnly + }); + + SpriteText loading; + Add(loading = new SpriteText + { + Text = @"Loading available channels...", + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 40, + }); + messageRequest?.Cancel(); ListChannelsRequest req = new ListChannelsRequest(); req.Success += delegate (List channels) { - this.channels = channels; - messageRequest = scheduler.AddDelayed(requestNewMessages, 1000, true); + Game.Scheduler.Add(delegate + { + loading.FadeOut(100); + }); + + addChannel(channels.Find(c => c.Name == @"#osu")); + addChannel(channels.Find(c => c.Name == @"#lobby")); + addChannel(channels.Find(c => c.Name == @"#english")); + + messageRequest = scheduler.AddDelayed(() => FetchNewMessages(api), 1000, true); }; api.Queue(req); } - private void requestNewMessages() + private void addChannel(Channel channel) { - messageRequest.Wait(); + flow.Add(channelDisplay = new ChannelDisplay(channel) + { + Size = new Vector2(1, 0.3f) + }); - Channel channel = channels.Find(c => c.Name == "#osu"); + careChannels.Add(channel); + } - GetMessagesRequest gm = new GetMessagesRequest(new List { channel }, lastMessageId); - gm.Success += delegate (List messages) + GetMessagesRequest fetchReq; + + public void FetchNewMessages(APIAccess api) + { + if (fetchReq != null) return; + + fetchReq = new GetMessagesRequest(careChannels, lastMessageId); + fetchReq.Success += delegate (List messages) { foreach (Message m in messages) { - //m.LineWidth = this.Size.X; //this is kinda ugly. - //m.Drawable.Depth = m.Id; - //m.Drawable.FadeInFromZero(800); - - //flow.Add(m.Drawable); - - //if (osu.Messages.Count > 50) - //{ - // osu.Messages[0].Drawable.Expire(); - // osu.Messages.RemoveAt(0); - //} - flow.Add(new ChatLine(m)); - channel.Messages.Add(m); + careChannels.Find(c => c.Id == m.ChannelId).AddNewMessages(m); } lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId; Debug.Write("success!"); - messageRequest.Continue(); + fetchReq = null; }; - gm.Failure += delegate + fetchReq.Failure += delegate { Debug.Write("failure!"); - messageRequest.Continue(); + fetchReq = null; }; - api.Queue(gm); + api.Queue(fetchReq); } } } diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index 96904337cf..59d0cd8cc1 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -1,8 +1,14 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; using Newtonsoft.Json; +using osu.Framework.Configuration; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; namespace osu.Game.Online.Chat { @@ -28,5 +34,26 @@ namespace osu.Game.Online.Chat public Channel() { } + + public event Action NewMessagesArrived; + + public void AddNewMessages(params Message[] messages) + { + Messages.AddRange(messages); + purgeOldMessages(); + + NewMessagesArrived?.Invoke(messages); + } + + private void purgeOldMessages() + { + const int max_history = 50; + + int messageCount = Messages.Count; + if (messageCount > 50) + { + Messages.RemoveRange(0, messageCount - max_history); + } + } } } diff --git a/osu.Game/Online/Chat/Display/ChannelDisplay.cs b/osu.Game/Online/Chat/Display/ChannelDisplay.cs new file mode 100644 index 0000000000..aacdd4c003 --- /dev/null +++ b/osu.Game/Online/Chat/Display/ChannelDisplay.cs @@ -0,0 +1,78 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using osu.Game.Online.Chat.Display.osu.Online.Social; +using OpenTK; + +namespace osu.Game.Online.Chat.Display +{ + public class ChannelDisplay : FlowContainer + { + private readonly Channel channel; + private FlowContainer flow; + + public ChannelDisplay(Channel channel) + { + this.channel = channel; + newMessages(channel.Messages); + channel.NewMessagesArrived += newMessages; + + RelativeSizeAxes = Axes.X; + Direction = FlowDirection.VerticalOnly; + + Add(new SpriteText + { + Text = channel.Name + }); + + Add(new ScrollContainer + { + RelativeSizeAxes = Axes.X, + Size = new Vector2(1, 200), + Children = new Drawable[] + { + flow = new FlowContainer + { + Direction = FlowDirection.VerticalOnly, + RelativeSizeAxes = Axes.X, + LayoutEasing = EasingTypes.Out, + Padding = new Vector2(1, 1) + } + } + }); + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + channel.NewMessagesArrived -= newMessages; + } + + public override void Load() + { + base.Load(); + newMessages(channel.Messages); + } + + private void newMessages(IEnumerable newMessages) + { + if (!IsLoaded) return; + + var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - 20)); + + //up to last 20 messages + foreach (Message m in displayMessages) + flow.Add(new ChatLine(m)); + + while (flow.Children.Count() > 20) + flow.Remove(flow.Children.First()); + } + } +} \ No newline at end of file diff --git a/osu.Game/Online/Chat/Display/ChatLine.cs b/osu.Game/Online/Chat/Display/ChatLine.cs index aa75107c09..fe43ebe66b 100644 --- a/osu.Game/Online/Chat/Display/ChatLine.cs +++ b/osu.Game/Online/Chat/Display/ChatLine.cs @@ -1,6 +1,8 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Drawables; @@ -14,11 +16,11 @@ namespace osu.Game.Online.Chat.Display { public class ChatLine : AutoSizeContainer { - private readonly Message msg; + public readonly Message Message; - public ChatLine(Message msg) + public ChatLine(Message message) { - this.msg = msg; + this.Message = message; } public override void Load() @@ -27,34 +29,27 @@ namespace osu.Game.Online.Chat.Display RelativeSizeAxes = Axes.X; - Add(new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Aqua, - Alpha = 0.2f - }); - Add(new SpriteText { - Text = msg.Timestamp.ToLocalTime().ToLongTimeString(), + Text = Message.Timestamp.ToLocalTime().ToLongTimeString(), Colour = new Color4(128, 128, 128, 255) }); Add(new SpriteText { - Text = msg.User.Name, + Text = Message.User.Name, Origin = Anchor.TopRight, RelativePositionAxes = Axes.X, - Position = new Vector2(0.14f,0), + Position = new Vector2(0.2f,0), }); Add(new SpriteText { - Text = msg.Content, + Text = Message.Content, RelativePositionAxes = Axes.X, - Position = new Vector2(0.15f, 0), + Position = new Vector2(0.22f, 0), RelativeSizeAxes = Axes.X, - Size = new Vector2(0.85f, 1), + Size = new Vector2(0.78f, 1), }); } } diff --git a/osu.Game/Online/Chat/Message.cs b/osu.Game/Online/Chat/Message.cs index 7f9f6ece2c..5b344da22c 100644 --- a/osu.Game/Online/Chat/Message.cs +++ b/osu.Game/Online/Chat/Message.cs @@ -12,10 +12,10 @@ namespace osu.Game.Online.Chat public long Id; [JsonProperty(@"user_id")] - public string UserId; + public int UserId; [JsonProperty(@"channel_id")] - public string ChannelId; + public int ChannelId; [JsonProperty(@"timestamp")] public DateTime Timestamp; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7852d68e33..45d79632e5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -120,6 +120,7 @@ + From adba72d29386d1cdc415af016754d6db1d9af0db Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 8 Oct 2016 00:41:31 +0900 Subject: [PATCH 07/45] Toolbar stores its current state locally (just for conformity). --- osu.Game/Overlays/Toolbar.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Overlays/Toolbar.cs b/osu.Game/Overlays/Toolbar.cs index 46bc2be0d6..049b6f66aa 100644 --- a/osu.Game/Overlays/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar.cs @@ -25,8 +25,12 @@ namespace osu.Game.Overlays private ToolbarModeSelector modeSelector; + public ToolbarState State { get; private set; } + public void SetState(ToolbarState state, bool instant = false) { + State = state; + int time = instant ? 0 : 200; switch (state) From 1e9e52aecc8a0dd541b0df50f51a649304712bf4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 8 Oct 2016 00:41:44 +0900 Subject: [PATCH 08/45] osuLogo handles less keys. --- osu.Game/GameModes/Menu/ButtonSystem.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 87a78c335d..7cc2c85ffb 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -125,16 +125,19 @@ namespace osu.Game.GameModes.Menu protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (args.Key == Key.Escape) + switch (args.Key) { - if (State == MenuState.Initial) - return false; + case Key.Space: + osuLogo.TriggerClick(state); + return true; + case Key.Escape: + if (State == MenuState.Initial) + return false; - State = MenuState.Initial; - return true; + State = MenuState.Initial; + return true; } - - osuLogo.TriggerClick(state); + return true; } From 47faf8f40d3d6252e2ecd22f8fa316802455fa0f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 8 Oct 2016 00:43:06 +0900 Subject: [PATCH 09/45] Add in-game chat display, along with a global hotkey handling method. --- osu.Game/Input/GlobalHotkeys.cs | 21 +++ .../Online/Chat/Display/ChannelDisplay.cs | 37 ++-- osu.Game/OsuGame.cs | 29 ++- osu.Game/Overlays/ChatConsole.cs | 171 ++++++++++++++++++ osu.Game/osu.Game.csproj | 2 + 5 files changed, 243 insertions(+), 17 deletions(-) create mode 100644 osu.Game/Input/GlobalHotkeys.cs create mode 100644 osu.Game/Overlays/ChatConsole.cs diff --git a/osu.Game/Input/GlobalHotkeys.cs b/osu.Game/Input/GlobalHotkeys.cs new file mode 100644 index 0000000000..2a0fa48adf --- /dev/null +++ b/osu.Game/Input/GlobalHotkeys.cs @@ -0,0 +1,21 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Graphics; +using osu.Framework.Input; + +namespace osu.Game.Input +{ + public class GlobalHotkeys : Drawable + { + public Func Handler; + + public override bool HandleInput => true; + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + return Handler(state, args); + } + } +} \ No newline at end of file diff --git a/osu.Game/Online/Chat/Display/ChannelDisplay.cs b/osu.Game/Online/Chat/Display/ChannelDisplay.cs index aacdd4c003..1b8c4e743e 100644 --- a/osu.Game/Online/Chat/Display/ChannelDisplay.cs +++ b/osu.Game/Online/Chat/Display/ChannelDisplay.cs @@ -24,29 +24,34 @@ namespace osu.Game.Online.Chat.Display newMessages(channel.Messages); channel.NewMessagesArrived += newMessages; - RelativeSizeAxes = Axes.X; + RelativeSizeAxes = Axes.Both; Direction = FlowDirection.VerticalOnly; - Add(new SpriteText + Children = new Drawable[] { - Text = channel.Name - }); - - Add(new ScrollContainer - { - RelativeSizeAxes = Axes.X, - Size = new Vector2(1, 200), - Children = new Drawable[] + new SpriteText { - flow = new FlowContainer + Text = channel.Name, + TextSize = 50, + Alpha = 0.3f, + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }, + new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - Direction = FlowDirection.VerticalOnly, - RelativeSizeAxes = Axes.X, - LayoutEasing = EasingTypes.Out, - Padding = new Vector2(1, 1) + flow = new FlowContainer + { + Direction = FlowDirection.VerticalOnly, + RelativeSizeAxes = Axes.X, + LayoutEasing = EasingTypes.Out, + Padding = new Vector2(1, 1) + } } } - }); + }; } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 87c6c30c51..d7b8ea30ff 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -8,6 +8,7 @@ using osu.Game.Configuration; using osu.Game.GameModes.Menu; using OpenTK; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Platform; using osu.Game.GameModes; @@ -15,12 +16,16 @@ using osu.Game.Graphics.Background; using osu.Game.GameModes.Play; using osu.Game.Graphics.Containers; using osu.Game.Overlays; +using osu.Framework.Input; +using osu.Game.Input; +using OpenTK.Input; namespace osu.Game { public class OsuGame : OsuGameBase { public Toolbar Toolbar; + public ChatConsole Chat; public MainMenu MainMenu => intro?.ChildGameMode as MainMenu; private Intro intro; @@ -51,15 +56,21 @@ namespace osu.Game OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, Alpha = 0.001f //fixes invalidation fuckup }, + Chat = new ChatConsole(), new VolumeControl { VolumeGlobal = Audio.Volume, VolumeSample = Audio.VolumeSample, VolumeTrack = Audio.VolumeTrack + }, + new GlobalHotkeys //exists because UserInputManager is at a level below us. + { + Handler = globalHotkeyPressed } }); Toolbar.SetState(ToolbarState.Hidden, true); + Chat.SetState(ChatConsoleState.Hidden, true); intro.ModePushed += modeAdded; intro.Exited += modeRemoved; @@ -71,6 +82,18 @@ namespace osu.Game Cursor.Alpha = 0; } + private bool globalHotkeyPressed(InputState state, KeyDownEventArgs args) + { + switch (args.Key) + { + case Key.F8: + Chat.SetState(Chat.State == ChatConsoleState.Hidden ? ChatConsoleState.Visible : ChatConsoleState.Hidden); + return true; + } + + return base.OnKeyDown(state, args); + } + public Action ModeChanged; private void modeChanged(GameMode newMode) @@ -83,6 +106,7 @@ namespace osu.Game if (newMode is Player || newMode is Intro) { Toolbar.SetState(ToolbarState.Hidden); + Chat.SetState(ChatConsoleState.Hidden); } else { @@ -101,7 +125,10 @@ namespace osu.Game { if (!intro.DidLoadMenu || intro.ChildGameMode != null) { - intro.MakeCurrent(); + Scheduler.Add(delegate + { + intro.MakeCurrent(); + }); return true; } diff --git a/osu.Game/Overlays/ChatConsole.cs b/osu.Game/Overlays/ChatConsole.cs new file mode 100644 index 0000000000..ca7cb040d3 --- /dev/null +++ b/osu.Game/Overlays/ChatConsole.cs @@ -0,0 +1,171 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Threading; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; +using osu.Game.Online.Chat; +using osu.Game.Online.Chat.Display; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Input; +using OpenTK.Input; + +namespace osu.Game.Overlays +{ + public class ChatConsole : Container + { + private APIAccess api => ((OsuGameBase)Game).API; + + private ChannelDisplay channelDisplay; + + private ScheduledDelegate messageRequest; + + private Container content; + + protected override Container AddTarget => content; + + public ChatConsole() + { + RelativeSizeAxes = Axes.X; + Size = new Vector2(1, 300); + Anchor = Anchor.BottomLeft; + Origin = Anchor.BottomLeft; + + AddTopLevel(new Box + { + Depth = float.MinValue, + RelativeSizeAxes = Axes.Both, + Colour = new Color4(0.1f, 0.1f, 0.1f, 0.4f) + }); + + AddTopLevel(content = new Container + { + RelativeSizeAxes = Axes.Both, + }); + } + + public override void Load() + { + base.Load(); + initializeChannels(); + } + + private long? lastMessageId; + + List careChannels; + + private void initializeChannels() + { + careChannels = new List(); + + //if (api.State != APIAccess.APIState.Online) + // return; + + Add(new FlowContainer + { + RelativeSizeAxes = Axes.Both, + Direction = FlowDirection.VerticalOnly + }); + + SpriteText loading; + Add(loading = new SpriteText + { + Text = @"Loading available channels...", + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 40, + }); + + messageRequest?.Cancel(); + + ListChannelsRequest req = new ListChannelsRequest(); + req.Success += delegate (List channels) + { + Game.Scheduler.Add(delegate + { + loading.FadeOut(100); + }); + + addChannel(channels.Find(c => c.Name == @"#osu")); + //addChannel(channels.Find(c => c.Name == @"#lobby")); + //addChannel(channels.Find(c => c.Name == @"#english")); + + messageRequest = Game.Scheduler.AddDelayed(() => FetchNewMessages(api), 1000, true); + }; + api.Queue(req); + } + + private void addChannel(Channel channel) + { + Add(channelDisplay = new ChannelDisplay(channel)); + careChannels.Add(channel); + } + + GetMessagesRequest fetchReq; + + public void FetchNewMessages(APIAccess api) + { + if (fetchReq != null) return; + + fetchReq = new GetMessagesRequest(careChannels, lastMessageId); + fetchReq.Success += delegate (List messages) + { + foreach (Message m in messages) + { + careChannels.Find(c => c.Id == m.ChannelId).AddNewMessages(m); + } + + lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId; + + Debug.Write("success!"); + fetchReq = null; + }; + fetchReq.Failure += delegate + { + Debug.Write("failure!"); + fetchReq = null; + }; + + api.Queue(fetchReq); + } + + public ChatConsoleState State { get; private set; } + + public void SetState(ChatConsoleState state, bool instant = false) + { + State = state; + + int time = instant ? 0 : 500; + + switch (state) + { + case ChatConsoleState.Hidden: + MoveToY(-Size.Y, time, EasingTypes.InQuint); + FadeOut(time, EasingTypes.InQuint); + break; + case ChatConsoleState.Visible: + MoveToY(0, time, EasingTypes.OutQuint); + FadeIn(time, EasingTypes.OutQuint); + break; + } + } + } + + public enum ChatConsoleState + { + Visible, + Hidden, + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 45d79632e5..2d242954aa 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -103,6 +103,7 @@ + @@ -126,6 +127,7 @@ + From 97c2dcf590e30afac920801befe85e22e2fad862 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 8 Oct 2016 23:25:38 +0900 Subject: [PATCH 10/45] Use PaddingContainer for better layout. --- osu.Game/Online/Chat/Display/ChatLine.cs | 60 +++++++++++++++--------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/osu.Game/Online/Chat/Display/ChatLine.cs b/osu.Game/Online/Chat/Display/ChatLine.cs index fe43ebe66b..125463e666 100644 --- a/osu.Game/Online/Chat/Display/ChatLine.cs +++ b/osu.Game/Online/Chat/Display/ChatLine.cs @@ -23,34 +23,52 @@ namespace osu.Game.Online.Chat.Display this.Message = message; } + const float padding = 200; + const float text_size = 20; + public override void Load() { base.Load(); RelativeSizeAxes = Axes.X; - Add(new SpriteText + Children = new Drawable[] { - Text = Message.Timestamp.ToLocalTime().ToLongTimeString(), - Colour = new Color4(128, 128, 128, 255) - }); - - Add(new SpriteText - { - Text = Message.User.Name, - Origin = Anchor.TopRight, - RelativePositionAxes = Axes.X, - Position = new Vector2(0.2f,0), - }); - - Add(new SpriteText - { - Text = Message.Content, - RelativePositionAxes = Axes.X, - Position = new Vector2(0.22f, 0), - RelativeSizeAxes = Axes.X, - Size = new Vector2(0.78f, 1), - }); + new Container + { + Size = new Vector2(padding, text_size), + Children = new Drawable[] + { + new SpriteText + { + Text = Message.Timestamp.ToLocalTime().ToLongTimeString(), + TextSize = text_size, + Colour = new Color4(128, 128, 128, 255) + }, + new SpriteText + { + Text = Message.User.Name, + TextSize = text_size, + Origin = Anchor.TopRight, + Anchor = Anchor.TopRight, + } + } + }, + new PaddingContainer + { + RelativeSizeAxes = Axes.X, + Padding = new Padding { Left = padding + 10 }, + Children = new Drawable[] + { + new SpriteText + { + Text = Message.Content, + TextSize = text_size, + RelativeSizeAxes = Axes.X, + } + } + } + }; } } } From eb7486f1094e0c75f00f69044181fa2e54f15ea7 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 8 Oct 2016 10:26:35 -0400 Subject: [PATCH 11/45] Update osu-framework and specify game name --- osu-framework | 2 +- osu.Desktop.VisualTests/Program.cs | 2 +- osu.Desktop/Program.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu-framework b/osu-framework index 6b884e1b80..a191e86dba 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 6b884e1b80444c5249754634a4b5529c50b52934 +Subproject commit a191e86dbae40c4530ed3ff4b291732696e3a2b0 diff --git a/osu.Desktop.VisualTests/Program.cs b/osu.Desktop.VisualTests/Program.cs index 1cfa440dd9..966b6d00b1 100644 --- a/osu.Desktop.VisualTests/Program.cs +++ b/osu.Desktop.VisualTests/Program.cs @@ -12,7 +12,7 @@ namespace osu.Framework.VisualTests [STAThread] public static void Main(string[] args) { - BasicGameHost host = Host.GetSuitableHost(); + BasicGameHost host = Host.GetSuitableHost(@"visual-tests"); host.Add(new VisualTestGame()); host.Run(); } diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index fe7423924c..1421086054 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -13,7 +13,7 @@ namespace osu.Desktop [STAThread] public static void Main() { - BasicGameHost host = Host.GetSuitableHost(); + BasicGameHost host = Host.GetSuitableHost(@"osu"); host.Add(new OsuGame()); host.Run(); } From 9594b7193c24e6419eb3974bcd7d74f593c14de3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 8 Oct 2016 12:53:46 +0900 Subject: [PATCH 12/45] Standardise drawable state access and split large nested classes out of MainMenu.ButtonSystem --- osu.Game/GameModes/Menu/Button.cs | 314 ++++++++++++++ osu.Game/GameModes/Menu/ButtonSystem.cs | 382 ++---------------- .../GameModes/Menu/FlowContainerWithOrigin.cs | 36 ++ osu.Game/GameModes/Menu/MainMenu.cs | 4 +- osu.Game/GameModes/Menu/MenuVisualisation.cs | 13 + osu.Game/GameModes/Menu/OsuLogo.cs | 4 +- osu.Game/OsuGame.cs | 15 +- osu.Game/Overlays/ChatConsole.cs | 43 +- osu.Game/Overlays/Toolbar.cs | 37 +- osu.Game/osu.Game.csproj | 3 + 10 files changed, 452 insertions(+), 399 deletions(-) create mode 100644 osu.Game/GameModes/Menu/Button.cs create mode 100644 osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs create mode 100644 osu.Game/GameModes/Menu/MenuVisualisation.cs diff --git a/osu.Game/GameModes/Menu/Button.cs b/osu.Game/GameModes/Menu/Button.cs new file mode 100644 index 0000000000..c151a95422 --- /dev/null +++ b/osu.Game/GameModes/Menu/Button.cs @@ -0,0 +1,314 @@ +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Input; +using osu.Framework; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Input; +using osu.Game.Graphics; +using System; + +namespace osu.Game.GameModes.Menu +{ + /// + /// Button designed specifically for the osu!next main menu. + /// In order to correctly flow, we have to use a negative margin on the parent container (due to the parallelogram shape). + /// + public class Button : AutoSizeContainer, IStateful + { + private Container iconText; + private WedgedBox box; + private Color4 colour; + private TextAwesome icon; + private string internalName; + private readonly FontAwesome symbol; + private Action clickAction; + private readonly float extraWidth; + private Key triggerKey; + private string text; + + public override Quad ScreenSpaceInputQuad => box.ScreenSpaceInputQuad; + + public Button(string text, string internalName, FontAwesome symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, Key triggerKey = Key.Unknown) + { + this.internalName = internalName; + this.symbol = symbol; + this.colour = colour; + this.clickAction = clickAction; + this.extraWidth = extraWidth; + this.triggerKey = triggerKey; + this.text = text; + } + + public override void Load() + { + base.Load(); + Alpha = 0; + + Children = new Drawable[] + { + box = new WedgedBox(new Vector2(ButtonSystem.button_width + Math.Abs(extraWidth), ButtonSystem.button_area_height), ButtonSystem.wedge_width) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = colour, + Scale = new Vector2(0, 1) + }, + iconText = new AutoSizeContainer + { + Position = new Vector2(extraWidth / 2, 0), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] + { + icon = new TextAwesome + { + Anchor = Anchor.Centre, + TextSize = 30, + Position = new Vector2(0, 0), + Icon = symbol + }, + new SpriteText + { + Direction = FlowDirection.HorizontalOnly, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 16, + Position = new Vector2(0, 35), + Text = text + } + } + } + }; + } + + protected override bool OnHover(InputState state) + { + if (State != ButtonState.Expanded) return true; + + //if (OsuGame.Instance.IsActive) + // Game.Audio.PlaySamplePositional($@"menu-{internalName}-hover", @"menuclick"); + + box.ScaleTo(new Vector2(1.5f, 1), 500, EasingTypes.OutElastic); + + int duration = 0; //(int)(Game.Audio.BeatLength / 2); + if (duration == 0) duration = 250; + + icon.ClearTransformations(); + + icon.ScaleTo(1, 500, EasingTypes.OutElasticHalf); + + double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration; + double startTime = Time + offset; + + icon.RotateTo(10, offset, EasingTypes.InOutSine); + icon.ScaleTo(new Vector2(1, 0.9f), offset, EasingTypes.Out); + + icon.Transforms.Add(new TransformRotation(Clock) + { + StartValue = -10, + EndValue = 10, + StartTime = startTime, + EndTime = startTime + duration * 2, + Easing = EasingTypes.InOutSine, + LoopCount = -1, + LoopDelay = duration * 2 + }); + + icon.Transforms.Add(new TransformPosition(Clock) + { + StartValue = Vector2.Zero, + EndValue = new Vector2(0, -10), + StartTime = startTime, + EndTime = startTime + duration, + Easing = EasingTypes.Out, + LoopCount = -1, + LoopDelay = duration + }); + + icon.Transforms.Add(new TransformScaleVector(Clock) + { + StartValue = new Vector2(1, 0.9f), + EndValue = Vector2.One, + StartTime = startTime, + EndTime = startTime + duration, + Easing = EasingTypes.Out, + LoopCount = -1, + LoopDelay = duration + }); + + icon.Transforms.Add(new TransformPosition(Clock) + { + StartValue = new Vector2(0, -10), + EndValue = Vector2.Zero, + StartTime = startTime + duration, + EndTime = startTime + duration * 2, + Easing = EasingTypes.In, + LoopCount = -1, + LoopDelay = duration + }); + + icon.Transforms.Add(new TransformScaleVector(Clock) + { + StartValue = Vector2.One, + EndValue = new Vector2(1, 0.9f), + StartTime = startTime + duration, + EndTime = startTime + duration * 2, + Easing = EasingTypes.In, + LoopCount = -1, + LoopDelay = duration + }); + + icon.Transforms.Add(new TransformRotation(Clock) + { + StartValue = 10, + EndValue = -10, + StartTime = startTime + duration * 2, + EndTime = startTime + duration * 4, + Easing = EasingTypes.InOutSine, + LoopCount = -1, + LoopDelay = duration * 2 + }); + + return true; + } + + protected override void OnHoverLost(InputState state) + { + icon.ClearTransformations(); + icon.RotateTo(0, 500, EasingTypes.Out); + icon.MoveTo(Vector2.Zero, 500, EasingTypes.Out); + icon.ScaleTo(0.7f, 500, EasingTypes.OutElasticHalf); + icon.ScaleTo(Vector2.One, 200, EasingTypes.Out); + + if (State == ButtonState.Expanded) + box.ScaleTo(new Vector2(1, 1), 500, EasingTypes.OutElastic); + } + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + trigger(); + return true; + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + base.OnKeyDown(state, args); + + if (triggerKey == args.Key && triggerKey != Key.Unknown) + { + trigger(); + return true; + } + + return false; + } + + private void trigger() + { + //Game.Audio.PlaySamplePositional($@"menu-{internalName}-click", internalName.Contains(@"back") ? @"menuback" : @"menuhit"); + + clickAction?.Invoke(); + + //box.FlashColour(ColourHelper.Lighten2(colour, 0.7f), 200); + } + + public override bool HandleInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f; + + protected override void Update() + { + iconText.Alpha = MathHelper.Clamp((box.Scale.X - 0.5f) / 0.3f, 0, 1); + base.Update(); + } + + public int ContractStyle; + + ButtonState state; + public ButtonState State + { + get { return state; } + set + { + + if (state == value) + return; + + state = value; + + switch (state) + { + case ButtonState.Contracted: + switch (ContractStyle) + { + default: + box.ScaleTo(new Vector2(0, 1), 500, EasingTypes.OutExpo); + FadeOut(500); + break; + case 1: + box.ScaleTo(new Vector2(0, 1), 400, EasingTypes.InSine); + FadeOut(800); + break; + } + break; + case ButtonState.Expanded: + const int expand_duration = 500; + box.ScaleTo(new Vector2(1, 1), expand_duration, EasingTypes.OutExpo); + FadeIn(expand_duration / 6); + break; + case ButtonState.Exploded: + const int explode_duration = 200; + box.ScaleTo(new Vector2(2, 1), explode_duration, EasingTypes.OutExpo); + FadeOut(explode_duration / 4 * 3); + break; + } + } + } + + /// + /// ________ + /// / / + /// / / + /// /_______/ + /// + class WedgedBox : Box + { + float wedgeWidth; + + public WedgedBox(Vector2 boxSize, float wedgeWidth) + { + Size = boxSize; + this.wedgeWidth = wedgeWidth; + } + + /// + /// Custom DrawQuad used to create the slanted effect. + /// + protected override Quad DrawQuad + { + get + { + Quad q = base.DrawQuad; + + //Will become infinite if we don't limit its maximum size. + float wedge = Math.Min(q.Width, wedgeWidth / Scale.X); + + q.TopLeft.X += wedge; + q.BottomRight.X -= wedge; + + return q; + } + } + } + } + + public enum ButtonState + { + Contracted, + Expanded, + Exploded + } +} diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 7cc2c85ffb..4624142d6f 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -16,10 +16,11 @@ using osu.Game.Graphics.Containers; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; +using osu.Framework; namespace osu.Game.GameModes.Menu { - public partial class ButtonSystem : Container + public partial class ButtonSystem : Container, IStateful { public Action OnEdit; public Action OnExit; @@ -32,9 +33,10 @@ namespace osu.Game.GameModes.Menu private FlowContainerWithOrigin buttonFlow; - const float button_area_height = 100; - const float button_width = 140f; - const float wedge_width = 20; + //todo: make these non-internal somehow. + internal const float button_area_height = 100; + internal const float button_width = 140f; + internal const float wedge_width = 20; public const int EXIT_DELAY = 3000; @@ -49,15 +51,6 @@ namespace osu.Game.GameModes.Menu List public EasingTypes RollingEasing = EasingTypes.None; + protected T prevVisibleCount; protected T visibleCount; /// @@ -65,13 +66,15 @@ namespace osu.Game.Graphics.UserInterface } protected set { + prevVisibleCount = visibleCount; if (visibleCount.Equals(value)) return; - transformVisibleCount(visibleCount, value); visibleCount = value; + transformVisibleCount(prevVisibleCount, value); } } + protected T prevCount; protected T count; /// @@ -85,6 +88,8 @@ namespace osu.Game.Graphics.UserInterface } set { + prevCount = count; + count = value; if (Clock != null) { RollingTotalDuration = @@ -93,13 +98,12 @@ namespace osu.Game.Graphics.UserInterface : RollingDuration; transformCount(IsRollingContinuous ? VisibleCount : count, value); } - count = value; } } protected RollingCounter() { - Debug.Assert(transformType.IsSubclassOf(typeof(Transform)), @"transformType should be a subclass of Transform."); + Debug.Assert(transformType.IsSubclassOf(typeof(Transform)) || transformType == typeof(Transform), @"transformType should be a subclass of Transform."); } public override void Load() diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index 5c355d06d6..d4eeb202fb 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -9,6 +9,7 @@ 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; @@ -20,26 +21,23 @@ namespace osu.Game.Graphics.UserInterface /// public class StarCounter : RollingCounter { - protected override Type transformType => typeof(TransformStar); - - protected float MinStarSize = 0.3f; + protected override Type transformType => typeof(TransformStarCounter); protected Container starContainer; protected List stars = new List(); + public ulong StarAnimationDuration = 500; + 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; - RollingEasing = EasingTypes.Out; } protected override ulong getProportionalDuration(float currentValue, float newValue) @@ -77,7 +75,7 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.Centre, TextSize = StarSize, Scale = new Vector2(MinStarSize), - Alpha = MinStarAlpha, + Alpha = (i == 0) ? 1.0f : MinStarAlpha, Position = new Vector2((StarSize + StarSpacing) * i + (StarSize + StarSpacing) / 2, 0), }; stars.Add(star); @@ -87,27 +85,79 @@ namespace osu.Game.Graphics.UserInterface ResetCount(); } - protected override void transformVisibleCount(float currentValue, float newValue) + protected override void transformCount(float currentValue, float newValue) { - for (int i = 0; i < MaxStars; i++) - { - if (newValue < i) - { - stars[i].Alpha = MinStarAlpha; - stars[i].ScaleTo(MinStarSize); - } - else - { - stars[i].Alpha = 1; - if (newValue > (i + 1)) - stars[i].ScaleTo(1f); - else - stars[i].ScaleTo(Interpolation.ValueAt(newValue, MinStarSize, 1f, i, i + 1, EasingTypes.None)); - } - } + transformStar((int)Math.Floor(currentValue), currentValue < newValue); + transformCount(new TransformStarCounter(Clock), currentValue, newValue); } - protected class TransformStar : Transform + 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((isIncrement ? Math.Min(i + 1, Count) : Math.Max(i, Count)), MinStarSize, 1.0f, i, i + 1)); + transform.Easing = EasingTypes.OutElasticHalf; + + 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, bool isIncrement) + { + 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, VisibleCount) : getProportionalDuration(i, VisibleCount); + // If decrementing, animation should had started when VisibleCount crossed end of star (i + 1) + else + startTime -= i == (int)Math.Floor(prevCount) ? getProportionalDuration(prevCount, VisibleCount) : getProportionalDuration(i + 1, VisibleCount); + + 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, 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, false); + } + + protected class TransformStarCounter : Transform { public override float CurrentValue { @@ -127,8 +177,8 @@ namespace osu.Game.Graphics.UserInterface (d as StarCounter).VisibleCount = CurrentValue; } - public TransformStar(IClock clock) - : base(clock) + public TransformStarCounter(IClock clock) + : base(clock) { } } From 841707b61f7798b49dc9defb5e30389d81fd0864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Sun, 9 Oct 2016 14:09:07 -0500 Subject: [PATCH 27/45] Not animate stars over MaxStars --- osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs | 2 +- osu.Game/Graphics/UserInterface/StarCounter.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 2ad177a6be..144adf9098 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -141,7 +141,7 @@ namespace osu.Desktop.Tests AddButton(@"Alter stars", delegate { - tc.Count = RNG.NextSingle() * tc.MaxStars; + tc.Count = RNG.NextSingle() * (tc.MaxStars + 1); text.Text = tc.Count.ToString("0.00"); }); diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index d4eeb202fb..b4576e6104 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -126,6 +126,9 @@ namespace osu.Game.Graphics.UserInterface protected void transformStar(int i, bool isIncrement) { + if (i >= MaxStars) + return; + if (Clock == null) return; From 01da3ca4748ba65f2b29c248a08039053e064332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Sun, 9 Oct 2016 14:48:24 -0500 Subject: [PATCH 28/45] More line wrapping --- .../Graphics/UserInterface/RollingCounter.cs | 9 ++++++--- .../Graphics/UserInterface/StarCounter.cs | 20 +++++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 1c7d024d85..6b6c82b76b 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -42,8 +42,8 @@ namespace osu.Game.Graphics.UserInterface public bool IsRollingProportional = false; /// - /// If IsRollingProportional = false, duration in milliseconds for the counter roll-up animation for each element. - /// If IsRollingProportional = true, duration in milliseconds for the counter roll-up animation in total. + /// 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. /// public ulong RollingDuration = 0; @@ -103,7 +103,10 @@ namespace osu.Game.Graphics.UserInterface protected RollingCounter() { - Debug.Assert(transformType.IsSubclassOf(typeof(Transform)) || transformType == typeof(Transform), @"transformType should be a subclass of Transform."); + Debug.Assert( + transformType.IsSubclassOf(typeof(Transform)) || transformType == typeof(Transform), + @"transformType should be a subclass of Transform." + ); } public override void Load() diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index b4576e6104..dad3bbd05a 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -97,7 +97,9 @@ namespace osu.Game.Graphics.UserInterface 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)); + stars[i].Transforms.RemoveAll(t => + t.GetType() == typeof(TransformScaleVector) || t.GetType() == typeof(TransformAlpha) + ); } protected void transformStarScale(int i, TransformScaleVector transform, bool isIncrement, double startTime) @@ -105,7 +107,15 @@ namespace osu.Game.Graphics.UserInterface transform.StartTime = startTime; transform.EndTime = transform.StartTime + StarAnimationDuration; transform.StartValue = stars[i].Scale; - transform.EndValue = new Vector2(Interpolation.ValueAt((isIncrement ? Math.Min(i + 1, Count) : Math.Max(i, Count)), MinStarSize, 1.0f, i, i + 1)); + transform.EndValue = new Vector2( + Interpolation.ValueAt( + (isIncrement ? Math.Min(i + 1, Count) : Math.Max(i, Count)), + MinStarSize, + 1.0f, + i, + i + 1 + ) + ); transform.Easing = EasingTypes.OutElasticHalf; stars[i].Transforms.Add(transform); @@ -136,10 +146,12 @@ namespace osu.Game.Graphics.UserInterface 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, VisibleCount) : getProportionalDuration(i, VisibleCount); + startTime -= i == (int)Math.Floor(prevCount) ? + getProportionalDuration(prevCount, VisibleCount) : getProportionalDuration(i, VisibleCount); // If decrementing, animation should had started when VisibleCount crossed end of star (i + 1) else - startTime -= i == (int)Math.Floor(prevCount) ? getProportionalDuration(prevCount, VisibleCount) : getProportionalDuration(i + 1, VisibleCount); + startTime -= i == (int)Math.Floor(prevCount) ? + getProportionalDuration(prevCount, VisibleCount) : getProportionalDuration(i + 1, VisibleCount); updateTransformStar(i); From fd1cbfd8fa851a0838e5dc82210347a0a312eaa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Sun, 9 Oct 2016 14:53:06 -0500 Subject: [PATCH 29/45] Hide VisibleCount from transformStar --- osu.Game/Graphics/UserInterface/StarCounter.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index dad3bbd05a..523527dcce 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -87,7 +87,7 @@ namespace osu.Game.Graphics.UserInterface protected override void transformCount(float currentValue, float newValue) { - transformStar((int)Math.Floor(currentValue), currentValue < newValue); + transformStar((int)Math.Floor(currentValue), currentValue, currentValue < newValue); transformCount(new TransformStarCounter(Clock), currentValue, newValue); } @@ -134,7 +134,7 @@ namespace osu.Game.Graphics.UserInterface } - protected void transformStar(int i, bool isIncrement) + protected void transformStar(int i, float value, bool isIncrement) { if (i >= MaxStars) return; @@ -147,11 +147,11 @@ namespace osu.Game.Graphics.UserInterface // If incrementing, animation should had started when VisibleCount crossed start of star (i) if (isIncrement) startTime -= i == (int)Math.Floor(prevCount) ? - getProportionalDuration(prevCount, VisibleCount) : getProportionalDuration(i, VisibleCount); + 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, VisibleCount) : getProportionalDuration(i + 1, VisibleCount); + getProportionalDuration(prevCount, value) : getProportionalDuration(i + 1, value); updateTransformStar(i); @@ -164,12 +164,12 @@ namespace osu.Game.Graphics.UserInterface // 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, true); + 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, false); + transformStar(i, newValue, false); } protected class TransformStarCounter : Transform From 4d0c8ed441cae1f4b4132b9c359c9307292e4b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Sun, 9 Oct 2016 14:55:50 -0500 Subject: [PATCH 30/45] StarAnimationEasing --- osu.Game/Graphics/UserInterface/StarCounter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index 523527dcce..67f2a2ae0c 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -27,6 +27,7 @@ namespace osu.Game.Graphics.UserInterface protected List stars = new List(); public ulong StarAnimationDuration = 500; + public EasingTypes StarAnimationEasing = EasingTypes.OutElasticHalf; public ulong FadeDuration = 100; public float MinStarSize = 0.3f; public float MinStarAlpha = 0.5f; @@ -116,7 +117,7 @@ namespace osu.Game.Graphics.UserInterface i + 1 ) ); - transform.Easing = EasingTypes.OutElasticHalf; + transform.Easing = StarAnimationEasing; stars[i].Transforms.Add(transform); } From 2954c1934519990f296d30130ac9ad185a1188ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Sun, 9 Oct 2016 15:19:35 -0500 Subject: [PATCH 31/45] Misc. fixes --- osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs | 2 +- osu.Game/Graphics/UserInterface/RollingCounter.cs | 2 +- osu.Game/Graphics/UserInterface/StandardComboCounter.cs | 2 +- osu.Game/Graphics/UserInterface/StarCounter.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs index 4a343737f1..8c5510eca4 100644 --- a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs @@ -62,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface protected virtual void transformAnimate() { - countSpriteText.Colour = TintColour; + countSpriteText.FadeColour(TintColour, 0); countSpriteText.ScaleTo(new Vector2(1, ScaleFactor)); countSpriteText.FadeColour(OriginalColour, TintDuration, TintEasing); countSpriteText.ScaleTo(new Vector2(1, 1), TintDuration, TintEasing); diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 6b6c82b76b..b0f757a378 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -96,7 +96,7 @@ namespace osu.Game.Graphics.UserInterface IsRollingProportional ? getProportionalDuration(VisibleCount, value) : RollingDuration; - transformCount(IsRollingContinuous ? VisibleCount : count, value); + transformCount(IsRollingContinuous ? VisibleCount : prevCount, value); } } } diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs index 7b8587ac94..b3af78b78e 100644 --- a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs @@ -23,7 +23,7 @@ namespace osu.Game.Graphics.UserInterface public float PopOutSmallScale = 1.2f; public EasingTypes PopOutEasing = EasingTypes.None; public bool CanPopOutWhenBackwards = false; - public float PopOutInitialAlpha = 1.0f; + public float PopOutInitialAlpha = 0.75f; public StandardComboCounter() : base() { diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index 67f2a2ae0c..3ee67a38d6 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -110,7 +110,7 @@ namespace osu.Game.Graphics.UserInterface transform.StartValue = stars[i].Scale; transform.EndValue = new Vector2( Interpolation.ValueAt( - (isIncrement ? Math.Min(i + 1, Count) : Math.Max(i, Count)), + Math.Min(Math.Max(i, Count), i + 1), MinStarSize, 1.0f, i, From 0b08c8ba15052a42e887d8dc6395ad05a744b85a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Oct 2016 14:18:06 +0900 Subject: [PATCH 32/45] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index aaa35586b9..19252f6177 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit aaa35586b9e3243f90d17657c91a0371296483e3 +Subproject commit 19252f6177622908cfbbf3caed7ceca42e5832d6 From 3f83ffcb996083e49576145416dc431133e55919 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Oct 2016 14:36:27 +0900 Subject: [PATCH 33/45] Bring framework up-to-date with upstream master. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index a191e86dba..857a472d57 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a191e86dbae40c4530ed3ff4b291732696e3a2b0 +Subproject commit 857a472d570227937de549d50fa8bd672022afbf From 4ac2c9ad901eeee08b4568d721f1b7b439a0a143 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Oct 2016 15:12:21 +0900 Subject: [PATCH 34/45] Update framework to fix draw order. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 857a472d57..c610557427 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 857a472d570227937de549d50fa8bd672022afbf +Subproject commit c6105574275ac3bed45a45feb77b34bedda925a8 From c0ea061bd4d5d26f543b962128aaaa4a2390bc29 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Oct 2016 12:22:19 +0900 Subject: [PATCH 35/45] Update framework; amend ToolbarButton to use padding and Children initialiser. --- osu-framework | 2 +- osu.Desktop.VisualTests/Program.cs | 2 +- osu.Desktop/Program.cs | 2 +- osu.Game/GameModes/Menu/ButtonSystem.cs | 2 +- .../Online/Chat/Display/ChannelDisplay.cs | 2 +- osu.Game/Online/Chat/Display/ChatLine.cs | 5 +- osu.Game/Overlays/ToolbarButton.cs | 125 ++++++------------ 7 files changed, 52 insertions(+), 88 deletions(-) diff --git a/osu-framework b/osu-framework index 1f770847b2..f47b7132ca 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 1f770847b245e6d250e63e60c24e9e84131d15e7 +Subproject commit f47b7132ca5d579e7a4c011bbfa38a7bb6c91c6a diff --git a/osu.Desktop.VisualTests/Program.cs b/osu.Desktop.VisualTests/Program.cs index 1cfa440dd9..4dcfaff987 100644 --- a/osu.Desktop.VisualTests/Program.cs +++ b/osu.Desktop.VisualTests/Program.cs @@ -12,7 +12,7 @@ namespace osu.Framework.VisualTests [STAThread] public static void Main(string[] args) { - BasicGameHost host = Host.GetSuitableHost(); + BasicGameHost host = Host.GetSuitableHost(@"osu-visual-tests"); host.Add(new VisualTestGame()); host.Run(); } diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index fe7423924c..1421086054 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -13,7 +13,7 @@ namespace osu.Desktop [STAThread] public static void Main() { - BasicGameHost host = Host.GetSuitableHost(); + BasicGameHost host = Host.GetSuitableHost(@"osu"); host.Add(new OsuGame()); host.Run(); } diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 1f0888d7ea..00cef96ec9 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -82,7 +82,7 @@ namespace osu.Game.GameModes.Menu buttonFlow = new FlowContainerWithOrigin { Anchor = Anchor.Centre, - Padding = new Vector2(-wedge_width, 0), + Spacing = new Vector2(-wedge_width, 0), Children = new Drawable[] { settingsButton = new Button(@"settings", @"options", FontAwesome.gear, new Color4(85, 85, 85, 255), OnSettings, -wedge_width, Key.O), diff --git a/osu.Game/Online/Chat/Display/ChannelDisplay.cs b/osu.Game/Online/Chat/Display/ChannelDisplay.cs index 1b8c4e743e..f4c4417cd3 100644 --- a/osu.Game/Online/Chat/Display/ChannelDisplay.cs +++ b/osu.Game/Online/Chat/Display/ChannelDisplay.cs @@ -47,7 +47,7 @@ namespace osu.Game.Online.Chat.Display Direction = FlowDirection.VerticalOnly, RelativeSizeAxes = Axes.X, LayoutEasing = EasingTypes.Out, - Padding = new Vector2(1, 1) + Spacing = new Vector2(1, 1) } } } diff --git a/osu.Game/Online/Chat/Display/ChatLine.cs b/osu.Game/Online/Chat/Display/ChatLine.cs index 125463e666..5dc8b7133a 100644 --- a/osu.Game/Online/Chat/Display/ChatLine.cs +++ b/osu.Game/Online/Chat/Display/ChatLine.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Drawables; using osu.Framework.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Graphics.Primitives; namespace osu.Game.Online.Chat.Display { @@ -54,10 +55,10 @@ namespace osu.Game.Online.Chat.Display } } }, - new PaddingContainer + new Container { RelativeSizeAxes = Axes.X, - Padding = new Padding { Left = padding + 10 }, + Padding = new MarginPadding { Left = padding + 10 }, Children = new Drawable[] { new SpriteText diff --git a/osu.Game/Overlays/ToolbarButton.cs b/osu.Game/Overlays/ToolbarButton.cs index 815f31590b..a6798d6582 100644 --- a/osu.Game/Overlays/ToolbarButton.cs +++ b/osu.Game/Overlays/ToolbarButton.cs @@ -10,6 +10,7 @@ using osu.Framework.Input; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Graphics.Primitives; namespace osu.Game.Overlays { @@ -29,7 +30,6 @@ namespace osu.Game.Overlays set { DrawableText.Text = value; - paddingIcon.Alpha = string.IsNullOrEmpty(value) ? 0 : 1; } } @@ -55,110 +55,73 @@ namespace osu.Game.Overlays protected TextAwesome DrawableIcon; protected SpriteText DrawableText; protected Box HoverBackground; - private Drawable paddingLeft; - private Drawable paddingRight; - private Drawable paddingIcon; private FlowContainer tooltipContainer; private SpriteText tooltip1; private SpriteText tooltip2; - public new float Padding - { - get { return paddingLeft.Size.X; } - set - { - paddingLeft.Size = new Vector2(value, 1); - paddingRight.Size = new Vector2(value, 1); - tooltipContainer.Position = new Vector2(value, tooltipContainer.Position.Y); - } - } - public ToolbarButton() { - HoverBackground = new Box + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Additive = true, - Colour = new Color4(60, 60, 60, 255), - Alpha = 0, - }; - - DrawableIcon = new TextAwesome - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - }; - - DrawableText = new SpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - }; - - tooltipContainer = new FlowContainer - { - Direction = FlowDirection.VerticalOnly, - Anchor = Anchor.BottomLeft, - Position = new Vector2(0, -5), - Alpha = 0, - Children = new[] + HoverBackground = new Box { - tooltip1 = new SpriteText() + RelativeSizeAxes = Axes.Both, + Additive = true, + Colour = new Color4(60, 60, 60, 255), + Alpha = 0, + }, + new FlowContainer + { + Direction = FlowDirection.HorizontalOnly, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Padding = new MarginPadding { Left = 5, Right = 5 }, + RelativeSizeAxes = Axes.Y, + Children = new Drawable[] { - TextSize = 22, + DrawableIcon = new TextAwesome + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, + DrawableText = new SpriteText + { + Margin = new MarginPadding { Left = 5 }, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, }, - tooltip2 = new SpriteText + }, + tooltipContainer = new FlowContainer + { + Direction = FlowDirection.VerticalOnly, + Anchor = Anchor.BottomLeft, + Position = new Vector2(5, -5), + Alpha = 0, + Children = new[] { - TextSize = 15 + tooltip1 = new SpriteText() + { + TextSize = 22, + }, + tooltip2 = new SpriteText + { + TextSize = 15 + } } } }; - paddingLeft = new Container { RelativeSizeAxes = Axes.Y }; - paddingRight = new Container { RelativeSizeAxes = Axes.Y }; - paddingIcon = new Container - { - Size = new Vector2(5, 0), - Alpha = 0 - }; - - Padding = 10; RelativeSizeAxes = Axes.Y; Size = new Vector2(WIDTH, 1); } - public override void Load() - { - base.Load(); - - Children = new Drawable[] - { - HoverBackground, - new FlowContainer - { - Direction = FlowDirection.HorizontalOnly, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.Y, - Children = new Drawable[] - { - paddingLeft, - DrawableIcon, - paddingIcon, - DrawableText, - paddingRight - }, - }, - tooltipContainer - }; - } - protected override void Update() { base.Update(); //todo: find a way to avoid using this (autosize needs to be able to ignore certain drawables.. in this case the tooltip) - Size = new Vector2(WIDTH + DrawableText.Size.X, 1); + Size = new Vector2(WIDTH + (DrawableText.IsVisible ? DrawableText.Size.X : 0), 1); } protected override bool OnClick(InputState state) From 05031d18ef2947f6524f909523a8cec61e0493a8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Oct 2016 13:35:21 +0900 Subject: [PATCH 36/45] Fix some display regressions in ChatConsole. --- osu.Game/Online/Chat/Display/ChannelDisplay.cs | 5 +---- osu.Game/Overlays/ChatConsole.cs | 16 +++++----------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/osu.Game/Online/Chat/Display/ChannelDisplay.cs b/osu.Game/Online/Chat/Display/ChannelDisplay.cs index f4c4417cd3..ad7db24a55 100644 --- a/osu.Game/Online/Chat/Display/ChannelDisplay.cs +++ b/osu.Game/Online/Chat/Display/ChannelDisplay.cs @@ -13,7 +13,7 @@ using OpenTK; namespace osu.Game.Online.Chat.Display { - public class ChannelDisplay : FlowContainer + public class ChannelDisplay : Container { private readonly Channel channel; private FlowContainer flow; @@ -25,7 +25,6 @@ namespace osu.Game.Online.Chat.Display channel.NewMessagesArrived += newMessages; RelativeSizeAxes = Axes.Both; - Direction = FlowDirection.VerticalOnly; Children = new Drawable[] { @@ -39,14 +38,12 @@ namespace osu.Game.Online.Chat.Display }, new ScrollContainer { - RelativeSizeAxes = Axes.Both, Children = new Drawable[] { flow = new FlowContainer { Direction = FlowDirection.VerticalOnly, RelativeSizeAxes = Axes.X, - LayoutEasing = EasingTypes.Out, Spacing = new Vector2(1, 1) } } diff --git a/osu.Game/Overlays/ChatConsole.cs b/osu.Game/Overlays/ChatConsole.cs index c8e9cb2233..8f068fd8ed 100644 --- a/osu.Game/Overlays/ChatConsole.cs +++ b/osu.Game/Overlays/ChatConsole.cs @@ -44,19 +44,19 @@ namespace osu.Game.Overlays Anchor = Anchor.BottomLeft; Origin = Anchor.BottomLeft; - InternalChildren = new Drawable[] + AddInternal(new Drawable[] { new Box { Depth = float.MinValue, RelativeSizeAxes = Axes.Both, - Colour = new Color4(0.1f, 0.1f, 0.1f, 0.4f) + Colour = new Color4(0.1f, 0.1f, 0.1f, 0.4f), }, content = new Container { RelativeSizeAxes = Axes.Both, } - }; + }); } public override void Load() @@ -76,12 +76,6 @@ namespace osu.Game.Overlays //if (api.State != APIAccess.APIState.Online) // return; - Add(new FlowContainer - { - RelativeSizeAxes = Axes.Both, - Direction = FlowDirection.VerticalOnly - }); - SpriteText loading; Add(loading = new SpriteText { @@ -99,9 +93,9 @@ namespace osu.Game.Overlays Scheduler.Add(delegate { loading.FadeOut(100); + addChannel(channels.Find(c => c.Name == @"#osu")); }); - - addChannel(channels.Find(c => c.Name == @"#osu")); + //addChannel(channels.Find(c => c.Name == @"#lobby")); //addChannel(channels.Find(c => c.Name == @"#english")); From 9276244d6a647738d5d1977cbc78575aae839cab Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Oct 2016 15:21:59 +0900 Subject: [PATCH 37/45] getter on single line. --- osu.Game/Overlays/ChatConsole.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/ChatConsole.cs b/osu.Game/Overlays/ChatConsole.cs index 8f068fd8ed..d6626a1d9e 100644 --- a/osu.Game/Overlays/ChatConsole.cs +++ b/osu.Game/Overlays/ChatConsole.cs @@ -95,7 +95,7 @@ namespace osu.Game.Overlays loading.FadeOut(100); addChannel(channels.Find(c => c.Name == @"#osu")); }); - + //addChannel(channels.Find(c => c.Name == @"#lobby")); //addChannel(channels.Find(c => c.Name == @"#english")); @@ -142,10 +142,7 @@ namespace osu.Game.Overlays public ChatConsoleState State { - get - { - return state; - } + get { return state; } set { From 24771a62cf25398648533e5f12af46aba11d2394 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Oct 2016 15:22:57 +0900 Subject: [PATCH 38/45] Remove upwards reference. --- osu.Game/OsuGame.cs | 2 +- osu.Game/Overlays/ChatConsole.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 909b6e0842..a926888571 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -56,7 +56,7 @@ namespace osu.Game OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, Alpha = 0.001f, }, - Chat = new ChatConsole(), + Chat = new ChatConsole(API), new VolumeControl { VolumeGlobal = Audio.Volume, diff --git a/osu.Game/Overlays/ChatConsole.cs b/osu.Game/Overlays/ChatConsole.cs index d6626a1d9e..0d457fe116 100644 --- a/osu.Game/Overlays/ChatConsole.cs +++ b/osu.Game/Overlays/ChatConsole.cs @@ -27,8 +27,6 @@ namespace osu.Game.Overlays { public class ChatConsole : Container, IStateful { - private APIAccess api => ((OsuGameBase)Game).API; - private ChannelDisplay channelDisplay; private ScheduledDelegate messageRequest; @@ -37,8 +35,12 @@ namespace osu.Game.Overlays protected override Container Content => content; - public ChatConsole() + private APIAccess api; + + public ChatConsole(APIAccess api) { + this.api = api; + RelativeSizeAxes = Axes.X; Size = new Vector2(1, 300); Anchor = Anchor.BottomLeft; From 1c0b76945143bb40f39bda8ccfa0968f5cb86d53 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Oct 2016 15:25:07 +0900 Subject: [PATCH 39/45] Centralise the maximum chat history variable. --- osu.Game/Online/Chat/Channel.cs | 10 ++++------ osu.Game/Online/Chat/Display/ChannelDisplay.cs | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index 59d0cd8cc1..92e93d4a08 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -30,6 +30,8 @@ namespace osu.Game.Online.Chat //internal bool Joined; + public const int MAX_HISTORY = 100; + [JsonConstructor] public Channel() { @@ -47,13 +49,9 @@ namespace osu.Game.Online.Chat private void purgeOldMessages() { - const int max_history = 50; - int messageCount = Messages.Count; - if (messageCount > 50) - { - Messages.RemoveRange(0, messageCount - max_history); - } + if (messageCount > MAX_HISTORY) + Messages.RemoveRange(0, messageCount - MAX_HISTORY); } } } diff --git a/osu.Game/Online/Chat/Display/ChannelDisplay.cs b/osu.Game/Online/Chat/Display/ChannelDisplay.cs index ad7db24a55..4c6bc4af80 100644 --- a/osu.Game/Online/Chat/Display/ChannelDisplay.cs +++ b/osu.Game/Online/Chat/Display/ChannelDisplay.cs @@ -67,13 +67,13 @@ namespace osu.Game.Online.Chat.Display { if (!IsLoaded) return; - var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - 20)); + var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY)); - //up to last 20 messages + //up to last Channel.MAX_HISTORY messages foreach (Message m in displayMessages) flow.Add(new ChatLine(m)); - while (flow.Children.Count() > 20) + while (flow.Children.Count() > Channel.MAX_HISTORY) flow.Remove(flow.Children.First()); } } From f737090c6b510817cf7879fd500c23246241a73f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Oct 2016 15:28:28 +0900 Subject: [PATCH 40/45] Make CentreTarget public. --- osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs b/osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs index e935f353d8..a618e81e1f 100644 --- a/osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs +++ b/osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs @@ -11,9 +11,9 @@ namespace osu.Game.GameModes.Menu { /// /// A target drawable which this flowcontainer should be centered around. - /// This target MUST be in this FlowContainer's *direct* children. + /// This target should be a direct child of this FlowContainer. /// - internal Drawable CentreTarget; + public Drawable CentreTarget; public override Anchor Origin => Anchor.Custom; From af76dc09d3cbce33d93248e870629be047315ce1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Oct 2016 15:33:04 +0900 Subject: [PATCH 41/45] Move direction declaration to usage. --- osu.Game/GameModes/Menu/ButtonSystem.cs | 3 ++- osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 00cef96ec9..155d06dd8b 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -81,6 +81,7 @@ namespace osu.Game.GameModes.Menu }, buttonFlow = new FlowContainerWithOrigin { + Direction = FlowDirection.HorizontalOnly, Anchor = Anchor.Centre, Spacing = new Vector2(-wedge_width, 0), Children = new Drawable[] @@ -133,7 +134,7 @@ namespace osu.Game.GameModes.Menu State = MenuState.Initial; return true; } - + return true; } diff --git a/osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs b/osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs index a618e81e1f..890a1948a3 100644 --- a/osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs +++ b/osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs @@ -27,10 +27,5 @@ namespace osu.Game.GameModes.Menu return CentreTarget.Position + CentreTarget.Size / 2; } } - - public FlowContainerWithOrigin() - { - Direction = FlowDirection.HorizontalOnly; - } } } From 4052a665bf46aa7b8879afc8e44997dfc51a308b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Oct 2016 17:17:26 +0900 Subject: [PATCH 42/45] Remove all non-load Game access. --- osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs | 10 +++++++++- osu.Desktop.VisualTests/VisualTestGame.cs | 4 ++-- osu.Game/GameModes/BackgroundMode.cs | 5 +++-- .../GameModes/Backgrounds/BackgroundModeCustom.cs | 5 +++-- .../GameModes/Backgrounds/BackgroundModeDefault.cs | 5 +++-- osu.Game/GameModes/GameModeWhiteBox.cs | 5 +++-- osu.Game/GameModes/Menu/ButtonSystem.cs | 9 +++++---- osu.Game/GameModes/Menu/Intro.cs | 8 ++++---- osu.Game/GameModes/Menu/MainMenu.cs | 7 ++++--- osu.Game/GameModes/Menu/OsuLogo.cs | 9 +++++---- osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs | 10 ++++------ osu.Game/GameModes/Play/Catch/CatchPlayfield.cs | 5 +++-- osu.Game/GameModes/Play/HitRenderer.cs | 5 +++-- osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs | 10 ++++------ osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs | 5 +++-- osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs | 12 ++++++------ osu.Game/GameModes/Play/Osu/OsuPlayfield.cs | 5 +++-- osu.Game/GameModes/Play/PlaySongSelect.cs | 7 ++++--- osu.Game/GameModes/Play/Player.cs | 7 ++++--- osu.Game/GameModes/Play/Playfield.cs | 5 +++-- osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs | 10 ++++------ osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs | 7 ++++--- osu.Game/Graphics/Background/Background.cs | 7 ++++--- osu.Game/Graphics/Containers/ParallaxContainer.cs | 5 +++-- osu.Game/Graphics/Cursor/OsuCursorContainer.cs | 7 ++++--- osu.Game/Graphics/UserInterface/KeyCounter.cs | 9 +++++---- osu.Game/Online/Chat/Display/ChatLine.cs | 5 +++-- osu.Game/OsuGame.cs | 5 +++-- osu.Game/OsuGameBase.cs | 9 +++++---- osu.Game/Overlays/Options.cs | 5 +++-- osu.Game/Overlays/Toolbar.cs | 7 ++++--- osu.Game/Overlays/ToolbarModeButton.cs | 5 +++-- osu.Game/Overlays/ToolbarModeSelector.cs | 5 +++-- osu.Game/VolumeControl.cs | 5 +++-- 34 files changed, 129 insertions(+), 100 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 353ad4f9f1..ff8f0e07dc 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -16,6 +16,7 @@ using System.Diagnostics; using System.Linq; using osu.Framework.Graphics.Sprites; using osu.Game.Online.Chat.Display.osu.Online.Social; +using osu.Framework; namespace osu.Desktop.Tests { @@ -31,10 +32,17 @@ namespace osu.Desktop.Tests private Scheduler scheduler = new Scheduler(); - private APIAccess api => ((OsuGameBase)Game).API; + private APIAccess api; private long? lastMessageId; + public override void Load(BaseGame game) + { + base.Load(game); + + api = ((OsuGameBase)game).API; + } + public override void Reset() { base.Reset(); diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index ecbaf7ac8f..bc4c59c4e3 100644 --- a/osu.Desktop.VisualTests/VisualTestGame.cs +++ b/osu.Desktop.VisualTests/VisualTestGame.cs @@ -9,9 +9,9 @@ namespace osu.Framework.VisualTests { class VisualTestGame : OsuGameBase { - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Add(new TestBrowser()); diff --git a/osu.Game/GameModes/BackgroundMode.cs b/osu.Game/GameModes/BackgroundMode.cs index 1f90448e55..d9b1c1b18f 100644 --- a/osu.Game/GameModes/BackgroundMode.cs +++ b/osu.Game/GameModes/BackgroundMode.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Transformations; using OpenTK; using osu.Framework.Graphics; using osu.Framework.Input; +using osu.Framework; namespace osu.Game.GameModes { @@ -30,9 +31,9 @@ namespace osu.Game.GameModes return false; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Content.Scale *= 1 + (x_movement_amount / Size.X) * 2; } diff --git a/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs b/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs index ae8e2d916e..7b1756436f 100644 --- a/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs +++ b/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs @@ -1,6 +1,7 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework; using osu.Game.Graphics.Background; namespace osu.Game.GameModes.Backgrounds @@ -14,9 +15,9 @@ namespace osu.Game.GameModes.Backgrounds this.textureName = textureName; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Add(new Background(textureName)); } diff --git a/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs b/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs index 0683a267a5..542e9b58b7 100644 --- a/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs +++ b/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs @@ -1,15 +1,16 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework; using osu.Game.Graphics.Background; namespace osu.Game.GameModes.Backgrounds { public class BackgroundModeDefault : BackgroundMode { - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Add(new Background()); } diff --git a/osu.Game/GameModes/GameModeWhiteBox.cs b/osu.Game/GameModes/GameModeWhiteBox.cs index 46250d9a91..121cb20d12 100644 --- a/osu.Game/GameModes/GameModeWhiteBox.cs +++ b/osu.Game/GameModes/GameModeWhiteBox.cs @@ -13,6 +13,7 @@ using osu.Framework.Graphics.UserInterface; using osu.Game.GameModes.Backgrounds; using OpenTK; using OpenTK.Graphics; +using osu.Framework; namespace osu.Game.GameModes { @@ -77,9 +78,9 @@ namespace osu.Game.GameModes Content.FadeIn(transition_time, EasingTypes.OutExpo); } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Children = new Drawable[] { diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 93701e6c18..75d6288a4f 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -16,6 +16,7 @@ using osu.Game.Graphics.Containers; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; +using osu.Framework; namespace osu.Game.GameModes.Menu { @@ -63,9 +64,9 @@ namespace osu.Game.GameModes.Menu RelativeSizeAxes = Axes.Both; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Children = new Drawable[] { @@ -346,9 +347,9 @@ namespace osu.Game.GameModes.Menu this.text = text; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Alpha = 0; Children = new Drawable[] diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index e70b2639cf..5127f5be5c 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -23,9 +23,9 @@ namespace osu.Game.GameModes.Menu protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty(); - public override void Load() + public override void Load(Framework.BaseGame game) { - base.Load(); + base.Load(game); Children = new Drawable[] { @@ -39,9 +39,9 @@ namespace osu.Game.GameModes.Menu } }; - AudioSample welcome = Game.Audio.Sample.Get(@"welcome"); + AudioSample welcome = game.Audio.Sample.Get(@"welcome"); - AudioTrack bgm = Game.Audio.Track.Get(@"circles"); + AudioTrack bgm = game.Audio.Track.Get(@"circles"); bgm.Looping = true; Scheduler.Add(delegate diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index e74c83e03d..c700b370c2 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -15,6 +15,7 @@ using osu.Game.GameModes.Multiplayer; using osu.Game.GameModes.Play; using osu.Game.Graphics.Containers; using OpenTK; +using osu.Framework; namespace osu.Game.GameModes.Menu { @@ -25,11 +26,11 @@ namespace osu.Game.GameModes.Menu protected override BackgroundMode CreateBackground() => new BackgroundModeDefault(); - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); - OsuGame osu = (OsuGame)Game; + OsuGame osu = (OsuGame)game; Children = new Drawable[] { diff --git a/osu.Game/GameModes/Menu/OsuLogo.cs b/osu.Game/GameModes/Menu/OsuLogo.cs index 5e50ae5db4..5190e1f027 100644 --- a/osu.Game/GameModes/Menu/OsuLogo.cs +++ b/osu.Game/GameModes/Menu/OsuLogo.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; +using osu.Framework; namespace osu.Game.GameModes.Menu { @@ -82,12 +83,12 @@ namespace osu.Game.GameModes.Menu }; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); - logo.Texture = Game.Textures.Get(@"Menu/logo"); - ripple.Texture = Game.Textures.Get(@"Menu/logo"); + logo.Texture = game.Textures.Get(@"Menu/logo"); + ripple.Texture = game.Textures.Get(@"Menu/logo"); ripple.ScaleTo(1.1f, 500); ripple.FadeOut(500); diff --git a/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs b/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs index 0c42039af0..d6543360fc 100644 --- a/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs +++ b/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs @@ -10,6 +10,7 @@ using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Osu; using osu.Game.Beatmaps.Objects.Catch; using OpenTK; +using osu.Framework; namespace osu.Game.GameModes.Play.Catch { @@ -24,9 +25,6 @@ namespace osu.Game.GameModes.Play.Catch { //osu! mode requires all objects to be of CatchBaseHit type. objects = value.ConvertAll(convertForCatch); - - if (Parent != null) - Load(); } } @@ -50,9 +48,9 @@ namespace osu.Game.GameModes.Play.Catch return h; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); if (playfield == null) Add(playfield = new CatchPlayfield()); @@ -66,7 +64,7 @@ namespace osu.Game.GameModes.Play.Catch //render stuff! Sprite s = new Sprite { - Texture = Game.Textures.Get(@"Menu/logo"), + Texture = game.Textures.Get(@"Menu/logo"), Origin = Anchor.Centre, Scale = new Vector2(0.1f), RelativePositionAxes = Axes.Y, diff --git a/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs b/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs index 97979319e2..fef80e6b4a 100644 --- a/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs +++ b/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Drawables; using osu.Framework.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; +using osu.Framework; namespace osu.Game.GameModes.Play.Catch { @@ -20,9 +21,9 @@ namespace osu.Game.GameModes.Play.Catch Origin = Anchor.BottomCentre; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); } diff --git a/osu.Game/GameModes/Play/HitRenderer.cs b/osu.Game/GameModes/Play/HitRenderer.cs index 6016c93a34..06d98da836 100644 --- a/osu.Game/GameModes/Play/HitRenderer.cs +++ b/osu.Game/GameModes/Play/HitRenderer.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Drawables; using osu.Game.Beatmaps.Objects; using OpenTK; using OpenTK.Graphics; +using osu.Framework; namespace osu.Game.GameModes.Play { @@ -21,9 +22,9 @@ namespace osu.Game.GameModes.Play RelativeSizeAxes = Axes.Both; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Add(new Box() { diff --git a/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs b/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs index e001626974..1e55e552d3 100644 --- a/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs +++ b/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs @@ -10,6 +10,7 @@ using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Osu; using osu.Game.Beatmaps.Objects.Mania; using OpenTK; +using osu.Framework; namespace osu.Game.GameModes.Play.Mania { @@ -30,9 +31,6 @@ namespace osu.Game.GameModes.Play.Mania { //osu! mode requires all objects to be of ManiaBaseHit type. objects = value.ConvertAll(convertForMania); - - if (Parent != null) - Load(); } } @@ -56,9 +54,9 @@ namespace osu.Game.GameModes.Play.Mania return h; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); if (playfield == null) Add(playfield = new ManiaPlayfield(columns)); @@ -72,7 +70,7 @@ namespace osu.Game.GameModes.Play.Mania //render stuff! Sprite s = new Sprite { - Texture = Game.Textures.Get(@"Menu/logo"), + Texture = game.Textures.Get(@"Menu/logo"), Origin = Anchor.Centre, Scale = new Vector2(0.1f), RelativePositionAxes = Axes.Both, diff --git a/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs b/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs index 287db8777b..53de8221eb 100644 --- a/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs +++ b/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Drawables; using osu.Framework.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; +using osu.Framework; namespace osu.Game.GameModes.Play.Mania { @@ -23,9 +24,9 @@ namespace osu.Game.GameModes.Play.Mania Origin = Anchor.BottomCentre; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Add(new Box() { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); diff --git a/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs b/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs index d2f72fd85f..1f027fb6ae 100644 --- a/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs +++ b/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Transformations; using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Osu; using OpenTK; +using System.Diagnostics; namespace osu.Game.GameModes.Play.Osu { @@ -20,17 +21,16 @@ namespace osu.Game.GameModes.Play.Osu { set { + Debug.Assert(objects == null); + //osu! mode requires all objects to be of OsuBaseHit type. objects = value.ConvertAll(o => (OsuBaseHit)o); - - if (Parent != null) - Load(); } } - public override void Load() + public override void Load(Framework.BaseGame game) { - base.Load(); + base.Load(game); if (playfield == null) Add(playfield = new OsuPlayfield()); @@ -44,7 +44,7 @@ namespace osu.Game.GameModes.Play.Osu //render stuff! Sprite s = new Sprite { - Texture = Game.Textures.Get(@"Menu/logo"), + Texture = game.Textures.Get(@"Menu/logo"), Origin = Anchor.Centre, Scale = new Vector2(0.1f), Alpha = 0, diff --git a/osu.Game/GameModes/Play/Osu/OsuPlayfield.cs b/osu.Game/GameModes/Play/Osu/OsuPlayfield.cs index dd3348d8e1..e232a2af40 100644 --- a/osu.Game/GameModes/Play/Osu/OsuPlayfield.cs +++ b/osu.Game/GameModes/Play/Osu/OsuPlayfield.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Drawables; using OpenTK; +using osu.Framework; namespace osu.Game.GameModes.Play.Osu { @@ -18,9 +19,9 @@ namespace osu.Game.GameModes.Play.Osu Origin = Anchor.Centre; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Add(new Box() { diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index 06f7d8f914..df120ba8ba 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using osu.Framework.Configuration; using osu.Game.GameModes.Backgrounds; +using osu.Framework; namespace osu.Game.GameModes.Play { @@ -19,11 +20,11 @@ namespace osu.Game.GameModes.Play typeof(Player) }; - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); - OsuGame osu = Game as OsuGame; + OsuGame osu = game as OsuGame; playMode = osu.PlayMode; playMode.ValueChanged += PlayMode_ValueChanged; diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index 3a8685b501..829b3e8db0 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -20,6 +20,7 @@ using osu.Game.GameModes.Play.Taiko; using osu.Game.Graphics.UserInterface; using OpenTK; using OpenTK.Input; +using osu.Framework; namespace osu.Game.GameModes.Play { @@ -31,9 +32,9 @@ namespace osu.Game.GameModes.Play typeof(Results) }; - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); List objects = new List(); @@ -54,7 +55,7 @@ namespace osu.Game.GameModes.Play HitObjects = objects }; - OsuGame osu = Game as OsuGame; + OsuGame osu = game as OsuGame; switch (osu.PlayMode.Value) { diff --git a/osu.Game/GameModes/Play/Playfield.cs b/osu.Game/GameModes/Play/Playfield.cs index 41a73472d8..aee8287be3 100644 --- a/osu.Game/GameModes/Play/Playfield.cs +++ b/osu.Game/GameModes/Play/Playfield.cs @@ -1,15 +1,16 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework; using osu.Framework.Graphics.Containers; namespace osu.Game.GameModes.Play { public class Playfield : Container { - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Masking = true; } diff --git a/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs b/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs index 7315614c8d..2874c62fca 100644 --- a/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs +++ b/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs @@ -10,6 +10,7 @@ using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Osu; using osu.Game.Beatmaps.Objects.Taiko; using OpenTK; +using osu.Framework; namespace osu.Game.GameModes.Play.Taiko { @@ -24,9 +25,6 @@ namespace osu.Game.GameModes.Play.Taiko { //osu! mode requires all objects to be of TaikoBaseHit type. objects = value.ConvertAll(convertForTaiko); - - if (Parent != null) - Load(); } } @@ -49,9 +47,9 @@ namespace osu.Game.GameModes.Play.Taiko return h; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); if (playfield == null) Add(playfield = new TaikoPlayfield()); @@ -65,7 +63,7 @@ namespace osu.Game.GameModes.Play.Taiko //render stuff! Sprite s = new Sprite { - Texture = Game.Textures.Get(@"Menu/logo"), + Texture = game.Textures.Get(@"Menu/logo"), Origin = Anchor.Centre, Scale = new Vector2(0.2f), RelativePositionAxes = Axes.Both, diff --git a/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs b/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs index e99914c1c2..0f2ab70727 100644 --- a/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs +++ b/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Drawables; using osu.Framework.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; +using osu.Framework; namespace osu.Game.GameModes.Play.Taiko { @@ -20,15 +21,15 @@ namespace osu.Game.GameModes.Play.Taiko Origin = Anchor.Centre; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); Add(new Sprite { - Texture = Game.Textures.Get(@"Menu/logo"), + Texture = game.Textures.Get(@"Menu/logo"), Origin = Anchor.Centre, Scale = new Vector2(0.2f), RelativePositionAxes = Axes.Both, diff --git a/osu.Game/Graphics/Background/Background.cs b/osu.Game/Graphics/Background/Background.cs index 8333d975f9..a0bb99f589 100644 --- a/osu.Game/Graphics/Background/Background.cs +++ b/osu.Game/Graphics/Background/Background.cs @@ -8,6 +8,7 @@ using osu.Game.Graphics.Containers; using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework; namespace osu.Game.Graphics.Background { @@ -24,13 +25,13 @@ namespace osu.Game.Graphics.Background Depth = float.MinValue; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Add(BackgroundSprite = new Sprite { - Texture = Game.Textures.Get(textureName), + Texture = game.Textures.Get(textureName), Anchor = Anchor.Centre, Origin = Anchor.Centre, Colour = Color4.DarkGray diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 183b0c054a..129997e663 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -2,6 +2,7 @@ using osu.Framework.Graphics; using osu.Framework.Input; using OpenTK; +using osu.Framework; namespace osu.Game.Graphics.Containers { @@ -26,9 +27,9 @@ namespace osu.Game.Graphics.Containers protected override Container Content => content; - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); } protected override bool OnMouseMove(InputState state) diff --git a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs index 8f862d288a..3239961eff 100644 --- a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs @@ -1,6 +1,7 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -35,15 +36,15 @@ namespace osu.Game.Graphics.Cursor Origin = Anchor.Centre; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Children = new Drawable[] { new Sprite { - Texture = Game.Textures.Get(@"Cursor/cursor") + Texture = game.Textures.Get(@"Cursor/cursor") } }; } diff --git a/osu.Game/Graphics/UserInterface/KeyCounter.cs b/osu.Game/Graphics/UserInterface/KeyCounter.cs index 480476ed00..5f48de699b 100644 --- a/osu.Game/Graphics/UserInterface/KeyCounter.cs +++ b/osu.Game/Graphics/UserInterface/KeyCounter.cs @@ -3,6 +3,7 @@ using OpenTK; using OpenTK.Graphics; +using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -58,20 +59,20 @@ namespace osu.Game.Graphics.UserInterface Name = name; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Children = new Drawable[] { buttonSprite = new Sprite { - Texture = Game.Textures.Get(@"KeyCounter/key-up"), + Texture = game.Textures.Get(@"KeyCounter/key-up"), Anchor = Anchor.Centre, Origin = Anchor.Centre, }, glowSprite = new Sprite { - Texture = Game.Textures.Get(@"KeyCounter/key-glow"), + Texture = game.Textures.Get(@"KeyCounter/key-glow"), Anchor = Anchor.Centre, Origin = Anchor.Centre, Alpha = 0 diff --git a/osu.Game/Online/Chat/Display/ChatLine.cs b/osu.Game/Online/Chat/Display/ChatLine.cs index aa75107c09..2c68b81479 100644 --- a/osu.Game/Online/Chat/Display/ChatLine.cs +++ b/osu.Game/Online/Chat/Display/ChatLine.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Drawables; using osu.Framework.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; +using osu.Framework; namespace osu.Game.Online.Chat.Display { @@ -21,9 +22,9 @@ namespace osu.Game.Online.Chat.Display this.msg = msg; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); RelativeSizeAxes = Axes.X; diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index d8ae0b05a1..121505507c 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -15,6 +15,7 @@ using osu.Game.Graphics.Background; using osu.Game.GameModes.Play; using osu.Game.Graphics.Containers; using osu.Game.Overlays; +using osu.Framework; namespace osu.Game { @@ -33,9 +34,9 @@ namespace osu.Game host.Size = new Vector2(Config.Get(OsuConfig.Width), Config.Get(OsuConfig.Height)); } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); //attach our bindables to the audio subsystem. Audio.Volume.Weld(Config.GetBindable(OsuConfig.VolumeGlobal)); diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index bd3990d5ef..41b2235dec 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -1,4 +1,5 @@ -using osu.Framework.GameModes; +using osu.Framework; +using osu.Framework.GameModes; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -12,7 +13,7 @@ using osu.Game.Overlays; namespace osu.Game { - public class OsuGameBase : Framework.Game + public class OsuGameBase : Framework.BaseGame { internal OsuConfigManager Config = new OsuConfigManager(); @@ -27,9 +28,9 @@ namespace osu.Game public CursorContainer Cursor; - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); //this completely overrides the framework default. will need to change once we make a proper FontStore. Fonts = new TextureStore() { ScaleAdjust = 0.01f }; diff --git a/osu.Game/Overlays/Options.cs b/osu.Game/Overlays/Options.cs index 4eb2b0f235..bdab31bc6e 100644 --- a/osu.Game/Overlays/Options.cs +++ b/osu.Game/Overlays/Options.cs @@ -9,6 +9,7 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Input; using OpenTK.Input; +using osu.Framework; namespace osu.Game.Overlays { @@ -16,9 +17,9 @@ namespace osu.Game.Overlays { const float width = 300; - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Depth = float.MaxValue; RelativeSizeAxes = Axes.Y; diff --git a/osu.Game/Overlays/Toolbar.cs b/osu.Game/Overlays/Toolbar.cs index 46bc2be0d6..ac9c653889 100644 --- a/osu.Game/Overlays/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar.cs @@ -12,6 +12,7 @@ using System; using osu.Framework.Graphics.Transformations; using osu.Framework.Timing; using osu.Game.GameModes.Play; +using osu.Framework; namespace osu.Game.Overlays { @@ -42,9 +43,9 @@ namespace osu.Game.Overlays } } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); RelativeSizeAxes = Axes.X; Size = new Vector2(1, height); @@ -97,7 +98,7 @@ namespace osu.Game.Overlays new ToolbarButton { Icon = FontAwesome.user, - Text = ((OsuGame)Game).Config.Get(OsuConfig.Username) + Text = ((OsuGame)game).Config.Get(OsuConfig.Username) }, new ToolbarButton { diff --git a/osu.Game/Overlays/ToolbarModeButton.cs b/osu.Game/Overlays/ToolbarModeButton.cs index a8519e3436..678a953fb1 100644 --- a/osu.Game/Overlays/ToolbarModeButton.cs +++ b/osu.Game/Overlays/ToolbarModeButton.cs @@ -5,6 +5,7 @@ using osu.Framework.Extensions; using osu.Game.GameModes.Play; using osu.Game.Graphics; using OpenTK.Graphics; +using osu.Framework; namespace osu.Game.Overlays { @@ -42,9 +43,9 @@ namespace osu.Game.Overlays } } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); DrawableIcon.TextSize *= 1.4f; } } diff --git a/osu.Game/Overlays/ToolbarModeSelector.cs b/osu.Game/Overlays/ToolbarModeSelector.cs index c429dd5a24..d73c7dc8a9 100644 --- a/osu.Game/Overlays/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/ToolbarModeSelector.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Transformations; using osu.Game.GameModes.Play; using OpenTK; using OpenTK.Graphics; +using osu.Framework; namespace osu.Game.Overlays { @@ -29,9 +30,9 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Y; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Children = new Drawable[] { diff --git a/osu.Game/VolumeControl.cs b/osu.Game/VolumeControl.cs index 0ea9aab67e..ff74a767bd 100644 --- a/osu.Game/VolumeControl.cs +++ b/osu.Game/VolumeControl.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Drawables; using osu.Framework.Input; using osu.Framework.Graphics.Transformations; +using osu.Framework; namespace osu.Game { @@ -24,9 +25,9 @@ namespace osu.Game RelativeSizeAxes = Axes.Both; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Children = new Drawable[] { meterContainer = new Container { From b2c31d30475523670a890f30bcc7c7beced65e68 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Oct 2016 15:58:12 +0900 Subject: [PATCH 43/45] Updates post-master-merge. --- .../Tests/TestCaseChatDisplay.cs | 2 +- osu.Game/GameModes/Menu/ButtonSystem.cs | 2 +- osu.Game/Overlays/ToolbarButton.cs | 5 ++- osu.sln | 45 +++++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index ff8f0e07dc..e1e98207df 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -65,7 +65,7 @@ namespace osu.Desktop.Tests RelativeSizeAxes = Axes.X, LayoutDuration = 100, LayoutEasing = EasingTypes.Out, - Padding = new Vector2(1, 1) + Spacing = new Vector2(1, 1) } } }); diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 75d6288a4f..14876e10d9 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -90,7 +90,7 @@ namespace osu.Game.GameModes.Menu buttonFlow = new FlowContainerWithOrigin { Anchor = Anchor.Centre, - Padding = new Vector2(-wedge_width, 0), + Spacing = new Vector2(-wedge_width, 0), Children = new Drawable[] { settingsButton = new Button(@"settings", @"options", FontAwesome.gear, new Color4(85, 85, 85, 255), OnSettings, -wedge_width, Key.O), diff --git a/osu.Game/Overlays/ToolbarButton.cs b/osu.Game/Overlays/ToolbarButton.cs index 815f31590b..8b44583fe1 100644 --- a/osu.Game/Overlays/ToolbarButton.cs +++ b/osu.Game/Overlays/ToolbarButton.cs @@ -10,6 +10,7 @@ using osu.Framework.Input; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; +using osu.Framework; namespace osu.Game.Overlays { @@ -127,9 +128,9 @@ namespace osu.Game.Overlays Size = new Vector2(WIDTH, 1); } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Children = new Drawable[] { diff --git a/osu.sln b/osu.sln index e3c4d8468d..d9f58def79 100644 --- a/osu.sln +++ b/osu.sln @@ -19,36 +19,51 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework.Desktop", "os EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Desktop.VisualTests", "osu.Desktop.VisualTests\osu.Desktop.VisualTests.csproj", "{69051C69-12AE-4E7D-A3E6-460D2E282312}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Tests", "osu.Game.Tests\osu.Game.Tests.csproj", "{54377672-20B1-40AF-8087-5CF73BF3953A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Deploy|Any CPU = Deploy|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {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}.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.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.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.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.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.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.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.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.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.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.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.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.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.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -60,5 +75,35 @@ Global {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58} = {0D37A2AD-80A4-464F-A1DE-1560B70F1CE3} {65DC628F-A640-4111-AB35-3A5652BC1E17} = {7A75DFA2-DE65-4458-98AF-26AF96FFD6DC} {69051C69-12AE-4E7D-A3E6-460D2E282312} = {0D37A2AD-80A4-464F-A1DE-1560B70F1CE3} + {54377672-20B1-40AF-8087-5CF73BF3953A} = {0D37A2AD-80A4-464F-A1DE-1560B70F1CE3} + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + Policies = $0 + $0.TextStylePolicy = $1 + $1.EolMarker = Windows + $1.inheritsSet = VisualStudio + $1.inheritsScope = text/plain + $1.scope = text/x-csharp + $0.CSharpFormattingPolicy = $2 + $2.IndentSwitchSection = True + $2.NewLinesForBracesInProperties = True + $2.NewLinesForBracesInAccessors = True + $2.NewLinesForBracesInAnonymousMethods = True + $2.NewLinesForBracesInControlBlocks = True + $2.NewLinesForBracesInAnonymousTypes = True + $2.NewLinesForBracesInObjectCollectionArrayInitializers = True + $2.NewLinesForBracesInLambdaExpressionBody = True + $2.NewLineForElse = True + $2.NewLineForCatch = True + $2.NewLineForFinally = True + $2.NewLineForMembersInObjectInit = True + $2.NewLineForMembersInAnonymousTypes = True + $2.NewLineForClausesInQuery = True + $2.SpacingAfterMethodDeclarationName = False + $2.SpaceAfterMethodCallName = False + $2.SpaceBeforeOpenSquareBracket = False + $2.inheritsSet = Mono + $2.inheritsScope = text/x-csharp + $2.scope = text/x-csharp EndGlobalSection EndGlobal From 61d5c7c56dec678a7d8190737eee5f3205435804 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Oct 2016 16:11:40 +0900 Subject: [PATCH 44/45] Make stuff compile again (but StarCounter hits assertions). --- osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs | 6 ++++-- osu.Game/Graphics/UserInterface/NumericRollingCounter.cs | 6 ++++-- osu.Game/Graphics/UserInterface/RollingCounter.cs | 7 ++++--- osu.Game/Graphics/UserInterface/ScoreCounter.cs | 6 ++++-- osu.Game/Graphics/UserInterface/StandardComboCounter.cs | 6 ++++-- osu.Game/Graphics/UserInterface/StarCounter.cs | 7 +++++-- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs index 8c5510eca4..9b710174ea 100644 --- a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs @@ -3,6 +3,7 @@ using OpenTK; using OpenTK.Graphics; +using osu.Framework; using osu.Framework.Graphics.Transformations; using System; using System.Collections.Generic; @@ -29,9 +30,10 @@ namespace osu.Game.Graphics.UserInterface IsRollingContinuous = false; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); + countSpriteText.Hide(); OriginalColour = Colour; } diff --git a/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs b/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs index ce0efb6450..e1cb9ddbb4 100644 --- a/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs @@ -1,6 +1,7 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //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; @@ -31,9 +32,10 @@ namespace osu.Game.Graphics.UserInterface } } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); + Children = new Drawable[] { countSpriteText = new SpriteText diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index b0f757a378..b0686ca0cb 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -1,4 +1,5 @@ -using osu.Framework.Graphics; +using osu.Framework; +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transformations; using System; @@ -109,9 +110,9 @@ namespace osu.Game.Graphics.UserInterface ); } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); removeTransforms(transformType); if (Count == null) ResetCount(); diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index cdf22eaea1..d5b9edf73d 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -1,6 +1,7 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //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; @@ -16,9 +17,10 @@ namespace osu.Game.Graphics.UserInterface /// public uint LeadingZeroes = 0; - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); + countSpriteText.FixedWidth = true; } diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs index b3af78b78e..676e3672d2 100644 --- a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs @@ -1,6 +1,7 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //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; @@ -30,9 +31,10 @@ namespace osu.Game.Graphics.UserInterface IsRollingContinuous = false; } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); + countSpriteText.Alpha = 0; Add(popOutSpriteText = new SpriteText { diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index 3ee67a38d6..790e0ddcc8 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -2,6 +2,7 @@ //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; @@ -52,9 +53,9 @@ namespace osu.Game.Graphics.UserInterface StopRolling(); } - public override void Load() + public override void Load(BaseGame game) { - base.Load(); + base.Load(game); Children = new Drawable[] { @@ -79,6 +80,8 @@ namespace osu.Game.Graphics.UserInterface Alpha = (i == 0) ? 1.0f : MinStarAlpha, Position = new Vector2((StarSize + StarSpacing) * i + (StarSize + StarSpacing) / 2, 0), }; + + //todo: user Container once we have it. stars.Add(star); starContainer.Add(star); } From 29d223dc418b49e9e2916738f97ae30f28141145 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Oct 2016 19:52:49 +0900 Subject: [PATCH 45/45] Update framework and simplify some references. --- osu-framework | 2 +- osu.Game/GameModes/Menu/Intro.cs | 3 ++- osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs | 3 ++- osu.Game/OsuGameBase.cs | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/osu-framework b/osu-framework index c610557427..7439250a63 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit c6105574275ac3bed45a45feb77b34bedda925a8 +Subproject commit 7439250a63dd451f34dbc08ecf68a196cf8e479f diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index 5127f5be5c..1fb97a9b4e 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; using osu.Game.GameModes.Backgrounds; using OpenTK.Graphics; +using osu.Framework; namespace osu.Game.GameModes.Menu { @@ -23,7 +24,7 @@ namespace osu.Game.GameModes.Menu protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty(); - public override void Load(Framework.BaseGame game) + public override void Load(BaseGame game) { base.Load(game); diff --git a/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs b/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs index 1f027fb6ae..c95eca8077 100644 --- a/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs +++ b/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs @@ -9,6 +9,7 @@ using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Osu; using OpenTK; using System.Diagnostics; +using osu.Framework; namespace osu.Game.GameModes.Play.Osu { @@ -28,7 +29,7 @@ namespace osu.Game.GameModes.Play.Osu } } - public override void Load(Framework.BaseGame game) + public override void Load(BaseGame game) { base.Load(game); diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 41b2235dec..229b306d14 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -13,7 +13,7 @@ using osu.Game.Overlays; namespace osu.Game { - public class OsuGameBase : Framework.BaseGame + public class OsuGameBase : BaseGame { internal OsuConfigManager Config = new OsuConfigManager();