Skip to content

Commit

Permalink
Merge pull request #1286 from andy840119/refactor-gameplay-setting-ov…
Browse files Browse the repository at this point in the history
…erlay

Refactor the gameplay setting overlay.
  • Loading branch information
andy840119 authored Apr 24, 2022
2 parents 2b7b6f1 + 158d484 commit e6eb7b8
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 71 deletions.
42 changes: 24 additions & 18 deletions osu.Game.Rulesets.Karaoke/UI/HUD/GeneralSettingOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Rulesets.Karaoke.Beatmaps;
using osu.Game.Rulesets.Karaoke.Configuration;
using osu.Game.Rulesets.Karaoke.UI.PlayerSettings;
Expand All @@ -20,33 +22,37 @@ public class GeneralSettingOverlay : SettingOverlay, IKeyBindingHandler<KaraokeA
private readonly BindableInt bindableVocalPitch = new();
private readonly BindableInt bindableSaitenPitch = new();

protected override OverlayColourScheme OverlayColourScheme => OverlayColourScheme.Blue;

public GeneralSettingOverlay()
{
// Add common group
Add(new VisualSettings
Children = new Drawable[]
{
Expanded =
new VisualSettings
{
Value = false
}
});
Add(new PitchSettings
{
Expanded =
Expanded =
{
Value = false
}
},
new PitchSettings
{
Value = false
}
});
Add(new RubyRomajiSettings
{
Expanded =
Expanded =
{
Value = false
}
},
new RubyRomajiSettings
{
Value = false
Expanded =
{
Value = false
}
}
});
};
}

public override SettingButton CreateToggleButton() => new()
protected override SettingButton CreateButton() => new()
{
Name = "Toggle setting button",
Text = "Settings",
Expand Down
20 changes: 13 additions & 7 deletions osu.Game.Rulesets.Karaoke/UI/HUD/PracticeOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Game.Overlays;
using osu.Game.Rulesets.Karaoke.UI.PlayerSettings;

namespace osu.Game.Rulesets.Karaoke.UI.HUD
{
public class PracticeOverlay : SettingOverlay
{
protected override OverlayColourScheme OverlayColourScheme => OverlayColourScheme.Purple;

public PracticeOverlay()
{
Add(new PracticeSettings
Children = new[]
{
Expanded =
new PracticeSettings
{
Value = true
},
Width = 400
});
Expanded =
{
Value = true
},
Width = 400
}
};
}

public override SettingButton CreateToggleButton() => new()
protected override SettingButton CreateButton() => new()
{
Name = "Toggle Practice",
Text = "Practice",
Expand Down
8 changes: 0 additions & 8 deletions osu.Game.Rulesets.Karaoke/UI/HUD/SettingButton.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;

namespace osu.Game.Rulesets.Karaoke.UI.HUD
Expand All @@ -18,11 +16,5 @@ public SettingButton()
Width = 90;
Height = 45;
}

[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = colours.Blue;
}
}
}
20 changes: 16 additions & 4 deletions osu.Game.Rulesets.Karaoke/UI/HUD/SettingOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using osu.Game.Graphics.Containers;
using osu.Game.Overlays;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Karaoke.UI.HUD
{
Expand All @@ -29,20 +28,25 @@ public abstract class SettingOverlay : OsuFocusedOverlayContainer

private readonly FillFlowContainer<Drawable> content;

public abstract SettingButton CreateToggleButton();
protected abstract OverlayColourScheme OverlayColourScheme { get; }

[Cached]
private readonly OverlayColourProvider colourProvider;

protected SettingOverlay()
{
RelativeSizeAxes = Axes.Y;

colourProvider = new OverlayColourProvider(OverlayColourScheme);

InternalChildren = new Drawable[]
{
new Box
{
Name = "Background",
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.6f
Colour = colourProvider.Background4,
Alpha = 1,
},
new Container
{
Expand Down Expand Up @@ -136,6 +140,14 @@ private float getHideXPosition() =>
OverlayDirection.Right => DrawWidth,
_ => throw new ArgumentOutOfRangeException()
};

public SettingButton CreateToggleButton()
=> CreateButton().With(x =>
{
x.BackgroundColour = colourProvider.Colour1;
});

protected abstract SettingButton CreateButton();
}

public enum OverlayDirection
Expand Down
53 changes: 22 additions & 31 deletions osu.Game.Rulesets.Karaoke/UI/PlayerSettings/LyricsPreview.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// 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;
Expand All @@ -25,13 +25,13 @@ public class LyricsPreview : CompositeDrawable
private readonly Bindable<double> bindablePreemptTime = new();
private readonly Bindable<Lyric[]> singingLyrics = new();

private readonly FillFlowContainer<ClickableLyric> lyricTable;

[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; }

public LyricsPreview()
{
FillFlowContainer<ClickableLyric> lyricTable;

InternalChild = new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
Expand All @@ -40,6 +40,7 @@ public LyricsPreview()
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Spacing = new Vector2(15)
}
};

Expand Down Expand Up @@ -77,12 +78,6 @@ private void triggerLyric(Lyric lyric)
singingLyrics.Value = new[] { lyric };
}

public Vector2 Spacing
{
get => lyricTable.Spacing;
set => lyricTable.Spacing = value;
}

[BackgroundDependencyLoader]
private void load(KaraokeRulesetConfigManager config, KaraokeSessionStatics session)
{
Expand Down Expand Up @@ -111,30 +106,28 @@ public ClickableLyric(Lyric lyric)
{
background = new Box
{
RelativeSizeAxes = Axes.Both
RelativeSizeAxes = Axes.Both,
Alpha = 0,
},
icon = new SpriteIcon
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(15),
Icon = FontAwesome.Solid.Play,
Margin = new MarginPadding { Left = 5 },
Alpha = 0,
},
previewLyric = new PreviewLyricSpriteText(lyric)
{
Font = new FontUsage(size: 25),
RubyFont = new FontUsage(size: 10),
RomajiFont = new FontUsage(size: 10),
Margin = new MarginPadding { Left = 25 }
},
icon = createIcon(),
previewLyric = createLyric(lyric),
};
}

private PreviewLyricSpriteText createLyric(Lyric lyric) => new(lyric)
{
Font = new FontUsage(size: 25),
RubyFont = new FontUsage(size: 10),
RomajiFont = new FontUsage(size: 10),
Margin = new MarginPadding { Left = 25 }
};

private Drawable createIcon() => new SpriteIcon
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(15),
Icon = FontAwesome.Solid.Play,
Margin = new MarginPadding { Left = 5 }
};

private bool selected;

public bool Selected
Expand Down Expand Up @@ -162,9 +155,7 @@ private void load(OsuColour colours)

previewLyric.Colour = idolTextColour;
background.Colour = colours.Blue;
background.Alpha = 0;
icon.Colour = hoverTextColour;
icon.Alpha = 0;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Karaoke.Configuration;
using osu.Game.Screens.Play.PlayerSettings;
using osuTK;

namespace osu.Game.Rulesets.Karaoke.UI.PlayerSettings
{
Expand All @@ -34,7 +33,6 @@ public PracticeSettings()
{
Height = 580,
RelativeSizeAxes = Axes.X,
Spacing = new Vector2(15),
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="ILRepack.Lib.MSBuild" Version="2.1.18" />
<PackageReference Include="LanguageDetection.karaoke-dev" Version="1.3.3-alpha" />
<PackageReference Include="Octokit" Version="0.50.0" />
<PackageReference Include="osu.Framework.KaraokeFont" Version="2022.423.1" />
<PackageReference Include="osu.Framework.KaraokeFont" Version="2022.424.0" />
<PackageReference Include="osu.Framework.Microphone" Version="2022.327.0" />
<PackageReference Include="ppy.osu.Game" Version="2022.418.0" />
<PackageReference Include="LyricMaker" Version="1.1.1" />
Expand Down

0 comments on commit e6eb7b8

Please sign in to comment.