2019-09-03 08:57:34 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 08:43:03 +00:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-09-05 14:24:13 +00:00
|
|
|
|
using System.Collections.Generic;
|
2021-05-11 05:12:28 +00:00
|
|
|
|
using System.Linq;
|
2021-05-12 20:18:15 +00:00
|
|
|
|
using JetBrains.Annotations;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-09-03 08:57:34 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-07-17 07:54:30 +00:00
|
|
|
|
using osu.Framework.Graphics.OpenGL.Textures;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2019-08-23 11:32:43 +00:00
|
|
|
|
using osu.Game.Audio;
|
2021-05-05 04:11:45 +00:00
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
2021-05-11 05:12:28 +00:00
|
|
|
|
using osu.Game.Extensions;
|
2021-05-11 08:00:24 +00:00
|
|
|
|
using osu.Game.IO;
|
2021-05-17 09:26:15 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2021-05-11 05:12:28 +00:00
|
|
|
|
using osu.Game.Screens.Play.HUD;
|
2021-05-18 06:50:40 +00:00
|
|
|
|
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
2021-05-11 05:12:28 +00:00
|
|
|
|
using osuTK;
|
2019-09-05 14:24:13 +00:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
|
{
|
|
|
|
|
public class DefaultSkin : Skin
|
|
|
|
|
{
|
2021-11-29 08:15:26 +00:00
|
|
|
|
public static SkinInfo CreateInfo() => new SkinInfo
|
|
|
|
|
{
|
|
|
|
|
ID = osu.Game.Skinning.SkinInfo.DEFAULT_SKIN,
|
|
|
|
|
Name = "osu! (triangles)",
|
|
|
|
|
Creator = "team osu!",
|
|
|
|
|
Protected = true,
|
|
|
|
|
InstantiationInfo = typeof(DefaultSkin).GetInvariantInstantiationInfo()
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-27 02:48:48 +00:00
|
|
|
|
private readonly IStorageResourceProvider resources;
|
|
|
|
|
|
2021-05-11 08:00:24 +00:00
|
|
|
|
public DefaultSkin(IStorageResourceProvider resources)
|
2021-11-29 08:15:26 +00:00
|
|
|
|
: this(CreateInfo(), resources)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-12 20:18:15 +00:00
|
|
|
|
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
|
2021-05-11 08:00:24 +00:00
|
|
|
|
public DefaultSkin(SkinInfo skin, IStorageResourceProvider resources)
|
|
|
|
|
: base(skin, resources)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2021-05-27 02:48:48 +00:00
|
|
|
|
this.resources = resources;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-17 07:54:30 +00:00
|
|
|
|
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-05-27 02:48:48 +00:00
|
|
|
|
public override ISample GetSample(ISampleInfo sampleInfo)
|
|
|
|
|
{
|
2021-10-27 04:04:41 +00:00
|
|
|
|
foreach (string lookup in sampleInfo.LookupNames)
|
2021-05-27 02:48:48 +00:00
|
|
|
|
{
|
|
|
|
|
var sample = resources.AudioManager.Samples.Get(lookup);
|
|
|
|
|
if (sample != null)
|
|
|
|
|
return sample;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2019-09-03 08:57:34 +00:00
|
|
|
|
|
2021-05-11 05:12:28 +00:00
|
|
|
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
|
|
|
|
{
|
2021-05-11 09:55:45 +00:00
|
|
|
|
if (base.GetDrawableComponent(component) is Drawable c)
|
|
|
|
|
return c;
|
|
|
|
|
|
2021-05-11 05:12:28 +00:00
|
|
|
|
switch (component)
|
|
|
|
|
{
|
|
|
|
|
case SkinnableTargetComponent target:
|
|
|
|
|
switch (target.Target)
|
|
|
|
|
{
|
|
|
|
|
case SkinnableTarget.MainHUDComponents:
|
2021-05-13 09:51:23 +00:00
|
|
|
|
var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
|
2021-05-11 05:12:28 +00:00
|
|
|
|
{
|
|
|
|
|
var score = container.OfType<DefaultScoreCounter>().FirstOrDefault();
|
|
|
|
|
var accuracy = container.OfType<DefaultAccuracyCounter>().FirstOrDefault();
|
|
|
|
|
var combo = container.OfType<DefaultComboCounter>().FirstOrDefault();
|
2021-10-04 11:34:08 +00:00
|
|
|
|
var ppCounter = container.OfType<PerformancePointsCounter>().FirstOrDefault();
|
2021-05-11 05:12:28 +00:00
|
|
|
|
|
|
|
|
|
if (score != null)
|
|
|
|
|
{
|
|
|
|
|
score.Anchor = Anchor.TopCentre;
|
|
|
|
|
score.Origin = Anchor.TopCentre;
|
|
|
|
|
|
|
|
|
|
// elements default to beneath the health bar
|
|
|
|
|
const float vertical_offset = 30;
|
|
|
|
|
|
|
|
|
|
const float horizontal_padding = 20;
|
|
|
|
|
|
|
|
|
|
score.Position = new Vector2(0, vertical_offset);
|
|
|
|
|
|
2021-09-30 08:55:00 +00:00
|
|
|
|
if (ppCounter != null)
|
|
|
|
|
{
|
2021-10-05 06:23:34 +00:00
|
|
|
|
ppCounter.Y = score.Position.Y + ppCounter.ScreenSpaceDeltaToParentSpace(score.ScreenSpaceDrawQuad.Size).Y - 4;
|
2021-09-30 08:55:00 +00:00
|
|
|
|
ppCounter.Origin = Anchor.TopCentre;
|
|
|
|
|
ppCounter.Anchor = Anchor.TopCentre;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-11 05:12:28 +00:00
|
|
|
|
if (accuracy != null)
|
|
|
|
|
{
|
|
|
|
|
accuracy.Position = new Vector2(-accuracy.ScreenSpaceDeltaToParentSpace(score.ScreenSpaceDrawQuad.Size).X / 2 - horizontal_padding, vertical_offset + 5);
|
|
|
|
|
accuracy.Origin = Anchor.TopRight;
|
|
|
|
|
accuracy.Anchor = Anchor.TopCentre;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (combo != null)
|
|
|
|
|
{
|
|
|
|
|
combo.Position = new Vector2(accuracy.ScreenSpaceDeltaToParentSpace(score.ScreenSpaceDrawQuad.Size).X / 2 + horizontal_padding, vertical_offset + 5);
|
|
|
|
|
combo.Anchor = Anchor.TopCentre;
|
|
|
|
|
}
|
2021-05-18 06:50:40 +00:00
|
|
|
|
|
|
|
|
|
var hitError = container.OfType<HitErrorMeter>().FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (hitError != null)
|
|
|
|
|
{
|
|
|
|
|
hitError.Anchor = Anchor.CentreLeft;
|
|
|
|
|
hitError.Origin = Anchor.CentreLeft;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hitError2 = container.OfType<HitErrorMeter>().LastOrDefault();
|
|
|
|
|
|
|
|
|
|
if (hitError2 != null)
|
|
|
|
|
{
|
|
|
|
|
hitError2.Anchor = Anchor.CentreRight;
|
|
|
|
|
hitError2.Scale = new Vector2(-1, 1);
|
2021-05-19 16:59:30 +00:00
|
|
|
|
// origin flipped to match scale above.
|
|
|
|
|
hitError2.Origin = Anchor.CentreLeft;
|
2021-05-18 06:50:40 +00:00
|
|
|
|
}
|
2021-05-11 05:12:28 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{
|
2021-05-18 09:37:23 +00:00
|
|
|
|
Children = new Drawable[]
|
2021-05-11 05:12:28 +00:00
|
|
|
|
{
|
2021-05-18 09:37:23 +00:00
|
|
|
|
new DefaultComboCounter(),
|
|
|
|
|
new DefaultScoreCounter(),
|
|
|
|
|
new DefaultAccuracyCounter(),
|
|
|
|
|
new DefaultHealthDisplay(),
|
2021-05-31 06:23:04 +00:00
|
|
|
|
new SongProgress(),
|
|
|
|
|
new BarHitErrorMeter(),
|
|
|
|
|
new BarHitErrorMeter(),
|
2021-10-04 11:34:08 +00:00
|
|
|
|
new PerformancePointsCounter()
|
2021-05-11 05:12:28 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return skinnableTargetWrapper;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-13 04:02:55 +00:00
|
|
|
|
break;
|
2021-05-11 05:12:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-13 04:02:55 +00:00
|
|
|
|
return null;
|
2021-05-11 05:12:28 +00:00
|
|
|
|
}
|
2019-09-03 08:57:34 +00:00
|
|
|
|
|
2019-09-05 14:24:13 +00:00
|
|
|
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
|
|
|
|
{
|
2021-05-05 04:11:45 +00:00
|
|
|
|
// todo: this code is pulled from LegacySkin and should not exist.
|
|
|
|
|
// will likely change based on how databased storage of skin configuration goes.
|
2019-09-05 14:24:13 +00:00
|
|
|
|
switch (lookup)
|
|
|
|
|
{
|
2020-02-07 05:58:07 +00:00
|
|
|
|
case GlobalSkinColours global:
|
2019-09-05 14:24:13 +00:00
|
|
|
|
switch (global)
|
|
|
|
|
{
|
2020-02-07 05:58:07 +00:00
|
|
|
|
case GlobalSkinColours.ComboColours:
|
2019-11-07 12:54:30 +00:00
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(Configuration.ComboColours));
|
2019-09-05 14:24:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2021-05-05 04:11:45 +00:00
|
|
|
|
|
|
|
|
|
case SkinComboColourLookup comboColour:
|
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<Color4>(getComboColour(Configuration, comboColour.ColourIndex)));
|
2019-09-05 14:24:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-05-05 04:11:45 +00:00
|
|
|
|
|
|
|
|
|
private static Color4 getComboColour(IHasComboColours source, int colourIndex)
|
|
|
|
|
=> source.ComboColours[colourIndex % source.ComboColours.Count];
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|