1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 15:27:26 +08:00

Merge remote-tracking branch 'origin/master' into counter_bindables

Conflicts:
	osu.Game/Modes/UI/HudOverlay.cs
This commit is contained in:
smoogipooo 2017-03-11 14:19:25 +09:00
commit 3276316ac8
14 changed files with 57 additions and 342 deletions

View File

@ -82,15 +82,12 @@ namespace osu.Game.Modes.Catch
public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o;
public override IEnumerable<KeyCounter> CreateGameplayKeys()
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new KeyCounter[]
{
return new KeyCounter[]
{
new KeyCounterKeyboard(Key.ShiftLeft),
new KeyCounterMouse(MouseButton.Left),
new KeyCounterMouse(MouseButton.Right)
};
}
new KeyCounterKeyboard(Key.ShiftLeft),
new KeyCounterMouse(MouseButton.Left),
new KeyCounterMouse(MouseButton.Right)
};
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null;

View File

@ -102,10 +102,7 @@ namespace osu.Game.Modes.Mania
public override FontAwesome Icon => FontAwesome.fa_osu_mania_o;
public override IEnumerable<KeyCounter> CreateGameplayKeys()
{
return new KeyCounter[] { /* Todo: Should be keymod specific */ };
}
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new KeyCounter[] { /* Todo: Should be keymod specific */ };
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null;

View File

@ -114,15 +114,12 @@ namespace osu.Game.Modes.Osu
public override string Description => "osu!";
public override IEnumerable<KeyCounter> CreateGameplayKeys()
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new KeyCounter[]
{
return new KeyCounter[]
{
new KeyCounterKeyboard(Key.Z),
new KeyCounterKeyboard(Key.X),
new KeyCounterMouse(MouseButton.Left),
new KeyCounterMouse(MouseButton.Right)
};
}
new KeyCounterKeyboard(Key.Z),
new KeyCounterKeyboard(Key.X),
new KeyCounterMouse(MouseButton.Left),
new KeyCounterMouse(MouseButton.Right)
};
}
}

View File

@ -1,128 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Modes.Osu
{
public class OsuRuleset : Ruleset
{
public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new OsuHitRenderer
{
Beatmap = beatmap,
};
public override IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new[]
{
new BeatmapStatistic
{
Name = @"Circle count",
Content = beatmap.Beatmap.HitObjects.Count(h => h is HitCircle).ToString(),
Icon = FontAwesome.fa_dot_circle_o
},
new BeatmapStatistic
{
Name = @"Slider count",
Content = beatmap.Beatmap.HitObjects.Count(h => h is Slider).ToString(),
Icon = FontAwesome.fa_circle_o
}
};
public override IEnumerable<Mod> GetModsFor(ModType type)
{
switch (type)
{
case ModType.DifficultyReduction:
return new Mod[]
{
new OsuModEasy(),
new OsuModNoFail(),
new OsuModHalfTime(),
};
case ModType.DifficultyIncrease:
return new Mod[]
{
new OsuModHardRock(),
new MultiMod
{
Mods = new Mod[]
{
new OsuModSuddenDeath(),
new OsuModPerfect(),
},
},
new MultiMod
{
Mods = new Mod[]
{
new OsuModDoubleTime(),
new OsuModNightcore(),
},
},
new OsuModHidden(),
new OsuModFlashlight(),
};
case ModType.Special:
return new Mod[]
{
new OsuModRelax(),
new OsuModAutopilot(),
new OsuModSpunOut(),
new MultiMod
{
Mods = new Mod[]
{
new OsuModAutoplay(),
new ModCinema(),
},
},
new OsuModTarget(),
};
default:
return new Mod[] { };
}
}
public override FontAwesome Icon => FontAwesome.fa_osu_osu_o;
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => new OsuScoreProcessor(hitObjectCount);
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap);
public override Score CreateAutoplayScore(Beatmap beatmap)
{
var score = CreateScoreProcessor().GetScore();
score.Replay = new OsuAutoReplay(beatmap);
return score;
}
protected override PlayMode PlayMode => PlayMode.Osu;
public override string Description => "osu!";
<<<<<<< HEAD
public override KeyCounter[] CreateGameplayKeys => new KeyCounter[]
=======
public override KeyCounter[] GameplayKeys => new KeyCounter[]
>>>>>>> combocounter_bindable
{
new KeyCounterKeyboard(Key.Z),
new KeyCounterKeyboard(Key.X),
new KeyCounterMouse(MouseButton.Left),
new KeyCounterMouse(MouseButton.Right)
};
}
}

View File

@ -82,16 +82,13 @@ namespace osu.Game.Modes.Taiko
public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o;
public override IEnumerable<KeyCounter> CreateGameplayKeys()
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new KeyCounter[]
{
return new KeyCounter[]
{
new KeyCounterKeyboard(Key.D),
new KeyCounterKeyboard(Key.F),
new KeyCounterKeyboard(Key.J),
new KeyCounterKeyboard(Key.K)
};
}
new KeyCounterKeyboard(Key.D),
new KeyCounterKeyboard(Key.F),
new KeyCounterKeyboard(Key.J),
new KeyCounterKeyboard(Key.K)
};
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null;

View File

@ -1,69 +0,0 @@
// 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.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Objects;
using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace osu.Game.Modes
{
public class BeatmapStatistic
{
public FontAwesome Icon;
public string Content;
public string Name;
}
public abstract class Ruleset
{
public abstract KeyCounter[] CreateGameplayKeys { get; }
private static ConcurrentDictionary<PlayMode, Type> availableRulesets = new ConcurrentDictionary<PlayMode, Type>();
<<<<<<< HEAD
public static IEnumerable<PlayMode> PlayModes => availableRulesets.Keys;
=======
public static IEnumerable<PlayMode> PlayModes => availableRulesets.Keys;
>>>>>>> combocounter_bindable
public virtual IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { };
public abstract IEnumerable<Mod> GetModsFor(ModType type);
public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0);
public abstract HitRenderer CreateHitRendererWith(Beatmap beatmap);
public abstract HitObjectParser CreateHitObjectParser();
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);
public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
protected abstract PlayMode PlayMode { get; }
public virtual FontAwesome Icon => FontAwesome.fa_question_circle;
public abstract string Description { get; }
public virtual Score CreateAutoplayScore(Beatmap beatmap) => null;
public static Ruleset GetRuleset(PlayMode mode)
{
Type type;
if (!availableRulesets.TryGetValue(mode, out type))
return null;
return Activator.CreateInstance(type) as Ruleset;
}
}
}

View File

@ -10,8 +10,8 @@ namespace osu.Game.Modes
public double TotalScore { get; set; }
public double Accuracy { get; set; }
public double Health { get; set; }
public long Combo { get; set; }
public long MaxCombo { get; set; }
public int MaxCombo { get; set; }
public int Combo { get; set; }
public Replay Replay;
public BeatmapInfo Beatmap;

View File

@ -25,7 +25,7 @@ namespace osu.Game.Modes
public readonly BindableDouble Health = new BindableDouble { MinValue = 0, MaxValue = 1 };
public readonly BindableLong Combo = new BindableLong();
public readonly BindableInt Combo = new BindableInt();
/// <summary>
/// Are we allowed to fail?
@ -43,7 +43,7 @@ namespace osu.Game.Modes
/// Keeps track of the highest combo ever achieved in this play.
/// This is handled automatically by ScoreProcessor.
/// </summary>
public readonly BindableLong HighestCombo = new BindableLong();
public readonly BindableInt HighestCombo = new BindableInt();
public readonly List<JudgementInfo> Judgements;

View File

@ -14,7 +14,7 @@ namespace osu.Game.Modes.UI
{
public abstract class ComboCounter : Container
{
public BindableLong Current = new BindableLong
public BindableInt Current = new BindableInt
{
MinValue = 0,
};
@ -42,7 +42,7 @@ namespace osu.Game.Modes.UI
protected SpriteText DisplayedCountSpriteText;
private long previousValue;
private int previousValue;
/// <summary>
/// Base of all combo counters.
@ -85,11 +85,11 @@ namespace osu.Game.Modes.UI
StopRolling();
}
private long displayedCount;
private int displayedCount;
/// <summary>
/// Value shown at the current moment.
/// </summary>
public virtual long DisplayedCount
public virtual int DisplayedCount
{
get { return displayedCount; }
protected set
@ -116,7 +116,7 @@ namespace osu.Game.Modes.UI
/// Increments the combo by an amount.
/// </summary>
/// <param name="amount"></param>
public void Increment(long amount = 1)
public void Increment(int amount = 1)
{
Current.Value = Current + amount;
}
@ -129,33 +129,33 @@ namespace osu.Game.Modes.UI
updateCount(false);
}
protected virtual string FormatCount(long count)
protected virtual string FormatCount(int count)
{
return count.ToString();
}
protected virtual void OnCountRolling(long currentValue, long newValue)
protected virtual void OnCountRolling(int currentValue, int newValue)
{
transformRoll(new TransformComboRoll(), currentValue, newValue);
}
protected virtual void OnCountIncrement(long currentValue, long newValue)
protected virtual void OnCountIncrement(int currentValue, int newValue)
{
DisplayedCount = newValue;
}
protected virtual void OnCountChange(long currentValue, long newValue)
protected virtual void OnCountChange(int currentValue, int newValue)
{
DisplayedCount = newValue;
}
private double getProportionalDuration(long currentValue, long newValue)
private double getProportionalDuration(int currentValue, int newValue)
{
double difference = currentValue > newValue ? currentValue - newValue : newValue - currentValue;
return difference * RollingDuration;
}
private void updateDisplayedCount(long currentValue, long newValue, bool rolling)
private void updateDisplayedCount(int currentValue, int newValue, bool rolling)
{
displayedCount = newValue;
if (rolling)
@ -168,7 +168,7 @@ namespace osu.Game.Modes.UI
private void updateCount(bool rolling)
{
long prev = previousValue;
int prev = previousValue;
previousValue = Current;
if (!IsLoaded)
@ -192,7 +192,7 @@ namespace osu.Game.Modes.UI
}
}
private void transformRoll(TransformComboRoll transform, long currentValue, long newValue)
private void transformRoll(TransformComboRoll transform, int currentValue, int newValue)
{
Flush(false, typeof(TransformComboRoll));
@ -211,9 +211,9 @@ namespace osu.Game.Modes.UI
Transforms.Add(transform);
}
protected class TransformComboRoll : Transform<long>
protected class TransformComboRoll : Transform<int>
{
protected override long CurrentValue
protected override int CurrentValue
{
get
{
@ -221,7 +221,7 @@ namespace osu.Game.Modes.UI
if (time < StartTime) return StartValue;
if (time >= EndTime) return EndValue;
return (long)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
return (int)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
}
}
@ -232,8 +232,8 @@ namespace osu.Game.Modes.UI
}
}
protected abstract void OnDisplayedCountRolling(long currentValue, long newValue);
protected abstract void OnDisplayedCountIncrement(long newValue);
protected abstract void OnDisplayedCountChange(long newValue);
protected abstract void OnDisplayedCountRolling(int currentValue, int newValue);
protected abstract void OnDisplayedCountIncrement(int newValue);
protected abstract void OnDisplayedCountChange(int newValue);
}
}

View File

@ -1,77 +0,0 @@
// 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.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Modes.Objects;
using osu.Game.Screens.Play;
using System;
namespace osu.Game.Modes.UI
{
public abstract class HudOverlay : Container
{
public readonly KeyCounterCollection KeyCounter;
public readonly ComboCounter ComboCounter;
public readonly ScoreCounter ScoreCounter;
public readonly PercentageCounter AccuracyCounter;
public readonly HealthDisplay HealthDisplay;
private Bindable<bool> showKeyCounter;
protected abstract KeyCounterCollection CreateKeyCounter();
protected abstract ComboCounter CreateComboCounter();
protected abstract PercentageCounter CreateAccuracyCounter();
protected abstract ScoreCounter CreateScoreCounter();
protected abstract HealthDisplay CreateHealthDisplay();
protected HudOverlay(Ruleset ruleset)
{
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
KeyCounter = CreateKeyCounter(),
ComboCounter = CreateComboCounter(),
ScoreCounter = CreateScoreCounter(),
AccuracyCounter = CreateAccuracyCounter(),
HealthDisplay = CreateHealthDisplay(),
};
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
showKeyCounter = config.GetBindable<bool>(OsuConfig.KeyOverlay);
showKeyCounter.ValueChanged += visibilityChanged;
showKeyCounter.TriggerChange();
}
private void visibilityChanged(object sender, EventArgs e)
{
if (showKeyCounter)
KeyCounter.Show();
else
KeyCounter.Hide();
}
public void BindProcessor(ScoreProcessor processor)
{
//bind processor bindables to combocounter, score display etc.
//TODO: these should be bindable binds, not events!
ScoreCounter?.Current.BindTo(processor.TotalScore);
AccuracyCounter?.Current.BindTo(processor.Accuracy);
ComboCounter?.Current.BindTo(processor.Combo);
HealthDisplay?.Current.BindTo(processor.Health);
}
public void BindHitRenderer(HitRenderer hitRenderer)
{
hitRenderer.InputManager.Add(KeyCounter.GetReceptor());
}
}
}

View File

@ -29,7 +29,7 @@ namespace osu.Game.Modes.UI
protected abstract ScoreCounter CreateScoreCounter();
protected abstract HealthDisplay CreateHealthDisplay();
protected HudOverlay(Ruleset ruleset)
protected HudOverlay()
{
RelativeSizeAxes = Axes.Both;

View File

@ -25,12 +25,12 @@ namespace osu.Game.Modes.UI
PopOutCount.Anchor = Anchor;
}
protected override string FormatCount(long count)
protected override string FormatCount(int count)
{
return $@"{count}x";
}
protected virtual void TransformPopOut(long newValue)
protected virtual void TransformPopOut(int newValue)
{
PopOutCount.Text = FormatCount(newValue);
@ -43,19 +43,19 @@ namespace osu.Game.Modes.UI
PopOutCount.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing);
}
protected virtual void TransformPopOutRolling(long newValue)
protected virtual void TransformPopOutRolling(int newValue)
{
TransformPopOut(newValue);
TransformPopOutSmall(newValue);
}
protected virtual void TransformNoPopOut(long newValue)
protected virtual void TransformNoPopOut(int newValue)
{
DisplayedCountSpriteText.Text = FormatCount(newValue);
DisplayedCountSpriteText.ScaleTo(1);
}
protected virtual void TransformPopOutSmall(long newValue)
protected virtual void TransformPopOutSmall(int newValue)
{
DisplayedCountSpriteText.Text = FormatCount(newValue);
DisplayedCountSpriteText.ScaleTo(PopOutSmallScale);
@ -71,7 +71,7 @@ namespace osu.Game.Modes.UI
DisplayedCount++;
}
protected override void OnCountRolling(long currentValue, long newValue)
protected override void OnCountRolling(int currentValue, int newValue)
{
ScheduledPopOutCurrentId++;
@ -82,7 +82,7 @@ namespace osu.Game.Modes.UI
base.OnCountRolling(currentValue, newValue);
}
protected override void OnCountIncrement(long currentValue, long newValue)
protected override void OnCountIncrement(int currentValue, int newValue)
{
ScheduledPopOutCurrentId++;
@ -100,7 +100,7 @@ namespace osu.Game.Modes.UI
}, PopOutDuration);
}
protected override void OnCountChange(long currentValue, long newValue)
protected override void OnCountChange(int currentValue, int newValue)
{
ScheduledPopOutCurrentId++;
@ -110,7 +110,7 @@ namespace osu.Game.Modes.UI
base.OnCountChange(currentValue, newValue);
}
protected override void OnDisplayedCountRolling(long currentValue, long newValue)
protected override void OnDisplayedCountRolling(int currentValue, int newValue)
{
if (newValue == 0)
DisplayedCountSpriteText.FadeOut(FadeOutDuration);
@ -123,14 +123,14 @@ namespace osu.Game.Modes.UI
TransformNoPopOut(newValue);
}
protected override void OnDisplayedCountChange(long newValue)
protected override void OnDisplayedCountChange(int newValue)
{
DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
TransformNoPopOut(newValue);
}
protected override void OnDisplayedCountIncrement(long newValue)
protected override void OnDisplayedCountIncrement(int newValue)
{
DisplayedCountSpriteText.Show();

View File

@ -112,7 +112,8 @@ namespace osu.Game.Screens.Play
ruleset = Ruleset.GetRuleset(Beatmap.PlayMode);
hudOverlay = new StandardHudOverlay(ruleset);
hudOverlay = new StandardHudOverlay();
hudOverlay.KeyCounter.Add(ruleset.CreateGameplayKeys());
hudOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count));
pauseOverlay = new PauseOverlay

View File

@ -97,7 +97,9 @@
<Compile Include="Modes\Score.cs" />
<Compile Include="Modes\ScoreProcesssor.cs" />
<Compile Include="Modes\UI\HealthDisplay.cs" />
<Compile Include="Modes\UI\HudOverlay.cs" />
<Compile Include="Modes\UI\StandardHealthDisplay.cs" />
<Compile Include="Modes\UI\StandardHudOverlay.cs" />
<Compile Include="Online\API\IOnlineComponent.cs" />
<Compile Include="Online\API\Requests\GetUserRequest.cs" />
<Compile Include="Overlays\DragBar.cs" />
@ -169,7 +171,6 @@
<Compile Include="Screens\Play\PlayerLoader.cs" />
<Compile Include="Screens\Play\SkipButton.cs" />
<Compile Include="Modes\UI\StandardComboCounter.cs" />
<Compile Include="Modes\UI\StandardHudOverlay.cs" />
<Compile Include="Screens\Select\CarouselContainer.cs" />
<Compile Include="Screens\Select\MatchSongSelect.cs" />
<Compile Include="Screens\OsuGameScreen.cs" />
@ -184,7 +185,6 @@
<Compile Include="Screens\Select\PlaySongSelect.cs" />
<Compile Include="Modes\UI\HitRenderer.cs" />
<Compile Include="Modes\UI\Playfield.cs" />
<Compile Include="Modes\UI\HudOverlay.cs" />
<Compile Include="Screens\Select\EditSongSelect.cs" />
<Compile Include="Modes\UI\ComboCounter.cs" />
<Compile Include="Modes\UI\ComboResultCounter.cs" />