mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
reafactor: simplify type checking
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -43,14 +42,15 @@ namespace osu.Game.Screens.Play
|
|||||||
public override void Add(KeyCounter key)
|
public override void Add(KeyCounter key)
|
||||||
{
|
{
|
||||||
base.Add(key);
|
base.Add(key);
|
||||||
if (key is not DefaultKeyCounter defaultKey)
|
DefaultKeyCounter defaultKey = (DefaultKeyCounter)key;
|
||||||
throw new ArgumentException($"{key.GetType()} is not a supported {nameof(KeyCounter)}.", nameof(key));
|
|
||||||
|
|
||||||
defaultKey.FadeTime = key_fade_time;
|
defaultKey.FadeTime = key_fade_time;
|
||||||
defaultKey.KeyDownTextColor = KeyDownTextColor;
|
defaultKey.KeyDownTextColor = KeyDownTextColor;
|
||||||
defaultKey.KeyUpTextColor = KeyUpTextColor;
|
defaultKey.KeyUpTextColor = KeyUpTextColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool CheckType(KeyCounter key) => key is DefaultKeyCounter;
|
||||||
|
|
||||||
protected override void UpdateVisibility() =>
|
protected override void UpdateVisibility() =>
|
||||||
// Isolate changing visibility of the key counters from fading this component.
|
// Isolate changing visibility of the key counters from fading this component.
|
||||||
KeyFlow.FadeTo(AlwaysVisible.Value || ConfigVisibility.Value ? 1 : 0, duration);
|
KeyFlow.FadeTo(AlwaysVisible.Value || ConfigVisibility.Value ? 1 : 0, duration);
|
||||||
|
@ -29,12 +29,15 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public override void Add(KeyCounter key)
|
public override void Add(KeyCounter key)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(key);
|
if (!CheckType(key))
|
||||||
|
throw new ArgumentException($"{key.GetType()} is not a supported {nameof(KeyCounter)}.", nameof(key));
|
||||||
|
|
||||||
base.Add(key);
|
base.Add(key);
|
||||||
key.IsCounting = IsCounting;
|
key.IsCounting = IsCounting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual bool CheckType(KeyCounter key) => true;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user