Skip to content

Commit

Permalink
Merge pull request #1810 from andy840119/refactor-some-editor-parts
Browse files Browse the repository at this point in the history
Refactor some editor parts.
  • Loading branch information
andy840119 authored Dec 24, 2022
2 parents 69d4a98 + 85d6dfc commit c735b37
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ private void load()
x.RelativeSizeAxes = Axes.X;
x.AutoSizeAxes = Axes.Y;
x.Padding = new MarginPadding { Horizontal = horizontal_padding };
x.Description = CreateInvalidLyricDescriptionFormat();
x.Description = CreateInvalidDescriptionFormat();
})
};
});
}

protected abstract OsuButton CreateGenerateButton();
protected abstract EditorSectionButton CreateGenerateButton();

protected virtual DescriptionTextFlowContainer CreateDescriptionTextFlowContainer() => new();

protected abstract DescriptionFormat CreateInvalidLyricDescriptionFormat();
protected abstract DescriptionFormat CreateInvalidDescriptionFormat();

protected abstract ConfigButton CreateConfigButton();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Configs.Generator.Lyri
{
public partial class ReferenceLyricGeneratorConfigDialog : GeneratorConfigDialog<ReferenceLyricDetectorConfig>
{
protected override KaraokeRulesetEditGeneratorSetting Config => KaraokeRulesetEditGeneratorSetting.NoteGeneratorConfig;
protected override KaraokeRulesetEditGeneratorSetting Config => KaraokeRulesetEditGeneratorSetting.ReferenceLyricDetectorConfig;

protected override OverlayColourScheme OverlayColourScheme => OverlayColourScheme.Green;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public LanguageAutoGenerateSubsection()
{
}

protected override DescriptionFormat CreateInvalidLyricDescriptionFormat()
protected override DescriptionFormat CreateInvalidDescriptionFormat()
=> new()
{
Text = $"Seems some lyric has no texts, go to [{DescriptionFormat.LINK_KEY_ACTION}]({typing_mode}) to fill the text.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Diagnostics.CodeAnalysis;
using osu.Framework.Allocation;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Components.Markdown;
Expand All @@ -22,7 +21,7 @@ protected LyricEditorAutoGenerateSubsection(LyricAutoGenerateProperty autoGenera
this.autoGenerateProperty = autoGenerateProperty;
}

protected override OsuButton CreateGenerateButton()
protected override EditorSectionButton CreateGenerateButton()
=> new AutoGenerateButton(autoGenerateProperty);

protected sealed override DescriptionTextFlowContainer CreateDescriptionTextFlowContainer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public NoteAutoGenerateSubsection()
{
}

protected override DescriptionFormat CreateInvalidLyricDescriptionFormat()
protected override DescriptionFormat CreateInvalidDescriptionFormat()
=> new()
{
Text = $"Seems some lyric contains invalid time-tag, go to [{DescriptionFormat.LINK_KEY_ACTION}]({create_time_tag_mode}) to fix those issue.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ReferenceLyricAutoGenerateSubsection()
{
}

protected override DescriptionFormat CreateInvalidLyricDescriptionFormat()
protected override DescriptionFormat CreateInvalidDescriptionFormat()
=> new()
{
Text = "Seems every lyrics in the songs are unique. But don't worry, reference lyric can still link by hands."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Objects.Types;
Expand All @@ -21,7 +20,7 @@

namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji.Components
{
public partial class CreateNewTextTagButton<TTextTag> : OsuButton, IHasPopover where TTextTag : class, ITextTag, new()
public partial class CreateNewTextTagButton<TTextTag> : EditorSectionButton, IHasPopover where TTextTag : class, ITextTag, new()
{
public new Action<TTextTag> Action;

Expand All @@ -34,8 +33,6 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRo

public CreateNewTextTagButton()
{
RelativeSizeAxes = Axes.X;
Content.CornerRadius = 15;
base.Action = this.ShowPopover;
}

Expand Down Expand Up @@ -151,13 +148,8 @@ private void submit()
});
}

private partial class AddButton : OsuButton
private partial class AddButton : EditorSectionButton
{
public AddButton()
{
RelativeSizeAxes = Axes.X;
Content.CornerRadius = 15;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected TextTagAutoGenerateSubsection(LyricAutoGenerateProperty autoGeneratePr
{
}

protected override DescriptionFormat CreateInvalidLyricDescriptionFormat()
protected override DescriptionFormat CreateInvalidDescriptionFormat()
=> new()
{
Text = $"Seems some lyric missing language, go to [{DescriptionFormat.LINK_KEY_ACTION}]({language_mode}) to fill the language.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States;

namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings
{
public abstract partial class SelectLyricButton : OsuButton
public abstract partial class SelectLyricButton : EditorSectionButton
{
private IBindable<bool> selecting;

Expand All @@ -36,12 +34,6 @@ protected virtual void Cancel() { }
[Resolved]
private ILyricSelectionState lyricSelectionState { get; set; }

protected SelectLyricButton()
{
RelativeSizeAxes = Axes.X;
Content.CornerRadius = 15;
}

[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public TimeTageAutoGenerateSubsection()
{
}

protected override DescriptionFormat CreateInvalidLyricDescriptionFormat()
protected override DescriptionFormat CreateInvalidDescriptionFormat()
=> new()
{
Text = $"Seems some lyric missing language, go to [{DescriptionFormat.LINK_KEY_ACTION}]({language_mode}) to fill the language.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Components.Markdown;
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States;
using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown;
Expand Down Expand Up @@ -179,15 +178,13 @@ private DescriptionFormat getDescription(CreateTimeTagEditMode mode) =>
_ => throw new InvalidOperationException(nameof(mode))
};

private partial class EditModeButton : OsuButton
private partial class EditModeButton : EditorSectionButton
{
public CreateTimeTagEditMode Mode { get; }

public EditModeButton(CreateTimeTagEditMode mode)
{
Mode = mode;
RelativeSizeAxes = Axes.X;
Content.CornerRadius = 15;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas;
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Beatmaps;
using osu.Game.Rulesets.Karaoke.Edit.Utils;
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Pages.Settings;
using osu.Game.Screens.Edit;

namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Pages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Pages;
namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Pages.Settings;

public partial class PageEditorEditModeSection : EditModeSection<PageEditorEditMode>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Issues;
using osuTK;

namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Pages;
namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Pages.Settings;

public partial class PageEditorIssueSection : IssueSection
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using osu.Framework.Graphics;
using osu.Game.Overlays;

namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Pages;
namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Pages.Settings;

public partial class PageSettings : EditorSettings
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas;
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Beatmaps;
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Components.UserInterface;
using osu.Game.Screens.Edit;
using osuTK;

namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Pages;
namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Pages.Settings;

public partial class PagesSection : EditorSection
{
Expand Down Expand Up @@ -158,7 +157,7 @@ private void load(OsuColour colour, IPageStateProvider pageStateProvider)
}
}

private partial class CreateNewPageButton : OsuButton
private partial class CreateNewPageButton : EditorSectionButton
{
[Resolved, AllowNull]
private IBeatmapPagesChangeHandler beatmapPagesChangeHandler { get; set; }
Expand All @@ -168,8 +167,6 @@ private partial class CreateNewPageButton : OsuButton

public CreateNewPageButton()
{
RelativeSizeAxes = Axes.X;
Content.CornerRadius = 15;
Text = "Create new page";
Action = () =>
{
Expand Down
6 changes: 1 addition & 5 deletions osu.Game.Rulesets.Karaoke/Screens/Edit/EditModeSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Overlays.Toolbar;
using osu.Game.Rulesets.Edit.Checks.Components;
Expand Down Expand Up @@ -119,17 +118,14 @@ internal virtual void UpdateEditMode(TEditMode mode)

protected abstract DescriptionFormat GetSelectionDescription(TEditMode mode);

protected partial class Selection : OsuButton
protected partial class Selection : EditorSectionButton
{
public new Action<TEditMode> Action;

public TEditMode Mode { get; set; }

public Selection()
{
RelativeSizeAxes = Axes.X;
Content.CornerRadius = 15;

base.Action = () => Action?.Invoke(Mode);
}
}
Expand Down
16 changes: 16 additions & 0 deletions osu.Game.Rulesets.Karaoke/Screens/Edit/EditorSectionButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.Graphics;
using osu.Game.Graphics.UserInterface;

namespace osu.Game.Rulesets.Karaoke.Screens.Edit;

public abstract partial class EditorSectionButton : OsuButton
{
protected EditorSectionButton()
{
RelativeSizeAxes = Axes.X;
Content.CornerRadius = 15;
}
}

0 comments on commit c735b37

Please sign in to comment.