Skip to content

Commit

Permalink
Merge pull request #587 from andy840119/sync-skin-component
Browse files Browse the repository at this point in the history
Sync skin component
  • Loading branch information
andy840119 authored May 1, 2021
2 parents e14c9f5 + 69759de commit 9bc6d40
Show file tree
Hide file tree
Showing 24 changed files with 117 additions and 46 deletions.
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Karaoke.Beatmaps;
using osu.Game.Rulesets.Karaoke.Edit.Layout;
using osu.Game.Rulesets.Karaoke.Skinning;
using osu.Game.Rulesets.Karaoke.Skinning.Legacy;
using osu.Game.Rulesets.Karaoke.Tests.Beatmaps;
using osu.Game.Screens.Edit;
using osu.Game.Skinning;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using osu.Game.Rulesets.Karaoke.Edit.Components.Cursor;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Skinning;
using osu.Game.Rulesets.Karaoke.Skinning.Legacy;
using osu.Game.Skinning;
using osu.Game.Tests.Visual;

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Karaoke.Beatmaps;
using osu.Game.Rulesets.Karaoke.Edit.Style;
using osu.Game.Rulesets.Karaoke.Skinning;
using osu.Game.Rulesets.Karaoke.Skinning.Legacy;
using osu.Game.Rulesets.Karaoke.Tests.Beatmaps;
using osu.Game.Screens.Edit;
using osu.Game.Skinning;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Rulesets.Karaoke.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Karaoke.Skinning.Default;

namespace osu.Game.Rulesets.Karaoke.Edit.Blueprints.Notes.Components
{
Expand Down
24 changes: 24 additions & 0 deletions osu.Game.Rulesets.Karaoke/Edit/Lyrics/KaraokeLyricEditorSkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using osu.Framework.Bindables;
using osu.Game.Rulesets.Karaoke.Skinning;
using osu.Game.Skinning;

namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics
{
Expand All @@ -14,6 +16,9 @@ public class KaraokeLyricEditorSkin : KaraokeInternalSkin
public const int MIN_FONT_SIZE = 10;
public const int MAX_FONT_SIZE = 45;

protected readonly Bindable<float> BindableColumnHeight = new Bindable<float>(12);
protected readonly Bindable<float> BindableJudgementAresPrecentage = new Bindable<float>(0.05f);

protected override string ResourceName => @"osu.Game.Rulesets.Karaoke.Resources.Skin.editor.skin";

public KaraokeLyricEditorSkin()
Expand All @@ -35,5 +40,24 @@ public float FontSize
BindableFont.TriggerChange();
}
}

public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
{
if (lookup is KaraokeSkinConfigurationLookup skinConfigurationLookup)
{
switch (skinConfigurationLookup.Lookup)
{
// should use customize height for note playfield in lyric editor.
case LegacyKaraokeSkinConfigurationLookups.ColumnHeight:
return SkinUtils.As<TValue>(BindableColumnHeight);

// not have note playfield judgement spacing in lyric editor.
case LegacyKaraokeSkinConfigurationLookups.JudgementAresPrecentage:
return SkinUtils.As<TValue>(BindableJudgementAresPrecentage);
}
}

return base.GetConfig<TLookup, TValue>(lookup);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Karaoke.Beatmaps;
using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas;
using osu.Game.Rulesets.Karaoke.Graphics.UserInterface;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Objects.Drawables.Pieces;
using osu.Game.Screens.Edit;

namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.LyricRows.Infos.SubInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private class LocalScrollingInfo : IScrollingInfo
{
public IBindable<ScrollingDirection> Direction { get; } = new Bindable<ScrollingDirection>(ScrollingDirection.Left);

public IBindable<double> TimeRange { get; } = new BindableDouble(1500);
public IBindable<double> TimeRange { get; } = new BindableDouble(5000);

public IScrollAlgorithm Algorithm { get; set; } = new SequentialScrollAlgorithm(new List<MultiplierControlPoint>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using osu.Game.Rulesets.Karaoke.Graphics.Sprites;
using osuTK;

namespace osu.Game.Rulesets.Karaoke.Objects.Drawables.Pieces
namespace osu.Game.Rulesets.Karaoke.Graphics.UserInterface
{
public class SingerDisplay : Container, IHasCurrentValue<IReadOnlyList<Singer>>
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/KaraokeRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
using osu.Game.Rulesets.Karaoke.Mods;
using osu.Game.Rulesets.Karaoke.Replays;
using osu.Game.Rulesets.Karaoke.Scoring;
using osu.Game.Rulesets.Karaoke.Skinning;
using osu.Game.Rulesets.Karaoke.Skinning.Legacy;
using osu.Game.Rulesets.Karaoke.Statistics;
using osu.Game.Rulesets.Karaoke.UI;
using osu.Game.Rulesets.Mods;
Expand Down
8 changes: 7 additions & 1 deletion osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
using osu.Framework.Input.Bindings;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Karaoke.Judgements;
using osu.Game.Rulesets.Karaoke.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Karaoke.Skinning;
using osu.Game.Rulesets.Karaoke.Skinning.Default;
using osu.Game.Rulesets.Karaoke.Skinning.Metadatas.Notes;
using osu.Game.Rulesets.Karaoke.UI.Components;
using osu.Game.Rulesets.Scoring;
Expand Down Expand Up @@ -117,6 +117,12 @@ protected override void ApplySkin(ISkinSource skin, bool allowFallback)
if (HitObject == null)
return;

var columns = 9; // todo : get real number
var column = 0; // todo : get real number
var columnHeight = skin.GetConfig<KaraokeSkinConfigurationLookup, float>(new KaraokeSkinConfigurationLookup(columns, LegacyKaraokeSkinConfigurationLookups.ColumnHeight, column))?.Value;
if (columnHeight != null)
Height = columnHeight.Value; // todo : might have a better way to assign height.

var noteSkin = skin.GetConfig<KaraokeSkinLookup, NoteSkin>(new KaraokeSkinLookup(KaraokeSkinConfiguration.NoteStyle, HitObject.ParentLyric?.Singers))?.Value;
if (noteSkin == null)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Layout;
using osu.Game.Rulesets.Karaoke.Skinning;
using osu.Game.Rulesets.Karaoke.Objects.Drawables;
using osu.Game.Rulesets.Karaoke.Skinning.Metadatas.Notes;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Skinning;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Karaoke.Objects.Drawables.Pieces
namespace osu.Game.Rulesets.Karaoke.Skinning.Default
{
public class DefaultBodyPiece : Container
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Skinning/KaraokeInternalSkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected KaraokeInternalSkin()

public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null;

public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
public virtual IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
{
if (!(lookup is KaraokeSkinLookup skinLookup))
throw new NotSupportedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

namespace osu.Game.Rulesets.Karaoke.Skinning
{
public class LegacyKaraokeSkinConfigurationLookup
public class KaraokeSkinConfigurationLookup
{
public readonly int Columns;
public readonly LegacyKaraokeSkinConfigurationLookups Lookup;
public readonly int? TargetColumn;

public LegacyKaraokeSkinConfigurationLookup(int columns, LegacyKaraokeSkinConfigurationLookups lookup, int? targetColumn = null)
public KaraokeSkinConfigurationLookup(int columns, LegacyKaraokeSkinConfigurationLookups lookup, int? targetColumn = null)
{
Columns = columns;
Lookup = lookup;
Expand All @@ -29,6 +29,7 @@ public enum LegacyKaraokeSkinConfigurationLookups
JudgementLineHeadImage,
JudgementLineTailImage,
JudgementLineBodyImage,
JudgementAresPrecentage,
ShowJudgementLine,
NoteHeadImage,
NoteTailImage,
Expand Down
15 changes: 10 additions & 5 deletions osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkinLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ namespace osu.Game.Rulesets.Karaoke.Skinning
{
public readonly struct KaraokeSkinLookup
{
/// <summary>
/// Parts wants to be searched.
/// </summary>
public KaraokeSkinConfiguration Config { get; }

/// <summary>
/// Lookup index
/// </summary>
public int Lookup { get; }

/// <summary>
/// Ctor for <see cref="KaraokeSkinConfiguration.LyricStyle"/> and <see cref="KaraokeSkinConfiguration.NoteStyle"/>
/// </summary>
Expand All @@ -24,11 +34,6 @@ public KaraokeSkinLookup(KaraokeSkinConfiguration config, int lookup)
{
Config = config;
Lookup = lookup;
Editor = false;
}

public KaraokeSkinConfiguration Config { get; }
public int Lookup { get; }
public bool Editor { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using osu.Game.Rulesets.Karaoke.Skinning.Metadatas.Notes;
using osu.Game.Skinning;

namespace osu.Game.Rulesets.Karaoke.Skinning
namespace osu.Game.Rulesets.Karaoke.Skinning.Legacy
{
public class KaraokeLegacySkinTransformer : LegacySkinTransformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Karaoke.Skinning
namespace osu.Game.Rulesets.Karaoke.Skinning.Legacy
{
public class LegacyColumnBackground : LegacyKaraokeColumnElement
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using osu.Game.Skinning;
using osuTK;

namespace osu.Game.Rulesets.Karaoke.Skinning
namespace osu.Game.Rulesets.Karaoke.Skinning.Legacy
{
public class LegacyHitExplosion : LegacyKaraokeColumnElement
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using osu.Game.Skinning;
using osuTK;

namespace osu.Game.Rulesets.Karaoke.Skinning
namespace osu.Game.Rulesets.Karaoke.Skinning.Legacy
{
public class LegacyJudgementLine : LegacyKaraokeElement
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using osu.Game.Rulesets.Karaoke.UI.Scrolling;
using osu.Game.Skinning;

namespace osu.Game.Rulesets.Karaoke.Skinning
namespace osu.Game.Rulesets.Karaoke.Skinning.Legacy
{
public class LegacyKaraokeColumnElement : LegacyKaraokeElement
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using osu.Game.Rulesets.Karaoke.UI;
using osu.Game.Skinning;

namespace osu.Game.Rulesets.Karaoke.Skinning
namespace osu.Game.Rulesets.Karaoke.Skinning.Legacy
{
/// <summary>
/// A karaoke legacy skin element.
Expand All @@ -26,7 +26,7 @@ public class LegacyKaraokeElement : CompositeDrawable
/// <param name="lookup">The value to retrieve.</param>
/// <param name="index">If not null, denotes the index of the column to which the entry applies.</param>
protected virtual IBindable<T> GetKaraokeSkinConfig<T>(ISkin skin, LegacyKaraokeSkinConfigurationLookups lookup, int? index = null)
=> skin.GetConfig<LegacyKaraokeSkinConfigurationLookup, T>(
new LegacyKaraokeSkinConfigurationLookup(Playfield?.NotePlayfield.Columns ?? 4, lookup, index));
=> skin.GetConfig<KaraokeSkinConfigurationLookup, T>(
new KaraokeSkinConfigurationLookup(Playfield?.NotePlayfield.Columns ?? 4, lookup, index));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Karaoke.Skinning
namespace osu.Game.Rulesets.Karaoke.Skinning.Legacy
{
public class LegacyNotePiece : LegacyKaraokeColumnElement
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using osu.Game.Skinning;
using osuTK;

namespace osu.Game.Rulesets.Karaoke.Skinning
namespace osu.Game.Rulesets.Karaoke.Skinning.Legacy
{
public class LegacyStageBackground : LegacyKaraokeElement
{
Expand Down
5 changes: 2 additions & 3 deletions osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,13 @@ public NotePlayfield(int columns)
AddInternal(saitenStatus = new SaitenStatus(SaitenStatusMode.NotInitialized));
}

protected override void OnDirectionChanged(KaraokeScrollingDirection direction)
protected override void OnDirectionChanged(KaraokeScrollingDirection direction, float judgementAreaPercentage)
{
base.OnDirectionChanged(direction);
base.OnDirectionChanged(direction, judgementAreaPercentage);

bool left = direction == KaraokeScrollingDirection.Left;

//TODO : will apply in skin
var judgementAreaPercentage = 0.4f;
var judgementPadding = 10;

judgementArea.Size = new Vector2(judgementAreaPercentage, 1);
Expand Down
Loading

0 comments on commit 9bc6d40

Please sign in to comment.