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;
|
2021-05-13 04:18:15 +08:00
|
|
|
|
using JetBrains.Annotations;
|
2018-02-23 11:35:25 +08:00
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-09-03 16:57:34 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-02-22 16:16:48 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2018-03-20 15:28:39 +08:00
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2019-08-23 19:32:43 +08:00
|
|
|
|
using osu.Game.Audio;
|
2021-05-05 12:11:45 +08:00
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
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;
|
2021-05-18 14:50:40 +08:00
|
|
|
|
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
2021-05-11 13:12:28 +08:00
|
|
|
|
using osuTK;
|
2019-09-05 22:24:13 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-02-22 16:16:48 +08:00
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
|
{
|
2022-09-17 23:14:49 +08:00
|
|
|
|
public class TrianglesSkin : Skin
|
2018-02-22 16:16:48 +08:00
|
|
|
|
{
|
2021-11-29 16:15:26 +08:00
|
|
|
|
public static SkinInfo CreateInfo() => new SkinInfo
|
|
|
|
|
{
|
2022-09-17 23:14:49 +08:00
|
|
|
|
ID = osu.Game.Skinning.SkinInfo.TRIANGLES_SKIN,
|
2022-09-15 14:49:15 +08:00
|
|
|
|
Name = "osu! \"triangles\" (2017)",
|
2021-11-29 16:15:26 +08:00
|
|
|
|
Creator = "team osu!",
|
|
|
|
|
Protected = true,
|
2022-09-17 23:14:49 +08:00
|
|
|
|
InstantiationInfo = typeof(TrianglesSkin).GetInvariantInstantiationInfo()
|
2021-11-29 16:15:26 +08:00
|
|
|
|
};
|
|
|
|
|
|
2021-05-27 10:48:48 +08:00
|
|
|
|
private readonly IStorageResourceProvider resources;
|
|
|
|
|
|
2022-09-17 23:14:49 +08:00
|
|
|
|
public TrianglesSkin(IStorageResourceProvider resources)
|
2021-11-29 16:15:26 +08:00
|
|
|
|
: this(CreateInfo(), resources)
|
2018-02-22 16:16:48 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-05-13 04:18:15 +08:00
|
|
|
|
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
|
2022-09-17 23:14:49 +08:00
|
|
|
|
public TrianglesSkin(SkinInfo skin, IStorageResourceProvider resources)
|
2021-05-11 16:00:24 +08:00
|
|
|
|
: base(skin, resources)
|
2018-02-22 16:16:48 +08:00
|
|
|
|
{
|
2021-05-27 10:48:48 +08:00
|
|
|
|
this.resources = resources;
|
2018-02-22 16:16:48 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-11-09 12:44:59 +08:00
|
|
|
|
public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Textures?.Get(componentName, wrapModeS, wrapModeT);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-11-09 12:44:59 +08:00
|
|
|
|
public override ISample? GetSample(ISampleInfo sampleInfo)
|
2021-05-27 10:48:48 +08:00
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
foreach (string lookup in sampleInfo.LookupNames)
|
2021-05-27 10:48:48 +08:00
|
|
|
|
{
|
2022-08-08 12:31:57 +08:00
|
|
|
|
var sample = Samples?.Get(lookup) ?? resources.AudioManager?.Samples.Get(lookup);
|
2021-05-27 10:48:48 +08:00
|
|
|
|
if (sample != null)
|
|
|
|
|
return sample;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2019-09-03 16:57:34 +08:00
|
|
|
|
|
2022-11-09 15:04:56 +08:00
|
|
|
|
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
|
2021-05-11 13:12:28 +08:00
|
|
|
|
{
|
2022-11-13 11:46:20 +08:00
|
|
|
|
// Temporary until default skin has a valid hit lighting.
|
|
|
|
|
if ((lookup as SkinnableSprite.SpriteComponentLookup)?.LookupName == @"lighting") return Drawable.Empty();
|
|
|
|
|
|
2022-11-09 13:11:41 +08:00
|
|
|
|
if (base.GetDrawableComponent(lookup) is Drawable c)
|
2021-05-11 17:55:45 +08:00
|
|
|
|
return c;
|
|
|
|
|
|
2022-11-09 13:11:41 +08:00
|
|
|
|
switch (lookup)
|
2021-05-11 13:12:28 +08:00
|
|
|
|
{
|
2023-02-16 14:33:56 +08:00
|
|
|
|
case SkinComponentsContainerLookup containerLookup:
|
2023-02-17 17:22:10 +08:00
|
|
|
|
// Only handle global level defaults for now.
|
|
|
|
|
if (containerLookup.Ruleset != null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-02-16 14:33:56 +08:00
|
|
|
|
switch (containerLookup.Target)
|
2021-05-11 13:12:28 +08:00
|
|
|
|
{
|
2023-02-15 17:31:55 +08:00
|
|
|
|
case SkinComponentsContainerLookup.TargetArea.SongSelect:
|
2023-02-15 16:24:34 +08:00
|
|
|
|
var songSelectComponents = new DefaultSkinComponentsContainer(_ =>
|
2022-03-07 22:26:27 +08:00
|
|
|
|
{
|
|
|
|
|
// do stuff when we need to.
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return songSelectComponents;
|
|
|
|
|
|
2023-02-15 17:31:55 +08:00
|
|
|
|
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents:
|
2023-02-15 16:24:34 +08:00
|
|
|
|
var skinnableTargetWrapper = new DefaultSkinComponentsContainer(container =>
|
2021-05-11 13:12:28 +08:00
|
|
|
|
{
|
|
|
|
|
var score = container.OfType<DefaultScoreCounter>().FirstOrDefault();
|
|
|
|
|
var accuracy = container.OfType<DefaultAccuracyCounter>().FirstOrDefault();
|
|
|
|
|
var combo = container.OfType<DefaultComboCounter>().FirstOrDefault();
|
2021-10-04 19:34:08 +08:00
|
|
|
|
var ppCounter = container.OfType<PerformancePointsCounter>().FirstOrDefault();
|
2023-06-15 03:15:12 +08:00
|
|
|
|
var songProgress = container.OfType<DefaultSongProgress>().FirstOrDefault();
|
|
|
|
|
var keyCounter = container.OfType<DefaultKeyCounterDisplay>().FirstOrDefault();
|
2021-05-11 13:12:28 +08: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 16:55:00 +08:00
|
|
|
|
if (ppCounter != null)
|
|
|
|
|
{
|
2021-10-05 14:23:34 +08:00
|
|
|
|
ppCounter.Y = score.Position.Y + ppCounter.ScreenSpaceDeltaToParentSpace(score.ScreenSpaceDrawQuad.Size).Y - 4;
|
2021-09-30 16:55:00 +08:00
|
|
|
|
ppCounter.Origin = Anchor.TopCentre;
|
|
|
|
|
ppCounter.Anchor = Anchor.TopCentre;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-11 13:12:28 +08: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;
|
|
|
|
|
|
2022-07-02 11:50:28 +08:00
|
|
|
|
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-11 13:12:28 +08:00
|
|
|
|
}
|
2021-05-18 14:50:40 +08: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-20 00:59:30 +08:00
|
|
|
|
// origin flipped to match scale above.
|
|
|
|
|
hitError2.Origin = Anchor.CentreLeft;
|
2021-05-18 14:50:40 +08:00
|
|
|
|
}
|
2021-05-11 13:12:28 +08:00
|
|
|
|
}
|
2023-06-15 03:15:12 +08:00
|
|
|
|
|
|
|
|
|
if (songProgress != null && keyCounter != null)
|
|
|
|
|
{
|
2023-06-26 15:04:16 +08:00
|
|
|
|
const float padding = 10;
|
|
|
|
|
|
2023-06-26 15:20:51 +08:00
|
|
|
|
// Hard to find this at runtime, so taken from the most expanded state during replay.
|
|
|
|
|
const float song_progress_offset_height = 73;
|
|
|
|
|
|
2023-06-15 03:15:12 +08:00
|
|
|
|
keyCounter.Anchor = Anchor.BottomRight;
|
|
|
|
|
keyCounter.Origin = Anchor.BottomRight;
|
2023-06-26 15:20:51 +08:00
|
|
|
|
keyCounter.Position = new Vector2(-padding, -(song_progress_offset_height + padding));
|
2023-06-15 03:15:12 +08:00
|
|
|
|
}
|
2021-05-11 13:12:28 +08:00
|
|
|
|
})
|
|
|
|
|
{
|
2021-05-18 17:37:23 +08:00
|
|
|
|
Children = new Drawable[]
|
2021-05-11 13:12:28 +08:00
|
|
|
|
{
|
2021-05-18 17:37:23 +08:00
|
|
|
|
new DefaultComboCounter(),
|
|
|
|
|
new DefaultScoreCounter(),
|
|
|
|
|
new DefaultAccuracyCounter(),
|
|
|
|
|
new DefaultHealthDisplay(),
|
2022-07-27 15:19:21 +08:00
|
|
|
|
new DefaultSongProgress(),
|
2023-06-15 03:15:12 +08:00
|
|
|
|
new DefaultKeyCounterDisplay(),
|
2021-05-31 14:23:04 +08:00
|
|
|
|
new BarHitErrorMeter(),
|
|
|
|
|
new BarHitErrorMeter(),
|
2021-10-04 19:34:08 +08:00
|
|
|
|
new PerformancePointsCounter()
|
2021-05-11 13:12:28 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return skinnableTargetWrapper;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-23 06:08:53 +08:00
|
|
|
|
return null;
|
2021-05-11 13:12:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-13 12:02:55 +08:00
|
|
|
|
return null;
|
2021-05-11 13:12:28 +08:00
|
|
|
|
}
|
2019-09-03 16:57:34 +08:00
|
|
|
|
|
2022-11-09 12:44:59 +08:00
|
|
|
|
public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)
|
2019-09-05 22:24:13 +08:00
|
|
|
|
{
|
2021-05-05 12:11:45 +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.
|
2019-09-05 22:24:13 +08:00
|
|
|
|
switch (lookup)
|
|
|
|
|
{
|
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:
|
2023-09-06 16:37:17 +08:00
|
|
|
|
{
|
|
|
|
|
LogLookupDebug(this, lookup, LookupDebugType.Hit);
|
2022-11-09 12:44:59 +08:00
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>?>(Configuration.ComboColours));
|
2023-09-06 16:37:17 +08:00
|
|
|
|
}
|
2019-09-05 22:24:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2021-05-05 12:11:45 +08:00
|
|
|
|
|
|
|
|
|
case SkinComboColourLookup comboColour:
|
2023-09-06 16:37:17 +08:00
|
|
|
|
LogLookupDebug(this, lookup, LookupDebugType.Hit);
|
2021-05-05 12:11:45 +08:00
|
|
|
|
return SkinUtils.As<TValue>(new Bindable<Color4>(getComboColour(Configuration, comboColour.ColourIndex)));
|
2019-09-05 22:24:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-06 16:37:17 +08:00
|
|
|
|
LogLookupDebug(this, lookup, LookupDebugType.Miss);
|
2019-09-05 22:24:13 +08:00
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-05-05 12:11:45 +08:00
|
|
|
|
|
|
|
|
|
private static Color4 getComboColour(IHasComboColours source, int colourIndex)
|
2023-08-16 18:34:37 +08:00
|
|
|
|
=> source.ComboColours![colourIndex % source.ComboColours.Count];
|
2018-02-22 16:16:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|