2019-09-03 16:57:34 +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
|
|
|
|
|
2019-09-05 22:24:13 +08:00
|
|
|
|
using System.Collections.Generic;
|
2021-05-11 13:12:28 +08:00
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-09-03 16:57:34 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2021-05-11 13:12:28 +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;
|
2019-08-23 19:32:43 +08:00
|
|
|
|
using osu.Game.Audio;
|
2021-05-11 13:12:28 +08:00
|
|
|
|
using osu.Game.Extensions;
|
2021-05-11 16:00:24 +08:00
|
|
|
|
using osu.Game.IO;
|
2021-05-11 13:12:28 +08:00
|
|
|
|
using osu.Game.Screens.Play.HUD;
|
|
|
|
|
using osuTK;
|
2019-09-05 22:24:13 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
|
{
|
|
|
|
|
public class DefaultSkin : Skin
|
|
|
|
|
{
|
2021-05-11 16:00:24 +08:00
|
|
|
|
public DefaultSkin(IStorageResourceProvider resources)
|
|
|
|
|
: this(SkinInfo.Default, resources)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DefaultSkin(SkinInfo skin, IStorageResourceProvider resources)
|
|
|
|
|
: base(skin, resources)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-08-31 11:33:29 +08:00
|
|
|
|
Configuration = new DefaultSkinConfiguration();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-17 15:54:30 +08:00
|
|
|
|
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-18 17:32:28 +08:00
|
|
|
|
public override ISample GetSample(ISampleInfo sampleInfo) => null;
|
2019-09-03 16:57:34 +08:00
|
|
|
|
|
2021-05-11 13:12:28 +08:00
|
|
|
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
|
|
|
|
{
|
|
|
|
|
switch (component)
|
|
|
|
|
{
|
|
|
|
|
case SkinnableTargetComponent target:
|
|
|
|
|
switch (target.Target)
|
|
|
|
|
{
|
|
|
|
|
case SkinnableTarget.MainHUDComponents:
|
|
|
|
|
var skinnableTargetWrapper = new SkinnableTargetWrapper(container =>
|
|
|
|
|
{
|
|
|
|
|
var score = container.OfType<DefaultScoreCounter>().FirstOrDefault();
|
|
|
|
|
var accuracy = container.OfType<DefaultAccuracyCounter>().FirstOrDefault();
|
|
|
|
|
var combo = container.OfType<DefaultComboCounter>().FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new DefaultComboCounter(),
|
|
|
|
|
new DefaultScoreCounter(),
|
|
|
|
|
new DefaultAccuracyCounter(),
|
|
|
|
|
new DefaultHealthDisplay(),
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return skinnableTargetWrapper;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.GetDrawableComponent(component);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 22:24:13 +08:00
|
|
|
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
|
|
|
|
{
|
|
|
|
|
switch (lookup)
|
|
|
|
|
{
|
2019-09-06 11:16:20 +08:00
|
|
|
|
// todo: this code is pulled from LegacySkin and should not exist.
|
|
|
|
|
// will likely change based on how databased storage of skin configuration goes.
|
2020-02-07 13:58:07 +08:00
|
|
|
|
case GlobalSkinColours global:
|
2019-09-05 22:24:13 +08:00
|
|
|
|
switch (global)
|
|
|
|
|
{
|
2020-02-07 13:58:07 +08:00
|
|
|
|
case GlobalSkinColours.ComboColours:
|
2019-11-07 20:54:30 +08:00
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(Configuration.ComboColours));
|
2019-09-05 22:24:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|