2019-08-21 14:11:33 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-04-01 22:32:33 +08:00
|
|
|
using System;
|
2019-09-03 16:57:34 +08:00
|
|
|
using System.Collections.Generic;
|
2020-04-01 12:38:03 +08:00
|
|
|
using System.Diagnostics;
|
2018-04-13 17:19:50 +08:00
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
2019-09-04 14:59:09 +08:00
|
|
|
using JetBrains.Annotations;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Audio;
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-09-03 16:57:34 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Graphics;
|
2020-07-17 15:54:30 +08:00
|
|
|
using osu.Framework.Graphics.OpenGL.Textures;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
using osu.Framework.IO.Stores;
|
2019-08-23 19:32:43 +08:00
|
|
|
using osu.Game.Audio;
|
2020-04-02 16:56:12 +08:00
|
|
|
using osu.Game.Beatmaps.Formats;
|
2019-09-10 06:43:30 +08:00
|
|
|
using osu.Game.IO;
|
2019-08-30 14:12:03 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2019-07-30 22:06:18 +08:00
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
|
|
|
public class LegacySkin : Skin
|
|
|
|
{
|
2019-09-04 14:59:09 +08:00
|
|
|
[CanBeNull]
|
2018-04-13 17:19:50 +08:00
|
|
|
protected TextureStore Textures;
|
|
|
|
|
2019-09-04 14:59:09 +08:00
|
|
|
[CanBeNull]
|
2019-05-28 22:54:42 +08:00
|
|
|
protected IResourceStore<SampleChannel> Samples;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-04-01 22:32:33 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether texture for the keys exists.
|
|
|
|
/// Used to determine if the mania ruleset is skinned.
|
|
|
|
/// </summary>
|
|
|
|
private readonly Lazy<bool> hasKeyTexture;
|
|
|
|
|
|
|
|
protected virtual bool AllowManiaSkin => hasKeyTexture.Value;
|
2020-03-31 09:14:36 +08:00
|
|
|
|
2020-07-29 05:52:09 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether this skin can use samples with a custom bank (custom sample set in stable terminology).
|
|
|
|
/// Added in order to match sample lookup logic from stable (in stable, only the beatmap skin could use samples with a custom sample bank).
|
|
|
|
/// </summary>
|
|
|
|
protected virtual bool UseCustomSampleBanks => false;
|
|
|
|
|
2019-11-24 09:10:04 +08:00
|
|
|
public new LegacySkinConfiguration Configuration
|
2019-11-20 06:15:40 +08:00
|
|
|
{
|
|
|
|
get => base.Configuration as LegacySkinConfiguration;
|
|
|
|
set => base.Configuration = value;
|
|
|
|
}
|
2019-10-10 04:04:34 +08:00
|
|
|
|
2020-03-31 09:14:36 +08:00
|
|
|
private readonly Dictionary<int, LegacyManiaSkinConfiguration> maniaConfigurations = new Dictionary<int, LegacyManiaSkinConfiguration>();
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
public LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager)
|
|
|
|
: this(skin, new LegacySkinResourceStore<SkinFileInfo>(skin, storage), audioManager, "skin.ini")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-28 12:31:40 +08:00
|
|
|
protected LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager, string filename)
|
|
|
|
: base(skin)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2020-03-31 09:14:36 +08:00
|
|
|
using (var stream = storage?.GetStream(filename))
|
2019-11-11 19:53:22 +08:00
|
|
|
{
|
2020-03-31 09:14:36 +08:00
|
|
|
if (stream != null)
|
|
|
|
{
|
|
|
|
using (LineBufferedReader reader = new LineBufferedReader(stream, true))
|
|
|
|
Configuration = new LegacySkinDecoder().Decode(reader);
|
|
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
|
|
using (LineBufferedReader reader = new LineBufferedReader(stream))
|
|
|
|
{
|
|
|
|
var maniaList = new LegacyManiaSkinDecoder().Decode(reader);
|
|
|
|
|
|
|
|
foreach (var config in maniaList)
|
|
|
|
maniaConfigurations[config.Keys] = config;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-04-06 18:36:04 +08:00
|
|
|
Configuration = new LegacySkinConfiguration();
|
2019-11-11 19:53:22 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-09-04 14:59:09 +08:00
|
|
|
if (storage != null)
|
|
|
|
{
|
2020-03-22 01:16:28 +08:00
|
|
|
var samples = audioManager?.GetSampleStore(storage);
|
|
|
|
if (samples != null)
|
|
|
|
samples.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
|
|
|
|
|
|
|
|
Samples = samples;
|
2019-09-04 14:59:09 +08:00
|
|
|
Textures = new TextureStore(new TextureLoaderStore(storage));
|
2020-02-18 12:21:55 +08:00
|
|
|
|
|
|
|
(storage as ResourceStore<byte[]>)?.AddExtension("ogg");
|
2019-09-04 14:59:09 +08:00
|
|
|
}
|
2020-04-01 22:32:33 +08:00
|
|
|
|
|
|
|
// todo: this shouldn't really be duplicated here (from ManiaLegacySkinTransformer). we need to come up with a better solution.
|
|
|
|
hasKeyTexture = new Lazy<bool>(() => this.GetAnimation(
|
2020-04-07 15:53:29 +08:00
|
|
|
lookupForMania<string>(new LegacyManiaSkinConfigurationLookup(4, LegacyManiaSkinConfigurationLookups.KeyImage, 0))?.Value ?? "mania-key1", true,
|
|
|
|
true) != null);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2019-05-28 22:54:42 +08:00
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
Textures?.Dispose();
|
|
|
|
Samples?.Dispose();
|
|
|
|
}
|
|
|
|
|
2019-09-03 16:57:34 +08:00
|
|
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
|
|
|
{
|
|
|
|
switch (lookup)
|
|
|
|
{
|
2020-02-07 13:58:07 +08:00
|
|
|
case GlobalSkinColours colour:
|
|
|
|
switch (colour)
|
2019-09-03 16:57:34 +08:00
|
|
|
{
|
2020-02-07 13:58:07 +08:00
|
|
|
case GlobalSkinColours.ComboColours:
|
2019-11-07 04:20:36 +08:00
|
|
|
var comboColours = Configuration.ComboColours;
|
|
|
|
if (comboColours != null)
|
2019-11-07 20:54:30 +08:00
|
|
|
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(comboColours));
|
2019-10-10 02:08:07 +08:00
|
|
|
|
|
|
|
break;
|
2020-02-07 13:58:07 +08:00
|
|
|
|
|
|
|
default:
|
2020-04-02 16:56:12 +08:00
|
|
|
return SkinUtils.As<TValue>(getCustomColour(Configuration, colour.ToString()));
|
2019-09-03 16:57:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SkinCustomColourLookup customColour:
|
2020-04-02 16:56:12 +08:00
|
|
|
return SkinUtils.As<TValue>(getCustomColour(Configuration, customColour.Lookup.ToString()));
|
2019-09-03 16:57:34 +08:00
|
|
|
|
2020-03-31 17:22:46 +08:00
|
|
|
case LegacyManiaSkinConfigurationLookup maniaLookup:
|
2020-03-31 09:14:36 +08:00
|
|
|
if (!AllowManiaSkin)
|
|
|
|
return null;
|
|
|
|
|
2020-04-01 22:46:50 +08:00
|
|
|
var result = lookupForMania<TValue>(maniaLookup);
|
|
|
|
if (result != null)
|
|
|
|
return result;
|
2020-03-31 09:14:36 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2020-07-30 12:09:40 +08:00
|
|
|
case LegacySkinConfiguration.LegacySetting legacy:
|
2020-08-03 01:50:17 +08:00
|
|
|
return legacySettingLookup<TValue>(legacy);
|
2020-07-29 15:34:09 +08:00
|
|
|
|
2019-09-03 16:57:34 +08:00
|
|
|
default:
|
2020-08-03 01:46:29 +08:00
|
|
|
return genericLookup<TLookup, TValue>(lookup);
|
2019-09-03 16:57:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-04-01 22:46:50 +08:00
|
|
|
private IBindable<TValue> lookupForMania<TValue>(LegacyManiaSkinConfigurationLookup maniaLookup)
|
|
|
|
{
|
|
|
|
if (!maniaConfigurations.TryGetValue(maniaLookup.Keys, out var existing))
|
|
|
|
maniaConfigurations[maniaLookup.Keys] = existing = new LegacyManiaSkinConfiguration(maniaLookup.Keys);
|
|
|
|
|
|
|
|
switch (maniaLookup.Lookup)
|
|
|
|
{
|
|
|
|
case LegacyManiaSkinConfigurationLookups.ColumnWidth:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnWidth[maniaLookup.TargetColumn.Value]));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.ColumnSpacing:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnSpacing[maniaLookup.TargetColumn.Value]));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.HitPosition:
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.HitPosition));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.LightPosition:
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.LightPosition));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.ShowJudgementLine:
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<bool>(existing.ShowJudgementLine));
|
2020-04-02 13:29:16 +08:00
|
|
|
|
2020-08-25 14:35:37 +08:00
|
|
|
case LegacyManiaSkinConfigurationLookups.ExplosionImage:
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, "LightingN"));
|
|
|
|
|
2020-04-02 13:29:16 +08:00
|
|
|
case LegacyManiaSkinConfigurationLookups.ExplosionScale:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
|
|
|
|
if (GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value < 2.5m)
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(1));
|
|
|
|
|
|
|
|
if (existing.ExplosionWidth[maniaLookup.TargetColumn.Value] != 0)
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.ExplosionWidth[maniaLookup.TargetColumn.Value] / LegacyManiaSkinConfiguration.DEFAULT_COLUMN_SIZE));
|
|
|
|
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnWidth[maniaLookup.TargetColumn.Value] / LegacyManiaSkinConfiguration.DEFAULT_COLUMN_SIZE));
|
2020-04-02 22:57:03 +08:00
|
|
|
|
2020-04-02 17:10:17 +08:00
|
|
|
case LegacyManiaSkinConfigurationLookups.ColumnLineColour:
|
|
|
|
return SkinUtils.As<TValue>(getCustomColour(existing, "ColourColumnLine"));
|
2020-04-07 15:50:08 +08:00
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.JudgementLineColour:
|
|
|
|
return SkinUtils.As<TValue>(getCustomColour(existing, "ColourJudgementLine"));
|
2020-04-07 15:53:29 +08:00
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.ColumnBackgroundColour:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
2020-04-07 16:11:32 +08:00
|
|
|
return SkinUtils.As<TValue>(getCustomColour(existing, $"Colour{maniaLookup.TargetColumn + 1}"));
|
2020-04-07 15:53:29 +08:00
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.ColumnLightColour:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
2020-04-07 16:11:32 +08:00
|
|
|
return SkinUtils.As<TValue>(getCustomColour(existing, $"ColourLight{maniaLookup.TargetColumn + 1}"));
|
2020-04-07 22:36:42 +08:00
|
|
|
|
2020-04-07 15:07:18 +08:00
|
|
|
case LegacyManiaSkinConfigurationLookups.MinimumColumnWidth:
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.MinimumColumnWidth));
|
2020-04-07 21:41:22 +08:00
|
|
|
|
2020-04-06 18:04:02 +08:00
|
|
|
case LegacyManiaSkinConfigurationLookups.NoteImage:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, $"NoteImage{maniaLookup.TargetColumn}"));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, $"NoteImage{maniaLookup.TargetColumn}H"));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.HoldNoteTailImage:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, $"NoteImage{maniaLookup.TargetColumn}T"));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.HoldNoteBodyImage:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, $"NoteImage{maniaLookup.TargetColumn}L"));
|
|
|
|
|
2020-08-26 19:21:41 +08:00
|
|
|
case LegacyManiaSkinConfigurationLookups.HoldNoteLightImage:
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, "LightingL"));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.HoldNoteLightScale:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
|
|
|
|
if (GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value < 2.5m)
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(1));
|
|
|
|
|
|
|
|
if (existing.HoldNoteLightWidth[maniaLookup.TargetColumn.Value] != 0)
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.HoldNoteLightWidth[maniaLookup.TargetColumn.Value] / LegacyManiaSkinConfiguration.DEFAULT_COLUMN_SIZE));
|
|
|
|
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnWidth[maniaLookup.TargetColumn.Value] / LegacyManiaSkinConfiguration.DEFAULT_COLUMN_SIZE));
|
|
|
|
|
2020-04-06 18:04:02 +08:00
|
|
|
case LegacyManiaSkinConfigurationLookups.KeyImage:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, $"KeyImage{maniaLookup.TargetColumn}"));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.KeyImageDown:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, $"KeyImage{maniaLookup.TargetColumn}D"));
|
2020-04-08 14:36:07 +08:00
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.LeftStageImage:
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, "StageLeft"));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.RightStageImage:
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, "StageRight"));
|
2020-04-21 16:14:04 +08:00
|
|
|
|
2020-07-05 13:02:50 +08:00
|
|
|
case LegacyManiaSkinConfigurationLookups.BottomStageImage:
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, "StageBottom"));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.LightImage:
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, "StageLight"));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.HitTargetImage:
|
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, "StageHint"));
|
|
|
|
|
2020-04-21 16:14:04 +08:00
|
|
|
case LegacyManiaSkinConfigurationLookups.LeftLineWidth:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnLineWidth[maniaLookup.TargetColumn.Value]));
|
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.RightLineWidth:
|
|
|
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnLineWidth[maniaLookup.TargetColumn.Value + 1]));
|
2020-06-12 21:22:22 +08:00
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.Hit0:
|
|
|
|
case LegacyManiaSkinConfigurationLookups.Hit50:
|
|
|
|
case LegacyManiaSkinConfigurationLookups.Hit100:
|
|
|
|
case LegacyManiaSkinConfigurationLookups.Hit200:
|
|
|
|
case LegacyManiaSkinConfigurationLookups.Hit300:
|
|
|
|
case LegacyManiaSkinConfigurationLookups.Hit300g:
|
2020-06-13 20:19:06 +08:00
|
|
|
return SkinUtils.As<TValue>(getManiaImage(existing, maniaLookup.Lookup.ToString()));
|
2020-08-26 14:37:16 +08:00
|
|
|
|
|
|
|
case LegacyManiaSkinConfigurationLookups.KeysUnderNotes:
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<bool>(existing.KeysUnderNotes));
|
2020-04-01 22:46:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-04-02 16:56:12 +08:00
|
|
|
private IBindable<Color4> getCustomColour(IHasCustomColours source, string lookup)
|
|
|
|
=> source.CustomColours.TryGetValue(lookup, out var col) ? new Bindable<Color4>(col) : null;
|
2019-09-03 16:57:34 +08:00
|
|
|
|
2020-04-06 18:04:02 +08:00
|
|
|
private IBindable<string> getManiaImage(LegacyManiaSkinConfiguration source, string lookup)
|
|
|
|
=> source.ImageLookups.TryGetValue(lookup, out var image) ? new Bindable<string>(image) : null;
|
|
|
|
|
2020-08-03 01:50:17 +08:00
|
|
|
[CanBeNull]
|
|
|
|
private IBindable<TValue> legacySettingLookup<TValue>(LegacySkinConfiguration.LegacySetting legacySetting)
|
|
|
|
{
|
|
|
|
switch (legacySetting)
|
|
|
|
{
|
|
|
|
case LegacySkinConfiguration.LegacySetting.Version:
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<decimal>(Configuration.LegacyVersion ?? LegacySkinConfiguration.LATEST_VERSION));
|
|
|
|
|
|
|
|
default:
|
|
|
|
return genericLookup<LegacySkinConfiguration.LegacySetting, TValue>(legacySetting);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-03 01:46:29 +08:00
|
|
|
[CanBeNull]
|
|
|
|
private IBindable<TValue> genericLookup<TLookup, TValue>(TLookup lookup)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (Configuration.ConfigDictionary.TryGetValue(lookup.ToString(), out var val))
|
|
|
|
{
|
|
|
|
// special case for handling skins which use 1 or 0 to signify a boolean state.
|
|
|
|
if (typeof(TValue) == typeof(bool))
|
|
|
|
val = val == "1" ? "true" : "false";
|
|
|
|
|
|
|
|
var bindable = new Bindable<TValue>();
|
|
|
|
if (val != null)
|
|
|
|
bindable.Parse(val);
|
|
|
|
return bindable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-08-30 13:39:02 +08:00
|
|
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-08-30 14:12:03 +08:00
|
|
|
switch (component)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-08-30 14:10:11 +08:00
|
|
|
case GameplaySkinComponent<HitResult> resultComponent:
|
2019-08-30 14:12:03 +08:00
|
|
|
switch (resultComponent.Component)
|
|
|
|
{
|
|
|
|
case HitResult.Miss:
|
|
|
|
return this.GetAnimation("hit0", true, false);
|
2019-04-01 11:16:05 +08:00
|
|
|
|
2019-08-30 14:12:03 +08:00
|
|
|
case HitResult.Meh:
|
|
|
|
return this.GetAnimation("hit50", true, false);
|
2019-04-01 11:16:05 +08:00
|
|
|
|
2019-08-30 14:12:03 +08:00
|
|
|
case HitResult.Good:
|
|
|
|
return this.GetAnimation("hit100", true, false);
|
2019-04-01 11:16:05 +08:00
|
|
|
|
2019-08-30 14:12:03 +08:00
|
|
|
case HitResult.Great:
|
|
|
|
return this.GetAnimation("hit300", true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2019-08-30 13:39:02 +08:00
|
|
|
return this.GetAnimation(component.LookupName, false, false);
|
2019-08-19 18:23:54 +08:00
|
|
|
}
|
|
|
|
|
2020-07-17 15:54:30 +08:00
|
|
|
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
|
2019-08-27 16:18:32 +08:00
|
|
|
{
|
2020-04-06 18:02:50 +08:00
|
|
|
foreach (var name in getFallbackNames(componentName))
|
|
|
|
{
|
|
|
|
float ratio = 2;
|
2020-07-17 15:54:30 +08:00
|
|
|
var texture = Textures?.Get($"{name}@2x", wrapModeS, wrapModeT);
|
2019-08-27 16:18:32 +08:00
|
|
|
|
2020-04-06 18:02:50 +08:00
|
|
|
if (texture == null)
|
|
|
|
{
|
|
|
|
ratio = 1;
|
2020-07-17 15:54:30 +08:00
|
|
|
texture = Textures?.Get(name, wrapModeS, wrapModeT);
|
2020-04-06 18:02:50 +08:00
|
|
|
}
|
2019-08-27 16:18:32 +08:00
|
|
|
|
2020-04-08 04:50:25 +08:00
|
|
|
if (texture == null)
|
|
|
|
continue;
|
2019-08-27 16:18:32 +08:00
|
|
|
|
2020-04-08 04:50:25 +08:00
|
|
|
texture.ScaleAdjust = ratio;
|
2020-04-06 18:02:50 +08:00
|
|
|
return texture;
|
2019-08-27 16:18:32 +08:00
|
|
|
}
|
|
|
|
|
2020-04-06 18:02:50 +08:00
|
|
|
return null;
|
2019-08-27 16:18:32 +08:00
|
|
|
}
|
|
|
|
|
2019-08-23 19:32:43 +08:00
|
|
|
public override SampleChannel GetSample(ISampleInfo sampleInfo)
|
2019-08-22 17:50:47 +08:00
|
|
|
{
|
2020-07-29 05:52:09 +08:00
|
|
|
var lookupNames = sampleInfo.LookupNames;
|
|
|
|
|
|
|
|
if (sampleInfo is HitSampleInfo hitSample)
|
|
|
|
lookupNames = getLegacyLookupNames(hitSample);
|
|
|
|
|
|
|
|
foreach (var lookup in lookupNames)
|
2019-08-22 17:50:47 +08:00
|
|
|
{
|
2020-01-02 13:07:22 +08:00
|
|
|
var sample = Samples?.Get(lookup);
|
2019-08-23 19:32:43 +08:00
|
|
|
|
|
|
|
if (sample != null)
|
|
|
|
return sample;
|
2019-08-22 17:50:47 +08:00
|
|
|
}
|
|
|
|
|
2019-08-23 19:32:43 +08:00
|
|
|
return null;
|
2019-08-22 17:50:47 +08:00
|
|
|
}
|
2019-08-27 16:18:32 +08:00
|
|
|
|
2020-04-06 18:02:50 +08:00
|
|
|
private IEnumerable<string> getFallbackNames(string componentName)
|
2019-08-27 16:18:32 +08:00
|
|
|
{
|
2020-04-06 18:02:50 +08:00
|
|
|
// May be something like "Gameplay/osu/approachcircle" from lazer, or "Arrows/note1" from a user skin.
|
|
|
|
yield return componentName;
|
|
|
|
|
|
|
|
// Fall back to using the last piece for components coming from lazer (e.g. "Gameplay/osu/approachcircle" -> "approachcircle").
|
2019-08-27 16:18:32 +08:00
|
|
|
string lastPiece = componentName.Split('/').Last();
|
2020-04-06 18:02:50 +08:00
|
|
|
yield return componentName.StartsWith("Gameplay/taiko/") ? "taiko-" + lastPiece : lastPiece;
|
2019-08-27 16:18:32 +08:00
|
|
|
}
|
2020-07-29 05:52:09 +08:00
|
|
|
|
|
|
|
private IEnumerable<string> getLegacyLookupNames(HitSampleInfo hitSample)
|
|
|
|
{
|
|
|
|
var lookupNames = hitSample.LookupNames;
|
|
|
|
|
|
|
|
if (!UseCustomSampleBanks && !string.IsNullOrEmpty(hitSample.Suffix))
|
|
|
|
// for compatibility with stable, exclude the lookup names with the custom sample bank suffix, if they are not valid for use in this skin.
|
|
|
|
// using .EndsWith() is intentional as it ensures parity in all edge cases
|
|
|
|
// (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply, but the sample bank should not).
|
|
|
|
lookupNames = hitSample.LookupNames.Where(name => !name.EndsWith(hitSample.Suffix));
|
|
|
|
|
2020-07-31 04:07:07 +08:00
|
|
|
// also for compatibility, try falling back to non-bank samples (so-called "universal" samples) as the last resort.
|
|
|
|
// going forward specifying banks shall always be required, even for elements that wouldn't require it on stable,
|
|
|
|
// which is why this is done locally here.
|
|
|
|
lookupNames = lookupNames.Append(hitSample.Name);
|
|
|
|
|
2020-07-29 05:52:09 +08:00
|
|
|
return lookupNames;
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|