mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
More bindables!
This commit is contained in:
@ -1,19 +1,25 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public abstract class RollingCounter<T> : Container
|
||||
{
|
||||
/// <summary>
|
||||
/// The current value.
|
||||
/// </summary>
|
||||
public Bindable<T> Current = new Bindable<T>();
|
||||
|
||||
/// <summary>
|
||||
/// Type of the Transform to use.
|
||||
/// </summary>
|
||||
@ -60,32 +66,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
private T count;
|
||||
|
||||
/// <summary>
|
||||
/// Actual value of counter.
|
||||
/// </summary>
|
||||
public virtual T Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return count;
|
||||
}
|
||||
set
|
||||
{
|
||||
count = value;
|
||||
if (IsLoaded)
|
||||
{
|
||||
TransformCount(displayedCount, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Set(T value)
|
||||
{
|
||||
Count = value;
|
||||
}
|
||||
|
||||
public abstract void Increment(T amount);
|
||||
|
||||
private float textSize;
|
||||
@ -116,7 +96,15 @@ namespace osu.Game.Graphics.UserInterface
|
||||
TextSize = 40;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
DisplayedCount = Count;
|
||||
DisplayedCount = Current;
|
||||
|
||||
Current.ValueChanged += currentChanged;
|
||||
}
|
||||
|
||||
private void currentChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (IsLoaded)
|
||||
TransformCount(displayedCount, Current);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -125,7 +113,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
Flush(false, TransformType);
|
||||
|
||||
DisplayedCountSpriteText.Text = FormatCount(count);
|
||||
DisplayedCountSpriteText.Text = FormatCount(Current);
|
||||
DisplayedCountSpriteText.Anchor = Anchor;
|
||||
DisplayedCountSpriteText.Origin = Origin;
|
||||
}
|
||||
@ -136,7 +124,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// <param name="count">New count value.</param>
|
||||
public virtual void SetCountWithoutRolling(T count)
|
||||
{
|
||||
Count = count;
|
||||
Current.Value = count;
|
||||
StopRolling();
|
||||
}
|
||||
|
||||
@ -146,7 +134,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
public virtual void StopRolling()
|
||||
{
|
||||
Flush(false, TransformType);
|
||||
DisplayedCount = Count;
|
||||
DisplayedCount = Current;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -211,7 +199,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
if (RollingDuration < 1)
|
||||
{
|
||||
DisplayedCount = Count;
|
||||
DisplayedCount = Current;
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user