1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 09:42:55 +08:00

Update in line with new changes

This commit is contained in:
Dean Herbert 2024-08-09 00:19:36 +09:00
parent e645651ef4
commit 80c814008f
No known key found for this signature in database
7 changed files with 93 additions and 85 deletions

View File

@ -4,7 +4,6 @@
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -37,7 +36,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
// Modifications for global components. // Modifications for global components.
if (containerLookup.Ruleset == null) if (containerLookup.Ruleset == null)
return base.GetDrawableComponent(lookup) as Container; return base.GetDrawableComponent(lookup);
// Skin has configuration. // Skin has configuration.
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d) if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Diagnostics;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -15,7 +14,7 @@ using osuTK.Graphics;
namespace osu.Game.Rulesets.Mania.Skinning.Argon namespace osu.Game.Rulesets.Mania.Skinning.Argon
{ {
public class ManiaArgonSkinTransformer : ArgonSkinTransformer public class ManiaArgonSkinTransformer : SkinTransformer
{ {
private readonly ManiaBeatmap beatmap; private readonly ManiaBeatmap beatmap;
@ -30,32 +29,31 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
switch (lookup) switch (lookup)
{ {
case SkinComponentsContainerLookup containerLookup: case SkinComponentsContainerLookup containerLookup:
switch (containerLookup.Target) if (containerLookup.Target != SkinComponentsContainerLookup.TargetArea.MainHUDComponents)
return base.GetDrawableComponent(lookup);
// Only handle per ruleset defaults here.
if (containerLookup.Ruleset == null)
return base.GetDrawableComponent(lookup);
// Skin has configuration.
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
return d;
return new DefaultSkinComponentsContainer(container =>
{ {
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents when containerLookup.Ruleset != null: var combo = container.ChildrenOfType<ArgonManiaComboCounter>().FirstOrDefault();
Debug.Assert(containerLookup.Ruleset.ShortName == ManiaRuleset.SHORT_NAME);
var rulesetHUDComponents = Skin.GetDrawableComponent(lookup); if (combo != null)
{
rulesetHUDComponents ??= new DefaultSkinComponentsContainer(container => combo.Anchor = Anchor.TopCentre;
{ combo.Origin = Anchor.Centre;
var combo = container.ChildrenOfType<ArgonManiaComboCounter>().FirstOrDefault(); combo.Y = 200;
}
if (combo != null) })
{ {
combo.Anchor = Anchor.TopCentre; new ArgonManiaComboCounter(),
combo.Origin = Anchor.Centre; };
combo.Y = 200;
}
})
{
new ArgonManiaComboCounter(),
};
return rulesetHUDComponents;
}
break;
case GameplaySkinComponentLookup<HitResult> resultComponent: case GameplaySkinComponentLookup<HitResult> resultComponent:
// This should eventually be moved to a skin setting, when supported. // This should eventually be moved to a skin setting, when supported.

View File

@ -3,7 +3,6 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.EnumExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -49,7 +48,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
private void updateAnchor() private void updateAnchor()
{ {
// if the anchor isn't a vertical center, set top or bottom anchor based on scroll direction // if the anchor isn't a vertical center, set top or bottom anchor based on scroll direction
if (!Anchor.HasFlagFast(Anchor.y1)) if (!Anchor.HasFlag(Anchor.y1))
{ {
Anchor &= ~(Anchor.y0 | Anchor.y2); Anchor &= ~(Anchor.y0 | Anchor.y2);
Anchor |= direction.Value == ScrollingDirection.Up ? Anchor.y2 : Anchor.y0; Anchor |= direction.Value == ScrollingDirection.Up ? Anchor.y2 : Anchor.y0;

View File

@ -5,7 +5,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -82,32 +81,31 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
switch (lookup) switch (lookup)
{ {
case SkinComponentsContainerLookup containerLookup: case SkinComponentsContainerLookup containerLookup:
switch (containerLookup.Target) if (containerLookup.Target != SkinComponentsContainerLookup.TargetArea.MainHUDComponents)
return base.GetDrawableComponent(lookup);
// Modifications for global components.
if (containerLookup.Ruleset == null)
return base.GetDrawableComponent(lookup);
// Skin has configuration.
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
return d;
return new DefaultSkinComponentsContainer(container =>
{ {
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents when containerLookup.Ruleset != null: var combo = container.ChildrenOfType<LegacyManiaComboCounter>().FirstOrDefault();
Debug.Assert(containerLookup.Ruleset.ShortName == ManiaRuleset.SHORT_NAME);
var rulesetHUDComponents = Skin.GetDrawableComponent(lookup); if (combo != null)
{
rulesetHUDComponents ??= new DefaultSkinComponentsContainer(container => combo.Anchor = Anchor.TopCentre;
{ combo.Origin = Anchor.Centre;
var combo = container.ChildrenOfType<LegacyManiaComboCounter>().FirstOrDefault(); combo.Y = this.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.ComboPosition)?.Value ?? 0;
}
if (combo != null) })
{ {
combo.Anchor = Anchor.TopCentre; new LegacyManiaComboCounter(),
combo.Origin = Anchor.Centre; };
combo.Y = this.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.ComboPosition)?.Value ?? 0;
}
})
{
new LegacyManiaComboCounter(),
};
return rulesetHUDComponents;
}
break;
case GameplaySkinComponentLookup<HitResult> resultComponent: case GameplaySkinComponentLookup<HitResult> resultComponent:
return getResult(resultComponent.Component); return getResult(resultComponent.Component);

View File

@ -45,6 +45,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
switch (lookup) switch (lookup)
{ {
case SkinComponentsContainerLookup containerLookup: case SkinComponentsContainerLookup containerLookup:
if (containerLookup.Target != SkinComponentsContainerLookup.TargetArea.MainHUDComponents)
return base.GetDrawableComponent(lookup);
// Only handle per ruleset defaults here. // Only handle per ruleset defaults here.
if (containerLookup.Ruleset == null) if (containerLookup.Ruleset == null)
return base.GetDrawableComponent(lookup); return base.GetDrawableComponent(lookup);
@ -53,34 +56,36 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d) if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
return d; return d;
// Our own ruleset components default. return new DefaultSkinComponentsContainer(container =>
switch (containerLookup.Target)
{ {
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: var keyCounter = container.OfType<LegacyKeyCounterDisplay>().FirstOrDefault();
return new DefaultSkinComponentsContainer(container =>
{
var keyCounter = container.OfType<LegacyKeyCounterDisplay>().FirstOrDefault();
if (keyCounter != null) if (keyCounter != null)
{ {
// set the anchor to top right so that it won't squash to the return button to the top // set the anchor to top right so that it won't squash to the return button to the top
keyCounter.Anchor = Anchor.CentreRight; keyCounter.Anchor = Anchor.CentreRight;
keyCounter.Origin = Anchor.CentreRight; keyCounter.Origin = Anchor.CentreRight;
keyCounter.X = 0; keyCounter.X = 0;
// 340px is the default height inherit from stable // 340px is the default height inherit from stable
keyCounter.Y = container.ToLocalSpace(new Vector2(0, container.ScreenSpaceDrawQuad.Centre.Y - 340f)).Y; keyCounter.Y = container.ToLocalSpace(new Vector2(0, container.ScreenSpaceDrawQuad.Centre.Y - 340f)).Y;
} }
})
{
Children = new Drawable[]
{
new LegacyComboCounter(),
new LegacyKeyCounterDisplay(),
}
};
}
return null; var combo = container.OfType<LegacyDefaultComboCounter>().FirstOrDefault();
if (combo != null)
{
combo.Anchor = Anchor.BottomLeft;
combo.Origin = Anchor.BottomLeft;
combo.Scale = new Vector2(1.28f);
}
})
{
Children = new Drawable[]
{
new LegacyDefaultComboCounter(),
new LegacyKeyCounterDisplay(),
}
};
case OsuSkinComponentLookup osuComponent: case OsuSkinComponentLookup osuComponent:
switch (osuComponent.Component) switch (osuComponent.Component)

View File

@ -443,7 +443,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("no combo in global target", () => !globalHUDTarget.Components.OfType<LegacyComboCounter>().Any()); AddAssert("no combo in global target", () => !globalHUDTarget.Components.OfType<LegacyComboCounter>().Any());
AddAssert("combo placed in ruleset target", () => rulesetHUDTarget.Components.OfType<LegacyComboCounter>().Count() == 1); AddAssert("combo placed in ruleset target", () => rulesetHUDTarget.Components.OfType<LegacyComboCounter>().Count() == 1);
AddStep("add combo to global target", () => globalHUDTarget.Add(new LegacyComboCounter AddStep("add combo to global target", () => globalHUDTarget.Add(new LegacyDefaultComboCounter
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -13,7 +13,6 @@ using osu.Framework.Audio.Sample;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using osu.Game.Audio; using osu.Game.Audio;
@ -24,6 +23,7 @@ using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Play.HUD.HitErrorMeters; using osu.Game.Screens.Play.HUD.HitErrorMeters;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Skinning namespace osu.Game.Skinning
@ -367,10 +367,19 @@ namespace osu.Game.Skinning
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: case SkinComponentsContainerLookup.TargetArea.MainHUDComponents:
if (containerLookup.Ruleset != null) if (containerLookup.Ruleset != null)
{ {
return new Container return new DefaultSkinComponentsContainer(container =>
{ {
RelativeSizeAxes = Axes.Both, var combo = container.OfType<LegacyDefaultComboCounter>().FirstOrDefault();
Child = new LegacyComboCounter(),
if (combo != null)
{
combo.Anchor = Anchor.BottomLeft;
combo.Origin = Anchor.BottomLeft;
combo.Scale = new Vector2(1.28f);
}
})
{
new LegacyDefaultComboCounter()
}; };
} }