2022-09-27 17:52:21 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2022-10-10 12:12:12 +08:00
using System ;
2023-12-30 10:20:51 +08:00
using System.Diagnostics ;
using System.Linq ;
2022-10-04 18:42:43 +08:00
using osu.Framework.Bindables ;
2022-09-27 17:52:21 +08:00
using osu.Framework.Graphics ;
2023-12-30 10:20:51 +08:00
using osu.Framework.Testing ;
2022-10-06 13:51:17 +08:00
using osu.Game.Beatmaps ;
using osu.Game.Rulesets.Mania.Beatmaps ;
2022-10-06 20:39:29 +08:00
using osu.Game.Rulesets.Scoring ;
2022-09-27 17:52:21 +08:00
using osu.Game.Skinning ;
2022-10-04 18:42:43 +08:00
using osuTK.Graphics ;
2022-09-27 17:52:21 +08:00
namespace osu.Game.Rulesets.Mania.Skinning.Argon
{
2023-12-30 10:20:51 +08:00
public class ManiaArgonSkinTransformer : ArgonSkinTransformer
2022-09-27 17:52:21 +08:00
{
2022-10-06 13:51:17 +08:00
private readonly ManiaBeatmap beatmap ;
public ManiaArgonSkinTransformer ( ISkin skin , IBeatmap beatmap )
2022-09-27 17:52:21 +08:00
: base ( skin )
{
2022-10-06 13:51:17 +08:00
this . beatmap = ( ManiaBeatmap ) beatmap ;
2022-09-27 17:52:21 +08:00
}
2022-11-09 15:04:56 +08:00
public override Drawable ? GetDrawableComponent ( ISkinComponentLookup lookup )
2022-09-27 17:52:21 +08:00
{
2022-11-09 13:11:41 +08:00
switch ( lookup )
2022-09-27 17:52:21 +08:00
{
2023-12-30 10:20:51 +08:00
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 ;
}
break ;
2022-11-09 15:04:56 +08:00
case GameplaySkinComponentLookup < HitResult > resultComponent :
2022-12-24 03:35:44 +08:00
// This should eventually be moved to a skin setting, when supported.
if ( Skin is ArgonProSkin & & resultComponent . Component > = HitResult . Great )
return Drawable . Empty ( ) ;
2022-10-06 20:39:29 +08:00
return new ArgonJudgementPiece ( resultComponent . Component ) ;
2022-11-09 15:04:56 +08:00
case ManiaSkinComponentLookup maniaComponent :
2022-10-04 15:17:38 +08:00
// TODO: Once everything is finalised, consider throwing UnsupportedSkinComponentException on missing entries.
2022-09-27 17:52:21 +08:00
switch ( maniaComponent . Component )
{
2022-10-06 17:12:55 +08:00
case ManiaSkinComponents . StageBackground :
return new ArgonStageBackground ( ) ;
case ManiaSkinComponents . ColumnBackground :
return new ArgonColumnBackground ( ) ;
2022-10-06 15:54:47 +08:00
case ManiaSkinComponents . HoldNoteBody :
return new ArgonHoldBodyPiece ( ) ;
case ManiaSkinComponents . HoldNoteTail :
return new ArgonHoldNoteTailPiece ( ) ;
2022-10-06 15:54:08 +08:00
case ManiaSkinComponents . HoldNoteHead :
2023-03-09 18:02:15 +08:00
return new ArgonHoldNoteHeadPiece ( ) ;
2022-10-06 15:54:08 +08:00
case ManiaSkinComponents . Note :
return new ArgonNotePiece ( ) ;
2022-09-27 18:48:27 +08:00
case ManiaSkinComponents . HitTarget :
return new ArgonHitTarget ( ) ;
2022-09-27 17:52:21 +08:00
case ManiaSkinComponents . KeyArea :
return new ArgonKeyArea ( ) ;
2022-10-06 19:51:28 +08:00
case ManiaSkinComponents . HitExplosion :
return new ArgonHitExplosion ( ) ;
2022-09-27 17:52:21 +08:00
}
break ;
}
2022-11-09 13:11:41 +08:00
return base . GetDrawableComponent ( lookup ) ;
2022-09-27 17:52:21 +08:00
}
2022-10-04 18:42:43 +08:00
2023-03-08 18:58:05 +08:00
private static readonly Color4 colour_special_column = new Color4 ( 169 , 106 , 255 , 255 ) ;
private const int total_colours = 6 ;
private static readonly Color4 colour_yellow = new Color4 ( 255 , 197 , 40 , 255 ) ;
private static readonly Color4 colour_orange = new Color4 ( 252 , 109 , 1 , 255 ) ;
private static readonly Color4 colour_pink = new Color4 ( 213 , 35 , 90 , 255 ) ;
private static readonly Color4 colour_purple = new Color4 ( 203 , 60 , 236 , 255 ) ;
private static readonly Color4 colour_cyan = new Color4 ( 72 , 198 , 255 , 255 ) ;
private static readonly Color4 colour_green = new Color4 ( 100 , 192 , 92 , 255 ) ;
2022-10-04 18:42:43 +08:00
public override IBindable < TValue > ? GetConfig < TLookup , TValue > ( TLookup lookup )
{
if ( lookup is ManiaSkinConfigurationLookup maniaLookup )
{
2023-03-09 17:25:30 +08:00
int columnIndex = maniaLookup . ColumnIndex ? ? 0 ;
var stage = beatmap . GetStageForColumnIndex ( columnIndex ) ;
2022-10-06 16:46:54 +08:00
2022-10-04 18:42:43 +08:00
switch ( maniaLookup . Lookup )
{
2022-10-07 17:44:29 +08:00
case LegacyManiaSkinConfigurationLookups . ColumnSpacing :
return SkinUtils . As < TValue > ( new Bindable < float > ( 2 ) ) ;
2022-10-06 17:03:48 +08:00
case LegacyManiaSkinConfigurationLookups . StagePaddingBottom :
case LegacyManiaSkinConfigurationLookups . StagePaddingTop :
return SkinUtils . As < TValue > ( new Bindable < float > ( 30 ) ) ;
2022-10-06 16:46:54 +08:00
case LegacyManiaSkinConfigurationLookups . ColumnWidth :
2023-11-02 18:40:20 +08:00
bool isSpecialColumn = stage . IsSpecialColumn ( columnIndex ) ;
2023-11-02 14:13:43 +08:00
2023-12-15 17:02:27 +08:00
float width = 60 * ( isSpecialColumn ? 2 : 1 ) ;
2023-11-02 14:13:43 +08:00
2023-11-02 18:40:20 +08:00
return SkinUtils . As < TValue > ( new Bindable < float > ( width ) ) ;
2022-10-06 16:46:54 +08:00
2022-10-04 18:42:43 +08:00
case LegacyManiaSkinConfigurationLookups . ColumnBackgroundColour :
2022-10-06 13:51:17 +08:00
2023-03-09 17:25:30 +08:00
var colour = getColourForLayout ( columnIndex , stage ) ;
2022-10-06 15:54:32 +08:00
2023-03-08 18:58:05 +08:00
return SkinUtils . As < TValue > ( new Bindable < Color4 > ( colour ) ) ;
}
}
2022-10-10 12:12:12 +08:00
2023-03-08 18:58:05 +08:00
return base . GetConfig < TLookup , TValue > ( lookup ) ;
}
2022-10-06 15:54:32 +08:00
2023-03-09 17:25:30 +08:00
private Color4 getColourForLayout ( int columnIndex , StageDefinition stage )
2023-03-08 18:58:05 +08:00
{
2023-03-09 17:25:30 +08:00
// Account for cases like dual-stage (assume that all stages have the same column count for now).
columnIndex % = stage . Columns ;
2022-10-06 15:54:32 +08:00
2023-03-08 18:58:05 +08:00
// For now, these are defined per column count as per https://user-images.githubusercontent.com/50823728/218038463-b450f46c-ef21-4551-b133-f866be59970c.png
// See https://github.com/ppy/osu/discussions/21996 for discussion.
switch ( stage . Columns )
{
case 1 :
return colour_yellow ;
2022-10-06 15:54:32 +08:00
2023-03-08 18:58:05 +08:00
case 2 :
2023-03-09 17:25:30 +08:00
switch ( columnIndex )
2023-03-08 18:58:05 +08:00
{
case 0 : return colour_green ;
2022-10-06 15:54:32 +08:00
2023-03-08 18:58:05 +08:00
case 1 : return colour_cyan ;
2022-10-06 15:54:32 +08:00
2023-03-08 18:58:05 +08:00
default : throw new ArgumentOutOfRangeException ( ) ;
}
2022-10-06 15:54:32 +08:00
2023-03-08 18:58:05 +08:00
case 3 :
2023-03-09 17:25:30 +08:00
switch ( columnIndex )
2023-03-08 18:58:05 +08:00
{
2023-06-06 15:42:20 +08:00
case 0 : return colour_green ;
2022-10-10 12:12:12 +08:00
2023-06-07 11:10:30 +08:00
case 1 : return colour_special_column ;
2022-10-04 18:42:43 +08:00
2023-06-06 15:42:20 +08:00
case 2 : return colour_cyan ;
2022-10-04 18:42:43 +08:00
2023-03-08 18:58:05 +08:00
default : throw new ArgumentOutOfRangeException ( ) ;
}
case 4 :
2023-03-09 17:25:30 +08:00
switch ( columnIndex )
2023-03-08 18:58:05 +08:00
{
case 0 : return colour_yellow ;
case 1 : return colour_orange ;
case 2 : return colour_pink ;
case 3 : return colour_purple ;
default : throw new ArgumentOutOfRangeException ( ) ;
}
case 5 :
2023-03-09 17:25:30 +08:00
switch ( columnIndex )
2023-03-08 18:58:05 +08:00
{
case 0 : return colour_pink ;
case 1 : return colour_orange ;
case 2 : return colour_yellow ;
case 3 : return colour_green ;
case 4 : return colour_cyan ;
default : throw new ArgumentOutOfRangeException ( ) ;
}
case 6 :
2023-03-09 17:25:30 +08:00
switch ( columnIndex )
2023-03-08 18:58:05 +08:00
{
case 0 : return colour_pink ;
case 1 : return colour_orange ;
2023-06-06 15:42:20 +08:00
case 2 : return colour_green ;
2023-03-08 18:58:05 +08:00
case 3 : return colour_cyan ;
2023-06-06 15:42:20 +08:00
case 4 : return colour_orange ;
2023-03-08 18:58:05 +08:00
case 5 : return colour_pink ;
default : throw new ArgumentOutOfRangeException ( ) ;
}
case 7 :
2023-03-09 17:25:30 +08:00
switch ( columnIndex )
2023-03-08 18:58:05 +08:00
{
case 0 : return colour_pink ;
2023-06-06 15:42:20 +08:00
case 1 : return colour_orange ;
2023-03-08 18:58:05 +08:00
case 2 : return colour_pink ;
case 3 : return colour_special_column ;
2023-06-06 15:42:20 +08:00
case 4 : return colour_pink ;
2023-03-08 18:58:05 +08:00
2023-06-06 15:42:20 +08:00
case 5 : return colour_orange ;
2023-03-08 18:58:05 +08:00
2023-06-06 15:42:20 +08:00
case 6 : return colour_pink ;
2023-03-08 18:58:05 +08:00
default : throw new ArgumentOutOfRangeException ( ) ;
}
case 8 :
2023-03-09 17:25:30 +08:00
switch ( columnIndex )
2023-03-08 18:58:05 +08:00
{
case 0 : return colour_purple ;
case 1 : return colour_pink ;
case 2 : return colour_orange ;
2023-06-06 15:42:20 +08:00
case 3 : return colour_green ;
2023-03-08 18:58:05 +08:00
2023-06-06 15:42:20 +08:00
case 4 : return colour_cyan ;
2023-03-08 18:58:05 +08:00
case 5 : return colour_orange ;
case 6 : return colour_pink ;
case 7 : return colour_purple ;
default : throw new ArgumentOutOfRangeException ( ) ;
}
case 9 :
2023-03-09 17:25:30 +08:00
switch ( columnIndex )
2023-03-08 18:58:05 +08:00
{
case 0 : return colour_purple ;
case 1 : return colour_pink ;
case 2 : return colour_orange ;
case 3 : return colour_yellow ;
case 4 : return colour_special_column ;
case 5 : return colour_yellow ;
case 6 : return colour_orange ;
case 7 : return colour_pink ;
case 8 : return colour_purple ;
default : throw new ArgumentOutOfRangeException ( ) ;
}
case 10 :
2023-03-09 17:25:30 +08:00
switch ( columnIndex )
2023-03-08 18:58:05 +08:00
{
case 0 : return colour_purple ;
case 1 : return colour_pink ;
case 2 : return colour_orange ;
case 3 : return colour_yellow ;
2023-06-06 15:42:20 +08:00
case 4 : return colour_green ;
2023-03-08 18:58:05 +08:00
2023-06-06 15:42:20 +08:00
case 5 : return colour_cyan ;
2023-03-08 18:58:05 +08:00
case 6 : return colour_yellow ;
case 7 : return colour_orange ;
case 8 : return colour_pink ;
case 9 : return colour_purple ;
default : throw new ArgumentOutOfRangeException ( ) ;
}
2022-10-04 18:42:43 +08:00
}
2023-03-08 18:58:05 +08:00
// fallback for unhandled scenarios
2023-03-09 17:25:30 +08:00
if ( stage . IsSpecialColumn ( columnIndex ) )
2023-03-08 18:58:05 +08:00
return colour_special_column ;
2023-03-09 17:25:30 +08:00
switch ( columnIndex % total_colours )
2023-03-08 18:58:05 +08:00
{
2023-03-21 01:16:33 +08:00
case 0 : return colour_yellow ;
2023-03-08 18:58:05 +08:00
2023-03-21 01:16:33 +08:00
case 1 : return colour_orange ;
2023-03-08 18:58:05 +08:00
2023-03-21 01:16:33 +08:00
case 2 : return colour_pink ;
2023-03-08 18:58:05 +08:00
2023-03-21 01:16:33 +08:00
case 3 : return colour_purple ;
2023-03-08 18:58:05 +08:00
2023-03-21 01:16:33 +08:00
case 4 : return colour_cyan ;
2023-03-08 18:58:05 +08:00
2023-03-21 01:16:33 +08:00
case 5 : return colour_green ;
2023-03-08 18:58:05 +08:00
default : throw new ArgumentOutOfRangeException ( ) ;
}
2022-10-04 18:42:43 +08:00
}
2022-09-27 17:52:21 +08:00
}
}