Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2254 from peppy/skin--completion
Add skin/beatmap lookup hierarchy
- Loading branch information
Showing
20 changed files
with
228 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. | ||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE | ||
|
||
namespace osu.Game.Rulesets.Objects.Types | ||
{ | ||
/// <summary> | ||
/// A HitObject that is part of a combo and has extended information about its position relative to other combo objects. | ||
/// </summary> | ||
public interface IHasComboIndex : IHasCombo | ||
{ | ||
/// <summary> | ||
/// The offset of this hitobject in the current combo. | ||
/// </summary> | ||
int IndexInCurrentCombo { get; set; } | ||
|
||
/// <summary> | ||
/// The offset of this hitobject in the current combo. | ||
/// </summary> | ||
int ComboIndex { get; set; } | ||
|
||
/// <summary> | ||
/// Whether this is the last object in the current combo. | ||
/// </summary> | ||
bool LastInCombo { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. | ||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE | ||
|
||
using System; | ||
using osu.Framework.Audio.Sample; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Textures; | ||
|
||
namespace osu.Game.Skinning | ||
{ | ||
/// <summary> | ||
/// Provides access to skinnable elements. | ||
/// </summary> | ||
public interface ISkinSource | ||
{ | ||
event Action SourceChanged; | ||
|
||
Drawable GetDrawableComponent(string componentName); | ||
|
||
Texture GetTexture(string componentName); | ||
|
||
SampleChannel GetSample(string sampleName); | ||
|
||
TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration where TValue : class; | ||
|
||
TValue? GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue?> query) where TConfiguration : SkinConfiguration where TValue : struct; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. | ||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE | ||
|
||
using System; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Audio.Sample; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Textures; | ||
|
||
namespace osu.Game.Skinning | ||
{ | ||
public class LocalSkinOverrideContainer : Container, ISkinSource | ||
{ | ||
public event Action SourceChanged; | ||
|
||
public Drawable GetDrawableComponent(string componentName) => source.GetDrawableComponent(componentName) ?? fallbackSource?.GetDrawableComponent(componentName); | ||
|
||
public Texture GetTexture(string componentName) => source.GetTexture(componentName) ?? fallbackSource.GetTexture(componentName); | ||
|
||
public SampleChannel GetSample(string sampleName) => source.GetSample(sampleName) ?? fallbackSource?.GetSample(sampleName); | ||
|
||
public TValue? GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue?> query) where TConfiguration : SkinConfiguration where TValue : struct | ||
{ | ||
TValue? val = null; | ||
var conf = (source as Skin)?.Configuration as TConfiguration; | ||
if (conf != null) | ||
val = query?.Invoke(conf); | ||
|
||
return val ?? fallbackSource?.GetValue(query); | ||
} | ||
|
||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration where TValue : class | ||
{ | ||
TValue val = null; | ||
var conf = (source as Skin)?.Configuration as TConfiguration; | ||
if (conf != null) | ||
val = query?.Invoke(conf); | ||
|
||
return val ?? fallbackSource?.GetValue(query); | ||
} | ||
|
||
private readonly ISkinSource source; | ||
private ISkinSource fallbackSource; | ||
|
||
public LocalSkinOverrideContainer(ISkinSource source) | ||
{ | ||
this.source = source; | ||
} | ||
|
||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) | ||
{ | ||
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); | ||
|
||
fallbackSource = dependencies.Get<ISkinSource>(); | ||
if (fallbackSource != null) | ||
fallbackSource.SourceChanged += () => SourceChanged?.Invoke(); | ||
|
||
dependencies.CacheAs<ISkinSource>(this); | ||
|
||
return dependencies; | ||
} | ||
|
||
protected override void Dispose(bool isDisposing) | ||
{ | ||
base.Dispose(isDisposing); | ||
|
||
if (fallbackSource != null) | ||
fallbackSource.SourceChanged -= SourceChanged; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.