Skip to content

Commit

Permalink
Update in line with new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Aug 8, 2024
1 parent e645651 commit 4bb7b73
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public CatchLegacySkinTransformer(ISkin skin)

// Modifications for global components.
if (containerLookup.Ruleset == null)
return base.GetDrawableComponent(lookup) as Container;
return base.GetDrawableComponent(lookup);

// Skin has configuration.
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
Expand Down
52 changes: 25 additions & 27 deletions osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
Expand All @@ -15,7 +14,7 @@

namespace osu.Game.Rulesets.Mania.Skinning.Argon
{
public class ManiaArgonSkinTransformer : ArgonSkinTransformer
public class ManiaArgonSkinTransformer : SkinTransformer
{
private readonly ManiaBeatmap beatmap;

Expand All @@ -30,32 +29,31 @@ public ManiaArgonSkinTransformer(ISkin skin, IBeatmap beatmap)
switch (lookup)
{
case SkinComponentsContainerLookup containerLookup:
switch (containerLookup.Target)
{
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents when containerLookup.Ruleset != null:
Debug.Assert(containerLookup.Ruleset.ShortName == ManiaRuleset.SHORT_NAME);

var rulesetHUDComponents = Skin.GetDrawableComponent(lookup);

rulesetHUDComponents ??= new DefaultSkinComponentsContainer(container =>
{
var combo = container.ChildrenOfType<ArgonManiaComboCounter>().FirstOrDefault();
if (combo != null)
{
combo.Anchor = Anchor.TopCentre;
combo.Origin = Anchor.Centre;
combo.Y = 200;
}
})
{
new ArgonManiaComboCounter(),
};

return rulesetHUDComponents;
}
if (containerLookup.Target != SkinComponentsContainerLookup.TargetArea.MainHUDComponents)
return base.GetDrawableComponent(lookup);

break;
// 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 =>
{
var combo = container.ChildrenOfType<ArgonManiaComboCounter>().FirstOrDefault();
if (combo != null)
{
combo.Anchor = Anchor.TopCentre;
combo.Origin = Anchor.Centre;
combo.Y = 200;
}
})
{
new ArgonManiaComboCounter(),
};

case GameplaySkinComponentLookup<HitResult> resultComponent:
// This should eventually be moved to a skin setting, when supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.EnumExtensions;
using osu.Framework.Graphics;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning;
Expand Down Expand Up @@ -49,7 +48,7 @@ protected override void LoadComplete()
private void updateAnchor()
{
// 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 |= direction.Value == ScrollingDirection.Up ? Anchor.y2 : Anchor.y0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
Expand Down Expand Up @@ -82,32 +81,31 @@ public override Drawable GetDrawableComponent(ISkinComponentLookup lookup)
switch (lookup)
{
case SkinComponentsContainerLookup containerLookup:
switch (containerLookup.Target)
{
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents when containerLookup.Ruleset != null:
Debug.Assert(containerLookup.Ruleset.ShortName == ManiaRuleset.SHORT_NAME);

var rulesetHUDComponents = Skin.GetDrawableComponent(lookup);

rulesetHUDComponents ??= new DefaultSkinComponentsContainer(container =>
{
var combo = container.ChildrenOfType<LegacyManiaComboCounter>().FirstOrDefault();
if (combo != null)
{
combo.Anchor = Anchor.TopCentre;
combo.Origin = Anchor.Centre;
combo.Y = this.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.ComboPosition)?.Value ?? 0;
}
})
{
new LegacyManiaComboCounter(),
};

return rulesetHUDComponents;
}
if (containerLookup.Target != SkinComponentsContainerLookup.TargetArea.MainHUDComponents)
return base.GetDrawableComponent(lookup);

// Modifications for global components.
if (containerLookup.Ruleset == null)
return base.GetDrawableComponent(lookup);

break;
// Skin has configuration.
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
return d;

return new DefaultSkinComponentsContainer(container =>
{
var combo = container.ChildrenOfType<LegacyManiaComboCounter>().FirstOrDefault();
if (combo != null)
{
combo.Anchor = Anchor.TopCentre;
combo.Origin = Anchor.Centre;
combo.Y = this.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.ComboPosition)?.Value ?? 0;
}
})
{
new LegacyManiaComboCounter(),
};

case GameplaySkinComponentLookup<HitResult> resultComponent:
return getResult(resultComponent.Component);
Expand Down
59 changes: 32 additions & 27 deletions osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public OsuLegacySkinTransformer(ISkin skin)
switch (lookup)
{
case SkinComponentsContainerLookup containerLookup:
if (containerLookup.Target != SkinComponentsContainerLookup.TargetArea.MainHUDComponents)
return base.GetDrawableComponent(lookup);

// Only handle per ruleset defaults here.
if (containerLookup.Ruleset == null)
return base.GetDrawableComponent(lookup);
Expand All @@ -53,34 +56,36 @@ public OsuLegacySkinTransformer(ISkin skin)
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
return d;

// Our own ruleset components default.
switch (containerLookup.Target)
return new DefaultSkinComponentsContainer(container =>
{
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents:
return new DefaultSkinComponentsContainer(container =>
{
var keyCounter = container.OfType<LegacyKeyCounterDisplay>().FirstOrDefault();
if (keyCounter != null)
{
// set the anchor to top right so that it won't squash to the return button to the top
keyCounter.Anchor = Anchor.CentreRight;
keyCounter.Origin = Anchor.CentreRight;
keyCounter.X = 0;
// 340px is the default height inherit from stable
keyCounter.Y = container.ToLocalSpace(new Vector2(0, container.ScreenSpaceDrawQuad.Centre.Y - 340f)).Y;
}
})
{
Children = new Drawable[]
{
new LegacyComboCounter(),
new LegacyKeyCounterDisplay(),
}
};
}

return null;
var keyCounter = container.OfType<LegacyKeyCounterDisplay>().FirstOrDefault();
if (keyCounter != null)
{
// set the anchor to top right so that it won't squash to the return button to the top
keyCounter.Anchor = Anchor.CentreRight;
keyCounter.Origin = Anchor.CentreRight;
keyCounter.X = 0;
// 340px is the default height inherit from stable
keyCounter.Y = container.ToLocalSpace(new Vector2(0, container.ScreenSpaceDrawQuad.Centre.Y - 340f)).Y;
}
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:
switch (osuComponent.Component)
Expand Down
17 changes: 13 additions & 4 deletions osu.Game/Skinning/LegacySkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
using osu.Game.Audio;
Expand All @@ -24,6 +23,7 @@
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Play.HUD.HitErrorMeters;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Skinning
Expand Down Expand Up @@ -367,10 +367,19 @@ protected override void ParseConfigurationStream(Stream stream)
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents:
if (containerLookup.Ruleset != null)
{
return new Container
return new DefaultSkinComponentsContainer(container =>
{
RelativeSizeAxes = Axes.Both,
Child = new LegacyComboCounter(),
var combo = container.OfType<LegacyDefaultComboCounter>().FirstOrDefault();
if (combo != null)
{
combo.Anchor = Anchor.BottomLeft;
combo.Origin = Anchor.BottomLeft;
combo.Scale = new Vector2(1.28f);
}
})
{
new LegacyDefaultComboCounter()
};
}

Expand Down

0 comments on commit 4bb7b73

Please sign in to comment.