-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1965 from andy840119/fix-cannot-entry-to-the-game…
…play-if-use-legacy-skin Fix cannot entry to the gameplay if use legacy skin.
- Loading branch information
Showing
3 changed files
with
60 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Linq; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.UI.HUD; | ||
using osu.Game.Skinning; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Skinning.Default | ||
|
@@ -19,5 +23,50 @@ public KaraokeDefaultSkinTransformer(ISkin skin, IBeatmap beatmap) | |
|
||
public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) | ||
=> karaokeSkin.GetConfig<TLookup, TValue>(lookup); | ||
|
||
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup) | ||
{ | ||
switch (lookup) | ||
{ | ||
case SkinComponentsContainerLookup containerLookup: | ||
// Only handle ruleset level defaults for now. | ||
if (containerLookup.Ruleset == null) | ||
return base.GetDrawableComponent(lookup); | ||
|
||
switch (containerLookup.Target) | ||
{ | ||
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: | ||
// see the fall-back strategy in the SkinManager.AllSources. | ||
// will receive the: | ||
// 1. Legacy beatmap skin. | ||
// 2. default skin(e.g. argon skin) -> container will not be null only if skin is edited. | ||
// 3. triangle skin | ||
|
||
// component will not be null only if skin is edited. | ||
var component = base.GetDrawableComponent(lookup) as Container; | ||
|
||
// todo: technically can return non-null container if current skin is triangle skin. | ||
// but have no idea why still not showing the setting button. | ||
if (component != null && !component.Children.OfType<SettingButtonsDisplay>().Any()) | ||
{ | ||
// should add the setting button if not in the ruleset hud. | ||
component.Add(new SettingButtonsDisplay | ||
{ | ||
Anchor = Anchor.CentreRight, | ||
Origin = Anchor.CentreRight, | ||
}); | ||
} | ||
|
||
return component; | ||
|
||
case SkinComponentsContainerLookup.TargetArea.SongSelect: | ||
default: | ||
return base.GetDrawableComponent(lookup); | ||
} | ||
|
||
default: | ||
return base.GetDrawableComponent(lookup); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters