-
Notifications
You must be signed in to change notification settings - Fork 15
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 #1808 from andy840119/make-auto-genreate-section-m…
…ore-generic Make auto-generate section more generic
- Loading branch information
Showing
14 changed files
with
249 additions
and
244 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
osu.Game.Rulesets.Karaoke/Screens/Edit/AutoGenerateSection.cs
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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.Localisation; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Screens.Edit; | ||
|
||
public abstract partial class AutoGenerateSection : EditorSection | ||
{ | ||
protected sealed override LocalisableString Title => "Auto generate"; | ||
|
||
protected AutoGenerateSection() | ||
{ | ||
Children = new[] | ||
{ | ||
CreateAutoGenerateSubsection() | ||
}; | ||
} | ||
|
||
protected abstract AutoGenerateSubsection CreateAutoGenerateSubsection(); | ||
} |
152 changes: 152 additions & 0 deletions
152
osu.Game.Rulesets.Karaoke/Screens/Edit/AutoGenerateSubsection.cs
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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Extensions; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Cursor; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Framework.Graphics.UserInterface; | ||
using osu.Game.Graphics.UserInterface; | ||
using osu.Game.Graphics.UserInterfaceV2; | ||
using osu.Game.Rulesets.Karaoke.Configuration; | ||
using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; | ||
using osuTK; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Screens.Edit; | ||
|
||
public abstract partial class AutoGenerateSubsection : FillFlowContainer | ||
{ | ||
private const int horizontal_padding = 20; | ||
|
||
protected AutoGenerateSubsection() | ||
{ | ||
RelativeSizeAxes = Axes.X; | ||
AutoSizeAxes = Axes.Y; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load() | ||
{ | ||
// should wait until BDL in the parent class has been loaded. | ||
Schedule(() => | ||
{ | ||
Children = new Drawable[] | ||
{ | ||
new GridContainer | ||
{ | ||
AutoSizeAxes = Axes.Y, | ||
RelativeSizeAxes = Axes.X, | ||
ColumnDimensions = new[] | ||
{ | ||
new Dimension(), | ||
new Dimension(GridSizeMode.Absolute, 5), | ||
new Dimension(GridSizeMode.Absolute, 36) | ||
}, | ||
RowDimensions = new[] | ||
{ | ||
new Dimension(GridSizeMode.AutoSize) | ||
}, | ||
Content = new[] | ||
{ | ||
new Drawable?[] | ||
{ | ||
CreateGenerateButton(), | ||
null, | ||
CreateConfigButton().With(x => | ||
{ | ||
x.Anchor = Anchor.Centre; | ||
x.Origin = Anchor.Centre; | ||
x.Size = new Vector2(36); | ||
}) | ||
} | ||
}, | ||
}, | ||
CreateDescriptionTextFlowContainer().With(x => | ||
{ | ||
x.RelativeSizeAxes = Axes.X; | ||
x.AutoSizeAxes = Axes.Y; | ||
x.Padding = new MarginPadding { Horizontal = horizontal_padding }; | ||
x.Description = CreateInvalidLyricDescriptionFormat(); | ||
}) | ||
}; | ||
}); | ||
} | ||
|
||
protected abstract OsuButton CreateGenerateButton(); | ||
|
||
protected virtual DescriptionTextFlowContainer CreateDescriptionTextFlowContainer() => new(); | ||
|
||
protected abstract DescriptionFormat CreateInvalidLyricDescriptionFormat(); | ||
|
||
protected abstract ConfigButton CreateConfigButton(); | ||
|
||
protected abstract partial class ConfigButton : IconButton, IHasPopover | ||
{ | ||
protected ConfigButton() | ||
{ | ||
Icon = FontAwesome.Solid.Cog; | ||
Action = openConfigSetting; | ||
|
||
void openConfigSetting() | ||
=> this.ShowPopover(); | ||
} | ||
|
||
public abstract Popover GetPopover(); | ||
} | ||
|
||
protected abstract partial class MultiConfigButton : ConfigButton | ||
{ | ||
private KaraokeRulesetEditGeneratorSetting? selectedSetting; | ||
|
||
protected MultiConfigButton() | ||
{ | ||
Action = this.ShowPopover; | ||
} | ||
|
||
public override Popover GetPopover() | ||
{ | ||
if (selectedSetting == null) | ||
return createSelectionPopover(); | ||
|
||
return GetPopoverBySettingType(selectedSetting.Value); | ||
} | ||
|
||
protected abstract IEnumerable<KaraokeRulesetEditGeneratorSetting> AvailableSettings { get; } | ||
|
||
protected abstract string GetDisplayName(KaraokeRulesetEditGeneratorSetting setting); | ||
|
||
protected abstract Popover GetPopoverBySettingType(KaraokeRulesetEditGeneratorSetting setting); | ||
|
||
private Popover createSelectionPopover() | ||
=> new OsuPopover | ||
{ | ||
Child = new FillFlowContainer<OsuButton> | ||
{ | ||
AutoSizeAxes = Axes.Both, | ||
Direction = FillDirection.Vertical, | ||
Spacing = new Vector2(10), | ||
Children = AvailableSettings.Select(x => | ||
{ | ||
string name = GetDisplayName(x); | ||
return new OsuButton | ||
{ | ||
Text = name, | ||
Width = 150, | ||
Action = () => | ||
{ | ||
selectedSetting = x; | ||
this.ShowPopover(); | ||
|
||
// after show config pop-over, should make the state back for able to show this dialog next time. | ||
selectedSetting = null; | ||
}, | ||
}; | ||
}).ToList() | ||
} | ||
}; | ||
} | ||
} |
187 changes: 0 additions & 187 deletions
187
osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/AutoGenerateSubsection.cs
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.