mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 03:13:22 +08:00
Migrate legacy health bar display to per-ruleset target
This commit is contained in:
parent
f1b5686904
commit
76f79ce083
@ -376,7 +376,8 @@ namespace osu.Game.Skinning
|
||||
}
|
||||
})
|
||||
{
|
||||
new LegacyDefaultComboCounter()
|
||||
new LegacyDefaultComboCounter(),
|
||||
new LegacyHealthDisplay(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -415,7 +416,6 @@ namespace osu.Game.Skinning
|
||||
new LegacyScoreCounter(),
|
||||
new LegacyAccuracyCounter(),
|
||||
new LegacySongProgress(),
|
||||
new LegacyHealthDisplay(),
|
||||
new BarHitErrorMeter(),
|
||||
}
|
||||
};
|
||||
|
@ -23,6 +23,7 @@ using osu.Game.Database;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
@ -317,6 +318,57 @@ namespace osu.Game.Skinning
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
// Legacy health bar is moved from the global HUD components target into per-ruleset.
|
||||
// On osu!mania, the health bar is moved from the HUD to Playfield target for stage-based positioning.
|
||||
if (resources == null)
|
||||
break;
|
||||
|
||||
var hudLayout = layoutInfos.GetValueOrDefault(GlobalSkinnableContainers.MainHUDComponents);
|
||||
var playfieldLayout = layoutInfos.GetValueOrDefault(GlobalSkinnableContainers.Playfield);
|
||||
|
||||
if (hudLayout == null || !hudLayout.TryGetDrawableInfo(null, out var globalHUDComponents))
|
||||
globalHUDComponents = Array.Empty<SerialisedDrawableInfo>();
|
||||
|
||||
var legacyHealthBars = globalHUDComponents.Where(h => h.Type.Name == nameof(LegacyHealthDisplay)).ToArray();
|
||||
hudLayout?.Update(null, globalHUDComponents.Except(legacyHealthBars).ToArray());
|
||||
|
||||
resources.RealmAccess.Run(r =>
|
||||
{
|
||||
foreach (var ruleset in r.All<RulesetInfo>())
|
||||
{
|
||||
if (ruleset.ShortName == @"mania")
|
||||
{
|
||||
// should avoid adding legacy health bar to non-legacy skins (unless explicitly added by user).
|
||||
if (!legacyHealthBars.Any())
|
||||
break;
|
||||
|
||||
var legacyManiaHealthDisplay = new LegacyHealthDisplay
|
||||
{
|
||||
Rotation = -90f,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.TopLeft,
|
||||
X = 1,
|
||||
Scale = new Vector2(0.7f),
|
||||
}.CreateSerialisedInfo();
|
||||
|
||||
playfieldLayout?.Update(ruleset, playfieldLayout.TryGetDrawableInfo(ruleset, out var maniaPlayfieldComponents)
|
||||
? maniaPlayfieldComponents.Append(legacyManiaHealthDisplay).ToArray()
|
||||
: new[] { legacyManiaHealthDisplay });
|
||||
}
|
||||
else
|
||||
{
|
||||
hudLayout?.Update(ruleset, hudLayout.TryGetDrawableInfo(ruleset, out var rulesetHUDComponents)
|
||||
? rulesetHUDComponents.Concat(legacyHealthBars).ToArray()
|
||||
: legacyHealthBars);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,10 @@ namespace osu.Game.Skinning
|
||||
/// <list type="bullet">
|
||||
/// <item><description>0: Initial version of all skin layouts.</description></item>
|
||||
/// <item><description>1: Moves existing combo counters from global to per-ruleset HUD targets.</description></item>
|
||||
/// <item><description>2: Moves existing legacy health bars from global to per-ruleset HUD targets, and to playfield target on mania.</description></item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public const int LATEST_VERSION = 1;
|
||||
public const int LATEST_VERSION = 2;
|
||||
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
public int Version = LATEST_VERSION;
|
||||
|
Loading…
Reference in New Issue
Block a user