Skip to content

Commit

Permalink
Should wrap into the section for the same style as edit detail popove…
Browse files Browse the repository at this point in the history
…r in the singer editor.
  • Loading branch information
andy840119 committed Sep 11, 2022
1 parent 92b3f56 commit 731639e
Showing 1 changed file with 81 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,98 +3,119 @@

#nullable disable

using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Notes;
using osu.Game.Rulesets.Karaoke.Edit.Components.Containers;
using osu.Game.Rulesets.Karaoke.Objects;

namespace osu.Game.Rulesets.Karaoke.Edit.Components.UserInterfaceV2
{
public class NoteEditPopover : OsuPopover
{
[Resolved(canBeNull: true)]
private INotePropertyChangeHandler notePropertyChangeHandler { get; set; }

public NoteEditPopover(Note note)
{
LabelledTextBox text;
LabelledTextBox rubyText;
LabelledSwitchButton display;
if (note == null)
throw new ArgumentNullException(nameof(note));

Children = new Drawable[]
Child = new OsuScrollContainer
{
new FillFlowContainer
Height = 320,
Width = 300,
Child = new FillFlowContainer<Section>
{
Width = 200,
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
Children = new Section[]
{
text = new LabelledTextBox
{
Label = "Text",
Description = "The text display on the note.",
Current = note.TextBindable,
TabbableContentContainer = this
},
rubyText = new LabelledTextBox
{
Label = "Ruby text",
Description = "Should place something like ruby, 拼音 or ふりがな.",
Current = note.RubyTextBindable,
TabbableContentContainer = this
},
display = new LabelledSwitchButton
{
Label = "Display",
Description = "This note will be hidden and not scorable if not display.",
Current = note.DisplayBindable,
}
new NoteSection(note),
}
}
};
}

ScheduleAfterChildren(() =>
{
GetContainingInputManager().ChangeFocus(text);
});
private class NoteSection : Section
{
private INotePropertyChangeHandler notePropertyChangeHandler { get; set; }

text.OnCommit += (sender, newText) =>
protected override LocalisableString Title => "Note property";

public NoteSection(Note note)
{
if (!newText)
return;
LabelledTextBox text;
LabelledTextBox rubyText;
LabelledSwitchButton display;

string text = sender.Text.Trim();
notePropertyChangeHandler?.ChangeText(text);
};
Children = new Drawable[]
{
text = new LabelledTextBox
{
Label = "Text",
Description = "The text display on the note.",
Current = note.TextBindable,
TabbableContentContainer = this
},
rubyText = new LabelledTextBox
{
Label = "Ruby text",
Description = "Should place something like ruby, 拼音 or ふりがな.",
Current = note.RubyTextBindable,
TabbableContentContainer = this
},
display = new LabelledSwitchButton
{
Label = "Display",
Description = "This note will be hidden and not scorable if not display.",
Current = note.DisplayBindable,
}
};

rubyText.OnCommit += (sender, newText) =>
{
if (!newText)
return;
ScheduleAfterChildren(() =>
{
GetContainingInputManager().ChangeFocus(text);
});

string text = sender.Text.Trim();
notePropertyChangeHandler?.ChangeRubyText(text);
};
text.OnCommit += (sender, newText) =>
{
if (!newText)
return;

display.Current.BindValueChanged(v =>
{
notePropertyChangeHandler?.ChangeDisplayState(v.NewValue);
});
}
string text = sender.Text.Trim();
notePropertyChangeHandler?.ChangeText(text);
};

[BackgroundDependencyLoader(true)]
private void load(HitObjectComposer composer)
{
if (notePropertyChangeHandler != null || composer == null)
return;
rubyText.OnCommit += (sender, newText) =>
{
if (!newText)
return;

string text = sender.Text.Trim();
notePropertyChangeHandler?.ChangeRubyText(text);
};

display.Current.BindValueChanged(v =>
{
notePropertyChangeHandler?.ChangeDisplayState(v.NewValue);
});
}

[BackgroundDependencyLoader(true)]
private void load(HitObjectComposer composer)
{
if (notePropertyChangeHandler != null || composer == null)
return;

// todo: not a good way to get change handler, might remove or found another way eventually.
// cannot get change handler directly in editor screen, so should trying to get from karaoke hit object composer.
notePropertyChangeHandler = composer.Dependencies.Get<INotePropertyChangeHandler>();
// todo: not a good way to get change handler, might remove or found another way eventually.
// cannot get change handler directly in editor screen, so should trying to get from karaoke hit object composer.
notePropertyChangeHandler = composer.Dependencies.Get<INotePropertyChangeHandler>();
}
}
}
}

0 comments on commit 731639e

Please sign in to comment.